ValoFly TetherCom Library  41
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 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 ValueException : public std::exception {
104  // Disable copy constructors
105  ValueException& operator=(const ValueException&);
106  std::string _exWhat;
107 
108  public:
114  explicit ValueException(const char* description)
115  {
116  std::stringstream ss;
117  ss << "Value Exception: " << description;
118  _exWhat = ss.str();
119  }
125  ValueException(const ValueException& other) : _exWhat(other._exWhat) {}
126 
127  virtual ~ValueException() noexcept {}
128 
134  virtual const char* what() const throw () {
135  return _exWhat.c_str();
136  }
137  };
138 
140 
141  class TetherCom
142  {
143  public:
144  /******************************************************************/
145  /* Public communication definitions */
146  /******************************************************************/
147 
149 
152  struct systemConfig //
153  {
155  unsigned int cableRetractionTorque;
158  };
159 
161  struct cableStatus
162  {
163  float lengthUnwound = 0;
164  float speed = 0;
166  unsigned int retractionTorque = 0;
171  };
172 
174  struct envStatus
175  {
176  float temp1 = -128;
177  float temp2 = -128;
178  float temp3 = -128;
179  float temp4 = -128;
180  float humidity1 = -128;
181  float pressure1 = 0;
186  int fan1RPM = 0;
188  int fan2RPM = 0;
190  };
191 
194  {
195  float mainsU = 0;
196  float mainsI = 0;
197  float mainsF = 0;
202  };
203 
206  {
207  float uavVoltage = 0;
208  float uavCurrent = 0;
209  float uavPower = 0;
211  int uavBatCellCount = 0;
212  };
213 
216  {
220  uint32_t systemTime = 0;
221  uint32_t operationTime = 0;
222  uint32_t flightTime = 0;
223  uint32_t operationFlightTimeSum = 0;
224  uint32_t operationFlightCountSum = 0;
226  };
227 
230  {
237  };
238 
241  {
242  int mainCtrlStatus = static_cast<int>(TetherComDefinitions::hardwareModuleStatus::not_available);
247  };
248 
251  {
259  };
260 
263  {
264  std::string productType = "";
265  std::string model = "";
266  std::string serialNumber = "";
267  std::string dayOfProduction = "";
268  std::string hardwareVersion = "";
271  {
272  std::string mainCtrl = "";
273  std::string reelCtrl = "";
274  std::string lpwrCtrl = "";
275  std::string hpwrCtrl = "";
276  std::string envCtrl = "";
277  std::string netCtrl = "";
278  std::string backupBatteryCtrl = "";
280  std::string protocolVersion = "";
281  std::string uavCellVoltages = "";
282  int maxPower = 0;
283  std::string cableType = "";
284  int maxCableLength = 0;
286  uint32_t flightTimeSum = 0;
287  uint32_t flightCount = 0;
288  uint32_t operationTimeSum = 0;
289  uint32_t operationCount = 0;
290  uint32_t systemTimeSum = 0;
291  uint32_t systemUseCount = 0;
293  uint32_t timeToMaintenance = 0;
295  };
296 
297  private:
301  class TetherComImpl;
302  TetherComImpl* _pImpl;
303 
304  public:
305  TetherCom();
306  TetherCom(TetherCom&&);
307  TetherCom(const TetherCom&) = delete; // non construction-copyable
308  TetherCom& operator=(TetherCom&&) = default; // move assignment operator
309  TetherCom& operator=(const TetherCom&) = delete; // non copyable
310  ~TetherCom();
311 
319  void getSerialPortsInfo(std::vector<std::string>& devListPort, std::vector<std::string>& devListDesc, std::vector<std::string>& devListHwID);
320 
322  void printSerialPortList();
323 
328  void printSerialPortList(std::ostream& stream);
329 
337  void openConnection(const std::string& portName);
338 
344  void closeConnection();
345 
351  int getConnectionStatus();
352 
358  bool isConnected();
359 
366  void setConnectionTimeout(const unsigned int timeout);
367 
373  int getConnectionTimeout();
374 
383  void getSystemDetails(systemDetails& sysDetails);
384 
393  void getSystemStatus(systemStatus& sysStatus);
394 
428 
442  bool checkSystemStatus(systemStatus& sysStatus, TetherComDefinitions::systemError& errorStatus, bool checkMaintenance = false);
443 
455  bool checkSystemStatus(systemStatus& sysStatus, systemDetails& sysDetails, TetherComDefinitions::systemError& errorStatus, bool checkMaintenance = true);
456 
465  void getSystemConfig(systemConfig& config);
466 
472  unsigned int getMinimalCableRetractionTorque();
473 
479  unsigned int getMaximalCableRetractionTorque();
480 
487 
500  void setSystemConfig(const bool activation, const unsigned int retractionTorque, const float startLength);
501 
512  void setSystemConfig(const systemConfig& conf);
513 
522  void setSystemActivation(bool activation);
523 
534  void setCableRetractionTorque(unsigned int retractionTorque);
535 
547  void setCableRetractionStartLength(float startLength);
548 
558 
568 
578  void print();
579 
586  void print(systemStatus& sysStatus, std::ostream& stream = std::cout);
587 
594  void print(systemDetails& sysDetails, std::ostream& stream = std::cout);
595 
601  std::string getLibBuild();
602 
608  void getLibBuild(std::string& build);
609 
615  std::string getLibProtocolVersion();
616 
622  void getLibProtocolVersion(std::string& version);
623 
627  void printVersionDetails();
628 
634  void printVersionDetails(std::ostream& stream);
635 
636  };
637 };
638 
639 #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:142
void getSystemStatus(systemStatus &sysStatus)
Definition: TetherCom.cpp:119
void openConnection(const std::string &portName)
Definition: TetherCom.cpp:59
void setSystemConfig(const bool activation, const unsigned int retractionTorque, const float startLength)
Definition: TetherCom.cpp:203
unsigned int getMaximalCableRetractionTorque()
Definition: TetherCom.cpp:193
void setSystemActivation(bool activation)
Definition: TetherCom.cpp:243
float getMinimalCableRetractionStartLength()
Definition: TetherCom.cpp:198
bool checkSystemStatus(TetherComDefinitions::systemError &errorStatus)
Definition: TetherCom.cpp:135
unsigned int getMinimalCableRetractionTorque()
Definition: TetherCom.cpp:188
void setCableRetractionStartLength(float startLength)
Definition: TetherCom.cpp:283
void setCableRetractionTorque(unsigned int retractionTorque)
Definition: TetherCom.cpp:263
void getSystemStatusConfig(systemStatusConfig &conf)
Definition: TetherCom.cpp:303
void closeConnection()
Definition: TetherCom.cpp:71
void setConnectionTimeout(const unsigned int timeout)
Definition: TetherCom.cpp:93
bool isConnected()
Definition: TetherCom.cpp:88
void getSystemDetails(systemDetails &sysDetails)
Definition: TetherCom.cpp:103
void printVersionDetails()
Definition: TetherCom.cpp:381
void printSerialPortList()
Definition: TetherCom.cpp:49
int getConnectionTimeout()
Definition: TetherCom.cpp:98
void getSystemConfig(systemConfig &config)
Definition: TetherCom.cpp:172
void setSystemStatusConfig(systemStatusConfig &conf)
Definition: TetherCom.cpp:319
void print()
Definition: TetherCom.cpp:335
int getConnectionStatus()
Definition: TetherCom.cpp:83
std::string getLibBuild()
Definition: TetherCom.cpp:361
std::string getLibProtocolVersion()
Definition: TetherCom.cpp:371
void getSerialPortsInfo(std::vector< std::string > &devListPort, std::vector< std::string > &devListDesc, std::vector< std::string > &devListHwID)
Definition: TetherCom.cpp:44
Data content handling exception class.
Definition: TetherCom.h:103
ValueException(const char *description)
Definition: TetherCom.h:114
ValueException(const ValueException &other)
Definition: TetherCom.h:125
virtual const char * what() const
Definition: TetherCom.h:134
systemError
Definition: TetherComDefinitions.h:65
Namespace for classes and members developed by ValoFly GmbH.
Definition: TetherCom.h:23
Definition: TetherCom.h:162
int retractionStatus
Definition: TetherCom.h:165
float retractionStartLength
Definition: TetherCom.h:167
float speed
Definition: TetherCom.h:164
int guideStatus
Definition: TetherCom.h:169
float lengthUnwound
Definition: TetherCom.h:163
int reelStatus
Definition: TetherCom.h:170
int tetherStatus
Definition: TetherCom.h:168
unsigned int retractionTorque
Definition: TetherCom.h:166
Definition: TetherCom.h:194
float mainsU
Definition: TetherCom.h:195
int ctrlSupplyStatus
Definition: TetherCom.h:199
int mainsStatus
Definition: TetherCom.h:198
float mainsF
Definition: TetherCom.h:197
float backupBatteryVoltage
Definition: TetherCom.h:200
int backupBatteryStatus
Definition: TetherCom.h:201
float mainsI
Definition: TetherCom.h:196
Definition: TetherCom.h:206
int extSupplyStatus
Definition: TetherCom.h:210
float uavVoltage
Definition: TetherCom.h:207
float uavPower
Definition: TetherCom.h:209
float uavCurrent
Definition: TetherCom.h:208
int uavBatCellCount
Definition: TetherCom.h:211
Definition: TetherCom.h:175
float temp3
Definition: TetherCom.h:178
int envSensor3Status
Definition: TetherCom.h:184
int fan2RPM
Definition: TetherCom.h:188
float temp1
Definition: TetherCom.h:176
int fan1RPM
Definition: TetherCom.h:186
float pressure1
Definition: TetherCom.h:181
int fan2Status
Definition: TetherCom.h:189
int fan1Status
Definition: TetherCom.h:187
float temp4
Definition: TetherCom.h:179
int envSensor4Status
Definition: TetherCom.h:185
int envSensor1Status
Definition: TetherCom.h:182
float temp2
Definition: TetherCom.h:177
float humidity1
Definition: TetherCom.h:180
int envSensor2Status
Definition: TetherCom.h:183
Definition: TetherCom.h:241
int envCtrlStatus
Definition: TetherCom.h:246
int reelCtrlStatus
Definition: TetherCom.h:243
int lpwrCtrlStatus
Definition: TetherCom.h:244
int hpwrCtrlStatus
Definition: TetherCom.h:245
Configuration parameter structure.
Definition: TetherCom.h:153
int cableRetractionStatus
Definition: TetherCom.h:157
unsigned int cableRetractionTorque
Definition: TetherCom.h:155
bool systemActivation
Definition: TetherCom.h:154
float cableRetractionStartLength
Definition: TetherCom.h:156
std::string lpwrCtrl
Definition: TetherCom.h:274
std::string envCtrl
Definition: TetherCom.h:276
std::string netCtrl
Definition: TetherCom.h:277
std::string mainCtrl
Definition: TetherCom.h:272
std::string backupBatteryCtrl
Definition: TetherCom.h:278
std::string reelCtrl
Definition: TetherCom.h:273
std::string hpwrCtrl
Definition: TetherCom.h:275
Definition: TetherCom.h:263
std::string dayOfProduction
Definition: TetherCom.h:267
uint32_t flightCount
Definition: TetherCom.h:287
uint32_t operationCount
Definition: TetherCom.h:289
std::string cableType
Definition: TetherCom.h:283
std::string model
Definition: TetherCom.h:265
uint32_t systemUseCount
Definition: TetherCom.h:291
struct VALOFLY::TetherCom::systemDetails::softwareVersions softwareVersion
uint32_t systemTimeSum
Definition: TetherCom.h:290
int maxPower
Definition: TetherCom.h:282
uint32_t operationTimeSum
Definition: TetherCom.h:288
uint32_t timeToMaintenance
Definition: TetherCom.h:293
std::string productType
Definition: TetherCom.h:264
std::string serialNumber
Definition: TetherCom.h:266
uint32_t flightTimeSum
Definition: TetherCom.h:286
std::string hardwareVersion
Definition: TetherCom.h:268
std::string uavCellVoltages
Definition: TetherCom.h:281
std::string protocolVersion
Definition: TetherCom.h:280
int maxCableLength
Definition: TetherCom.h:284
int networkType
Definition: TetherCom.h:285
int maintenanceRequired
Definition: TetherCom.h:294
uint32_t maintenanceLastTimestamp
Definition: TetherCom.h:292
Definition: TetherCom.h:216
uint32_t systemTime
Definition: TetherCom.h:220
int backupBatteryStatus
Definition: TetherCom.h:219
int activation
Definition: TetherCom.h:217
uint32_t operationTime
Definition: TetherCom.h:221
uint32_t flightTime
Definition: TetherCom.h:222
uint32_t operationFlightTimeSum
Definition: TetherCom.h:223
int retractionStatus
Definition: TetherCom.h:218
uint32_t operationFlightCountSum
Definition: TetherCom.h:224
int error
Definition: TetherCom.h:225
Definition: TetherCom.h:230
int energyUAVEnabled
Definition: TetherCom.h:234
int energyGSEnabled
Definition: TetherCom.h:233
int envEnabled
Definition: TetherCom.h:232
int systemStatesEnabled
Definition: TetherCom.h:235
int cableEnabled
Definition: TetherCom.h:231
int hardwareModuleStatusEnabled
Definition: TetherCom.h:236
Definition: TetherCom.h:251
systemStates sysStates
Definition: TetherCom.h:257
energyUAVStatus energyUAV
Definition: TetherCom.h:256
systemStatusConfig conf
Definition: TetherCom.h:252
envStatus env
Definition: TetherCom.h:254
energyGSStatus energyGS
Definition: TetherCom.h:255
cableStatus cable
Definition: TetherCom.h:253
hardwareModuleStatus hwModules
Definition: TetherCom.h:258