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

All Component structure. More...

#include <jsondef.h>

Inheritance diagram for allstruc:
Collaboration diagram for allstruc:

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

bool enabled = true
 Enabled? More...
 
uint16_t type = 0
 Component Type. More...
 
uint16_t model = 0
 Device Model. More...
 
uint32_t flag = 0
 Device flag - catch all for any small piece of information that might be device specific. More...
 
uint16_t addr = 0
 Device specific address. More...
 
uint16_t cidx = 0
 Component Index. More...
 
uint16_t didx = 0
 Device specific index. More...
 
uint16_t pidx = 0
 Piece index. More...
 
uint16_t bidx = 0
 Power Bus index. More...
 
uint16_t portidx = 0
 Connection information for device. More...
 
float namp = 0.f
 Nominal Amperage. More...
 
float nvolt = 0.f
 Nominal Voltage. More...
 
float amp = 0.f
 Current Amperage. More...
 
float volt = 0.f
 Current Voltage. More...
 
float power = 0.f
 Current Power. More...
 
float energy = 0.f
 Total energy usage. More...
 
float drate = 0.f
 Current data rate. More...
 
float temp = 0.f
 Current Temperature. More...
 
double utc = 0.
 Device information time stamp. More...
 

Detailed Description

All Component structure.

These are the elements that are repeated in all devices. Each device specific structure has these as its first elements, followed by any specific elements. They are all then combined together in one grand union as a devicestruc.

Member Function Documentation

