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

Torque Rod Control Unit. More...

#include <jsondef.h>

Collaboration diagram for tcustruc:

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 mcnt = 0
 Torque Rod count. More...
 
uint16_t mcidx [3] = {0}
 Torque Rod Component indices. More...
 

Detailed Description

Torque Rod Control Unit.

Member Function Documentation

json11::Json tcustruc::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
3040  {
3041  vector<uint16_t> v_mcidx = vector<uint16_t>(mcidx, mcidx+sizeof(mcidx)/sizeof(mcidx[0]));
3042  return json11::Json::object {
3043  { "mcnt" , mcnt },
3044  { "mcidx", v_mcidx }
3045  };
3046  }
std::map< std::string, Json > object
Definition: json11.hpp:88
uint16_t mcidx[3]
Torque Rod Component indices.
Definition: jsondef.h:3034
uint16_t mcnt
Torque Rod count.
Definition: jsondef.h:3032
void tcustruc::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
3054  {
3055  string error;
3056  json11::Json parsed = json11::Json::parse(s,error);
3057  if(error.empty()) {
3058  if(!parsed["mcnt"].is_null()) { mcnt = parsed["mcnt"].int_value(); }
3059  if(!parsed["mcidx"].is_null()) {
3060  auto p_mcidx = parsed["mcidx"].array_items();
3061  for(size_t i = 0; i != p_mcidx.size(); ++i) {
3062  if(!p_mcidx[i].is_null()) { mcidx[i] = p_mcidx[i].int_value(); }
3063  }
3064  }
3065  } else {
3066  cerr<<"ERROR: <"<<error<<">"<<endl;
3067  }
3068  return;
3069  }
Definition: json11.hpp:79
int i
Definition: rw_test.cpp:37
uint16_t mcidx[3]
Torque Rod Component indices.
Definition: jsondef.h:3034
uint16_t mcnt
Torque Rod count.
Definition: jsondef.h:3032
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
const array & array_items() const
Definition: json11.cpp:284
int int_value() const
Definition: json11.cpp:281

Member Data Documentation

uint16_t tcustruc::mcnt = 0

Torque Rod count.

uint16_t tcustruc::mcidx[3] = {0}

Torque Rod Component indices.


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