libcyberradio  22.01.24
DucComponent.h
1 /***************************************************************************
2  * \file DucComponent.h
3  * \brief Defines the basic DUC interface for an NDR-class radio.
4  * \author DA
5  * \author NH
6  * \author MN
7  * \copyright (c) 2017 CyberRadio Solutions, Inc. All rights reserved.
8  *
9  ***************************************************************************/
10 
11 #ifndef INCLUDED_LIBCYBERRADIO_DRIVER_DUCCOMPONENT_H
12 #define INCLUDED_LIBCYBERRADIO_DRIVER_DUCCOMPONENT_H
13 
14 #include "LibCyberRadio/Driver/RadioComponent.h"
15 #include "LibCyberRadio/Common/BasicDict.h"
16 #include "LibCyberRadio/Common/BasicList.h"
17 #include <string>
18 
19 
23 namespace LibCyberRadio
24 {
28  namespace Driver
29  {
36  typedef BASIC_DICT_CONTAINER<int, double> DucRateSet;
37 
66  {
67  public:
95  DucComponent(const std::string& name = "DUC",
96  int index = 1,
97  RadioHandler* parent = NULL,
98  bool debug = false,
99  double freqRangeMin = 0.0,
100  double freqRangeMax = 0.0,
101  double freqRes = 1.0,
102  double freqUnits = 1.0,
103  double attRangeMin = 0.0,
104  double attRangeMax = 10.0,
105  double attRes = 1.0,
106  int dataPort = 0,
107  double frequency = 0.0,
108  double attenuation = 0.0,
109  int rateIndex = 0,
110  int txChannels = 0,
111  int mode = 0,
112  unsigned int streamId = 0);
116  virtual ~DucComponent();
121  DucComponent(const DucComponent& other);
127  virtual DucComponent& operator=(const DucComponent& other);
128  // RadioComponent interface
134  virtual bool enable(bool enabled = true);
140  virtual bool setConfiguration(ConfigurationDict& cfg);
145  virtual void queryConfiguration();
146  // DucComponent extensions
151  virtual int getDataPort() const;
158  virtual bool setDataPort(int port);
163  virtual double getFrequency() const;
169  virtual bool setFrequency(double freq);
174  virtual BasicDoubleList getFrequencyRange() const;
179  virtual double getFrequencyRes() const;
184  virtual double getFrequencyUnit() const;
189  virtual double getAttenuation() const;
195  virtual bool setAttenuation(double atten);
200  virtual BasicDoubleList getAttenuationRange() const;
205  virtual double getAttenuationRes() const;
210  virtual int getRateIndex() const;
216  virtual bool setRateIndex(int index);
224  virtual int getTxChannelBitmap() const;
233  virtual bool setTxChannelBitmap(int txChannels);
238  virtual int getMode() const;
244  virtual bool setMode(int mode);
249  virtual unsigned int getStreamId() const;
255  virtual bool setStreamId(unsigned int sid);
260  virtual DucRateSet getRateSet() const;
266  virtual bool setRateSet(const DucRateSet& set);
272  virtual BasicDoubleList getRateList() const;
277  virtual bool supportsSnapshotLoad() const;
292  virtual bool loadSnapshot(const std::string& filename,
293  unsigned int startSample = 0,
294  unsigned int samples = 0);
299  virtual bool supportsSnapshotTransmit() const;
300 
301  protected:
302  // RadioComponent interface
307  virtual void initConfigurationDict();
311  virtual void updateConfigurationDict();
312  // DucComponent extensions
328  virtual bool executeDucQuery(int index,
329  int& dataPort,
330  double& frequency,
331  double& attenuation,
332  int& rateIndex,
333  int& txChannels,
334  int& mode,
335  unsigned int& streamId);
348  virtual bool executeDucCommand(int index,
349  int& dataPort,
350  double& frequency,
351  double& attenuation,
352  int& rateIndex,
353  int& txChannels,
354  int& mode,
355  unsigned int& streamId);
364  virtual bool executeSnapshotLoadCommand(int index,
365  const std::string& filename,
366  unsigned int startSample,
367  unsigned int samples);
368 
369  protected:
370  // Minimum tunable frequency (Hz)
371  double _freqRangeMin;
372  // Maximum tunable frequency (Hz)
373  double _freqRangeMax;
374  // Frequency resolution (Hz)
375  double _freqRes;
376  // Frequency units (Hz)
377  double _freqUnits;
378  // Minimum attenuation (dB)
379  double _attRangeMin;
380  // Maximum attenuation (dB)
381  double _attRangeMax;
382  // Attenuation resolution
383  double _attRes;
384  // Data port
385  int _dataPort;
386  // Tuned frequency
387  double _frequency;
388  // Attenuation
389  double _attenuation;
390  // Rate index
391  int _rateIndex;
392  // TX channel bitmap
393  int _txChannels;
394  // DUC mode (streaming or playback)
395  int _mode;
396  // VITA 49 stream ID
397  unsigned int _streamId;
398  // Supports snapshot load
399  bool _supportsSnapLoad;
400  // Snapshot file name
401  std::string _snapFilename;
402  // Snapshot starting sample
403  unsigned int _snapStartSample;
404  // Snapshot number of samples
405  unsigned int _snapSamples;
406  // Supports snapshot transmit
407  bool _supportsSnapTransmit;
408  // Whether snapshot transmit is single playback
409  bool _snapSinglePlayback;
410  // Whether snapshot transmit should pause until enabled
411  bool _snapPauseUntilEnabled;
412  // Rate set
413  DucRateSet _rateSet;
414 
415  }; // class DucComponent
416 
420  typedef BASIC_DICT_CONTAINER<int, DucComponent*> DucComponentDict;
421 
422  } // namespace Driver
423 
424 } // namespace LibCyberRadio
425 
426 
427 #endif // INCLUDED_LIBCYBERRADIO_DRIVER_DUCCOMPONENT_H
virtual bool executeDucCommand(int index, int &dataPort, double &frequency, double &attenuation, int &rateIndex, int &txChannels, int &mode, unsigned int &streamId)
Executes the DUC configuration set command.
virtual bool setAttenuation(double atten)
Sets the attenuation.
virtual void initConfigurationDict()
Initializes the configuration dictionary, defining the allowed keys.
virtual bool supportsSnapshotTransmit() const
Gets whether or not the DUC supports transmitting snapshots.
DucComponent(const std::string &name="DUC", int index=1, RadioHandler *parent=NULL, bool debug=false, double freqRangeMin=0.0, double freqRangeMax=0.0, double freqRes=1.0, double freqUnits=1.0, double attRangeMin=0.0, double attRangeMax=10.0, double attRes=1.0, int dataPort=0, double frequency=0.0, double attenuation=0.0, int rateIndex=0, int txChannels=0, int mode=0, unsigned int streamId=0)
Constructs a DucComponent object.
virtual bool supportsSnapshotLoad() const
Gets whether or not the DUC supports loading snapshot files.
BASIC_DICT_CONTAINER< int, DucComponent * > DucComponentDict
A dictionary of DUC components, keyed by index.
Definition: DucComponent.h:420
virtual int getMode() const
Gets the DUC&#39;s mode.
Base hardware component class.
BASIC_LIST_CONTAINER< double > BasicDoubleList
Type representing a list of doubles.
Definition: BasicList.h:29
virtual bool executeSnapshotLoadCommand(int index, const std::string &filename, unsigned int startSample, unsigned int samples)
Executes the DUC snapshot load command.
virtual bool executeDucQuery(int index, int &dataPort, double &frequency, double &attenuation, int &rateIndex, int &txChannels, int &mode, unsigned int &streamId)
Executes the DUC configuration query command.
virtual bool setFrequency(double freq)
Sets the DUC tuned frequency.
virtual bool setTxChannelBitmap(int txChannels)
Sets the DUC&#39;s transmit channel bitmap.
virtual bool setStreamId(unsigned int sid)
Sets the DUC&#39;s VITA 49 stream ID.
virtual ~DucComponent()
Destroys a DucComponent object.
virtual double getFrequencyRes() const
Gets the tuned frequency resolution.
virtual double getAttenuation() const
Gets the attenuation.
virtual int getRateIndex() const
Gets the DUC&#39;s rate index.
virtual double getFrequencyUnit() const
Gets the tuned frequency units.
virtual DucComponent & operator=(const DucComponent &other)
Assignment operator for DucComponent objects.
Generic radio handler class.
Definition: RadioHandler.h:54
virtual int debug(const char *format,...)
Outputs debug information.
Definition: Debuggable.cpp:95
virtual BasicDoubleList getAttenuationRange() const
Gets the attenuation range.
BASIC_DICT_CONTAINER< int, double > DucRateSet
A rate set for a DUC.
Definition: DucComponent.h:36
virtual int getDataPort() const
Gets the DUC&#39;s data port.
virtual void updateConfigurationDict()
Updates the configuration dictionary from component settings.
virtual DucRateSet getRateSet() const
Gets the DUC&#39;s rate set.
Defines functionality for LibCyberRadio applications.
Definition: App.h:23
virtual bool setDataPort(int port)
Sets the DUC&#39;s data port.
virtual void queryConfiguration()
Tells the component to query its hardware configuration in order to create its configuration dictiona...
A configuration dictionary.
Definition: Configurable.h:51
virtual double getFrequency() const
Gets the tuned frequency.
virtual int getTxChannelBitmap() const
Gets the DUC&#39;s transmit channel bitmap.
virtual unsigned int getStreamId() const
Gets the DUC&#39;s VITA 49 stream ID.
virtual BasicDoubleList getFrequencyRange() const
Gets the tunable frequency range.
virtual bool enable(bool enabled=true)
Enables this component.
Base DUC component class.
Definition: DucComponent.h:65
virtual double getAttenuationRes() const
Gets the attenuation resolution.
virtual BasicDoubleList getRateList() const
Gets the list of allowed sample rates, based on the rate set.
virtual bool setRateSet(const DucRateSet &set)
Sets the DUC rate set.
virtual bool loadSnapshot(const std::string &filename, unsigned int startSample=0, unsigned int samples=0)
Load a snapshot file into the DUC&#39;s memory block.
virtual bool setMode(int mode)
Sets the DUC&#39;s mode.
virtual bool setRateIndex(int index)
Sets the DUC&#39;s rate index.
virtual bool setConfiguration(ConfigurationDict &cfg)
Sets the configuration dictionary for this component.