COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
telemstruc Struct Reference

Telemetry (TELEM) structure. More...

#include <jsondef.h>

Collaboration diagram for telemstruc:

Public Member Functions

json11::Json to_json () const
 Convert class contents to JSON object. More...
 
void from_json (const string &s)
 Set class contents from JSON string. More...
 

Public Attributes

uint16_t type = 0
 Data type. More...
 
uint8_t vuint8 = 0
 Union of data. More...
 
int8_t vint8 = 0
 
uint16_t vuint16 = 0
 
int16_t vint16 = 0
 
uint32_t vuint32 = 0
 
int32_t vint32 = 0
 
float vfloat = 0.f
 
double vdouble = 0.f
 
char vstring [40+1] = ""
 

Detailed Description

Telemetry (TELEM) structure.

This provides access to a union of a variety of possible data types, along with an optional indicator of what type the data actually is. The same data is then accessible as all supported data types, both in the structure and the Namespace.

Member Function Documentation

json11::Json telemstruc::to_json ( ) const
inline

Convert class contents to JSON object.

Returns a json11 JSON object of the class

Returns
A json11 JSON object containing every member variable within the class
1721  {
1722  return json11::Json::object {
1723  { "type" , type },
1724  { "vstring", vstring }
1725  };
1726  }
std::map< std::string, Json > object
Definition: json11.hpp:88
uint16_t type
Data type.
Definition: jsondef.h:1702
char vstring[40+1]
Definition: jsondef.h:1714
void telemstruc::from_json ( const string &  s)
inline

Set class contents from JSON string.

Parses the provided JSON-formatted string and sets the class data. String should be formatted like the string returned from to_json()

Parameters
sJSON-formatted string to set class contents to
Returns
n/a
1734  {
1735  string error;
1736  json11::Json parsed = json11::Json::parse(s,error);
1737  if(error.empty()) {
1738  if(!parsed["type"].is_null()) { type = parsed["type"].number_value(); }
1739 // TODO: vstring = parsed["vstring"].string_value();
1740  } else {
1741  cerr<<"ERROR: <"<<error<<">"<<endl;
1742  }
1743  return;
1744  }
Definition: json11.hpp:79
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
uint16_t type
Data type.
Definition: jsondef.h:1702
double number_value() const
Definition: json11.cpp:280

Member Data Documentation

uint16_t telemstruc::type = 0

Data type.

uint8_t telemstruc::vuint8 = 0

Union of data.

int8_t telemstruc::vint8 = 0
uint16_t telemstruc::vuint16 = 0
int16_t telemstruc::vint16 = 0
uint32_t telemstruc::vuint32 = 0
int32_t telemstruc::vint32 = 0
float telemstruc::vfloat = 0.f
double telemstruc::vdouble = 0.f
char telemstruc::vstring[40+1] = ""

The documentation for this struct was generated from the following file: