#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; return m_collector;
} }
CAPRSEntryLinkStatus& CAPRSEntry::getLinkStatus() CAPRSEntryStatus& CAPRSEntry::getStatus()
{ {
return m_linkStatus; return m_linkStatus;
} }

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

@ -16,49 +16,39 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "APRSEntryLinkStatus.h" #include "APRSEntryStatus.h"
CAPRSEntryLinkStatus::CAPRSEntryLinkStatus() : CAPRSEntryStatus::CAPRSEntryStatus() :
m_linkStatus(LS_NONE), m_status(),
m_linkDestination(), m_statusChanged(false),
m_linkStatusChanged(false),
m_timer(1000U) m_timer(1000U)
{ {
m_timer.setTimeout(20U * 60U); //statuses go out every 20 minutes or every change 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) { if(changed) {
m_linkStatus = linkstatus; m_status = linkstatus;
m_linkDestination = destination;
} }
m_linkStatusChanged = changed; m_statusChanged = changed;
}
void CAPRSEntryLinkStatus::reset()
{
m_linkStatusChanged = false;
m_timer.start();
} }
void CAPRSEntryLinkStatus::clock(unsigned int ms) void CAPRSEntryStatus::clock(unsigned int ms)
{ {
m_timer.clock(ms); m_timer.clock(ms);
} }

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

@ -158,7 +158,7 @@ void CAPRSWriter::writeData(const std::string& callsign, const CAMBEData& data)
collector->reset(); 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]; CAPRSEntry* entry = m_array[callsign];
if (entry == NULL) { if (entry == NULL) {
@ -166,7 +166,7 @@ void CAPRSWriter::writeLinkStatus(const std::string& callsign, LINK_STATUS statu
return; return;
} }
entry->getLinkStatus().setLink(status, destination); entry->getStatus().setStatus(status);
} }
void CAPRSWriter::clock(unsigned int ms) void CAPRSWriter::clock(unsigned int ms)
@ -183,7 +183,7 @@ void CAPRSWriter::clock(unsigned int ms)
for (auto it : m_array) { for (auto it : m_array) {
if(it.second != NULL) { if(it.second != NULL) {
it.second->clock(ms); it.second->clock(ms);
if(it.second->getLinkStatus().isOutOfDate()) if(it.second->getStatus().isOutOfDate())
sendStatusFrame(it.second); sendStatusFrame(it.second);
} }
} }
@ -193,36 +193,14 @@ void CAPRSWriter::sendStatusFrame(CAPRSEntry * entry)
{ {
assert(entry != nullptr); assert(entry != nullptr);
// 20211231 TODO F4FXL support different languages
if(!m_thread->isConnected()) if(!m_thread->isConnected())
return; return;
auto linkStatus = entry->getLinkStatus(); auto linkStatus = entry->getStatus();
std::string body; std::string body = boost::trim_copy(linkStatus.getStatus());
switch (linkStatus.getLinkStatus()) if(body[0] != '>')
{ body = '>' + body;
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;
}
std::string output = CStringUtils::string_format("%s-%s>APD5T3,TCPIP*,qAC,%s-%sS:%s\r\n", 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(), 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()); m_thread->write(output.c_str());
linkStatus.reset();
} }
void CAPRSWriter::sendIdFrames() void CAPRSWriter::sendIdFrames()

@ -51,7 +51,7 @@ public:
void writeData(const std::string& callsign, const CAMBEData& data); 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; bool isConnected() const;

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

Loading…
Cancel
Save

Powered by TurnKey Linux.