#8 Simplify and add language suport to APRS status

pull/11/head
Geoffrey Merck 4 years ago
parent 79fda5fc4c
commit eaa2c74154

@ -90,7 +90,7 @@ CAPRSCollector* CAPRSEntry::getCollector() const
return m_collector;
}
CAPRSEntryLinkStatus& CAPRSEntry::getLinkStatus()
CAPRSEntryStatus& CAPRSEntry::getStatus()
{
return m_linkStatus;
}

@ -22,7 +22,7 @@
#include <string>
#include "APRSCollector.h"
#include "APRSEntryLinkStatus.h"
#include "APRSEntryStatus.h"
#include "Timer.h"
#include "Defs.h"
@ -40,7 +40,7 @@ public:
double getLongitude() const;
double getAGL() const;
CAPRSCollector* getCollector() const;
CAPRSEntryLinkStatus& getLinkStatus();
CAPRSEntryStatus& getStatus();
// Transmission timer
void reset();
@ -59,5 +59,5 @@ private:
CTimer m_timer;
bool m_first;
CAPRSCollector* m_collector;
CAPRSEntryLinkStatus m_linkStatus;
CAPRSEntryStatus m_linkStatus;
};

@ -16,49 +16,39 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "APRSEntryLinkStatus.h"
#include "APRSEntryStatus.h"
CAPRSEntryLinkStatus::CAPRSEntryLinkStatus() :
m_linkStatus(LS_NONE),
m_linkDestination(),
m_linkStatusChanged(false),
CAPRSEntryStatus::CAPRSEntryStatus() :
m_status(),
m_statusChanged(false),
m_timer(1000U)
{
m_timer.setTimeout(20U * 60U); //statuses go out every 20 minutes or every change
}
bool CAPRSEntryLinkStatus::isOutOfDate()
bool CAPRSEntryStatus::isOutOfDate()
{
return m_linkStatusChanged || m_timer.hasExpired();
bool ouOfDate = m_statusChanged || m_timer.hasExpired();
m_statusChanged = false;
return ouOfDate;
}
std::string CAPRSEntryLinkStatus::getLinkDestination() const
{
return m_linkDestination;
}
LINK_STATUS CAPRSEntryLinkStatus::getLinkStatus() const
std::string CAPRSEntryStatus::getStatus() const
{
return m_linkStatus;
return m_status;
}
void CAPRSEntryLinkStatus::setLink(LINK_STATUS linkstatus, const std::string& destination)
void CAPRSEntryStatus::setStatus(const std::string& linkstatus)
{
bool changed = m_linkStatus != linkstatus || m_linkDestination != destination;
bool changed = m_status != linkstatus;
if(changed) {
m_linkStatus = linkstatus;
m_linkDestination = destination;
m_status = linkstatus;
}
m_linkStatusChanged = changed;
}
void CAPRSEntryLinkStatus::reset()
{
m_linkStatusChanged = false;
m_timer.start();
m_statusChanged = changed;
}
void CAPRSEntryLinkStatus::clock(unsigned int ms)
void CAPRSEntryStatus::clock(unsigned int ms)
{
m_timer.clock(ms);
}

@ -18,24 +18,22 @@
#pragma once
#include <string>
#include "Timer.h"
#include "Defs.h"
class CAPRSEntryLinkStatus
class CAPRSEntryStatus
{
public:
CAPRSEntryLinkStatus() ;
CAPRSEntryStatus() ;
LINK_STATUS getLinkStatus() const;
std::string getLinkDestination() const;
std::string getStatus() const;
bool isOutOfDate();
void setLink(LINK_STATUS linkstatus, const std::string& destination);
void reset();
void setStatus(const std::string& destination);
void clock(unsigned int ms);
private:
LINK_STATUS m_linkStatus;
std::string m_linkDestination;
bool m_linkStatusChanged;
std::string m_status;
bool m_statusChanged;
CTimer m_timer;
};

