libdrmconf  0.12.0
A library to program DMR radios.
gpssystem.hh
1 #ifndef GPSSYSTEM_H
2 #define GPSSYSTEM_H
3 
4 #include "configreference.hh"
5 #include <QAbstractTableModel>
6 #include "anytone_extension.hh"
7 
8 class Config;
9 class DMRContact;
10 class DMRChannel;
11 class FMChannel;
12 
13 
17 {
18  Q_OBJECT
19  Q_CLASSINFO("IdPrefix", "aprs")
20 
21 
22  Q_PROPERTY(unsigned period READ period WRITE setPeriod)
23 
24 protected:
26  explicit PositioningSystem(QObject *parent=nullptr);
33  PositioningSystem(const QString &name, unsigned period=300, QObject *parent=nullptr);
34 
35 public:
37  virtual ~PositioningSystem();
38 
40  unsigned period() const;
42  void setPeriod(unsigned period);
43 
44 public:
45  bool parse(const YAML::Node &node, Context &ctx, const ErrorStack &err=ErrorStack());
46  bool link(const YAML::Node &node, const Context &ctx, const ErrorStack &err=ErrorStack());
47 
48 protected:
49  bool populate(YAML::Node &node, const ConfigItem::Context &context, const ErrorStack &err=ErrorStack());
50 
51 protected slots:
53  void onReferenceModified();
54 
55 protected:
57  unsigned _period;
58 };
59 
60 
64 {
65  Q_OBJECT
66 
68  Q_PROPERTY(DMRContactReference* contact READ contact WRITE setContact)
70  Q_PROPERTY(DMRChannelReference* revert READ revert WRITE setRevert)
71 
72 public:
74  Q_INVOKABLE explicit GPSSystem(QObject *parent=nullptr);
85  GPSSystem(const QString &name, DMRContact *contact=nullptr,
86  DMRChannel *revertChannel = nullptr, unsigned period=300,
87  QObject *parent = nullptr);
88 
89  ConfigItem *clone() const;
90 
92  bool hasContact() const;
94  DMRContact *contactObj() const;
98  const DMRContactReference *contact() const;
103 
106  bool hasRevertChannel() const;
108  DMRChannel *revertChannel() const;
110  void setRevertChannel(DMRChannel *channel);
112  const DMRChannelReference *revert() const;
116  void setRevert(DMRChannelReference *channel);
117 
118 public:
119  YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack());
120 
121 protected:
126 };
127 
128 
132 {
133  Q_OBJECT
134 
136  Q_PROPERTY(FMChannelReference* revert READ revert WRITE setRevert)
138  Q_PROPERTY(Icon icon READ icon WRITE setIcon)
140  Q_PROPERTY(QString message READ message WRITE setMessage)
143 
144 public:
145  static const unsigned PRIMARY_TABLE = (0<<8);
146  static const unsigned SECONDARY_TABLE = (1<<8);
147  static const unsigned TABLE_MASK = (3<<8);
148  static const unsigned ICON_MASK = 0x7f;
149 
151  enum class Icon {
152  PoliceStation = (PRIMARY_TABLE | 0), None, Digipeater, Phone, DXCluster, HFGateway, SmallPlane,
153  MobileSatelliteStation, WheelChair, Snowmobile, RedCross, BoyScout, Home, X, RedDot,
154  Circle0, Circle1, Circle2, Circle3, Circle4, Circle5, Circle6, Circle7, Circle8, Circle9,
155  Fire, Campground, Motorcycle, RailEngine, Car, FileServer, HCFuture, AidStation, BBS, Canoe,
156  Eyeball = (PRIMARY_TABLE | 36), Tractor, GridSquare, Hotel, TCPIP, School = (PRIMARY_TABLE | 42),
157  Logon, MacOS, NTSStation, Balloon, PoliceCar, TBD, RV, Shuttle, SSTV, Bus, ATV, WXService, Helo,
158  Yacht, Windows, Jogger, Triangle, PBBS, LargePlane, WXStation, DishAntenna, Ambulance, Bike,
159  ICP, FireStation, Horse, FireTruck, Glider, Hospital, IOTA, Jeep, SmallTruck, Laptop, MicE,
160  Node, EOC, Rover, Grid, Antenna, PowerBoat, TruckStop, TruckLarge, Van, Water, XAPRS, Yagi,
161  Shelter
162  };
163  Q_ENUM(Icon)
164 
165 public:
167  Q_INVOKABLE explicit APRSSystem(QObject *parent=nullptr);
183  APRSSystem(const QString &name, FMChannel *channel, const QString &dest, unsigned destSSID,
184  const QString &src, unsigned srcSSID, const QString &path="", Icon icon=Icon::Jogger,
185  const QString &message="", unsigned period=300, QObject *parent=nullptr);
186 
187  bool copy(const ConfigItem &other);
188  ConfigItem *clone() const;
189 
191  FMChannel *revertChannel() const;
195  const FMChannelReference *revert() const;
199  void setRevert(FMChannelReference *ref);
200 
202  const QString &destination() const;
204  unsigned destSSID() const;
206  void setDestination(const QString &call, unsigned ssid);
207 
209  const QString &source() const;
211  unsigned srcSSID() const;
213  void setSource(const QString &call, unsigned ssid);
214 
216  const QString &path() const;
218  void setPath(const QString &path);
219 
221  Icon icon() const;
223  void setIcon(Icon icon);
224 
226  const QString &message() const;
228  void setMessage(const QString &msg);
229 
234 
235 public:
236  YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack());
237  bool parse(const YAML::Node &node, Context &ctx, const ErrorStack &err=ErrorStack());
238 
239 protected:
240  bool populate(YAML::Node &node, const Context &context, const ErrorStack &err=ErrorStack());
241 
242 protected:
246  QString _destination;
248  unsigned _destSSID;
250  QString _source;
252  unsigned _srcSSID;
254  QString _path;
258  QString _message;
261 };
262 
263 
267 {
268 Q_OBJECT
269 
270 public:
272  explicit PositioningSystems(QObject *parent=nullptr);
273 
275  PositioningSystem *system(int idx) const;
276 
277  int add(ConfigObject *obj, int row=-1, bool unique=true);
278 
280  int gpsCount() const;
283  int indexOfGPSSys(const GPSSystem *gps) const;
286  GPSSystem *gpsSystem(int idx) const;
287 
289  int aprsCount() const;
292  int indexOfAPRSSys(APRSSystem *gps) const;
295  APRSSystem *aprsSystem(int idx) const;
296 
297 public:
298  ConfigItem *allocateChild(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack());
299 };
300 
301 
302 #endif // GPSSYSTEM_H
Represents an APRS system within the generic config.
Definition: gpssystem.hh:132
AnytoneFMAPRSSettingsExtension * _anytone
Owns the Anytone settings extension.
Definition: gpssystem.hh:260
QString _source
Holds the source call.
Definition: gpssystem.hh:250
void setRevertChannel(FMChannel *revertChannel)
Sets the transmit channel of the APRS system.
Definition: gpssystem.cc:245
void setAnytoneExtension(AnytoneFMAPRSSettingsExtension *ext)
Sets the Anytone settings extension.
Definition: gpssystem.cc:326
Q_INVOKABLE APRSSystem(QObject *parent=nullptr)
Default constructor.
Definition: gpssystem.cc:196
static const unsigned ICON_MASK
Bitmask for the icon table entry.
Definition: gpssystem.hh:148
void setRevert(FMChannelReference *ref)
Sets the revert channel reference.
Definition: gpssystem.cc:260
AnytoneFMAPRSSettingsExtension * anytoneExtension() const
Returns the Anytone settings extension, if set.
Definition: gpssystem.cc:322
const QString & source() const
Returns the source call.
Definition: gpssystem.cc:279
QString _destination
Holds the destination call.
Definition: gpssystem.hh:246
void setIcon(Icon icon)
Sets the map icon.
Definition: gpssystem.cc:307
bool parse(const YAML::Node &node, Context &ctx, const ErrorStack &err=ErrorStack())
Parses the given YAML node, updates the given object and updates the given context (IDs).
Definition: gpssystem.cc:377
static const unsigned SECONDARY_TABLE
Secondary icon table flag.
Definition: gpssystem.hh:146
FMChannel * revertChannel() const
Returns the transmit channel of the APRS system.
Definition: gpssystem.cc:240
QString message
An optional text message.
Definition: gpssystem.hh:140
bool populate(YAML::Node &node, const Context &context, const ErrorStack &err=ErrorStack())
Recursively serializes the configuration to YAML nodes.
Definition: gpssystem.cc:348
void setPath(const QString &path)
Sets the APRS path.
Definition: gpssystem.cc:297
static const unsigned PRIMARY_TABLE
Primary icon table flag.
Definition: gpssystem.hh:145
const QString & destination() const
Returns the destination call.
Definition: gpssystem.cc:265
const QString & path() const
Returns the APRS path.
Definition: gpssystem.cc:293
unsigned _destSSID
Holds the destination SSID.
Definition: gpssystem.hh:248
YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack())
Recursively serializes the configuration to YAML nodes.
Definition: gpssystem.cc:339
AnytoneFMAPRSSettingsExtension * anytone
Anytone sepecific settings.
Definition: gpssystem.hh:142
QString _message
Holds the optional message.
Definition: gpssystem.hh:258
FMChannelReference _channel
A weak reference to the transmit channel.
Definition: gpssystem.hh:244
static const unsigned TABLE_MASK
Bitmask for icon table flags.
Definition: gpssystem.hh:147
unsigned _srcSSID
Holds the source SSID.
Definition: gpssystem.hh:252
void setDestination(const QString &call, unsigned ssid)
Sets the destination call and SSID.
Definition: gpssystem.cc:273
FMChannelReference * revert()
Returns a reference to the revert channel.
Icon icon
The APRS icon.
Definition: gpssystem.hh:138
unsigned srcSSID() const
Returns the source SSID.
Definition: gpssystem.cc:283
unsigned destSSID() const
Returns the destination SSID.
Definition: gpssystem.cc:269
FMChannelReference * revert
The transmit channel.
Definition: gpssystem.hh:136
void setMessage(const QString &msg)
Sets the optional APRS message text.
Definition: gpssystem.cc:316
QString _path
Holds the APRS path string.
Definition: gpssystem.hh:254
Icon _icon
Holds the map icon.
Definition: gpssystem.hh:256
ConfigItem * clone() const
Clones this item.
Definition: gpssystem.cc:230
bool copy(const ConfigItem &other)
Copies the given item into this one.
Definition: gpssystem.cc:217
void setSource(const QString &call, unsigned ssid)
Sets the source call and SSID.
Definition: gpssystem.cc:287
Icon
All implemented APRS icons.
Definition: gpssystem.hh:151
Implements some additional settings for the FM APRS system.
Definition: anytone_extension.hh:2351
Parse context for config objects.
Definition: configobject.hh:48
Base class for all configuration objects (channels, zones, contacts, etc).
Definition: configobject.hh:40
List class for config objects.
Definition: configobject.hh:349
Base class of all labeled and named objects.
Definition: configobject.hh:199
QString name
The name of the object.
Definition: configobject.hh:203
The config class, representing the codeplug configuration.
Definition: config.hh:70
Implements a reference to a DMR channel.
Definition: configreference.hh:139
Extension to the DigitalChannel class to implement an DMR channel.
Definition: channel.hh:354
Represents a reference to a DMR contact.
Definition: configreference.hh:99
Represents a digital contact, that is a DMR number.
Definition: contact.hh:141
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
Implements a reference to a FM channel.
Definition: configreference.hh:151
Extension to the AnalogChannel class to implement an analog FM channel.
Definition: channel.hh:210
This class represents a GPS signalling system within the codeplug.
Definition: gpssystem.hh:64
YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack())
Recursively serializes the configuration to YAML nodes.
Definition: gpssystem.cc:184
DMRChannel * revertChannel() const
Returns the revert channel for the GPS information or nullptr if not set.
Definition: gpssystem.cc:159
void setContact(DMRContactReference *contactObj)
Sets the reference to the destination contact for the GPS information.
Definition: gpssystem.cc:139
ConfigItem * clone() const
Clones this item.
Definition: gpssystem.cc:114
void setContactObj(DMRContact *contactObj)
Sets the destination contact for the GPS information.
Definition: gpssystem.cc:134
DMRContactReference _contact
Holds the destination contact for the GPS information.
Definition: gpssystem.hh:123
DMRChannelReference * revert()
Returns a reference to the revert channel.
void setRevert(DMRChannelReference *channel)
Sets the revert channel for the GPS information to be sent on.
Definition: gpssystem.cc:179
DMRContactReference * contact()
Returns the reference to the destination contact.
DMRContact * contactObj() const
Returns the destination contact for the GPS information or nullptr if not set.
Definition: gpssystem.cc:129
DMRChannelReference * revert
References the revert channel.
Definition: gpssystem.hh:70
void setRevertChannel(DMRChannel *channel)
Sets the revert channel for the GPS information to be sent on.
Definition: gpssystem.cc:164
bool hasContact() const
Returns true if a contact is set for the GPS system.
Definition: gpssystem.cc:124
DMRContactReference * contact
References the destination contact.
Definition: gpssystem.hh:68
DMRChannelReference _revertChannel
Holds the revert channel on which the GPS information is sent on.
Definition: gpssystem.hh:125
Q_INVOKABLE GPSSystem(QObject *parent=nullptr)
Default constructor.
Definition: gpssystem.cc:79
bool hasRevertChannel() const
Returns true if the GPS system has a revert channel set.
Definition: gpssystem.cc:154
Base class of the positioning systems, that is APRS and DMR position reporting system.
Definition: gpssystem.hh:17
bool link(const YAML::Node &node, const Context &ctx, const ErrorStack &err=ErrorStack())
Links the given object to the rest of the codeplug using the given context.
Definition: gpssystem.cc:66
unsigned _period
Holds the update period in seconds.
Definition: gpssystem.hh:57
bool populate(YAML::Node &node, const ConfigItem::Context &context, const ErrorStack &err=ErrorStack())
Recursively serializes the configuration to YAML nodes.
Definition: gpssystem.cc:39
void onReferenceModified()
Gets called, whenever a reference is modified.
Definition: gpssystem.cc:71
void setPeriod(unsigned period)
Sets the update period in seconds.
Definition: gpssystem.cc:33
PositioningSystem(QObject *parent=nullptr)
Default constructor.
Definition: gpssystem.cc:11
virtual ~PositioningSystem()
Destructor.
Definition: gpssystem.cc:23
bool parse(const YAML::Node &node, Context &ctx, const ErrorStack &err=ErrorStack())
Parses the given YAML node, updates the given object and updates the given context (IDs).
Definition: gpssystem.cc:46
unsigned period
The update period in seconds.
Definition: gpssystem.hh:22
The list of positioning systems.
Definition: gpssystem.hh:267
PositioningSystems(QObject *parent=nullptr)
Constructs an empty list of GPS systems.
Definition: gpssystem.cc:434
APRSSystem * aprsSystem(int idx) const
Returns the APRS system at index idx.
Definition: gpssystem.cc:522
int aprsCount() const
Returns the number of defined APRS system.
Definition: gpssystem.cc:496
int indexOfGPSSys(const GPSSystem *gps) const
Returns the index of the GPS System.
Definition: gpssystem.cc:464
int indexOfAPRSSys(APRSSystem *gps) const
Returns the index of the specified APRS system.
Definition: gpssystem.cc:506
int add(ConfigObject *obj, int row=-1, bool unique=true)
Adds an element to the list.
Definition: gpssystem.cc:448
int gpsCount() const
Returns the number of defined GPS systems.
Definition: gpssystem.cc:455
GPSSystem * gpsSystem(int idx) const
Gets the GPS system at the specified index.
Definition: gpssystem.cc:480
PositioningSystem * system(int idx) const
Returns the positioning system at the specified index.
Definition: gpssystem.cc:441
ConfigItem * allocateChild(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack())
Allocates a member objects for the given YAML node.
Definition: gpssystem.cc:537