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

Battery (BATT) structure. More...

#include <jsondef.h>

Collaboration diagram for battstruc:

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

float capacity = 0.f
 Capacity in amp hours. More...
 
float efficiency = 0.f
 Charge conversion efficiency. More...
 
float charge = 0.f
 Charge in amp hours. More...
 
float r_in = 0.f
 Resistance in. More...
 
float r_out = 0.f
 Resistance out. More...
 
float percentage = 0.f
 Battery Percentage Remaining. More...
 
float time_remaining = 0.f
 Time Remaining. More...
 

Detailed Description

Battery (BATT) structure.

Member Function Documentation

json11::Json battstruc::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
2666  {
2667  return json11::Json::object {
2668  { "capacity" , capacity },
2669  { "efficiency", efficiency },
2670  { "charge" , charge },
2671  { "r_in" , r_in },
2672  { "r_out" , r_out },
2673  { "percentage", percentage },
2674  { "time_remaining" , time_remaining }
2675  };
2676  }
std::map< std::string, Json > object
Definition: json11.hpp:88
float charge
Charge in amp hours.
Definition: jsondef.h:2652
float percentage
Battery Percentage Remaining.
Definition: jsondef.h:2658
float capacity
Capacity in amp hours.
Definition: jsondef.h:2648
float time_remaining
Time Remaining.
Definition: jsondef.h:2660
float efficiency
Charge conversion efficiency.
Definition: jsondef.h:2650
float r_out
Resistance out.
Definition: jsondef.h:2656
float r_in
Resistance in.
Definition: jsondef.h:2654
void battstruc::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
2684  {
2685  string error;
2686  json11::Json parsed = json11::Json::parse(s,error);
2687  if(error.empty()) {
2688  if(!parsed["capacity"].is_null()) { capacity = parsed["capacity"].number_value(); }
2689  if(!parsed["efficiency"].is_null()) { efficiency = parsed["efficiency"].number_value(); }
2690  if(!parsed["charge"].is_null()) { charge = parsed["charge"].number_value(); }
2691  if(!parsed["r_in"].is_null()) { r_in = parsed["r_in"].number_value(); }
2692  if(!parsed["r_out"].is_null()) { r_out = parsed["r_out"].number_value(); }
2693  if(!parsed["percentage"].is_null()) { percentage = parsed["percentage"].number_value(); }
2694  if(!parsed["time_remaining"].is_null()) { time_remaining = parsed["time_remaining"].number_value(); }
2695  } else {
2696  cerr<<"ERROR: <"<<error<<">"<<endl;
2697  }
2698  return;
2699  }
float charge
Charge in amp hours.
Definition: jsondef.h:2652
Definition: json11.hpp:79
float percentage
Battery Percentage Remaining.
Definition: jsondef.h:2658
float capacity
Capacity in amp hours.
Definition: jsondef.h:2648
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
float time_remaining
Time Remaining.
Definition: jsondef.h:2660
float efficiency
Charge conversion efficiency.
Definition: jsondef.h:2650
float r_out
Resistance out.
Definition: jsondef.h:2656
float r_in
Resistance in.
Definition: jsondef.h:2654
double number_value() const
Definition: json11.cpp:280

Member Data Documentation

float battstruc::capacity = 0.f

Capacity in amp hours.

float battstruc::efficiency = 0.f

Charge conversion efficiency.

float battstruc::charge = 0.f

Charge in amp hours.

float battstruc::r_in = 0.f

Resistance in.

float battstruc::r_out = 0.f

Resistance out.

float battstruc::percentage = 0.f

Battery Percentage Remaining.

float battstruc::time_remaining = 0.f

Time Remaining.


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