@ -158,7 +158,7 @@ void CAPRSWriter::writeData(const std::string& callsign, const CAMBEData& data)
collector->reset();
}
void CAPRSWriter::writeLinkStatus(const std::string& callsign, LINK_STATUS status, const std::string& destination)
void CAPRSWriter::writeStatus(const std::string& callsign, const std::string status)
{
CAPRSEntry* entry = m_array[callsign];
if (entry == NULL) {
@ -166,7 +166,7 @@ void CAPRSWriter::writeLinkStatus(const std::string& callsign, LINK_STATUS statu
return;
}
entry->getLinkStatus().setLink(status, destination);
entry->getStatus().setStatus(status);
}
void CAPRSWriter::clock(unsigned int ms)
@ -183,7 +183,7 @@ void CAPRSWriter::clock(unsigned int ms)
for (auto it : m_array) {
if(it.second != NULL) {
it.second->clock(ms);
if(it.second->getLinkStatus().isOutOfDate())
if(it.second->getStatus().isOutOfDate())
sendStatusFrame(it.second);
}
}
@ -193,36 +193,14 @@ void CAPRSWriter::sendStatusFrame(CAPRSEntry * entry)
{
assert(entry != nullptr);
// 20211231 TODO F4FXL support different languages
if(!m_thread->isConnected())
return;
auto linkStatus = entry->getLinkStatus();
std::string body;
auto linkStatus = entry->getStatus();
std::string body = boost::trim_copy(linkStatus.getStatus());
switch (linkStatus.getLinkStatus())
{
case LS_LINKED_DCS:
case LS_LINKED_CCS:
case LS_LINKED_DEXTRA:
case LS_LINKED_DPLUS:
case LS_LINKED_LOOPBACK:
body = ">Linked to " + linkStatus.getLinkDestination();
break;
case LS_LINKING_DCS:
case LS_LINKING_CCS:
case LS_LINKING_DEXTRA:
case LS_LINKING_DPLUS:
case LS_LINKING_LOOPBACK:
body = ">Linking to " + linkStatus.getLinkDestination();;
break;
default:
body = ">Not linked";
break;
}
if(body[0] != '>')
body = '>' + body;
std::string output = CStringUtils::string_format("%s-%s>APD5T3,TCPIP*,qAC,%s-%sS:%s\r\n",
entry->getCallsign().c_str(), entry->getBand().c_str(), entry->getCallsign().c_str(), entry->getBand().c_str(),
@ -230,7 +208,6 @@ void CAPRSWriter::sendStatusFrame(CAPRSEntry * entry)
m_thread->write(output.c_str());
linkStatus.reset();
}
void CAPRSWriter::sendIdFrames()

@ -51,7 +51,7 @@ public:
void writeData(const std::string& callsign, const CAMBEData& data);
void writeLinkStatus(const std::string& callsign, LINK_STATUS status, const std::string& destination);
void writeStatus(const std::string& callsign, const std::string status);
bool isConnected() const;

@ -2564,7 +2564,7 @@ void CRepeaterHandler::writeLinkingTo(const std::string &callsign)
triggerInfo();
if(m_aprsWriter != nullptr)
m_aprsWriter->writeLinkStatus(m_rptCallsign, m_linkStatus, callsign);
m_aprsWriter->writeStatus(m_rptCallsign, text);
#ifdef USE_CCS
m_ccsHandler->setReflector();
@ -2619,7 +2619,7 @@ void CRepeaterHandler::writeLinkedTo(const std::string &callsign)
triggerInfo();
if(m_aprsWriter != nullptr)
m_aprsWriter->writeLinkStatus(m_rptCallsign, m_linkStatus, callsign);
m_aprsWriter->writeStatus(m_rptCallsign, text);
#ifdef USE_CCS
m_ccsHandler->setReflector(callsign);
@ -2674,7 +2674,7 @@ void CRepeaterHandler::writeNotLinked()
triggerInfo();
if(m_aprsWriter != nullptr)
m_aprsWriter->writeLinkStatus(m_rptCallsign, m_linkStatus, "");
m_aprsWriter->writeStatus(m_rptCallsign, text);
#ifdef USE_CCS
m_ccsHandler->setReflector();
@ -2745,7 +2745,7 @@ void CRepeaterHandler::writeIsBusy(const std::string& callsign)
triggerInfo();
if(m_aprsWriter != nullptr)
m_aprsWriter->writeLinkStatus(m_rptCallsign, m_linkStatus, callsign);
m_aprsWriter->writeStatus(m_rptCallsign, text);
#ifdef USE_CCS
m_ccsHandler->setReflector();

Loading…
Cancel
Save

Powered by TurnKey Linux.