json11::Json allstruc::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
1627  {
1628  return json11::Json::object {
1629  { "enabled" , enabled },
1630  { "type" , type },
1631  { "model" , model },
1632  { "flag" , static_cast<int>(flag) },
1633  { "addr" , addr },
1634  { "cidx" , cidx },
1635  { "didx" , didx },
1636  { "pidx" , pidx },
1637  { "bidx" , bidx },
1638  { "portidx" , portidx },
1639  { "namp" , namp},
1640  { "nvolt" , nvolt },
1641  { "amp" , amp },
1642  { "volt" , volt },
1643  { "power" , power },
1644  { "energy" , energy },
1645  { "drate" , drate },
1646  { "temp" , temp },
1647  { "utc" , utc },
1648  };
1649  }
uint16_t model
Device Model.
Definition: jsondef.h:1589
uint16_t portidx
Connection information for device.
Definition: jsondef.h:1603
std::map< std::string, Json > object
Definition: json11.hpp:88
float power
Current Power.
Definition: jsondef.h:1613
float volt
Current Voltage.
Definition: jsondef.h:1611
uint16_t pidx
Piece index.
Definition: jsondef.h:1599
float energy
Total energy usage.
Definition: jsondef.h:1615
float drate
Current data rate.
Definition: jsondef.h:1617
uint16_t didx
Device specific index.
Definition: jsondef.h:1597
uint16_t type
Component Type.
Definition: jsondef.h:1587
uint16_t bidx
Power Bus index.
Definition: jsondef.h:1601
float amp
Current Amperage.
Definition: jsondef.h:1609
float namp
Nominal Amperage.
Definition: jsondef.h:1605
double utc
Device information time stamp.
Definition: jsondef.h:1621
bool enabled
Enabled?
Definition: jsondef.h:1585
uint32_t flag
Device flag - catch all for any small piece of information that might be device specific.
Definition: jsondef.h:1591
uint16_t addr
Device specific address.
Definition: jsondef.h:1593
float temp
Current Temperature.
Definition: jsondef.h:1619
uint16_t cidx
Component Index.
Definition: jsondef.h:1595
float nvolt
Nominal Voltage.
Definition: jsondef.h:1607
void allstruc::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
1657  {
1658  string error;
1659  json11::Json parsed = json11::Json::parse(s,error);
1660  if(error.empty()) {
1661  if(!parsed["enabled"].is_null()) { enabled = parsed["enabled"].bool_value(); }
1662  if(!parsed["type"].is_null()) { type = parsed["type"].int_value(); }
1663  if(!parsed["model"].is_null()) { model = parsed["model"].int_value(); }
1664  if(!parsed["flag"].is_null()) { flag = parsed["flag"].int_value(); }
1665  if(!parsed["addr"].is_null()) { addr = parsed["addr"].int_value(); }
1666  if(!parsed["cidx"].is_null()) { cidx = parsed["cidx"].int_value(); }
1667  if(!parsed["didx"].is_null()) { didx = parsed["didx"].int_value(); }
1668  if(!parsed["pidx"].is_null()) { pidx = parsed["pidx"].int_value(); }
1669  if(!parsed["bidx"].is_null()) { bidx = parsed["bidx"].int_value(); }
1670  if(!parsed["portidx"].is_null()) { portidx = parsed["portidx"].int_value(); }
1671  if(!parsed["namp"].is_null()) { namp = parsed["namp"].number_value(); }
1672  if(!parsed["nvolt"].is_null()) { nvolt = parsed["nvolt"].number_value(); }
1673  if(!parsed["amp"].is_null()) { amp = parsed["amp"].number_value(); }
1674  if(!parsed["volt"].is_null()) { volt = parsed["volt"].number_value(); }
1675  if(!parsed["power"].is_null()) { power = parsed["power"].number_value(); }
1676  if(!parsed["energy"].is_null()) { energy = parsed["energy"].number_value(); }
1677  if(!parsed["drate"].is_null()) { drate = parsed["drate"].number_value(); }
1678  if(!parsed["temp"].is_null()) { temp = parsed["temp"].number_value(); }
1679  if(!parsed["utc"].is_null()) { utc = parsed["utc"].number_value(); }
1680  } else {
1681  cerr<<"ERROR: <"<<error<<">"<<endl;
1682  }
1683  return;
1684  }
uint16_t model
Device Model.
Definition: jsondef.h:1589
uint16_t portidx
Connection information for device.
Definition: jsondef.h:1603
Definition: json11.hpp:79
float power
Current Power.
Definition: jsondef.h:1613
float volt
Current Voltage.
Definition: jsondef.h:1611
uint16_t pidx
Piece index.
Definition: jsondef.h:1599
float energy
Total energy usage.
Definition: jsondef.h:1615
float drate
Current data rate.
Definition: jsondef.h:1617
uint16_t didx
Device specific index.
Definition: jsondef.h:1597
uint16_t type
Component Type.
Definition: jsondef.h:1587
uint16_t bidx
Power Bus index.
Definition: jsondef.h:1601
float amp
Current Amperage.
Definition: jsondef.h:1609
float namp
Nominal Amperage.
Definition: jsondef.h:1605
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
double utc
Device information time stamp.
Definition: jsondef.h:1621
bool enabled
Enabled?
Definition: jsondef.h:1585
bool bool_value() const
Definition: json11.cpp:282
uint32_t flag
Device flag - catch all for any small piece of information that might be device specific.
Definition: jsondef.h:1591
uint16_t addr
Device specific address.
Definition: jsondef.h:1593
float temp
Current Temperature.
Definition: jsondef.h:1619
uint16_t cidx
Component Index.
Definition: jsondef.h:1595
float nvolt
Nominal Voltage.
Definition: jsondef.h:1607
int int_value() const
Definition: json11.cpp:281
double number_value() const
Definition: json11.cpp:280

Member Data Documentation

bool allstruc::enabled = true

Enabled?

uint16_t allstruc::type = 0

Component Type.

uint16_t allstruc::model = 0

Device Model.

uint32_t allstruc::flag = 0

Device flag - catch all for any small piece of information that might be device specific.

uint16_t allstruc::addr = 0

Device specific address.

uint16_t allstruc::cidx = 0

Component Index.

uint16_t allstruc::didx = 0

Device specific index.

uint16_t allstruc::pidx = 0

Piece index.

uint16_t allstruc::bidx = 0

Power Bus index.

uint16_t allstruc::portidx = 0

Connection information for device.

float allstruc::namp = 0.f

Nominal Amperage.

float allstruc::nvolt = 0.f

Nominal Voltage.

float allstruc::amp = 0.f

Current Amperage.

float allstruc::volt = 0.f

Current Voltage.

float allstruc::power = 0.f

Current Power.

float allstruc::energy = 0.f

Total energy usage.

float allstruc::drate = 0.f

Current data rate.

float allstruc::temp = 0.f

Current Temperature.

double allstruc::utc = 0.

Device information time stamp.


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