ValoFly TetherCom Library  9
Communication library for ValoFly Tether.Solutions ground stations
TetherCom.h
Go to the documentation of this file.
1 //
2 // Copyright (C) ValoFly GmbH - All Rights Reserved
3 //
11 #ifndef _VALOFLY_TETHERCOM_LIB_HEADER_
12 #define _VALOFLY_TETHERCOM_LIB_HEADER_
13 
15 
16 #include <exception>
17 #include <vector>
18 #include <string>
19 #include <sstream>
20 #include <iostream>
21 
23 namespace VALOFLY {
24 
26 
27  class IOException : public std::exception {
28  // Disable copy constructors
29  IOException& operator=(const IOException&);
30  std::string _exWhat;
31 
32  public:
38  explicit IOException(const char* description)
39  {
40  std::stringstream ss;
41  ss << "IO Exception: " << description;
42  _exWhat = ss.str();
43  }
49  IOException(const IOException& other) : _exWhat(other._exWhat) {}
50 
51  virtual ~IOException() noexcept {}
52 
58  virtual const char* what() const throw () {
59  return _exWhat.c_str();
60  }
61  };
62 
64 
65  class DataException : public std::exception {
66  // Disable copy constructors
67  DataException& operator=(const DataException&);
68  std::string _exWhat;
69 
70  public:
76  explicit DataException(const char* description)
77  {
78  std::stringstream ss;
79  ss << "Data Stream Exception: " << description;
80  _exWhat = ss.str();
81  }
87  DataException(const DataException& other) : _exWhat(other._exWhat) {}
88 
89  virtual ~DataException() noexcept {}
90 
96  virtual const char* what() const throw () {
97  return _exWhat.c_str();
98  }
99  };
100 
102 
103  class TetherCom
104  {
105  public:
106  /******************************************************************/
107  /* Public communication definitions */
108  /******************************************************************/
109 
111 
114  struct systemConfig //
115  {
120  };
121 
123  struct cableStatus
124  {
125  float lengthUnwound = 0;
126  float speed = 0;
128  float retractionTorque = 0;
133  };
134 
136  struct envStatus
137  {
138  float temp1 = -128;
139  float temp2 = -128;
140  float temp3 = -128;
141  float temp4 = -128;
142  float humidity = -128;
143  float pressure = 0;
145  int fan1RPM = 0;
147  int fan2RPM = 0;
149  };
150 
153  {
154  float mainsU = 0;
155  float mainsI = 0;
156  float mainsF = 0;
161  };
162 
165  {
166  float uavVoltage = 0;
167  float uavCurrent = 0;
168  float uavPower = 0;
170  int uavBatCellCount = 0;
171  };
172 
175  {
179  uint32_t systemTime = 0;
180  uint32_t operationTime = 0;
181  uint32_t flightTime = 0;
182  uint32_t operationFlightTimeSum = 0;
183  uint32_t operationFlightCountSum = 0;
185  };
186 
189  {
190  int cableEnabled = 0;
191  int envEnabled = 0;
192  int energyGSEnabled = 0;
195  };
196 
199  {
206  };
207 
210  {
211  std::string productType = "";
212  std::string model = "";
213  std::string serialNumber = "";
214  std::string dayOfProduction = "";
215  std::string hardwareVersion = "";
218  {
219  std::string mainCtrl = "";
220  std::string reelCtrl = "";
221  std::string lpwrCtrl = "";
222  std::string hpwrCtrl = "";
223  std::string envCtrl = "";
224  std::string netCtrl = "";
225  std::string backupBatteryCtrl = "";
227  std::string protocolVersion = "";
228  std::string uavCellVoltages = "";
229  int maxPower = 0;
230  std::string cableType = "";
231  int maxCableLength = 0;
233  uint32_t flightTimeSum = 0;
234  uint32_t flightCount = 0;
235  uint32_t operationTimeSum = 0;
236  uint32_t operationCount = 0;
237  uint32_t systemTimeSum = 0;
238  uint32_t systemUseCount = 0;
239  uint32_t timeToMaintenance = 0;
241  };
242 
243  private:
247  class TetherComImpl;
248  TetherComImpl* _pImpl;
249 
250  public:
251  TetherCom();
252  TetherCom(TetherCom&&);
253  TetherCom(const TetherCom&) = delete; // non construction-copyable
254  TetherCom& operator=(TetherCom&&) = default; // move assignment operator
255  TetherCom& operator=(const TetherCom&) = delete; // non copyable
256  ~TetherCom();
257 
265  void getSerialPortsInfo(std::vector<std::string>& devListPort, std::vector<std::string>& devListDesc, std::vector<std::string>& devListHwID);
266 
268  void printSerialPortList();
269 
274  void printSerialPortList(std::ostream& stream);
275 
283  void openConnection(const std::string& portName);
284 
290  void closeConnection();
291 
297  int getConnectionStatus();
298 
304  bool isConnected();
305 
312  void setConnectionTimeout(const unsigned int timeout);
313 
319  int getConnectionTimeout();
320 
329  void getSystemDetails(systemDetails& sysDetails);
330 
339  void getSystemStatus(systemStatus& sysStatus);
340 
349  void getSystemConfig(systemConfig& config);
350 
360  void setSystemConfig(const systemConfig& conf);
361 
370  void setSystemActivation(bool activation);
371 
381  void setCableRetractionTorque(float retractionTorque);
382 
392  void setCableRetractionStartLength(float startLength);
393 
403 
413 
423  void print();
424 
431  void print(systemStatus& sysStatus, std::ostream& stream = std::cout);
432 
439  void print(systemDetails& sysDetails, std::ostream& stream = std::cout);
440 
446  std::string getLibBuild();
447 
453  void getLibBuild(std::string& build);
454 
460  std::string getLibProtocolVersion();
461 
467  void getLibProtocolVersion(std::string& version);
468  };
469 };
470 
471 #endif // _VALOFLY_TETHERCOM_LIB_HEADER_
Data handling exception class.
Definition: TetherCom.h:65
DataException(const DataException &other)
Definition: TetherCom.h:87
DataException(const char *description)
Definition: TetherCom.h:76
virtual const char * what() const
Definition: TetherCom.h:96
IO handling exception class.
Definition: TetherCom.h:27
IOException(const char *description)
Definition: TetherCom.h:38
virtual const char * what() const
Definition: TetherCom.h:58
IOException(const IOException &other)
Definition: TetherCom.h:49
Communication class for ValoFly Tether.Solutions Ground Stations.
Definition: TetherCom.h:104
void getSystemStatus(systemStatus &sysStatus)
Definition: TetherCom.cpp:120
void openConnection(const std::string &portName)
Definition: TetherCom.cpp:60
std::string getLibProtocolVersion()
Definition: TetherCom.cpp:284
void setSystemActivation(bool activation)
Definition: TetherCom.cpp:168
void setCableRetractionStartLength(float startLength)
Definition: TetherCom.cpp:200
void getSystemStatusConfig(systemStatusConfig &conf)
Definition: TetherCom.cpp:216
void closeConnection()
Definition: TetherCom.cpp:72
void setConnectionTimeout(const unsigned int timeout)
Definition: TetherCom.cpp:94
bool isConnected()
Definition: TetherCom.cpp:89
void setSystemConfig(const systemConfig &conf)
Definition: TetherCom.cpp:152
void getSystemDetails(systemDetails &sysDetails)
Definition: TetherCom.cpp:104
void printSerialPortList()
Definition: TetherCom.cpp:50
int getConnectionTimeout()
Definition: TetherCom.cpp:99
void setCableRetractionTorque(float retractionTorque)
Definition: TetherCom.cpp:184
void getSystemConfig(systemConfig &config)
Definition: TetherCom.cpp:136
void setSystemStatusConfig(systemStatusConfig &conf)
Definition: TetherCom.cpp:232
void print()
Definition: TetherCom.cpp:248
int getConnectionStatus()
Definition: TetherCom.cpp:84
std::string getLibBuild()
Definition: TetherCom.cpp:274
void getSerialPortsInfo(std::vector< std::string > &devListPort, std::vector< std::string > &devListDesc, std::vector< std::string > &devListHwID)
Definition: TetherCom.cpp:45
Namespace for classes and members developed by ValoFly GmbH.
Definition: TetherCom.h:23
Definition: TetherCom.h:124
int retractionStatus
Definition: TetherCom.h:127
float retractionStartLength
Definition: TetherCom.h:129
float speed
Definition: TetherCom.h:126
int guideStatus
Definition: TetherCom.h:131
float lengthUnwound
Definition: TetherCom.h:125
int reelStatus
Definition: TetherCom.h:132
float retractionTorque
Definition: TetherCom.h:128
int tetherStatus
Definition: TetherCom.h:130
Definition: TetherCom.h:153
float mainsU
Definition: TetherCom.h:154
int ctrlSupplyStatus
Definition: TetherCom.h:158
int mainsStatus
Definition: TetherCom.h:157
float mainsF
Definition: TetherCom.h:156
float backupBatteryVoltage
Definition: TetherCom.h:159
int backupBatteryStatus
Definition: TetherCom.h:160
float mainsI
Definition: TetherCom.h:155
Definition: TetherCom.h:165
int extSupplyStatus
Definition: TetherCom.h:169
float uavVoltage
Definition: TetherCom.h:166
float uavPower
Definition: TetherCom.h:168
float uavCurrent
Definition: TetherCom.h:167
int uavBatCellCount
Definition: TetherCom.h:170
Definition: TetherCom.h:137
float temp3
Definition: TetherCom.h:140
int fan2RPM
Definition: TetherCom.h:147
float temp1
Definition: TetherCom.h:138
int fan1RPM
Definition: TetherCom.h:145
int fan2Status
Definition: TetherCom.h:148
float humidity
Definition: TetherCom.h:142
int fan1Status
Definition: TetherCom.h:146
float temp4
Definition: TetherCom.h:141
int envSensor1Status
Definition: TetherCom.h:144
float temp2
Definition: TetherCom.h:139
float pressure
Definition: TetherCom.h:143
Configuration parameter structure.
Definition: TetherCom.h:115
int cableRetractionStatus
Definition: TetherCom.h:119
float cableRetractionTorque
Definition: TetherCom.h:117
bool systemActivation
Definition: TetherCom.h:116
float cableRetractionStartLength
Definition: TetherCom.h:118
std::string lpwrCtrl
Definition: TetherCom.h:221
std::string mainCtrl
Definition: TetherCom.h:219
std::string reelCtrl
Definition: TetherCom.h:220
std::string backupBatteryCtrl
Definition: TetherCom.h:225
std::string netCtrl
Definition: TetherCom.h:224
std::string envCtrl
Definition: TetherCom.h:223
std::string hpwrCtrl
Definition: TetherCom.h:222
Definition: TetherCom.h:210
struct VALOFLY::TetherCom::systemDetails::softwareVerions softwareVerion
std::string dayOfProduction
Definition: TetherCom.h:214
uint32_t flightCount
Definition: TetherCom.h:234
int maintenance_required
Definition: TetherCom.h:240
uint32_t operationCount
Definition: TetherCom.h:236
std::string cableType
Definition: TetherCom.h:230
std::string model
Definition: TetherCom.h:212
uint32_t systemUseCount
Definition: TetherCom.h:238
uint32_t systemTimeSum
Definition: TetherCom.h:237
int maxPower
Definition: TetherCom.h:229
uint32_t operationTimeSum
Definition: TetherCom.h:235
uint32_t timeToMaintenance
Definition: TetherCom.h:239
std::string productType
Definition: TetherCom.h:211
std::string serialNumber
Definition: TetherCom.h:213
uint32_t flightTimeSum
Definition: TetherCom.h:233
std::string hardwareVersion
Definition: TetherCom.h:215
std::string uavCellVoltages
Definition: TetherCom.h:228
std::string protocolVersion
Definition: TetherCom.h:227
int maxCableLength
Definition: TetherCom.h:231
int networkType
Definition: TetherCom.h:232
Definition: TetherCom.h:175
uint32_t systemTime
Definition: TetherCom.h:179
int backupBatteryStatus
Definition: TetherCom.h:178
int activation
Definition: TetherCom.h:176
uint32_t operationTime
Definition: TetherCom.h:180
uint32_t flightTime
Definition: TetherCom.h:181
uint32_t operationFlightTimeSum
Definition: TetherCom.h:182
int retractionStatus
Definition: TetherCom.h:177
uint32_t operationFlightCountSum
Definition: TetherCom.h:183
int error
Definition: TetherCom.h:184
Definition: TetherCom.h:189
int energyUAVEnabled
Definition: TetherCom.h:193
int energyGSEnabled
Definition: TetherCom.h:192
int envEnabled
Definition: TetherCom.h:191
int systemStatesEnabled
Definition: TetherCom.h:194
int cableEnabled
Definition: TetherCom.h:190
Definition: TetherCom.h:199
systemStates sysStates
Definition: TetherCom.h:205
energyUAVStatus energyUAV
Definition: TetherCom.h:204
systemStatusConfig conf
Definition: TetherCom.h:200
envStatus env
Definition: TetherCom.h:202
energyGSStatus energyGS
Definition: TetherCom.h:203
cableStatus cable
Definition: TetherCom.h:201