libdrmconf  0.12.0
A library to program DMR radios.
radio.hh
1 
8 #ifndef RADIO_HH
9 #define RADIO_HH
10 
11 #include <QThread>
12 #include "radioinfo.hh"
13 #include "radiointerface.hh"
14 #include "codeplug.hh"
15 #include "userdatabase.hh"
16 #include "callsigndb.hh"
17 #include "errorstack.hh"
18 #include "config.hh"
19 
20 class RadioLimits;
21 
22 
31 class Radio : public QThread
32 {
33  Q_OBJECT
34 
35 public:
37  typedef enum {
43  } Status;
44 
45 public:
47  explicit Radio(QObject *parent = nullptr);
48 
49  virtual ~Radio();
50 
52  virtual const QString &name() const = 0;
53 
59  virtual const RadioLimits &limits() const = 0;
60 
62  virtual const Codeplug &codeplug() const = 0;
64  virtual Codeplug &codeplug() = 0;
65 
67  virtual const CallsignDB *callsignDB() const;
69  virtual CallsignDB *callsignDB();
70 
72  Status status() const;
73 
76  const ErrorStack &errorStack() const;
77 
78 public:
81  static Radio *detect(const USBDeviceDescriptor &descr, const RadioInfo &force=RadioInfo(),
82  const ErrorStack &err=ErrorStack());
83 
84 public slots:
88  virtual bool startDownload(bool blocking=false, const ErrorStack &err=ErrorStack()) = 0;
91  virtual bool startUpload(
92  Config *config, bool blocking=false,
93  const Codeplug::Flags &flags = Codeplug::Flags(), const ErrorStack &err=ErrorStack()) = 0;
95  virtual bool startUploadCallsignDB(
96  UserDatabase *db, bool blocking=false,
98  const ErrorStack &err=ErrorStack()) = 0;
99 
100 signals:
104  void downloadProgress(int percent);
108  void downloadError(Radio *radio);
109 
113  void uploadProgress(int percent);
115  void uploadError(Radio *radio);
117  void uploadComplete(Radio *radio);
118 
119 protected:
124 };
125 
126 #endif // RADIO_HH
Controls the selection of callsigns from the UserDatabase to be encoded into the callsign db.
Definition: callsigndb.hh:20
Abstract base class of all callsign database implementations.
Definition: callsigndb.hh:14
Certain flags passed to CodePlug::encode to control the transfer and encoding of the codeplug.
Definition: codeplug.hh:25
This class defines the interface all device-specific code-plugs must implement.
Definition: codeplug.hh:19
The config class, representing the codeplug configuration.
Definition: config.hh:70
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
Provides some information about a radio model.
Definition: radioinfo.hh:16
Represents the limits or the entire codeplug.
Definition: radiolimits.hh:684
Base class for all Radio objects.
Definition: radio.hh:32
virtual const Codeplug & codeplug() const =0
Returns the codeplug instance.
virtual bool startUploadCallsignDB(UserDatabase *db, bool blocking=false, const CallsignDB::Selection &selection=CallsignDB::Selection(), const ErrorStack &err=ErrorStack())=0
Assembles the callsign DB from the given one and uploads it to the device.
void uploadProgress(int percent)
Gets emitted on upload progress (e.g., for progress bars).
Status status() const
Returns the current status.
Definition: radio.cc:185
void uploadError(Radio *radio)
Gets emitted if there was an error during the upload.
void uploadComplete(Radio *radio)
Gets emitted once the codeplug upload has been completed successfully.
static Radio * detect(const USBDeviceDescriptor &descr, const RadioInfo &force=RadioInfo(), const ErrorStack &err=ErrorStack())
Tries to detect the radio connected to the specified interface or constructs the specified radio usin...
Definition: radio.cc:56
const ErrorStack & errorStack() const
Returns the error stack, passed to startDownload, startUpload or startUploadCallsignDB.
Definition: radio.cc:190
void downloadError(Radio *radio)
Gets emitted if there was an error during the codeplug download.
void uploadStarted()
Gets emitted once the codeplug upload has been started.
virtual const QString & name() const =0
Returns the name of the radio (e.g., device identifier).
virtual Codeplug & codeplug()=0
Returns the codeplug instance.
void downloadFinished(Radio *radio, Codeplug *codeplug)
Gets emitted once the codeplug download has been finished.
void downloadStarted()
Gets emitted once the codeplug download has been started.
Status
Possible states of the radio object.
Definition: radio.hh:37
@ StatusError
An error occurred.
Definition: radio.hh:42
@ StatusDownload
Downloading codeplug.
Definition: radio.hh:39
@ StatusIdle
Idle, nothing to do.
Definition: radio.hh:38
@ StatusUpload
Uploading codeplug.
Definition: radio.hh:40
@ StatusUploadCallsigns
Uploading codeplug.
Definition: radio.hh:41
virtual bool startUpload(Config *config, bool blocking=false, const Codeplug::Flags &flags=Codeplug::Flags(), const ErrorStack &err=ErrorStack())=0
Derives the device-specific codeplug from the generic configuration and uploads that codeplug to the ...
Status _task
The current state/task.
Definition: radio.hh:121
virtual const RadioLimits & limits() const =0
Returns the limits for this radio.
Radio(QObject *parent=nullptr)
Default constructor.
Definition: radio.cc:34
ErrorStack _errorStack
The error stack.
Definition: radio.hh:123
void downloadProgress(int percent)
Gets emitted on download progress (e.g., for progress bars).
virtual bool startDownload(bool blocking=false, const ErrorStack &err=ErrorStack())=0
Starts the download of the codeplug.
virtual const CallsignDB * callsignDB() const
Returns the call-sign DB instance.
Definition: radio.cc:45
Base class for all radio interface descriptors representing a unique interface to a connected radio.
Definition: usbdevice.hh:197
Auto-updating DMR user database.
Definition: userdatabase.hh:23