libdrmconf 0.14.1
A library to program DMR radios.
Loading...
Searching...
No Matches
satellitedatabase.hh
1#ifndef SATELLITEDATABASE_HH
2#define SATELLITEDATABASE_HH
3
4#include "errorstack.hh"
5#include "frequency.hh"
6#include "signaling.hh"
7#include "transponderdatabase.hh"
8#include "orbitalelementsdatabase.hh"
9
10
18{
19public:
21 Satellite();
23 Satellite(const OrbitalElement &orbit);
25 Satellite(const Satellite &sat) = default;
27 Satellite &operator =(const Satellite &other) = default;
28
30 const QString &name() const;
32 void setName(const QString &name);
33
35 const Frequency &fmUplink() const;
37 void setFMUplink(const Frequency &f);
39 const Frequency &fmDownlink() const;
41 void setFMDownlink(const Frequency &f);
43 const SelectiveCall &fmUplinkTone() const;
45 void setFMUplinkTone(const SelectiveCall &tone);
47 const SelectiveCall &fmDownlinkTone() const;
49 void setFMDownlinkTone(const SelectiveCall &tone);
50
52 const Frequency &aprsUplink() const;
54 void setAPRSUplink(const Frequency &f);
56 const Frequency &aprsDownlink() const;
58 void setAPRSDownlink(const Frequency &f);
60 const SelectiveCall &aprsUplinkTone() const;
62 void setAPRSUplinkTone(const SelectiveCall &tone);
64 const SelectiveCall &aprsDownlinkTone() const;
66 void setAPRSDownlinkTone(const SelectiveCall &tone);
68 const Frequency &beacon() const;
70 void setBeacon(const Frequency &f);
71
73 QJsonObject toJson() const;
74
75public:
77 static Satellite fromJson(const QJsonObject &obj, const OrbitalElementsDatabase &db);
78
79protected:
81 QString _name;
100};
101
102
103
107class SatelliteDatabase : public QAbstractTableModel
108{
109 Q_OBJECT
110
111public:
113 explicit SatelliteDatabase(unsigned int updatePeriodDays=7, QObject *parent = nullptr);
114
120 const TransponderDatabase &transponders() const;
123
125 unsigned int count() const;
127 const Satellite &getAt(unsigned int idx) const;
129 bool setAt(const Satellite &sat, unsigned int idx);
131 void add(const Satellite &sat);
133 bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex());
134
136 Qt::ItemFlags flags(const QModelIndex &index) const;
139 int rowCount(const QModelIndex &parent=QModelIndex()) const;
141 int columnCount(const QModelIndex &parent=QModelIndex()) const;
143 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
145 QVariant data(const QModelIndex &index, int role) const;
147 bool setData(const QModelIndex &index, const QVariant &value, int role);
148
149public slots:
151 void update();
153 void load();
155 bool save(const ErrorStack &err = ErrorStack()) const;
156
157signals:
159 void loaded();
161 void error(const QString &msg);
162
163private:
165 QVector<Satellite> _satellites;
167 OrbitalElementsDatabase _orbitalElements;
169 TransponderDatabase _transponders;
170};
171
172#endif // SATELLITEDATABASE_HH
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition errorstack.hh:43
OrbitalElement()
Default constructor.
Definition orbitalelementsdatabase.cc:77
Downloads and updates a database of orbital elements from CelesTrak.
Definition orbitalelementsdatabase.hh:122
int columnCount(const QModelIndex &parent=QModelIndex()) const
Implements the QAbstractTableModel interface.
Definition satellitedatabase.cc:304
SatelliteDatabase(unsigned int updatePeriodDays=7, QObject *parent=nullptr)
Constructs a new satellite database.
Definition satellitedatabase.cc:219
void load()
Loads the user-curated satellite database.
Definition satellitedatabase.cc:439
bool setAt(const Satellite &sat, unsigned int idx)
Returns the i-th satellite.
Definition satellitedatabase.cc:262
void loaded()
Gets emitted once the satellites has been loaded.
QVariant data(const QModelIndex &index, int role) const
Implements the QAbstractTableModel interface.
Definition satellitedatabase.cc:360
void error(const QString &msg)
Gets emitted if the loading one of the sources fails.
int rowCount(const QModelIndex &parent=QModelIndex()) const
Implements the QAbstractTableModel interface.
Definition satellitedatabase.cc:298
unsigned int count() const
Returns the number of configured satellites.
Definition satellitedatabase.cc:252
bool save(const ErrorStack &err=ErrorStack()) const
Saves the user-curated satellite database.
Definition satellitedatabase.cc:489
Qt::ItemFlags flags(const QModelIndex &index) const
Implements the QAbstractTableModel interface.
Definition satellitedatabase.cc:333
bool setData(const QModelIndex &index, const QVariant &value, int role)
Implements the QAbstractTableModel interface.
Definition satellitedatabase.cc:409
void update()
Triggers a download of the orbital and transponder databases.
Definition satellitedatabase.cc:433
const TransponderDatabase & transponders() const
Returns the transponder database.
Definition satellitedatabase.cc:237
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
Removes one or more satellites.
Definition satellitedatabase.cc:282
const OrbitalElementsDatabase & orbitalElements() const
Returns the orbital element database.
Definition satellitedatabase.cc:232
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Implements the QAbstractTableModel interface.
Definition satellitedatabase.cc:310
void add(const Satellite &sat)
Appends a satellite.
Definition satellitedatabase.cc:271
const Satellite & getAt(unsigned int idx) const
Returns the i-th satellite.
Definition satellitedatabase.cc:257
Extends the OrbitalElement to include transponder information for a satellite.
Definition satellitedatabase.hh:18
void setBeacon(const Frequency &f)
Sets a beacon frequency.
Definition satellitedatabase.cc:138
static Satellite fromJson(const QJsonObject &obj, const OrbitalElementsDatabase &db)
Constructs a satellite from the given JSON object and orbital element database.
Definition satellitedatabase.cc:180
Frequency _aprsDownlink
Holds the APRS downlink frequency.
Definition satellitedatabase.hh:93
Satellite(const Satellite &sat)=default
Copy constructor.
SelectiveCall _aprsUplinkTone
Holds the APRS uplink tone.
Definition satellitedatabase.hh:95
QString _name
Holds the name of the satellite.
Definition satellitedatabase.hh:81
SelectiveCall _aprsDownlinkTone
Holds the APRS downlink tone.
Definition satellitedatabase.hh:97
SelectiveCall _fmUplinkTone
Holds the FM uplink tone.
Definition satellitedatabase.hh:87
const SelectiveCall & fmDownlinkTone() const
Returns the FM downlink tone (i.e., RX tone).
Definition satellitedatabase.cc:81
Frequency _fmUplink
Holds the FM uplink frequency.
Definition satellitedatabase.hh:83
void setAPRSDownlinkTone(const SelectiveCall &tone)
Sets the APRS downlink sub tone.
Definition satellitedatabase.cc:128
const SelectiveCall & aprsDownlinkTone() const
Returns the APRS downlink tone (i.e., RX tone).
Definition satellitedatabase.cc:123
void setFMUplink(const Frequency &f)
Sets the FM uplink frequency.
Definition satellitedatabase.cc:53
QJsonObject toJson() const
Serializes the satellite into a JSON object.
Definition satellitedatabase.cc:144
Satellite()
Default constructor.
Definition satellitedatabase.cc:19
void setAPRSDownlink(const Frequency &f)
Sets the APRS downlink frequency.
Definition satellitedatabase.cc:107
Frequency _aprsUplink
Holds the APRS uplink frequency.
Definition satellitedatabase.hh:91
Satellite & operator=(const Satellite &other)=default
Copy assignment.
void setFMDownlinkTone(const SelectiveCall &tone)
Sets the FM downlink sub tone.
Definition satellitedatabase.cc:86
const Frequency & aprsDownlink() const
Returns the APRS downlink frequency.
Definition satellitedatabase.cc:102
const Frequency & beacon() const
Returns a beacon frequency.
Definition satellitedatabase.cc:133
void setFMDownlink(const Frequency &f)
Sets the FM downlink frequency.
Definition satellitedatabase.cc:64
SelectiveCall _fmDownlinkTone
Holds the FM downlink tone.
Definition satellitedatabase.hh:89
const Frequency & fmDownlink() const
Returns the FM downlink frequency.
Definition satellitedatabase.cc:59
Frequency _beacon
Holds a beacon frequency.
Definition satellitedatabase.hh:99
void setName(const QString &name)
Sets the name of the satellite.
Definition satellitedatabase.cc:42
void setAPRSUplink(const Frequency &f)
Sets the APRS uplink frequency.
Definition satellitedatabase.cc:97
void setAPRSUplinkTone(const SelectiveCall &tone)
Sets the APRS uplink sub tone.
Definition satellitedatabase.cc:118
Frequency _fmDownlink
Holds the FM downlink frequency.
Definition satellitedatabase.hh:85
const Frequency & fmUplink() const
Returns the FM uplink frequency.
Definition satellitedatabase.cc:48
const SelectiveCall & aprsUplinkTone() const
Returns the APRS uplink tone (i.e., TX tone).
Definition satellitedatabase.cc:113
const SelectiveCall & fmUplinkTone() const
Returns the FM uplink tone (i.e., TX tone).
Definition satellitedatabase.cc:70
void setFMUplinkTone(const SelectiveCall &tone)
Sets the FM uplink sub tone.
Definition satellitedatabase.cc:75
const Frequency & aprsUplink() const
Returns the APRS uplink frequency.
Definition satellitedatabase.cc:92
const QString & name() const
Returns the name of the satellite.
Definition satellitedatabase.cc:37
Implements the database of all known transponder.
Definition transponderdatabase.hh:77
Helper type to encode frequencies without any rounding error.
Definition frequency.hh:107
Encodes a selective call.
Definition signaling.hh:13