1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
|
/**
@file LocationInfo.h
@brief Contains the infrastructure for APRS based EchoLink status updates
@author Adi/DL1HRC and Steve/DH1DM
@date 2009-03-12
\verbatim
SvxLink - A Multi Purpose Voice Services System for Ham Radio Use
Copyright (C) 2003-2015 Tobias Blomberg / SM0SVX
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\endverbatim
*/
#ifndef LOCATION_INFO_INCLUDED
#define LOCATION_INFO_INCLUDED
/****************************************************************************
*
* System Includes
*
****************************************************************************/
#include <string>
#include <vector>
#include <list>
/****************************************************************************
*
* Project Includes
*
****************************************************************************/
#include <AsyncConfig.h>
#include <EchoLinkStationData.h>
/****************************************************************************
*
* Local Includes
*
****************************************************************************/
#include "AprsPty.h"
/****************************************************************************
*
* Forward declarations
*
****************************************************************************/
class AprsClient;
/****************************************************************************
*
* Namespace
*
****************************************************************************/
/****************************************************************************
*
* Forward declarations of classes inside of the declared namespace
*
****************************************************************************/
/****************************************************************************
*
* Defines & typedefs
*
****************************************************************************/
/****************************************************************************
*
* Exported Global Types
*
****************************************************************************/
/****************************************************************************
*
* Class definitions
*
****************************************************************************/
class LocationInfo
{
public:
static LocationInfo* instance()
{
static CGuard g;
if (!_instance)
return NULL; // illegal pointer, if not initialized
return _instance;
}
static bool has_instance()
{
return _instance;
}
struct Coordinate
{
explicit Coordinate(char d = 'N') : deg(0), min(0), sec(0), dir(d) {};
unsigned int deg, min, sec;
char dir;
};
std::string getCallsign();
struct AprsStatistics
{
std::string logic_name;
unsigned rx_on_nr;
unsigned tx_on_nr;
float rx_sec;
float tx_sec;
struct timeval last_rx_sec;
struct timeval last_tx_sec;
bool tx_on;
bool squelch_on;
AprsStatistics(void) : rx_on_nr(0), tx_on_nr(0), rx_sec(0), tx_sec(0),
last_rx_sec(), last_tx_sec(), tx_on(false),
squelch_on(false) {}
void reset(void)
{
rx_on_nr = 0;
tx_on_nr = 0;
rx_sec = 0;
tx_sec = 0;
last_tx_sec.tv_sec = 0;
last_rx_sec.tv_sec = 0;
last_tx_sec.tv_usec = 0;
last_rx_sec.tv_usec = 0;
}
};
typedef std::map<std::string, AprsStatistics> aprs_struct;
aprs_struct aprs_stats;
struct Cfg
{
Cfg() : interval(600000), frequency(0), power(0), tone(0), height(10),
gain(0), beam_dir(-1), range(0), range_unit('m'), lat_pos('N'),
lon_pos('E') {};
unsigned int interval;
unsigned int frequency;
unsigned int power;
unsigned int tone;
unsigned int height;
unsigned int gain;
int beam_dir;
unsigned int range;
char range_unit;
Coordinate lat_pos;
Coordinate lon_pos;
std::string mycall;
std::string prefix;
std::string path;
std::string comment;
};
static bool initialize(const Async::Config &cfg, const std::string &cfg_name);
void updateDirectoryStatus(EchoLink::StationData::Status new_status);
void igateMessage(const std::string& info);
void update3rdState(const std::string& call, const std::string& info);
void updateQsoStatus(int action, const std::string& call,
const std::string& name,
std::list<std::string>& call_list);
bool getTransmitting(const std::string &name);
void setTransmitting(const std::string &name, struct timeval tv, bool state);
void setReceiving(const std::string &name, struct timeval tv, bool state);
class CGuard
{
public:
~CGuard()
{
if(NULL != LocationInfo::_instance)
{
delete LocationInfo::_instance;
LocationInfo::_instance = NULL;
}
}
};
friend class CGuard;
private:
static LocationInfo* _instance;
LocationInfo() : sequence(0), aprs_stats_timer(0), sinterval(0) {}
LocationInfo(const LocationInfo&);
~LocationInfo(void) { delete aprs_stats_timer; };
typedef std::list<AprsClient*> ClientList;
Cfg loc_cfg; // weshalb?
ClientList clients;
int sequence;
Async::Timer *aprs_stats_timer;
unsigned int sinterval;
bool parsePosition(const Async::Config &cfg, const std::string &name);
bool parseLatitude(Coordinate &pos, const std::string &value);
bool parseLongitude(Coordinate &pos, const std::string &value);
bool parseStationHW(const Async::Config &cfg, const std::string &name);
bool parsePath(const Async::Config &cfg, const std::string &name);
int calculateRange(const Cfg &cfg);
bool parseAntennaHeight(Cfg &cfg, const std::string value);
bool parseClientStr(std::string &host, int &port, const std::string &val);
bool parseClients(const Async::Config &cfg, const std::string &name);
void startStatisticsTimer(int interval);
void sendAprsStatistics(Async::Timer *t);
void initExtPty(std::string ptydevice);
void mesReceived(std::string message);
}; /* class LocationInfo */
#endif /* LOCATION_INFO_INCLUDED */
/*
* This file has not been truncated
*/
|