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

Payload (PLOAD) structure. More...

#include <jsondef.h>

Collaboration diagram for ploadstruc:

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 key_cnt = 0
 Number of keys being used. More...
 
uint16_t keyidx [10] = {0}
 Name for each key. More...
 
float keyval [10] = {0.f}
 Value for each key. More...
 

Detailed Description

Payload (PLOAD) structure.

You can define up to MAXPLOADKEYCNT keys by giving them unique names. You can then set double precision values for these keys in the dynamic structure.

Member Function Documentation

json11::Json ploadstruc::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
1765  {
1766  vector<uint16_t> v_keyidx = vector<uint16_t>(keyidx, keyidx+MAXPLOADKEYCNT);
1767  vector<float> v_keyval = vector<float>(keyval, keyval+MAXPLOADKEYCNT);
1768  return json11::Json::object {
1769  { "key_cnt", key_cnt },
1770  { "keyidx" , v_keyidx },
1771  { "keyval" , v_keyval }
1772  };
1773  }
std::map< std::string, Json > object
Definition: json11.hpp:88
uint16_t key_cnt
Number of keys being used.
Definition: jsondef.h:1755
float keyval[10]
Value for each key.
Definition: jsondef.h:1759
uint16_t keyidx[10]
Name for each key.
Definition: jsondef.h:1757
#define MAXPLOADKEYCNT
Maximum number of Special Payload Keys.
Definition: jsondef.h:416
void ploadstruc::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
1781  {
1782  string error;
1783  json11::Json parsed = json11::Json::parse(s,error);
1784  if(error.empty()) {
1785  if(!parsed["key_cnt"].is_null()) { key_cnt = parsed["key_cnt"].number_value(); }
1786  if(!parsed["keyidx"].is_null()) {
1787  auto p_keyidx = parsed["keyidx"].array_items();
1788  for(size_t i = 0; i != p_keyidx.size(); ++i) {
1789  if(!parsed["keyidx"][i].is_null()) { keyidx[i] = p_keyidx[i].int_value(); }
1790  }
1791  }
1792  if(!parsed["keyval"].is_null()) {
1793  auto p_keyval = parsed["keyval"].array_items();
1794  for(size_t i = 0; i != p_keyval.size(); ++i) {
1795  if(!parsed["keyval"][i].is_null()) { keyval[i] = p_keyval[i].number_value(); }
1796  }
1797  }
1798  } else {
1799  cerr<<"ERROR: <"<<error<<">"<<endl;
1800  }
1801  return;
1802  }
Definition: json11.hpp:79
int i
Definition: rw_test.cpp:37
uint16_t key_cnt
Number of keys being used.
Definition: jsondef.h:1755
float keyval[10]
Value for each key.
Definition: jsondef.h:1759
uint16_t keyidx[10]
Name for each key.
Definition: jsondef.h:1757
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
const array & array_items() const
Definition: json11.cpp:284
double number_value() const
Definition: json11.cpp:280

Member Data Documentation

uint16_t ploadstruc::key_cnt = 0

Number of keys being used.

uint16_t ploadstruc::keyidx[10] = {0}

Name for each key.

float ploadstruc::keyval[10] = {0.f}

Value for each key.


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