COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
Collaboration diagram for JSON functions:

Functions

void json_init_unit (cosmosstruc *cinfo)
 
void json_init_device_type_string ()
 
void json_init_node (cosmosstruc *cinfo)
 
void json_init_reserve (cosmosstruc *cinfo)
 
cosmosstrucjson_init ()
 Initialize JSON pointer map. More...
 
void json_destroy (cosmosstruc *cinfo)
 Remove JSON pointer map. More...
 
uint16_t json_hash (string hstring)
 Calculate JSON HASH. More...
 
int32_t json_create_node (cosmosstruc *cinfo, string &node_name, uint16_t node_type)
 
int32_t json_create_cpu (string &node_name)
 
int32_t json_create_mcc (string &node_name)
 
int32_t json_createpiece (cosmosstruc *cinfo, string name, DeviceType ctype, double emi, double abs, double hcap, double hcon, double density)
 Create new piece. More...
 
int32_t json_finddev (cosmosstruc *cinfo, string name)
 
int32_t json_findcomp (cosmosstruc *cinfo, string name)
 
int32_t json_findpiece (cosmosstruc *cinfo, string name)
 
int32_t json_addpiece (cosmosstruc *cinfo, string name, DeviceType ctype, double emi, double abs, double hcap, double hcon, double density)
 Add new piece. More...
 
int32_t json_createport (cosmosstruc *cinfo, string name, PORT_TYPE type)
 
int32_t json_addentry (jsonentry entry, cosmosstruc *cinfo)
 Enter an entry into the JSON Namespace. More...
 
int32_t json_addentry (string name, uint16_t d1, uint16_t d2, ptrdiff_t offset, uint16_t type, uint16_t group, cosmosstruc *cinfo, uint16_t unit)
 Add an entry to the JSON Namespace map with units. More...
 
int32_t json_addentry (string name, uint16_t d1, uint16_t d2, uint8_t *ptr, uint16_t type, cosmosstruc *cinfo, uint16_t unit)
 
int32_t json_toggleentry (string name, uint16_t d1, uint16_t d2, cosmosstruc *cinfo, bool state)
 Toggle the enable state of an entry in the JSON Namespace map. More...
 
bool json_checkentry (string name, uint16_t d1, uint16_t d2, cosmosstruc *cinfo)
 Check the enable state of an entry in the JSON Namespace map. More...
 
size_t json_count_hash (uint16_t hash, cosmosstruc *cinfo)
 Number of items in current JSON map with a specific hash. More...
 
size_t json_count_total (cosmosstruc *cinfo)
 Number of items in the current JSON map. More...
 
int32_t json_out_handle (string &jstring, jsonhandle handle, cosmosstruc *cinfo)
 Perform JSON output for a JSON item by handle. More...
 
int32_t json_out_entry (string &jstring, const jsonentry &entry, cosmosstruc *cinfo)
 Perform JSON output for a single JSON entry. More...
 
int32_t json_out_value (string &jstring, string name, uint8_t *data, uint16_t type, cosmosstruc *cinfo)
 Output JSON Pair. More...
 
int32_t json_out_type (string &jstring, uint8_t *data, uint16_t type, cosmosstruc *cinfo)
 Output JSON Value. More...
 
int32_t json_append (string &jstring, const char *tstring)
 Extend JSON stream. More...
 
int32_t json_out_character (string &jstring, char character)
 Single character to JSON. More...
 
int32_t json_out_name (string &jstring, string name)
 Object name to JSON. More...
 
int32_t json_out_bool (string &jstring, bool value)
 Boolean to JSON. More...
 
int32_t json_out_int8 (string &jstring, int8_t value)
 Signed 8 bit integer to JSON. More...
 
int32_t json_out_int16 (string &jstring, int16_t value)
 Signed 16 bit integer to JSON. More...
 
int32_t json_out_int32 (string &jstring, int32_t value)
 Signed 32 bit integer to JSON. More...
 
int32_t json_out_uint8 (string &jstring, uint8_t value)
 Unsigned 8 bit integer to JSON. More...
 
int32_t json_out_uint16 (string &jstring, uint16_t value)
 Unsigned 16 bit integer to JSON. More...
 
int32_t json_out_uint32 (string &jstring, uint32_t value)
 Unsigned 32 bit integer to JSON. More...
 
int32_t json_out_float (string &jstring, float value)
 Single precision floating vertex32_t to JSON. More...
 
int32_t json_out_double (string &jstring, double value)
 Perform JSON output for a single nonindexed double. More...
 
int32_t json_out_string (string &jstring, string ostring, uint16_t len)
 String to JSON. More...
 
int32_t json_out_gvector (string &jstring, gvector value)
 gvector to JSON More...
 
int32_t json_out_svector (string &jstring, svector value)
 svector to JSON More...
 
int32_t json_out_avector (string &jstring, avector value)
 avector to JSON More...
 
int32_t json_out_vector (string &jstring, Vector value)
 ::Vector to JSON More...
 
int32_t json_out_rvector (string &jstring, rvector value)
 rvector to JSON More...
 
int32_t json_out_quaternion (string &jstring, quaternion value)
 quaternion to JSON More...
 
int32_t json_out_cvector (string &jstring, cvector value)
 cvector to JSON More...
 
int32_t json_out_cartpos (string &jstring, cartpos value)
 cartpos to JSON More...
 
int32_t json_out_geoidpos (string &jstring, geoidpos value)
 geoidpos to JSON More...
 
int32_t json_out_spherpos (string &jstring, spherpos value)
 spherpos to JSON More...
 
int32_t json_out_node (string &jstring, string value)
 Node name to JSON. More...
 
int32_t json_out_utcstart (string &jstring, double value)
 UTC Start to JSON. More...
 
int32_t json_out_ecipos (string &jstring, cartpos value)
 ECI position to JSON. More...
 
int32_t json_out_posstruc (string &jstring, posstruc value)
 posstruc to JSON More...
 
int32_t json_out_attstruc (string &jstring, attstruc value)
 attstruc to JSON More...
 
int32_t json_out_locstruc (string &jstring, locstruc value)
 locstruc to JSON More...
 
int32_t json_out_commandevent (string &jstring, eventstruc value)
 Command event to JSON. More...
 
int32_t json_out_dcmatt (string &jstring, dcmatt value)
 
int32_t json_out_qatt (string &jstring, qatt value)
 qatt to JSON More...
 
int32_t json_out_dcm (string &jstring, rmatrix value)
 rmatrix to JSON More...
 
int32_t json_out_rmatrix (string &jstring, rmatrix value)
 rmatrix to JSON More...
 
int32_t json_out_beatstruc (string &jstring, beatstruc value)
 beatstruc to JSON More...
 
int32_t json_out_1d (string &jstring, const char *token, uint16_t index, cosmosstruc *cinfo)
 Perform JSON output for a single element of a 1D named JSON item. More...
 
int32_t json_out_2d (string &jstring, const char *token, uint16_t row, uint16_t col, cosmosstruc *cinfo)
 Perform JSON output for a single element of a 2D named JSON item. More...
 
int32_t json_out (string &jstring, string token, cosmosstruc *cinfo)
 Perform JSON output for a single named JSON item. More...
 
int32_t json_out_list (string &jstring, string tokens, cosmosstruc *cinfo)
 Output a list of named JSON items. More...
 
int32_t json_out_wildcard (string &jstring, string wildcard, cosmosstruc *cinfo)
 Output JSON items from wildcard. More...
 
uint8_t * json_ptr_of_entry (const jsonentry &entry, cosmosstruc *cinfo)
 Address from entry. More...
 
uint8_t * json_ptr_of_offset (ptrdiff_t offset, uint16_t group, cosmosstruc *cinfo)
 Address from offset. More...
 
int32_t json_table_of_list (vector< jsonentry * > &table, string tokens, cosmosstruc *cinfo)
 Output a vector of JSON entries. More...
 
jsonentryjson_entry_of (uint8_t *ptr, cosmosstruc *cinfo)
 Info on Namespace address. More...
 
jsonentryjson_entry_of (string token, cosmosstruc *cinfo)
 Info on Namespace name. More...
 
jsonequationjson_equation_of (jsonhandle handle, cosmosstruc *cinfo)
 Info on Namespace equation. More...
 
jsonentryjson_entry_of (jsonhandle handle, cosmosstruc *cinfo)
 Info on Namespace name. More...
 
uint16_t json_type_of_name (string token, cosmosstruc *cinfo)
 Type of namespace name. More...
 
uint8_t * json_ptrto (string token, cosmosstruc *cinfo)
 Return the data pointer that matches a JSON name. More...
 
uint8_t * json_ptrto_1d (string token, uint16_t index1, cosmosstruc *cinfo)
 Return the data pointer that matches a singly indexed JSON name. More...
 
uint8_t * json_ptrto_2d (string token, uint16_t index1, uint16_t index2, cosmosstruc *cinfo)
 Return the data pointer that matches a doubly indexed JSON name. More...
 
int32_t json_get_int (jsonhandle &handle, cosmosstruc *cinfo)
 Return integer from handle. More...
 
int32_t json_get_int (const jsonentry &entry, cosmosstruc *cinfo)
 Return integer from entry. More...
 
int32_t json_get_int (string token, cosmosstruc *cinfo)
 Return integer from name. More...
 
int32_t json_get_int (string token, uint16_t index1, cosmosstruc *cinfo)
 Return integer from 1d name. More...
 
int32_t json_get_int (string token, uint16_t index1, uint16_t index2, cosmosstruc *cinfo)
 Return integer from 2d name. More...
 
uint32_t json_get_uint (jsonhandle &handle, cosmosstruc *cinfo)
 Return unsigned integer from handle. More...
 
uint32_t json_get_uint (const jsonentry &entry, cosmosstruc *cinfo)
 Return unsigned integer from entry. More...
 
uint32_t json_get_uint (string token, cosmosstruc *cinfo)
 Return unsigned integer from name. More...
 
uint32_t json_get_uint (string token, uint16_t index1, cosmosstruc *cinfo)
 Return unsigned integer from 1d name. More...
 
uint32_t json_get_uint (string token, uint16_t index1, uint16_t index2, cosmosstruc *cinfo)
 Return unsigned integer from 2d name. More...
 
double json_get_double (jsonhandle &handle, cosmosstruc *cinfo)
 Return double from handle. More...
 
double json_get_double (string token, cosmosstruc *cinfo)
 Return double from name. More...
 
double json_get_double (const jsonentry &entry, cosmosstruc *cinfo)
 Return double from entry. More...
 
rvector json_get_rvector (const jsonentry &entry, cosmosstruc *cinfo)
 Return rvector from entry. More...
 
quaternion json_get_quaternion (const jsonentry &entry, cosmosstruc *cinfo)
 Return quaternion from entry. More...
 
double json_get_double (string token, uint16_t index1, cosmosstruc *cinfo)
 Return double from 1d name. More...
 
double json_get_double (string token, uint16_t index1, uint16_t index2, cosmosstruc *cinfo)
 Return double from 2d name. More...
 
string json_get_string (string token, cosmosstruc *cinfo)
 Return string from name. More...
 
string json_get_string (const jsonentry &entry, cosmosstruc *cinfo)
 Return string from entry. More...
 
posstruc json_get_posstruc (const jsonentry &entry, cosmosstruc *cinfo)
 Return posstruc from entry. More...
 
int32_t json_set_double_name (double value, char *token, cosmosstruc *cinfo)
 Set name from double. More...
 
double json_equation (const char *&ptr, cosmosstruc *cinfo)
 Return the results of a JSON equation. More...
 
double json_equation (jsonhandle *handle, cosmosstruc *cinfo)
 Return the results of a known JSON equation handle. More...
 
double json_equation (jsonequation *ptr, cosmosstruc *cinfo)
 Return the results of a known JSON equation entry. More...
 
string json_extract_namedmember (string json, string token)
 Extract JSON value matching name. More...
 
int32_t json_extract_value (const char *&ptr, string &value)
 Extract next JSON value. More...
 
string json_convert_string (string object)
 Convert JSON to string. More...
 
double json_convert_double (string object)
 Convert JSON to double. More...
 
int32_t json_tokenize (string jstring, cosmosstruc *cinfo, vector< jsontoken > &tokens)
 Tokenize using JSON Name Space. More...
 
int32_t json_tokenize_namedmember (const char *&ptr, cosmosstruc *cinfo, jsontoken &token)
 Tokenize next JSON Named Pair. More...
 
int32_t json_parse (string jstring, cosmosstruc *cinfo)
 Parse JSON using Name Space. More...
 
int32_t json_parse_namedmember (const char *&ptr, cosmosstruc *cinfo)
 Parse next JSON Named Pair. More...
 
int32_t json_skip_character (const char *&ptr, const char character)
 Skip over a specific character in a JSON stream. More...
 
int32_t json_extract_name (const char *&ptr, string &ostring)
 Parse the next variable name out of a JSON stream. More...
 
int32_t json_parse_equation (const char *&ptr, string &equation)
 Parse the next JSON equation out of a JSON stream. More...
 
int32_t json_parse_operand (const char *&ptr, jsonoperand *operand, cosmosstruc *cinfo)
 Parse the next JSON equation operand out of a JSON stream. More...
 
int32_t json_extract_string (const char *&ptr, string &ostring)
 Parse the next JSON string out of a JSON stream. More...
 
int32_t json_parse_number (const char *&ptr, double *number)
 Parse the next number out of a JSON stream. More...
 
int32_t json_skip_white (const char *&ptr)
 Skip white space in JSON string. More...
 
int32_t json_skip_to_next_member (const char *&ptr)
 Skip to next COSMOS name in JSON string. More...
 
int32_t json_set_string (string val, const jsonentry &entry, cosmosstruc *cinfo)
 
int32_t json_set_number (double val, const jsonentry &entry, cosmosstruc *cinfo)
 
int32_t json_parse_value (const char *&ptr, const jsonentry &entry, cosmosstruc *cinfo)
 
int32_t json_parse_value (const char *&ptr, uint16_t type, ptrdiff_t offset, uint16_t group, cosmosstruc *cinfo)
 
int32_t json_parse_value (const char *&ptr, uint16_t type, uint8_t *data, cosmosstruc *cinfo)
 
int32_t json_clear_cosmosstruc (int32_t type, cosmosstruc *cinfo)
 Clear global data structure. More...
 
int32_t json_load_node (string node, jsonnode &json)
 Map Name Space to global data structure components and pieces. More...
 
int32_t json_recenter_node (cosmosstruc *cinfo)
 
int32_t json_pushdevspec (uint16_t cidx, cosmosstruc *cinfo)
 
int32_t json_setup_node (jsonnode json, cosmosstruc *cinfo, bool create_flag)
 Setup JSON Namespace using Node description JSON. More...
 
int32_t json_setup_node (string &node, cosmosstruc *cinfo)
 Setup JSON Namespace using file. More...
 
int32_t json_dump_node (cosmosstruc *cinfo)
 Save Node entries to disk. More...
 
int32_t json_mapentries (cosmosstruc *cinfo)
 
int32_t json_mapbaseentries (cosmosstruc *cinfo)
 Add base entries to JMAP. More...
 
int32_t json_mapvertexentry (uint16_t vidx, cosmosstruc *cinfo)
 Add vertex entry. More...
 
int32_t json_mapfaceentry (uint16_t fidx, cosmosstruc *cinfo)
 Add face entry. More...
 
int32_t json_mappieceentry (uint16_t pidx, cosmosstruc *cinfo)
 Add piece entry. More...
 
int32_t json_togglepieceentry (uint16_t pidx, cosmosstruc *cinfo, bool state)
 Toggle piece entry. More...
 
int32_t json_mapcompentry (uint16_t cidx, cosmosstruc *cinfo)
 Add component entry. More...
 
int32_t json_togglecompentry (uint16_t cidx, cosmosstruc *cinfo, bool state)
 Toggle component entry. More...
 
uint16_t json_mapdeviceentry (const devicestruc &device, cosmosstruc *cinfo)
 Add device entry. More...
 
int32_t json_toggledeviceentry (uint16_t didx, DeviceType type, cosmosstruc *cinfo, bool state)
 Toggle device entry. More...
 
uint16_t json_mapportentry (uint16_t portidx, cosmosstruc *cinfo)
 Add port entry. More...
 
int32_t json_toggleportentry (uint16_t portidx, cosmosstruc *cinfo, bool state)
 Toggle port entry. More...
 
const char * json_of_wildcard (string &jstring, string wildcard, cosmosstruc *cinfo)
 Create JSON stream from wildcard. More...
 
const char * json_of_list (string &jstring, string list, cosmosstruc *cinfo)
 Create JSON stream from list. More...
 
const char * json_of_table (string &jstring, vector< jsonentry * > table, cosmosstruc *cinfo)
 Create JSON stream from entries. More...
 
const char * json_of_target (string &jstring, cosmosstruc *cinfo, uint16_t num)
 Create JSON Track string. More...
 
const char * json_of_node (string &jstring, cosmosstruc *cinfo)
 Create JSON Node string. More...
 
const char * json_of_agent (string &jstring, cosmosstruc *cinfo)
 Create JSON Agent string. More...
 
const char * json_of_time (string &jstring, cosmosstruc *cinfo)
 Create JSON Time string. More...
 
const char * json_of_beat (string &jstring, cosmosstruc *cinfo)
 Create JSON Heart Beat string. More...
 
const char * json_of_beacon (string &jstring, cosmosstruc *cinfo)
 Create JSON Beacon string. More...
 
const char * json_of_imu (string &jstring, uint16_t num, cosmosstruc *cinfo)
 Create JSON IMU string. More...
 
const char * json_of_ephemeris (string &jstring, cosmosstruc *cinfo)
 
const char * json_of_utc (string &jstring, cosmosstruc *cinfo)
 
string json_list_of_all (cosmosstruc *cinfo)
 Get list of all Namespace names. More...
 
string json_list_of_soh (cosmosstruc *cinfo)
 
string json_list_of_fullsoh (cosmosstruc *cinfo)
 
const char * json_of_soh (string &jstring, cosmosstruc *cinfo)
 
const char * json_of_event (string &jstring, cosmosstruc *cinfo)
 Create JSON for an event. More...
 
const char * json_of_groundcontact (string &jstring, cosmosstruc *cinfo)
 
const char * json_of_mtr (string &jstring, uint16_t index, cosmosstruc *cinfo)
 
const char * json_of_rw (string &jstring, uint16_t index, cosmosstruc *cinfo)
 
const char * json_of_state_eci (string &jstring, cosmosstruc *cinfo)
 
const char * json_of_state_geoc (string &jstring, cosmosstruc *cinfo)
 
const char * json_node (string &jstring, cosmosstruc *cinfo)
 Dump Node description. More...
 
const char * json_vertices (string &jstring, cosmosstruc *cinfo)
 Dump Vertex description. More...
 
const char * json_faces (string &jstring, cosmosstruc *cinfo)
 Dump Face description. More...
 
const char * json_pieces (string &jstring, cosmosstruc *cinfo)
 Dump Piece description. More...
 
const char * json_devices_general (string &jstring, cosmosstruc *cinfo)
 Dump General Device description. More...
 
const char * json_devices_specific (string &jstring, cosmosstruc *cinfo)
 Dump Specific Device description. More...
 
const char * json_ports (string &jstring, cosmosstruc *cinfo)
 Dump Port description. More...
 
void json_test (cosmosstruc *cinfo)
 
int32_t json_name_map (string name, cosmosstruc *cinfo, jsonhandle &handle)
 Get hash and index in JSON Namespace map. More...
 
int32_t json_equation_map (string equation, cosmosstruc *cinfo, jsonhandle *handle)
 Get hash and index in JSON Equation map. More...
 
int32_t json_clone (cosmosstruc *cinfo1, cosmosstruc *cinfo2)
 Clone cosmosstruc data areas, direct. More...
 
uint32_t json_get_name_list_count (cosmosstruc *cinfo)
 
int32_t node_init (string node, cosmosstruc *cinfo)
 Initialize Node configuration. More...
 
int32_t node_calc (cosmosstruc *cinfo)
 Calculate Satellite configuration values. More...
 
void create_databases (cosmosstruc *cinfo)
 Dump tab delimited database files. More...
 
int32_t load_target (cosmosstruc *cinfo)
 Load Track list. More...
 
int32_t update_target (cosmosstruc *cinfo)
 Update Track list. More...
 
int32_t update_target (locstruc source, targetstruc &target)
 
size_t load_dictionary (vector< eventstruc > &dict, cosmosstruc *cinfo, const char *file)
 Load Event Dictionary. More...
 
size_t calc_events (vector< eventstruc > &dictionary, cosmosstruc *cinfo, vector< eventstruc > &events)
 Calculate current Events. More...
 
uint16_t device_type_index (string name)
 
string device_type_name (uint32_t type)
 
std::ostream & operator<< (std::ostream &out, const beatstruc &b)
 
int32_t json_clone (cosmosstruc *cinfo)
 
int32_t json_repoint (cosmosstruc *cinfo)
 
int32_t json_addentry (string name, string value, cosmosstruc *cinfo)
 
int32_t json_out_tvector (string &jstring, rvector value)
 
uint8_t * json_ptrto_1d (const char *token, uint16_t index1, cosmosstruc *cinfo)
 
uint8_t * json_ptrto_2d (const char *token, uint16_t index1, uint16_t index2, cosmosstruc *cinfo)
 
int32_t json_scan (char *istring)
 
int32_t json_convert_int32 (string object)
 
uint32_t json_convert_uint32 (string object)
 
int16_t json_convert_int16 (string object)
 
uint16_t json_convert_uint16 (string object)
 
float json_convert_float (string object)
 
const char * json_of_groundcontact (cosmosstruc *cinfo)
 
const char * json_of_groundstation (string &jstring, cosmosstruc *cinfo)
 
const char * json_of_log (string &jstring, cosmosstruc *cinfo)
 
bool json_static (char *json_extended_name)
 
bool json_dynamic (char *json_extended_name)
 
string port_type_name (uint32_t type)
 

Detailed Description

Function Documentation

void json_init_unit ( cosmosstruc cinfo)
75  {
76 
77  // Create JSON Map unit table
78  for (uint16_t i=0; i<JSON_UNIT_COUNT; ++i)
79  {
80  // SI Units
81  cinfo->unit.push_back(vector<unitstruc>());
82  unitstruc tunit;
83 
84  switch (i)
85  {
86  case JSON_UNIT_NONE:
87  tunit.name = "";
88  break;
90  tunit.name = "m/s2";
91  break;
92  case JSON_UNIT_ANGLE:
93  tunit.name = "rad";
94  break;
96  tunit.name = "rad/s";
97  break;
98  case JSON_UNIT_AREA:
99  tunit.name = "m2";
100  break;
101  case JSON_UNIT_BYTES:
102  tunit.name = "GiB";
103  break;
105  tunit.name = "F";
106  break;
107  case JSON_UNIT_CHARGE:
108  tunit.name = "C";
109  break;
110  case JSON_UNIT_CURRENT:
111  tunit.name = "A";
112  break;
113  case JSON_UNIT_DATE:
114  tunit.name = "MJD";
115  break;
116  case JSON_UNIT_DENSITY:
117  tunit.name = "kg/m3";
118  break;
119  case JSON_UNIT_ENERGY:
120  tunit.name = "j";
121  break;
122  case JSON_UNIT_FORCE:
123  tunit.name = "N";
124  break;
125  case JSON_UNIT_FRACTION:
126  tunit.name = "";
127  break;
128  case JSON_UNIT_FREQUENCY:
129  tunit.name = "Hz";
130  break;
131  case JSON_UNIT_INTENSITY:
132  tunit.name = "Ca";
133  break;
134  case JSON_UNIT_ISP:
135  tunit.name = "s";
136  break;
137  case JSON_UNIT_LENGTH:
138  tunit.name = "m";
139  break;
140  case JSON_UNIT_LUMINANCE:
141  tunit.name = "Cd/m2";
142  break;
143  case JSON_UNIT_MAGFIELD:
144  tunit.name = "A/m";
145  break;
146  case JSON_UNIT_MAGFLUX:
147  tunit.name = "Wb";
148  break;
150  tunit.name = "T";
151  break;
152  case JSON_UNIT_MAGMOMENT:
153  tunit.name = "Am2";
154  break;
155  case JSON_UNIT_MASS:
156  tunit.name = "kg";
157  break;
158  case JSON_UNIT_MOI:
159  tunit.name = "kgm2";
160  break;
161  case JSON_UNIT_POWER:
162  tunit.name = "watt";
163  break;
164  case JSON_UNIT_PRESSURE:
165  tunit.name = "Pa";
166  break;
168  tunit.name = "ohm";
169  break;
171  tunit.name = "sr";
172  break;
173  case JSON_UNIT_SPEED:
174  tunit.name = "m/s";
175  break;
177  tunit.name = "K";
178  break;
179  case JSON_UNIT_TIME:
180  tunit.name = "s";
181  break;
182  case JSON_UNIT_TORQUE:
183  tunit.name = "Nm";
184  break;
185  case JSON_UNIT_VOLTAGE:
186  tunit.name = "V";
187  break;
188  case JSON_UNIT_VOLUME:
189  tunit.name = "m3";
190  break;
191  }
192  cinfo->unit[i].push_back(tunit);
193 
194  // Alternate Units
195  switch (i)
196  {
197  case JSON_UNIT_NONE:
198  break;
200  tunit.name = "g";
201  tunit.type = JSON_UNIT_TYPE_POLY;
202  tunit.p1 = 1.f/9.80665f;
203  cinfo->unit[i].push_back(tunit);
204  break;
205  case JSON_UNIT_ANGLE:
206  tunit.name = "deg";
207  tunit.type = JSON_UNIT_TYPE_POLY;
208  tunit.p1 = static_cast<float>(RTOD);
209  cinfo->unit[i].push_back(tunit);
210  break;
212  tunit.name = "deg/s";
213  tunit.type = JSON_UNIT_TYPE_POLY;
214  tunit.p1 = static_cast<float>(RTOD);
215  cinfo->unit[i].push_back(tunit);
216  break;
217  case JSON_UNIT_AREA:
218  tunit.name = "ft2";
219  tunit.type = JSON_UNIT_TYPE_POLY;
220  tunit.p1 = 10.76391f;
221  cinfo->unit[i].push_back(tunit);
222  break;
223  case JSON_UNIT_BYTES:
224  tunit.name = "KiB";
225  tunit.type = JSON_UNIT_TYPE_POLY;
226  tunit.p1 = 1.f/1024.f;
227  cinfo->unit[i].push_back(tunit);
228  break;
230  break;
231  case JSON_UNIT_CHARGE:
232  tunit.name = "Ahr";
233  tunit.type = JSON_UNIT_TYPE_POLY;
234  tunit.p1 = 3600.f;
235  cinfo->unit[i].push_back(tunit);
236  break;
237  case JSON_UNIT_CURRENT:
238  break;
239  case JSON_UNIT_DATE:
240  tunit.name = "min";
241  tunit.type = JSON_UNIT_TYPE_POLY;
242  tunit.p1 = 1440.f;
243  cinfo->unit[i].push_back(tunit);
244  tunit.name = "hr";
245  tunit.type = JSON_UNIT_TYPE_POLY;
246  tunit.p1 = 24.f;
247  cinfo->unit[i].push_back(tunit);
248  tunit.name = "day";
249  tunit.type = JSON_UNIT_TYPE_POLY;
250  tunit.p1 = 1.f;
251  cinfo->unit[i].push_back(tunit);
252  break;
253  case JSON_UNIT_DENSITY:
254  break;
255  case JSON_UNIT_ENERGY:
256  tunit.name = "erg";
257  tunit.type = JSON_UNIT_TYPE_POLY;
258  tunit.p1 = 1e7;
259  cinfo->unit[i].push_back(tunit);
260  break;
261  case JSON_UNIT_FORCE:
262  tunit.name = "dyn";
263  tunit.type = JSON_UNIT_TYPE_POLY;
264  tunit.p1 = 1e5;
265  cinfo->unit[i].push_back(tunit);
266  tunit.name = "lb";
267  tunit.type = JSON_UNIT_TYPE_POLY;
268  tunit.p1 = .22481f;
269  cinfo->unit[i].push_back(tunit);
270  break;
271  case JSON_UNIT_FRACTION:
272  tunit.name = "%";
273  tunit.type = JSON_UNIT_TYPE_POLY;
274  tunit.p1 = 100.f;
275  cinfo->unit[i].push_back(tunit);
276  break;
277  case JSON_UNIT_FREQUENCY:
278  break;
279  case JSON_UNIT_INTENSITY:
280  break;
281  case JSON_UNIT_ISP:
282  break;
283  case JSON_UNIT_LENGTH:
284  tunit.name = "km";
285  tunit.type = JSON_UNIT_TYPE_POLY;
286  tunit.p1 = 1e-3f;
287  cinfo->unit[i].push_back(tunit);
288  tunit.name = "cm";
289  tunit.type = JSON_UNIT_TYPE_POLY;
290  tunit.p1 = 1e2;
291  cinfo->unit[i].push_back(tunit);
292  tunit.name = "ft";
293  tunit.type = JSON_UNIT_TYPE_POLY;
294  tunit.p1 = 3.280833f;
295  cinfo->unit[i].push_back(tunit);
296  break;
297  case JSON_UNIT_LUMINANCE:
298  break;
299  case JSON_UNIT_MAGFIELD:
300  break;
301  case JSON_UNIT_MAGFLUX:
302  break;
304  tunit.name = "uT";
305  tunit.type = JSON_UNIT_TYPE_POLY;
306  tunit.p1 = 1e6;
307  cinfo->unit[i].push_back(tunit);
308  tunit.name = "nT";
309  tunit.type = JSON_UNIT_TYPE_POLY;
310  tunit.p1 = 1e9;
311  cinfo->unit[i].push_back(tunit);
312  break;
313  case JSON_UNIT_MAGMOMENT:
314  break;
315  case JSON_UNIT_MASS:
316  tunit.name = "g";
317  tunit.type = JSON_UNIT_TYPE_POLY;
318  tunit.p1 = 1e3;
319  cinfo->unit[i].push_back(tunit);
320  break;
321  case JSON_UNIT_PRESSURE:
322  break;
324  break;
326  break;
327  case JSON_UNIT_SPEED:
328  tunit.name = "km/s";
329  tunit.type = JSON_UNIT_TYPE_POLY;
330  tunit.p1 = 1e-3f;
331  cinfo->unit[i].push_back(tunit);
332  tunit.name = "cm/s";
333  tunit.type = JSON_UNIT_TYPE_POLY;
334  tunit.p1 = 1e2;
335  cinfo->unit[i].push_back(tunit);
336  break;
338  tunit.name = "\260C";
339  tunit.type = JSON_UNIT_TYPE_POLY;
340  tunit.p0 = -273.15f;
341  tunit.p1 = 1.;
342  cinfo->unit[i].push_back(tunit);
343  break;
344  case JSON_UNIT_TIME:
345  tunit.name = "min";
346  tunit.type = JSON_UNIT_TYPE_POLY;
347  tunit.p1 = 1.f/60.f;
348  cinfo->unit[i].push_back(tunit);
349  tunit.name = "hr";
350  tunit.type = JSON_UNIT_TYPE_POLY;
351  tunit.p1 = 1.f/3600.f;
352  cinfo->unit[i].push_back(tunit);
353  tunit.name = "day";
354  tunit.type = JSON_UNIT_TYPE_POLY;
355  tunit.p1 = 1.f/86400.f;
356  cinfo->unit[i].push_back(tunit);
357  tunit.name = "MJD";
358  tunit.type = JSON_UNIT_TYPE_POLY;
359  tunit.p1 = 1.f/86400.f;
360  cinfo->unit[i].push_back(tunit);
361  break;
362  case JSON_UNIT_VOLTAGE:
363  break;
364  case JSON_UNIT_VOLUME:
365  break;
366  }
367  }
368 }
float p0
0th derivative term
Definition: jsondef.h:679
Fraction.
Definition: jsondef.h:135
Power.
Definition: jsondef.h:113
Magnetic Field Strengh.
Definition: jsondef.h:123
const double RTOD
Multiplicand for Radians to Degrees.
Definition: math/constants.h:27
Definition: eci2kep_test.cpp:33
Charge.
Definition: jsondef.h:115
Frequency.
Definition: jsondef.h:103
Force.
Definition: jsondef.h:105
Electrical Resistance.
Definition: jsondef.h:121
int i
Definition: rw_test.cpp:37
Capacitance.
Definition: jsondef.h:119
float p1
1th derivative term
Definition: jsondef.h:681
Magnetic FLux.
Definition: jsondef.h:125
Specific Impulse.
Definition: jsondef.h:131
No units.
Definition: jsondef.h:65
Angle.
Definition: jsondef.h:95
string name
JSON Unit Name.
Definition: jsondef.h:675
Length.
Definition: jsondef.h:67
Temperature.
Definition: jsondef.h:79
vector< vector< unitstruc > > unit
JSON Unit Map matrix: first level is for unit type, second level is for all variants (starting with p...
Definition: jsondef.h:4214
Energy.
Definition: jsondef.h:111
Solid Angle.
Definition: jsondef.h:101
Holder for number of entries (CLEVER!)
Definition: jsondef.h:137
Polynomial.
Definition: jsondef.h:56
Angular rate.
Definition: jsondef.h:97
Intensity.
Definition: jsondef.h:81
Speed.
Definition: jsondef.h:87
Torque.
Definition: jsondef.h:107
Acceleration.
Definition: jsondef.h:89
Pressure.
Definition: jsondef.h:109
uint16_t type
JSON Unit conversion type.
Definition: jsondef.h:677
Density.
Definition: jsondef.h:91
Date.
Definition: jsondef.h:75
Magnetic Moment.
Definition: jsondef.h:129
Luminance.
Definition: jsondef.h:93
Electric Potential.
Definition: jsondef.h:117
Current.
Definition: jsondef.h:77
Time.
Definition: jsondef.h:73
Magnetic Flux Density.
Definition: jsondef.h:127
Random Access Memory and Disk Storage.
Definition: jsondef.h:133
JSON unit type entry.
Definition: jsondef.h:672
Area.
Definition: jsondef.h:83
Moment of Inertia.
Definition: jsondef.h:71
Volume.
Definition: jsondef.h:85
Mass.
Definition: jsondef.h:69
void json_init_device_type_string ( )
370  {
371  // Create device component names
372  device_type_string.clear();
405  return;
406 }
Radio Receiver.
Definition: jsondef.h:508
Magnetic Torque Rod.
Definition: jsondef.h:500
Photo Voltaic String.
Definition: jsondef.h:514
static vector< string > device_type_string
Definition: jsonlib.cpp:47
Reaction Wheel.
Definition: jsondef.h:498
Heater.
Definition: jsondef.h:518
Motor.
Definition: jsondef.h:520
Telemetry.
Definition: jsondef.h:546
Elevation and Azimuth Sun Sensor.
Definition: jsondef.h:494
BCREG.
Definition: jsondef.h:552
Rotor.
Definition: jsondef.h:530
Radio Transceiver.
Definition: jsondef.h:512
List count.
Definition: jsondef.h:554
Thruster.
Definition: jsondef.h:524
Payload.
Definition: jsondef.h:492
SUCHI.
Definition: jsondef.h:542
Camera.
Definition: jsondef.h:544
Pressure sensor.
Definition: jsondef.h:540
Power Bus.
Definition: jsondef.h:538
Propellant Tank.
Definition: jsondef.h:526
GPS Unit.
Definition: jsondef.h:504
Processing Unit.
Definition: jsondef.h:502
Antenna.
Definition: jsondef.h:506
Battery.
Definition: jsondef.h:516
Star Tracker.
Definition: jsondef.h:532
TNC.
Definition: jsondef.h:550
Torque rod Control Unit.
Definition: jsondef.h:536
Disk Drive.
Definition: jsondef.h:548
Radio Transmitter.
Definition: jsondef.h:510
Inertial Measurement Unit.
Definition: jsondef.h:496
Switch.
Definition: jsondef.h:528
Temperature Sensor.
Definition: jsondef.h:522
Motion Capture Camera.
Definition: jsondef.h:534
void json_init_node ( cosmosstruc cinfo)
408  {
409  // JIMNOTE: how hard to change to string?
410  cinfo->node.name[0] = 0;
411 }
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
char name[40+1]
Node Name.
Definition: jsondef.h:3556
void json_init_reserve ( cosmosstruc cinfo)
413  {
414  // JIMNOTE: change all to reserve
415  // reserve/resize fixed-sized vectors
416  cinfo->unit.reserve(JSON_UNIT_COUNT);
417 
418  cinfo->jmap.resize(JSON_MAX_HASH);
419  cinfo->emap.resize(JSON_MAX_HASH);
420 
421  // TODO: enforce this maximum for all vert/tri.push_back calls
422  cinfo->node.phys.vertices.reserve(MAX_NUMBER_OF_VERTICES);
423  cinfo->node.phys.triangles.reserve(MAX_NUMBER_OF_TRIANGLES);
424 
425  cinfo->vertexs.reserve(MAX_NUMBER_OF_VERTEXS);
426  cinfo->normals.reserve(MAX_NUMBER_OF_NORMALS);
427 
428  cinfo->user.reserve(MAX_NUMBER_OF_USERS);
429  cinfo->user.resize(MAX_NUMBER_OF_USERS);
430 
431  cinfo->agent.reserve(MAX_NUMBER_OF_AGENTS);
432  cinfo->agent.resize(1);
433 
434  cinfo->equation.reserve(MAX_NUMBER_OF_EQUATIONS);
435 
436  cinfo->event.reserve(MAX_NUMBER_OF_EVENTS);
437  cinfo->event.resize(1);
438 
439 
440  cinfo->port.reserve(MAX_NUMBER_OF_PORTS);
441 
442  cinfo->tle.reserve(MAX_NUMBER_OF_TLES);
443  return;
444 }
#define MAX_NUMBER_OF_TLES
Definition: jsondef.h:480
vector< portstruc > port
Vector of all ports known to node.
Definition: jsondef.h:4244
#define MAX_NUMBER_OF_USERS
Definition: jsondef.h:477
vector< tlestruc > tle
Array of Two Line Elements.
Definition: jsondef.h:4259
vector< Vector > vertices
Definition: jsondef.h:3451
#define MAX_NUMBER_OF_TRIANGLES
Definition: jsondef.h:453
#define MAX_NUMBER_OF_AGENTS
Definition: jsondef.h:465
vector< vertexstruc > vertexs
Vector of all vertexs in node.
Definition: jsondef.h:4223
#define JSON_MAX_HASH
Maximum value of JSON HASH.
Definition: jsondef.h:431
vector< vector< jsonequation > > emap
JSON Equation Map matrix.
Definition: jsondef.h:4211
vector< vector< unitstruc > > unit
JSON Unit Map matrix: first level is for unit type, second level is for all variants (starting with p...
Definition: jsondef.h:4214
Holder for number of entries (CLEVER!)
Definition: jsondef.h:137
vector< vertexstruc > normals
Vector of all vertexs in node.
Definition: jsondef.h:4226
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
#define MAX_NUMBER_OF_VERTEXS
Definition: jsondef.h:456
vector< equationstruc > equation
Vector of Equations.
Definition: jsondef.h:4217
#define MAX_NUMBER_OF_PORTS
Definition: jsondef.h:468
vector< userstruc > user
Single entry vector for user information.
Definition: jsondef.h:4256
#define MAX_NUMBER_OF_NORMALS
Definition: jsondef.h:459
#define MAX_NUMBER_OF_VERTICES
Definition: jsondef.h:450
vector< agentstruc > agent
Single entry vector for agent information.
Definition: jsondef.h:4247
#define MAX_NUMBER_OF_EVENTS
Definition: jsondef.h:471
vector< eventstruc > event
Single entry vector for event information.
Definition: jsondef.h:4250
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
physicsstruc phys
Definition: jsondef.h:3597
#define MAX_NUMBER_OF_EQUATIONS
Definition: jsondef.h:462
vector< trianglestruc > triangles
Definition: jsondef.h:3452
cosmosstruc * json_init ( )

Initialize JSON pointer map.

Create a cosmosstruc and use it to assign storage for each of the groups and entries for each of the non Node based elements to the JSON Name Map.

Returns
Pointer to new cosmosstruc or nullptr.
455 {
456  cosmosstruc* cinfo = nullptr;
457  if ((cinfo = new cosmosstruc()) == nullptr) { return nullptr; }
458 
460 // would be nice to have unit test for these three guys
461  //SCOTTNOTE: reserve capacity for all vectors in these strucs
462  cinfo->node = nodestruc();
463  cinfo->node.phys = physicsstruc();
464  cinfo->devspec = devspecstruc();
465 
466  json_init_reserve(cinfo);
467  if (cinfo == nullptr) { return nullptr; }
468 
469  json_init_unit(cinfo);
470  json_init_node(cinfo);
471 
472  cinfo->timestamp = currentmjd();
473 
474  // NS1 check
475  int32_t iretn = json_mapbaseentries(cinfo);
476  if (iretn < 0) {
477  delete cinfo;
478  cinfo = nullptr;
479  }
480 
481  // NS2
482  cinfo->add_default_names();
483 
484  return cinfo;
485 }
int32_t json_mapbaseentries(cosmosstruc *cinfo)
Add base entries to JMAP.
Definition: jsonlib.cpp:7368
double timestamp
Timestamp for last change to data.
Definition: jsondef.h:4202
void json_init_unit(cosmosstruc *cinfo)
Definition: jsonlib.cpp:75
int iretn
Definition: rw_test.cpp:37
void add_default_names()
Add default names for every accessible memory location within the COSMOS Data Structure (cosmosstruc)...
Definition: jsondef.h:4671
Physics Simulation Structure.
Definition: jsondef.h:3411
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
void json_init_node(cosmosstruc *cinfo)
Definition: jsonlib.cpp:408
void json_init_device_type_string()
Definition: jsonlib.cpp:370
Definition: jsondef.h:3553
Specific Device structure.
Definition: jsondef.h:3860
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
void json_init_reserve(cosmosstruc *cinfo)
Definition: jsonlib.cpp:413
Definition: jsondef.h:4199
physicsstruc phys
Definition: jsondef.h:3597
void json_destroy ( cosmosstruc cinfo)

Remove JSON pointer map.

Frees up all space assigned to JSON pointer map. Includes any space allocated through json_addentry.

492 {
493  if (cinfo == nullptr) { return; }
494  delete cinfo;
495  cinfo = nullptr;
496 }
uint16_t json_hash ( string  hstring)

Calculate JSON HASH.

Simple hash function (TCPL Section 6.6 Table Lookup)

Parameters
hstringString to calculate the hash for.
Returns
The hash, as an unsigned 16 bit number.
505 {
506  uint16_t hashval;
507 
508  hashval = 0;
509  for (uint8_t val : hstring)
510  {
511  hashval *= 31;
512  hashval += val;
513  }
514  return (hashval % JSON_MAX_HASH);
515 }
#define JSON_MAX_HASH
Maximum value of JSON HASH.
Definition: jsondef.h:431
int32_t json_create_node ( cosmosstruc cinfo,
string &  node_name,
uint16_t  node_type 
)
518 {
519  if (node_name.empty())
520  {
522  node_name = deviceCpu.getHostName();
523  }
524 
525 // if (get_nodedir(node_name).empty())
526 // {
527 // if (get_nodedir(node_name, true).empty())
528 // {
529 // return DATA_ERROR_NODES_FOLDER;
530 // }
531  if (!get_nodedir(node_name, true).empty())
532  {
533  strncpy(cinfo->node.name, node_name.c_str(), COSMOS_MAX_NAME);
534  cinfo->node.type = node_type;
535 
536  int32_t iretn = json_dump_node(cinfo);
537  return iretn;
538  }
539  else
540  {
542  }
543 }
#define DATA_ERROR_NODES_FOLDER
Definition: cosmos-errno.h:154
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
int iretn
Definition: rw_test.cpp:37
int32_t json_dump_node(cosmosstruc *cinfo)
Save Node entries to disk.
Definition: jsonlib.cpp:7233
string node_name
Definition: agent_001.cpp:46
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
static DeviceCpu deviceCpu
Definition: agent_cpu-2-0.cpp:77
Definition: devicecpu.h:239
char name[40+1]
Node Name.
Definition: jsondef.h:3556
string get_nodedir(string node, bool create_flag)
Get Current Node Directory.
Definition: datalib.cpp:1572
string getHostName()
Definition: devicecpu.cpp:205
uint16_t type
Node Type as listed in NODE_TYPE.
Definition: jsondef.h:3562
int32_t json_create_cpu ( string &  node_name)
546 {
547  cosmosstruc *cinfo = nullptr;
548 
549  if (node_name.empty())
550  {
552  node_name = deviceCpu.getHostName();
553  }
554 
555  if (get_nodedir(node_name).empty())
556  {
557  if (get_nodedir(node_name, true).empty())
558  {
559  return 1;
560  }
561 
562  cinfo = json_init();
563  strncpy(cinfo->node.name, node_name.c_str(), COSMOS_MAX_NAME);
564  cinfo->node.type = NODE_TYPE_COMPUTER;
565 
566  json_addpiece(cinfo, "main_cpu", DeviceType::CPU);
567  json_mappieceentry(cinfo->pieces.size()-1, cinfo);
568  json_togglepieceentry(cinfo->pieces.size()-1, cinfo, true);
569 
570  json_addpiece(cinfo, "main_drive", DeviceType::DISK);
571  json_mappieceentry(cinfo->pieces.size()-1, cinfo);
572  json_togglepieceentry(cinfo->pieces.size()-1, cinfo, true);
573 
574  cinfo->node.device_cnt = cinfo->node.piece_cnt;
575  cinfo->device.resize(cinfo->node.device_cnt);
576  cinfo->devspec.cpu_cnt = 1;
577  cinfo->devspec.disk_cnt = 1;
578  cinfo->node.port_cnt = 1;
579  cinfo->port.resize(cinfo->node.port_cnt);
580 
581  for (size_t i=0; i<cinfo->node.piece_cnt; ++i)
582  {
583 
584  cinfo->device[i].pidx = i;
585  cinfo->device[i].cidx = i;
586  switch (i)
587  {
588  case 0:
589  cinfo->device[i].type = DeviceType::CPU;
590  cinfo->device[i].didx = 0;
591  cinfo->device[i].portidx = PORT_TYPE_NONE;
592  cinfo->device[i].cpu.maxload = 1.;
593  cinfo->device[i].cpu.maxgib = 1.;
594  json_mapdeviceentry(cinfo->device[i], cinfo);
595  //json_addentry("cpu_utilization", "(\"device_cpu_load_000\"/\"device_cpu_maxload_000\")", cinfo);
596  break;
597  default:
598  cinfo->device[i].disk.maxgib = 1000.;
599  cinfo->device[i].type = DeviceType::DISK;
600  cinfo->device[i].didx = i-1;
601  cinfo->device[i].portidx = cinfo->device[i].didx;
602  cinfo->port[cinfo->device[i].didx].type = PORT_TYPE_DRIVE;
603  json_mapdeviceentry(cinfo->device[i], cinfo);
604  json_toggledeviceentry(i-1, DeviceType::DISK, cinfo, true);
605 #ifdef COSMOS_WIN_OS
606  strcpy(cinfo->port[cinfo->device[i].didx].name, "c:/");
607 #else
608  strcpy(cinfo->port[cinfo->device[i].didx].name, "/");
609 #endif
610  json_mapportentry(cinfo->device[i].portidx, cinfo);
611  json_toggleportentry(cinfo->device[i].portidx, cinfo, true);
612  //json_addentry("disk_utilization", "(\"device_disk_gib_000\"/\"device_disk_maxgib_000\")", cinfo);
613  break;
614  }
615  json_mapcompentry(i, cinfo);
616  json_togglecompentry(i, cinfo, true);
617  cinfo->device[i].enabled = true;
618  }
619 
620  int32_t iretn = json_dump_node(cinfo);
621  json_destroy(cinfo);
622  return iretn;
623  }
624  else
625  {
626  return 0;
627  }
628 }
uint16_t disk_cnt
Definition: jsondef.h:3868
vector< portstruc > port
Vector of all ports known to node.
Definition: jsondef.h:4244
uint16_t device_cnt
Definition: jsondef.h:3571
int32_t json_toggleportentry(uint16_t portidx, cosmosstruc *cinfo, bool state)
Toggle port entry.
Definition: jsonlib.cpp:8673
uint16_t json_mapdeviceentry(const devicestruc &device, cosmosstruc *cinfo)
Add device entry.
Definition: jsonlib.cpp:7777
int i
Definition: rw_test.cpp:37
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
uint16_t json_mapportentry(uint16_t portidx, cosmosstruc *cinfo)
Add port entry.
Definition: jsonlib.cpp:8652
int iretn
Definition: rw_test.cpp:37
uint16_t piece_cnt
Definition: jsondef.h:3570
cosmosstruc * json_init()
Initialize JSON pointer map.
Definition: jsonlib.cpp:454
int32_t json_dump_node(cosmosstruc *cinfo)
Save Node entries to disk.
Definition: jsonlib.cpp:7233
string node_name
Definition: agent_001.cpp:46
vector< devicestruc > device
Vector of all general (common) information for devices (components) in node.
Definition: jsondef.h:4238
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
static DeviceCpu deviceCpu
Definition: agent_cpu-2-0.cpp:77
uint16_t port_cnt
Definition: jsondef.h:3572
Definition: devicecpu.h:239
char name[40+1]
Node Name.
Definition: jsondef.h:3556
int32_t json_toggledeviceentry(uint16_t didx, DeviceType type, cosmosstruc *cinfo, bool state)
Toggle device entry.
Definition: jsonlib.cpp:8234
Definition: jsondef.h:649
int32_t json_mapcompentry(uint16_t cidx, cosmosstruc *cinfo)
Add component entry.
Definition: jsonlib.cpp:7708
uint16_t cpu_cnt
Definition: jsondef.h:3867
void json_destroy(cosmosstruc *cinfo)
Remove JSON pointer map.
Definition: jsonlib.cpp:491
string get_nodedir(string node, bool create_flag)
Get Current Node Directory.
Definition: datalib.cpp:1572
string getHostName()
Definition: devicecpu.cpp:205
Processing Unit.
Definition: jsondef.h:502
int32_t json_togglepieceentry(uint16_t pidx, cosmosstruc *cinfo, bool state)
Toggle piece entry.
Definition: jsonlib.cpp:7674
vector< piecestruc > pieces
Vector of all pieces in node.
Definition: jsondef.h:4232
int32_t json_addpiece(cosmosstruc *cinfo, string name, DeviceType ctype, double emi, double abs, double hcap, double hcon, double density)
Add new piece.
Definition: jsonlib.cpp:808
int32_t json_togglecompentry(uint16_t cidx, cosmosstruc *cinfo, bool state)
Toggle component entry.
Definition: jsonlib.cpp:7744
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
Definition: cosmos-defs.h:99
Disk Drive.
Definition: jsondef.h:548
Definition: jsondef.h:4199
Definition: jsondef.h:655
uint16_t type
Node Type as listed in NODE_TYPE.
Definition: jsondef.h:3562
int32_t json_mappieceentry(uint16_t pidx, cosmosstruc *cinfo)
Add piece entry.
Definition: jsonlib.cpp:7635
int32_t json_create_mcc ( string &  node_name)
631 {
632  cosmosstruc *cinfo = nullptr;
633 
634  if (node_name.empty())
635  {
637  node_name = deviceCpu.getHostName();
638  }
639 
640  if (get_nodedir(node_name).empty())
641  {
642  if (get_nodedir(node_name, true).empty())
643  {
644  return 1;
645  }
646 
647  cinfo = json_init();
648 // json_mapbaseentries(cinfo);
649  strncpy(cinfo->node.name, node_name.c_str(), COSMOS_MAX_NAME);
650  cinfo->node.type = NODE_TYPE_TESTBED;
651 
652  json_addpiece(cinfo, "motion_capture_unit", DeviceType::MCC);
653  json_mappieceentry(cinfo->pieces.size()-1, cinfo);
654  json_togglepieceentry(cinfo->pieces.size()-1, cinfo, true);
655 
656  cinfo->node.device_cnt = cinfo->node.piece_cnt;
657  cinfo->device.resize(cinfo->node.device_cnt);
658  cinfo->devspec.mcc_cnt = 1;
659  cinfo->node.port_cnt = 1;
660  cinfo->port.resize(cinfo->node.port_cnt);
661 
662  for (size_t i=0; i<cinfo->node.piece_cnt; ++i)
663  {
664 
665  cinfo->device[i].pidx = i;
666  cinfo->device[i].cidx = i;
667  switch (i)
668  {
669  case 0:
670  cinfo->device[i].type = DeviceType::MCC;
671  cinfo->device[i].didx = 0;
672  cinfo->device[i].portidx = 0;
673  cinfo->device[i].mcc.align = {{0., 0., 0.}, 1.};
674  json_mapdeviceentry(cinfo->device[i], cinfo);
675  json_toggledeviceentry(0, DeviceType::MCC, cinfo, true);
676  //json_addentry("mcc_utilization", "(\"device_mcc_load_000\"/\"device_mcc_maxload_000\")", cinfo);
677  cinfo->port[0].type = PORT_TYPE_ETHERNET;
678  json_mapportentry(cinfo->device[i].portidx, cinfo);
679  json_toggleportentry(cinfo->device[i].portidx, cinfo, true);
680  break;
681  default:
682  cinfo->device[i].disk.maxgib = 1000.;
683  cinfo->device[i].type = DeviceType::DISK;
684  cinfo->device[i].didx = i-1;
685  cinfo->device[i].portidx = cinfo->device[i].didx;
686  cinfo->port[cinfo->device[i].didx].type = PORT_TYPE_DRIVE;
687  json_mapdeviceentry(cinfo->device[i], cinfo);
688  json_toggledeviceentry(i-1, DeviceType::DISK, cinfo, true);
689 #ifdef COSMOS_WIN_OS
690  strcpy(cinfo->port[cinfo->device[i].didx].name, "c:/");
691 #else
692  strcpy(cinfo->port[cinfo->device[i].didx].name, "/");
693 #endif
694  break;
695  }
696  json_mapcompentry(i, cinfo);
697  json_togglecompentry(i, cinfo, true);
698  cinfo->device[i].enabled = true;
699  }
700 
701  int32_t iretn = json_dump_node(cinfo);
702  json_destroy(cinfo);
703  return iretn;
704  }
705  else
706  {
707  return 0;
708  }
709 }
Definition: jsondef.h:647
vector< portstruc > port
Vector of all ports known to node.
Definition: jsondef.h:4244
uint16_t device_cnt
Definition: jsondef.h:3571
int32_t json_toggleportentry(uint16_t portidx, cosmosstruc *cinfo, bool state)
Toggle port entry.
Definition: jsonlib.cpp:8673
uint16_t mcc_cnt
Definition: jsondef.h:3872
uint16_t json_mapdeviceentry(const devicestruc &device, cosmosstruc *cinfo)
Add device entry.
Definition: jsonlib.cpp:7777
int i
Definition: rw_test.cpp:37
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
uint16_t json_mapportentry(uint16_t portidx, cosmosstruc *cinfo)
Add port entry.
Definition: jsonlib.cpp:8652
int iretn
Definition: rw_test.cpp:37
uint16_t piece_cnt
Definition: jsondef.h:3570
cosmosstruc * json_init()
Initialize JSON pointer map.
Definition: jsonlib.cpp:454
int32_t json_dump_node(cosmosstruc *cinfo)
Save Node entries to disk.
Definition: jsonlib.cpp:7233
string node_name
Definition: agent_001.cpp:46
vector< devicestruc > device
Vector of all general (common) information for devices (components) in node.
Definition: jsondef.h:4238
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
Definition: cosmos-defs.h:104
static DeviceCpu deviceCpu
Definition: agent_cpu-2-0.cpp:77
uint16_t port_cnt
Definition: jsondef.h:3572
Definition: devicecpu.h:239
char name[40+1]
Node Name.
Definition: jsondef.h:3556
int32_t json_toggledeviceentry(uint16_t didx, DeviceType type, cosmosstruc *cinfo, bool state)
Toggle device entry.
Definition: jsonlib.cpp:8234
Definition: jsondef.h:649
int32_t json_mapcompentry(uint16_t cidx, cosmosstruc *cinfo)
Add component entry.
Definition: jsonlib.cpp:7708
void json_destroy(cosmosstruc *cinfo)
Remove JSON pointer map.
Definition: jsonlib.cpp:491
string get_nodedir(string node, bool create_flag)
Get Current Node Directory.
Definition: datalib.cpp:1572
string getHostName()
Definition: devicecpu.cpp:205
int32_t json_togglepieceentry(uint16_t pidx, cosmosstruc *cinfo, bool state)
Toggle piece entry.
Definition: jsonlib.cpp:7674
vector< piecestruc > pieces
Vector of all pieces in node.
Definition: jsondef.h:4232
int32_t json_addpiece(cosmosstruc *cinfo, string name, DeviceType ctype, double emi, double abs, double hcap, double hcon, double density)
Add new piece.
Definition: jsonlib.cpp:808
int32_t json_togglecompentry(uint16_t cidx, cosmosstruc *cinfo, bool state)
Toggle component entry.
Definition: jsonlib.cpp:7744
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
Disk Drive.
Definition: jsondef.h:548
Definition: jsondef.h:4199
uint16_t type
Node Type as listed in NODE_TYPE.
Definition: jsondef.h:3562
Motion Capture Camera.
Definition: jsondef.h:534
int32_t json_mappieceentry(uint16_t pidx, cosmosstruc *cinfo)
Add piece entry.
Definition: jsonlib.cpp:7635
int32_t json_createpiece ( cosmosstruc cinfo,
string  name,
DeviceType  ctype,
double  emi,
double  abs,
double  hcap,
double  hcon,
double  density 
)

Create new piece.

Use json_addpiece to add a new piecestruc and its attendant device information and then map it.

Parameters
typeJSON PIECE_TYPE
emiEmissivity
absAbsorbtivity
hcapHeat capacity
hconHeat conductivity
densityDensity
Returns
Index of piece, or negative error
723 {
724  int32_t iretn;
725  iretn = json_addpiece(cinfo, name, ctype, emi, abs, hcap, hcon, density);
726  if (iretn < 0)
727  {
728  return iretn;
729  }
730  uint16_t pidx = static_cast <uint16_t>(iretn);
731 
732  iretn = json_mappieceentry(pidx, cinfo);
733  if (iretn < 0)
734  {
735  return iretn;
736  }
737  iretn = json_togglepieceentry(pidx, cinfo, true);
738  if (iretn < 0)
739  {
740  return iretn;
741  }
742 
743  if (ctype < DeviceType::COUNT)
744  {
745  uint16_t cidx = cinfo->pieces[pidx].cidx;
746  json_mapcompentry(cidx, cinfo);
747  json_togglecompentry(cidx, cinfo, true);
748  json_mapdeviceentry(cinfo->device[cidx], cinfo);
749 // json_pushdevspec(cidx, cinfo);
750  json_toggledeviceentry(cinfo->device[cidx].didx, ctype, cinfo, true);
751  }
752  return pidx;
753 }
uint16_t json_mapdeviceentry(const devicestruc &device, cosmosstruc *cinfo)
Add device entry.
Definition: jsonlib.cpp:7777
int iretn
Definition: rw_test.cpp:37
vector< devicestruc > device
Vector of all general (common) information for devices (components) in node.
Definition: jsondef.h:4238
List count.
Definition: jsondef.h:554
int32_t json_toggledeviceentry(uint16_t didx, DeviceType type, cosmosstruc *cinfo, bool state)
Toggle device entry.
Definition: jsonlib.cpp:8234
string name
Definition: cubesat2obj.cpp:6
int32_t json_mapcompentry(uint16_t cidx, cosmosstruc *cinfo)
Add component entry.
Definition: jsonlib.cpp:7708
int32_t json_togglepieceentry(uint16_t pidx, cosmosstruc *cinfo, bool state)
Toggle piece entry.
Definition: jsonlib.cpp:7674
vector< piecestruc > pieces
Vector of all pieces in node.
Definition: jsondef.h:4232
int32_t json_addpiece(cosmosstruc *cinfo, string name, DeviceType ctype, double emi, double abs, double hcap, double hcon, double density)
Add new piece.
Definition: jsonlib.cpp:808
int32_t json_togglecompentry(uint16_t cidx, cosmosstruc *cinfo, bool state)
Toggle component entry.
Definition: jsonlib.cpp:7744
int32_t json_mappieceentry(uint16_t pidx, cosmosstruc *cinfo)
Add piece entry.
Definition: jsonlib.cpp:7635
int32_t json_finddev ( cosmosstruc cinfo,
string  name 
)
756 {
757  int32_t iretn;
758 
759  iretn = json_findpiece(cinfo, name);
760  if (iretn >= 0)
761  {
762  iretn = cinfo->pieces[static_cast <size_t>(iretn)].cidx;
763  if (iretn >= 0)
764  {
765  iretn = cinfo->device[static_cast <size_t>(iretn)].didx;
766  }
767  }
768 
769  return iretn;
770 }
int iretn
Definition: rw_test.cpp:37
vector< devicestruc > device
Vector of all general (common) information for devices (components) in node.
Definition: jsondef.h:4238
string name
Definition: cubesat2obj.cpp:6
vector< piecestruc > pieces
Vector of all pieces in node.
Definition: jsondef.h:4232
int32_t json_findpiece(cosmosstruc *cinfo, string name)
Definition: jsonlib.cpp:785
int32_t json_findcomp ( cosmosstruc cinfo,
string  name 
)
773 {
774  int32_t iretn;
775 
776  iretn = json_findpiece(cinfo, name);
777  if (iretn >= 0)
778  {
779  iretn = cinfo->pieces[static_cast <size_t>(iretn)].cidx;
780  }
781 
782  return iretn;
783 }
int iretn
Definition: rw_test.cpp:37
string name
Definition: cubesat2obj.cpp:6
vector< piecestruc > pieces
Vector of all pieces in node.
Definition: jsondef.h:4232
int32_t json_findpiece(cosmosstruc *cinfo, string name)
Definition: jsonlib.cpp:785
int32_t json_findpiece ( cosmosstruc cinfo,
string  name 
)
786 {
787  for (size_t i=0; i<cinfo->pieces.size(); ++i)
788  {
789  if (name == cinfo->pieces[i].name)
790  {
791  return i;
792  }
793  }
794  return JSON_ERROR_NOJMAP;
795 }
#define JSON_ERROR_NOJMAP
Definition: cosmos-errno.h:93
int i
Definition: rw_test.cpp:37
string name
Definition: cubesat2obj.cpp:6
vector< piecestruc > pieces
Vector of all pieces in node.
Definition: jsondef.h:4232
int32_t json_addpiece ( cosmosstruc cinfo,
string  name,
DeviceType  ctype,
double  emi,
double  abs,
double  hcap,
double  hcon,
double  density 
)

Add new piece.

Take an empty piecestruc and fill it with the provided information, generating the vertexs for the indicated type.

Parameters
typeJSON PIECE_TYPE
emiEmissivity
absAbsorbtivity
hcapHeat capacity
hconHeat conductivity
densityDensity
Returns
Zero, or negative error

Antennae

Battery

Bud

Camera

Processing Unit

Disk

GPS Unit

Heater

Inertial Measurement Unit

Motion Capture Camera

Motor

Magnetic Torque Rod

Payload

Propellant Tank

Pressure Sensor

BCREG

Rotor

Reaction Wheel

Radio Receiver

Elevation and Azimuth Sun Sensor

Photo Voltaic String

Star Tracker

SUCHI

Switch

Texas Christian University

Radio Transceiver

Telemetry

Thruster

Temperature Sensor

TNC

Radio Transmitter

809 {
810  // look for existing piece
811  for (size_t i=0; i<cinfo->pieces.size(); ++i)
812  {
813  if (name == cinfo->pieces[i].name)
814  {
815  return i;
816  }
817  }
818 
819  // otherwise make a new piece
820  piecestruc piece;
821  strncpy(piece.name, name.c_str(), COSMOS_MAX_NAME);
822  piece.emi = emi;
823  piece.abs = abs;
824  piece.density = density;
825  piece.volume = .001 / density;
826  piece.hcap = hcap;
827  piece.hcon = hcon;
828  if (ctype < DeviceType::COUNT)
829  {
830  piece.cidx = cinfo->device.size();
831  }
832  else
833  {
834  piece.cidx = DeviceType::NONE;
835  }
836  piece.enabled = true;
837  piece.face_cnt = 0;
838  cinfo->pieces.push_back(piece);
839  cinfo->node.piece_cnt = static_cast <uint16_t>(cinfo->pieces.size());
840 
841 // JIMNOTE: this area of code has troubles... devicestruc is a union! can't be all willy nilly!
842  if (ctype < DeviceType::COUNT)
843  {
845  device.pidx = static_cast <uint16_t>(cinfo->pieces.size()) - 1;
846  device.cidx = piece.cidx;
847  device.type = static_cast<uint16_t>(ctype);
848  device.portidx = PORT_TYPE_NONE;
849  switch(ctype)
850  {
851  case DeviceType::COUNT:
852  case DeviceType::NONE:
853  break;
855  case DeviceType::ANT:
856  device.didx = cinfo->devspec.ant.size();
857  cinfo->device.push_back(device);
858  cinfo->devspec.ant.push_back(piece.cidx);
859  cinfo->devspec.ant_cnt = cinfo->devspec.ant.size();
860  break;
862  case DeviceType::BATT:
863  device.didx = cinfo->devspec.batt.size();
864  cinfo->device.push_back(device);
865  cinfo->devspec.batt.push_back(piece.cidx);
866  cinfo->devspec.batt_cnt = cinfo->devspec.batt.size();
867  break;
869  case DeviceType::BUS:
870  device.didx = cinfo->devspec.bus.size();
871  cinfo->device.push_back(device);
872  cinfo->devspec.bus.push_back(piece.cidx);
873  cinfo->devspec.bus_cnt = cinfo->devspec.bus.size();
874  break;
876  case DeviceType::CAM:
877  device.didx = cinfo->devspec.cam.size();
878  cinfo->device.push_back(device);
879  cinfo->devspec.cam.push_back(piece.cidx);
880  cinfo->devspec.cam_cnt = (uint16_t)cinfo->devspec.cam.size();
881  break;
883  case DeviceType::CPU:
884  device.didx = cinfo->devspec.cpu.size();
885  device.cpu.maxload = 1.;
886  device.cpu.maxgib = 1.;
887  cinfo->device.push_back(device);
888  cinfo->devspec.cpu.push_back(piece.cidx);
889  cinfo->devspec.cpu_cnt = (uint16_t)cinfo->devspec.cpu.size();
890  break;
892  case DeviceType::DISK:
893  device.didx = cinfo->devspec.disk.size();
894  device.disk.maxgib = 100.;
895  cinfo->device.push_back(device);
896  cinfo->devspec.disk.push_back(piece.cidx);
897  cinfo->devspec.disk_cnt = (uint16_t)cinfo->devspec.disk.size();
898  break;
900  case DeviceType::GPS:
901  device.didx = cinfo->devspec.gps.size();
902  cinfo->device.push_back(device);
903  cinfo->devspec.gps.push_back(piece.cidx);
904  cinfo->devspec.gps_cnt = (uint16_t)cinfo->devspec.gps.size();
905  break;
907  case DeviceType::HTR:
908  device.didx = cinfo->devspec.htr.size();
909  cinfo->device.push_back(device);
910  cinfo->devspec.htr.push_back(piece.cidx);
911  cinfo->devspec.htr_cnt = (uint16_t)cinfo->devspec.htr.size();
912  break;
914  case DeviceType::IMU:
915  device.didx = cinfo->devspec.imu.size();
916  cinfo->device.push_back(device);
917  cinfo->devspec.imu.push_back(piece.cidx);
918  cinfo->devspec.imu_cnt = (uint16_t)cinfo->devspec.imu.size();
919  break;
921  case DeviceType::MCC:
922  device.didx = cinfo->devspec.mcc.size();
923  device.mcc.align = {{0., 0., 0.}, 1.};
924  cinfo->device.push_back(device);
925  cinfo->devspec.mcc.push_back(piece.cidx);
926  cinfo->devspec.mcc_cnt = (uint16_t)cinfo->devspec.mcc.size();
927  break;
929  case DeviceType::MOTR:
930  device.didx = cinfo->devspec.motr.size();
931  cinfo->device.push_back(device);
932  cinfo->devspec.motr.push_back(piece.cidx);
933  cinfo->devspec.motr_cnt = (uint16_t)cinfo->devspec.motr.size();
934  break;
936  case DeviceType::MTR:
937  device.didx = cinfo->devspec.mtr.size();
938  cinfo->device.push_back(device);
939  cinfo->devspec.mtr.push_back(piece.cidx);
940  cinfo->devspec.mtr_cnt = (uint16_t)cinfo->devspec.mtr.size();
941  break;
943  case DeviceType::PLOAD:
944  device.didx = cinfo->devspec.pload.size();
945  cinfo->device.push_back(device);
946  cinfo->devspec.pload.push_back(piece.cidx);
947  cinfo->devspec.pload_cnt = (uint16_t)cinfo->devspec.pload.size();
948  break;
950  case DeviceType::PROP:
951  device.didx = cinfo->devspec.prop.size();
952  cinfo->device.push_back(device);
953  cinfo->devspec.prop.push_back(piece.cidx);
954  cinfo->devspec.prop_cnt = (uint16_t)cinfo->devspec.prop.size();
955  break;
957  case DeviceType::PSEN:
958  device.didx = cinfo->devspec.psen.size();
959  cinfo->device.push_back(device);
960  cinfo->devspec.psen.push_back(piece.cidx);
961  cinfo->devspec.psen_cnt = (uint16_t)cinfo->devspec.psen.size();
962  break;
964  case DeviceType::BCREG:
965  device.didx = cinfo->devspec.bcreg.size();
966  cinfo->device.push_back(device);
967  cinfo->devspec.bcreg.push_back(piece.cidx);
968  cinfo->devspec.bcreg_cnt = (uint16_t)cinfo->devspec.bcreg.size();
969  break;
971  case DeviceType::ROT:
972  device.didx = cinfo->devspec.rot.size();
973  cinfo->device.push_back(device);
974  cinfo->devspec.rot.push_back(piece.cidx);
975  cinfo->devspec.rot_cnt = (uint16_t)cinfo->devspec.rot.size();
976  break;
978  case DeviceType::RW:
979  device.didx = cinfo->devspec.rw.size();
980  cinfo->device.push_back(device);
981  cinfo->devspec.rw.push_back(piece.cidx);
982  cinfo->devspec.rw_cnt = (uint16_t)cinfo->devspec.rw.size();
983  break;
985  case DeviceType::RXR:
986  device.didx = cinfo->devspec.rxr.size();
987  cinfo->device.push_back(device);
988  cinfo->devspec.rxr.push_back(piece.cidx);
989  cinfo->devspec.rxr_cnt = (uint16_t)cinfo->devspec.rxr.size();
990  break;
992  case DeviceType::SSEN:
993  device.didx = cinfo->devspec.ssen.size();
994  cinfo->device.push_back(device);
995  cinfo->devspec.ssen.push_back(piece.cidx);
996  cinfo->devspec.ssen_cnt = (uint16_t)cinfo->devspec.ssen.size();
997  break;
999  case DeviceType::PVSTRG:
1000  device.didx = cinfo->devspec.pvstrg.size();
1001  cinfo->device.push_back(device);
1002  cinfo->devspec.pvstrg.push_back(piece.cidx);
1003  cinfo->devspec.pvstrg_cnt = (uint16_t)cinfo->devspec.pvstrg.size();
1004  break;
1006  case DeviceType::STT:
1007  device.didx = cinfo->devspec.stt.size();
1008  cinfo->device.push_back(device);
1009  cinfo->devspec.stt.push_back(piece.cidx);
1010  cinfo->devspec.stt_cnt = (uint16_t)cinfo->devspec.stt.size();
1011  break;
1013  case DeviceType::SUCHI:
1014  device.didx = cinfo->devspec.suchi.size();
1015  cinfo->device.push_back(device);
1016  cinfo->devspec.suchi.push_back(piece.cidx);
1017  cinfo->devspec.suchi_cnt = (uint16_t)cinfo->devspec.suchi.size();
1018  break;
1020  case DeviceType::SWCH:
1021  device.didx = cinfo->devspec.swch.size();
1022  cinfo->device.push_back(device);
1023  cinfo->devspec.swch.push_back(piece.cidx);
1024  cinfo->devspec.swch_cnt = (uint16_t)cinfo->devspec.swch.size();
1025  break;
1027  case DeviceType::TCU:
1028  device.didx = cinfo->devspec.tcu.size();
1029  cinfo->device.push_back(device);
1030  cinfo->devspec.tcu.push_back(piece.cidx);
1031  cinfo->devspec.tcu_cnt = (uint16_t)cinfo->devspec.tcu.size();
1032  break;
1034  case DeviceType::TCV:
1035  device.didx = cinfo->devspec.tcv.size();
1036  cinfo->device.push_back(device);
1037  cinfo->devspec.tcv.push_back(piece.cidx);
1038  cinfo->devspec.tcv_cnt = (uint16_t)cinfo->devspec.tcv.size();
1039  break;
1041  case DeviceType::TELEM:
1042  device.didx = cinfo->devspec.telem.size();
1043  cinfo->device.push_back(device);
1044  cinfo->devspec.telem.push_back(piece.cidx);
1045  cinfo->devspec.telem_cnt = (uint16_t)cinfo->devspec.telem.size();
1046  break;
1048  case DeviceType::THST:
1049  device.didx = cinfo->devspec.thst.size();
1050  cinfo->device.push_back(device);
1051  cinfo->devspec.thst.push_back(piece.cidx);
1052  cinfo->devspec.thst_cnt = (uint16_t)cinfo->devspec.thst.size();
1053  break;
1055  case DeviceType::TSEN:
1056  device.didx = cinfo->devspec.tsen.size();
1057  cinfo->device.push_back(device);
1058  cinfo->devspec.tsen.push_back(piece.cidx);
1059  cinfo->devspec.tsen_cnt = (uint16_t)cinfo->devspec.tsen.size();
1060  break;
1062  case DeviceType::TNC:
1063  device.didx = cinfo->devspec.tnc.size();
1064  cinfo->device.push_back(device);
1065  cinfo->devspec.tnc.push_back(piece.cidx);
1066  cinfo->devspec.tnc_cnt = (uint16_t)cinfo->devspec.tnc.size();
1067  break;
1069  case DeviceType::TXR:
1070  device.didx = cinfo->devspec.txr.size();
1071  cinfo->device.push_back(device);
1072  cinfo->devspec.txr.push_back(piece.cidx);
1073  cinfo->devspec.txr_cnt = (uint16_t)cinfo->devspec.txr.size();
1074  break;
1075  }
1076  cinfo->node.device_cnt = cinfo->device.size();
1077  }
1078  return (static_cast <int32_t>(cinfo->pieces.size() - 1));
1079 }
Radio Receiver.
Definition: jsondef.h:508
float hcap
Heat capacity in joules per kelvin.
Definition: jsondef.h:1463
Magnetic Torque Rod.
Definition: jsondef.h:500
uint16_t disk_cnt
Definition: jsondef.h:3868
Photo Voltaic String.
Definition: jsondef.h:514
uint16_t portidx
Connection information for device.
Definition: jsondef.h:1603
uint16_t imu_cnt
Definition: jsondef.h:3871
vector< uint16_t > mtr
Definition: jsondef.h:3907
vector< uint16_t > stt
Definition: jsondef.h:3916
uint16_t device_cnt
Definition: jsondef.h:3571
vector< uint16_t > prop
Definition: jsondef.h:3909
Device structure.
Definition: jsondef.h:3692
uint16_t mcc_cnt
Definition: jsondef.h:3872
uint16_t suchi_cnt
Definition: jsondef.h:3885
vector< uint16_t > bus
Definition: jsondef.h:3898
Reaction Wheel.
Definition: jsondef.h:498
Heater.
Definition: jsondef.h:518
vector< uint16_t > gps
Definition: jsondef.h:3902
vector< uint16_t > rxr
Definition: jsondef.h:3914
uint16_t tsen_cnt
Definition: jsondef.h:3891
int i
Definition: rw_test.cpp:37
Motor.
Definition: jsondef.h:520
Telemetry.
Definition: jsondef.h:546
Elevation and Azimuth Sun Sensor.
Definition: jsondef.h:494
uint16_t pidx
Piece index.
Definition: jsondef.h:1599
uint16_t swch_cnt
Definition: jsondef.h:3886
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
diskstruc disk
Definition: jsondef.h:3701
uint16_t motr_cnt
Definition: jsondef.h:3873
uint16_t ssen_cnt
Definition: jsondef.h:3882
Not a Component.
Definition: jsondef.h:556
uint16_t bcreg_cnt
Definition: jsondef.h:3878
uint16_t piece_cnt
Definition: jsondef.h:3570
BCREG.
Definition: jsondef.h:552
vector< uint16_t > htr
Definition: jsondef.h:3903
uint16_t didx
Device specific index.
Definition: jsondef.h:1597
vector< uint16_t > imu
Definition: jsondef.h:3904
uint16_t tcv_cnt
Definition: jsondef.h:3888
uint16_t type
Component Type.
Definition: jsondef.h:1587
Part structure: physical information for each piece of Node.
Definition: jsondef.h:1446
Rotor.
Definition: jsondef.h:530
vector< uint16_t > ant
Definition: jsondef.h:3895
vector< uint16_t > rw
Definition: jsondef.h:3913
uint16_t psen_cnt
Definition: jsondef.h:3877
uint16_t pload_cnt
Definition: jsondef.h:3875
vector< uint16_t > txr
Definition: jsondef.h:3925
vector< uint16_t > pload
Definition: jsondef.h:3908
quaternion align
Sensor alignment quaternion.
Definition: jsondef.h:2988
vector< uint16_t > tcu
Definition: jsondef.h:3919
vector< devicestruc > device
Vector of all general (common) information for devices (components) in node.
Definition: jsondef.h:4238
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
uint16_t prop_cnt
Definition: jsondef.h:3876
vector< uint16_t > suchi
Definition: jsondef.h:3917
uint16_t telem_cnt
Definition: jsondef.h:3889
float maxgib
Maximum disk capacity in GiB.
Definition: jsondef.h:2118
Radio Transceiver.
Definition: jsondef.h:512
float maxload
Maximum load.
Definition: jsondef.h:2064
uint16_t txr_cnt
Definition: jsondef.h:3893
List count.
Definition: jsondef.h:554
uint16_t tnc_cnt
Definition: jsondef.h:3892
vector< uint16_t > rot
Definition: jsondef.h:3912
uint16_t pvstrg_cnt
Definition: jsondef.h:3883
uint16_t gps_cnt
Definition: jsondef.h:3869
uint16_t batt_cnt
Definition: jsondef.h:3864
Thruster.
Definition: jsondef.h:524
vector< uint16_t > tcv
Definition: jsondef.h:3920
uint16_t face_cnt
Number of faces.
Definition: jsondef.h:1473
vector< uint16_t > disk
Definition: jsondef.h:3901
Payload.
Definition: jsondef.h:492
vector< uint16_t > motr
Definition: jsondef.h:3906
SUCHI.
Definition: jsondef.h:542
uint16_t bus_cnt
Definition: jsondef.h:3865
vector< uint16_t > cam
Definition: jsondef.h:3899
vector< uint16_t > thst
Definition: jsondef.h:3922
string name
Definition: cubesat2obj.cpp:6
Camera.
Definition: jsondef.h:544
float volume
Volume in cubic meters.
Definition: jsondef.h:1471
vector< uint16_t > telem
Definition: jsondef.h:3921
Pressure sensor.
Definition: jsondef.h:540
float abs
Absorptivity: 0-1.
Definition: jsondef.h:1461
uint16_t cpu_cnt
Definition: jsondef.h:3867
uint16_t rw_cnt
Definition: jsondef.h:3880
vector< uint16_t > tsen
Definition: jsondef.h:3924
mccstruc mcc
Definition: jsondef.h:3705
Power Bus.
Definition: jsondef.h:538
Propellant Tank.
Definition: jsondef.h:526
char name[40+1]
Name of piece.
Definition: jsondef.h:1449
vector< uint16_t > cpu
Definition: jsondef.h:3900
vector< uint16_t > bcreg
Definition: jsondef.h:3897
GPS Unit.
Definition: jsondef.h:504
uint16_t cidx
Component Index.
Definition: jsondef.h:1595
Processing Unit.
Definition: jsondef.h:502
uint16_t ant_cnt
Definition: jsondef.h:3863
Antenna.
Definition: jsondef.h:506
vector< uint16_t > tnc
Definition: jsondef.h:3923
bool enabled
Enabled?
Definition: jsondef.h:1451
Battery.
Definition: jsondef.h:516
vector< piecestruc > pieces
Vector of all pieces in node.
Definition: jsondef.h:4232
uint16_t rxr_cnt
Definition: jsondef.h:3881
float emi
Emissivity: 0-1.
Definition: jsondef.h:1459
float maxgib
Maximum memory capacity in GiB.
Definition: jsondef.h:2068
uint16_t rot_cnt
Definition: jsondef.h:3879
uint16_t thst_cnt
Definition: jsondef.h:3890
Star Tracker.
Definition: jsondef.h:532
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
uint16_t tcu_cnt
Definition: jsondef.h:3887
TNC.
Definition: jsondef.h:550
vector< uint16_t > swch
Definition: jsondef.h:3918
Torque rod Control Unit.
Definition: jsondef.h:536
Disk Drive.
Definition: jsondef.h:548
vector< uint16_t > psen
Definition: jsondef.h:3910
Definition: jsondef.h:655
uint16_t mtr_cnt
Definition: jsondef.h:3874
uint16_t cam_cnt
Definition: jsondef.h:3866
Radio Transmitter.
Definition: jsondef.h:510
float hcon
Heat conductivity in Watts per meter per kelvin.
Definition: jsondef.h:1465
Inertial Measurement Unit.
Definition: jsondef.h:496
Switch.
Definition: jsondef.h:528
vector< uint16_t > batt
Definition: jsondef.h:3896
uint16_t cidx
Component index: -1 if not a Component.
Definition: jsondef.h:1453
float density
Density in kg/cu m.
Definition: jsondef.h:1455
cpustruc cpu
Definition: jsondef.h:3700
static string device
Definition: ax25_recv.cpp:39
uint16_t htr_cnt
Definition: jsondef.h:3870
vector< uint16_t > pvstrg
Definition: jsondef.h:3911
Temperature Sensor.
Definition: jsondef.h:522
vector< uint16_t > mcc
Definition: jsondef.h:3905
uint16_t stt_cnt
Definition: jsondef.h:3884
Motion Capture Camera.
Definition: jsondef.h:534
vector< uint16_t > ssen
Definition: jsondef.h:3915
int32_t json_createport ( cosmosstruc cinfo,
string  name,
PORT_TYPE  type 
)

Add new port entry Extend the existing port list with an entry for the given name and piece

Parameters
cinfoPointer to cosmosstruc
nameName information for port
typePort type listed in PORT_TYPE.
1087 {
1088  for (uint16_t i=0; i<cinfo->port.size(); ++i)
1089  {
1090  if (name == cinfo->port[i].name)
1091  {
1092  if (type != cinfo->port[i].type)
1093  {
1094  return GENERAL_ERROR_MISMATCH;
1095  }
1096  return i;
1097  }
1098  }
1099 
1100  portstruc port;
1101  strcpy(port.name, name.c_str());
1102  port.type = type;
1103  cinfo->port.push_back(port);
1104  cinfo->node.port_cnt = static_cast <uint16_t>(cinfo->port.size());
1105  json_mapportentry(static_cast <uint16_t>(cinfo->port.size()) - 1, cinfo);
1106  json_toggleportentry(static_cast <uint16_t>(cinfo->port.size()) - 1, cinfo, true);
1107 
1108  return (static_cast <int32_t>(cinfo->port.size() - 1));
1109 }
static string port
Definition: add_radio.cpp:16
vector< portstruc > port
Vector of all ports known to node.
Definition: jsondef.h:4244
int32_t json_toggleportentry(uint16_t portidx, cosmosstruc *cinfo, bool state)
Toggle port entry.
Definition: jsonlib.cpp:8673
int i
Definition: rw_test.cpp:37
uint16_t json_mapportentry(uint16_t portidx, cosmosstruc *cinfo)
Add port entry.
Definition: jsonlib.cpp:8652
PORT_TYPE type
Type of I/O as listed in PORT_TYPE.
Definition: jsondef.h:1360
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
uint16_t port_cnt
Definition: jsondef.h:3572
char name[COSMOS_MAX_DATA+1]
Definition: jsondef.h:1363
string name
Definition: cubesat2obj.cpp:6
Port structure.
Definition: jsondef.h:1357
#define GENERAL_ERROR_MISMATCH
Definition: cosmos-errno.h:303
int32_t json_addentry ( jsonentry  entry,
cosmosstruc cinfo 
)

Enter an entry into the JSON Namespace.

Enters a jsonentry in the JSON Data Name Space.

Parameters
entryThe entry to be entered.
Returns
The current number of entries, if successful, negative error if the entry could not be added.
1119 {
1120  uint16_t hash = json_hash(entry.name);
1121  size_t csize = cinfo->jmap[hash].size();
1122 
1123  for (size_t i=0; i<csize; ++i)
1124  {
1125  if (entry.name == cinfo->jmap[hash][i].name)
1126  {
1127  cinfo->jmap[hash][i] = entry;
1128  return cinfo->jmapped;
1129  }
1130  }
1131 
1132  cinfo->jmap[hash].push_back(entry);
1133  if (cinfo->jmap[hash].size() != csize+1) { return JSON_ERROR_NOENTRY; }
1134 
1135  ++cinfo->jmapped;
1136  return (cinfo->jmapped);
1137 }
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
int i
Definition: rw_test.cpp:37
#define JSON_ERROR_NOENTRY
Definition: cosmos-errno.h:94
string name
Name of entry.
Definition: jsondef.h:4173
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
uint16_t json_hash(string hstring)
Calculate JSON HASH.
Definition: jsonlib.cpp:504
int32_t json_addentry ( string  name,
uint16_t  d1,
uint16_t  d2,
ptrdiff_t  offset,
uint16_t  type,
uint16_t  group,
cosmosstruc cinfo,
uint16_t  unit 
)

Add an entry to the JSON Namespace map with units.

Allocates the space for a new jsonentry and then enters the information associating a pointer with an entry in the name table. The name will be of form "name" if it is a scalar, "name_iii" if it is a first level array, "name_iii_iii" if it is second level, where "iii" is the zero filled index for the appropriate level.

Parameters
namevariable name from the JSON Data Name Space
d1array index for first level, otherwise -1
d2array index for second level, otherwise -1
offsetOffset to the data from the beginning of its group.
sizeNumber of bytes jsonentry take up.
typeCOSMOS JSON Data Type.
groupCOSMOS JSON Data Group.
unitIndex into JMAP unit table.
Returns
The current number of entries, if successful, 0 if the entry could not be added, or if enough memory could not be allocated to hold the JSON stream.
1157 {
1158  jsonentry tentry;
1159  char ename[COSMOS_MAX_NAME+1];
1160 
1161  // Determine extended name
1162  strcpy(ename,name.c_str());
1163  if (d1 < UINT16_MAX)
1164  sprintf(&ename[strlen(ename)],"_%03u",d1);
1165  if (d2 < UINT16_MAX)
1166  sprintf(&ename[strlen(ename)],"_%03u",d2);
1167 
1168  // Populate the entry
1169  tentry.alarm_index = 0;
1170  tentry.alert_index = 0;
1171  tentry.maximum_index = 0;
1172  tentry.minimum_index = 0;
1173  tentry.unit_index = unit;
1174  tentry.type = type;
1175  tentry.group = group;
1176  tentry.name = ename;
1177  tentry.offset = offset;
1178  tentry.ptr = nullptr;
1179  // tentry.size = size;
1180 
1181  return json_addentry(tentry, cinfo);
1182 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
string name
Name of entry.
Definition: jsondef.h:4173
uint8_t * ptr
pointer to data storage
Definition: jsondef.h:4177
uint16_t group
JSON Data Group.
Definition: jsondef.h:4171
uint16_t type
JSON Data Type.
Definition: jsondef.h:4169
uint16_t minimum_index
Index to minimum condition in Data Dictionary.
Definition: jsondef.h:4189
JSON map offset entry.
Definition: jsondef.h:4164
uint16_t maximum_index
Index to maximum condition in Data Dictionary.
Definition: jsondef.h:4187
int32_t json_addentry(jsonentry entry, cosmosstruc *cinfo)
Enter an entry into the JSON Namespace.
Definition: jsonlib.cpp:1118
string name
Definition: cubesat2obj.cpp:6
uint16_t alarm_index
Index to alarm condition in Data Dictionary.
Definition: jsondef.h:4185
uint16_t unit_index
Index to JSON Unit Type.
Definition: jsondef.h:4181
ptrdiff_t offset
offset to data storage
Definition: jsondef.h:4175
struct ip_mreq group
Definition: mcastclient.c:39
uint16_t alert_index
Index to alert condition in Data Dictionary.
Definition: jsondef.h:4183
int32_t json_addentry ( string  name,
uint16_t  d1,
uint16_t  d2,
uint8_t *  ptr,
uint16_t  type,
cosmosstruc cinfo,
uint16_t  unit 
)
1185 {
1186  jsonentry tentry;
1187  char ename[COSMOS_MAX_NAME+1];
1188 
1189  // Determine extended name
1190  strcpy(ename,name.c_str());
1191  if (d1 < UINT16_MAX)
1192  sprintf(&ename[strlen(ename)],"_%03u",d1);
1193  if (d2 < UINT16_MAX)
1194  sprintf(&ename[strlen(ename)],"_%03u",d2);
1195 
1196  // Populate the entry
1197  tentry.alarm_index = 0;
1198  tentry.alert_index = 0;
1199  tentry.maximum_index = 0;
1200  tentry.minimum_index = 0;
1201  tentry.unit_index = unit;
1202  tentry.type = type;
1203  tentry.group = JSON_STRUCT_PTR;
1204  tentry.name = ename;
1205  tentry.offset = 0;
1206  tentry.ptr = ptr;
1207  // tentry.size = size;
1208 
1209  return json_addentry(tentry, cinfo);
1210 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
string name
Name of entry.
Definition: jsondef.h:4173
uint8_t * ptr
pointer to data storage
Definition: jsondef.h:4177
Definition: jsondef.h:173
uint16_t group
JSON Data Group.
Definition: jsondef.h:4171
uint16_t type
JSON Data Type.
Definition: jsondef.h:4169
uint16_t minimum_index
Index to minimum condition in Data Dictionary.
Definition: jsondef.h:4189
JSON map offset entry.
Definition: jsondef.h:4164
uint16_t maximum_index
Index to maximum condition in Data Dictionary.
Definition: jsondef.h:4187
int32_t json_addentry(jsonentry entry, cosmosstruc *cinfo)
Enter an entry into the JSON Namespace.
Definition: jsonlib.cpp:1118
string name
Definition: cubesat2obj.cpp:6
uint16_t alarm_index
Index to alarm condition in Data Dictionary.
Definition: jsondef.h:4185
uint16_t unit_index
Index to JSON Unit Type.
Definition: jsondef.h:4181
ptrdiff_t offset
offset to data storage
Definition: jsondef.h:4175
uint16_t alert_index
Index to alert condition in Data Dictionary.
Definition: jsondef.h:4183
int32_t json_toggleentry ( string  name,
uint16_t  d1,
uint16_t  d2,
cosmosstruc cinfo,
bool  state 
)

Toggle the enable state of an entry in the JSON Namespace map.

Sets or clears the enabled flag for an entry in the name table. The name will be of form "name" if it is a scalar, "name_iii" if it is a first level array, "name_iii_iii" if it is second level, where "iii" is the zero filled index for the appropriate level.

Parameters
namevariable name from the JSON Data Name Space
d1array index for first level, otherwise -1
d2array index for second level, otherwise -1
stateEnable state to toggle to.
Returns
0 or a negative error.
1225 {
1226  char ename[COSMOS_MAX_NAME+1];
1227 
1228  // Determine extended name
1229  strcpy(ename,name.c_str());
1230  // JIMNOTE: this scheme really only works up to 999, not MAX. Also should error if out of bounds
1231  if (d1 < UINT16_MAX)
1232  sprintf(&ename[strlen(ename)],"_%03u",d1);
1233  if (d2 < UINT16_MAX)
1234  sprintf(&ename[strlen(ename)],"_%03u",d2);
1235 
1236  // Find the name in the map
1237  jsonentry *tentry = json_entry_of(ename, cinfo);
1238  if (tentry!= nullptr)
1239  {
1240  tentry->enabled = state;
1241  return 0;
1242  } else {
1243  return JSON_ERROR_NOENTRY;
1244  }
1245 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
#define JSON_ERROR_NOENTRY
Definition: cosmos-errno.h:94
jsonentry * json_entry_of(uint8_t *ptr, cosmosstruc *cinfo)
Info on Namespace address.
Definition: jsonlib.cpp:3124
JSON map offset entry.
Definition: jsondef.h:4164
string name
Definition: cubesat2obj.cpp:6
bool enabled
Enabled?
Definition: jsondef.h:4167
bool json_checkentry ( string  name,
uint16_t  d1,
uint16_t  d2,
cosmosstruc cinfo 
)

Check the enable state of an entry in the JSON Namespace map.

Returns the enabled flag for an entry in the name table. The name will be of form "name" if it is a scalar, "name_iii" if it is a first level array, "name_iii_iii" if it is second level, where "iii" is the zero filled index for the appropriate level.

Parameters
namevariable name from the JSON Data Name Space
d1array index for first level, otherwise -1
d2array index for second level, otherwise -1
Returns
0 or a negative error.
1259 {
1260  char ename[COSMOS_MAX_NAME+1];
1261 
1262  // Determine extended name
1263  strcpy(ename,name.c_str());
1264  // JIMNOTE: this scheme really only works up to 999, not MAX. Also should error if out of bounds
1265  if (d1 < UINT16_MAX)
1266  sprintf(&ename[strlen(ename)],"_%03u",d1);
1267  if (d2 < UINT16_MAX)
1268  sprintf(&ename[strlen(ename)],"_%03u",d2);
1269 
1270  // Find the name in the map
1271  jsonentry *tentry = json_entry_of(ename, cinfo);
1272  if (tentry!= nullptr)
1273  {
1274  return tentry->enabled;
1275  } else {
1276  return false;
1277  }
1278 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
jsonentry * json_entry_of(uint8_t *ptr, cosmosstruc *cinfo)
Info on Namespace address.
Definition: jsonlib.cpp:3124
JSON map offset entry.
Definition: jsondef.h:4164
string name
Definition: cubesat2obj.cpp:6
bool enabled
Enabled?
Definition: jsondef.h:4167
size_t json_count_hash ( uint16_t  hash,
cosmosstruc cinfo 
)

Number of items in current JSON map with a specific hash.

Returns the number of JSON items currently mapped.

Parameters
hashJSON HASH value.
Returns
Number of JSON items mapped, otherwise zero.
1287 {
1288  return (cinfo->jmap[hash].size());
1289 }
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
size_t json_count_total ( cosmosstruc cinfo)

Number of items in the current JSON map.

Returns the number of JSON items currently mapped.

Returns
total number of JSON items mapped, otherwise zero.
1298 {
1299  size_t i = 0;
1300  for(uint32_t j = 0; j < cinfo->jmap.size(); ++j)
1301  i += json_count_hash((uint16_t)j, cinfo);
1302  return i;
1303 }
int i
Definition: rw_test.cpp:37
size_t json_count_hash(uint16_t hash, cosmosstruc *cinfo)
Number of items in current JSON map with a specific hash.
Definition: jsonlib.cpp:1286
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
int32_t json_out_handle ( string &  jstring,
jsonhandle  handle,
cosmosstruc cinfo 
)

Perform JSON output for a JSON item by handle.

Appends the indicated JSON object to the supplied JSON Stream.

Parameters
jstringReference to JSON stream.
handleThe jsonhandle of the desired object.
cinfoReference to cosmosstruc to use.
Returns
0 if successful, negative error otherwise
1314 {
1315  if (!cinfo->jmapped)
1316  return (JSON_ERROR_NOJMAP);
1317  return json_out_entry(jstring, cinfo->jmap[handle.hash][handle.index], cinfo);
1318 }
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
#define JSON_ERROR_NOJMAP
Definition: cosmos-errno.h:93
int32_t json_out_entry(string &jstring, const jsonentry &entry, cosmosstruc *cinfo)
Perform JSON output for a single JSON entry.
Definition: jsonlib.cpp:1327
uint16_t hash
Definition: jsondef.h:794
uint16_t index
Definition: jsondef.h:796
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
int32_t json_out_entry ( string &  jstring,
const jsonentry entry,
cosmosstruc cinfo 
)

Perform JSON output for a single JSON entry.

Populates the jstring for the indicated ::jsonmap by jsonentry.

Parameters
jstringReference to JSON stream.
entryThe jsonentry of the desired variable.
cinfoReference to cosmosstruc to use.
Returns
0 if successful, negative error otherwise
1328 {
1329  int32_t iretn;
1330  uint8_t *data;
1331 
1332  jstring.erase(jstring.find_last_not_of(" \n\r\t")+1);
1333  if (jstring.back() =='}') //replaces '}' with ',' to allow the continuation of the json object (if node json is to remain separate, input ' ' at end?
1334  {
1335  jstring.back()=',';
1336  }
1337  else if ((iretn=json_out_character(jstring,'{')) != 0) //still inputs '{' if it is the first entry into the string
1338  return iretn;
1339 
1340  data = json_ptr_of_entry(entry, cinfo);
1341  if ((iretn=json_out_value(jstring, entry.name, data, entry.type, cinfo)) != 0)
1342  return iretn;
1343 
1344  if ((iretn=json_out_character(jstring,'}')) != 0) //closes json object. if json continues it will be overwritten with ','
1345  return iretn;
1346 
1347  return iretn;
1348 }
int32_t json_out_value(string &jstring, string name, uint8_t *data, uint16_t type, cosmosstruc *cinfo)
Output JSON Pair.
Definition: jsonlib.cpp:1361
int iretn
Definition: rw_test.cpp:37
string name
Name of entry.
Definition: jsondef.h:4173
uint16_t type
JSON Data Type.
Definition: jsondef.h:4169
uint8_t * json_ptr_of_entry(const jsonentry &entry, cosmosstruc *cinfo)
Address from entry.
Definition: jsonlib.cpp:3004
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
int32_t json_out_value ( string &  jstring,
string  name,
uint8_t *  data,
uint16_t  type,
cosmosstruc cinfo 
)

Output JSON Pair.

Append a name:value pair to the provided JSON String for a variable in the JSON Namespace, based on the provided data and type.

Parameters
jstringReference to JSON String to append to.
nameNamespace name of variable.
dataPointer to location in cosmosstruc of variable.
typeType of variable.
cinfoReference to cosmosstruc to use.
Returns
Zero or negative error.
1362 {
1363  int32_t iretn;
1364 
1365  if (!cinfo->jmapped)
1366  {
1367  return JSON_ERROR_NOJMAP;
1368  }
1369 
1370  if ((iretn=json_out_name(jstring ,name)) != 0)
1371  {
1372  return iretn;
1373  }
1374 
1375  if ((iretn=json_out_type(jstring, data, type, cinfo)) != 0)
1376  {
1377  return iretn;
1378  }
1379 
1380  return 0;
1381 }
int32_t json_out_type(string &jstring, uint8_t *data, uint16_t type, cosmosstruc *cinfo)
Output JSON Value.
Definition: jsonlib.cpp:1393
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
#define JSON_ERROR_NOJMAP
Definition: cosmos-errno.h:93
int iretn
Definition: rw_test.cpp:37
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
string name
Definition: cubesat2obj.cpp:6
int32_t json_out_type ( string &  jstring,
uint8_t *  data,
uint16_t  type,
cosmosstruc cinfo 
)

Output JSON Value.

Append the value of a name:value pair to the provided JSON String for a variable in the JSON Namespace, based on the provided data and type.

Parameters
jstringReference to JSON String to append to.
dataPointer to location of variable.
typeType of variable.
cinfoReference to cosmosstruc to use.
Returns
Zero or negative error.
1394 {
1395  int32_t iretn = 0;
1396 
1397  switch (type)
1398  {
1399  case JSON_TYPE_BOOL:
1400  if ((iretn=json_out_uint8(jstring,*(uint8_t *)data)) != 0)
1401  return iretn;
1402  break;
1403  case JSON_TYPE_UINT8:
1404  if ((iretn=json_out_uint8(jstring,*(uint8_t *)data)) != 0)
1405  return iretn;
1406  break;
1407  case JSON_TYPE_UINT16:
1408  if ((iretn=json_out_uint16(jstring,*(uint16_t *)data)) != 0)
1409  return iretn;
1410  break;
1411  case JSON_TYPE_UINT32:
1412  if ((iretn=json_out_uint32(jstring,*(uint32_t *)data)) != 0)
1413  return iretn;
1414  break;
1415  case JSON_TYPE_INT8:
1416  if ((iretn=json_out_int8(jstring,*(int8_t *)data)) != 0)
1417  return iretn;
1418  break;
1419  case JSON_TYPE_INT16:
1420  if ((iretn=json_out_int16(jstring,*(int16_t *)data)) != 0)
1421  return iretn;
1422  break;
1423  case JSON_TYPE_INT32:
1424  if ((iretn=json_out_int32(jstring,*(int32_t *)data)) != 0)
1425  return iretn;
1426  break;
1427  case JSON_TYPE_FLOAT:
1428  if ((iretn=json_out_float(jstring,*(float *)data)) != 0)
1429  return iretn;
1430  break;
1431  case JSON_TYPE_DOUBLE:
1432  case JSON_TYPE_TIMESTAMP:
1433  if ((iretn=json_out_double(jstring,*(double *)data)) != 0)
1434  return iretn;
1435  break;
1436  case JSON_TYPE_STRING:
1437  if ((iretn=json_out_string(jstring,(char *)data,COSMOS_MAX_DATA)) != 0)
1438  return iretn;
1439  break;
1440  case JSON_TYPE_NAME:
1441  if ((iretn=json_out_string(jstring,(char *)data,COSMOS_MAX_NAME)) != 0)
1442  return iretn;
1443  break;
1444  case JSON_TYPE_VECTOR:
1445  if ((iretn=json_out_vector(jstring,*(Vector *)data)) != 0)
1446  return iretn;
1447  break;
1448  case JSON_TYPE_GVECTOR:
1449  if ((iretn=json_out_gvector(jstring,*(gvector *)data)) != 0)
1450  return iretn;
1451  break;
1452  case JSON_TYPE_CVECTOR:
1453  if ((iretn=json_out_cvector(jstring,*(cvector *)data)) != 0)
1454  return iretn;
1455  break;
1456  case JSON_TYPE_AVECTOR:
1457  if ((iretn=json_out_avector(jstring,*(avector *)data)) != 0)
1458  return iretn;
1459  break;
1460  case JSON_TYPE_QUATERNION:
1461  if ((iretn=json_out_quaternion(jstring,*(quaternion *)data)) != 0)
1462  return iretn;
1463  break;
1464  case JSON_TYPE_RMATRIX:
1465  if ((iretn=json_out_rmatrix(jstring,*(rmatrix *)data)) != 0)
1466  return iretn;
1467  break;
1468  case JSON_TYPE_RVECTOR:
1469  // case JSON_TYPE_TVECTOR:
1470  if ((iretn=json_out_rvector(jstring,*(rvector *)data)) != 0)
1471  return iretn;
1472  break;
1473  case JSON_TYPE_GEOIDPOS:
1474  case JSON_TYPE_POS_SELG:
1475  case JSON_TYPE_POS_GEOD:
1476  if ((iretn=json_out_geoidpos(jstring,*(geoidpos *)data)) != 0)
1477  return iretn;
1478  break;
1479  case JSON_TYPE_SPHERPOS:
1480  case JSON_TYPE_POS_GEOS:
1481  if ((iretn=json_out_spherpos(jstring,*(spherpos *)data)) != 0)
1482  return iretn;
1483  break;
1484  case JSON_TYPE_CARTPOS:
1485  case JSON_TYPE_POS_GEOC:
1486  case JSON_TYPE_POS_SELC:
1487  case JSON_TYPE_POS_ECI:
1488  case JSON_TYPE_POS_SCI:
1489  case JSON_TYPE_POS_ICRF:
1490  if ((iretn=json_out_cartpos(jstring,*(cartpos *)data)) != 0)
1491  return iretn;
1492  break;
1493  case JSON_TYPE_DCMATT:
1494  if ((iretn=json_out_dcmatt(jstring,*(dcmatt *)data)) != 0)
1495  return iretn;
1496  break;
1497  case JSON_TYPE_QATT:
1498  case JSON_TYPE_QATT_TOPO:
1499  case JSON_TYPE_QATT_GEOC:
1500  case JSON_TYPE_QATT_LVLH:
1501  case JSON_TYPE_QATT_ICRF:
1502  case JSON_TYPE_QATT_SELC:
1503  if ((iretn=json_out_qatt(jstring,*(qatt *)data)) != 0)
1504  return iretn;
1505  break;
1506  case JSON_TYPE_HBEAT:
1507  if ((iretn=json_out_beatstruc(jstring,*(beatstruc *)data)) != 0)
1508  return iretn;
1509  break;
1510  case JSON_TYPE_LOC_POS:
1511  if ((iretn=json_out_posstruc(jstring,*(posstruc *)data)) != 0)
1512  return iretn;
1513  break;
1514  case JSON_TYPE_LOC_ATT:
1515  {
1516  if ((iretn=json_out_attstruc(jstring,*(attstruc *)data)) != 0)
1517  return iretn;
1518  break;
1519  }
1520  case JSON_TYPE_LOCSTRUC:
1521  {
1522  if ((iretn=json_out_locstruc(jstring,*(locstruc *)data)) != 0)
1523  return iretn;
1524  break;
1525  }
1526  case JSON_TYPE_EQUATION:
1527  {
1528  const char *ptr = (char *)data;
1529  if ((iretn=json_out_double(jstring, json_equation(ptr, cinfo))) != 0)
1530  {
1531  return iretn;
1532  }
1533  break;
1534  }
1535  }
1536 
1537  return iretn;
1538 }
JSON 16 bit integer type.
Definition: jsondef.h:194
JSON rvector.
Definition: jsondef.h:210
int32_t json_out_cvector(string &jstring, cvector value)
cvector to JSON
Definition: jsonlib.cpp:2086
JSON Timestamp.
Definition: jsondef.h:292
int32_t json_out_attstruc(string &jstring, attstruc value)
attstruc to JSON
Definition: jsonlib.cpp:2446
JSON string type.
Definition: jsondef.h:204
JSON Geocentric Attitude.
Definition: jsondef.h:264
Definition: jsondef.h:923
JSON 8 bit unsigned integer type.
Definition: jsondef.h:182
Quaternion Attitude.
Definition: convertdef.h:475
3 element generic row vector
Definition: vector.h:53
Direction Cosine Matrix Attitude.
Definition: convertdef.h:423
int32_t json_out_int32(string &jstring, int32_t value)
Signed 32 bit integer to JSON.
Definition: jsonlib.cpp:1652
Geodetic position structure.
Definition: convertdef.h:259
JSON Earth Centered Inertial Position.
Definition: jsondef.h:247
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
int32_t json_out_string(string &jstring, string ostring, uint16_t len)
String to JSON.
Definition: jsonlib.cpp:1764
JSON qatt.
Definition: jsondef.h:232
Cartesian full position structure.
Definition: convertdef.h:158
int32_t json_out_gvector(string &jstring, gvector value)
gvector to JSON
Definition: jsonlib.cpp:1854
int32_t json_out_geoidpos(string &jstring, geoidpos value)
geoidpos to JSON
Definition: jsonlib.cpp:2175
JSON rmatrix.
Definition: jsondef.h:222
int32_t json_out_quaternion(string &jstring, quaternion value)
quaternion to JSON
Definition: jsonlib.cpp:2054
Quaternion, scalar last, using x, y, z.
Definition: vector.h:402
int32_t json_out_uint32(string &jstring, uint32_t value)
Unsigned 32 bit integer to JSON.
Definition: jsonlib.cpp:1703
int iretn
Definition: rw_test.cpp:37
JSON cvector.
Definition: jsondef.h:214
JSON Lunar Centered Inertial Attitude.
Definition: jsondef.h:266
int32_t json_out_int16(string &jstring, int16_t value)
Signed 16 bit integer to JSON.
Definition: jsonlib.cpp:1635
int32_t json_out_uint16(string &jstring, uint16_t value)
Unsigned 16 bit integer to JSON.
Definition: jsonlib.cpp:1686
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
JSON Geocentric Spherical.
Definition: jsondef.h:257
int32_t json_out_rvector(string &jstring, rvector value)
rvector to JSON
Definition: jsonlib.cpp:2018
JSON rvector.
Definition: jsondef.h:212
int32_t json_out_spherpos(string &jstring, spherpos value)
spherpos to JSON
Definition: jsonlib.cpp:2224
JSON Geocentric Position.
Definition: jsondef.h:251
Definition: convertdef.h:733
double json_equation(const char *&ptr, cosmosstruc *cinfo)
Return the results of a JSON equation.
Definition: jsonlib.cpp:4294
JSON Name type.
Definition: jsondef.h:206
JSON Satellite Position Structure.
Definition: jsondef.h:272
JSON Lunar Centered Inertial Position.
Definition: jsondef.h:249
JSON Earth Centered Inertial Attitude.
Definition: jsondef.h:268
JSON LVLH Attitude.
Definition: jsondef.h:270
JSON Satellite Attitude Structure.
Definition: jsondef.h:274
#define COSMOS_MAX_DATA
Definition: cosmos-defs.h:53
3 element attitude vector.
Definition: vector.h:277
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
JSON cartpos.
Definition: jsondef.h:228
3x3 element generic matrix
Definition: matrix.h:41
int32_t json_out_cartpos(string &jstring, cartpos value)
cartpos to JSON
Definition: jsonlib.cpp:2126
int32_t json_out_int8(string &jstring, int8_t value)
Signed 8 bit integer to JSON.
Definition: jsonlib.cpp:1618
int32_t json_out_locstruc(string &jstring, locstruc value)
locstruc to JSON
Definition: jsonlib.cpp:2511
JSON Geodetic Position.
Definition: jsondef.h:255
JSON dcmatt.
Definition: jsondef.h:234
JSON cartpos.
Definition: jsondef.h:226
int32_t json_out_qatt(string &jstring, qatt value)
qatt to JSON
Definition: jsonlib.cpp:2677
int32_t json_out_rmatrix(string &jstring, rmatrix value)
rmatrix to JSON
Definition: jsonlib.cpp:2760
JSON 32 bit integer type.
Definition: jsondef.h:196
int32_t json_out_vector(string &jstring, Vector value)
::Vector to JSON
Definition: jsonlib.cpp:1974
int32_t json_out_uint8(string &jstring, uint8_t value)
Unsigned 8 bit integer to JSON.
Definition: jsonlib.cpp:1669
JSON Boolean.
Definition: jsondef.h:188
JSON Topocentric Attitude.
Definition: jsondef.h:262
Spherical position structure.
Definition: convertdef.h:314
JSON Agent Heartbeat.
Definition: jsondef.h:242
JSON double precision floating vertex type.
Definition: jsondef.h:200
JSON 8 bit signed integer type.
Definition: jsondef.h:184
JSON 32 bit unsigned integer type.
Definition: jsondef.h:190
JSON cartpos.
Definition: jsondef.h:224
JSON ::Vector.
Definition: jsondef.h:208
int32_t json_out_beatstruc(string &jstring, beatstruc value)
beatstruc to JSON
Definition: jsonlib.cpp:2796
int32_t json_out_float(string &jstring, float value)
Single precision floating vertex32_t to JSON.
Definition: jsonlib.cpp:1720
JSON single precision floating vertex type.
Definition: jsondef.h:198
JSON locstruc type.
Definition: jsondef.h:276
JSON Equation.
Definition: jsondef.h:294
Vector Class.
Definition: vector.h:672
int32_t json_out_dcmatt(string &jstring, dcmatt value)
Definition: jsonlib.cpp:2636
Definition: convertdef.h:823
3 element geodetic vector
Definition: vector.h:222
JSON gvector.
Definition: jsondef.h:218
JSON Selenocentric Position.
Definition: jsondef.h:253
JSON Solar Barycentric Position.
Definition: jsondef.h:244
Definition: convertdef.h:876
JSON quaternion type.
Definition: jsondef.h:216
int32_t json_out_posstruc(string &jstring, posstruc value)
posstruc to JSON
Definition: jsonlib.cpp:2349
3 element cartesian vector
Definition: vector.h:107
int32_t json_out_avector(string &jstring, avector value)
avector to JSON
Definition: jsonlib.cpp:1934
JSON Selenographic Position.
Definition: jsondef.h:259
int32_t json_append ( string &  jstring,
const char *  tstring 
)

Extend JSON stream.

Append the indicated string to the current JSON stream, extending it if necessary.

Parameters
jstringJSON stting to be appended to.
tstringString to be appended.
Returns
0 if successful, negative error number otherwise.
1547 {
1548  jstring.append(tstring);
1549  return 0;
1550 }
int32_t json_out_character ( string &  jstring,
char  character 
)

Single character to JSON.

Appends an entry for the single character to the current JSON stream.

Parameters
jstringReference to JSON stream.
characterCharacter to be added to string in the raw.
Returns
0 if successful, otherwise negative error.
1559 {
1560  char tstring[2] = {0,0};
1561  int32_t iretn;
1562 
1563  tstring[0] = character;
1564  if ((iretn=json_append(jstring,tstring)) < 0)
1565  return iretn;
1566 
1567  return 0;
1568 }
int32_t json_append(string &jstring, const char *tstring)
Extend JSON stream.
Definition: jsonlib.cpp:1546
int iretn
Definition: rw_test.cpp:37
int32_t json_out_name ( string &  jstring,
string  name 
)

Object name to JSON.

Appends an entry for the name piece of a JSON object (including ":") to the current JSON string.

Parameters
jstringReference to JSON stream.
nameThe Object Name
Returns
0 if successful, otherwise negative error.
1578 {
1579  int32_t iretn;
1580 
1581  if ((iretn=json_out_string(jstring, name, COSMOS_MAX_NAME)) < 0)
1582  return iretn;
1583  if ((iretn=json_out_character(jstring,':')) < 0)
1584  return iretn;
1585  return 0;
1586 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
int32_t json_out_string(string &jstring, string ostring, uint16_t len)
String to JSON.
Definition: jsonlib.cpp:1764
int iretn
Definition: rw_test.cpp:37
string name
Definition: cubesat2obj.cpp:6
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
int32_t json_out_bool ( string &  jstring,
bool  value 
)

Boolean to JSON.

Appends a JSON entry to the current JSON stream for the indicated 8 bit boolean.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
1595 {
1596  int32_t iretn;
1597  char tstring[15];
1598 
1599  if (value)
1600  {
1601  sprintf(tstring, "true");
1602  }
1603  else
1604  {
1605  sprintf(tstring, "false");
1606  }
1607 
1608  iretn = json_append(jstring,tstring);
1609  return iretn;
1610 }
int32_t json_append(string &jstring, const char *tstring)
Extend JSON stream.
Definition: jsonlib.cpp:1546
int iretn
Definition: rw_test.cpp:37
int32_t json_out_int8 ( string &  jstring,
int8_t  value 
)

Signed 8 bit integer to JSON.

Appends a JSON entry to the current JSON stream for the indicated 8 bit signed integer.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
1619 {
1620  int32_t iretn;
1621  char tstring[15];
1622 
1623  sprintf(tstring,"%" PRIi8,value);
1624 
1625  iretn = json_append(jstring,tstring);
1626  return iretn;
1627 }
int32_t json_append(string &jstring, const char *tstring)
Extend JSON stream.
Definition: jsonlib.cpp:1546
int iretn
Definition: rw_test.cpp:37
int32_t json_out_int16 ( string &  jstring,
int16_t  value 
)

Signed 16 bit integer to JSON.

Appends a JSON entry to the current JSON stream for the indicated 16 bit signed integer.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
1636 {
1637  int32_t iretn;
1638  char tstring[15];
1639 
1640  sprintf(tstring,"%d",value);
1641 
1642  iretn = json_append(jstring,tstring);
1643  return iretn;
1644 }
int32_t json_append(string &jstring, const char *tstring)
Extend JSON stream.
Definition: jsonlib.cpp:1546
int iretn
Definition: rw_test.cpp:37
int32_t json_out_int32 ( string &  jstring,
int32_t  value 
)

Signed 32 bit integer to JSON.

Appends a JSON entry to the current JSON stream for the indicated 32 bit signed integer.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
1653 {
1654  int32_t iretn;
1655  char tstring[15];
1656 
1657  sprintf(tstring,"%d",value);
1658 
1659  iretn = json_append(jstring,tstring);
1660  return iretn;
1661 }
int32_t json_append(string &jstring, const char *tstring)
Extend JSON stream.
Definition: jsonlib.cpp:1546
int iretn
Definition: rw_test.cpp:37
int32_t json_out_uint8 ( string &  jstring,
uint8_t  value 
)

Unsigned 8 bit integer to JSON.

Appends a JSON entry to the current JSON stream for the indicated 8 bit unsigned integer.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
1670 {
1671  int32_t iretn;
1672  char tstring[15];
1673 
1674  sprintf(tstring, "%u",value);
1675 
1676  iretn = json_append(jstring,tstring);
1677  return iretn;
1678 }
int32_t json_append(string &jstring, const char *tstring)
Extend JSON stream.
Definition: jsonlib.cpp:1546
int iretn
Definition: rw_test.cpp:37
int32_t json_out_uint16 ( string &  jstring,
uint16_t  value 
)

Unsigned 16 bit integer to JSON.

Appends a JSON entry to the current JSON stream for the indicated 16 bit unsigned integer.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
1687 {
1688  int32_t iretn;
1689  char tstring[15];
1690 
1691  sprintf(tstring,"%u",value);
1692 
1693  iretn = json_append(jstring,tstring);
1694  return iretn;
1695 }
int32_t json_append(string &jstring, const char *tstring)
Extend JSON stream.
Definition: jsonlib.cpp:1546
int iretn
Definition: rw_test.cpp:37
int32_t json_out_uint32 ( string &  jstring,
uint32_t  value 
)

Unsigned 32 bit integer to JSON.

Appends a JSON entry to the current JSON stream for the indicated 32 bit unsigned integer.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
1704 {
1705  int32_t iretn;
1706  char tstring[15];
1707 
1708  sprintf(tstring,"%u",value);
1709 
1710  iretn = json_append(jstring,tstring);
1711  return iretn;
1712 }
int32_t json_append(string &jstring, const char *tstring)
Extend JSON stream.
Definition: jsonlib.cpp:1546
int iretn
Definition: rw_test.cpp:37
int32_t json_out_float ( string &  jstring,
float  value 
)

Single precision floating vertex32_t to JSON.

Appends a JSON entry to the current JSON stream for the indicated float.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
1721 {
1722  int32_t iretn = 0;
1723  char tstring[15];
1724 
1725  if (!isfinite(value)) //CT:11/07/2017: changing invalid floats to 0.
1726  {
1727  value=0.0;
1728  }
1729 
1730  sprintf(tstring,"%.8g",value);
1731  iretn = json_append(jstring,tstring);
1732  return iretn;
1733 }
int32_t json_append(string &jstring, const char *tstring)
Extend JSON stream.
Definition: jsonlib.cpp:1546
int iretn
Definition: rw_test.cpp:37
int32_t json_out_double ( string &  jstring,
double  value 
)

Perform JSON output for a single nonindexed double.

Appends a JSON entry to the current JSON stream for the indicated double.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
1742 {
1743  int32_t iretn = 0;
1744  char tstring[30];
1745 
1746  if (!isfinite(value)) //CT:11/07/2017: changing invalid doubles to 0.
1747  {
1748  value=0.0;
1749  }
1750 
1751  sprintf(tstring,"%.17g",value);
1752  iretn = json_append(jstring,tstring);
1753 
1754  return iretn;
1755 }
int32_t json_append(string &jstring, const char *tstring)
Extend JSON stream.
Definition: jsonlib.cpp:1546
int iretn
Definition: rw_test.cpp:37
int32_t json_out_string ( string &  jstring,
string  ostring,
uint16_t  len 
)

String to JSON.

Appends a JSON entry to the current JSON stream for the string variable.

Parameters
jstringReference to JSON stream.
ostringString to append.
lenMaximum allowed size.
Returns
0 if successful, negative error otherwise
1765 {
1766  int32_t iretn;
1767  uint16_t i;
1768  char tstring[5];
1769 
1770  if (len > JSON_MAX_DATA)
1771  len = JSON_MAX_DATA;
1772 
1773  if ((iretn=json_out_character(jstring,'"')) < 0)
1774  {
1775  return iretn;
1776  }
1777 
1778  for (i=0; i<ostring.size(); i++)
1779  {
1780  if (i > len)
1781  {
1782  break;
1783  }
1784 
1785  if (ostring[i] == '"' || ostring[i] == '\\' || ostring[i] == '/')
1786  {
1787  if ((iretn=json_out_character(jstring,'\\')) < 0)
1788  return iretn;
1789  if ((iretn=json_out_character(jstring, ostring[i])) < 0)
1790  return iretn;
1791  }
1792  else if (ostring[i] < 32)
1793  {
1794  if ((iretn=json_out_character(jstring,'\\')) < 0)
1795  return iretn;
1796  switch (ostring[i])
1797  {
1798  case '\b':
1799  if ((iretn=json_out_character(jstring,'b')) < 0)
1800  return iretn;
1801  break;
1802  case '\f':
1803  if ((iretn=json_out_character(jstring,'f')) < 0)
1804  return iretn;
1805  break;
1806  case '\n':
1807  if ((iretn=json_out_character(jstring,'n')) < 0)
1808  return iretn;
1809  break;
1810  case '\r':
1811  if ((iretn=json_out_character(jstring,'r')) < 0)
1812  return iretn;
1813  break;
1814  case '\t':
1815  if ((iretn=json_out_character(jstring,'t')) < 0)
1816  return iretn;
1817  break;
1818  default:
1819  if ((iretn=json_out_character(jstring,'u')) < 0)
1820  return iretn;
1821  sprintf(tstring,"%04x", ostring[i]);
1822  if ((iretn=json_out_string(jstring,tstring,4)) < 0)
1823  return iretn;
1824  }
1825  }
1826  else if (ostring[i] < 127)
1827  {
1828  if ((iretn=json_out_character(jstring, ostring[i])) < 0)
1829  return iretn;
1830  }
1831  else
1832  {
1833  if ((iretn=json_out_character(jstring,'\\')) < 0)
1834  return iretn;
1835  if ((iretn=json_out_character(jstring,'u')) < 0)
1836  return iretn;
1837  sprintf(tstring,"%04x", ostring[i]);
1838  if ((iretn=json_out_string(jstring,tstring,4)) < 0)
1839  return iretn;
1840  }
1841  }
1842  if ((iretn=json_out_character(jstring,'"')) < 0)
1843  return iretn;
1844 
1845  return iretn;
1846 }
int i
Definition: rw_test.cpp:37
int32_t json_out_string(string &jstring, string ostring, uint16_t len)
String to JSON.
Definition: jsonlib.cpp:1764
int iretn
Definition: rw_test.cpp:37
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
#define JSON_MAX_DATA
Largest JSON data.
Definition: jsondef.h:427
int32_t json_out_gvector ( string &  jstring,
gvector  value 
)

gvector to JSON

Appends a JSON entry to the current JSON stream for the indicated gvector.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
1855 {
1856  int32_t iretn;
1857 
1858  if ((iretn=json_out_character(jstring,'{')) < 0)
1859  return iretn;
1860 
1861  // Output Latitude
1862  if ((iretn=json_out_name(jstring, "lat")) < 0)
1863  return iretn;
1864  if ((iretn=json_out_double(jstring,value.lat)) < 0)
1865  return iretn;
1866  if ((iretn=json_out_character(jstring,',')) < 0)
1867  return iretn;
1868 
1869  // Output Longitude
1870  if ((iretn=json_out_name(jstring, "lon")) < 0)
1871  return iretn;
1872  if ((iretn=json_out_double(jstring,value.lon)) < 0)
1873  return iretn;
1874  if ((iretn=json_out_character(jstring,',')) < 0)
1875  return iretn;
1876 
1877  // Output Height
1878  if ((iretn=json_out_name(jstring, "h")) < 0)
1879  return iretn;
1880  if ((iretn=json_out_double(jstring,value.h)) < 0)
1881  return iretn;
1882 
1883  if ((iretn=json_out_character(jstring,'}')) < 0)
1884  return iretn;
1885  return 0;
1886 }
int iretn
Definition: rw_test.cpp:37
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
double h
Height in meters.
Definition: vector.h:229
double lon
Longitude in radians.
Definition: vector.h:227
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
double lat
Latitude in radians.
Definition: vector.h:225
int32_t json_out_svector ( string &  jstring,
svector  value 
)

svector to JSON

Appends a JSON entry to the current JSON stream for the indicated svector.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
1895 {
1896  int32_t iretn;
1897 
1898  if ((iretn=json_out_character(jstring,'{')) < 0)
1899  return iretn;
1900 
1901  // Output Latitude
1902  if ((iretn=json_out_name(jstring, "phi")) < 0)
1903  return iretn;
1904  if ((iretn=json_out_double(jstring,value.phi)) < 0)
1905  return iretn;
1906  if ((iretn=json_out_character(jstring,',')) < 0)
1907  return iretn;
1908 
1909  // Output Longitude
1910  if ((iretn=json_out_name(jstring, "lambda")) < 0)
1911  return iretn;
1912  if ((iretn=json_out_double(jstring,value.lambda)) < 0)
1913  return iretn;
1914  if ((iretn=json_out_character(jstring,',')) < 0)
1915  return iretn;
1916 
1917  // Output Height
1918  if ((iretn=json_out_name(jstring, "r")) < 0)
1919  return iretn;
1920  if ((iretn=json_out_double(jstring,value.r)) < 0)
1921  return iretn;
1922 
1923  if ((iretn=json_out_character(jstring,'}')) < 0)
1924  return iretn;
1925  return 0;
1926 }
double lambda
E/W in radians.
Definition: vector.h:172
int iretn
Definition: rw_test.cpp:37
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
double phi
N/S in radians.
Definition: vector.h:170
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
double r
Radius in meters.
Definition: vector.h:174
int32_t json_out_avector ( string &  jstring,
avector  value 
)

avector to JSON

Appends a JSON entry to the current JSON stream for the indicated avector.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
1935 {
1936  int32_t iretn;
1937 
1938  if ((iretn=json_out_character(jstring,'{')) < 0)
1939  return iretn;
1940 
1941  // Output Bank
1942  if ((iretn=json_out_name(jstring, "b")) < 0)
1943  return iretn;
1944  if ((iretn=json_out_double(jstring,value.b)) < 0)
1945  return iretn;
1946  if ((iretn=json_out_character(jstring,',')) < 0)
1947  return iretn;
1948 
1949  // Output Elevation
1950  if ((iretn=json_out_name(jstring, "e")) < 0)
1951  return iretn;
1952  if ((iretn=json_out_double(jstring,value.e)) < 0)
1953  return iretn;
1954  if ((iretn=json_out_character(jstring,',')) < 0)
1955  return iretn;
1956 
1957  // Output Heading
1958  if ((iretn=json_out_name(jstring, "h")) < 0)
1959  return iretn;
1960  if ((iretn=json_out_double(jstring,value.h)) < 0)
1961  return iretn;
1962 
1963  if ((iretn=json_out_character(jstring,'}')) < 0)
1964  return iretn;
1965  return 0;
1966 }
int iretn
Definition: rw_test.cpp:37
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
double e
Elevation.
Definition: vector.h:282
double b
Bank.
Definition: vector.h:284
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
double h
Heading.
Definition: vector.h:280
int32_t json_out_vector ( string &  jstring,
Vector  value 
)

::Vector to JSON

Appends a JSON entry to the current JSON stream for the indicated ::Vector.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
1975 {
1976  int32_t iretn;
1977 
1978  if ((iretn=json_out_character(jstring,'[')) < 0)
1979  return iretn;
1980 
1981  // Output x
1982  if ((iretn=json_out_double(jstring,value.x)) < 0)
1983  return iretn;
1984  if ((iretn=json_out_character(jstring,',')) < 0)
1985  return iretn;
1986 
1987  // Output y
1988  if ((iretn=json_out_double(jstring,value.y)) < 0)
1989  return iretn;
1990  if ((iretn=json_out_character(jstring,',')) < 0)
1991  return iretn;
1992 
1993  // Output z
1994  if ((iretn=json_out_double(jstring,value.z)) < 0)
1995  return iretn;
1996 
1997  // Optionally output w
1998  if (value.w != 0.)
1999  {
2000  if ((iretn=json_out_character(jstring,',')) < 0)
2001  return iretn;
2002  if ((iretn=json_out_double(jstring,value.w)) < 0)
2003  return iretn;
2004  }
2005 
2006  if ((iretn=json_out_character(jstring,']')) < 0)
2007  return iretn;
2008 
2009  return 0;
2010 }
int iretn
Definition: rw_test.cpp:37
double y
Definition: vector.h:713
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
double z
Definition: vector.h:714
double x
Definition: vector.h:712
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
double w
Definition: vector.h:715
int32_t json_out_rvector ( string &  jstring,
rvector  value 
)

rvector to JSON

Appends a JSON entry to the current JSON stream for the indicated rvector.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2019 {
2020  int32_t iretn;
2021 
2022  if ((iretn=json_out_character(jstring,'[')) < 0)
2023  return iretn;
2024 
2025  // Output Col[0]
2026  if ((iretn=json_out_double(jstring,value.col[0])) < 0)
2027  return iretn;
2028  if ((iretn=json_out_character(jstring,',')) < 0)
2029  return iretn;
2030 
2031  // Output Col[1]
2032  if ((iretn=json_out_double(jstring,value.col[1])) < 0)
2033  return iretn;
2034  if ((iretn=json_out_character(jstring,',')) < 0)
2035  return iretn;
2036 
2037  // Output Col[2]
2038  if ((iretn=json_out_double(jstring,value.col[2])) < 0)
2039  return iretn;
2040 
2041  if ((iretn=json_out_character(jstring,']')) < 0)
2042  return iretn;
2043 
2044  return 0;
2045 }
int iretn
Definition: rw_test.cpp:37
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
double col[3]
Definition: vector.h:55
int32_t json_out_quaternion ( string &  jstring,
quaternion  value 
)

quaternion to JSON

Appends a JSON entry to the current JSON stream for the indicated quaternion.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2055 {
2056  int32_t iretn;
2057 
2058  if ((iretn=json_out_character(jstring,'{')) < 0)
2059  return iretn;
2060 
2061  // Output Orientation
2062  if ((iretn=json_out_name(jstring, "d")) < 0)
2063  return iretn;
2064  if ((iretn=json_out_cvector(jstring,value.d)) < 0)
2065  return iretn;
2066  if ((iretn=json_out_character(jstring,',')) < 0)
2067  return iretn;
2068 
2069  // Output Rotation
2070  if ((iretn=json_out_name(jstring, "w")) < 0)
2071  return iretn;
2072  if ((iretn=json_out_double(jstring,value.w)) < 0)
2073  return iretn;
2074 
2075  if ((iretn=json_out_character(jstring,'}')) < 0)
2076  return iretn;
2077  return 0;
2078 }
int32_t json_out_cvector(string &jstring, cvector value)
cvector to JSON
Definition: jsonlib.cpp:2086
cvector d
Orientation.
Definition: vector.h:405
int iretn
Definition: rw_test.cpp:37
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
double w
Rotation.
Definition: vector.h:407
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
int32_t json_out_cvector ( string &  jstring,
cvector  value 
)

cvector to JSON

Appends a JSON entry to the current JSON stream for the indicated cvector.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2087 {
2088  int32_t iretn;
2089 
2090  if ((iretn=json_out_character(jstring,'{')) < 0)
2091  return iretn;
2092 
2093  // Output X
2094  if ((iretn=json_out_name(jstring, "x")) < 0)
2095  return iretn;
2096  if ((iretn=json_out_double(jstring,value.x)) < 0)
2097  return iretn;
2098  if ((iretn=json_out_character(jstring,',')) < 0)
2099  return iretn;
2100 
2101  // Output Y
2102  if ((iretn=json_out_name(jstring, "y")) < 0)
2103  return iretn;
2104  if ((iretn=json_out_double(jstring,value.y)) < 0)
2105  return iretn;
2106  if ((iretn=json_out_character(jstring,',')) < 0)
2107  return iretn;
2108 
2109  // Output Z
2110  if ((iretn=json_out_name(jstring, "z")) < 0)
2111  return iretn;
2112  if ((iretn=json_out_double(jstring,value.z)) < 0)
2113  return iretn;
2114 
2115  if ((iretn=json_out_character(jstring,'}')) < 0)
2116  return iretn;
2117  return 0;
2118 }
double y
Y value.
Definition: vector.h:114
int iretn
Definition: rw_test.cpp:37
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
double x
X value.
Definition: vector.h:112
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
double z
Z value.
Definition: vector.h:116
int32_t json_out_cartpos ( string &  jstring,
cartpos  value 
)

cartpos to JSON

Appends a JSON entry to the current JSON stream for the indicated cartpos.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2127 {
2128  int32_t iretn;
2129 
2130  if ((iretn=json_out_character(jstring,'{')) < 0)
2131  return iretn;
2132 
2133  // Output Time
2134  if ((iretn=json_out_name(jstring, "utc")) < 0)
2135  return iretn;
2136  if ((iretn=json_out_double(jstring,value.utc)) < 0)
2137  return iretn;
2138  if ((iretn=json_out_character(jstring,',')) < 0)
2139  return iretn;
2140 
2141  // Output Position
2142  if ((iretn=json_out_name(jstring, "pos")) < 0)
2143  return iretn;
2144  if ((iretn=json_out_rvector(jstring,value.s)) < 0)
2145  return iretn;
2146  if ((iretn=json_out_character(jstring,',')) < 0)
2147  return iretn;
2148 
2149  // Output Velocity
2150  if ((iretn=json_out_name(jstring, "vel")) < 0)
2151  return iretn;
2152  if ((iretn=json_out_rvector(jstring,value.v)) < 0)
2153  return iretn;
2154  if ((iretn=json_out_character(jstring,',')) < 0)
2155  return iretn;
2156 
2157  // Output Acceleration
2158  if ((iretn=json_out_name(jstring, "acc")) < 0)
2159  return iretn;
2160  if ((iretn=json_out_rvector(jstring,value.a)) < 0)
2161  return iretn;
2162 
2163  if ((iretn=json_out_character(jstring,'}')) < 0)
2164  return iretn;
2165  return 0;
2166 }
rvector a
Acceleration.
Definition: convertdef.h:167
double utc
UTC of Position.
Definition: convertdef.h:161
int iretn
Definition: rw_test.cpp:37
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
int32_t json_out_rvector(string &jstring, rvector value)
rvector to JSON
Definition: jsonlib.cpp:2018
rvector s
Location.
Definition: convertdef.h:163
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
rvector v
Velocity.
Definition: convertdef.h:165
int32_t json_out_geoidpos ( string &  jstring,
geoidpos  value 
)

geoidpos to JSON

Appends a JSON entry to the current JSON stream for the indicated geoidpos.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2176 {
2177  int32_t iretn;
2178 
2179  if ((iretn=json_out_character(jstring,'{')) < 0)
2180  return iretn;
2181 
2182  // Output Time
2183  if ((iretn=json_out_name(jstring, "utc")) < 0)
2184  return iretn;
2185  if ((iretn=json_out_double(jstring,value.utc)) < 0)
2186  return iretn;
2187  if ((iretn=json_out_character(jstring,',')) < 0)
2188  return iretn;
2189 
2190  // Output Position
2191  if ((iretn=json_out_name(jstring, "pos")) < 0)
2192  return iretn;
2193  if ((iretn=json_out_gvector(jstring,value.s)) < 0)
2194  return iretn;
2195  if ((iretn=json_out_character(jstring,',')) < 0)
2196  return iretn;
2197 
2198  // Output Velocity
2199  if ((iretn=json_out_name(jstring, "vel")) < 0)
2200  return iretn;
2201  if ((iretn=json_out_gvector(jstring,value.v)) < 0)
2202  return iretn;
2203  if ((iretn=json_out_character(jstring,',')) < 0)
2204  return iretn;
2205 
2206  // Output Acceleration
2207  if ((iretn=json_out_name(jstring, "acc")) < 0)
2208  return iretn;
2209  if ((iretn=json_out_gvector(jstring,value.a)) < 0)
2210  return iretn;
2211 
2212  if ((iretn=json_out_character(jstring,'}')) < 0)
2213  return iretn;
2214  return 0;
2215 }
double utc
Definition: convertdef.h:261
int32_t json_out_gvector(string &jstring, gvector value)
gvector to JSON
Definition: jsonlib.cpp:1854
int iretn
Definition: rw_test.cpp:37
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
gvector a
Acceleration vector.
Definition: convertdef.h:267
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
gvector s
Position vector.
Definition: convertdef.h:263
gvector v
Velocity vector.
Definition: convertdef.h:265
int32_t json_out_spherpos ( string &  jstring,
spherpos  value 
)

spherpos to JSON

Appends a JSON entry to the current JSON stream for the indicated spherpos.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2225 {
2226  int32_t iretn;
2227 
2228  if ((iretn=json_out_character(jstring,'{')) < 0)
2229  return iretn;
2230 
2231  // Output Time
2232  if ((iretn=json_out_name(jstring, "utc")) < 0)
2233  return iretn;
2234  if ((iretn=json_out_double(jstring,value.utc)) < 0)
2235  return iretn;
2236  if ((iretn=json_out_character(jstring,',')) < 0)
2237  return iretn;
2238 
2239  // Output Position
2240  if ((iretn=json_out_name(jstring, "pos")) < 0)
2241  return iretn;
2242  if ((iretn=json_out_svector(jstring,value.s)) < 0)
2243  return iretn;
2244  if ((iretn=json_out_character(jstring,',')) < 0)
2245  return iretn;
2246 
2247  // Output Velocity
2248  if ((iretn=json_out_name(jstring, "vel")) < 0)
2249  return iretn;
2250  if ((iretn=json_out_svector(jstring,value.v)) < 0)
2251  return iretn;
2252  if ((iretn=json_out_character(jstring,',')) < 0)
2253  return iretn;
2254 
2255  // Output Acceleration
2256  if ((iretn=json_out_name(jstring, "acc")) < 0)
2257  return iretn;
2258  if ((iretn=json_out_svector(jstring,value.a)) < 0)
2259  return iretn;
2260 
2261  if ((iretn=json_out_character(jstring,'}')) < 0)
2262  return iretn;
2263  return 0;
2264 }
svector s
Position vector.
Definition: convertdef.h:318
int iretn
Definition: rw_test.cpp:37
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
int32_t json_out_svector(string &jstring, svector value)
svector to JSON
Definition: jsonlib.cpp:1894
svector v
Velocity vector.
Definition: convertdef.h:320
double utc
Definition: convertdef.h:316
svector a
Acceleration vector.
Definition: convertdef.h:322
int32_t json_out_node ( string &  jstring,
string  value 
)

Node name to JSON.

Appends a JSON entry to the current JSON stream for the indicated Node name.

Parameters
jstringJSON stream to append to
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2275 {
2276  int32_t iretn;
2277 
2278  if ((iretn=json_out_character(jstring, '{')) < 0)
2279  return iretn;
2280 
2281  if ((iretn=json_out_name(jstring, "node_name")) < 0)
2282  return iretn;
2283  if ((iretn=json_out_string(jstring, value, COSMOS_MAX_NAME)) < 0)
2284  return iretn;
2285 
2286  if ((iretn=json_out_character(jstring,'}')) < 0)
2287  return iretn;
2288  return 0;
2289 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
int32_t json_out_string(string &jstring, string ostring, uint16_t len)
String to JSON.
Definition: jsonlib.cpp:1764
int iretn
Definition: rw_test.cpp:37
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
int32_t json_out_utcstart ( string &  jstring,
double  value 
)

UTC Start to JSON.

Appends a JSON entry to the current JSON stream for the indicated UTC start.

Parameters
jstringJSON stream to append to
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2300 {
2301  int32_t iretn;
2302 
2303  if ((iretn=json_out_character(jstring,'{')) < 0)
2304  return iretn;
2305 
2306  if ((iretn=json_out_name(jstring, "node_utcstart")) < 0)
2307  return iretn;
2308  if ((iretn=json_out_double(jstring,value)) < 0)
2309  return iretn;
2310 
2311  if ((iretn=json_out_character(jstring,'}')) < 0)
2312  return iretn;
2313  return 0;
2314 }
int iretn
Definition: rw_test.cpp:37
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
int32_t json_out_ecipos ( string &  jstring,
cartpos  value 
)

ECI position to JSON.

Appends a JSON entry to the current JSON stream for the indicated ECI based position.

Parameters
jstringJSON stream to append to
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2325 {
2326  int32_t iretn;
2327 
2328  if ((iretn=json_out_character(jstring,'{')) < 0)
2329  return iretn;
2330 
2331  // Output Earth Centered Inertial
2332  if ((iretn=json_out_name(jstring, "node_loc_pos_eci")) < 0)
2333  return iretn;
2334  if ((iretn=json_out_cartpos(jstring,value)) < 0)
2335  return iretn;
2336 
2337  if ((iretn=json_out_character(jstring,'}')) < 0)
2338  return iretn;
2339  return 0;
2340 }
int iretn
Definition: rw_test.cpp:37
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
int32_t json_out_cartpos(string &jstring, cartpos value)
cartpos to JSON
Definition: jsonlib.cpp:2126
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
int32_t json_out_posstruc ( string &  jstring,
posstruc  value 
)

posstruc to JSON

Appends a JSON entry to the current JSON stream for the indicated posstruc.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2350 {
2351  int32_t iretn;
2352 
2353  if ((iretn=json_out_character(jstring,'{')) < 0)
2354  return iretn;
2355 
2356  // Output Time
2357  if ((iretn=json_out_name(jstring, "utc")) < 0)
2358  return iretn;
2359  if ((iretn=json_out_double(jstring,value.utc)) < 0)
2360  return iretn;
2361  if ((iretn=json_out_character(jstring,',')) < 0)
2362  return iretn;
2363 
2364  // Output Earth Magnetic Field
2365  if ((iretn=json_out_name(jstring, "bearth")) < 0)
2366  return iretn;
2367  if ((iretn=json_out_rvector(jstring,value.bearth)) < 0)
2368  return iretn;
2369 
2370  // Output Barycentric
2371  if ((iretn=json_out_name(jstring, "icrf")) < 0)
2372  return iretn;
2373  if ((iretn=json_out_cartpos(jstring,value.icrf)) < 0)
2374  return iretn;
2375  if ((iretn=json_out_character(jstring,',')) < 0)
2376  return iretn;
2377 
2378  // Output Earth Centered Inertial
2379  if ((iretn=json_out_name(jstring, "eci")) < 0)
2380  return iretn;
2381  if ((iretn=json_out_cartpos(jstring,value.eci)) < 0)
2382  return iretn;
2383  if ((iretn=json_out_character(jstring,',')) < 0)
2384  return iretn;
2385 
2386  // Output Selene Centered Inertial
2387  if ((iretn=json_out_name(jstring, "sci")) < 0)
2388  return iretn;
2389  if ((iretn=json_out_cartpos(jstring,value.sci)) < 0)
2390  return iretn;
2391  if ((iretn=json_out_character(jstring,',')) < 0)
2392  return iretn;
2393 
2394  // Output Geocentric
2395  if ((iretn=json_out_name(jstring, "geoc")) < 0)
2396  return iretn;
2397  if ((iretn=json_out_cartpos(jstring,value.geoc)) < 0)
2398  return iretn;
2399  if ((iretn=json_out_character(jstring,',')) < 0)
2400  return iretn;
2401 
2402  // Output Selenocentric
2403  if ((iretn=json_out_name(jstring, "selc")) < 0)
2404  return iretn;
2405  if ((iretn=json_out_cartpos(jstring,value.selc)) < 0)
2406  return iretn;
2407  if ((iretn=json_out_character(jstring,',')) < 0)
2408  return iretn;
2409 
2410  // Output Geodetic
2411  if ((iretn=json_out_name(jstring, "geod")) < 0)
2412  return iretn;
2413  if ((iretn=json_out_geoidpos(jstring,value.geod)) < 0)
2414  return iretn;
2415  if ((iretn=json_out_character(jstring,',')) < 0)
2416  return iretn;
2417 
2418  // Output Selenographic
2419  if ((iretn=json_out_name(jstring, "selg")) < 0)
2420  return iretn;
2421  if ((iretn=json_out_geoidpos(jstring,value.selg)) < 0)
2422  return iretn;
2423  if ((iretn=json_out_character(jstring,',')) < 0)
2424  return iretn;
2425 
2426  // Output Geocentric Spherical
2427  if ((iretn=json_out_name(jstring, "geos")) < 0)
2428  return iretn;
2429  if ((iretn=json_out_spherpos(jstring,value.geos)) < 0)
2430  return iretn;
2431  // if ((iretn=json_out_character(jstring,',')) < 0)
2432  // return iretn;
2433 
2434  if ((iretn=json_out_character(jstring,'}')) < 0)
2435  return iretn;
2436  return 0;
2437 }
rvector bearth
Earth magnetic vector in ITRS for this time and location.
Definition: convertdef.h:754
spherpos geos
Definition: convertdef.h:743
cartpos selc
Definition: convertdef.h:740
int32_t json_out_geoidpos(string &jstring, geoidpos value)
geoidpos to JSON
Definition: jsonlib.cpp:2175
int iretn
Definition: rw_test.cpp:37
cartpos geoc
Definition: convertdef.h:739
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
int32_t json_out_rvector(string &jstring, rvector value)
rvector to JSON
Definition: jsonlib.cpp:2018
int32_t json_out_spherpos(string &jstring, spherpos value)
spherpos to JSON
Definition: jsonlib.cpp:2224
geoidpos selg
Definition: convertdef.h:742
int32_t json_out_cartpos(string &jstring, cartpos value)
cartpos to JSON
Definition: jsonlib.cpp:2126
double utc
Definition: convertdef.h:735
cartpos sci
Definition: convertdef.h:738
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
cartpos eci
Definition: convertdef.h:737
geoidpos geod
Definition: convertdef.h:741
cartpos icrf
Definition: convertdef.h:736
int32_t json_out_attstruc ( string &  jstring,
attstruc  value 
)

attstruc to JSON

Appends a JSON entry to the current JSON stream for the indicated attstruc.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2447 {
2448  int32_t iretn;
2449 
2450  if ((iretn=json_out_character(jstring,'{')) < 0)
2451  return iretn;
2452 
2453  // Output Time
2454  if ((iretn=json_out_name(jstring, "utc")) < 0)
2455  return iretn;
2456  if ((iretn=json_out_double(jstring,value.utc)) < 0)
2457  return iretn;
2458  if ((iretn=json_out_character(jstring,',')) < 0)
2459  return iretn;
2460 
2461  // Output Topocentric
2462  if ((iretn=json_out_name(jstring, "topo")) < 0)
2463  return iretn;
2464  if ((iretn=json_out_qatt(jstring,value.topo)) < 0)
2465  return iretn;
2466  if ((iretn=json_out_character(jstring,',')) < 0)
2467  return iretn;
2468 
2469  // Output LVLH
2470  if ((iretn=json_out_name(jstring, "lvlh")) < 0)
2471  return iretn;
2472  if ((iretn=json_out_qatt(jstring,value.lvlh)) < 0)
2473  return iretn;
2474  if ((iretn=json_out_character(jstring,',')) < 0)
2475  return iretn;
2476 
2477  // Output Geocentric
2478  if ((iretn=json_out_name(jstring, "geoc")) < 0)
2479  return iretn;
2480  if ((iretn=json_out_qatt(jstring,value.geoc)) < 0)
2481  return iretn;
2482  if ((iretn=json_out_character(jstring,',')) < 0)
2483  return iretn;
2484 
2485  // Output Selenocentric
2486  if ((iretn=json_out_name(jstring, "selc")) < 0)
2487  return iretn;
2488  if ((iretn=json_out_qatt(jstring,value.selc)) < 0)
2489  return iretn;
2490  if ((iretn=json_out_character(jstring,',')) < 0)
2491  return iretn;
2492 
2493  // Output ICRF
2494  if ((iretn=json_out_name(jstring, "icrf")) < 0)
2495  return iretn;
2496  if ((iretn=json_out_qatt(jstring,value.icrf)) < 0)
2497  return iretn;
2498 
2499  if ((iretn=json_out_character(jstring,'}')) < 0)
2500  return iretn;
2501  return 0;
2502 }
qatt geoc
Definition: convertdef.h:828
int iretn
Definition: rw_test.cpp:37
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
qatt lvlh
Definition: convertdef.h:827
qatt selc
Definition: convertdef.h:829
qatt icrf
Definition: convertdef.h:830
int32_t json_out_qatt(string &jstring, qatt value)
qatt to JSON
Definition: jsonlib.cpp:2677
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
qatt topo
Definition: convertdef.h:826
double utc
Definition: convertdef.h:825
int32_t json_out_locstruc ( string &  jstring,
locstruc  value 
)

locstruc to JSON

Appends a JSON entry to the current JSON stream for the indicated locstruc.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2512 {
2513  int32_t iretn;
2514 
2515  if ((iretn=json_out_character(jstring,'{')) < 0)
2516  return iretn;
2517 
2518  // Output Time
2519  if ((iretn=json_out_name(jstring, "utc")) < 0)
2520  return iretn;
2521  if ((iretn=json_out_double(jstring,value.utc)) < 0)
2522  return iretn;
2523  if ((iretn=json_out_character(jstring,',')) < 0)
2524  return iretn;
2525 
2526  // Output Position
2527  if ((iretn=json_out_name(jstring, "pos")) < 0)
2528  return iretn;
2529  if ((iretn=json_out_posstruc(jstring,value.pos)) < 0)
2530  return iretn;
2531  if ((iretn=json_out_character(jstring,',')) < 0)
2532  return iretn;
2533 
2534  // Output Attitude
2535  if ((iretn=json_out_name(jstring, "att")) < 0)
2536  return iretn;
2537  if ((iretn=json_out_attstruc(jstring,value.att)) < 0)
2538  return iretn;
2539  if ((iretn=json_out_character(jstring,',')) < 0)
2540  return iretn;
2541 
2542  if ((iretn=json_out_character(jstring,'}')) < 0)
2543  return iretn;
2544  return 0;
2545 }
int32_t json_out_attstruc(string &jstring, attstruc value)
attstruc to JSON
Definition: jsonlib.cpp:2446
int iretn
Definition: rw_test.cpp:37
double utc
Master time for location, in Modified Julian Day.
Definition: convertdef.h:879
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
attstruc att
attstruc for this time.
Definition: convertdef.h:883
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
posstruc pos
posstruc for this time.
Definition: convertdef.h:881
int32_t json_out_posstruc(string &jstring, posstruc value)
posstruc to JSON
Definition: jsonlib.cpp:2349
int32_t json_out_commandevent ( string &  jstring,
eventstruc  value 
)

Command event to JSON.

Appends a JSON entry to the current JSON stream for the indicated eventstruc specific to a command event.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2555 {
2556  int32_t iretn;
2557 
2558  //CT-JSON: keep as a separate object? or have it combine?
2559  if ((iretn=json_out_character(jstring, '{')) < 0)
2560  return iretn;
2561  if ((iretn=json_out_name(jstring, (char *)"event_utc")) < 0)
2562  return iretn;
2563  if ((iretn=json_out_double(jstring, value.utc)) < 0)
2564  return iretn;
2565  if ((iretn=json_out_character(jstring, '}')) < 0)
2566  return iretn;
2567 
2568  if (value.utcexec != 0.)
2569  {
2570  if ((iretn=json_out_character(jstring, '{')) < 0)
2571  return iretn;
2572  if ((iretn=json_out_name(jstring, (char *)"event_utcexec")) < 0)
2573  return iretn;
2574  if ((iretn=json_out_double(jstring, value.utcexec)) < 0)
2575  return iretn;
2576  if ((iretn=json_out_character(jstring, '}')) < 0)
2577  return iretn;
2578  }
2579 
2580  if ((iretn=json_out_character(jstring, '{')) < 0)
2581  return iretn;
2582  if ((iretn=json_out_name(jstring, (char *)"event_name")) < 0)
2583  return iretn;
2584  if ((iretn=json_out_string(jstring, value.name, COSMOS_MAX_NAME)) < 0)
2585  return iretn;
2586  if ((iretn=json_out_character(jstring, '}')) < 0)
2587  return iretn;
2588 
2589  if ((iretn=json_out_character(jstring, '{')) < 0)
2590  return iretn;
2591  if ((iretn=json_out_name(jstring, (char *)"event_type")) < 0)
2592  return iretn;
2593  if ((iretn=json_out_uint32(jstring, value.type)) < 0)
2594  return iretn;
2595  if ((iretn=json_out_character(jstring, '}')) < 0)
2596  return iretn;
2597 
2598  if ((iretn=json_out_character(jstring, '{')) < 0)
2599  return iretn;
2600  if ((iretn=json_out_name(jstring, (char *)"event_flag")) < 0)
2601  return iretn;
2602  if ((iretn=json_out_uint32(jstring, value.flag)) < 0)
2603  return iretn;
2604  if ((iretn=json_out_character(jstring, '}')) < 0)
2605  return iretn;
2606 
2607  if ((iretn=json_out_character(jstring, '{')) < 0)
2608  return iretn;
2609  if ((iretn=json_out_name(jstring, (char *)"event_data")) < 0)
2610  return iretn;
2611  if ((iretn=json_out_string(jstring, value.data, COSMOS_MAX_DATA)) < 0)
2612  return iretn;
2613  if ((iretn=json_out_character(jstring, '}')) < 0)
2614  return iretn;
2615 
2616  if (value.flag & EVENT_FLAG_CONDITIONAL)
2617  {
2618  if ((iretn=json_out_character(jstring, '{')) < 0)
2619  return iretn;
2620  if ((iretn=json_out_name(jstring, (char *)"event_condition")) < 0)
2621  return iretn;
2622  if ((iretn=json_out_string(jstring, value.condition, COSMOS_MAX_DATA)) < 0)
2623  return iretn;
2624  if ((iretn=json_out_character(jstring, '}')) < 0)
2625  return iretn;
2626  }
2627 
2628  return 0;
2629 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
int32_t json_out_string(string &jstring, string ostring, uint16_t len)
String to JSON.
Definition: jsonlib.cpp:1764
int32_t json_out_uint32(string &jstring, uint32_t value)
Unsigned 32 bit integer to JSON.
Definition: jsonlib.cpp:1703
int iretn
Definition: rw_test.cpp:37
double utcexec
Time event was executed.
Definition: jsondef.h:1098
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
char condition[(COSMOS_MAX_DATA)]
Condition that caused event, NULL if timed event.
Definition: jsondef.h:1133
double utc
Time event is to start.
Definition: jsondef.h:1096
#define COSMOS_MAX_DATA
Definition: cosmos-defs.h:53
char data[(COSMOS_MAX_DATA)]
Event specific data.
Definition: jsondef.h:1131
uint32_t type
Event type.
Definition: jsondef.h:1109
uint32_t flag
Event flags.
Definition: jsondef.h:1107
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
#define EVENT_FLAG_CONDITIONAL
Conditional event.
Definition: cosmos-defs.h:169
char name[40+1]
Name of event.
Definition: jsondef.h:1103
int32_t json_out_dcmatt ( string &  jstring,
dcmatt  value 
)

Appends a JSON entry to the current JSON stream for the indicated dcmatt.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2637 {
2638  int32_t iretn;
2639 
2640  if ((iretn=json_out_character(jstring,'{')) < 0)
2641  return iretn;
2642 
2643  // Output Position
2644  if ((iretn=json_out_name(jstring, "pos")) < 0)
2645  return iretn;
2646  if ((iretn=json_out_dcm(jstring,value.s)) < 0)
2647  return iretn;
2648  if ((iretn=json_out_character(jstring,',')) < 0)
2649  return iretn;
2650 
2651  // Output Velocity
2652  if ((iretn=json_out_name(jstring, "vel")) < 0)
2653  return iretn;
2654  if ((iretn=json_out_rvector(jstring,value.v)) < 0)
2655  return iretn;
2656  if ((iretn=json_out_character(jstring,',')) < 0)
2657  return iretn;
2658 
2659  // Output Acceleration
2660  if ((iretn=json_out_name(jstring, "acc")) < 0)
2661  return iretn;
2662  if ((iretn=json_out_rvector(jstring,value.a)) < 0)
2663  return iretn;
2664 
2665  if ((iretn=json_out_character(jstring,'}')) < 0)
2666  return iretn;
2667  return 0;
2668 }
rvector a
2nd derivative
Definition: convertdef.h:431
int iretn
Definition: rw_test.cpp:37
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
int32_t json_out_rvector(string &jstring, rvector value)
rvector to JSON
Definition: jsonlib.cpp:2018
rvector v
1st derivative
Definition: convertdef.h:429
int32_t json_out_dcm(string &jstring, rmatrix value)
rmatrix to JSON
Definition: jsonlib.cpp:2725
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
rmatrix s
0th derivative
Definition: convertdef.h:427
int32_t json_out_qatt ( string &  jstring,
qatt  value 
)

qatt to JSON

Appends a JSON entry to the current JSON stream for the indicated qatt.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2678 {
2679  int32_t iretn;
2680 
2681  if ((iretn=json_out_character(jstring,'{')) < 0)
2682  return iretn;
2683 
2684  // Output Time
2685  if ((iretn=json_out_name(jstring, "utc")) < 0)
2686  return iretn;
2687  if ((iretn=json_out_double(jstring,value.utc)) < 0)
2688  return iretn;
2689  if ((iretn=json_out_character(jstring,',')) < 0)
2690  return iretn;
2691 
2692  // Output Position
2693  if ((iretn=json_out_name(jstring, "pos")) < 0)
2694  return iretn;
2695  if ((iretn=json_out_quaternion(jstring,value.s)) < 0)
2696  return iretn;
2697  if ((iretn=json_out_character(jstring,',')) < 0)
2698  return iretn;
2699 
2700  // Output Velocity
2701  if ((iretn=json_out_name(jstring, "vel")) < 0)
2702  return iretn;
2703  if ((iretn=json_out_rvector(jstring,value.v)) < 0)
2704  return iretn;
2705  if ((iretn=json_out_character(jstring,',')) < 0)
2706  return iretn;
2707 
2708  // Output Acceleration
2709  if ((iretn=json_out_name(jstring, "acc")) < 0)
2710  return iretn;
2711  if ((iretn=json_out_rvector(jstring,value.a)) < 0)
2712  return iretn;
2713 
2714  if ((iretn=json_out_character(jstring,'}')) < 0)
2715  return iretn;
2716  return 0;
2717 }
rvector a
2nd derivative: Alpha - acceleration
Definition: convertdef.h:483
int32_t json_out_quaternion(string &jstring, quaternion value)
quaternion to JSON
Definition: jsonlib.cpp:2054
int iretn
Definition: rw_test.cpp:37
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
int32_t json_out_rvector(string &jstring, rvector value)
rvector to JSON
Definition: jsonlib.cpp:2018
rvector v
1st derivative: Omega - angular velocity
Definition: convertdef.h:481
double utc
Definition: convertdef.h:477
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
quaternion s
0th derivative: Quaternion
Definition: convertdef.h:479
int32_t json_out_dcm ( string &  jstring,
rmatrix  value 
)

rmatrix to JSON

Appends a JSON entry to the current JSON stream for the indicated rmatrix.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2726 {
2727  int32_t iretn;
2728 
2729  if ((iretn=json_out_character(jstring,'[')) < 0)
2730  return iretn;
2731 
2732  // Output Row[0]
2733  if ((iretn=json_out_rvector(jstring,value.row[0])) < 0)
2734  return iretn;
2735  if ((iretn=json_out_character(jstring,',')) < 0)
2736  return iretn;
2737 
2738  // Output Row[1]
2739  if ((iretn=json_out_rvector(jstring,value.row[1])) < 0)
2740  return iretn;
2741  if ((iretn=json_out_character(jstring,',')) < 0)
2742  return iretn;
2743 
2744  // Output Row[2]
2745  if ((iretn=json_out_rvector(jstring,value.row[2])) < 0)
2746  return iretn;
2747 
2748  if ((iretn=json_out_character(jstring,']')) < 0)
2749  return iretn;
2750  return 0;
2751 }
int iretn
Definition: rw_test.cpp:37
int32_t json_out_rvector(string &jstring, rvector value)
rvector to JSON
Definition: jsonlib.cpp:2018
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
rvector row[3]
Definition: matrix.h:43
int32_t json_out_rmatrix ( string &  jstring,
rmatrix  value 
)

rmatrix to JSON

Appends a JSON entry to the current JSON stream for the indicated rmatrix.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2761 {
2762  int32_t iretn;
2763 
2764  if ((iretn=json_out_character(jstring,'[')) < 0)
2765  return iretn;
2766 
2767  // Output Row[0]
2768  if ((iretn=json_out_rvector(jstring,value.row[0])) < 0)
2769  return iretn;
2770  if ((iretn=json_out_character(jstring,',')) < 0)
2771  return iretn;
2772 
2773  // Output Row[1]
2774  if ((iretn=json_out_rvector(jstring,value.row[1])) < 0)
2775  return iretn;
2776  if ((iretn=json_out_character(jstring,',')) < 0)
2777  return iretn;
2778 
2779  // Output Row[2]
2780  if ((iretn=json_out_rvector(jstring,value.row[2])) < 0)
2781  return iretn;
2782  if ((iretn=json_out_character(jstring,',')) < 0)
2783  return iretn;
2784 
2785  if ((iretn=json_out_character(jstring,']')) < 0)
2786  return iretn;
2787  return 0;
2788 }
int iretn
Definition: rw_test.cpp:37
int32_t json_out_rvector(string &jstring, rvector value)
rvector to JSON
Definition: jsonlib.cpp:2018
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
rvector row[3]
Definition: matrix.h:43
int32_t json_out_beatstruc ( string &  jstring,
beatstruc  value 
)

beatstruc to JSON

Appends a JSON entry to the current JSON stream for the indicated beatstruc.

Parameters
jstringReference to JSON stream.
valueThe JSON data of the desired variable
Returns
0 if successful, negative error otherwise
2797 {
2798  int32_t iretn;
2799 
2800  if ((iretn=json_out_character(jstring,'{')) < 0)
2801  return iretn;
2802 
2803  // Output Ntype
2804  if ((iretn=json_out_name(jstring, "ntype")) < 0)
2805  return iretn;
2806  if ((iretn=json_out_uint16(jstring,(uint16_t)value.ntype)) < 0)
2807  return iretn;
2808  if ((iretn=json_out_character(jstring,',')) < 0)
2809  return iretn;
2810 
2811  // Output IP Address
2812  if ((iretn=json_out_name(jstring, "addr")) < 0)
2813  return iretn;
2814  if ((iretn=json_out_string(jstring,value.addr,16)) < 0)
2815  return iretn;
2816  if ((iretn=json_out_character(jstring,',')) < 0)
2817  return iretn;
2818 
2819  // Output IP Port
2820  if ((iretn=json_out_name(jstring, "port")) < 0)
2821  return iretn;
2822  if ((iretn=json_out_int32(jstring,value.port)) < 0)
2823  return iretn;
2824  if ((iretn=json_out_character(jstring,',')) < 0)
2825  return iretn;
2826 
2827  // Output Buffer Size
2828  if ((iretn=json_out_name(jstring, "bsz")) < 0)
2829  return iretn;
2830  if ((iretn=json_out_int32(jstring,value.bsz)) < 0)
2831  return iretn;
2832  if ((iretn=json_out_character(jstring,',')) < 0)
2833  return iretn;
2834 
2835  // Output Beat Period
2836  if ((iretn=json_out_name(jstring, "bprd")) < 0)
2837  return iretn;
2838  if ((iretn=json_out_double(jstring,value.bprd)) < 0)
2839  return iretn;
2840 
2841  if ((iretn=json_out_character(jstring,'}')) < 0)
2842  return iretn;
2843  return 0;
2844 }
NetworkType ntype
Definition: jsondef.h:932
int32_t json_out_int32(string &jstring, int32_t value)
Signed 32 bit integer to JSON.
Definition: jsonlib.cpp:1652
int32_t json_out_string(string &jstring, string ostring, uint16_t len)
String to JSON.
Definition: jsonlib.cpp:1764
uint32_t bsz
Transfer buffer size.
Definition: jsondef.h:938
char addr[18]
Protocol Address.
Definition: jsondef.h:934
int iretn
Definition: rw_test.cpp:37
int32_t json_out_uint16(string &jstring, uint16_t value)
Unsigned 16 bit integer to JSON.
Definition: jsonlib.cpp:1686
int32_t json_out_double(string &jstring, double value)
Perform JSON output for a single nonindexed double.
Definition: jsonlib.cpp:1741
int32_t json_out_name(string &jstring, string name)
Object name to JSON.
Definition: jsonlib.cpp:1577
uint16_t port
AGENT port.
Definition: jsondef.h:936
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
double bprd
Heartbeat period in seconds.
Definition: jsondef.h:940
int32_t json_out_1d ( string &  jstring,
const char *  token,
uint16_t  index,
cosmosstruc cinfo 
)

Perform JSON output for a single element of a 1D named JSON item.

Calls json_out for the indexed element of the named JSON vector.

Parameters
jstringReference to JSON stream.
tokenThe JSON name for the desired variable
indexThe desired element number
cinfoReference to cosmosstruc to use.
Returns
0 if successful, negative error otherwise
2856 {
2857  char name[COSMOS_MAX_NAME+1];
2858  int32_t iretn;
2859 
2860  if (strlen(token) > COSMOS_MAX_NAME+4)
2861  return (JSON_ERROR_NAME_LENGTH);
2862 
2863  if (index > 999)
2864  return (JSON_ERROR_INDEX_SIZE);
2865 
2866  sprintf(name,"%s_%03u",token,index);
2867  iretn = json_out(jstring, name, cinfo);
2868  return iretn;
2869 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
int iretn
Definition: rw_test.cpp:37
#define JSON_ERROR_INDEX_SIZE
Definition: cosmos-errno.h:92
string name
Definition: cubesat2obj.cpp:6
#define JSON_ERROR_NAME_LENGTH
Definition: cosmos-errno.h:90
int32_t json_out_2d ( string &  jstring,
const char *  token,
uint16_t  row,
uint16_t  col,
cosmosstruc cinfo 
)

Perform JSON output for a single element of a 2D named JSON item.

Calls json_out for the indexed element of the named JSON matrix.

Parameters
jstringReference to JSON stream.
tokenThe JSON name for the desired variable
rowThe desired row number
colThe desired column number
cinfoReference to cosmosstruc to use.
Returns
0 if successful, negative error otherwise
2882 {
2883  char name[COSMOS_MAX_NAME+1];
2884  int32_t iretn;
2885 
2886  if (strlen(token) > COSMOS_MAX_NAME+8)
2887  return (JSON_ERROR_NAME_LENGTH);
2888 
2889  if (row > 999 || col > 999)
2890  return (JSON_ERROR_INDEX_SIZE);
2891 
2892  sprintf(name,"%s_%03u_%03u",token,row,col);
2893  iretn = json_out(jstring, name, cinfo);
2894  return iretn;
2895 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
int iretn
Definition: rw_test.cpp:37
#define JSON_ERROR_INDEX_SIZE
Definition: cosmos-errno.h:92
string name
Definition: cubesat2obj.cpp:6
#define JSON_ERROR_NAME_LENGTH
Definition: cosmos-errno.h:90
int32_t json_out ( string &  jstring,
string  token,
cosmosstruc cinfo 
)

Perform JSON output for a single named JSON item.

Populates the jstring for the indicated ::jsonmap through reference to JSON name.

Parameters
jstringThe jstring into which to store the result.
tokenThe JSON name for the desired variable.
cinfoReference to cosmosstruc to use.
Returns
0 if successful, negative error otherwise
2906 {
2907  jsonhandle h;
2908 
2909  if (!cinfo->jmapped)
2910  return (JSON_ERROR_NOJMAP);
2911 
2912  h.hash = json_hash(token);
2913 
2914  if (cinfo->jmap.size() == 0)
2915  return (JSON_ERROR_NOJMAP);
2916 
2917  for (h.index=0; h.index < cinfo->jmap[h.hash].size(); ++h.index)
2918  // if (!strcmp(token.c_str(), cinfo->jmap[h.hash][h.index].name))
2919  if (token == cinfo->jmap[h.hash][h.index].name)
2920  {
2921  return (json_out_handle(jstring, h, cinfo));
2922  }
2923 
2924  return (JSON_ERROR_NOENTRY);
2925 }
Definition: eci2kep_test.cpp:33
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
#define JSON_ERROR_NOJMAP
Definition: cosmos-errno.h:93
#define JSON_ERROR_NOENTRY
Definition: cosmos-errno.h:94
uint16_t hash
Definition: jsondef.h:794
JSON handle.
Definition: jsondef.h:791
int32_t json_out_handle(string &jstring, jsonhandle handle, cosmosstruc *cinfo)
Perform JSON output for a JSON item by handle.
Definition: jsonlib.cpp:1313
uint16_t index
Definition: jsondef.h:796
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
uint16_t json_hash(string hstring)
Calculate JSON HASH.
Definition: jsonlib.cpp:504
int32_t json_out_list ( string &  jstring,
string  tokens,
cosmosstruc cinfo 
)

Output a list of named JSON items.

Populates the jstring for the indicated ::jsonmap through reference to a list of JSON names.

Parameters
jstringThe jstring into which to store the result.
tokensThe comma separated list of JSON names for the desired variables.
cinfoReference to cosmosstruc to use.
Returns
0 if successful, negative error otherwise
2937 {
2938  string tstring;
2939  const char* ptr;
2940  int32_t iretn;
2941 
2942  ptr = &tokens[0];
2943  while (ptr[0] != 0 && ptr[0] != '{')
2944  {
2945  ptr++;
2946  }
2947  if ((iretn=json_skip_character(ptr,'{')) != 0)
2948  {
2949  return iretn;
2950  }
2951  do
2952  {
2953  if ((iretn=json_extract_string(ptr, tstring)) != 0)
2954  return iretn;
2955  if ((iretn = json_skip_white(ptr)) < 0)
2956  return iretn;
2957  json_out(jstring, tstring.c_str(), cinfo);
2958  } while (!json_skip_character(ptr,','));
2959  if ((iretn = json_skip_white(ptr)) < 0)
2960  return iretn;
2961  if ((iretn=json_skip_character(ptr,'}')) != 0 && iretn!=JSON_ERROR_EOS)
2962  return iretn;
2963  if ((iretn = json_skip_white(ptr)) < 0 && iretn!=JSON_ERROR_EOS)
2964  return iretn;
2965  return 0;
2966 }
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
int iretn
Definition: rw_test.cpp:37
int32_t json_skip_white(const char *&ptr)
Skip white space in JSON string.
Definition: jsonlib.cpp:5336
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
int32_t json_extract_string(const char *&ptr, string &ostring)
Parse the next JSON string out of a JSON stream.
Definition: jsonlib.cpp:5186
int32_t json_skip_character(const char *&ptr, const char character)
Skip over a specific character in a JSON stream.
Definition: jsonlib.cpp:4972
int32_t json_out_wildcard ( string &  jstring,
string  wildcard,
cosmosstruc cinfo 
)

Output JSON items from wildcard.

Populates the jstring for the indicated ::jsonmap through reference to a regular expression matching of JSON names.

Parameters
jstringThe jstring into which to store the result.
wildcardThe regular expression to match against.
cinfoReference to cosmosstruc to use.
Returns
0 if successful, negative error otherwise
2980 {
2981  int32_t iretn=0;
2982  jsonhandle h;
2983 
2984  for (h.hash=0; h.hash<cinfo->jmap.size(); ++h.hash)
2985  {
2986  for (h.index=0; h.index<cinfo->jmap[h.hash].size(); ++h.index)
2987  {
2988  if (string_cmp(wildcard.c_str(), cinfo->jmap[h.hash][h.index].name.c_str()))
2989  {
2990  iretn = json_out_handle(jstring, h, cinfo);
2991  }
2992  }
2993  }
2994  return iretn;
2995 }
Definition: eci2kep_test.cpp:33
int iretn
Definition: rw_test.cpp:37
uint16_t hash
Definition: jsondef.h:794
JSON handle.
Definition: jsondef.h:791
int32_t json_out_handle(string &jstring, jsonhandle handle, cosmosstruc *cinfo)
Perform JSON output for a JSON item by handle.
Definition: jsonlib.cpp:1313
uint16_t index
Definition: jsondef.h:796
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
int string_cmp(const char *wild, const char *string)
Definition: stringlib.cpp:110
uint8_t * json_ptr_of_entry ( const jsonentry entry,
cosmosstruc cinfo 
)

Address from entry.

Calculate the actual address of a value from its entry in the ::jmap.

Parameters
entryA jsonentry
cinfoReference to cosmosstruc to use.
Returns
A pointer, castable into any desired type.
3005 {
3006  uint8_t *data=nullptr;
3007 
3008  if (entry.group == JSON_STRUCT_PTR)
3009  {
3010  data = entry.ptr;
3011  }
3012  else
3013  {
3014  data = json_ptr_of_offset(entry.offset, entry.group, cinfo);
3015  }
3016 
3017  return data;
3018 }
uint8_t * ptr
pointer to data storage
Definition: jsondef.h:4177
Definition: jsondef.h:173
uint16_t group
JSON Data Group.
Definition: jsondef.h:4171
uint8_t * json_ptr_of_offset(ptrdiff_t offset, uint16_t group, cosmosstruc *cinfo)
Address from offset.
Definition: jsonlib.cpp:3029
ptrdiff_t offset
offset to data storage
Definition: jsondef.h:4175
uint8_t * json_ptr_of_offset ( ptrdiff_t  offset,
uint16_t  group,
cosmosstruc cinfo 
)

Address from offset.

Calculate the actual address of an offset into either static or dynamic space, using the provide cdata static and dynamic addresses.

Parameters
offsetAn offset taken from a jsonentry
groupThe structure group from which the offset is measured.
cinfoReference to cosmosstruc to use.
Returns
A pointer, castable into any desired type.
3030 {
3031  uint8_t *data=nullptr;
3032 
3033  switch (group)
3034  {
3035  case JSON_STRUCT_ABSOLUTE:
3036  data = offset + (uint8_t *)cinfo;
3037  break;
3038  case JSON_STRUCT_AGENT:
3039  data = offset + (uint8_t *)cinfo->agent.data();
3040  break;
3041  case JSON_STRUCT_PHYSICS:
3042  data = offset + (uint8_t *)&(cinfo->node.phys);
3043  break;
3044  case JSON_STRUCT_EVENT:
3045  data = offset + (uint8_t *)cinfo->event.data();
3046  break;
3047  case JSON_STRUCT_NODE:
3048  data = offset + (uint8_t *)&(cinfo->node);
3049  break;
3050  case JSON_STRUCT_DEVICE:
3051  data = offset + (uint8_t *)cinfo->device.data();
3052  break;
3053  case JSON_STRUCT_DEVSPEC:
3054  data = offset + (uint8_t *)&(cinfo->devspec);
3055  break;
3056  case JSON_STRUCT_PIECE:
3057  data = offset + (uint8_t *)cinfo->pieces.data();
3058  break;
3059  case JSON_STRUCT_TARGET:
3060  data = offset + (uint8_t *)cinfo->target.data();
3061  break;
3062  case JSON_STRUCT_USER:
3063  data = offset + (uint8_t *)cinfo->user.data();
3064  break;
3065  case JSON_STRUCT_PORT:
3066  data = offset + (uint8_t *)cinfo->port.data();
3067  break;
3068  case JSON_STRUCT_TLE:
3069  data = offset + (uint8_t *)cinfo->tle.data();
3070  break;
3071  case JSON_STRUCT_EQUATION:
3072  data = (uint8_t *)&cinfo->equation[offset];
3073  break;
3074  }
3075  return (data);
3076 }
vector< portstruc > port
Vector of all ports known to node.
Definition: jsondef.h:4244
vector< tlestruc > tle
Array of Two Line Elements.
Definition: jsondef.h:4259
piecestruc
Definition: jsondef.h:158
devspecstruc
Definition: jsondef.h:152
userstruc
Definition: jsondef.h:162
devicestruc
Definition: jsondef.h:150
vector< devicestruc > device
Vector of all general (common) information for devices (components) in node.
Definition: jsondef.h:4238
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
tlestruc
Definition: jsondef.h:166
vector< equationstruc > equation
Vector of Equations.
Definition: jsondef.h:4217
eventstruc
Definition: jsondef.h:156
equationstruc
Definition: jsondef.h:168
portstruc
Definition: jsondef.h:164
vector< userstruc > user
Single entry vector for user information.
Definition: jsondef.h:4256
nodestruc
Definition: jsondef.h:146
agentstruc
Definition: jsondef.h:148
struct ip_mreq group
Definition: mcastclient.c:39
vector< agentstruc > agent
Single entry vector for agent information.
Definition: jsondef.h:4247
targetstruc
Definition: jsondef.h:160
vector< piecestruc > pieces
Vector of all pieces in node.
Definition: jsondef.h:4232
vector< eventstruc > event
Single entry vector for event information.
Definition: jsondef.h:4250
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
vector< targetstruc > target
Vector of all targets known to node.
Definition: jsondef.h:4253
Absolute pointer.
Definition: jsondef.h:144
physicsstruc
Definition: jsondef.h:154
physicsstruc phys
Definition: jsondef.h:3597
int32_t json_table_of_list ( vector< jsonentry * > &  table,
string  tokens,
cosmosstruc cinfo 
)

Output a vector of JSON entries.

Populates the provided vector for the indicated ::jsonmap through reference to a list of JSON names.

Parameters
tableThe vector of jsonentry into which to store the result.
tokensThe comma separated list of JSON names for the desired variables.
Returns
0 if successful, negative error otherwise
3087 {
3088  string tstring;
3089  const char *ptr;
3090  int32_t iretn;
3091  jsonentry* tentry;
3092 
3093  ptr = &tokens[0];
3094  while (ptr[0] != 0 && ptr[0] != '{') //move forward until '{'
3095  ptr++;
3096  if ((iretn=json_skip_character(ptr,'{')) != 0) //skip over '{'
3097  return iretn;
3098  do
3099  {
3100  if ((iretn=json_extract_string(ptr, tstring)) != 0)
3101  return iretn;
3102  if ((iretn = json_skip_white(ptr)) < 0)
3103  return iretn;
3104  tentry = json_entry_of(tstring, cinfo);
3105  table.push_back(tentry);
3106  } while (!json_skip_character(ptr,','));
3107  if ((iretn = json_skip_white(ptr)) < 0)
3108  return iretn;
3109  if ((iretn=json_skip_character(ptr,'}')) != 0 && iretn!=JSON_ERROR_EOS)
3110  return iretn;
3111  if ((iretn = json_skip_white(ptr)) < 0 && iretn!=JSON_ERROR_EOS)
3112  return iretn;
3113  return 0;
3114 }
int iretn
Definition: rw_test.cpp:37
jsonentry * json_entry_of(uint8_t *ptr, cosmosstruc *cinfo)
Info on Namespace address.
Definition: jsonlib.cpp:3124
int32_t json_skip_white(const char *&ptr)
Skip white space in JSON string.
Definition: jsonlib.cpp:5336
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
JSON map offset entry.
Definition: jsondef.h:4164
int32_t json_extract_string(const char *&ptr, string &ostring)
Parse the next JSON string out of a JSON stream.
Definition: jsonlib.cpp:5186
int32_t json_skip_character(const char *&ptr, const char character)
Skip over a specific character in a JSON stream.
Definition: jsonlib.cpp:4972
jsonentry * json_entry_of ( uint8_t *  ptr,
cosmosstruc cinfo 
)

Info on Namespace address.

Return a pointer to the Namespace Entry structure containing the information for a the namespace value that matches a given memory address.

Parameters
ptrAddress of a variable that may match a namespace name.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the jsonentry for the token, or nullptr.
3125 {
3126  uint16_t m;
3127  uint16_t group = UINT16_MAX;
3128  ptrdiff_t offset;
3129 
3130  if (!cinfo->jmapped)
3131  return nullptr;
3132 
3133  offset = -1;
3134 
3135  if ((offset = (uint8_t *)ptr - (uint8_t *)&(cinfo->node)) > 0 && offset < (ptrdiff_t)sizeof(nodestruc))
3136  {
3137  group = JSON_STRUCT_NODE;
3138  }
3139  else
3140  {
3141  offset = -1;
3142  //#undef max;
3143  offset = (numeric_limits<ptrdiff_t>::max)();
3144 
3145  }
3146  if (offset < 0 && (offset=(uint8_t *)ptr - (uint8_t *)&(cinfo->node)) > 0 && offset < (ptrdiff_t)sizeof(agentstruc))
3147  {
3148  group = JSON_STRUCT_AGENT;
3149  }
3150  else
3151  {
3152  offset = -1;
3153  }
3154  if (offset < 0 && (offset=(uint8_t *)ptr - (uint8_t *)&(cinfo->node)) > 0 && offset < (ptrdiff_t)sizeof(physicsstruc))
3155  {
3156  group = JSON_STRUCT_PHYSICS;
3157  }
3158  else
3159  {
3160  offset = -1;
3161  }
3162  if (offset < 0 && (offset=(uint8_t *)ptr - (uint8_t *)&(cinfo->node)) > 0 && offset < (ptrdiff_t)sizeof(eventstruc))
3163  {
3164  group = JSON_STRUCT_EVENT;
3165  }
3166  else
3167  {
3168  offset = -1;
3169  }
3170 
3171  if (offset == -1)
3172  return ((jsonentry *)nullptr);
3173 
3174  for (m=0; m<cinfo->jmap.size(); m++)
3175  {
3176  for (size_t n=0; n<cinfo->jmap[m].size(); n++)
3177  {
3178  if (cinfo->jmap[m][n].group == group && cinfo->jmap[m][n].offset == offset)
3179  {
3180  return ((jsonentry *)&cinfo->jmap[m][n]);
3181  }
3182  }
3183  }
3184  return ((jsonentry *)nullptr);
3185 }
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
Physics Simulation Structure.
Definition: jsondef.h:3411
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
eventstruc
Definition: jsondef.h:156
JSON map offset entry.
Definition: jsondef.h:4164
Full COSMOS Event structure.
Definition: jsondef.h:1093
nodestruc
Definition: jsondef.h:146
agentstruc
Definition: jsondef.h:148
Agent control structure.
Definition: jsondef.h:1006
struct ip_mreq group
Definition: mcastclient.c:39
Definition: jsondef.h:3553
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
physicsstruc
Definition: jsondef.h:154
jsonentry * json_entry_of ( string  token,
cosmosstruc cinfo 
)

Info on Namespace name.

Return a pointer to the Namespace Entry structure containing the information for a given name.

Parameters
tokenNamespace name to look up
Returns
Pointer to the jsonentry for the token, or nullptr.
3195 {
3196  int16_t hash;
3197  // uint16_t n;
3198 
3199  if (!cinfo->jmapped)
3200  return nullptr;
3201 
3202  hash = json_hash(token);
3203 
3204  if (cinfo->jmap[hash].size() == 0)
3205  return ((jsonentry *)nullptr);
3206 
3207  for (size_t n=0; n<cinfo->jmap[hash].size(); n++)
3208  {
3209  if (token == cinfo->jmap[hash][n].name)
3210  {
3211  return ((jsonentry *)&cinfo->jmap[hash][n]);
3212  }
3213  }
3214  return ((jsonentry *)nullptr);
3215 }
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
JSON map offset entry.
Definition: jsondef.h:4164
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
uint16_t json_hash(string hstring)
Calculate JSON HASH.
Definition: jsonlib.cpp:504
jsonequation * json_equation_of ( jsonhandle  handle,
cosmosstruc cinfo 
)

Info on Namespace equation.

Return a pointer to the Namespace Equation structure containing the information for a given equation.

Parameters
handlejsonhandle for the entry in the global emap
Returns
Pointer to the jsonequation for the token, or nullptr.
3225 {
3226  if (!cinfo->jmapped || handle.hash >= cinfo->emap.size())
3227  return nullptr;
3228 
3229  if (cinfo->emap[handle.hash].size() > handle.index)
3230  {
3231  return ((jsonequation *)&cinfo->emap[handle.hash][handle.index]);
3232  }
3233  return ((jsonequation *)nullptr);
3234 }
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
vector< vector< jsonequation > > emap
JSON Equation Map matrix.
Definition: jsondef.h:4211
uint16_t hash
Definition: jsondef.h:794
JSON equation entry.
Definition: jsondef.h:865
uint16_t index
Definition: jsondef.h:796
jsonentry * json_entry_of ( jsonhandle  handle,
cosmosstruc cinfo 
)

Info on Namespace name.

Return a pointer to the Namespace Entry structure containing the information for a given name.

Parameters
handlejsonhandle for the entry in the global jmap
Returns
Pointer to the jsonentry for the token, or nullptr.
3244 {
3245  if (!cinfo->jmapped || handle.hash >= cinfo->jmap.size())
3246  return nullptr;
3247 
3248  if (cinfo->jmap[handle.hash].size() > handle.index)
3249  {
3250  return ((jsonentry *)&cinfo->jmap[handle.hash][handle.index]);
3251  }
3252  return ((jsonentry *)nullptr);
3253 }
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
uint16_t hash
Definition: jsondef.h:794
JSON map offset entry.
Definition: jsondef.h:4164
uint16_t index
Definition: jsondef.h:796
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
uint16_t json_type_of_name ( string  token,
cosmosstruc cinfo 
)

Type of namespace name.

Return the JSON Name Space variable type constants of the token in the ::jsonmap.

Parameters
tokenthe JSON name for the desired variable
Returns
The JSON Name Space variable type constants, otherwise 0.
3262 {
3263  jsonentry *entry;
3264 
3265  if (token[0] == '(')
3266  return (JSON_TYPE_EQUATION);
3267 
3268  if ((entry=json_entry_of(token, cinfo)) != nullptr)
3269  {
3270  return (entry->type);
3271  }
3272  return 0;
3273 }
uint16_t type
JSON Data Type.
Definition: jsondef.h:4169
jsonentry * json_entry_of(uint8_t *ptr, cosmosstruc *cinfo)
Info on Namespace address.
Definition: jsonlib.cpp:3124
JSON map offset entry.
Definition: jsondef.h:4164
JSON Equation.
Definition: jsondef.h:294
uint8_t * json_ptrto ( string  token,
cosmosstruc cinfo 
)

Return the data pointer that matches a JSON name.

Look up the provided JSON data name in the indicated ::jsonmap and return the associated data pointer.

Parameters
tokenthe JSON name for the desired variable
cinfoReference to cosmosstruc to use.
Returns
The associated data pointer, if succesful, otherwise nullptr
3284 {
3285  jsonentry *ptr;
3286 
3287  if ((ptr=json_entry_of(token, cinfo)) == nullptr)
3288  {
3289  return ((uint8_t *)nullptr);
3290  }
3291  else
3292  {
3293  if (ptr->group == JSON_STRUCT_PTR)
3294  {
3295  return ptr->ptr;
3296  }
3297  else
3298  {
3299  return json_ptr_of_entry(*ptr, cinfo);
3300  }
3301  }
3302 }
uint8_t * ptr
pointer to data storage
Definition: jsondef.h:4177
Definition: jsondef.h:173
uint16_t group
JSON Data Group.
Definition: jsondef.h:4171
jsonentry * json_entry_of(uint8_t *ptr, cosmosstruc *cinfo)
Info on Namespace address.
Definition: jsonlib.cpp:3124
JSON map offset entry.
Definition: jsondef.h:4164
uint8_t * json_ptr_of_entry(const jsonentry &entry, cosmosstruc *cinfo)
Address from entry.
Definition: jsonlib.cpp:3004
uint8_t* json_ptrto_1d ( string  token,
uint16_t  index1,
cosmosstruc cinfo 
)

Return the data pointer that matches a singly indexed JSON name.

Look up the provided JSON data name with the indicated index in the current ::jsonmap and return the associated data pointer.

Parameters
tokenthe JSON name for the desired variable
index1Primary index.
cinfoReference to cosmosstruc to use.
Returns
The associated data pointer, if succesful, otherwise nullptr
3314 {
3315  char tstring[5+COSMOS_MAX_NAME];
3316 
3317  if (index1 > 999)
3318  return ((uint8_t *)nullptr);
3319 
3320  // Create extended name, shortening if neccessary
3321  sprintf(tstring,"%.*s_%03u",COSMOS_MAX_NAME,token.c_str(),index1);
3322 
3323  return (json_ptrto(token, cinfo));
3324 
3325 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
uint8_t * json_ptrto(string token, cosmosstruc *cinfo)
Return the data pointer that matches a JSON name.
Definition: jsonlib.cpp:3283
uint8_t* json_ptrto_2d ( string  token,
uint16_t  index1,
uint16_t  index2,
cosmosstruc cinfo 
)

Return the data pointer that matches a doubly indexed JSON name.

Look up the provided JSON data name with the indicated indices in the current ::jsonmap and return the associated data pointer.

Parameters
tokenthe JSON name for the desired variable
index1Primary index.
index2Secondary index.
cinfoReference to cosmosstruc to use.
Returns
The associated data pointer, if succesful, otherwise nullptr
3338 {
3339  char tstring[9+COSMOS_MAX_NAME];
3340 
3341  // Return error if index too large
3342  if (index1 > 999 || index2 > 999)
3343  return ((uint8_t *)nullptr);
3344 
3345  // Create extended name, shortening if necessary
3346  sprintf(tstring,"%.*s_%03u_%03u",COSMOS_MAX_NAME,token.c_str(), index1,index2);
3347 
3348  return (json_ptrto(token, cinfo));
3349 
3350 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
uint8_t * json_ptrto(string token, cosmosstruc *cinfo)
Return the data pointer that matches a JSON name.
Definition: jsonlib.cpp:3283
int32_t json_get_int ( jsonhandle handle,
cosmosstruc cinfo 
)

Return integer from handle.

If the value at this jsonhandle can in any way be interepreted as a number, return it as an int32_t.

Parameters
handlejsonhandle for a valid COSMOS Namespace entry.
cinfoReference to cosmosstruc to use.
Returns
Value cast as an int32_t, or 0.
3361 {
3362  int32_t value=0;
3363 
3364  if (cinfo->jmap[handle.hash].size() <= handle.index)
3365  {
3366  return 0;
3367  }
3368 
3369  value = json_get_int(cinfo->jmap[handle.hash][handle.index], cinfo);
3370  return value;
3371 }
uint16_t hash
Definition: jsondef.h:794
int32_t json_get_int(jsonhandle &handle, cosmosstruc *cinfo)
Return integer from handle.
Definition: jsonlib.cpp:3360
uint16_t index
Definition: jsondef.h:796
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
int32_t json_get_int ( const jsonentry entry,
cosmosstruc cinfo 
)

Return integer from entry.

If the value stored in this jsonentry can in any way be interepreted as a number, return it as an int32_t.

Parameters
entryA valid COSMOS Namespace entry.
cinfoReference to cosmosstruc to use.
Returns
Value cast as an int32_t, or 0.
3382 {
3383  uint8_t *dptr=nullptr;
3384  int32_t value=0;
3385 
3386  dptr = json_ptr_of_entry(entry, cinfo);
3387  if (dptr == nullptr)
3388  {
3389  return 0;
3390  }
3391  else
3392  {
3393  switch (entry.type)
3394  {
3395  case JSON_TYPE_UINT16:
3396  value = (int32_t)(*(uint16_t *)(dptr));
3397  break;
3398  case JSON_TYPE_UINT32:
3399  value = (int32_t)(*(uint32_t *)(dptr));
3400  break;
3401  case JSON_TYPE_INT16:
3402  value = (int32_t)(*(int16_t *)(dptr));
3403  break;
3404  case JSON_TYPE_INT32:
3405  value = (int32_t)(*(int32_t *)(dptr));
3406  break;
3407  case JSON_TYPE_FLOAT:
3408  value = (int32_t)(*(float *)(dptr));
3409  break;
3410  case JSON_TYPE_DOUBLE:
3411  case JSON_TYPE_TIMESTAMP:
3412  value = (int32_t)(*(double *)(dptr) + .5);
3413  break;
3414  case JSON_TYPE_STRING:
3415  value = atol((char *)(dptr));
3416  break;
3417  case JSON_TYPE_EQUATION:
3418  {
3419  const char *tpointer = (char *)dptr;
3420  value = (int32_t)json_equation(tpointer, cinfo);
3421  }
3422  break;
3423  case JSON_TYPE_ALIAS:
3424  {
3425  jsonentry *eptr;
3426  if ((eptr=json_entry_of((*(jsonhandle *)(dptr)), cinfo)) == nullptr)
3427  {
3428  value = 0;
3429  }
3430  else
3431  {
3432  value = json_get_int(*eptr, cinfo);
3433  }
3434  }
3435  break;
3436  }
3437  return value;
3438  }
3439 }
JSON 16 bit integer type.
Definition: jsondef.h:194
JSON Timestamp.
Definition: jsondef.h:292
JSON string type.
Definition: jsondef.h:204
double json_equation(const char *&ptr, cosmosstruc *cinfo)
Return the results of a JSON equation.
Definition: jsonlib.cpp:4294
uint16_t type
JSON Data Type.
Definition: jsondef.h:4169
jsonentry * json_entry_of(uint8_t *ptr, cosmosstruc *cinfo)
Info on Namespace address.
Definition: jsonlib.cpp:3124
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
JSON map offset entry.
Definition: jsondef.h:4164
JSON 32 bit integer type.
Definition: jsondef.h:196
uint8_t * json_ptr_of_entry(const jsonentry &entry, cosmosstruc *cinfo)
Address from entry.
Definition: jsonlib.cpp:3004
JSON double precision floating vertex type.
Definition: jsondef.h:200
JSON handle.
Definition: jsondef.h:791
JSON 32 bit unsigned integer type.
Definition: jsondef.h:190
JSON single precision floating vertex type.
Definition: jsondef.h:198
JSON Alias.
Definition: jsondef.h:296
int32_t json_get_int(jsonhandle &handle, cosmosstruc *cinfo)
Return integer from handle.
Definition: jsonlib.cpp:3360
JSON Equation.
Definition: jsondef.h:294
int32_t json_get_int ( string  token,
cosmosstruc cinfo 
)

Return integer from name.

If the named value can in any way be interepreted as a number, return it as a signed 32 bit integer.

Parameters
tokenValid COSMOS Namespace name.
cinfoReference to cosmosstruc to use.
Returns
Value cast as a signed 32 bit integer, or 0.
3450 {
3451  int32_t value=0;
3452  jsonentry *ptr;
3453 
3454  if ((ptr=json_entry_of(token, cinfo)) == nullptr)
3455  {
3456  return 0;
3457  }
3458 
3459  value = json_get_int(*ptr, cinfo);
3460  return (value);
3461 
3462 }
jsonentry * json_entry_of(uint8_t *ptr, cosmosstruc *cinfo)
Info on Namespace address.
Definition: jsonlib.cpp:3124
JSON map offset entry.
Definition: jsondef.h:4164
int32_t json_get_int(jsonhandle &handle, cosmosstruc *cinfo)
Return integer from handle.
Definition: jsonlib.cpp:3360
int32_t json_get_int ( string  token,
uint16_t  index1,
cosmosstruc cinfo 
)

Return integer from 1d name.

If the named 1d indexed value can in any way be interepreted as a number, return it as a signed 32 bit integer.

Parameters
tokenValid COSMOS Namespace name.
index11d index.
cinfoReference to cosmosstruc to use.
Returns
Value cast as a signed 32 bit integer, or 0.
3474 {
3475  int32_t value;
3476  char tstring[5+COSMOS_MAX_NAME];
3477 
3478  if (index1 > 999)
3479  return 0;
3480 
3481  // Create extended name, shortening if neccessary
3482  sprintf(tstring,"%.*s_%03u",COSMOS_MAX_NAME,token.c_str(), index1);
3483 
3484  value = json_get_int(tstring, cinfo);
3485 
3486  return (value);
3487 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
int32_t json_get_int(jsonhandle &handle, cosmosstruc *cinfo)
Return integer from handle.
Definition: jsonlib.cpp:3360
int32_t json_get_int ( string  token,
uint16_t  index1,
uint16_t  index2,
cosmosstruc cinfo 
)

Return integer from 2d name.

If the named 2d indexed value can in any way be interepreted as a number, return it as a signed 32 bit integer.

Parameters
tokenValid COSMOS Namespace name.
index11d index.
index22d index.
cinfoReference to cosmosstruc to use.
Returns
Value cast as a signed 32 bit integer, or 0.
3500 {
3501  int32_t value;
3502  char tstring[9+COSMOS_MAX_NAME];
3503 
3504  if (index1 > 999)
3505  return 0;
3506 
3507  // Create extended name, shortening if neccessary
3508  sprintf(tstring,"%.*s_%03u_%03u",COSMOS_MAX_NAME,token.c_str(), index1,index2);
3509 
3510  value = json_get_int(tstring, cinfo);
3511 
3512  return (value);
3513 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
int32_t json_get_int(jsonhandle &handle, cosmosstruc *cinfo)
Return integer from handle.
Definition: jsonlib.cpp:3360
uint32_t json_get_uint ( jsonhandle handle,
cosmosstruc cinfo 
)

Return unsigned integer from handle.

If the value at this jsonhandle can in any way be interepreted as a number, return it as an uint32_t.

Parameters
handlejsonhandle for a valid COSMOS Namespace entry.
cinfoReference to cosmosstruc to use.
Returns
Value cast as an uint32_t, or 0.
3525 {
3526  uint32_t value=0;
3527 
3528  if (cinfo->jmap[handle.hash].size() <= handle.index)
3529  {
3530  return 0;
3531  }
3532 
3533  value = json_get_uint(cinfo->jmap[handle.hash][handle.index], cinfo);
3534  return value;
3535 }
uint32_t json_get_uint(jsonhandle &handle, cosmosstruc *cinfo)
Return unsigned integer from handle.
Definition: jsonlib.cpp:3524
uint16_t hash
Definition: jsondef.h:794
uint16_t index
Definition: jsondef.h:796
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
uint32_t json_get_uint ( const jsonentry entry,
cosmosstruc cinfo 
)

Return unsigned integer from entry.

If the value stored in this jsonentry can in any way be interepreted as a number, return it as an uint32_t.

Parameters
entryA valid COSMOS Namespace entry.
cinfoReference to cosmosstruc to use.
Returns
Value cast as an uint32_t, or 0.
3547 {
3548  uint8_t *dptr=nullptr;
3549  uint32_t value=0;
3550 
3551  dptr = json_ptr_of_entry(entry, cinfo);
3552  if (dptr == nullptr)
3553  {
3554  return 0;
3555  }
3556  else
3557  {
3558  switch (entry.type)
3559  {
3560  case JSON_TYPE_UINT16:
3561  value = (uint32_t)(*(uint16_t *)(dptr));
3562  break;
3563  case JSON_TYPE_UINT32:
3564  value = (uint32_t)(*(uint32_t *)(dptr));
3565  break;
3566  case JSON_TYPE_INT16:
3567  value = (uint32_t)(*(int16_t *)(dptr));
3568  break;
3569  case JSON_TYPE_INT32:
3570  value = (uint32_t)(*(int32_t *)(dptr));
3571  break;
3572  case JSON_TYPE_FLOAT:
3573  value = (uint32_t)(*(float *)(dptr));
3574  break;
3575  case JSON_TYPE_DOUBLE:
3576  case JSON_TYPE_TIMESTAMP:
3577  value = (uint32_t)(*(double *)(dptr) + .5);
3578  break;
3579  case JSON_TYPE_STRING:
3580  value = atol((char *)(dptr));
3581  break;
3582  case JSON_TYPE_EQUATION:
3583  {
3584  const char *tpointer = (char *)dptr;
3585  value = (uint32_t)json_equation(tpointer, cinfo);
3586  }
3587  break;
3588  }
3589  return value;
3590  }
3591 }
JSON 16 bit integer type.
Definition: jsondef.h:194
JSON Timestamp.
Definition: jsondef.h:292
JSON string type.
Definition: jsondef.h:204
double json_equation(const char *&ptr, cosmosstruc *cinfo)
Return the results of a JSON equation.
Definition: jsonlib.cpp:4294
uint16_t type
JSON Data Type.
Definition: jsondef.h:4169
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
JSON 32 bit integer type.
Definition: jsondef.h:196
uint8_t * json_ptr_of_entry(const jsonentry &entry, cosmosstruc *cinfo)
Address from entry.
Definition: jsonlib.cpp:3004
JSON double precision floating vertex type.
Definition: jsondef.h:200
JSON 32 bit unsigned integer type.
Definition: jsondef.h:190
JSON single precision floating vertex type.
Definition: jsondef.h:198
JSON Equation.
Definition: jsondef.h:294
uint32_t json_get_uint ( string  token,
cosmosstruc cinfo 
)

Return unsigned integer from name.

If the named value can in any way be interepreted as a number, return it as a signed 32 bit unsigned integer.

Parameters
tokenValid COSMOS Namespace name.
cinfoReference to cosmosstruc to use.
Returns
Value cast as a signed 32 bit unsigned integer, or 0.
3603 {
3604  uint32_t value=0;
3605  jsonentry *ptr;
3606 
3607  if ((ptr=json_entry_of(token, cinfo)) == nullptr)
3608  {
3609  return 0;
3610  }
3611 
3612  value = json_get_uint(*ptr, cinfo);
3613  return (value);
3614 
3615 }
uint32_t json_get_uint(jsonhandle &handle, cosmosstruc *cinfo)
Return unsigned integer from handle.
Definition: jsonlib.cpp:3524
jsonentry * json_entry_of(uint8_t *ptr, cosmosstruc *cinfo)
Info on Namespace address.
Definition: jsonlib.cpp:3124
JSON map offset entry.
Definition: jsondef.h:4164
uint32_t json_get_uint ( string  token,
uint16_t  index1,
cosmosstruc cinfo 
)

Return unsigned integer from 1d name.

If the named 1d indexed value can in any way be interepreted as a number, return it as a signed 32 bit unsigned integer.

Parameters
tokenValid COSMOS Namespace name.
index11d index.
cinfoReference to cosmosstruc to use.
Returns
Value cast as a signed 32 bit unsigned integer, or 0.
3628 {
3629  uint32_t value;
3630  char tstring[5+COSMOS_MAX_NAME];
3631 
3632  if (index1 > 999)
3633  return 0;
3634 
3635  // Create extended name, shortening if neccessary
3636  sprintf(tstring,"%.*s_%03u",COSMOS_MAX_NAME,token.c_str(), index1);
3637 
3638  value = json_get_uint(tstring, cinfo);
3639 
3640  return (value);
3641 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
uint32_t json_get_uint(jsonhandle &handle, cosmosstruc *cinfo)
Return unsigned integer from handle.
Definition: jsonlib.cpp:3524
uint32_t json_get_uint ( string  token,
uint16_t  index1,
uint16_t  index2,
cosmosstruc cinfo 
)

Return unsigned integer from 2d name.

If the named 2d indexed value can in any way be interepreted as a number, return it as a signed 32 bit unsigned integer.

Parameters
tokenValid COSMOS Namespace name.
index11d index.
index22d index.
cinfoReference to cosmosstruc to use.
Returns
Value cast as a signed 32 bit unsigned integer, or 0.
3655 {
3656  uint32_t value;
3657  char tstring[9+COSMOS_MAX_NAME];
3658 
3659  if (index1 > 999)
3660  return 0;
3661 
3662  // Create extended name, shortening if neccessary
3663  sprintf(tstring,"%.*s_%03u_%03u",COSMOS_MAX_NAME,token.c_str(), index1,index2);
3664 
3665  value = json_get_uint(tstring, cinfo);
3666 
3667  return (value);
3668 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
uint32_t json_get_uint(jsonhandle &handle, cosmosstruc *cinfo)
Return unsigned integer from handle.
Definition: jsonlib.cpp:3524
double json_get_double ( jsonhandle handle,
cosmosstruc cinfo 
)

Return double from handle.

If the value at this jsonhandle can in any way be interepreted as a number, return it as a double.

Parameters
handlejsonhandle for a valid COSMOS Namespace entry.
cinfoReference to cosmosstruc to use.
Returns
Value cast as an double, or 0.
3680 {
3681  double value=0.;
3682 
3683  if (cinfo->jmap[handle.hash].size() <= handle.index)
3684  {
3685  return 0.;
3686  }
3687 
3688  value = json_get_double(cinfo->jmap[handle.hash][handle.index], cinfo);
3689  return value;
3690 }
uint16_t hash
Definition: jsondef.h:794
double json_get_double(jsonhandle &handle, cosmosstruc *cinfo)
Return double from handle.
Definition: jsonlib.cpp:3679
uint16_t index
Definition: jsondef.h:796
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
double json_get_double ( string  token,
cosmosstruc cinfo 
)

Return double from name.

If the named value can in any way be interepreted as a number, return it as a double.

Parameters
tokenValid COSMOS Namespace name.
cinfoReference to cosmosstruc to use.
Returns
Value cast as a double, or 0.
3702 {
3703  double value=0.;
3704  jsonentry *entry;
3705  const char* tokenp = &token[0];
3706 
3707  if (!std::isnan(value=json_equation(tokenp, cinfo)))
3708  return (value);
3709 
3710  if ((entry=json_entry_of(token, cinfo)) == nullptr)
3711  {
3712  return (NAN);
3713  }
3714 
3715  if (!std::isnan(value=json_get_double(*entry, cinfo)))
3716  return (value);
3717 
3718  return (NAN);
3719 }
double json_equation(const char *&ptr, cosmosstruc *cinfo)
Return the results of a JSON equation.
Definition: jsonlib.cpp:4294
jsonentry * json_entry_of(uint8_t *ptr, cosmosstruc *cinfo)
Info on Namespace address.
Definition: jsonlib.cpp:3124
JSON map offset entry.
Definition: jsondef.h:4164
double json_get_double(jsonhandle &handle, cosmosstruc *cinfo)
Return double from handle.
Definition: jsonlib.cpp:3679
double json_get_double ( const jsonentry entry,
cosmosstruc cinfo 
)

Return double from entry.

If the named value can in any way be interepreted as a number, return it as a double.

Parameters
entryPointer to a valid jsonentry.
cinfoReference to cosmosstruc to use.
Returns
Value cast as a double, or 0.
3731 {
3732  uint8_t *dptr=nullptr;
3733  double value=0.;
3734 
3735  dptr = json_ptr_of_entry(entry, cinfo);
3736  if (dptr == nullptr)
3737  {
3738  return 0.;
3739  }
3740  else
3741  {
3742  switch (entry.type)
3743  {
3744  case JSON_TYPE_UINT16:
3745  value = (double)(*(uint16_t *)(dptr));
3746  break;
3747  case JSON_TYPE_UINT32:
3748  value = (double)(*(uint32_t *)(dptr));
3749  break;
3750  case JSON_TYPE_INT16:
3751  value = (double)(*(int16_t *)(dptr));
3752  break;
3753  case JSON_TYPE_INT32:
3754  value = (double)(*(int32_t *)(dptr));
3755  break;
3756  case JSON_TYPE_FLOAT:
3757  value = (double)(*(float *)(dptr));
3758  break;
3759  case JSON_TYPE_DOUBLE:
3760  case JSON_TYPE_TIMESTAMP:
3761  value = (double)(*(double *)(dptr));
3762  break;
3763  case JSON_TYPE_STRING:
3764  value = atof((char *)dptr);
3765  break;
3766  case JSON_TYPE_EQUATION:
3767  {
3768  const char *tpointer = (char *)dptr;
3769  value = (double)json_equation(tpointer, cinfo);
3770  }
3771  break;
3772  default:
3773  value = 0;
3774  }
3775  return value;
3776  }
3777 }
JSON 16 bit integer type.
Definition: jsondef.h:194
JSON Timestamp.
Definition: jsondef.h:292
JSON string type.
Definition: jsondef.h:204
double json_equation(const char *&ptr, cosmosstruc *cinfo)
Return the results of a JSON equation.
Definition: jsonlib.cpp:4294
uint16_t type
JSON Data Type.
Definition: jsondef.h:4169
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
JSON 32 bit integer type.
Definition: jsondef.h:196
uint8_t * json_ptr_of_entry(const jsonentry &entry, cosmosstruc *cinfo)
Address from entry.
Definition: jsonlib.cpp:3004
JSON double precision floating vertex type.
Definition: jsondef.h:200
JSON 32 bit unsigned integer type.
Definition: jsondef.h:190
JSON single precision floating vertex type.
Definition: jsondef.h:198
JSON Equation.
Definition: jsondef.h:294
rvector json_get_rvector ( const jsonentry entry,
cosmosstruc cinfo 
)

Return rvector from entry.

If the named value can in any way be interepreted as three numbers, return it as an rvector.

Parameters
entryPointer to a valid jsonentry..
cinfoReference to cosmosstruc to use.
Returns
Value cast as an rvector, or 0.
3789 {
3790  uint8_t *dptr=nullptr;
3791  rvector value;
3792 
3793  dptr = json_ptr_of_entry(entry, cinfo);
3794  if (dptr == nullptr)
3795  {
3796  return value;
3797  }
3798  else
3799  {
3800  switch (entry.type)
3801  {
3802  case JSON_TYPE_SPHERPOS:
3803  case JSON_TYPE_POS_GEOS:
3804  {
3805  spherpos tpos = (spherpos)(*(spherpos *)(dptr));
3806  value.col[0] = tpos.s.phi;
3807  value.col[1] = tpos.s.lambda;
3808  value.col[2] = tpos.s.r;
3809  }
3810  break;
3811  case JSON_TYPE_GEOIDPOS:
3812  case JSON_TYPE_POS_GEOD:
3813  case JSON_TYPE_POS_SELG:
3814  {
3815  geoidpos tpos = (geoidpos)(*(geoidpos *)(dptr));
3816  value.col[0] = tpos.s.lat;
3817  value.col[1] = tpos.s.lon;
3818  value.col[2] = tpos.s.h;
3819  }
3820  break;
3821  case JSON_TYPE_CARTPOS:
3822  case JSON_TYPE_POS_GEOC:
3823  case JSON_TYPE_POS_SELC:
3824  case JSON_TYPE_POS_ECI:
3825  case JSON_TYPE_POS_SCI:
3826  case JSON_TYPE_POS_ICRF:
3827  {
3828  cartpos tpos = (cartpos)(*(cartpos *)(dptr));
3829  value = tpos.s;
3830  }
3831  break;
3832  case JSON_TYPE_VECTOR:
3833  case JSON_TYPE_RVECTOR:
3834  // case JSON_TYPE_TVECTOR:
3835  case JSON_TYPE_CVECTOR:
3836  case JSON_TYPE_SVECTOR:
3837  case JSON_TYPE_AVECTOR:
3838  value = (rvector)(*(rvector *)(dptr));
3839  break;
3840  case JSON_TYPE_UINT16:
3841  value.col[0] = (double)(*(uint16_t *)(dptr));
3842  break;
3843  case JSON_TYPE_UINT32:
3844  value.col[0] = (double)(*(uint32_t *)(dptr));
3845  break;
3846  case JSON_TYPE_INT16:
3847  value.col[0] = (double)(*(int16_t *)(dptr));
3848  break;
3849  case JSON_TYPE_INT32:
3850  value.col[0] = (double)(*(int32_t *)(dptr));
3851  break;
3852  case JSON_TYPE_FLOAT:
3853  value.col[0] = (double)(*(float *)(dptr));
3854  break;
3855  case JSON_TYPE_DOUBLE:
3856  case JSON_TYPE_TIMESTAMP:
3857  value.col[0] = (double)(*(double *)(dptr));
3858  break;
3859  case JSON_TYPE_STRING:
3860  value.col[0] = atof((char *)dptr);
3861  break;
3862  case JSON_TYPE_EQUATION:
3863  {
3864  const char *tpointer = (char *)dptr;
3865  value.col[0] = (double)json_equation(tpointer, cinfo);
3866  }
3867  break;
3868  default:
3869  value.col[0] = 0.;
3870  }
3871  return value;
3872  }
3873 }
JSON 16 bit integer type.
Definition: jsondef.h:194
JSON rvector.
Definition: jsondef.h:210
svector s
Position vector.
Definition: convertdef.h:318
JSON Timestamp.
Definition: jsondef.h:292
JSON string type.
Definition: jsondef.h:204
double lambda
E/W in radians.
Definition: vector.h:172
3 element generic row vector
Definition: vector.h:53
Geodetic position structure.
Definition: convertdef.h:259
JSON Earth Centered Inertial Position.
Definition: jsondef.h:247
Cartesian full position structure.
Definition: convertdef.h:158
JSON cvector.
Definition: jsondef.h:214
JSON Geocentric Spherical.
Definition: jsondef.h:257
JSON rvector.
Definition: jsondef.h:212
JSON Geocentric Position.
Definition: jsondef.h:251
double json_equation(const char *&ptr, cosmosstruc *cinfo)
Return the results of a JSON equation.
Definition: jsonlib.cpp:4294
rvector s
Location.
Definition: convertdef.h:163
JSON Lunar Centered Inertial Position.
Definition: jsondef.h:249
uint16_t type
JSON Data Type.
Definition: jsondef.h:4169
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
double phi
N/S in radians.
Definition: vector.h:170
JSON cartpos.
Definition: jsondef.h:228
JSON Geodetic Position.
Definition: jsondef.h:255
JSON cartpos.
Definition: jsondef.h:226
double h
Height in meters.
Definition: vector.h:229
JSON 32 bit integer type.
Definition: jsondef.h:196
double lon
Longitude in radians.
Definition: vector.h:227
Spherical position structure.
Definition: convertdef.h:314
uint8_t * json_ptr_of_entry(const jsonentry &entry, cosmosstruc *cinfo)
Address from entry.
Definition: jsonlib.cpp:3004
JSON double precision floating vertex type.
Definition: jsondef.h:200
gvector s
Position vector.
Definition: convertdef.h:263
double lat
Latitude in radians.
Definition: vector.h:225
JSON 32 bit unsigned integer type.
Definition: jsondef.h:190
JSON cartpos.
Definition: jsondef.h:224
JSON svector.
Definition: jsondef.h:220
JSON ::Vector.
Definition: jsondef.h:208
double col[3]
Definition: vector.h:55
JSON single precision floating vertex type.
Definition: jsondef.h:198
JSON Equation.
Definition: jsondef.h:294
double r
Radius in meters.
Definition: vector.h:174
JSON Selenocentric Position.
Definition: jsondef.h:253
JSON Solar Barycentric Position.
Definition: jsondef.h:244
JSON Selenographic Position.
Definition: jsondef.h:259
quaternion json_get_quaternion ( const jsonentry entry,
cosmosstruc cinfo 
)

Return quaternion from entry.

If the named value can in any way be interepreted as three numbers, return it as an quaternion.

Parameters
entryPointer to a valid jsonentry.
cinfoReference to cosmosstruc to use.
Returns
Value cast as an quaternion, or 0.
3885 {
3886  uint8_t *dptr=nullptr;
3887  quaternion value={{0., 0., 0.}, 0.};
3888 
3889  dptr = json_ptr_of_entry(entry, cinfo);
3890  if (dptr == nullptr)
3891  {
3892  return value;
3893  }
3894  else
3895  {
3896  switch (entry.type)
3897  {
3898  case JSON_TYPE_QATT:
3899  case JSON_TYPE_QATT_GEOC:
3900  case JSON_TYPE_QATT_SELC:
3901  case JSON_TYPE_QATT_ICRF:
3902  case JSON_TYPE_QATT_LVLH:
3903  case JSON_TYPE_QATT_TOPO:
3904  {
3905  value = (quaternion)(*(quaternion *)(dptr));
3906  }
3907  break;
3908  case JSON_TYPE_QUATERNION:
3909  value = (quaternion)(*(quaternion *)(dptr));
3910  break;
3911  case JSON_TYPE_RVECTOR:
3912  // case JSON_TYPE_TVECTOR:
3913  {
3914  rvector tvalue = (rvector)(*(rvector *)(dptr));
3915  value.d.x = tvalue.col[0];
3916  value.d.y = tvalue.col[1];
3917  value.d.z = tvalue.col[2];
3918  }
3919  break;
3920  case JSON_TYPE_GVECTOR:
3921  {
3922  gvector tvalue = (gvector)(*(gvector *)(dptr));
3923  value.d.x = tvalue.lat;
3924  value.d.y = tvalue.lon;
3925  value.d.z = tvalue.h;
3926  }
3927  break;
3928  case JSON_TYPE_SVECTOR:
3929  {
3930  svector tvalue = (svector)(*(svector *)(dptr));
3931  value.d.x = tvalue.phi;
3932  value.d.y = tvalue.lambda;
3933  value.d.z = tvalue.r;
3934  }
3935  break;
3936  case JSON_TYPE_AVECTOR:
3937  {
3938  avector tvalue = (avector)(*(avector *)(dptr));
3939  value.d.x = tvalue.h;
3940  value.d.y = tvalue.e;
3941  value.d.z = tvalue.b;
3942  }
3943  break;
3944  case JSON_TYPE_UINT16:
3945  value.d.x = (double)(*(uint16_t *)(dptr));
3946  break;
3947  case JSON_TYPE_UINT32:
3948  value.d.x = (double)(*(uint32_t *)(dptr));
3949  break;
3950  case JSON_TYPE_INT16:
3951  value.d.x = (double)(*(int16_t *)(dptr));
3952  break;
3953  case JSON_TYPE_INT32:
3954  value.d.x = (double)(*(int32_t *)(dptr));
3955  break;
3956  case JSON_TYPE_FLOAT:
3957  value.d.x = (double)(*(float *)(dptr));
3958  break;
3959  case JSON_TYPE_DOUBLE:
3960  case JSON_TYPE_TIMESTAMP:
3961  value.d.x = (double)(*(double *)(dptr));
3962  break;
3963  case JSON_TYPE_STRING:
3964  value.d.x = atof((char *)dptr);
3965  break;
3966  case JSON_TYPE_EQUATION:
3967  {
3968  const char *tpointer = (char *)dptr;
3969  value.d.x = (double)json_equation(tpointer, cinfo);
3970  }
3971  break;
3972  default:
3973  value.d.x = 0.;
3974  }
3975  return value;
3976  }
3977 }
double y
Y value.
Definition: vector.h:114
JSON 16 bit integer type.
Definition: jsondef.h:194
JSON rvector.
Definition: jsondef.h:210
JSON Timestamp.
Definition: jsondef.h:292
JSON string type.
Definition: jsondef.h:204
JSON Geocentric Attitude.
Definition: jsondef.h:264
double lambda
E/W in radians.
Definition: vector.h:172
3 element generic row vector
Definition: vector.h:53
cvector d
Orientation.
Definition: vector.h:405
JSON qatt.
Definition: jsondef.h:232
Quaternion, scalar last, using x, y, z.
Definition: vector.h:402
JSON Lunar Centered Inertial Attitude.
Definition: jsondef.h:266
double x
X value.
Definition: vector.h:112
double e
Elevation.
Definition: vector.h:282
JSON rvector.
Definition: jsondef.h:212
double json_equation(const char *&ptr, cosmosstruc *cinfo)
Return the results of a JSON equation.
Definition: jsonlib.cpp:4294
JSON Earth Centered Inertial Attitude.
Definition: jsondef.h:268
uint16_t type
JSON Data Type.
Definition: jsondef.h:4169
JSON LVLH Attitude.
Definition: jsondef.h:270
double b
Bank.
Definition: vector.h:284
3 element attitude vector.
Definition: vector.h:277
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
double phi
N/S in radians.
Definition: vector.h:170
3 element spherical vector
Definition: vector.h:167
double h
Height in meters.
Definition: vector.h:229
JSON 32 bit integer type.
Definition: jsondef.h:196
JSON Topocentric Attitude.
Definition: jsondef.h:262
double lon
Longitude in radians.
Definition: vector.h:227
uint8_t * json_ptr_of_entry(const jsonentry &entry, cosmosstruc *cinfo)
Address from entry.
Definition: jsonlib.cpp:3004
JSON double precision floating vertex type.
Definition: jsondef.h:200
double z
Z value.
Definition: vector.h:116
double lat
Latitude in radians.
Definition: vector.h:225
JSON 32 bit unsigned integer type.
Definition: jsondef.h:190
JSON svector.
Definition: jsondef.h:220
double col[3]
Definition: vector.h:55
JSON single precision floating vertex type.
Definition: jsondef.h:198
JSON Equation.
Definition: jsondef.h:294
double r
Radius in meters.
Definition: vector.h:174
double h
Heading.
Definition: vector.h:280
3 element geodetic vector
Definition: vector.h:222
JSON gvector.
Definition: jsondef.h:218
JSON quaternion type.
Definition: jsondef.h:216
double json_get_double ( string  token,
uint16_t  index1,
cosmosstruc cinfo 
)

Return double from 1d name.

If the named 1d indexed value can in any way be interepreted as a number, return it as a double.

Parameters
tokenValid COSMOS Namespace name.
index11d index.
cinfoReference to cosmosstruc to use.
Returns
Value cast as a double, or 0.
3990 {
3991  double value;
3992  char tstring[5+COSMOS_MAX_NAME];
3993 
3994  if (index1 > 999)
3995  return 0;
3996 
3997  // Create extended name, shortening if neccessary
3998  sprintf(tstring,"%.*s_%03u",COSMOS_MAX_NAME,token.c_str(), index1);
3999 
4000 
4001  value = json_get_double(tstring, cinfo);
4002 
4003  return (value);
4004 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
double json_get_double(jsonhandle &handle, cosmosstruc *cinfo)
Return double from handle.
Definition: jsonlib.cpp:3679
double json_get_double ( string  token,
uint16_t  index1,
uint16_t  index2,
cosmosstruc cinfo 
)

Return double from 2d name.

If the named 2d indexed value can in any way be interepreted as a number, return it as a double.

Parameters
tokenValid COSMOS Namespace name.
index11d index.
index22d index.
cinfoReference to cosmosstruc to use.
Returns
Value cast as a double, or 0.
4018 {
4019  double value;
4020  char tstring[9+COSMOS_MAX_NAME];
4021 
4022  if (index1 > 999)
4023  return 0;
4024 
4025  // Create extended name, shortening if neccessary
4026  sprintf(tstring,"%.*s_%03u_%03u",COSMOS_MAX_NAME,token.c_str(), index1,index2);
4027 
4028 
4029  value = json_get_double(tstring, cinfo);
4030 
4031  return (value);
4032 }
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
double json_get_double(jsonhandle &handle, cosmosstruc *cinfo)
Return double from handle.
Definition: jsonlib.cpp:3679
string json_get_string ( string  token,
cosmosstruc cinfo 
)

Return string from name.

If the named value is a string, just copy it. Otherwise, print whatever numerical value as a string. Return a pointer to an internal storage buffer for the string. Note: this value is changed each time you call this function.

Parameters
tokenValid COSMOS Namespace name.
cinfoReference to cosmosstruc to use.
Returns
Pointer to a char buffer containing the string.
4046 {
4047  jsonentry *ptr;
4048  string tstring;
4049 
4050  if ((ptr=json_entry_of(token, cinfo)) != nullptr)
4051  {
4052  tstring = json_get_string(*ptr, cinfo);
4053  }
4054 
4055  return tstring;
4056 }
string json_get_string(string token, cosmosstruc *cinfo)
Return string from name.
Definition: jsonlib.cpp:4045
jsonentry * json_entry_of(uint8_t *ptr, cosmosstruc *cinfo)
Info on Namespace address.
Definition: jsonlib.cpp:3124
JSON map offset entry.
Definition: jsondef.h:4164
string json_get_string ( const jsonentry entry,
cosmosstruc cinfo 
)

Return string from entry.

If the named value is a string, just copy it. Otherwise, print whatever numerical value as a string. Return a pointer to an internal storage buffer for the string. Note: this value is changed each time you call this function.

Parameters
ptrPointer to a valid jsonentry..
cinfoReference to cosmosstruc to use.
Returns
Pointer to a char buffer containing the string.
4069 {
4070  string tstring;
4071  char tbuf[200];
4072 
4073  // if (entry == nullptr)
4074  // {
4075  // return (tstring);
4076  // }
4077 
4078  switch (entry.type)
4079  {
4080  case JSON_TYPE_UINT16:
4081  sprintf(tbuf,"%u",(*(uint16_t *)(json_ptr_of_entry(entry, cinfo))));
4082  tstring = tbuf;
4083  break;
4084  case JSON_TYPE_UINT32:
4085  sprintf(tbuf,"%u",(*(uint32_t *)(json_ptr_of_entry(entry, cinfo))));
4086  tstring = tbuf;
4087  break;
4088  case JSON_TYPE_INT16:
4089  sprintf(tbuf,"%d",(*(int16_t *)(json_ptr_of_entry(entry, cinfo))));
4090  tstring = tbuf;
4091  break;
4092  case JSON_TYPE_INT32:
4093  sprintf(tbuf,"%d",(*(int32_t *)(json_ptr_of_entry(entry, cinfo))));
4094  tstring = tbuf;
4095  break;
4096  case JSON_TYPE_FLOAT:
4097  sprintf(tbuf,"%.8g",(*(float *)(json_ptr_of_entry(entry, cinfo))));
4098  tstring = tbuf;
4099  break;
4100  case JSON_TYPE_DOUBLE:
4101  case JSON_TYPE_TIMESTAMP:
4102  sprintf(tbuf,"%.17g",(*(double *)(json_ptr_of_entry(entry, cinfo))) + .5);
4103  tstring = tbuf;
4104  break;
4105  case JSON_TYPE_STRING:
4106  case JSON_TYPE_NAME:
4107  tstring = (char *)(json_ptr_of_entry(entry, cinfo));
4108  // strcpy(tbuf,(char *)(json_ptr_of_entry(entry, cinfo))));
4109  break;
4110  case JSON_TYPE_POS_ECI:
4111  cartpos tval = (*(cartpos *)(json_ptr_of_entry(entry, cinfo)));
4112  sprintf(tbuf, "[%.17g %.17g %.17g] [%.17g %.17g %.17g] [%.17g %.17g %.17g]",
4113  tval.s.col[0], tval.s.col[1], tval.s.col[2],
4114  tval.v.col[0], tval.v.col[1], tval.v.col[2],
4115  tval.a.col[0], tval.a.col[1], tval.a.col[2]);
4116  tstring = tbuf;
4117  break;
4118  }
4119 
4120  return (tstring);
4121 }
JSON 16 bit integer type.
Definition: jsondef.h:194
JSON Timestamp.
Definition: jsondef.h:292
JSON string type.
Definition: jsondef.h:204
rvector a
Acceleration.
Definition: convertdef.h:167
JSON Earth Centered Inertial Position.
Definition: jsondef.h:247
Cartesian full position structure.
Definition: convertdef.h:158
rvector s
Location.
Definition: convertdef.h:163
JSON Name type.
Definition: jsondef.h:206
uint16_t type
JSON Data Type.
Definition: jsondef.h:4169
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
JSON 32 bit integer type.
Definition: jsondef.h:196
uint8_t * json_ptr_of_entry(const jsonentry &entry, cosmosstruc *cinfo)
Address from entry.
Definition: jsonlib.cpp:3004
JSON double precision floating vertex type.
Definition: jsondef.h:200
JSON 32 bit unsigned integer type.
Definition: jsondef.h:190
double col[3]
Definition: vector.h:55
JSON single precision floating vertex type.
Definition: jsondef.h:198
rvector v
Velocity.
Definition: convertdef.h:165
posstruc json_get_posstruc ( const jsonentry entry,
cosmosstruc cinfo 
)

Return posstruc from entry.

If the named value can in any way be interepreted as a posstruc, return it as a posstruc.

Parameters
entryPointer to a valid jsonentry..
cinfoReference to cosmosstruc to use.
Returns
Value cast as a posstruc, or 0.
4133 {
4134  uint8_t *dptr=nullptr;
4135  locstruc value;
4136 
4137  memset((void *) &value, 0, COSMOS_SIZEOF(locstruc));
4138 
4139  dptr = json_ptr_of_entry(entry, cinfo);
4140  if (dptr == nullptr)
4141  {
4142  return value.pos;
4143  }
4144  else
4145  {
4146  switch (entry.type)
4147  {
4148  case JSON_TYPE_POSSTRUC:
4149  {
4150  value.pos = (posstruc)(*(posstruc *)(dptr));
4151  }
4152  break;
4153  case JSON_TYPE_RVECTOR:
4154  {
4155  value.pos.eci.s = (rvector)(*(rvector *)(dptr));
4156  value.pos.eci.v = rv_zero();
4157  value.pos.eci.a = rv_zero();
4158  ++value.pos.eci.pass;
4159  pos_eci(&value);
4160  }
4161  break;
4162  case JSON_TYPE_CARTPOS:
4163  {
4164  value.pos.eci = (cartpos)(*(cartpos *)(dptr));
4165  ++value.pos.eci.pass;
4166  pos_eci(&value);
4167  }
4168  break;
4169  case JSON_TYPE_POS_GEOC:
4170  {
4171  value.pos.geoc = (cartpos)(*(cartpos *)(dptr));
4172  ++value.pos.geoc.pass;
4173  pos_geoc(&value);
4174  }
4175  break;
4176  case JSON_TYPE_POS_GEOD:
4177  {
4178  value.pos.geod = (geoidpos)(*(geoidpos *)(dptr));
4179  ++value.pos.geod.pass;
4180  pos_geod(&value);
4181  }
4182  break;
4183  case JSON_TYPE_POS_SELC:
4184  {
4185  value.pos.selc = (cartpos)(*(cartpos *)(dptr));
4186  ++value.pos.selc.pass;
4187  pos_selc(&value);
4188  }
4189  break;
4190  case JSON_TYPE_POS_SELG:
4191  {
4192  value.pos.selg = (geoidpos)(*(geoidpos *)(dptr));
4193  ++value.pos.selg.pass;
4194  pos_selg(&value);
4195  }
4196  break;
4197  case JSON_TYPE_POS_ECI:
4198  {
4199  value.pos.eci = (cartpos)(*(cartpos *)(dptr));
4200  ++value.pos.eci.pass;
4201  pos_eci(&value);
4202  }
4203  break;
4204  case JSON_TYPE_POS_SCI:
4205  {
4206  value.pos.sci = (cartpos)(*(cartpos *)(dptr));
4207  ++value.pos.sci.pass;
4208  pos_sci(&value);
4209  }
4210  break;
4211  case JSON_TYPE_POS_ICRF:
4212  {
4213  value.pos.icrf = (cartpos)(*(cartpos *)(dptr));
4214  ++value.pos.icrf.pass;
4215  pos_icrf(&value);
4216  }
4217  break;
4218  }
4219 
4220  return value.pos;
4221  }
4222 }
JSON rvector.
Definition: jsondef.h:210
3 element generic row vector
Definition: vector.h:53
rvector a
Acceleration.
Definition: convertdef.h:167
#define COSMOS_SIZEOF(element)
Definition: configCosmos.h:139
cartpos selc
Definition: convertdef.h:740
Geodetic position structure.
Definition: convertdef.h:259
JSON Earth Centered Inertial Position.
Definition: jsondef.h:247
uint32_t pass
pass indicator: allows synchronization with other attitude and position values.
Definition: convertdef.h:170
Cartesian full position structure.
Definition: convertdef.h:158
int32_t pos_sci(locstruc *loc)
Set SCI position.
Definition: convertlib.cpp:312
cartpos geoc
Definition: convertdef.h:739
int32_t pos_selg(locstruc *loc)
Set Selenographic position.
Definition: convertlib.cpp:484
JSON Geocentric Position.
Definition: jsondef.h:251
Definition: convertdef.h:733
geoidpos selg
Definition: convertdef.h:742
rvector s
Location.
Definition: convertdef.h:163
JSON Lunar Centered Inertial Position.
Definition: jsondef.h:249
uint16_t type
JSON Data Type.
Definition: jsondef.h:4169
JSON Geodetic Position.
Definition: jsondef.h:255
int32_t pos_geoc(locstruc *loc)
Set Geocentric position.
Definition: convertlib.cpp:366
int32_t pos_eci(locstruc *loc)
Set ECI position.
Definition: convertlib.cpp:258
int32_t pos_icrf(locstruc *loc)
Set Barycentric position.
Definition: convertlib.cpp:162
int32_t pos_geod(locstruc *loc)
Set Geodetic position.
Definition: convertlib.cpp:576
rvector rv_zero()
Zero row order vector.
Definition: vector.cpp:107
uint8_t * json_ptr_of_entry(const jsonentry &entry, cosmosstruc *cinfo)
Address from entry.
Definition: jsonlib.cpp:3004
cartpos sci
Definition: convertdef.h:738
posstruc pos
posstruc for this time.
Definition: convertdef.h:881
JSON cartpos.
Definition: jsondef.h:224
int32_t pos_selc(locstruc *loc)
Set Selenocentric position.
Definition: convertlib.cpp:428
cartpos eci
Definition: convertdef.h:737
geoidpos geod
Definition: convertdef.h:741
uint32_t pass
pass indicator: allows synchronization with other attitude and position values.
Definition: convertdef.h:269
JSON posstruc.
Definition: jsondef.h:238
cartpos icrf
Definition: convertdef.h:736
JSON Selenocentric Position.
Definition: jsondef.h:253
JSON Solar Barycentric Position.
Definition: jsondef.h:244
Definition: convertdef.h:876
rvector v
Velocity.
Definition: convertdef.h:165
JSON Selenographic Position.
Definition: jsondef.h:259
int32_t json_set_double_name ( double  value,
char *  token,
cosmosstruc cinfo 
)

Set name from double.

If the provided double can in any way be placed in the name it will.

Parameters
valueDouble precision value to be stored in the name space.
tokenValid COSMOS Namespace name.
cinfoReference to cosmosstruc to use.
Returns
Negative error or zero.
4235 {
4236  utype *nval;
4237  jsonentry *ptr;
4238 
4239  if ((ptr=json_entry_of(token, cinfo)) == nullptr)
4240  return 0;
4241 
4242  nval = (utype *)(json_ptr_of_entry(*ptr, cinfo));
4243  switch (ptr->type)
4244  {
4245  case JSON_TYPE_UINT16:
4246  nval->u16 = (uint16_t)(value + .5);
4247  break;
4248  case JSON_TYPE_UINT32:
4249  nval->u32 = (uint32_t)(value + .5);
4250  break;
4251  case JSON_TYPE_INT16:
4252  nval->i16 = (int16_t)(value + .5);
4253  break;
4254  case JSON_TYPE_INT32:
4255  nval->i32 = (int32_t)(value + .5);
4256  break;
4257  case JSON_TYPE_FLOAT:
4258  nval->f = (float)value;
4259  break;
4260  case JSON_TYPE_DOUBLE:
4261  case JSON_TYPE_TIMESTAMP:
4262  nval->d = value;
4263  break;
4264  }
4265  return 0;
4266 }
JSON 16 bit integer type.
Definition: jsondef.h:194
JSON Timestamp.
Definition: jsondef.h:292
double d
Definition: mathlib.h:143
float f
Definition: mathlib.h:144
int32_t i32
Definition: mathlib.h:145
Scalar value type Union.
Definition: mathlib.h:141
uint16_t type
JSON Data Type.
Definition: jsondef.h:4169
jsonentry * json_entry_of(uint8_t *ptr, cosmosstruc *cinfo)
Info on Namespace address.
Definition: jsonlib.cpp:3124
uint32_t u32
Definition: mathlib.h:147
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
JSON map offset entry.
Definition: jsondef.h:4164
uint16_t u16
Definition: mathlib.h:148
JSON 32 bit integer type.
Definition: jsondef.h:196
uint8_t * json_ptr_of_entry(const jsonentry &entry, cosmosstruc *cinfo)
Address from entry.
Definition: jsonlib.cpp:3004
JSON double precision floating vertex type.
Definition: jsondef.h:200
JSON 32 bit unsigned integer type.
Definition: jsondef.h:190
JSON single precision floating vertex type.
Definition: jsondef.h:198
int16_t i16
Definition: mathlib.h:146
double json_equation ( const char *&  ptr,
cosmosstruc cinfo 
)

Return the results of a JSON equation.

At its minimum, a JSON equation will be defined as any two JSON names separated by an operation. Equations bracketed by '()' will be treated as names in their own right and will therefore require a matching operation, and name or bracketed equation. The result will always be assumed to be double precision, even in the case of booleans. Valid operations are:

  • '!': logical NOT
  • '~': bitwise complement
  • '+': addition
  • '-': subtraction
  • '*': multiplication
  • '/': division
  • '': modulo
  • '&': logical AND
  • '|': logical OR
  • '>': logical Greater Than
  • '<': logical Less Than
  • '=': logical Equal
  • '^': power
    Parameters
    ptrPointer to a pointer to a JSON stream.
    cinfoReference to cosmosstruc to use.
    Returns
    Result of the equation, or NAN.
4295 {
4296  string equation;
4297  int32_t iretn;
4299 
4300  if ((iretn=json_parse_equation(ptr, equation)) < 0) {
4301  return (NAN);
4302  }
4303 
4304  if (cinfo->emap.size() == 0) {
4305  return (NAN);
4306  }
4307 
4308  if ((iretn=json_equation_map(equation, cinfo, &handle)) < 0) {
4309  return (NAN);
4310  }
4311 
4312  return(json_equation(&cinfo->emap[handle.hash][handle.index], cinfo));
4313 }
int32_t json_parse_equation(const char *&ptr, string &equation)
Parse the next JSON equation out of a JSON stream.
Definition: jsonlib.cpp:5045
int iretn
Definition: rw_test.cpp:37
vector< vector< jsonequation > > emap
JSON Equation Map matrix.
Definition: jsondef.h:4211
uint16_t hash
Definition: jsondef.h:794
double json_equation(const char *&ptr, cosmosstruc *cinfo)
Return the results of a JSON equation.
Definition: jsonlib.cpp:4294
int32_t json_equation_map(string equation, cosmosstruc *cinfo, jsonhandle *handle)
Get hash and index in JSON Equation map.
Definition: jsonlib.cpp:10609
gige_handle * handle
Definition: kpc9612p_recv.cpp:33
JSON handle.
Definition: jsondef.h:791
uint16_t index
Definition: jsondef.h:796
double json_equation ( jsonhandle handle,
cosmosstruc cinfo 
)

Return the results of a known JSON equation handle.

Calculate a json_equation using already looked up values for the hash and index.

Parameters
handleValues for hash and index that point to an entry in the map.
cinfoReference to cosmosstruc to use.
Returns
Result of the equation, or NAN.
4324 {
4325  return(json_equation(&cinfo->emap[handle->hash][handle->index], cinfo));
4326 }
vector< vector< jsonequation > > emap
JSON Equation Map matrix.
Definition: jsondef.h:4211
uint16_t hash
Definition: jsondef.h:794
double json_equation(const char *&ptr, cosmosstruc *cinfo)
Return the results of a JSON equation.
Definition: jsonlib.cpp:4294
uint16_t index
Definition: jsondef.h:796
double json_equation ( jsonequation ptr,
cosmosstruc cinfo 
)

Return the results of a known JSON equation entry.

Calculate a json_equation using already looked up entry from the map.

Parameters
ptrPointer to a jsonequation from the map.
cinfoReference to cosmosstruc to use.
Returns
Result of the equation, or NAN.
4337 {
4338  double a[2]={0.,0.}, c=NAN;
4339 
4340  for (uint16_t i=0; i<2; ++i)
4341  {
4342  switch(ptr->operand[i].type)
4343  {
4344  case JSON_OPERAND_NULL:
4345  break;
4346  case JSON_OPERAND_CONSTANT:
4347  a[i] = ptr->operand[i].value;
4348  break;
4349  case JSON_OPERAND_EQUATION:
4350  a[i] = json_equation(&cinfo->emap[ptr->operand[i].data.hash][ptr->operand[i].data.index], cinfo);
4351  break;
4352  case JSON_OPERAND_NAME:
4353  a[i] = json_get_double(cinfo->jmap[ptr->operand[i].data.hash][ptr->operand[i].data.index], cinfo);
4354  break;
4355  }
4356  }
4357 
4358  switch(ptr->operation)
4359  {
4360  case JSON_OPERATION_NOT:
4361  c = !static_cast<bool>(a[0]);
4362  break;
4364  c = ~static_cast<uint32_t>(a[0]);
4365  break;
4366  case JSON_OPERATION_ADD:
4367  c = a[0] + a[1];
4368  break;
4370  c = a[0] - a[1];
4371  break;
4373  c = a[0] * a[1];
4374  break;
4375  case JSON_OPERATION_DIVIDE:
4376  c = a[0] / a[1];
4377  break;
4378  case JSON_OPERATION_MOD:
4379  c = fmod(a[0], a[1]);
4380  break;
4381  case JSON_OPERATION_AND:
4382  c = static_cast<int>(a[0]) && static_cast<int>(a[1]);
4383  break;
4384  case JSON_OPERATION_OR:
4385  c = static_cast<int>(a[0]) || static_cast<int>(a[1]);
4386  break;
4387  case JSON_OPERATION_GT:
4388  c = a[0] > a[1];
4389  break;
4390  case JSON_OPERATION_LT:
4391  c = a[0] < a[1];
4392  break;
4393  case JSON_OPERATION_EQ:
4394  c = fabs(a[0] - a[1]) < std::numeric_limits<double>::epsilon();
4395  break;
4396  case JSON_OPERATION_POWER:
4397  c = pow(a[0], a[1]);
4398  break;
4400  c = static_cast<int>(a[0]) & static_cast<int>(a[1]);
4401  break;
4403  c = static_cast<int>(a[0]) | static_cast<int>(a[1]);
4404  }
4405 
4406  return (c);
4407 }
A Namespace name.
Definition: jsondef.h:317
Bitwise OR #.
Definition: jsondef.h:354
Boolean And &.
Definition: jsondef.h:336
int i
Definition: rw_test.cpp:37
uint16_t type
JSON Operand Type.
Definition: jsondef.h:849
jsonoperand operand[2]
JSON equation operands.
Definition: jsondef.h:874
vector< vector< jsonequation > > emap
JSON Equation Map matrix.
Definition: jsondef.h:4211
Boolean Less Than <.
Definition: jsondef.h:342
uint16_t hash
Definition: jsondef.h:794
static double epsilon
Definition: agent_exec-2-0.cpp:140
Subtraction -.
Definition: jsondef.h:328
double json_equation(const char *&ptr, cosmosstruc *cinfo)
Return the results of a JSON equation.
Definition: jsonlib.cpp:4294
Complement ~.
Definition: jsondef.h:348
double json_get_double(jsonhandle &handle, cosmosstruc *cinfo)
Return double from handle.
Definition: jsonlib.cpp:3679
Another equation.
Definition: jsondef.h:319
Modulo %.
Definition: jsondef.h:334
jsonhandle data
Definition: jsondef.h:854
Nothing at all.
Definition: jsondef.h:313
A simple constant.
Definition: jsondef.h:315
Definition: eci2kep_test.cpp:33
Addition +.
Definition: jsondef.h:326
Logical Not !
Definition: jsondef.h:346
Bitwise AND .
Definition: jsondef.h:352
Multiplication *.
Definition: jsondef.h:330
uint16_t index
Definition: jsondef.h:796
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
double value
Definition: jsondef.h:853
Boolean Greater Than >
Definition: jsondef.h:340
Boolean Equal =.
Definition: jsondef.h:344
uint16_t operation
JSON equation operation.
Definition: jsondef.h:872
Division /.
Definition: jsondef.h:332
Power ^.
Definition: jsondef.h:350
Boolean Or |.
Definition: jsondef.h:338
string json_extract_namedmember ( string  json,
string  token 
)

Extract JSON value matching name.

Scan through the provided JSON stream looking for the supplied Namespace name. If it is found, return its value as a character string.

Parameters
jsonA string of JSON data
tokenThe Namespace name to be extracted.
Returns
A character string representing the extracted value, otherwise nullptr.
4418 {
4419  string tstring;
4420  const char *ptr;
4421  int32_t iretn;
4422 
4423  // Look for namespace name in string
4424  if ((ptr=(char*)strstr(json.c_str(), token.c_str())) == nullptr)
4425  {
4426  return tstring;
4427  }
4428  ptr += token.length();
4429 
4430  // Skip over " (which will be there if name was supplied without " "'s around it)
4431  if (ptr[0] == '"')
4432  {
4433  iretn = json_skip_character(ptr, '"');
4434  if (iretn < 0)
4435  {
4436  return tstring;
4437  }
4438  }
4439 
4440  // Skip over :
4441  if ((iretn = json_skip_white(ptr)) < 0)
4442  return tstring;
4443  iretn = json_skip_character(ptr, ':');
4444  if (iretn < 0)
4445  {
4446  return tstring;
4447  }
4448 
4449  // while (ptr[0] != 0 && ptr[0] != ':') ptr++;
4450 
4451  // if ((ptr)[0] == 0) return (tstring);
4452 
4453  // Skip over any white space
4454  iretn = json_skip_white(ptr);
4455  if (iretn < 0)
4456  {
4457  return tstring;
4458  }
4459 
4460  // ptr++;
4461  // while (ptr[0] != 0 && isspace(ptr[0])) ptr++;
4462 
4463  // if (ptr[0] == 0) return (tstring);
4464 
4465  // Extract next JSON value
4466  iretn = json_extract_value(ptr, tstring);
4467  return tstring;
4468 }
int iretn
Definition: rw_test.cpp:37
int32_t json_extract_value(const char *&ptr, string &value)
Extract next JSON value.
Definition: jsonlib.cpp:4477
int32_t json_skip_white(const char *&ptr)
Skip white space in JSON string.
Definition: jsonlib.cpp:5336
int32_t json_skip_character(const char *&ptr, const char character)
Skip over a specific character in a JSON stream.
Definition: jsonlib.cpp:4972
int32_t json_extract_value ( const char *&  ptr,
string &  value 
)

Extract next JSON value.

Extract the next JSON value from the provided string. If it is found, return its value as a string.

Parameters
ptrPointer to a pointer to a JSON stream.
valueReference to extracted string.
Returns
The length of the returned string.
4478 {
4479  const char *bptr, *eptr;
4480  uint32_t count;
4481  int32_t iretn = 0;
4482 
4483  bptr = ptr;
4484  switch (ptr[0])
4485  {
4486  case '{':
4487  count = 1;
4488  do
4489  {
4490  ++ptr;
4491  switch (ptr[0])
4492  {
4493  case '}':
4494  --count;
4495  break;
4496  case '{':
4497  ++count;
4498  break;
4499  case 0:
4500  return (iretn=JSON_ERROR_EOS);
4501  }
4502  } while (count);
4503  eptr = ptr;
4504  ptr++;
4505  break;
4506  case '[':
4507  count = 1;
4508  do
4509  {
4510  ++ptr;
4511  switch (ptr[0])
4512  {
4513  case ']':
4514  --count;
4515  break;
4516  case '[':
4517  ++count;
4518  break;
4519  case 0:
4520  return (iretn=JSON_ERROR_EOS);
4521  }
4522  } while (count);
4523  eptr = ptr;
4524  ptr++;
4525  break;
4526  case '"':
4527  do
4528  {
4529  ++ptr;
4530  if (ptr[0]==0) return (iretn=JSON_ERROR_EOS);
4531  } while (ptr[0] != '"');
4532  eptr = ptr;
4533  ptr++;
4534  break;
4535  default:
4536  do
4537  {
4538  ++ptr;
4539  } while ((ptr[0]>='0'&&ptr[0]<='9')||ptr[0]=='e'||ptr[0]=='E'||ptr[0]=='.'||ptr[0]=='-');
4540  eptr = ptr-1;
4541  break;
4542  }
4543 
4544  value = bptr;
4545  value.resize(eptr-bptr+1);
4546 
4547  return iretn;
4548 }
int count
Definition: rw_test.cpp:36
int iretn
Definition: rw_test.cpp:37
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
string json_convert_string ( string  object)

Convert JSON to string.

Convert the supplied JSON Object to a string representation. If the supplied Object does not have the proper format for a JSON string, an empty string will be returned.

Parameters
objectFully formed JSON object.
Returns
Object as string, or empty string.
4558 {
4559  string result;
4560  const char *ptr = &object[0];
4561 
4562  json_extract_string(ptr, result);
4563 
4564  return result;
4565 }
int32_t json_extract_string(const char *&ptr, string &ostring)
Parse the next JSON string out of a JSON stream.
Definition: jsonlib.cpp:5186
double json_convert_double ( string  object)

Convert JSON to double.

Convert the supplied JSON Object to a double representation. If the supplied Object does not have the proper format for a double, zero be returned.

Parameters
objectFully formed JSON object.
Returns
Object as double, or zero.
4575 {
4576  double dresult;
4577 
4578  if (!object.empty())
4579  {
4580  dresult = atof(object.c_str());
4581  return dresult;
4582  }
4583  else
4584  {
4585  dresult = 0;
4586  }
4587 
4588  return dresult;
4589 }
int32_t json_tokenize ( string  jstring,
cosmosstruc cinfo,
vector< jsontoken > &  tokens 
)

Tokenize using JSON Name Space.

Scan through the provided JSON stream, matching names to the ::jsonmap. for each match that is found, create a jsontoken entry and add it to a vector of tokens.

Parameters
jstringstring containing JSON stream.
tokensvector of jsontoken.
Returns
Zero or negative error.
4601 {
4602  const char *cpoint;
4603  size_t length;
4604  int32_t iretn;
4605  jsontoken ttoken;
4606 
4607  string val = json_extract_namedmember(jstring, "node_utc");
4608  if (val.length()!=0) ttoken.utc = json_convert_double(val);
4609  else
4610  {
4611  //Some older sets of telemetry do not include "node_utc" so the utc must be found elsewhere:
4612  if ((val = json_extract_namedmember(jstring, "node_loc_pos_eci")).length()!=0)
4613  {
4614  if ((val=json_extract_namedmember(val, "utc")).length()!=0) ttoken.utc = json_convert_double(val);
4615  }
4616  }
4617 
4618  length = jstring.size();
4619  cpoint = &jstring[0];
4620  while (*cpoint != 0 && *cpoint != '{')
4621  cpoint++;
4622  tokens.clear();
4623  do
4624  {
4625  if (*cpoint != 0)
4626  {
4627  if ((iretn = json_tokenize_namedmember(cpoint, cinfo, ttoken)) < 0)
4628  {
4629  if (iretn != JSON_ERROR_EOS && iretn != JSON_ERROR_NOJMAP)
4630  iretn = 0;
4631  }
4632  else
4633  {
4634  tokens.push_back(ttoken);
4635  }
4636  }
4637  else
4638  iretn = JSON_ERROR_EOS;
4639  } while (iretn != JSON_ERROR_EOS && iretn != JSON_ERROR_NOJMAP && *cpoint != 0 && (size_t)(cpoint-&jstring[0]) <= length);
4640 
4641  if (!iretn) iretn = (int32_t)tokens.size();
4642  return iretn;
4643 }
double utc
Definition: jsondef.h:837
#define JSON_ERROR_NOJMAP
Definition: cosmos-errno.h:93
int iretn
Definition: rw_test.cpp:37
string json_extract_namedmember(string json, string token)
Extract JSON value matching name.
Definition: jsonlib.cpp:4417
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
int32_t json_tokenize_namedmember(const char *&ptr, cosmosstruc *cinfo, jsontoken &token)
Tokenize next JSON Named Pair.
Definition: jsonlib.cpp:4653
double json_convert_double(string object)
Convert JSON to double.
Definition: jsonlib.cpp:4574
JSON token.
Definition: jsondef.h:833
png_uint_32 length
Definition: png.c:2173
int32_t json_tokenize_namedmember ( const char *&  ptr,
cosmosstruc cinfo,
jsontoken token 
)

Tokenize next JSON Named Pair.

Extract the next Named Pair from the provided JSON stream and place it in a jsontoken. Leave pointer at the next Object in the string.

Parameters
ptrPointer to a pointer to a JSON stream.
tokenjsontoken to return.
Returns
Zero, or a negative error.
4654 {
4655  int32_t iretn=0;
4656  string ostring;
4657  uint16_t hash, index;
4658 
4659  if (!(cinfo->jmapped))
4660  {
4661  return (JSON_ERROR_NOJMAP);
4662  }
4663 
4664  // Skip over opening brace
4665  if (ptr[0] != '{')
4666  {
4667  if ((iretn = json_skip_to_next_member(ptr)) < 0)
4668  return iretn;
4669  else
4670  return (JSON_ERROR_SCAN);
4671  }
4672 
4673  ptr++;
4674 
4675  // Extract string that should hold name of this object.
4676  if ((iretn = json_extract_string(ptr, ostring)) < 0)
4677  {
4678  if (iretn != JSON_ERROR_EOS)
4679  {
4680  if ((iretn = json_skip_to_next_member(ptr)) < 0)
4681  return iretn;
4682  else
4683  return (JSON_ERROR_SCAN);
4684  }
4685  else
4686  return iretn;
4687  }
4688  // Calculate hash
4689  hash = json_hash(ostring);
4690 
4691  // See if there is a match in the ::jsonmap.
4692  for (index=0; index<cinfo->jmap[hash].size(); ++index) {
4693  if (ostring == cinfo->jmap[hash][index].name)
4694  {
4695  break;
4696  }
4697  }
4698 
4699  if (index == cinfo->jmap[hash].size())
4700  {
4701  if ((iretn = json_skip_to_next_member(ptr)) < 0 && iretn != JSON_ERROR_EOS)
4702  {
4703  return iretn;
4704  }
4705  else
4706  return (JSON_ERROR_NOENTRY);
4707  }
4708  else
4709  {
4710  // Skip white space before separator
4711  if ((iretn = json_skip_white(ptr)) < 0)
4712  {
4713  if (iretn != JSON_ERROR_EOS)
4714  {
4715  if ((iretn = json_skip_to_next_member(ptr)) < 0)
4716  return iretn;
4717  else
4718  return (JSON_ERROR_SCAN);
4719  }
4720  else
4721  return iretn;
4722  }
4723  // Skip separator
4724  if ((iretn = json_skip_character(ptr,':')) < 0)
4725  {
4726  if (iretn != JSON_ERROR_EOS)
4727  {
4728  if ((iretn = json_skip_to_next_member(ptr)) < 0)
4729  return iretn;
4730  else
4731  return (JSON_ERROR_SCAN);
4732  }
4733  else
4734  return iretn;
4735  }
4736  // Skip white space before value
4737  if ((iretn = json_skip_white(ptr)) < 0)
4738  {
4739  if (iretn != JSON_ERROR_EOS)
4740  {
4741  if ((iretn = json_skip_to_next_member(ptr)) < 0)
4742  return iretn;
4743  else
4744  return (JSON_ERROR_SCAN);
4745  }
4746  else
4747  return iretn;
4748  }
4749  // Read value
4750  string input;
4751  if ((iretn = json_extract_value(ptr, input)) < 0)
4752  {
4753  if (iretn != JSON_ERROR_EOS)
4754  {
4755  if ((iretn = json_skip_to_next_member(ptr)) < 0)
4756  return iretn;
4757  else
4758  return (JSON_ERROR_SCAN);
4759  }
4760  else
4761  return iretn;
4762  }
4763  if (input.size())
4764  {
4765  token.value = input;
4766  token.handle.hash = hash;
4767  token.handle.index = index;
4768  }
4769  //Skip whitespace after value
4770  if ((iretn = json_skip_white(ptr)) < 0)
4771  {
4772  return iretn;
4773  }
4774  // Skip over closing brace
4775  if ((iretn = json_skip_character(ptr,'}')) < 0)
4776  {
4777  if ((iretn = json_skip_to_next_member(ptr)) < 0)
4778  return iretn;
4779  else
4780  return (JSON_ERROR_SCAN);
4781  }
4782  }
4783 
4784  // ptr++;
4785  json_skip_white(ptr);
4786  return iretn;
4787 }
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
jsonhandle handle
Definition: jsondef.h:835
#define JSON_ERROR_NOJMAP
Definition: cosmos-errno.h:93
int iretn
Definition: rw_test.cpp:37
#define JSON_ERROR_NOENTRY
Definition: cosmos-errno.h:94
int32_t json_extract_value(const char *&ptr, string &value)
Extract next JSON value.
Definition: jsonlib.cpp:4477
uint16_t hash
Definition: jsondef.h:794
int32_t json_skip_white(const char *&ptr)
Skip white space in JSON string.
Definition: jsonlib.cpp:5336
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
string value
Definition: jsondef.h:836
int32_t json_skip_to_next_member(const char *&ptr)
Skip to next COSMOS name in JSON string.
Definition: jsonlib.cpp:5354
int32_t json_extract_string(const char *&ptr, string &ostring)
Parse the next JSON string out of a JSON stream.
Definition: jsonlib.cpp:5186
#define JSON_ERROR_SCAN
Definition: cosmos-errno.h:96
int32_t json_skip_character(const char *&ptr, const char character)
Skip over a specific character in a JSON stream.
Definition: jsonlib.cpp:4972
uint16_t index
Definition: jsondef.h:796
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
uint16_t json_hash(string hstring)
Calculate JSON HASH.
Definition: jsonlib.cpp:504
int32_t json_parse ( string  jstring,
cosmosstruc cinfo 
)

Parse JSON using Name Space.

Scan through the provided JSON stream, matching names to the ::jsonmap. For each match that is found, load the associated data item with the accompanying data. This function supports complex data types.

Parameters
jstringA string of JSON data
cinfoReference to cosmosstruc to use.
Returns
Zero or negative error.
4800 {
4801  const char *cpoint;
4802  size_t length;
4803  int32_t iretn;
4804  uint32_t count = 0;
4805 
4806  length = jstring.size();
4807  cpoint = &jstring[0];
4808  while (*cpoint != 0 && *cpoint != '{' && *cpoint != ',' ) //advance until you find a '{' or ','
4809  cpoint++;
4810  do
4811  {
4812  // is this the only reference to endlines?
4813  if (*cpoint != 0)// && *cpoint != '\r' && *cpoint != '\n')
4814  //if (*cpoint != 0 && *cpoint != '\r' && *cpoint != '\n')
4815  {
4816  if ((iretn = json_parse_namedmember(cpoint, cinfo)) < 0)
4817  {
4818  if (iretn != JSON_ERROR_EOS && iretn != JSON_ERROR_NOJMAP)
4819  iretn = 0;
4820  }
4821  else
4822  {
4823  ++count;
4824  }
4825  }
4826  else
4827  iretn = JSON_ERROR_EOS;
4828  } while (iretn != JSON_ERROR_EOS && iretn != JSON_ERROR_NOJMAP && *cpoint != 0 && (size_t)(cpoint-&jstring[0]) <= length);
4829 
4830  if (iretn >= 0)
4831  {
4832 
4833  cinfo->timestamp = currentmjd();
4834  iretn = count;
4835  }
4836  return iretn;
4837 }
double timestamp
Timestamp for last change to data.
Definition: jsondef.h:4202
#define JSON_ERROR_NOJMAP
Definition: cosmos-errno.h:93
int count
Definition: rw_test.cpp:36
int iretn
Definition: rw_test.cpp:37
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
int32_t json_parse_namedmember(const char *&ptr, cosmosstruc *cinfo)
Parse next JSON Named Pair.
Definition: jsonlib.cpp:4847
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
png_uint_32 length
Definition: png.c:2173
int32_t json_parse_namedmember ( const char *&  ptr,
cosmosstruc cinfo 
)

Parse next JSON Named Pair.

Extract the next Named Pair from the provided JSON stream. Return a pointer to the next Object in the string, and an error flag.

Parameters
ptrPointer to a pointer to a JSON stream.
cinfoReference to cosmosstruc to use.
Returns
Zero, or a negative error.
4848 {
4849  uint32_t hash;
4850  int32_t iretn=0;
4851  string ostring;
4852 
4853  if (!(cinfo->jmapped))
4854  {
4855  return (JSON_ERROR_NOJMAP);
4856  }
4857 
4858  if (ptr[0] != '{' && ptr[0] != ',') //verify that there is a '{' or ','
4859  {
4860  if ((iretn = json_skip_to_next_member(ptr)) < 0)
4861  return iretn;
4862  else
4863  return (JSON_ERROR_SCAN);
4864  }
4865 
4866  ptr++; //move forward from '{' or ',' to '"' ?
4867 
4868  // Extract string that should hold name of this member.
4869  if ((iretn = json_extract_string(ptr, ostring)) < 0)
4870  {
4871  if (iretn != JSON_ERROR_EOS)
4872  {
4873  if ((iretn = json_skip_to_next_member(ptr)) < 0)
4874  return iretn;
4875  else
4876  return (JSON_ERROR_SCAN);
4877  }
4878  else
4879  return iretn;
4880  }
4881 
4882  if(ostring.find("$$_") == 0)
4883  {
4884  ostring = ostring.substr(3);
4885  }
4886 
4887 
4888  // Calculate hash of Namespace name
4889  hash = json_hash(ostring);
4890 
4891  // See if there is a match in the ::jsonmap.
4892  size_t n;
4893  for (n=0; n<cinfo->jmap[hash].size(); ++n) //check through every column in the row (using hash) exit loop if the name matches
4894  {
4895  if (ostring == cinfo->jmap[hash][n].name)
4896  {
4897  break;
4898  }
4899  }
4900 
4901  if (n == cinfo->jmap[hash].size()) //if there was no match
4902  {
4903  if ((iretn = json_skip_to_next_member(ptr)) < 0 && iretn != JSON_ERROR_EOS)
4904  {
4905  return iretn;
4906  }
4907  else
4908  return (JSON_ERROR_NOENTRY);
4909  }
4910  else //if a match was found
4911  {
4912  if ((iretn = json_skip_white(ptr)) < 0) //skip the white space
4913  {
4914  if (iretn != JSON_ERROR_EOS)
4915  {
4916  if ((iretn = json_skip_to_next_member(ptr)) < 0)
4917  return iretn;
4918  else
4919  return (JSON_ERROR_SCAN);
4920  }
4921  else
4922  return iretn;
4923  }
4924  if ((iretn = json_skip_character(ptr,':')) < 0) //skip the ':' before the value
4925  {
4926  if (iretn != JSON_ERROR_EOS)
4927  {
4928  if ((iretn = json_skip_to_next_member(ptr)) < 0)
4929  return iretn;
4930  else
4931  return (JSON_ERROR_SCAN);
4932  }
4933  else
4934  return iretn;
4935  }
4936  // enter value into the structs using pointer
4937  if ((iretn = json_parse_value(ptr, cinfo->jmap[hash][n], cinfo)) < 0)
4938  {
4939  if (iretn != JSON_ERROR_EOS)
4940  {
4941  if ((iretn = json_skip_to_next_member(ptr)) < 0)
4942  return iretn;
4943  else
4944  return (JSON_ERROR_SCAN);
4945  }
4946  else
4947  {
4948  return iretn;
4949  }
4950  }
4951  }
4952 
4953  // ptr++;
4954  json_skip_white(ptr);
4955  json_skip_character(ptr, '}');
4956  json_skip_white(ptr);
4957  if (iretn >= 0)
4958  {
4959  cinfo->jmap[hash][n].enabled = true;
4960  }
4961  return iretn;
4962 }
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
#define JSON_ERROR_NOJMAP
Definition: cosmos-errno.h:93
int iretn
Definition: rw_test.cpp:37
#define JSON_ERROR_NOENTRY
Definition: cosmos-errno.h:94
int32_t json_skip_white(const char *&ptr)
Skip white space in JSON string.
Definition: jsonlib.cpp:5336
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
int32_t json_skip_to_next_member(const char *&ptr)
Skip to next COSMOS name in JSON string.
Definition: jsonlib.cpp:5354
int32_t json_extract_string(const char *&ptr, string &ostring)
Parse the next JSON string out of a JSON stream.
Definition: jsonlib.cpp:5186
int32_t json_parse_value(const char *&ptr, const jsonentry &entry, cosmosstruc *cinfo)
Definition: jsonlib.cpp:5480
#define JSON_ERROR_SCAN
Definition: cosmos-errno.h:96
int32_t json_skip_character(const char *&ptr, const char character)
Skip over a specific character in a JSON stream.
Definition: jsonlib.cpp:4972
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
uint16_t json_hash(string hstring)
Calculate JSON HASH.
Definition: jsonlib.cpp:504
int32_t json_skip_character ( const char *&  ptr,
const char  character 
)

Skip over a specific character in a JSON stream.

Look for the specified character in the provided JSON stream and flag an error if it's not there. Otherwise, increment the pointer to the next byte in the string.

Parameters
ptrPointer to a pointer to a JSON stream.
characterThe character to look for.
Returns
Zero or a negative error.
4973 {
4974  int32_t iretn;
4975 
4976  iretn = json_skip_white(ptr);
4977  if (iretn < 0)
4978  {
4979  return iretn;
4980  }
4981 
4982  if (ptr[0] == 0)
4983  {
4984  return (JSON_ERROR_EOS);
4985  }
4986 
4987  if (ptr[0] != character)
4988  {
4989  return (JSON_ERROR_SCAN);
4990  }
4991  ptr++;
4992 
4993  return (0);
4994 }
int iretn
Definition: rw_test.cpp:37
int32_t json_skip_white(const char *&ptr)
Skip white space in JSON string.
Definition: jsonlib.cpp:5336
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
#define JSON_ERROR_SCAN
Definition: cosmos-errno.h:96
int32_t json_extract_name ( const char *&  ptr,
string &  ostring 
)

Parse the next variable name out of a JSON stream.

Look for a valid JSON string, followed by a ':' and copy that name to the provided buffer, otherwise flag an error.

Parameters
ptrPointer to a pointer to a JSON stream.
ostringPointer to a location to copy the string.
Returns
Zero, otherwise negative error.
5004 {
5005  int32_t iretn = 0;
5006 
5007  if (ptr[0] == 0)
5008  return (JSON_ERROR_EOS);
5009 
5010  //Skip whitespace before name
5011  if ((iretn = json_skip_white(ptr)) < 0)
5012  {
5013  return iretn;
5014  }
5015 
5016  //Parse name
5017  if ((iretn = json_extract_string(ptr, ostring)) < 0)
5018  return iretn;
5019 
5020  //Skip whitespace after name
5021  if ((iretn = json_skip_white(ptr)) < 0)
5022  {
5023  return iretn;
5024  }
5025 
5026  if ((iretn = json_skip_character(ptr, ':')) < 0)
5027  return iretn;
5028 
5029  //Skip whitespace after seperator
5030  if ((iretn = json_skip_white(ptr)) < 0)
5031  {
5032  return iretn;
5033  }
5034 
5035  return iretn;
5036 }
int iretn
Definition: rw_test.cpp:37
int32_t json_skip_white(const char *&ptr)
Skip white space in JSON string.
Definition: jsonlib.cpp:5336
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
int32_t json_extract_string(const char *&ptr, string &ostring)
Parse the next JSON string out of a JSON stream.
Definition: jsonlib.cpp:5186
int32_t json_skip_character(const char *&ptr, const char character)
Skip over a specific character in a JSON stream.
Definition: jsonlib.cpp:4972
int32_t json_parse_equation ( const char *&  ptr,
string &  equation 
)

Parse the next JSON equation out of a JSON stream.

Look for a valid JSON equation in the provided JSON stream and copy it to the provided buffer. Otherwise flag an error.

Parameters
ptrPointer to a pointer to a JSON stream.
equationReference to a location to copy the equation.
Returns
Zero, otherwise negative error.
5046 {
5047  int32_t iretn = 0;
5048  uint16_t i2;
5049  uint16_t index, depth=1;
5050  size_t ilen;
5051 
5052  if (ptr[0] == 0)
5053  return (JSON_ERROR_EOS);
5054 
5055  // Skip white space before '('
5056  if ((iretn=json_skip_white(ptr)) < 0)
5057  {
5058  return(JSON_ERROR_SCAN);
5059  }
5060 
5061  // Check if it's an equation. All equations must begin with '(' and end with ')'
5062  if (ptr[0] != '(')
5063  {
5064  return(JSON_ERROR_SCAN);
5065  }
5066 
5067  ilen = strlen(ptr);
5068 
5069  // Start of object, get equation
5070  index = 0;
5071  equation.push_back(ptr[0]);
5072  for (i2=1; i2<ilen; i2++)
5073  {
5074  if (index == JSON_MAX_DATA-1)
5075  break;
5076  switch(ptr[i2])
5077  {
5078  case ' ':
5079  case '\t':
5080  case '\f':
5081  case '\n':
5082  case '\r':
5083  case '\v':
5084  break;
5085  case ')':
5086  --depth;
5087  equation.push_back(ptr[i2]);
5088  break;
5089  case '(':
5090  ++depth;
5091  equation.push_back(ptr[i2]);
5092  break;
5093  default:
5094  equation.push_back(ptr[i2]);
5095  break;
5096  }
5097  if (!depth)
5098  break;
5099  }
5100 
5101  if (i2 >= ilen)
5102  {
5103  ptr = &ptr[ilen-1];
5104  return(JSON_ERROR_SCAN);
5105  }
5106 
5107  ptr = &ptr[i2+1];
5108 
5109  return iretn;
5110 }
int iretn
Definition: rw_test.cpp:37
int32_t json_skip_white(const char *&ptr)
Skip white space in JSON string.
Definition: jsonlib.cpp:5336
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
#define JSON_ERROR_SCAN
Definition: cosmos-errno.h:96
#define JSON_MAX_DATA
Largest JSON data.
Definition: jsondef.h:427
int32_t json_parse_operand ( const char *&  ptr,
jsonoperand operand,
cosmosstruc cinfo 
)

Parse the next JSON equation operand out of a JSON stream.

Look for a valid JSON equation operand in the provided JSON stream and copy it to a jsonoperand.

Parameters
ptrPointer to a pointer to a JSON stream.
operandPointer to a jsonoperand.
Returns
Zero, otherwise negative error.
5121 {
5122  string tstring;
5123  int32_t iretn;
5124 
5125  json_skip_white(ptr);
5126  switch(ptr[0])
5127  {
5128  case '(':
5129  // It's an equation
5130  if ((iretn=json_parse_equation(ptr, tstring)) < 0)
5131  {
5132  return (JSON_ERROR_SCAN);
5133  }
5134  if ((iretn=json_equation_map(tstring, cinfo, &operand->data)) < 0)
5135  {
5136  return (JSON_ERROR_SCAN);
5137  }
5138  operand->type = JSON_OPERAND_EQUATION;
5139  break;
5140  case '"':
5141  // It's a string
5142  if ((iretn=json_extract_string(ptr, tstring)) < 0)
5143  {
5144  return (JSON_ERROR_SCAN);
5145  }
5146  if ((iretn=json_name_map(tstring, cinfo, operand->data)) < 0)
5147  {
5148  return (JSON_ERROR_SCAN);
5149  }
5150  operand->type = JSON_OPERAND_NAME;
5151  break;
5152  case '0':
5153  case '1':
5154  case '2':
5155  case '3':
5156  case '4':
5157  case '5':
5158  case '6':
5159  case '7':
5160  case '8':
5161  case '9':
5162  case '+':
5163  case '-':
5164  case '.':
5165  case '%':
5166  // It's a constant
5167  operand->type = JSON_OPERAND_CONSTANT;
5168  if ((iretn=json_parse_number(ptr,&operand->value)) < 0)
5169  return (JSON_ERROR_SCAN);
5170  break;
5171  default:
5172  operand->type = JSON_OPERAND_NULL;
5173  break;
5174  }
5175 
5176  return 0;
5177 }
A Namespace name.
Definition: jsondef.h:317
uint16_t type
JSON Operand Type.
Definition: jsondef.h:849
int32_t json_parse_equation(const char *&ptr, string &equation)
Parse the next JSON equation out of a JSON stream.
Definition: jsonlib.cpp:5045
int iretn
Definition: rw_test.cpp:37
int32_t json_skip_white(const char *&ptr)
Skip white space in JSON string.
Definition: jsonlib.cpp:5336
int32_t json_parse_number(const char *&ptr, double *number)
Parse the next number out of a JSON stream.
Definition: jsonlib.cpp:5269
int32_t json_equation_map(string equation, cosmosstruc *cinfo, jsonhandle *handle)
Get hash and index in JSON Equation map.
Definition: jsonlib.cpp:10609
int32_t json_extract_string(const char *&ptr, string &ostring)
Parse the next JSON string out of a JSON stream.
Definition: jsonlib.cpp:5186
int32_t json_name_map(string name, cosmosstruc *cinfo, jsonhandle &handle)
Get hash and index in JSON Namespace map.
Definition: jsonlib.cpp:10581
Another equation.
Definition: jsondef.h:319
jsonhandle data
Definition: jsondef.h:854
Nothing at all.
Definition: jsondef.h:313
A simple constant.
Definition: jsondef.h:315
#define JSON_ERROR_SCAN
Definition: cosmos-errno.h:96
double value
Definition: jsondef.h:853
int32_t json_extract_string ( const char *&  ptr,
string &  ostring 
)

Parse the next JSON string out of a JSON stream.

Look for a valid JSON string in the provided JSON stream and copy it to the provided buffer. Otherwise flag an error.

Parameters
ptrPointer to a pointer to a JSON stream.
ostringPointer to a location to copy the string.
Returns
Zero, otherwise negative error.
5187 {
5188  int32_t iretn = 0;
5189  uint32_t i2;
5190  size_t ilen;
5191 
5192  if (ptr[0] == 0)
5193  return (JSON_ERROR_EOS);
5194 
5195  //Skip whitespace before string
5196  if ((iretn = json_skip_white(ptr)) < 0)
5197  {
5198  return iretn;
5199  }
5200 
5201  ilen = strlen(ptr);
5202 
5203  // Start of object, get string
5204  ostring.clear();
5205  for (i2=1; i2<ilen; i2++) //start from ptr[1] rather than ptr[0] which is a '"'?
5206  {
5207  if (ptr[i2] == '"')
5208  break; //exits for loop?
5209  if (ptr[i2] == '\\')
5210  {
5211  switch (ptr[i2+1])
5212  {
5213  case '"':
5214  case '\\':
5215  case '/':
5216  ostring.push_back(ptr[i2+1]);
5217  break;
5218  case 'b':
5219  ostring.push_back('\b');
5220  break;
5221  case 'f':
5222  ostring.push_back('\f');
5223  break;
5224  case 'n':
5225  ostring.push_back('\n');
5226  break;
5227  case 'r':
5228  ostring.push_back('\r');
5229  break;
5230  case 't':
5231  ostring.push_back('\t');
5232  break;
5233  default:
5234  i2 += 3;
5235  }
5236  i2++;
5237  }
5238  else
5239  {
5240  ostring.push_back(ptr[i2]);
5241  }
5242  }
5243 
5244  if (i2 >= ilen)
5245  {
5246  ptr = &ptr[ilen-1];
5247  return(JSON_ERROR_SCAN);
5248  }
5249 
5250  // i2 is last character in string +1, index is length of extracted string
5251  if (ostring.size() >= JSON_MAX_DATA)
5252  {
5253  ostring.resize(JSON_MAX_DATA-1);
5254  }
5255 
5256  ptr = &ptr[i2+1];
5257 
5258  return iretn;
5259 }
int iretn
Definition: rw_test.cpp:37
int32_t json_skip_white(const char *&ptr)
Skip white space in JSON string.
Definition: jsonlib.cpp:5336
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
#define JSON_ERROR_SCAN
Definition: cosmos-errno.h:96
#define JSON_MAX_DATA
Largest JSON data.
Definition: jsondef.h:427
int32_t json_parse_number ( const char *&  ptr,
double *  number 
)

Parse the next number out of a JSON stream.

Extract a valid number out of the provided JSON stream, otherwise flag an error.

Parameters
ptrPointer to a pointer to a JSON stream.
numberExtracted number in double precission.
Returns
Zero or negative error.
5270 {
5271  int32_t iretn = 0;
5272  uint32_t i1;
5273  size_t ilen;
5274 
5275  if (ptr[0] == 0)
5276  return (JSON_ERROR_EOS);
5277 
5278  //Skip whitespace before number
5279  if ((iretn = json_skip_white(ptr)) < 0)
5280  {
5281  return iretn;
5282  }
5283  ilen = strlen(ptr);
5284 
5285  // First, check for integer: series of digits
5286  i1 = 0;
5287  if (ptr[i1] == '-' || ptr[i1] == '+')
5288  {
5289  ++i1;
5290  }
5291  while (i1 < ilen && ptr[i1] >= '0' && ptr[i1] <= '9')
5292  {
5293  ++i1;
5294  }
5295 
5296  // Second, check for fraction: . followed by series of digits
5297  if (ptr[i1] == '.')
5298  {
5299  ++i1;
5300  while (i1 < ilen && ptr[i1] >= '0' && ptr[i1] <= '9')
5301  {
5302  ++i1;
5303  }
5304  }
5305 
5306  // Third, check for exponent: e or E followed by optional +/- and series of digits
5307  if (ptr[i1] == 'e' || ptr[i1] == 'E')
5308  {
5309  ++i1;
5310  if (ptr[i1] == '-' || ptr[i1] == '+')
5311  {
5312  ++i1;
5313  }
5314  if (ptr[i1] == '+')
5315  {
5316  ++i1;
5317  }
5318  while (i1 < ilen && ptr[i1] >= '0' && ptr[i1] <= '9')
5319  {
5320  ++i1;
5321  }
5322  }
5323 
5324  // Finally, scan resulting string and move pointer to new location: i1 equals first position after number
5325  sscanf(ptr,"%lf",number);
5326  ptr = &ptr[i1];
5327  return iretn;
5328 }
int iretn
Definition: rw_test.cpp:37
int32_t json_skip_white(const char *&ptr)
Skip white space in JSON string.
Definition: jsonlib.cpp:5336
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
int32_t json_skip_white ( const char *&  ptr)

Skip white space in JSON string.

Skip over any white space characters, leaving pointer at next non white space.

Parameters
ptrDouble pointer to the JSON string
Returns
Zero, or negative error.
5337 {
5338  if (ptr[0] == 0)
5339  return (JSON_ERROR_EOS);
5340 
5341  while (ptr[0] != 0 && isspace(ptr[0])) ptr++;
5342 
5343  if (ptr[0] == 0)
5344  return (JSON_ERROR_EOS);
5345  else
5346  return 0;
5347 }
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
int32_t json_skip_to_next_member ( const char *&  ptr)

Skip to next COSMOS name in JSON string.

Skip over characters until you reach the next COSMOS Namespace name in a JSON string.

Parameters
ptrDouble pointer to the JSON string
Returns
Zero, or negative error.
5355 {
5356  int32_t iretn;
5357 
5358  if (ptr[0] == 0)
5359  {
5360  return (JSON_ERROR_EOS);
5361  }
5362 
5363  do
5364  {
5365  if (ptr[0] == '\\')
5366  {
5367  ptr++;
5368  if (ptr[0] == 0)
5369  {
5370  break;
5371  }
5372  }
5373  else if (ptr[0] == '{' || ptr[0] == ',')
5374  {
5375  if (ptr[1] == 0)
5376  {
5377  break;
5378  }
5379  if (ptr[1] == '"')
5380  {
5381  string tstring;
5382  const char * cptr = ptr+1;
5383  iretn = json_extract_string(cptr, tstring);
5384  if (iretn < 0)
5385  {
5386  ptr = cptr;
5387  return iretn;
5388  }
5389  if (cptr[0] == ':')
5390  {
5391  return 0;
5392  }
5393  }
5394  }
5395  ptr++;
5396  } while (ptr[0] != 0);
5397 
5398  return (JSON_ERROR_EOS);
5399 }
int iretn
Definition: rw_test.cpp:37
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
int32_t json_extract_string(const char *&ptr, string &ostring)
Parse the next JSON string out of a JSON stream.
Definition: jsonlib.cpp:5186
int32_t json_set_string ( string  val,
const jsonentry entry,
cosmosstruc cinfo 
)
5402 {
5403  uint8_t *data;
5404 
5405  data = json_ptr_of_entry(entry, cinfo);
5406  if (data == nullptr)
5407  {
5408  return JSON_ERROR_NAN;
5409  }
5410 
5411  switch (entry.type)
5412  {
5413  case JSON_TYPE_UINT8:
5414  *(uint8_t *)data = stoi(val);
5415  break;
5416  case JSON_TYPE_INT8:
5417  *(int8_t *)data = stoi(val);
5418  break;
5419  case JSON_TYPE_UINT16:
5420  *(uint16_t *)data = stoi(val);
5421  break;
5422  case JSON_TYPE_UINT32:
5423  *(uint32_t *)data = stol(val);
5424  break;
5425  case JSON_TYPE_INT16:
5426  *(int16_t *)data = stoi(val);
5427  break;
5428  case JSON_TYPE_INT32:
5429  *(int32_t *)data = stol(val);
5430  break;
5431  case JSON_TYPE_FLOAT:
5432  *(float *)data = stof(val);
5433  break;
5434  case JSON_TYPE_TIMESTAMP:
5435  case JSON_TYPE_DOUBLE:
5436  *(double *)data = stod(val);
5437  break;
5438  }
5439  return 0;
5440 }
JSON 16 bit integer type.
Definition: jsondef.h:194
JSON Timestamp.
Definition: jsondef.h:292
JSON 8 bit unsigned integer type.
Definition: jsondef.h:182
uint16_t type
JSON Data Type.
Definition: jsondef.h:4169
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
JSON 32 bit integer type.
Definition: jsondef.h:196
#define JSON_ERROR_NAN
Definition: cosmos-errno.h:98
uint8_t * json_ptr_of_entry(const jsonentry &entry, cosmosstruc *cinfo)
Address from entry.
Definition: jsonlib.cpp:3004
JSON double precision floating vertex type.
Definition: jsondef.h:200
JSON 8 bit signed integer type.
Definition: jsondef.h:184
JSON 32 bit unsigned integer type.
Definition: jsondef.h:190
JSON single precision floating vertex type.
Definition: jsondef.h:198
int32_t json_set_number ( double  val,
const jsonentry entry,
cosmosstruc cinfo 
)
5443 {
5444  uint8_t *data;
5445  int32_t iretn = 0;
5446 
5447  data = json_ptr_of_entry(entry, cinfo);
5448 
5449  switch (entry.type)
5450  {
5451  case JSON_TYPE_UINT8:
5452  *(uint8_t *)data = (uint8_t)val;
5453  break;
5454  case JSON_TYPE_INT8:
5455  *(int8_t *)data = (int8_t)val;
5456  break;
5457  case JSON_TYPE_UINT16:
5458  *(uint16_t *)data = (uint16_t)val;
5459  break;
5460  case JSON_TYPE_UINT32:
5461  *(uint32_t *)data = (uint32_t)val;
5462  break;
5463  case JSON_TYPE_INT16:
5464  *(int16_t *)data = (int16_t)val;
5465  break;
5466  case JSON_TYPE_INT32:
5467  *(int32_t *)data = (int32_t)val;
5468  break;
5469  case JSON_TYPE_FLOAT:
5470  *(float *)data = (float)val;
5471  break;
5472  case JSON_TYPE_TIMESTAMP:
5473  case JSON_TYPE_DOUBLE:
5474  *(double *)data = (double)val;
5475  break;
5476  }
5477  return iretn;
5478 }
JSON 16 bit integer type.
Definition: jsondef.h:194
JSON Timestamp.
Definition: jsondef.h:292
JSON 8 bit unsigned integer type.
Definition: jsondef.h:182
int iretn
Definition: rw_test.cpp:37
uint16_t type
JSON Data Type.
Definition: jsondef.h:4169
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
JSON 32 bit integer type.
Definition: jsondef.h:196
uint8_t * json_ptr_of_entry(const jsonentry &entry, cosmosstruc *cinfo)
Address from entry.
Definition: jsonlib.cpp:3004
JSON double precision floating vertex type.
Definition: jsondef.h:200
JSON 8 bit signed integer type.
Definition: jsondef.h:184
JSON 32 bit unsigned integer type.
Definition: jsondef.h:190
JSON single precision floating vertex type.
Definition: jsondef.h:198
int32_t json_parse_value ( const char *&  ptr,
const jsonentry entry,
cosmosstruc cinfo 
)
5481 {
5482  uint8_t *data;
5483  int32_t iretn=0;
5484 
5485  data = json_ptr_of_entry(entry, cinfo);
5486 
5487  iretn = json_parse_value(ptr, entry.type, data, cinfo);
5488  return iretn;
5489 }
int iretn
Definition: rw_test.cpp:37
uint16_t type
JSON Data Type.
Definition: jsondef.h:4169
uint8_t * json_ptr_of_entry(const jsonentry &entry, cosmosstruc *cinfo)
Address from entry.
Definition: jsonlib.cpp:3004
int32_t json_parse_value(const char *&ptr, const jsonentry &entry, cosmosstruc *cinfo)
Definition: jsonlib.cpp:5480
int32_t json_parse_value ( const char *&  ptr,
uint16_t  type,
ptrdiff_t  offset,
uint16_t  group,
cosmosstruc cinfo 
)
5492 {
5493  uint8_t *data;
5494  int32_t iretn = 0;
5495 
5496  if (ptr[0] == 0)
5497  return (JSON_ERROR_EOS);
5498 
5499  data = json_ptr_of_offset(offset, group, cinfo);
5500 
5501  iretn = json_parse_value(ptr, type, data, cinfo);
5502  return iretn;
5503 }
int iretn
Definition: rw_test.cpp:37
uint8_t * json_ptr_of_offset(ptrdiff_t offset, uint16_t group, cosmosstruc *cinfo)
Address from offset.
Definition: jsonlib.cpp:3029
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
int32_t json_parse_value(const char *&ptr, const jsonentry &entry, cosmosstruc *cinfo)
Definition: jsonlib.cpp:5480
struct ip_mreq group
Definition: mcastclient.c:39
int32_t json_parse_value ( const char *&  ptr,
uint16_t  type,
uint8_t *  data,
cosmosstruc cinfo 
)
5506 {
5507  int32_t iretn=0;
5508  string input;
5509  double val;
5510  cartpos *rp;
5511  geoidpos *gp;
5512  spherpos *sp;
5513  dcmatt *ra;
5514  qatt *qa;
5515  string empty;
5516 
5517  //Skip whitespace before value
5518  if ((iretn = json_skip_white(ptr)) < 0)
5519  {
5520  return iretn;
5521  }
5522 
5523  switch (type)
5524  {
5525  case JSON_TYPE_UINT8:
5526  if (std::isnan(val=json_equation(ptr, cinfo)))
5527  {
5528  if ((iretn = json_parse_number(ptr,&val)) < 0)
5529  return iretn;
5530  }
5531  *(uint8_t *)data = (uint8_t)val;
5532  break;
5533 
5534  case JSON_TYPE_INT8:
5535  if (std::isnan(val=json_equation(ptr, cinfo)))
5536  {
5537  if ((iretn = json_parse_number(ptr,&val)) < 0)
5538  return iretn;
5539  }
5540  *(int8_t *)data = (int8_t)val;
5541  break;
5542 
5543  case JSON_TYPE_UINT16:
5544  if (std::isnan(val=json_equation(ptr, cinfo)))
5545  {
5546  if ((iretn = json_parse_number(ptr,&val)) < 0)
5547  return iretn;
5548  }
5549  *(uint16_t *)data = (uint16_t)val;
5550  break;
5551  case JSON_TYPE_UINT32:
5552  if (std::isnan(val=json_equation(ptr, cinfo)))
5553  {
5554  if ((iretn = json_parse_number(ptr,&val)) < 0)
5555  return iretn;
5556  }
5557  *(uint32_t *)data = (uint32_t)val;
5558  break;
5559  case JSON_TYPE_INT16:
5560  if (std::isnan(val=json_equation(ptr, cinfo)))
5561  {
5562  if ((iretn = json_parse_number(ptr,&val)) < 0)
5563  return iretn;
5564  }
5565  *(int16_t *)data = (int16_t)val;
5566  break;
5567  case JSON_TYPE_INT32:
5568  if (std::isnan(val=json_equation(ptr, cinfo)))
5569  {
5570  if ((iretn = json_parse_number(ptr,&val)) < 0)
5571  return iretn;
5572  }
5573  *(int32_t *)data = (int32_t)val;
5574  break;
5575  case JSON_TYPE_FLOAT:
5576  if (std::isnan(val=json_equation(ptr, cinfo)))
5577  {
5578  if ((iretn = json_parse_number(ptr,&val)) < 0)
5579  return iretn;
5580  }
5581  *(float *)data = (float)val;
5582  break;
5583  case JSON_TYPE_TIMESTAMP:
5584  if (std::isnan(val=json_equation(ptr, cinfo)))
5585  {
5586  if ((iretn = json_parse_number(ptr,&val)) < 0)
5587  return iretn;
5588  }
5589  *(double *)data = (double)val;
5590  break;
5591  case JSON_TYPE_DOUBLE:
5592  if (std::isnan(val=json_equation(ptr, cinfo)))
5593  {
5594  if ((iretn = json_parse_number(ptr,&val)) < 0)
5595  return iretn;
5596  }
5597  *(double *)data = (double)val;
5598  break;
5599  case JSON_TYPE_STRING:
5600  case JSON_TYPE_NAME:
5601  if ((iretn = json_extract_string(ptr, input)) < 0)
5602  return iretn;
5603  if (input.size())
5604  {
5605  if (type == JSON_TYPE_NAME)
5606  {
5607  if (input.size() > COSMOS_MAX_NAME)
5608  {
5609  input.resize(COSMOS_MAX_NAME-1);
5610  }
5611  }
5612  else
5613  {
5614  if (input.size() > COSMOS_MAX_DATA)
5615  {
5616  input.resize(COSMOS_MAX_DATA-1);
5617  }
5618  }
5619  strcpy((char *)data, (char*)&input[0]);
5620  }
5621  break;
5622  case JSON_TYPE_GVECTOR:
5623  if ((iretn = json_skip_character(ptr,'{')) < 0)
5624  return iretn;
5625  if ((iretn = json_extract_name(ptr, empty)) < 0)
5626  return iretn;
5627  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(gvector,lat), cinfo)) < 0)
5628  return iretn;
5629  if ((iretn = json_skip_character(ptr,',')) < 0)
5630  return iretn;
5631  if ((iretn = json_extract_name(ptr, empty)) < 0)
5632  return iretn;
5633  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(gvector,lon), cinfo)) < 0)
5634  return iretn;
5635  if ((iretn = json_skip_character(ptr,',')) < 0)
5636  return iretn;
5637  if ((iretn = json_extract_name(ptr, empty)) < 0)
5638  return iretn;
5639  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(gvector,h), cinfo)) < 0)
5640  return iretn;
5641  if ((iretn = json_skip_character(ptr,'}')) < 0)
5642  return iretn;
5643  break;
5644  case JSON_TYPE_AVECTOR:
5645  if ((iretn = json_skip_character(ptr,'{')) < 0)
5646  return iretn;
5647  if ((iretn = json_extract_name(ptr, empty)) < 0)
5648  return iretn;
5649  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(avector,h), cinfo)) < 0)
5650  return iretn;
5651  if ((iretn = json_skip_character(ptr,',')) < 0)
5652  return iretn;
5653  if ((iretn = json_extract_name(ptr, empty)) < 0)
5654  return iretn;
5655  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(avector,e), cinfo)) < 0)
5656  return iretn;
5657  if ((iretn = json_skip_character(ptr,',')) < 0)
5658  return iretn;
5659  if ((iretn = json_extract_name(ptr, empty)) < 0)
5660  return iretn;
5661  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(avector,b), cinfo)) < 0)
5662  return iretn;
5663  if ((iretn = json_skip_character(ptr,'}')) < 0)
5664  return iretn;
5665  break;
5666  case JSON_TYPE_CVECTOR:
5667  if ((iretn = json_skip_character(ptr,'{')) < 0)
5668  return iretn;
5669  if ((iretn = json_extract_name(ptr, empty)) < 0)
5670  return iretn;
5671  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(cvector,x), cinfo)) < 0)
5672  return iretn;
5673  if ((iretn = json_skip_character(ptr,',')) < 0)
5674  return iretn;
5675  if ((iretn = json_extract_name(ptr, empty)) < 0)
5676  return iretn;
5677  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(cvector,y), cinfo)) < 0)
5678  return iretn;
5679  if ((iretn = json_skip_character(ptr,',')) < 0)
5680  return iretn;
5681  if ((iretn = json_extract_name(ptr, empty)) < 0)
5682  return iretn;
5683  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(cvector,z), cinfo)) < 0)
5684  return iretn;
5685  if ((iretn = json_skip_character(ptr,'}')) < 0)
5686  return iretn;
5687  break;
5688  case JSON_TYPE_VECTOR:
5689  if ((iretn = json_skip_character(ptr,'[')) < 0)
5690  return iretn;
5691  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(Vector,x), cinfo)) < 0)
5692  return iretn;
5693  if ((iretn = json_skip_character(ptr,',')) < 0)
5694  return iretn;
5695  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(Vector,y), cinfo)) < 0)
5696  return iretn;
5697  if ((iretn = json_skip_character(ptr,',')) < 0)
5698  return iretn;
5699  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(Vector,z), cinfo)) < 0)
5700  return iretn;
5701  if ((iretn = json_skip_character(ptr,']')) < 0)
5702  {
5703  if ((iretn = json_skip_character(ptr,',')) < 0)
5704  return iretn;
5705  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(Vector,w), cinfo)) < 0)
5706  return iretn;
5707  if ((iretn = json_skip_character(ptr,']')) < 0)
5708  {
5709  return iretn;
5710  }
5711  }
5712  break;
5713  case JSON_TYPE_RVECTOR:
5714  // case JSON_TYPE_TVECTOR:
5715  if ((iretn = json_skip_character(ptr,'[')) < 0)
5716  return iretn;
5717  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(rvector,col[0]), cinfo)) < 0)
5718  return iretn;
5719  if ((iretn = json_skip_character(ptr,',')) < 0)
5720  return iretn;
5721  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(rvector,col[1]), cinfo)) < 0)
5722  return iretn;
5723  if ((iretn = json_skip_character(ptr,',')) < 0)
5724  return iretn;
5725  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(rvector,col[2]), cinfo)) < 0)
5726  return iretn;
5727  if ((iretn = json_skip_character(ptr,']')) < 0)
5728  return iretn;
5729  break;
5730  case JSON_TYPE_QUATERNION:
5731  if ((iretn = json_skip_character(ptr,'{')) < 0)
5732  return iretn;
5733  if ((iretn = json_extract_name(ptr, empty)) < 0)
5734  return iretn;
5735  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_CVECTOR, data+(ptrdiff_t)offsetof(quaternion,d), cinfo)) < 0)
5736  return iretn;
5737  if ((iretn = json_skip_character(ptr,',')) < 0)
5738  return iretn;
5739  if ((iretn = json_extract_name(ptr, empty)) < 0)
5740  return iretn;
5741  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(quaternion,w), cinfo)) < 0)
5742  return iretn;
5743  if ((iretn = json_skip_character(ptr,'}')) < 0)
5744  return iretn;
5745  break;
5746  case JSON_TYPE_RMATRIX:
5747  if ((iretn = json_skip_character(ptr,'[')) < 0)
5748  return iretn;
5749  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_RVECTOR, data+(ptrdiff_t)offsetof(rmatrix,row[0]), cinfo)) < 0)
5750  return iretn;
5751  if ((iretn = json_skip_character(ptr,',')) < 0)
5752  return iretn;
5753  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_RVECTOR, data+(ptrdiff_t)offsetof(rmatrix,row[1]), cinfo)) < 0)
5754  return iretn;
5755  if ((iretn = json_skip_character(ptr,',')) < 0)
5756  return iretn;
5757  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_RVECTOR, data+(ptrdiff_t)offsetof(rmatrix,row[2]), cinfo)) < 0)
5758  return iretn;
5759  if ((iretn = json_skip_character(ptr,',')) < 0)
5760  return iretn;
5761  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_RVECTOR, data+(ptrdiff_t)offsetof(rmatrix,row[3]), cinfo)) < 0)
5762  return iretn;
5763  if ((iretn = json_skip_character(ptr,']')) < 0)
5764  return iretn;
5765  break;
5766  // case JSON_TYPE_DCM:
5767  // if ((iretn = json_skip_character(ptr,'[')) < 0)
5768  // return iretn;
5769  // if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_RVECTOR, data+(ptrdiff_t)offsetof(rmatrix,row[0]), cinfo)) < 0)
5770  // return iretn;
5771  // if ((iretn = json_skip_character(ptr,',')) < 0)
5772  // return iretn;
5773  // if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_RVECTOR, data+(ptrdiff_t)offsetof(rmatrix,row[1]), cinfo)) < 0)
5774  // return iretn;
5775  // if ((iretn = json_skip_character(ptr,',')) < 0)
5776  // return iretn;
5777  // if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_RVECTOR, data+(ptrdiff_t)offsetof(rmatrix,row[2]), cinfo)) < 0)
5778  // return iretn;
5779  // if ((iretn = json_skip_character(ptr,']')) < 0)
5780  // return iretn;
5781  // break;
5782  case JSON_TYPE_GEOIDPOS:
5783  case JSON_TYPE_POS_SELG:
5784  case JSON_TYPE_POS_GEOD:
5785  if ((iretn = json_skip_character(ptr,'{')) < 0)
5786  return iretn;
5787  if ((iretn = json_extract_name(ptr,input)) < 0)
5788  return iretn;
5789 
5790  gp = (geoidpos *)(data+(ptrdiff_t)offsetof(geoidpos,utc));
5791  gp->utc = 0.;
5792  if (input == "utc")
5793  {
5794  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(cartpos,utc), cinfo)) < 0)
5795  return iretn;
5796  if ((iretn = json_skip_character(ptr,',')) < 0)
5797  return iretn;
5798  if ((iretn = json_extract_name(ptr, empty)) < 0)
5799  return iretn;
5800  }
5801  if (gp->utc == 0.)
5802  {
5803  gp->utc = currentmjd(cinfo->node.utcoffset);
5804  }
5805 
5806  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_GVECTOR, data+(ptrdiff_t)offsetof(geoidpos,s), cinfo)) < 0)
5807  return iretn;
5808  if ((iretn = json_skip_character(ptr,',')) < 0)
5809  return iretn;
5810  if ((iretn = json_extract_name(ptr, empty)) < 0)
5811  return iretn;
5812  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_GVECTOR, data+(ptrdiff_t)offsetof(geoidpos,v), cinfo)) < 0)
5813  return iretn;
5814  if ((iretn = json_skip_character(ptr,',')) < 0)
5815  return iretn;
5816  if ((iretn = json_extract_name(ptr, empty)) < 0)
5817  return iretn;
5818  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_GVECTOR, data+(ptrdiff_t)offsetof(geoidpos,a), cinfo)) < 0)
5819  return iretn;
5820  if ((iretn = json_skip_character(ptr,'}')) < 0)
5821  return iretn;
5822  gp->pass++;
5823  switch (type)
5824  {
5825  case JSON_TYPE_POS_SELG:
5826  pos_selg(&cinfo->node.loc);
5827  break;
5828  case JSON_TYPE_POS_GEOD:
5829  pos_geod(&cinfo->node.loc);
5830  break;
5831  }
5832  break;
5833  case JSON_TYPE_SPHERPOS:
5834  case JSON_TYPE_POS_GEOS:
5835  if ((iretn = json_skip_character(ptr,'{')) < 0)
5836  return iretn;
5837  if ((iretn = json_extract_name(ptr,input)) < 0)
5838  return iretn;
5839 
5840  sp = (spherpos *)(data+(ptrdiff_t)offsetof(spherpos,utc));
5841  sp->utc = 0.;
5842  if (input == "utc")
5843  {
5844  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(cartpos,utc), cinfo)) < 0)
5845  return iretn;
5846  if ((iretn = json_skip_character(ptr,',')) < 0)
5847  return iretn;
5848  if ((iretn = json_extract_name(ptr, empty)) < 0)
5849  return iretn;
5850  }
5851  if (sp->utc == 0.)
5852  {
5853  sp->utc = currentmjd(cinfo->node.utcoffset);
5854  }
5855 
5856  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_SVECTOR, data+(ptrdiff_t)offsetof(spherpos,s), cinfo)) < 0)
5857  return iretn;
5858  if ((iretn = json_skip_character(ptr,',')) < 0)
5859  return iretn;
5860  if ((iretn = json_extract_name(ptr, empty)) < 0)
5861  return iretn;
5862  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_SVECTOR, data+(ptrdiff_t)offsetof(spherpos,v), cinfo)) < 0)
5863  return iretn;
5864  if ((iretn = json_skip_character(ptr,',')) < 0)
5865  return iretn;
5866  if ((iretn = json_extract_name(ptr, empty)) < 0)
5867  return iretn;
5868  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_SVECTOR, data+(ptrdiff_t)offsetof(spherpos,a), cinfo)) < 0)
5869  return iretn;
5870  if ((iretn = json_skip_character(ptr,'}')) < 0)
5871  return iretn;
5872  sp->pass++;
5873  pos_geos(&cinfo->node.loc);
5874  break;
5875  case JSON_TYPE_CARTPOS:
5876  case JSON_TYPE_POS_GEOC:
5877  case JSON_TYPE_POS_SELC:
5878  case JSON_TYPE_POS_ECI:
5879  case JSON_TYPE_POS_SCI:
5880  case JSON_TYPE_POS_ICRF:
5881  if ((iretn = json_skip_character(ptr,'{')) < 0)
5882  return iretn;
5883  if ((iretn = json_extract_name(ptr,input)) < 0)
5884  return iretn;
5885 
5886  rp = (cartpos *)(data+(ptrdiff_t)offsetof(cartpos,utc));
5887  rp->utc = 0.;
5888  if (input == "utc")
5889  {
5890  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(cartpos,utc), cinfo)) < 0)
5891  return iretn;
5892  if ((iretn = json_skip_character(ptr,',')) < 0)
5893  return iretn;
5894  if ((iretn = json_extract_name(ptr, empty)) < 0)
5895  return iretn;
5896  }
5897  if (rp->utc == 0.)
5898  {
5899  rp->utc = currentmjd(cinfo->node.utcoffset);
5900  }
5901 
5902  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_RVECTOR, data+(ptrdiff_t)offsetof(cartpos,s), cinfo)) < 0)
5903  return iretn;
5904  if ((iretn = json_skip_character(ptr,',')) < 0)
5905  return iretn;
5906  if ((iretn = json_extract_name(ptr, empty)) < 0)
5907  return iretn;
5908  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_RVECTOR, data+(ptrdiff_t)offsetof(cartpos,v), cinfo)) < 0)
5909  return iretn;
5910  if ((iretn = json_skip_character(ptr,',')) < 0)
5911  return iretn;
5912  if ((iretn = json_extract_name(ptr, empty)) < 0)
5913  return iretn;
5914  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_RVECTOR, data+(ptrdiff_t)offsetof(cartpos,a), cinfo)) < 0)
5915  return iretn;
5916  if ((iretn = json_skip_character(ptr,'}')) < 0)
5917  return iretn;
5918  rp->pass++;
5919  switch (type)
5920  {
5921  case JSON_TYPE_POS_SELC:
5922  pos_selc(&cinfo->node.loc);
5923  break;
5924  case JSON_TYPE_POS_GEOC:
5925  pos_geoc(&cinfo->node.loc);
5926  break;
5927  case JSON_TYPE_POS_ECI:
5928  pos_eci(&cinfo->node.loc);
5929  break;
5930  case JSON_TYPE_POS_SCI:
5931  pos_sci(&cinfo->node.loc);
5932  break;
5933  case JSON_TYPE_POS_ICRF:
5934  pos_icrf(&cinfo->node.loc);
5935  break;
5936  }
5937  break;
5938  case JSON_TYPE_DCMATT:
5939  if ((iretn = json_skip_character(ptr,'{')) < 0)
5940  return iretn;
5941  if ((iretn = json_extract_name(ptr, empty)) < 0)
5942  return iretn;
5943  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_RMATRIX, data+(ptrdiff_t)offsetof(dcmatt,s), cinfo)) < 0)
5944  return iretn;
5945  if ((iretn = json_skip_character(ptr,',')) < 0)
5946  return iretn;
5947  if ((iretn = json_extract_name(ptr, empty)) < 0)
5948  return iretn;
5949  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_RVECTOR, data+(ptrdiff_t)offsetof(dcmatt,v), cinfo)) < 0)
5950  return iretn;
5951  if ((iretn = json_skip_character(ptr,',')) < 0)
5952  return iretn;
5953  if ((iretn = json_extract_name(ptr, empty)) < 0)
5954  return iretn;
5955  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_RVECTOR, data+(ptrdiff_t)offsetof(dcmatt,a), cinfo)) < 0)
5956  return iretn;
5957  if ((iretn = json_skip_character(ptr,'}')) < 0)
5958  return iretn;
5959  ra = (dcmatt *)(data+(ptrdiff_t)offsetof(dcmatt,utc));
5960  ra->utc = *(double *)json_ptrto((char *)"node_utc", cinfo);
5961  break;
5962  case JSON_TYPE_QATT:
5963  case JSON_TYPE_QATT_TOPO:
5964  case JSON_TYPE_QATT_GEOC:
5965  case JSON_TYPE_QATT_ICRF:
5966  case JSON_TYPE_QATT_SELC:
5967  case JSON_TYPE_QATT_LVLH:
5968  if ((iretn = json_skip_character(ptr,'{')) < 0)
5969  return iretn;
5970  if ((iretn = json_extract_name(ptr,input)) < 0)
5971  return iretn;
5972 
5973  qa = (qatt *)(data+(ptrdiff_t)offsetof(qatt,utc));
5974  qa->utc = 0.;
5975  if (input == "utc")
5976  {
5977  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(qatt,utc), cinfo)) < 0)
5978  return iretn;
5979  if ((iretn = json_skip_character(ptr,',')) < 0)
5980  return iretn;
5981  if ((iretn = json_extract_name(ptr, empty)) < 0)
5982  return iretn;
5983  }
5984  if (qa->utc == 0.)
5985  {
5986  qa->utc = currentmjd(cinfo->node.utcoffset);
5987  }
5988 
5989  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_QUATERNION, data+(ptrdiff_t)offsetof(qatt,s), cinfo)) < 0)
5990  return iretn;
5991  if ((iretn = json_skip_character(ptr,',')) < 0)
5992  return iretn;
5993  if ((iretn = json_extract_name(ptr, empty)) < 0)
5994  return iretn;
5995  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_RVECTOR, data+(ptrdiff_t)offsetof(qatt,v), cinfo)) < 0)
5996  return iretn;
5997  if ((iretn = json_skip_character(ptr,',')) < 0)
5998  return iretn;
5999  if ((iretn = json_extract_name(ptr, empty)) < 0)
6000  return iretn;
6001  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_RVECTOR, data+(ptrdiff_t)offsetof(qatt,a), cinfo)) < 0)
6002  return iretn;
6003  if ((iretn = json_skip_character(ptr,'}')) < 0)
6004  return iretn;
6005  qa->pass++;
6006  switch (type)
6007  {
6008  case JSON_TYPE_QATT_GEOC:
6009  att_geoc(&cinfo->node.loc);
6010  break;
6011  case JSON_TYPE_QATT_ICRF:
6012  att_icrf(&cinfo->node.loc);
6013  break;
6014  case JSON_TYPE_QATT_LVLH:
6015  att_lvlh(&cinfo->node.loc);
6016  break;
6017  case JSON_TYPE_QATT_SELC:
6018  att_selc(&cinfo->node.loc);
6019  break;
6020  case JSON_TYPE_QATT_TOPO:
6021  att_topo(&cinfo->node.loc);
6022  break;
6023  }
6024  break;
6025  case JSON_TYPE_HBEAT:
6026  if ((iretn = json_skip_character(ptr,'{')) < 0)
6027  return iretn;
6028  if ((iretn = json_extract_string(ptr, empty)) < 0)
6029  return iretn;
6030  if ((iretn = json_skip_white(ptr)) < 0)
6031  return iretn;
6032  if ((iretn = json_skip_character(ptr,':')) < 0)
6033  return iretn;
6034  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(beatstruc,utc), cinfo)) < 0)
6035  return iretn;
6036  if ((iretn = json_skip_character(ptr,',')) < 0)
6037  return iretn;
6038  if ((iretn = json_extract_string(ptr, empty)) < 0)
6039  return iretn;
6040  if ((iretn = json_skip_white(ptr)) < 0)
6041  return iretn;
6042  if ((iretn = json_skip_character(ptr,':')) < 0)
6043  return iretn;
6044  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_STRING, data+(ptrdiff_t)offsetof(beatstruc,node), cinfo)) < 0)
6045  return iretn;
6046  if ((iretn = json_skip_character(ptr,',')) < 0)
6047  return iretn;
6048  if ((iretn = json_extract_string(ptr, empty)) < 0)
6049  return iretn;
6050  if ((iretn = json_skip_white(ptr)) < 0)
6051  return iretn;
6052  if ((iretn = json_skip_character(ptr,':')) < 0)
6053  return iretn;
6054  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_STRING, data+(ptrdiff_t)offsetof(beatstruc,proc), cinfo)) < 0)
6055  return iretn;
6056  if ((iretn = json_skip_character(ptr,',')) < 0)
6057  return iretn;
6058  if ((iretn = json_extract_string(ptr, empty)) < 0)
6059  return iretn;
6060  if ((iretn = json_skip_white(ptr)) < 0)
6061  return iretn;
6062  if ((iretn = json_skip_character(ptr,':')) < 0)
6063  return iretn;
6064  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_INT32, data+(ptrdiff_t)offsetof(beatstruc,ntype), cinfo)) < 0)
6065  return iretn;
6066  if ((iretn = json_skip_character(ptr,',')) < 0)
6067  return iretn;
6068  if ((iretn = json_extract_string(ptr, empty)) < 0)
6069  return iretn;
6070  if ((iretn = json_skip_white(ptr)) < 0)
6071  return iretn;
6072  if ((iretn = json_skip_character(ptr,':')) < 0)
6073  return iretn;
6074  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_STRING, data+(ptrdiff_t)offsetof(beatstruc,addr), cinfo)) < 0)
6075  return iretn;
6076  if ((iretn = json_skip_character(ptr,',')) < 0)
6077  return iretn;
6078  if ((iretn = json_extract_string(ptr, empty)) < 0)
6079  return iretn;
6080  if ((iretn = json_skip_white(ptr)) < 0)
6081  return iretn;
6082  if ((iretn = json_skip_character(ptr,':')) < 0)
6083  return iretn;
6084  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_INT32, data+(ptrdiff_t)offsetof(beatstruc,port), cinfo)) < 0)
6085  return iretn;
6086  if ((iretn = json_skip_character(ptr,',')) < 0)
6087  return iretn;
6088  if ((iretn = json_extract_string(ptr, empty)) < 0)
6089  return iretn;
6090  if ((iretn = json_skip_white(ptr)) < 0)
6091  return iretn;
6092  if ((iretn = json_skip_character(ptr,':')) < 0)
6093  return iretn;
6094  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_INT32, data+(ptrdiff_t)offsetof(beatstruc,bsz), cinfo)) < 0)
6095  return iretn;
6096  if ((iretn = json_skip_character(ptr,',')) < 0)
6097  return iretn;
6098  if ((iretn = json_extract_string(ptr, empty)) < 0)
6099  return iretn;
6100  if ((iretn = json_skip_white(ptr)) < 0)
6101  return iretn;
6102  if ((iretn = json_skip_character(ptr,':')) < 0)
6103  return iretn;
6104  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(beatstruc,bprd), cinfo)) < 0)
6105  return iretn;
6106  if ((iretn = json_skip_character(ptr,'}')) < 0)
6107  return iretn;
6108  break;
6109  case JSON_TYPE_LOC_POS:
6110  if ((iretn = json_skip_character(ptr,'{')) < 0)
6111  return iretn;
6112  if ((iretn = json_extract_string(ptr, empty)) < 0)
6113  return iretn;
6114  if ((iretn = json_skip_white(ptr)) < 0)
6115  return iretn;
6116  if ((iretn = json_skip_character(ptr,':')) < 0)
6117  return iretn;
6118  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(posstruc,utc), cinfo)) < 0)
6119  return iretn;
6120  if ((iretn = json_skip_character(ptr,',')) < 0)
6121  return iretn;
6122  if ((iretn = json_extract_string(ptr, empty)) < 0)
6123  return iretn;
6124  if ((iretn = json_skip_white(ptr)) < 0)
6125  return iretn;
6126  if ((iretn = json_skip_character(ptr,':')) < 0)
6127  return iretn;
6128  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_CARTPOS, data+(ptrdiff_t)offsetof(posstruc,icrf), cinfo)) < 0)
6129  return iretn;
6130  if ((iretn = json_skip_character(ptr,',')) < 0)
6131  return iretn;
6132  if ((iretn = json_extract_string(ptr, empty)) < 0)
6133  return iretn;
6134  if ((iretn = json_skip_white(ptr)) < 0)
6135  return iretn;
6136  if ((iretn = json_skip_character(ptr,':')) < 0)
6137  return iretn;
6138  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_CARTPOS, data+(ptrdiff_t)offsetof(posstruc,eci), cinfo)) < 0)
6139  return iretn;
6140  if ((iretn = json_skip_character(ptr,',')) < 0)
6141  return iretn;
6142  if ((iretn = json_extract_string(ptr, empty)) < 0)
6143  return iretn;
6144  if ((iretn = json_skip_white(ptr)) < 0)
6145  return iretn;
6146  if ((iretn = json_skip_character(ptr,':')) < 0)
6147  return iretn;
6148  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_CARTPOS, data+(ptrdiff_t)offsetof(posstruc,sci), cinfo)) < 0)
6149  return iretn;
6150  if ((iretn = json_skip_character(ptr,',')) < 0)
6151  return iretn;
6152  if ((iretn = json_extract_string(ptr, empty)) < 0)
6153  return iretn;
6154  if ((iretn = json_skip_white(ptr)) < 0)
6155  return iretn;
6156  if ((iretn = json_skip_character(ptr,':')) < 0)
6157  return iretn;
6158  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_CARTPOS, data+(ptrdiff_t)offsetof(posstruc,geoc), cinfo)) < 0)
6159  return iretn;
6160  if ((iretn = json_skip_character(ptr,',')) < 0)
6161  return iretn;
6162  if ((iretn = json_extract_string(ptr, empty)) < 0)
6163  return iretn;
6164  if ((iretn = json_skip_white(ptr)) < 0)
6165  return iretn;
6166  if ((iretn = json_skip_character(ptr,':')) < 0)
6167  return iretn;
6168  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_CARTPOS, data+(ptrdiff_t)offsetof(posstruc,selc), cinfo)) < 0)
6169  return iretn;
6170  if ((iretn = json_skip_character(ptr,',')) < 0)
6171  return iretn;
6172  if ((iretn = json_extract_string(ptr, empty)) < 0)
6173  return iretn;
6174  if ((iretn = json_skip_white(ptr)) < 0)
6175  return iretn;
6176  if ((iretn = json_skip_character(ptr,':')) < 0)
6177  return iretn;
6178  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_POS_GEOD, data+(ptrdiff_t)offsetof(posstruc,geod), cinfo)) < 0)
6179  return iretn;
6180  if ((iretn = json_skip_character(ptr,',')) < 0)
6181  return iretn;
6182  if ((iretn = json_extract_string(ptr, empty)) < 0)
6183  return iretn;
6184  if ((iretn = json_skip_white(ptr)) < 0)
6185  return iretn;
6186  if ((iretn = json_skip_character(ptr,':')) < 0)
6187  return iretn;
6188  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_POS_GEOD, data+(ptrdiff_t)offsetof(posstruc,selg), cinfo)) < 0)
6189  return iretn;
6190  if ((iretn = json_skip_character(ptr,',')) < 0)
6191  return iretn;
6192  if ((iretn = json_extract_string(ptr, empty)) < 0)
6193  return iretn;
6194  if ((iretn = json_skip_white(ptr)) < 0)
6195  return iretn;
6196  if ((iretn = json_skip_character(ptr,':')) < 0)
6197  return iretn;
6198  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_POS_GEOS, data+(ptrdiff_t)offsetof(posstruc,geos), cinfo)) < 0)
6199  return iretn;
6200  if ((iretn = json_skip_character(ptr,',')) < 0)
6201  return iretn;
6202  if ((iretn = json_extract_string(ptr, empty)) < 0)
6203  return iretn;
6204  if ((iretn = json_skip_white(ptr)) < 0)
6205  return iretn;
6206  if ((iretn = json_skip_character(ptr,':')) < 0)
6207  return iretn;
6208  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_RVECTOR, data+(ptrdiff_t)offsetof(posstruc,bearth), cinfo)) < 0)
6209  return iretn;
6210  if ((iretn = json_skip_character(ptr,'}')) < 0)
6211  return iretn;
6212  break;
6213  case JSON_TYPE_LOCSTRUC:
6214  if ((iretn = json_skip_character(ptr,'{')) < 0)
6215  return iretn;
6216  if ((iretn = json_extract_string(ptr, empty)) < 0)
6217  return iretn;
6218  if ((iretn = json_skip_white(ptr)) < 0)
6219  return iretn;
6220  if ((iretn = json_skip_character(ptr,':')) < 0)
6221  return iretn;
6222  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_DOUBLE, data+(ptrdiff_t)offsetof(locstruc,utc), cinfo)) < 0)
6223  return iretn;
6224  if ((iretn = json_skip_character(ptr,',')) < 0)
6225  return iretn;
6226  if ((iretn = json_extract_string(ptr, empty)) < 0)
6227  return iretn;
6228  if ((iretn = json_skip_white(ptr)) < 0)
6229  return iretn;
6230  if ((iretn = json_skip_character(ptr,':')) < 0)
6231  return iretn;
6232  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_POSSTRUC, data+(ptrdiff_t)offsetof(locstruc,pos), cinfo)) < 0)
6233  return iretn;
6234  if ((iretn = json_skip_character(ptr,',')) < 0)
6235  return iretn;
6236  if ((iretn = json_extract_string(ptr, empty)) < 0)
6237  return iretn;
6238  if ((iretn = json_skip_white(ptr)) < 0)
6239  return iretn;
6240  if ((iretn = json_skip_character(ptr,':')) < 0)
6241  return iretn;
6242  if ((iretn = json_parse_value(ptr, (uint16_t)JSON_TYPE_ATTSTRUC, data+(ptrdiff_t)offsetof(locstruc,att), cinfo)) < 0)
6243  return iretn;
6244  if ((iretn = json_skip_character(ptr,'}')) < 0)
6245  return iretn;
6246  break;
6247  }
6248 
6249  //Skip whitespace after value
6250  if ((iretn = json_skip_white(ptr)) < 0)
6251  {
6252  return iretn;
6253  }
6254 
6255  return (type);
6256 }
JSON 16 bit integer type.
Definition: jsondef.h:194
int32_t att_selc(locstruc *loc)
Definition: convertlib.cpp:1794
static string port
Definition: add_radio.cpp:16
JSON rvector.
Definition: jsondef.h:210
JSON Timestamp.
Definition: jsondef.h:292
Definition: eci2kep_test.cpp:33
Definition: eci2kep_test.cpp:33
JSON string type.
Definition: jsondef.h:204
JSON Geocentric Attitude.
Definition: jsondef.h:264
Definition: jsondef.h:923
double utc
Definition: convertdef.h:261
y
Definition: inputfile.py:6
JSON 8 bit unsigned integer type.
Definition: jsondef.h:182
Quaternion Attitude.
Definition: convertdef.h:475
3 element generic row vector
Definition: vector.h:53
double utc
UTC of Position.
Definition: convertdef.h:161
Direction Cosine Matrix Attitude.
Definition: convertdef.h:423
Geodetic position structure.
Definition: convertdef.h:259
JSON Earth Centered Inertial Position.
Definition: jsondef.h:247
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
uint32_t pass
pass indicator: allows synchronization with other attitude and position values.
Definition: convertdef.h:170
JSON qatt.
Definition: jsondef.h:232
Cartesian full position structure.
Definition: convertdef.h:158
int32_t pos_sci(locstruc *loc)
Set SCI position.
Definition: convertlib.cpp:312
JSON rmatrix.
Definition: jsondef.h:222
Quaternion, scalar last, using x, y, z.
Definition: vector.h:402
int iretn
Definition: rw_test.cpp:37
JSON cvector.
Definition: jsondef.h:214
JSON Lunar Centered Inertial Attitude.
Definition: jsondef.h:266
uint8_t * json_ptrto(string token, cosmosstruc *cinfo)
Return the data pointer that matches a JSON name.
Definition: jsonlib.cpp:3283
int32_t att_icrf(locstruc *loc)
Definition: convertlib.cpp:1836
int32_t pos_selg(locstruc *loc)
Set Selenographic position.
Definition: convertlib.cpp:484
JSON Geocentric Spherical.
Definition: jsondef.h:257
JSON rvector.
Definition: jsondef.h:212
JSON Geocentric Position.
Definition: jsondef.h:251
JSON attstruc.
Definition: jsondef.h:240
long b
Definition: jpegint.h:371
int32_t pos_geos(locstruc *loc)
Set Geographic position.
Definition: convertlib.cpp:530
Definition: convertdef.h:733
double json_equation(const char *&ptr, cosmosstruc *cinfo)
Return the results of a JSON equation.
Definition: jsonlib.cpp:4294
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
double utc
Definition: convertdef.h:477
double utc
Definition: convertdef.h:425
JSON Name type.
Definition: jsondef.h:206
JSON Satellite Position Structure.
Definition: jsondef.h:272
JSON Lunar Centered Inertial Position.
Definition: jsondef.h:249
JSON Earth Centered Inertial Attitude.
Definition: jsondef.h:268
JSON LVLH Attitude.
Definition: jsondef.h:270
#define COSMOS_MAX_DATA
Definition: cosmos-defs.h:53
int32_t json_skip_white(const char *&ptr)
Skip white space in JSON string.
Definition: jsonlib.cpp:5336
3 element attitude vector.
Definition: vector.h:277
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
double utcoffset
MJD Offset between system UT and simulated UT.
Definition: jsondef.h:3590
int32_t json_parse_number(const char *&ptr, double *number)
Parse the next number out of a JSON stream.
Definition: jsonlib.cpp:5269
JSON cartpos.
Definition: jsondef.h:228
3x3 element generic matrix
Definition: matrix.h:41
int32_t json_extract_string(const char *&ptr, string &ostring)
Parse the next JSON string out of a JSON stream.
Definition: jsonlib.cpp:5186
JSON Geodetic Position.
Definition: jsondef.h:255
JSON dcmatt.
Definition: jsondef.h:234
locstruc loc
Location structure.
Definition: jsondef.h:3596
JSON cartpos.
Definition: jsondef.h:226
int32_t pos_geoc(locstruc *loc)
Set Geocentric position.
Definition: convertlib.cpp:366
int32_t att_geoc(locstruc *loc)
Definition: convertlib.cpp:1682
int32_t pos_eci(locstruc *loc)
Set ECI position.
Definition: convertlib.cpp:258
JSON 32 bit integer type.
Definition: jsondef.h:196
x
Definition: inputfile.py:6
JSON Topocentric Attitude.
Definition: jsondef.h:262
int32_t pos_icrf(locstruc *loc)
Set Barycentric position.
Definition: convertlib.cpp:162
int32_t pos_geod(locstruc *loc)
Set Geodetic position.
Definition: convertlib.cpp:576
Spherical position structure.
Definition: convertdef.h:314
Definition: eci2kep_test.cpp:33
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
JSON Agent Heartbeat.
Definition: jsondef.h:242
int32_t json_parse_value(const char *&ptr, const jsonentry &entry, cosmosstruc *cinfo)
Definition: jsonlib.cpp:5480
JSON double precision floating vertex type.
Definition: jsondef.h:200
uint32_t pass
pass indicator: allows synchronization with other attitude and position values.
Definition: convertdef.h:485
JSON 8 bit signed integer type.
Definition: jsondef.h:184
JSON 32 bit unsigned integer type.
Definition: jsondef.h:190
JSON cartpos.
Definition: jsondef.h:224
JSON svector.
Definition: jsondef.h:220
NetworkType ntype
Definition: agent_node.cpp:50
JSON ::Vector.
Definition: jsondef.h:208
int32_t pos_selc(locstruc *loc)
Set Selenocentric position.
Definition: convertlib.cpp:428
JSON single precision floating vertex type.
Definition: jsondef.h:198
JSON locstruc type.
Definition: jsondef.h:276
double utc
Definition: convertdef.h:316
int32_t json_skip_character(const char *&ptr, const char character)
Skip over a specific character in a JSON stream.
Definition: jsonlib.cpp:4972
uint32_t pass
pass indicator: allows synchronization with other attitude and position values.
Definition: convertdef.h:269
JSON posstruc.
Definition: jsondef.h:238
static string node
Definition: agent_monitor.cpp:126
uint32_t pass
pass indicator: allows synchronization with other attitude and position values.
Definition: convertdef.h:324
Vector Class.
Definition: vector.h:672
3 element geodetic vector
Definition: vector.h:222
int32_t att_topo(locstruc *loc)
Definition: convertlib.cpp:2252
JSON gvector.
Definition: jsondef.h:218
JSON Selenocentric Position.
Definition: jsondef.h:253
JSON Solar Barycentric Position.
Definition: jsondef.h:244
Definition: convertdef.h:876
int32_t att_lvlh(locstruc *loc)
Definition: convertlib.cpp:2064
JSON quaternion type.
Definition: jsondef.h:216
int32_t json_extract_name(const char *&ptr, string &ostring)
Parse the next variable name out of a JSON stream.
Definition: jsonlib.cpp:5003
3 element cartesian vector
Definition: vector.h:107
JSON Selenographic Position.
Definition: jsondef.h:259
int32_t json_clear_cosmosstruc ( int32_t  type,
cosmosstruc cinfo 
)

Clear global data structure.

Zero out elements of the cosmosstruc. The entire structure can be cleared, or the clearing can be confined to either the Dynamic or Static piece. This allows you to remove the effects of previous calls to json_parse.

Parameters
typeInstance of JSON_STRUCT_* enumeration.
cinfoReference to cosmosstruc to use.
Returns
0, or a negative COSMOS Error codes.
6269 {
6270  switch (type)
6271  {
6272  case JSON_STRUCT_NODE:
6273  cinfo->node = nodestruc();
6274  break;
6275  case JSON_STRUCT_EVENT:
6276  cinfo->event.clear();
6277  break;
6278  case JSON_STRUCT_PIECE:
6279  cinfo->pieces.clear();
6280  break;
6281  case JSON_STRUCT_DEVICE:
6282  cinfo->device.clear();
6283  break;
6284  case JSON_STRUCT_DEVSPEC:
6285  cinfo->devspec = devspecstruc();
6286  break;
6287  case JSON_STRUCT_PHYSICS:
6288  cinfo->node.phys = physicsstruc();
6289  break;
6290  case JSON_STRUCT_AGENT:
6291  cinfo->agent.clear();
6292  break;
6293  case JSON_STRUCT_USER:
6294  cinfo->user.clear();
6295  break;
6296  case JSON_STRUCT_PORT:
6297  cinfo->port.clear();
6298  break;
6299  case JSON_STRUCT_TARGET:
6300  cinfo->target.clear();
6301  break;
6302  case JSON_STRUCT_TLE:
6303  cinfo->tle.clear();
6304  break;
6305  case JSON_STRUCT_EQUATION:
6306  cinfo->equation.clear();
6307  break;
6308  case JSON_STRUCT_ALL:
6309  for (int32_t i=1; i<(int32_t)JSON_STRUCT_ALL; ++i)
6310  {
6311  json_clear_cosmosstruc(i, cinfo);
6312  }
6313  break;
6314  }
6315  return 0;
6316 }
vector< portstruc > port
Vector of all ports known to node.
Definition: jsondef.h:4244
vector< tlestruc > tle
Array of Two Line Elements.
Definition: jsondef.h:4259
piecestruc
Definition: jsondef.h:158
devspecstruc
Definition: jsondef.h:152
int i
Definition: rw_test.cpp:37
userstruc
Definition: jsondef.h:162
int32_t json_clear_cosmosstruc(int32_t type, cosmosstruc *cinfo)
Clear global data structure.
Definition: jsonlib.cpp:6268
devicestruc
Definition: jsondef.h:150
Physics Simulation Structure.
Definition: jsondef.h:3411
vector< devicestruc > device
Vector of all general (common) information for devices (components) in node.
Definition: jsondef.h:4238
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
tlestruc
Definition: jsondef.h:166
vector< equationstruc > equation
Vector of Equations.
Definition: jsondef.h:4217
eventstruc
Definition: jsondef.h:156
equationstruc
Definition: jsondef.h:168
portstruc
Definition: jsondef.h:164
vector< userstruc > user
Single entry vector for user information.
Definition: jsondef.h:4256
nodestruc
Definition: jsondef.h:146
entirety
Definition: jsondef.h:175
agentstruc
Definition: jsondef.h:148
vector< agentstruc > agent
Single entry vector for agent information.
Definition: jsondef.h:4247
targetstruc
Definition: jsondef.h:160
vector< piecestruc > pieces
Vector of all pieces in node.
Definition: jsondef.h:4232
Definition: jsondef.h:3553
vector< eventstruc > event
Single entry vector for event information.
Definition: jsondef.h:4250
Specific Device structure.
Definition: jsondef.h:3860
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
vector< targetstruc > target
Vector of all targets known to node.
Definition: jsondef.h:4253
physicsstruc
Definition: jsondef.h:154
physicsstruc phys
Definition: jsondef.h:3597
int32_t json_load_node ( string  node,
jsonnode json 
)

Map Name Space to global data structure components and pieces.

Create an entry in the JSON mapping tables between each name in the Name Space and the cosmosstruc.

Parameters
nodeName and/or path of node directory. If name, then a path will be created based on nodedir setting. If path, then name will be extracted from the end.
jsonjsonnode for storing JSON.
Returns
0, or a negative value from COSMOS Error Code definitions.
6327 {
6328  int32_t iretn;
6329  struct stat fstat;
6330  ifstream ifs;
6331  char *ibuf;
6332  string fname;
6333  string nodepath;
6334 
6335  size_t nodestart;
6336  if ((nodestart = node.rfind('/')) == string::npos)
6337  {
6338  nodepath = get_nodedir(node);
6339  }
6340  else
6341  {
6342  nodepath = node;
6343  node = node.substr(nodestart+1, string::npos);
6344  }
6345 
6346  // First: parse data for summary information - includes piece_cnt, device_cnt and port_cnt
6347  fname = nodepath + "/node.ini";
6348 
6349  if ((iretn=stat(fname.c_str(),&fstat)) == -1)
6350  {
6351  // cerr << "error " << DATA_ERROR_NODES_FOLDER << ": could not find cosmos/nodes folder" << endl;
6352  return (DATA_ERROR_NODES_FOLDER);
6353  //return (NODE_ERROR_NODE);
6354  }
6355 
6356  if (fstat.st_size)
6357  {
6358  ifs.open(fname);
6359  if (!ifs.is_open())
6360  {
6361  return (NODE_ERROR_NODE);
6362  }
6363 
6364  ibuf = (char *)calloc(1,fstat.st_size+1);
6365  ifs.read(ibuf, fstat.st_size);
6366  ifs.close();
6367  ibuf[fstat.st_size] = 0;
6368  json_out_node(json.node, node);
6369  json.node += ibuf;
6370  free(ibuf);
6371  }
6372 
6373  // 1A: load state vector, if it is present
6374  fname = nodepath + "/state.ini";
6375 
6376  if (!stat(fname.c_str(),&fstat) && fstat.st_size)
6377  {
6378  ifs.open(fname);
6379  if (ifs.is_open())
6380  {
6381  ibuf = (char *)calloc(1,fstat.st_size+1);
6382  ifs.read(ibuf, fstat.st_size);
6383  ifs.close();
6384  ibuf[fstat.st_size] = 0;
6385  json.state = ibuf;
6386  free(ibuf);
6387  }
6388  }
6389  // If not, use TLE if it is present
6390  else {
6391  fname = nodepath + "/state.tle";
6392 
6393  if (!stat(fname.c_str(),&fstat) && fstat.st_size)
6394  {
6395  int32_t iretn;
6396  cartpos eci;
6397  vector <tlestruc> tles;
6398  iretn = load_lines(fname, tles);
6399  if (iretn > 0)
6400  {
6401  if ((iretn=lines2eci(currentmjd()-10./1440., tles, eci)) == 0)
6402  {
6403  json_out_ecipos(json.state, eci);
6404  }
6405  }
6406  }
6407  }
6408 
6409  // Set node_utcstart
6410  fname = nodepath + "/node_utcstart.ini";
6411  double utcstart;
6412  if ((iretn=stat(fname.c_str(),&fstat)) == -1) {
6413  // First time, so write it
6414  utcstart = currentmjd();
6415  FILE *ifp = fopen(fname.c_str(), "w");
6416  if (ifp == nullptr)
6417  {
6418  return (NODE_ERROR_NODE);
6419  }
6420  fprintf(ifp, "%.15g", utcstart);
6421  fclose(ifp);
6422  } else {
6423  // Already set, so read it
6424  FILE *ifp = fopen(fname.c_str(), "r");
6425  if (ifp == nullptr)
6426  {
6427  // Still some problem, so just set it to current time
6428  utcstart = currentmjd();
6429  } else {
6430  iretn = fscanf(ifp, "%lg", &utcstart);
6431  if (iretn != 1)
6432  {
6433  utcstart = currentmjd();
6434  }
6435  fclose(ifp);
6436  }
6437  }
6438  json_out_utcstart(json.utcstart, utcstart);
6439 
6440  // Second: enter information for pieces
6441  fname = nodepath + "/vertices.ini";
6442  if (!stat(fname.c_str(),&fstat) && fstat.st_size)
6443  {
6444  ifs.open(fname);
6445  if (!ifs.is_open()) { return (NODE_ERROR_NODE); }
6446 
6447  ibuf = (char *)calloc(1,fstat.st_size+1);
6448  ifs.read(ibuf, fstat.st_size);
6449  ifs.close();
6450  ibuf[fstat.st_size] = 0;
6451  json.vertexs = ibuf;
6452  free(ibuf);
6453  }
6454 
6455  fname = nodepath + "/faces.ini";
6456  if (!stat(fname.c_str(),&fstat) && fstat.st_size)
6457  {
6458  ifs.open(fname);
6459  if (!ifs.is_open()) { return (NODE_ERROR_NODE); }
6460 
6461  ibuf = (char *)calloc(1,fstat.st_size+1);
6462  ifs.read(ibuf, fstat.st_size);
6463  ifs.close();
6464  ibuf[fstat.st_size] = 0;
6465  json.faces = ibuf;
6466  free(ibuf);
6467  }
6468 
6469 
6470  fname = nodepath + "/pieces.ini";
6471  if ((iretn=stat(fname.c_str(),&fstat)) == -1) { return (NODE_ERROR_NODE); }
6472 
6473  ifs.open(fname);
6474  if (!ifs.is_open()) { return (NODE_ERROR_NODE); }
6475 
6476  ibuf = (char *)calloc(1,fstat.st_size+1);
6477  ifs.read(ibuf, fstat.st_size);
6478  ifs.close();
6479  ibuf[fstat.st_size] = 0;
6480  json.pieces = ibuf;
6481  free(ibuf);
6482 
6483  // Third: enter information for all devices
6484  fname = nodepath + "/devices_general.ini";
6485  if ((iretn=stat(fname.c_str(),&fstat)) == -1) { return (NODE_ERROR_NODE); }
6486 
6487  ifs.open(fname);
6488  if (!ifs.is_open()) { return (NODE_ERROR_NODE); }
6489 
6490  ibuf = (char *)calloc(1,fstat.st_size+1);
6491  ifs.read(ibuf, fstat.st_size);
6492  ifs.close();
6493  ibuf[fstat.st_size] = 0;
6494  json.devgen = ibuf;
6495  free(ibuf);
6496 
6497  // Fourth: enter information for specific devices
6498  fname = nodepath + "/devices_specific.ini";
6499  if ((iretn=stat(fname.c_str(),&fstat)) == -1) { return (NODE_ERROR_NODE); }
6500 
6501  ifs.open(fname);
6502  if (!ifs.is_open()) { return (NODE_ERROR_NODE); }
6503 
6504  ibuf = (char *)calloc(1,fstat.st_size+1);
6505  ifs.read(ibuf, fstat.st_size);
6506  ifs.close();
6507  ibuf[fstat.st_size] = 0;
6508  json.devspec = ibuf;
6509  free(ibuf);
6510 
6511  // Fifth: enter information for ports
6512  // Resize, then add names for ports
6513  fname = nodepath + "/ports.ini";
6514  if ((iretn=stat(fname.c_str(),&fstat)) == -1) { return (NODE_ERROR_NODE); }
6515 
6516  ifs.open(fname);
6517  if (!ifs.is_open()) { return (NODE_ERROR_NODE); }
6518 
6519  ibuf = (char *)calloc(1,fstat.st_size+1);
6520  ifs.read(ibuf, fstat.st_size);
6521  ifs.close();
6522  ibuf[fstat.st_size] = 0;
6523  json.ports = ibuf;
6524  free(ibuf);
6525 
6526  // Load targeting information
6527  fname = nodepath + "/target.ini";
6528  if ((iretn=stat(fname.c_str(),&fstat)) == 0)
6529  {
6530  ifs.open(fname);
6531  if (ifs.is_open())
6532  {
6533  ibuf = (char *)calloc(1,fstat.st_size+1);
6534  ifs.read(ibuf, fstat.st_size);
6535  ifs.close();
6536  ibuf[fstat.st_size] = 0;
6537  json.targets = ibuf;
6538  free(ibuf);
6539  }
6540  }
6541 
6542  return 0;
6543 }
#define DATA_ERROR_NODES_FOLDER
Definition: cosmos-errno.h:154
double utcstart
Definition: fast_contacts.cpp:64
char ibuf[1000]
Definition: razor_imu.cpp:43
string devspec
Definition: jsondef.h:734
Cartesian full position structure.
Definition: convertdef.h:158
string faces
Definition: jsondef.h:731
string node
Definition: jsondef.h:727
int iretn
Definition: rw_test.cpp:37
int32_t json_out_ecipos(string &jstring, cartpos value)
ECI position to JSON.
Definition: jsonlib.cpp:2324
string pieces
Definition: jsondef.h:732
static char fname[100]
Definition: geomag.cpp:89
int32_t json_out_node(string &jstring, string value)
Node name to JSON.
Definition: jsonlib.cpp:2274
string targets
Definition: jsondef.h:736
string utcstart
Definition: jsondef.h:729
int32_t load_lines(string fname, vector< tlestruc > &lines)
Load TLE from file. TODO!!! Rename Function to loadTle and create new class for dealing with TLEs...
Definition: convertlib.cpp:3612
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
string ports
Definition: jsondef.h:735
string get_nodedir(string node, bool create_flag)
Get Current Node Directory.
Definition: datalib.cpp:1572
string state
Definition: jsondef.h:728
int32_t json_out_utcstart(string &jstring, double value)
UTC Start to JSON.
Definition: jsonlib.cpp:2299
string devgen
Definition: jsondef.h:733
static string node
Definition: agent_monitor.cpp:126
int lines2eci(double utc, vector< tlestruc >lines, cartpos &eci)
Return position from TLE set.
Definition: convertlib.cpp:3155
#define NODE_ERROR_NODE
Definition: cosmos-errno.h:143
string vertexs
Definition: jsondef.h:730
int32_t json_recenter_node ( cosmosstruc cinfo)
6546 {
6547  // Calculate centroid, normal and area for each face
6548  for (size_t i=0; i<cinfo->faces.size(); ++i)
6549  {
6550  if (cinfo->faces[i].vertex_cnt)
6551  {
6552  Vector fcentroid = cinfo->vertexs[cinfo->faces[i].vertex_idx[0]];
6553  fcentroid += cinfo->vertexs[cinfo->faces[i].vertex_idx[1]];
6554  Vector v1 = cinfo->vertexs[cinfo->faces[i].vertex_idx[0]] - cinfo->vertexs[cinfo->faces[i].vertex_idx[cinfo->faces[i].vertex_cnt-1]];
6555  Vector v2 = cinfo->vertexs[cinfo->faces[i].vertex_idx[1]] - cinfo->vertexs[cinfo->faces[i].vertex_idx[0]];
6556  Vector fnormal = v1.cross(v2);
6557  for (size_t j=2; j<cinfo->faces[i].vertex_cnt; ++j)
6558  {
6559  fcentroid += cinfo->vertexs[cinfo->faces[i].vertex_idx[j]];
6560  v1 = v2;
6561  v2 = cinfo->vertexs[cinfo->faces[i].vertex_idx[j]] - cinfo->vertexs[cinfo->faces[i].vertex_idx[j-1]];
6562  fnormal += v1.cross(v2);
6563  }
6564  v1 = v2;
6565  v2 = cinfo->vertexs[cinfo->faces[i].vertex_idx[0]] - cinfo->vertexs[cinfo->faces[i].vertex_idx[cinfo->faces[i].vertex_cnt-1]];
6566  fnormal += v1.cross(v2);
6567 
6568  fcentroid /= cinfo->faces[i].vertex_cnt;
6569  fnormal.normalize();
6570  cinfo->faces[i].normal = fnormal;
6571 
6572  cinfo->faces[i].com = Vector();
6573  cinfo->faces[i].area = 0.;
6574  v1 = cinfo->vertexs[cinfo->faces[i].vertex_idx[cinfo->faces[i].vertex_cnt-1]] - fcentroid;
6575  for (size_t j=0; j<cinfo->faces[i].vertex_cnt; ++j)
6576  {
6577  v2 = cinfo->vertexs[cinfo->faces[i].vertex_idx[j]] - fcentroid;
6578  // Area of triangle made by v1, v2 and Face centroid
6579  double tarea = v1.area(v2);
6580  // Sum
6581  cinfo->faces[i].area += tarea;
6582  // Centroid of triangle made by v1, v2 amd Face centroid
6583  Vector tcentroid = (v1 + v2 + fcentroid) / 3.;
6584  // Weighted sum
6585  cinfo->faces[i].com += tcentroid * tarea;
6586  v1 = v2;
6587  }
6588  // Divide by summed weights
6589  if (cinfo->faces[i].area)
6590  {
6591  cinfo->faces[i].com /= cinfo->faces[i].area;
6592  }
6593  }
6594  }
6595 
6596  Vector tcom = Vector();
6597  double tvolume = 0.;
6598  for (size_t i=0; i<cinfo->pieces.size(); ++i)
6599  {
6600  // Clean up any missing faces and calculate center of mass for each Piece using Faces
6601  cinfo->pieces[i].com = Vector ();
6602  for (size_t j=0; j<cinfo->pieces[i].face_cnt; ++j)
6603  {
6604  if (cinfo->faces.size() <= cinfo->pieces[i].face_idx[j])
6605  {
6606  cinfo->faces.resize(cinfo->pieces[i].face_idx[j]+1);
6607  cinfo->faces[cinfo->pieces[i].face_idx[j]].com = Vector ();
6608  cinfo->faces[cinfo->pieces[i].face_idx[j]].area = 0.;
6609  cinfo->faces[cinfo->pieces[i].face_idx[j]].normal = Vector ();
6610  }
6611  cinfo->pieces[i].com += cinfo->faces[cinfo->pieces[i].face_idx[j]].com;
6612  }
6613  if (cinfo->pieces[i].face_cnt)
6614  {
6615  cinfo->pieces[i].com /= cinfo->pieces[i].face_cnt;
6616  }
6617 
6618  // Calculate volume for each Piece using center of mass for each Face
6619  // Calculate normal for each Face that faces away from center of piece, or center of object
6620  cinfo->pieces[i].volume = 0.;
6621  for (size_t j=0; j<cinfo->pieces[i].face_cnt; ++j)
6622  {
6623  Vector dv = cinfo->faces[(cinfo->pieces[i].face_idx[j])].com - cinfo->pieces[i].com;
6624  if (dv.norm() != 0.)
6625  {
6626  cinfo->pieces[i].volume += cinfo->faces[(cinfo->pieces[i].face_idx[j])].area * dv.norm() / 3.;
6627  }
6628  }
6629  cinfo->node.face_cnt = cinfo->faces.size();
6630  tvolume += cinfo->pieces[i].volume;
6631  tcom += cinfo->pieces[i].com * cinfo->pieces[i].volume;
6632  }
6633  if (tvolume)
6634  {
6635  tcom /= tvolume;
6636  }
6637 
6638  // Calculate special norm for external panels
6639  for (size_t i=0; i<cinfo->pieces.size(); ++i)
6640  {
6641  if (cinfo->pieces[i].face_cnt == 1)
6642  {
6643  Vector dv = cinfo->faces[cinfo->pieces[i].face_idx[0]].com - tcom;
6644  if (dv.separation(cinfo->faces[cinfo->pieces[i].face_idx[0]].normal) > DPI2)
6645  {
6646  cinfo->normals.push_back(-cinfo->faces[cinfo->pieces[i].face_idx[0]].normal);
6647  cinfo->pieces[i].face_idx[0] = cinfo->normals.size() - 1;
6648  }
6649  }
6650  }
6651 
6652  // Recenter all vectors to object center of mass
6653  for (size_t i=0; i<cinfo->vertexs.size(); ++i)
6654  {
6655  cinfo->vertexs[i] -= tcom;
6656  }
6657 
6658  for (size_t i=0; i<cinfo->faces.size(); ++i)
6659  {
6660  cinfo->faces[i].com -= tcom;
6661  cinfo->faces[i].normal -= tcom;
6662  }
6663 
6664  for (size_t i=0; i<cinfo->pieces.size(); ++i)
6665  {
6666  cinfo->pieces[i].com -= tcom;
6667  }
6668  return 0;
6669 }
vector< facestruc > faces
Vector of all faces in node.
Definition: jsondef.h:4229
double norm()
Norm.
Definition: vector.cpp:1735
int i
Definition: rw_test.cpp:37
vector< vertexstruc > vertexs
Vector of all vertexs in node.
Definition: jsondef.h:4223
Vector cross(Vector b)
Cross product.
Definition: vector.cpp:1667
const double DPI2
Double precision PI/2.
Definition: math/constants.h:18
vector< vertexstruc > normals
Vector of all vertexs in node.
Definition: jsondef.h:4226
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
double area(Vector b)
Area subtended by two ::Vector.
Definition: vector.cpp:2018
double separation(Vector b)
Angular separation between two ::Vector.
Definition: vector.cpp:1997
Vector & normalize(double size=1.)
Normalize.
Definition: vector.cpp:1706
uint16_t face_cnt
Definition: jsondef.h:3569
vector< piecestruc > pieces
Vector of all pieces in node.
Definition: jsondef.h:4232
Vector Class.
Definition: vector.h:672
int32_t json_pushdevspec ( uint16_t  cidx,
cosmosstruc cinfo 
)

Antenna

Battery

Camera

Processing Unit

GPS Unit

Heater

Inertial Measurement Unit

Motor

Magnetic Torque Rod

Propellant Tank

Pressure Sensor

Rotor

Reaction Wheel

Radio Receiver

Elevation and Azimuth Sun Sensor

Photo Voltaic String

Star Tracker

Switch

Radio Transceiver

Thruster

Temperature Sensor

Radio Transmitter

6672 {
6673  switch (static_cast <DeviceType>(cinfo->device[cidx].type))
6674  {
6676  case DeviceType::ANT:
6677  cinfo->devspec.ant.push_back(cidx);
6678 // cinfo->devspec.ant.push_back((antstruc *)&cinfo->device[cidx].ant);
6679  cinfo->devspec.ant_cnt = (uint16_t)cinfo->devspec.ant.size();
6680  break;
6682  case DeviceType::BATT:
6683  cinfo->devspec.batt.push_back(cidx);
6684 // cinfo->devspec.batt.push_back((battstruc *)&cinfo->device[cidx].batt);
6685  cinfo->devspec.batt_cnt = (uint16_t)cinfo->devspec.batt.size();
6686  break;
6687  case DeviceType::BUS:
6688  cinfo->devspec.bus.push_back(cidx);
6689 // cinfo->devspec.bus.push_back((busstruc *)&cinfo->device[cidx].bus);
6690  cinfo->devspec.bus_cnt = (uint16_t)cinfo->devspec.bus.size();
6691  break;
6693  case DeviceType::CAM:
6694  cinfo->devspec.cam.push_back(cidx);
6695 // cinfo->devspec.cam.push_back((camstruc *)&cinfo->device[cidx].cam);
6696  cinfo->devspec.cam_cnt = (uint16_t)cinfo->devspec.cam.size();
6697  break;
6699  case DeviceType::CPU:
6700  cinfo->devspec.cpu.push_back(cidx);
6701 // cinfo->devspec.cpu.push_back((cpustruc *)&cinfo->device[cidx].cpu);
6702  cinfo->devspec.cpu_cnt = (uint16_t)cinfo->devspec.cpu.size();
6703  break;
6704  case DeviceType::DISK:
6705  cinfo->devspec.disk.push_back(cidx);
6706 // cinfo->devspec.disk.push_back((diskstruc *)&cinfo->device[cidx].disk);
6707  cinfo->devspec.disk_cnt = (uint16_t)cinfo->devspec.disk.size();
6708  break;
6710  case DeviceType::GPS:
6711  cinfo->devspec.gps.push_back(cidx);
6712 // cinfo->devspec.gps.push_back((gpsstruc *)&cinfo->device[cidx].gps);
6713  cinfo->devspec.gps_cnt = (uint16_t)cinfo->devspec.gps.size();
6714  break;
6716  case DeviceType::HTR:
6717  cinfo->devspec.htr.push_back(cidx);
6718 // cinfo->devspec.htr.push_back((htrstruc *)&cinfo->device[cidx].htr);
6719  cinfo->devspec.htr_cnt = (uint16_t)cinfo->devspec.htr.size();
6720  break;
6722  case DeviceType::IMU:
6723  cinfo->devspec.imu.push_back(cidx);
6724 // cinfo->devspec.imu.push_back((imustruc *)&cinfo->device[cidx].imu);
6725  cinfo->devspec.imu_cnt = (uint16_t)cinfo->devspec.imu.size();
6726  break;
6727  case DeviceType::MCC:
6728  cinfo->devspec.mcc.push_back(cidx);
6729 // cinfo->devspec.mcc.push_back((mccstruc *)&cinfo->device[cidx].mcc);
6730  cinfo->devspec.mcc_cnt = (uint16_t)cinfo->devspec.mcc.size();
6731  break;
6733  case DeviceType::MOTR:
6734  cinfo->devspec.motr.push_back(cidx);
6735 // cinfo->devspec.motr.push_back((motrstruc *)&cinfo->device[cidx].motr);
6736  cinfo->devspec.motr_cnt = (uint16_t)cinfo->devspec.motr.size();
6737  break;
6739  case DeviceType::MTR:
6740  cinfo->devspec.mtr.push_back(cidx);
6741 // cinfo->devspec.mtr.push_back((mtrstruc *)&cinfo->device[cidx].mtr);
6742  cinfo->devspec.mtr_cnt = (uint16_t)cinfo->devspec.mtr.size();
6743  break;
6744  case DeviceType::PLOAD:
6745  cinfo->devspec.pload.push_back(cidx);
6746 // cinfo->devspec.pload.push_back((ploadstruc *)&cinfo->device[cidx].pload);
6747  cinfo->devspec.pload_cnt = (uint16_t)cinfo->devspec.pload.size();
6748  break;
6750  case DeviceType::PROP:
6751  cinfo->devspec.prop.push_back(cidx);
6752 // cinfo->devspec.prop.push_back((propstruc *)&cinfo->device[cidx].prop);
6753  cinfo->devspec.prop_cnt = (uint16_t)cinfo->devspec.prop.size();
6754  break;
6756  case DeviceType::PSEN:
6757  cinfo->devspec.psen.push_back(cidx);
6758 // cinfo->devspec.psen.push_back((psenstruc *)&cinfo->device[cidx].psen);
6759  cinfo->devspec.psen_cnt = (uint16_t)cinfo->devspec.psen.size();
6760  break;
6761  case DeviceType::BCREG:
6762  cinfo->devspec.bcreg.push_back(cidx);
6763 // cinfo->devspec.bcreg.push_back((bcregstruc *)&cinfo->device[cidx].bcreg);
6764  cinfo->devspec.bcreg_cnt = (uint16_t)cinfo->devspec.bcreg.size();
6765  break;
6767  case DeviceType::ROT:
6768  cinfo->devspec.rot.push_back(cidx);
6769 // cinfo->devspec.rot.push_back((rotstruc *)&cinfo->device[cidx].rot);
6770  cinfo->devspec.rot_cnt = (uint16_t)cinfo->devspec.rot.size();
6771  break;
6773  case DeviceType::RW:
6774  cinfo->devspec.rw.push_back(cidx);
6775 // cinfo->devspec.rw.push_back((rwstruc *)&cinfo->device[cidx].rw);
6776  cinfo->devspec.rw_cnt = (uint16_t)cinfo->devspec.rw.size();
6777  break;
6779  case DeviceType::RXR:
6780  cinfo->devspec.rxr.push_back(cidx);
6781 // cinfo->devspec.rxr.push_back((rxrstruc *)&cinfo->device[cidx].rxr);
6782  cinfo->devspec.rxr_cnt = (uint16_t)cinfo->devspec.rxr.size();
6783  break;
6785  case DeviceType::SSEN:
6786  cinfo->devspec.ssen.push_back(cidx);
6787 // cinfo->devspec.ssen.push_back((ssenstruc *)&cinfo->device[cidx].ssen);
6788  cinfo->devspec.ssen_cnt = (uint16_t)cinfo->devspec.ssen.size();
6789  break;
6791  case DeviceType::PVSTRG:
6792  cinfo->devspec.pvstrg.push_back(cidx);
6793 // cinfo->devspec.pvstrg.push_back((pvstrgstruc *)&cinfo->device[cidx].pvstrg);
6794  cinfo->devspec.pvstrg_cnt = (uint16_t)cinfo->devspec.pvstrg.size();
6795  break;
6797  case DeviceType::STT:
6798  cinfo->devspec.stt.push_back(cidx);
6799 // cinfo->devspec.stt.push_back((sttstruc *)&cinfo->device[cidx].stt);
6800  cinfo->devspec.stt_cnt = (uint16_t)cinfo->devspec.stt.size();
6801  break;
6802  case DeviceType::SUCHI:
6803  {
6804  cinfo->devspec.suchi.push_back(cidx);
6805 // cinfo->devspec.suchi.push_back((suchistruc *)&cinfo->device[cidx].suchi);
6806  cinfo->devspec.suchi_cnt = (uint16_t)cinfo->devspec.suchi.size();
6807  }
6808  break;
6810  case DeviceType::SWCH:
6811  cinfo->devspec.swch.push_back(cidx);
6812 // cinfo->devspec.swch.push_back((swchstruc *)&cinfo->device[cidx].swch);
6813  cinfo->devspec.swch_cnt = (uint16_t)cinfo->devspec.swch.size();
6814  break;
6815  case DeviceType::TCU:
6816  cinfo->devspec.tcu.push_back(cidx);
6817 // cinfo->devspec.tcu.push_back((tcustruc *)&cinfo->device[cidx].tcu);
6818  cinfo->devspec.tcu_cnt = (uint16_t)cinfo->devspec.tcu.size();
6819  break;
6821  case DeviceType::TCV:
6822  cinfo->devspec.tcv.push_back(cidx);
6823 // cinfo->devspec.tcv.push_back((tcvstruc *)&cinfo->device[cidx].tcv);
6824  cinfo->devspec.tcv_cnt = (uint16_t)cinfo->devspec.tcv.size();
6825  break;
6826  case DeviceType::TELEM:
6827  cinfo->devspec.telem.push_back(cidx);
6828 // cinfo->devspec.telem.push_back((telemstruc *)&cinfo->device[cidx].telem);
6829  cinfo->devspec.telem_cnt = (uint16_t)cinfo->devspec.telem.size();
6830  break;
6832  case DeviceType::THST:
6833  cinfo->devspec.thst.push_back(cidx);
6834 // cinfo->devspec.thst.push_back((thststruc *)&cinfo->device[cidx].thst);
6835  cinfo->devspec.thst_cnt = (uint16_t)cinfo->devspec.thst.size();
6836  break;
6838  case DeviceType::TSEN:
6839  cinfo->devspec.tsen.push_back(cidx);
6840 // cinfo->devspec.tsen.push_back((tsenstruc *)&cinfo->device[cidx].tsen);
6841  cinfo->devspec.tsen_cnt = (uint16_t)cinfo->devspec.tsen.size();
6842  break;
6843  case DeviceType::TNC:
6844  cinfo->devspec.tnc.push_back(cidx);
6845 // cinfo->devspec.tnc.push_back((tncstruc *)&cinfo->device[cidx].tnc);
6846  cinfo->devspec.tnc_cnt = (uint16_t)cinfo->devspec.tnc.size();
6847  break;
6849  case DeviceType::TXR:
6850  cinfo->devspec.txr.push_back(cidx);
6851 // cinfo->devspec.txr.push_back((txrstruc *)&cinfo->device[cidx].txr);
6852  cinfo->devspec.txr_cnt = (uint16_t)cinfo->devspec.txr.size();
6853  break;
6854  case DeviceType::COUNT:
6855  case DeviceType::NONE:
6856  break;
6857  }
6858  return 0;
6859 }
Radio Receiver.
Definition: jsondef.h:508
Magnetic Torque Rod.
Definition: jsondef.h:500
uint16_t disk_cnt
Definition: jsondef.h:3868
Photo Voltaic String.
Definition: jsondef.h:514
uint16_t imu_cnt
Definition: jsondef.h:3871
vector< uint16_t > mtr
Definition: jsondef.h:3907
vector< uint16_t > stt
Definition: jsondef.h:3916
vector< uint16_t > prop
Definition: jsondef.h:3909
uint16_t mcc_cnt
Definition: jsondef.h:3872
uint16_t suchi_cnt
Definition: jsondef.h:3885
vector< uint16_t > bus
Definition: jsondef.h:3898
Reaction Wheel.
Definition: jsondef.h:498
Heater.
Definition: jsondef.h:518
vector< uint16_t > gps
Definition: jsondef.h:3902
vector< uint16_t > rxr
Definition: jsondef.h:3914
uint16_t tsen_cnt
Definition: jsondef.h:3891
Motor.
Definition: jsondef.h:520
Telemetry.
Definition: jsondef.h:546
Elevation and Azimuth Sun Sensor.
Definition: jsondef.h:494
uint16_t swch_cnt
Definition: jsondef.h:3886
uint16_t motr_cnt
Definition: jsondef.h:3873
uint16_t ssen_cnt
Definition: jsondef.h:3882
Not a Component.
Definition: jsondef.h:556
uint16_t bcreg_cnt
Definition: jsondef.h:3878
BCREG.
Definition: jsondef.h:552
vector< uint16_t > htr
Definition: jsondef.h:3903
vector< uint16_t > imu
Definition: jsondef.h:3904
uint16_t tcv_cnt
Definition: jsondef.h:3888
Rotor.
Definition: jsondef.h:530
vector< uint16_t > ant
Definition: jsondef.h:3895
vector< uint16_t > rw
Definition: jsondef.h:3913
uint16_t psen_cnt
Definition: jsondef.h:3877
uint16_t pload_cnt
Definition: jsondef.h:3875
vector< uint16_t > txr
Definition: jsondef.h:3925
vector< uint16_t > pload
Definition: jsondef.h:3908
vector< uint16_t > tcu
Definition: jsondef.h:3919
vector< devicestruc > device
Vector of all general (common) information for devices (components) in node.
Definition: jsondef.h:4238
uint16_t prop_cnt
Definition: jsondef.h:3876
vector< uint16_t > suchi
Definition: jsondef.h:3917
uint16_t telem_cnt
Definition: jsondef.h:3889
Radio Transceiver.
Definition: jsondef.h:512
uint16_t txr_cnt
Definition: jsondef.h:3893
List count.
Definition: jsondef.h:554
uint16_t tnc_cnt
Definition: jsondef.h:3892
vector< uint16_t > rot
Definition: jsondef.h:3912
uint16_t pvstrg_cnt
Definition: jsondef.h:3883
uint16_t gps_cnt
Definition: jsondef.h:3869
uint16_t batt_cnt
Definition: jsondef.h:3864
Thruster.
Definition: jsondef.h:524
vector< uint16_t > tcv
Definition: jsondef.h:3920
vector< uint16_t > disk
Definition: jsondef.h:3901
Payload.
Definition: jsondef.h:492
vector< uint16_t > motr
Definition: jsondef.h:3906
SUCHI.
Definition: jsondef.h:542
uint16_t bus_cnt
Definition: jsondef.h:3865
vector< uint16_t > cam
Definition: jsondef.h:3899
vector< uint16_t > thst
Definition: jsondef.h:3922
Camera.
Definition: jsondef.h:544
vector< uint16_t > telem
Definition: jsondef.h:3921
Pressure sensor.
Definition: jsondef.h:540
uint16_t cpu_cnt
Definition: jsondef.h:3867
uint16_t rw_cnt
Definition: jsondef.h:3880
vector< uint16_t > tsen
Definition: jsondef.h:3924
Power Bus.
Definition: jsondef.h:538
Propellant Tank.
Definition: jsondef.h:526
vector< uint16_t > cpu
Definition: jsondef.h:3900
vector< uint16_t > bcreg
Definition: jsondef.h:3897
GPS Unit.
Definition: jsondef.h:504
Processing Unit.
Definition: jsondef.h:502
uint16_t ant_cnt
Definition: jsondef.h:3863
Antenna.
Definition: jsondef.h:506
vector< uint16_t > tnc
Definition: jsondef.h:3923
Battery.
Definition: jsondef.h:516
uint16_t rxr_cnt
Definition: jsondef.h:3881
uint16_t rot_cnt
Definition: jsondef.h:3879
uint16_t thst_cnt
Definition: jsondef.h:3890
Star Tracker.
Definition: jsondef.h:532
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
uint16_t tcu_cnt
Definition: jsondef.h:3887
TNC.
Definition: jsondef.h:550
vector< uint16_t > swch
Definition: jsondef.h:3918
Torque rod Control Unit.
Definition: jsondef.h:536
Disk Drive.
Definition: jsondef.h:548
vector< uint16_t > psen
Definition: jsondef.h:3910
uint16_t mtr_cnt
Definition: jsondef.h:3874
uint16_t cam_cnt
Definition: jsondef.h:3866
Radio Transmitter.
Definition: jsondef.h:510
Inertial Measurement Unit.
Definition: jsondef.h:496
Switch.
Definition: jsondef.h:528
vector< uint16_t > batt
Definition: jsondef.h:3896
uint16_t htr_cnt
Definition: jsondef.h:3870
vector< uint16_t > pvstrg
Definition: jsondef.h:3911
Temperature Sensor.
Definition: jsondef.h:522
vector< uint16_t > mcc
Definition: jsondef.h:3905
uint16_t stt_cnt
Definition: jsondef.h:3884
Motion Capture Camera.
Definition: jsondef.h:534
vector< uint16_t > ssen
Definition: jsondef.h:3915
int32_t json_setup_node ( jsonnode  json,
cosmosstruc cinfo,
bool  create_flag 
)

Setup JSON Namespace using Node description JSON.

Create an entry in the JSON mapping tables between each name in the Name Space and the cosmosstruc. Load descriptive information from a structure of JSON descriptions.

Parameters
jsonStructure containing JSON descriptions.
cinfoPointer to cinfo cosmosstruc.
create_flagWhether or not to create node directory if it doesn't already exist.
Returns
0, or a negative COSMOS Error Code definitions

Load targeting information

6870 {
6871  int32_t iretn;
6872  ifstream ifs;
6873  string fname;
6874 
6875  if (!cinfo->jmapped)
6876  {
6877  return (JSON_ERROR_NOJMAP);
6878  }
6879 
6880  cinfo->node.utcoffset = 0.;
6881  // First: parse data for summary information - includes piece_cnt, device_cnt and port_cnt
6882  if (!json.node.empty())
6883  {
6884  // NS1
6885  // if ((iretn = json_parse(json.node, cinfo)) < 0 && iretn != JSON_ERROR_EOS)
6886  // NS2 maybe use set_json? do we even need this? what is the purpose of jsonnode?
6887  if ((iretn = json_parse(json.node, cinfo)) < 0 && iretn != JSON_ERROR_EOS)
6888  {
6889  return iretn;
6890  }
6891  }
6892  else
6893  {
6894  return NODE_ERROR_NODE;
6895  }
6896 
6897  string nodepath;
6898 // cinfo->name = cinfo->node.name;
6899  bool dump_flag = false;
6900  if (create_flag)
6901  {
6902  if ((nodepath = get_nodedir(cinfo->node.name)).empty())
6903  {
6904  dump_flag = true;
6905  }
6906  }
6907  nodepath = get_nodedir(cinfo->node.name, create_flag);
6908 
6909  // 1A: load state vector, if it is present
6910  if (!json.state.empty())
6911  {
6912  // NS1
6913  // if ((iretn = json_parse(json.state, cinfo)) < 0 && iretn != JSON_ERROR_EOS)
6914  // NS2 maybe use set_json? do we even need this? what is the purpose of jsonnode?
6915  if ((iretn = json_parse(json.state, cinfo)) < 0 && iretn != JSON_ERROR_EOS)
6916  {
6917  return iretn;
6918  }
6919  // loc_update(&cinfo->node.loc);
6920  }
6921 
6922  // Set node_utcstart
6923  if (!json.utcstart.empty())
6924  {
6925  // NS1
6926  // if ((iretn = json_parse(json.utcstart, cinfo)) < 0 && iretn != JSON_ERROR_EOS)
6927  // NS2 maybe use set_json? do we even need this? what is the purpose of jsonnode?
6928  if ((iretn = json_parse(json.utcstart, cinfo)) < 0 && iretn != JSON_ERROR_EOS)
6929  {
6930  return iretn;
6931  }
6932  }
6933 
6934  // Second: enter information for pieces
6935  // Vertices
6936  cinfo->vertexs.clear();
6937  if (cinfo->node.vertex_cnt)
6938  {
6939  // be careful about resizing vertex past MAX_NUMBER_VERTEXS
6940  cinfo->vertexs.resize(cinfo->node.vertex_cnt);
6941  if (cinfo->vertexs.size() != cinfo->node.vertex_cnt)
6942  {
6943  return (AGENT_ERROR_MEMORY);
6944  }
6945  for (uint16_t i=0; i<cinfo->node.vertex_cnt; i++)
6946  {
6947  //Add relevant names to namespace
6948  json_mapvertexentry(i, cinfo);
6949  }
6950 
6951  // Parse data for vertex information
6952  if (!json.vertexs.empty())
6953  {
6954  if ((iretn = json_parse(json.vertexs, cinfo)) < 0 && iretn != JSON_ERROR_EOS)
6955  {
6956  return iretn;
6957  }
6958  }
6959  }
6960 
6961 
6962  // Faces
6963  cinfo->faces.clear();
6964  if (cinfo->node.face_cnt)
6965  {
6966  cinfo->faces.resize(cinfo->node.face_cnt);
6967  if (cinfo->faces.size() != cinfo->node.face_cnt)
6968  {
6969  return (AGENT_ERROR_MEMORY);
6970  }
6971 
6972  for (uint16_t i=0; i<cinfo->node.face_cnt; i++)
6973  {
6974  //Add relevant names to namespace
6975  json_mapfaceentry(i, cinfo);
6976  }
6977 
6978  // Parse data for face information
6979  if (!json.faces.empty())
6980  {
6981  if ((iretn = json_parse(json.faces, cinfo)) < 0 && iretn != JSON_ERROR_EOS)
6982  {
6983  return iretn;
6984  }
6985  }
6986 
6987  // Do it a second time because now we know how many vertices in each face.
6988  for (uint16_t i=0; i<cinfo->node.face_cnt; i++)
6989  {
6990  //Add relevant names to namespace
6991  cinfo->faces[i].vertex_idx.resize(cinfo->faces[i].vertex_cnt);
6992  json_mapfaceentry(i, cinfo);
6993  }
6994 
6995  // Parse data for face information
6996  if (!json.faces.empty())
6997  {
6998  if ((iretn = json_parse(json.faces, cinfo)) < 0 && iretn != JSON_ERROR_EOS)
6999  {
7000  return iretn;
7001  }
7002  }
7003  }
7004 
7005  // Resize, then add entries to map for pieces
7006  cinfo->pieces.clear();
7007  if (cinfo->node.piece_cnt)
7008  {
7009  cinfo->pieces.resize(cinfo->node.piece_cnt);
7010  if (cinfo->pieces.size() != cinfo->node.piece_cnt)
7011  {
7012  return (AGENT_ERROR_MEMORY);
7013  }
7014 
7015  for (uint16_t i=0; i<cinfo->node.piece_cnt; i++)
7016  {
7017  // Initialize to disabled
7018  cinfo->pieces[i].enabled = false;
7019  cinfo->pieces[i].face_cnt = 0;
7020  //Add relevant names to namespace
7021  json_mappieceentry(i, cinfo);
7022  // Initialize to no component
7023  cinfo->pieces[i].cidx = DeviceType::NONE;
7024  }
7025 
7026  // Parse data for piece information
7027  if (!json.pieces.empty())
7028  {
7029  if ((iretn = json_parse(json.pieces, cinfo)) < 0 && iretn != JSON_ERROR_EOS)
7030  {
7031  return iretn;
7032  }
7033  }
7034 
7035  // Do it a second time, now that we know how many faces in each piece
7036  for (uint16_t i=0; i<cinfo->node.piece_cnt; i++)
7037  {
7038  cinfo->pieces[i].face_idx.resize(cinfo->pieces[i].face_cnt);
7039  json_mappieceentry(i, cinfo);
7040  }
7041 
7042  // Parse data for piece information
7043  if (!json.pieces.empty())
7044  {
7045  if ((iretn = json_parse(json.pieces, cinfo)) < 0 && iretn != JSON_ERROR_EOS)
7046  {
7047  return iretn;
7048  }
7049  }
7050 
7051  // Work through jmap, enabling each piece for which piece_type has been enabled
7052  for (size_t i=0; i<cinfo->node.piece_cnt; i++)
7053  {
7054  cinfo->pieces[i].enabled = json_checkentry("piece_name", i, UINT16_MAX, cinfo);
7055  }
7056 
7057  // Third: enter information for all devices
7058  // Resize, then add entries to map for devices
7059  cinfo->device.resize(cinfo->node.device_cnt);
7060  if (cinfo->device.size() != cinfo->node.device_cnt)
7061  {
7062  return (AGENT_ERROR_MEMORY);
7063  }
7064 
7065  // Add entries to map for Devices and set pointers in nodestruc for comp and devspec
7066  for (uint16_t i=0; i< cinfo->node.device_cnt; i++)
7067  {
7068  // Initialize to disabled
7069  cinfo->device[i].enabled = false;
7070  // Add relevant names for generic device to namespace
7071  json_mapcompentry(i, cinfo);
7072  // Initialize to no port
7073  cinfo->device[i].portidx = PORT_TYPE_NONE;
7074  }
7075 
7076  // Parse data for general device information
7077  if (!json.devgen.empty())
7078  {
7079  if ((iretn = json_parse(json.devgen, cinfo)) < 0 && iretn != JSON_ERROR_EOS)
7080  {
7081  return iretn;
7082  }
7083  }
7084 
7085  // Fix any mis registered pieces
7086  for (size_t i=0; i < cinfo->node.piece_cnt; ++i)
7087  {
7088  if (cinfo->pieces[i].cidx != UINT16_MAX)
7089  {
7090  if (cinfo->pieces[i].cidx >= cinfo->device.size())
7091  {
7092  cinfo->pieces[i].cidx = UINT16_MAX;
7093  } else {
7094  cinfo->device[cinfo->pieces[i].cidx].pidx = i;
7095  }
7096  }
7097  }
7098 
7099  // Work through jmap, enabling each device for which device_type has been enabled
7100  for (size_t i=0; i<cinfo->node.device_cnt; i++)
7101  {
7102  cinfo->device[i].enabled = json_checkentry("device_type", i, UINT16_MAX, cinfo);
7103  }
7104 
7105  // Fourth: enter information for specific devices
7106  // Add entries to map for Devices specific information
7107  for (uint16_t i=0; i< cinfo->node.device_cnt; i++)
7108  {
7109  json_mapdeviceentry(cinfo->device[i], cinfo);
7110  json_pushdevspec(i, cinfo);
7111  }
7112 
7113  // Parse data for specific device information
7114  if (!json.devspec.empty())
7115  {
7116  if ((iretn = json_parse(json.devspec, cinfo)) < 0 && iretn != JSON_ERROR_EOS)
7117  {
7118  return iretn;
7119  }
7120  }
7121 
7122  // Clean up any errors and perform some initializations
7123  for (uint16_t i=0; i< cinfo->node.device_cnt; i++)
7124  {
7125  cinfo->device[i].cidx = i;
7126  cinfo->device[i].amp = cinfo->device[i].namp;
7127  cinfo->device[i].volt = cinfo->device[i].nvolt;
7128  }
7129 
7130  // Fifth: enter information for ports
7131  // Resize, then add names for ports
7132  cinfo->port.resize(cinfo->node.port_cnt);
7133  if (cinfo->port.size() != cinfo->node.port_cnt)
7134  {
7135  return (AGENT_ERROR_MEMORY);
7136  }
7137 
7138  for (uint16_t i=0; i<cinfo->node.port_cnt; i++)
7139  {
7140  json_mapportentry(i, cinfo);
7141  }
7142 
7143  // Parse data for port information
7144  if (!json.ports.empty())
7145  {
7146  if ((iretn = json_parse(json.ports, cinfo)) < 0 && iretn != JSON_ERROR_EOS)
7147  {
7148  return iretn;
7149  }
7150  }
7151 
7152  node_calc(cinfo);
7153 
7155  if (!json.targets.empty())
7156  {
7157  if ((iretn = json_parse(json.targets, cinfo)) < 0 && iretn != JSON_ERROR_EOS)
7158  {
7159  return iretn;
7160  }
7161  }
7162  }
7163 
7164  cinfo->json = json;
7165 
7166  if (cinfo->node.type == NODE_TYPE_SUN)
7167  {
7169  cinfo->node.loc.pos.eci.pass++;
7170  pos_eci(&cinfo->node.loc);
7171  }
7172 
7173  if (cinfo->node.type == NODE_TYPE_MOON)
7174  {
7176  cinfo->node.loc.pos.eci.pass++;
7177  pos_eci(&cinfo->node.loc);
7178  }
7179 
7180  if (cinfo->node.type == NODE_TYPE_MARS)
7181  {
7183  cinfo->node.loc.pos.eci.pass++;
7184  pos_eci(&cinfo->node.loc);
7185  }
7186 
7187  if (dump_flag && !nodepath.empty()) { json_dump_node(cinfo); }
7188 
7189  return 0;
7190 }
#define AGENT_ERROR_MEMORY
Definition: cosmos-errno.h:107
vector< portstruc > port
Vector of all ports known to node.
Definition: jsondef.h:4244
vector< facestruc > faces
Vector of all faces in node.
Definition: jsondef.h:4229
uint16_t device_cnt
Definition: jsondef.h:3571
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
uint16_t json_mapdeviceentry(const devicestruc &device, cosmosstruc *cinfo)
Add device entry.
Definition: jsonlib.cpp:7777
#define JSON_ERROR_NOJMAP
Definition: cosmos-errno.h:93
int i
Definition: rw_test.cpp:37
int32_t json_parse(string jstring, cosmosstruc *cinfo)
Parse JSON using Name Space.
Definition: jsonlib.cpp:4799
Definition: cosmos-defs.h:101
string devspec
Definition: jsondef.h:734
uint32_t pass
pass indicator: allows synchronization with other attitude and position values.
Definition: convertdef.h:170
string faces
Definition: jsondef.h:731
vector< vertexstruc > vertexs
Vector of all vertexs in node.
Definition: jsondef.h:4223
uint16_t json_mapportentry(uint16_t portidx, cosmosstruc *cinfo)
Add port entry.
Definition: jsonlib.cpp:8652
Not a Component.
Definition: jsondef.h:556
string node
Definition: jsondef.h:727
int iretn
Definition: rw_test.cpp:37
bool json_checkentry(string name, uint16_t d1, uint16_t d2, cosmosstruc *cinfo)
Check the enable state of an entry in the JSON Namespace map.
Definition: jsonlib.cpp:1258
uint16_t piece_cnt
Definition: jsondef.h:3570
#define JPL_SUN
Definition: convertdef.h:120
int32_t json_dump_node(cosmosstruc *cinfo)
Save Node entries to disk.
Definition: jsonlib.cpp:7233
#define JPL_MOON
Definition: convertdef.h:119
#define JPL_MARS
Definition: convertdef.h:113
vector< devicestruc > device
Vector of all general (common) information for devices (components) in node.
Definition: jsondef.h:4238
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
uint16_t port_cnt
Definition: jsondef.h:3572
int32_t json_mapfaceentry(uint16_t fidx, cosmosstruc *cinfo)
Add face entry.
Definition: jsonlib.cpp:7605
double utcoffset
MJD Offset between system UT and simulated UT.
Definition: jsondef.h:3590
string pieces
Definition: jsondef.h:732
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
static char fname[100]
Definition: geomag.cpp:89
char name[40+1]
Node Name.
Definition: jsondef.h:3556
locstruc loc
Location structure.
Definition: jsondef.h:3596
int32_t json_mapcompentry(uint16_t cidx, cosmosstruc *cinfo)
Add component entry.
Definition: jsonlib.cpp:7708
string targets
Definition: jsondef.h:736
int32_t pos_eci(locstruc *loc)
Set ECI position.
Definition: convertlib.cpp:258
uint16_t vertex_cnt
Definition: jsondef.h:3567
string utcstart
Definition: jsondef.h:729
#define JPL_EARTH
Definition: convertdef.h:112
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
jsonnode json
JSON descriptive information.
Definition: jsondef.h:4262
int32_t node_calc(cosmosstruc *cinfo)
Calculate Satellite configuration values.
Definition: jsonlib.cpp:10859
string ports
Definition: jsondef.h:735
string get_nodedir(string node, bool create_flag)
Get Current Node Directory.
Definition: datalib.cpp:1572
posstruc pos
posstruc for this time.
Definition: convertdef.h:881
string state
Definition: jsondef.h:728
uint16_t face_cnt
Definition: jsondef.h:3569
Definition: cosmos-defs.h:100
vector< piecestruc > pieces
Vector of all pieces in node.
Definition: jsondef.h:4232
cartpos eci
Definition: convertdef.h:737
int32_t jplpos(long from, long to, double utc, cartpos *pos)
Position from JPL Ephemeris.
Definition: ephemlib.cpp:128
int32_t json_mapvertexentry(uint16_t vidx, cosmosstruc *cinfo)
Add vertex entry.
Definition: jsonlib.cpp:7580
string devgen
Definition: jsondef.h:733
Definition: jsondef.h:655
uint16_t type
Node Type as listed in NODE_TYPE.
Definition: jsondef.h:3562
int32_t json_pushdevspec(uint16_t cidx, cosmosstruc *cinfo)
Definition: jsonlib.cpp:6671
Definition: cosmos-defs.h:102
#define NODE_ERROR_NODE
Definition: cosmos-errno.h:143
string vertexs
Definition: jsondef.h:730
int32_t json_mappieceentry(uint16_t pidx, cosmosstruc *cinfo)
Add piece entry.
Definition: jsonlib.cpp:7635
int32_t json_setup_node ( string &  node,
cosmosstruc cinfo 
)

Setup JSON Namespace using file.

Create an entry in the JSON mapping tables between each name in the Name Space and the cosmosstruc. Load descriptive information from files in a Node directory of the goven name.

Parameters
nodeName and/or path of node directory. If name, then a path will be created based on nodedir setting. If path, then name will be extracted from the end.
cinfoPointer to cinfo cosmosstruc.
Returns
0, or a negative value from COSMOS Error Code definitions.
7201 {
7202  if (cinfo == nullptr) { return (JSON_ERROR_NOJMAP); }
7203 
7204  if (node.empty())
7205  {
7207  node = deviceCpu.getHostName();
7208  if (node.empty()) { return JSON_ERROR_NAME_LENGTH; }
7209  }
7210 
7211  if (node.length() > COSMOS_MAX_NAME) { node = node.substr(0, COSMOS_MAX_NAME); }
7212 
7213  jsonnode json;
7214  int32_t iretn = json_load_node(node, json);
7215  if (iretn < 0 || json.node.empty())
7216  {
7217  iretn = json_create_node(cinfo, node);
7218  return iretn;
7219  }
7220 
7221  iretn = json_setup_node(json, cinfo);
7222  if (iretn < 0) { return iretn; }
7223 
7224  return 0;
7225 }
int32_t json_load_node(string node, jsonnode &json)
Map Name Space to global data structure components and pieces.
Definition: jsonlib.cpp:6326
#define JSON_ERROR_NOJMAP
Definition: cosmos-errno.h:93
int32_t json_setup_node(jsonnode json, cosmosstruc *cinfo, bool create_flag)
Setup JSON Namespace using Node description JSON.
Definition: jsonlib.cpp:6869
int32_t json_create_node(cosmosstruc *cinfo, string &node_name, uint16_t node_type)
Definition: jsonlib.cpp:517
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
string node
Definition: jsondef.h:727
int iretn
Definition: rw_test.cpp:37
static DeviceCpu deviceCpu
Definition: agent_cpu-2-0.cpp:77
Definition: devicecpu.h:239
#define JSON_ERROR_NAME_LENGTH
Definition: cosmos-errno.h:90
string getHostName()
Definition: devicecpu.cpp:205
Definition: jsondef.h:724
static string node
Definition: agent_monitor.cpp:126
int32_t json_dump_node ( cosmosstruc cinfo)

Save Node entries to disk.

Create all of the initialization files that represent the Node in the provided cosmosstruc.

Parameters
cinfoReference to cosmosstruc to use.
Returns
Zero if successful, otherwise negative error.
7234 {
7235  string jst;
7236  string filename;
7237  json_mapentries(cinfo);
7238 
7239  // Node
7240  string output = json_node(jst, cinfo);
7241  string fileloc = get_nodedir(cinfo->node.name, true);
7242  if (fileloc.empty()) { return DATA_ERROR_NODES_FOLDER; }
7243  rename((fileloc+"/node.ini").c_str(), (fileloc+"/node.ini.old").c_str());
7244  // string filename = fileloc + "/node.ini";
7245  FILE *file = fopen((fileloc+"/node.ini").c_str(), "w");
7246  if (file == nullptr) { return -errno; }
7247  fputs(output.c_str(), file);
7248  fclose(file);
7249 
7250  // Vertices
7251  output = json_vertices(jst, cinfo);
7252  rename((fileloc+"/vertices.ini").c_str(), (fileloc+"/vertices.ini.old").c_str());
7253  // filename = fileloc + "/vertices.ini";
7254  file = fopen((fileloc + "/vertices.ini").c_str(), "w");
7255  if (file == nullptr) { return -errno; }
7256  fputs(output.c_str(), file);
7257  fclose(file);
7258 
7259  // cinfo->faces
7260  output = json_faces(jst, cinfo);
7261  rename((fileloc+"/faces.ini").c_str(), (fileloc+"/faces.ini.old").c_str());
7262  // filename = fileloc + "/faces.ini";
7263  file = fopen((fileloc + "/faces.ini").c_str(), "w");
7264  if (file == nullptr) { return -errno; }
7265  fputs(output.c_str(), file);
7266  fclose(file);
7267 
7268  // Pieces
7269  output = json_pieces(jst, cinfo);
7270  rename((fileloc+"/pieces.ini").c_str(), (fileloc+"/pieces.ini.old").c_str());
7271  // filename = fileloc + "/pieces.ini";
7272  file = fopen((fileloc + "/pieces.ini").c_str(), "w");
7273  if (file == nullptr) { return -errno; }
7274  fputs(output.c_str(), file);
7275  fclose(file);
7276 
7277  // General Devices
7278  output = json_devices_general(jst, cinfo);
7279  rename((fileloc+"/devices_general.ini").c_str(), (fileloc+"/devices_general.ini.old").c_str());
7280  // filename = fileloc + "/devices_general.ini";
7281  file = fopen((fileloc + "/devices_general.ini").c_str(), "w");
7282  if (file == nullptr) { return -errno; }
7283  fputs(output.c_str(), file);
7284  fclose(file);
7285 
7286  // Specific Devices
7287  output = json_devices_specific(jst, cinfo);
7288  rename((fileloc+"/devices_specific.ini").c_str(), (fileloc+"/devices_specific.ini.old").c_str());
7289  // filename = fileloc + "/devices_specific.ini";
7290  file = fopen((fileloc + "/devices_specific.ini").c_str(), "w");
7291  if (file == nullptr) { return -errno; }
7292  fputs(output.c_str(), file);
7293  fclose(file);
7294 
7295  // Ports
7296  output = json_ports(jst, cinfo);
7297  rename((fileloc+"/ports.ini").c_str(), (fileloc+"/ports.ini.old").c_str());
7298  // filename = fileloc + "/ports.ini";
7299  file = fopen((fileloc + "/ports.ini").c_str(), "w");
7300  if (file == nullptr) { return -errno; }
7301  fputs(output.c_str(), file);
7302  fclose(file);
7303 
7304  // Equations
7305  if (cinfo->equation.size())
7306  {
7307  rename((fileloc+"/equations.ini").c_str(), (fileloc+"/equations.ini.old").c_str());
7308  file = fopen((fileloc+"/equations.ini").c_str(), "w");
7309  if (file == nullptr) { return -errno; }
7310  for (equationstruc &equation : cinfo->equation) {
7311  fprintf(file, "%s %s\n", equation.name.c_str(), equation.value.c_str());
7312  }
7313  fclose(file);
7314  }
7315  return 0;
7316 }
#define DATA_ERROR_NODES_FOLDER
Definition: cosmos-errno.h:154
Equation structure.
Definition: jsondef.h:1249
string name
Definition: jsondef.h:1252
string output
Definition: agent-2-0.cpp:56
const char * json_ports(string &jstring, cosmosstruc *cinfo)
Dump Port description.
Definition: jsonlib.cpp:10536
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
string value
Definition: jsondef.h:1254
const char * json_node(string &jstring, cosmosstruc *cinfo)
Dump Node description.
Definition: jsonlib.cpp:9960
vector< equationstruc > equation
Vector of Equations.
Definition: jsondef.h:4217
const char * json_devices_specific(string &jstring, cosmosstruc *cinfo)
Dump Specific Device description.
Definition: jsonlib.cpp:10158
char name[40+1]
Node Name.
Definition: jsondef.h:3556
const char * json_pieces(string &jstring, cosmosstruc *cinfo)
Dump Piece description.
Definition: jsonlib.cpp:10055
string get_nodedir(string node, bool create_flag)
Get Current Node Directory.
Definition: datalib.cpp:1572
const char * json_faces(string &jstring, cosmosstruc *cinfo)
Dump Face description.
Definition: jsonlib.cpp:10016
int32_t json_mapentries(cosmosstruc *cinfo)
Definition: jsonlib.cpp:7324
const char * json_vertices(string &jstring, cosmosstruc *cinfo)
Dump Vertex description.
Definition: jsonlib.cpp:9989
const char * json_devices_general(string &jstring, cosmosstruc *cinfo)
Dump General Device description.
Definition: jsonlib.cpp:10112
int32_t json_mapentries ( cosmosstruc cinfo)

Map all entries in JMAP Add or update all possible entries in the Namespace map.

Parameters
cinfoReference to cosmosstruc to use.
Returns
The current number of entries, if successful, 0 if the entry could not be mapped.
7325 {
7326  json_mapbaseentries(cinfo);
7327 
7328  for (uint16_t i=0; i<cinfo->node.vertex_cnt; i++)
7329  {
7330  json_mapvertexentry(i, cinfo);
7331  }
7332 
7333  for (uint16_t i=0; i<cinfo->node.face_cnt; i++)
7334  {
7335  json_mapfaceentry(i, cinfo);
7336  }
7337 
7338  for (uint16_t i=0; i<cinfo->node.piece_cnt; i++)
7339  {
7340  json_mappieceentry(i, cinfo);
7341  }
7342 
7343  for (uint16_t i=0; i<cinfo->node.device_cnt; i++)
7344  {
7345  json_mapcompentry(i, cinfo);
7346  }
7347 
7348  for (uint16_t i=0; i<cinfo->node.device_cnt; i++)
7349  {
7350  json_mapdeviceentry(cinfo->device[i], cinfo);
7351  }
7352 
7353  for (uint16_t i=0; i<cinfo->node.port_cnt; i++)
7354  {
7355  json_mapportentry(i, cinfo);
7356  }
7357 
7358  return cinfo->jmapped;
7359 }
int32_t json_mapbaseentries(cosmosstruc *cinfo)
Add base entries to JMAP.
Definition: jsonlib.cpp:7368
uint16_t device_cnt
Definition: jsondef.h:3571
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
uint16_t json_mapdeviceentry(const devicestruc &device, cosmosstruc *cinfo)
Add device entry.
Definition: jsonlib.cpp:7777
int i
Definition: rw_test.cpp:37
uint16_t json_mapportentry(uint16_t portidx, cosmosstruc *cinfo)
Add port entry.
Definition: jsonlib.cpp:8652
uint16_t piece_cnt
Definition: jsondef.h:3570
vector< devicestruc > device
Vector of all general (common) information for devices (components) in node.
Definition: jsondef.h:4238
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
uint16_t port_cnt
Definition: jsondef.h:3572
int32_t json_mapfaceentry(uint16_t fidx, cosmosstruc *cinfo)
Add face entry.
Definition: jsonlib.cpp:7605
int32_t json_mapcompentry(uint16_t cidx, cosmosstruc *cinfo)
Add component entry.
Definition: jsonlib.cpp:7708
uint16_t vertex_cnt
Definition: jsondef.h:3567
uint16_t face_cnt
Definition: jsondef.h:3569
int32_t json_mapvertexentry(uint16_t vidx, cosmosstruc *cinfo)
Add vertex entry.
Definition: jsonlib.cpp:7580
int32_t json_mappieceentry(uint16_t pidx, cosmosstruc *cinfo)
Add piece entry.
Definition: jsonlib.cpp:7635
int32_t json_mapbaseentries ( cosmosstruc cinfo)

Add base entries to JMAP.

Add all of the base entries to the Namespace map.

Parameters
cinfoReference to cosmosstruc to use.
Returns
The current number of entries, if successful, 0 if the entry could not be
7369 {
7370  int32_t iretn;
7371 
7372  // User structure
7373  iretn = json_addentry("user_node", UINT16_MAX, UINT16_MAX,offsetof(userstruc,node), (uint16_t)JSON_TYPE_NAME, JSON_STRUCT_USER, cinfo);
7374  json_addentry("user_name", UINT16_MAX, UINT16_MAX,offsetof(userstruc,name), (uint16_t)JSON_TYPE_NAME, JSON_STRUCT_USER, cinfo);
7375  json_addentry("user_tool", UINT16_MAX, UINT16_MAX,offsetof(userstruc,tool), (uint16_t)JSON_TYPE_NAME, JSON_STRUCT_USER, cinfo);
7376  json_addentry("user_cpu", UINT16_MAX, UINT16_MAX,offsetof(userstruc,cpu), (uint16_t)JSON_TYPE_NAME, JSON_STRUCT_USER, cinfo);
7377 
7378 
7379  // Agent structure
7380  json_addentry("agent_addr", UINT16_MAX, UINT16_MAX,offsetof(agentstruc,beat)+offsetof(beatstruc,addr), (uint16_t)JSON_TYPE_NAME, JSON_STRUCT_AGENT, cinfo);
7381  json_addentry("agent_aprd", UINT16_MAX, UINT16_MAX,offsetof(agentstruc,aprd), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_AGENT, cinfo, JSON_UNIT_TIME);
7382  json_addentry("agent_beat", UINT16_MAX, UINT16_MAX,offsetof(agentstruc,beat), (uint16_t)JSON_TYPE_HBEAT, JSON_STRUCT_AGENT, cinfo);
7383  json_addentry("agent_bprd", UINT16_MAX, UINT16_MAX,offsetof(agentstruc,beat)+offsetof(beatstruc,bprd), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_AGENT, cinfo, JSON_UNIT_TIME);
7384  json_addentry("agent_bsz", UINT16_MAX, UINT16_MAX,offsetof(agentstruc,beat)+offsetof(beatstruc,bsz), (uint16_t)JSON_TYPE_UINT16, JSON_STRUCT_AGENT, cinfo, JSON_UNIT_BYTES);
7385  json_addentry("agent_node", UINT16_MAX, UINT16_MAX,offsetof(agentstruc,beat)+offsetof(beatstruc,node), (uint16_t)JSON_TYPE_NAME, JSON_STRUCT_AGENT, cinfo);
7386  json_addentry("agent_ntype", UINT16_MAX, UINT16_MAX,offsetof(agentstruc,beat)+offsetof(beatstruc,ntype), (uint16_t)JSON_TYPE_UINT16, JSON_STRUCT_AGENT, cinfo);
7387  json_addentry("agent_pid", UINT16_MAX, UINT16_MAX,offsetof(agentstruc,pid), (uint16_t)JSON_TYPE_INT32, JSON_STRUCT_AGENT, cinfo);
7388  json_addentry("agent_port", UINT16_MAX, UINT16_MAX,offsetof(agentstruc,beat)+offsetof(beatstruc,port), (uint16_t)JSON_TYPE_UINT16, JSON_STRUCT_AGENT, cinfo);
7389  json_addentry("agent_proc", UINT16_MAX, UINT16_MAX,offsetof(agentstruc,beat)+offsetof(beatstruc,proc), (uint16_t)JSON_TYPE_NAME, JSON_STRUCT_AGENT, cinfo);
7390  json_addentry("agent_stateflag", UINT16_MAX, UINT16_MAX,offsetof(agentstruc,stateflag), (uint16_t)JSON_TYPE_UINT16, JSON_STRUCT_AGENT, cinfo);
7391  json_addentry("agent_user", UINT16_MAX, UINT16_MAX,offsetof(agentstruc,beat)+offsetof(beatstruc,user), (uint16_t)JSON_TYPE_NAME, JSON_STRUCT_AGENT, cinfo);
7392  json_addentry("agent_utc", UINT16_MAX, UINT16_MAX,offsetof(agentstruc,beat)+offsetof(beatstruc,utc), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_AGENT, cinfo, JSON_UNIT_DATE);
7393  json_addentry("agent_cpu", UINT16_MAX, UINT16_MAX,offsetof(agentstruc,beat)+offsetof(beatstruc,cpu), (uint16_t)JSON_TYPE_FLOAT, JSON_STRUCT_AGENT, cinfo);
7394  json_addentry("agent_memory", UINT16_MAX, UINT16_MAX,offsetof(agentstruc,beat)+offsetof(beatstruc,memory), (uint16_t)JSON_TYPE_FLOAT, JSON_STRUCT_AGENT, cinfo, JSON_UNIT_BYTES);
7395  json_addentry("agent_jitter", UINT16_MAX, UINT16_MAX,offsetof(agentstruc,beat)+offsetof(beatstruc,jitter), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_AGENT, cinfo);
7396 
7397  // Event structure
7398  json_addentry("event_cbytes", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,cbytes), (uint16_t)JSON_TYPE_FLOAT, JSON_STRUCT_EVENT, cinfo, JSON_UNIT_BYTES);
7399  json_addentry("event_cenergy", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,cenergy), (uint16_t)JSON_TYPE_FLOAT, JSON_STRUCT_EVENT, cinfo, JSON_UNIT_ENERGY);
7400  json_addentry("event_cmass", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,cmass), (uint16_t)JSON_TYPE_FLOAT, JSON_STRUCT_EVENT, cinfo, JSON_UNIT_MASS);
7401  json_addentry("event_condition", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,condition), (uint16_t)JSON_TYPE_STRING, JSON_STRUCT_EVENT, cinfo);
7402  json_addentry("event_ctime", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,ctime), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_EVENT, cinfo, JSON_UNIT_TIME);
7403  json_addentry("event_data", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,data), (uint16_t)JSON_TYPE_STRING, JSON_STRUCT_EVENT, cinfo, JSON_UNIT_BYTES);
7404  json_addentry("event_dbytes", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,dbytes), (uint16_t)JSON_TYPE_FLOAT, JSON_STRUCT_EVENT, cinfo, JSON_UNIT_BYTES);
7405  json_addentry("event_denergy", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,denergy), (uint16_t)JSON_TYPE_FLOAT, JSON_STRUCT_EVENT, cinfo, JSON_UNIT_ENERGY);
7406  json_addentry("event_dmass", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,dmass), (uint16_t)JSON_TYPE_FLOAT, JSON_STRUCT_EVENT, cinfo, JSON_UNIT_MASS);
7407  json_addentry("event_dtime", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,dtime), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_EVENT, cinfo, JSON_UNIT_TIME);
7408  json_addentry("event_flag", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,flag), (uint16_t)JSON_TYPE_UINT32, JSON_STRUCT_EVENT, cinfo);
7409  json_addentry("event_name", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,name), (uint16_t)JSON_TYPE_NAME, JSON_STRUCT_EVENT, cinfo);
7410  json_addentry("event_node", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,node), (uint16_t)JSON_TYPE_NAME, JSON_STRUCT_EVENT, cinfo);
7411  json_addentry("event_type", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,type), (uint16_t)JSON_TYPE_UINT32, JSON_STRUCT_EVENT, cinfo);
7412  json_addentry("event_user", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,user), (uint16_t)JSON_TYPE_NAME, JSON_STRUCT_EVENT, cinfo);
7413  json_addentry("event_utc", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,utc), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_EVENT, cinfo, JSON_UNIT_DATE);
7414  json_addentry("event_utcexec", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,utcexec), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_EVENT, cinfo, JSON_UNIT_DATE);
7415  json_addentry("event_value", UINT16_MAX, UINT16_MAX,offsetof(eventstruc,value), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_EVENT, cinfo);
7416 
7417  // Physics structure
7418  json_addentry("physics_dt", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,dt), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_TIME);
7419  json_addentry("physics_dtj", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,dtj), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_DATE);
7420  json_addentry("physics_mjdbase", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,utc), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_DATE);
7421  json_addentry("physics_mjdaccel", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,mjdaccel), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_DATE);
7422  json_addentry("physics_mjddiff", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,mjddiff), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_DATE);
7423  json_addentry("physics_mode", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,mode), (uint16_t)JSON_TYPE_INT32, JSON_STRUCT_PHYSICS, cinfo);
7424  json_addentry("physics_thrust", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,thrust), (uint16_t)JSON_TYPE_RVECTOR, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_FORCE);
7425  json_addentry("physics_adrag", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,adrag), (uint16_t)JSON_TYPE_RVECTOR, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_FORCE);
7426  json_addentry("physics_rdrag", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,rdrag), (uint16_t)JSON_TYPE_RVECTOR, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_FORCE);
7427  json_addentry("physics_atorque", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,atorque), (uint16_t)JSON_TYPE_RVECTOR, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_TORQUE);
7428  json_addentry("physics_rtorque", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,rtorque), (uint16_t)JSON_TYPE_RVECTOR, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_TORQUE);
7429  json_addentry("physics_gtorque", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,gtorque), (uint16_t)JSON_TYPE_RVECTOR, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_TORQUE);
7430  json_addentry("physics_htorque", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,htorque), (uint16_t)JSON_TYPE_RVECTOR, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_TORQUE);
7431  json_addentry("physics_ctorque", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,ctorque), (uint16_t)JSON_TYPE_RVECTOR, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_TORQUE);
7432  json_addentry("physics_ftorque", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,ftorque), (uint16_t)JSON_TYPE_RVECTOR, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_TORQUE);
7433  json_addentry("physics_ftorque_x", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,ftorque.x), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_TORQUE);
7434  json_addentry("physics_ftorque_y", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,ftorque.y), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_TORQUE);
7435  json_addentry("physics_ftorque_z", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,ftorque.z), (uint16_t)JSON_TYPE_DOUBLE, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_TORQUE);
7436  json_addentry("physics_hcap", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,hcap), (uint16_t)JSON_TYPE_FLOAT, JSON_STRUCT_PHYSICS, cinfo);
7437  json_addentry("physics_area", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,area), (uint16_t)JSON_TYPE_FLOAT, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_AREA);
7438  json_addentry("physics_moi", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,moi), (uint16_t)JSON_TYPE_RVECTOR, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_MOI);
7439  json_addentry("physics_com", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,com), (uint16_t)JSON_TYPE_RVECTOR, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_LENGTH);
7440  json_addentry("physics_mass", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,mass), (uint16_t)JSON_TYPE_FLOAT, JSON_STRUCT_PHYSICS, cinfo, JSON_UNIT_MASS);
7441  json_addentry("physics_heat", UINT16_MAX, UINT16_MAX,offsetof(physicsstruc,heat), (uint16_t)JSON_TYPE_FLOAT, JSON_STRUCT_PHYSICS, cinfo);
7442 
7443  // Node Structure
7444  json_addentry("node_utcoffset", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.utcoffset, (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_DATE);
7445  json_addentry("node_name", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.name, (uint16_t)JSON_TYPE_NAME, cinfo);
7446  json_addentry("node_lastevent", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.lastevent, (uint16_t)JSON_TYPE_NAME, cinfo);
7447  json_addentry("node_lasteventutc", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.lasteventutc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7448  json_addentry("node_type", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.type, (uint16_t)JSON_TYPE_UINT16, cinfo);
7449  json_addentry("node_state", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.state, (uint16_t)JSON_TYPE_UINT16, cinfo);
7450  json_addentry("node_hcap", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.phys.hcap, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7451  json_addentry("node_mass", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.phys.mass, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_MASS);
7452  json_addentry("node_area", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.phys.area, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_AREA);
7453  json_addentry("node_moi", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.phys.moi, (uint16_t)JSON_TYPE_RVECTOR, cinfo, JSON_UNIT_MOI);
7454  json_addentry("node_battcap", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.phys.battcap, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_CHARGE);
7455  json_addentry("node_flags", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.flags, (uint16_t)JSON_TYPE_UINT16, cinfo);
7456  json_addentry("node_powmode", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.powmode, (uint16_t)JSON_TYPE_INT16, cinfo);
7457  json_addentry("node_powgen", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.phys.powgen, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_POWER);
7458  json_addentry("node_powuse", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.phys.powuse, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_POWER);
7459  json_addentry("node_battlev", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.phys.battlev, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_CHARGE);
7460  json_addentry("node_downtime", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.downtime, (uint16_t)JSON_TYPE_UINT32, cinfo, JSON_UNIT_CHARGE);
7461  json_addentry("node_utc", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_DATE);
7462  json_addentry("node_utcstart", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.utcstart, (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_DATE);
7463  json_addentry("node_loc", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc, (uint16_t)JSON_TYPE_LOCSTRUC, cinfo);
7464  json_addentry("node_loc_utc", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7465  json_addentry("node_loc_pos", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos, (uint16_t)JSON_TYPE_POSSTRUC, cinfo);
7466  json_addentry("node_loc_pos_geod", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.geod, (uint16_t)JSON_TYPE_POS_GEOD, cinfo);
7467  json_addentry("node_loc_pos_geod_v_lat", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.geod.s.lat, (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_ANGULAR_RATE);
7468  json_addentry("node_loc_pos_geod_v_lon", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.geod.s.lon, (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_ANGULAR_RATE);
7469  json_addentry("node_loc_pos_geod_v_h", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.geod.s.h, (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_SPEED);
7470  json_addentry("node_loc_pos_geod_s_lat", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.geod.s.lat, (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_ANGLE);
7471  json_addentry("node_loc_pos_geod_s_lon", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.geod.s.lon, (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_ANGLE);
7472  json_addentry("node_loc_pos_geod_s_h", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.geod.s.h, (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_LENGTH);
7473  json_addentry("node_loc_pos_geoc", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.geoc, (uint16_t)JSON_TYPE_POS_GEOC, cinfo);
7474  json_addentry("node_loc_pos_geoc_v_x", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.geoc.v.col[0], (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_SPEED);
7475  json_addentry("node_loc_pos_geoc_v_y", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.geoc.v.col[1], (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_SPEED);
7476  json_addentry("node_loc_pos_geoc_v_z", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.geoc.v.col[2], (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_SPEED);
7477  json_addentry("node_loc_pos_geoc_s_x", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.geoc.s.col[0], (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_LENGTH);
7478  json_addentry("node_loc_pos_geoc_s_y", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.geoc.s.col[1], (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_LENGTH);
7479  json_addentry("node_loc_pos_geoc_s_z", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.geoc.s.col[2], (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_LENGTH);
7480  json_addentry("node_loc_pos_geos", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.geos, (uint16_t)JSON_TYPE_POS_GEOS, cinfo);
7481  json_addentry("node_loc_pos_eci", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.eci, (uint16_t)JSON_TYPE_POS_ECI, cinfo);
7482  json_addentry("node_loc_pos_eci_s", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.eci.s, (uint16_t)JSON_TYPE_RVECTOR, cinfo, JSON_UNIT_LENGTH);
7483  json_addentry("node_loc_pos_eci_v", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.eci.v, (uint16_t)JSON_TYPE_RVECTOR, cinfo, JSON_UNIT_SPEED);
7484  json_addentry("node_loc_pos_eci_a", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.eci.a, (uint16_t)JSON_TYPE_RVECTOR, cinfo, JSON_UNIT_ACCELERATION);
7485  json_addentry("node_loc_pos_sci", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.sci, (uint16_t)JSON_TYPE_POS_SCI, cinfo);
7486  json_addentry("node_loc_pos_selc", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.selc, (uint16_t)JSON_TYPE_POS_SELC, cinfo);
7487  json_addentry("node_loc_pos_selg", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.selg, (uint16_t)JSON_TYPE_POS_SELG, cinfo);
7488  json_addentry("node_loc_pos_icrf", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.icrf, (uint16_t)JSON_TYPE_POS_ICRF, cinfo);
7489  json_addentry("node_loc_pos_sunsize", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.sunsize, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_ANGLE);
7490  json_addentry("node_loc_pos_sunradiance", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.sunradiance, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_ANGLE);
7491  json_addentry("node_loc_pos_earthsep", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.earthsep, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_ANGLE);
7492  json_addentry("node_loc_pos_moonsep", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.moonsep, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7493  json_addentry("node_loc_att", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att, (uint16_t)JSON_TYPE_ATTSTRUC, cinfo);
7494  json_addentry("node_loc_att_icrf", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.icrf, (uint16_t)JSON_TYPE_QATT_ICRF, cinfo);
7495  json_addentry("node_loc_att_icrf_s", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.icrf.s, (uint16_t)JSON_TYPE_QUATERNION, cinfo);
7496  json_addentry("node_loc_att_icrf_v", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.icrf.v, (uint16_t)JSON_TYPE_RVECTOR, cinfo, JSON_UNIT_ANGULAR_RATE);
7497  json_addentry("node_loc_att_icrf_a", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.icrf.a, (uint16_t)JSON_TYPE_RVECTOR, cinfo);
7498  json_addentry("node_loc_att_topo", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.topo, (uint16_t)JSON_TYPE_QATT_TOPO, cinfo);
7499  json_addentry("node_loc_att_topo_s", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.topo.s, (uint16_t)JSON_TYPE_QUATERNION, cinfo);
7500  json_addentry("node_loc_att_topo_v", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.topo.v, (uint16_t)JSON_TYPE_RVECTOR, cinfo, JSON_UNIT_ANGULAR_RATE);
7501  json_addentry("node_loc_att_topo_a", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.topo.a, (uint16_t)JSON_TYPE_RVECTOR, cinfo);
7502  json_addentry("node_loc_att_geoc", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.geoc, (uint16_t)JSON_TYPE_QATT_GEOC, cinfo);
7503  json_addentry("node_loc_att_geoc_s", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.geoc.s, (uint16_t)JSON_TYPE_QUATERNION, cinfo);
7504  json_addentry("node_loc_att_geoc_v", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.geoc.v, (uint16_t)JSON_TYPE_RVECTOR, cinfo, JSON_UNIT_ANGULAR_RATE);
7505  json_addentry("node_loc_att_geoc_a", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.geoc.a, (uint16_t)JSON_TYPE_RVECTOR, cinfo);
7506  json_addentry("node_loc_att_lvlh", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.lvlh, (uint16_t)JSON_TYPE_QATT_LVLH, cinfo);
7507  json_addentry("node_loc_att_lvlh_s", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.lvlh.s, (uint16_t)JSON_TYPE_QUATERNION, cinfo);
7508  json_addentry("node_loc_att_lvlh_v", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.lvlh.v, (uint16_t)JSON_TYPE_RVECTOR, cinfo, JSON_UNIT_ANGULAR_RATE);
7509  json_addentry("node_loc_att_lvlh_a", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.lvlh.a, (uint16_t)JSON_TYPE_RVECTOR, cinfo);
7510  json_addentry("node_loc_att_selc", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.selc, (uint16_t)JSON_TYPE_QATT_SELC, cinfo);
7511  json_addentry("node_loc_att_selc_s", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.selc.s, (uint16_t)JSON_TYPE_QUATERNION, cinfo);
7512  json_addentry("node_loc_att_selc_v", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.selc.v, (uint16_t)JSON_TYPE_RVECTOR, cinfo, JSON_UNIT_ANGULAR_RATE);
7513  json_addentry("node_loc_att_selc_a", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.att.selc.a, (uint16_t)JSON_TYPE_RVECTOR, cinfo);
7514  json_addentry("node_loc_bearth", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.bearth, (uint16_t)JSON_TYPE_RVECTOR, cinfo);
7515  // JIMNOTE: is this how to properly add an entry?
7516  json_addentry("node_loc_orbit", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.loc.pos.orbit, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7517  json_addentry("node_azfrom", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.azfrom, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_ANGLE);
7518  json_addentry("node_azto", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.azto, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_ANGLE);
7519  json_addentry("node_elfrom", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.elfrom, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_ANGLE);
7520  json_addentry("node_elto", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.elto, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_ANGLE);
7521  json_addentry("node_range", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.range, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_LENGTH);
7522  json_addentry("node_device_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.device_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7523  json_addentry("node_vertex_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.vertex_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7524  json_addentry("node_normal_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.normal_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7525  json_addentry("node_face_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.face_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7526  json_addentry("node_piece_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.piece_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7527  json_addentry("node_port_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.port_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7528  json_addentry("node_target_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.target_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7529  json_addentry("node_agent_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.agent_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7530  json_addentry("node_event_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.event_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7531  json_addentry("node_user_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->node.user_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7532  json_addentry("device_ant_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.ant_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7533  json_addentry("device_batt_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.batt_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7534  json_addentry("device_bus_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.bus_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7535  json_addentry("device_cam_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.cam_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7536  json_addentry("device_cpu_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.cpu_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7537  json_addentry("device_disk_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.disk_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7538  json_addentry("device_gps_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.gps_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7539  json_addentry("device_htr_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.htr_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7540  json_addentry("device_imu_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.imu_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7541  json_addentry("device_mcc_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.mcc_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7542  json_addentry("device_motr_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.motr_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7543  json_addentry("device_mtr_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.mtr_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7544  json_addentry("device_pload_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.pload_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7545  json_addentry("device_prop_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.prop_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7546  json_addentry("device_psen_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.psen_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7547  json_addentry("device_bcreg_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.bcreg_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7548  json_addentry("device_rot_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.rot_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7549  json_addentry("device_rw_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.rw_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7550  json_addentry("device_rxr_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.rxr_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7551  json_addentry("device_ssen_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.ssen_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7552  json_addentry("device_pvstrg_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.pvstrg_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7553  json_addentry("device_stt_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.stt_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7554  json_addentry("device_suchi_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.suchi_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7555  json_addentry("device_swch_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.swch_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7556  json_addentry("device_tcu_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.tcu_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7557  json_addentry("device_tcv_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.tcv_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7558  json_addentry("device_telem_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.telem_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7559  json_addentry("device_thst_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.thst_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7560  json_addentry("device_tnc_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.tnc_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7561  json_addentry("device_tsen_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.tsen_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7562  json_addentry("device_txr_cnt", UINT16_MAX, UINT16_MAX, (uint8_t *)&cinfo->devspec.txr_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7563 
7564  if (iretn >= 0)
7565  {
7566  iretn = cinfo->jmapped;
7567  }
7568  return iretn;
7569 }
rvector bearth
Earth magnetic vector in ITRS for this time and location.
Definition: convertdef.h:754
JSON 16 bit integer type.
Definition: jsondef.h:194
uint16_t disk_cnt
Definition: jsondef.h:3868
static string port
Definition: add_radio.cpp:16
Vector moi
Definition: jsondef.h:3448
JSON rvector.
Definition: jsondef.h:210
float area
Definition: jsondef.h:3429
uint16_t target_cnt
Definition: jsondef.h:3575
uint16_t agent_cnt
Definition: jsondef.h:3573
uint16_t imu_cnt
Definition: jsondef.h:3871
Power.
Definition: jsondef.h:113
int16_t powmode
Definition: jsondef.h:3580
uint16_t device_cnt
Definition: jsondef.h:3571
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
qatt geoc
Definition: convertdef.h:828
Charge.
Definition: jsondef.h:115
JSON string type.
Definition: jsondef.h:204
JSON Geocentric Attitude.
Definition: jsondef.h:264
double orbit
Decimal Orbit number.
Definition: convertdef.h:756
Definition: jsondef.h:923
uint16_t mcc_cnt
Definition: jsondef.h:3872
uint16_t suchi_cnt
Definition: jsondef.h:3885
Force.
Definition: jsondef.h:105
ElapsedTime dt
Definition: agent_file3.cpp:183
spherpos geos
Definition: convertdef.h:743
rvector a
Acceleration.
Definition: convertdef.h:167
uint16_t tsen_cnt
Definition: jsondef.h:3891
userstruc
Definition: jsondef.h:162
cartpos selc
Definition: convertdef.h:740
float battcap
Definition: jsondef.h:3430
rvector a
2nd derivative: Alpha - acceleration
Definition: convertdef.h:483
uint16_t swch_cnt
Definition: jsondef.h:3886
JSON Earth Centered Inertial Position.
Definition: jsondef.h:247
uint16_t normal_cnt
Definition: jsondef.h:3568
uint16_t motr_cnt
Definition: jsondef.h:3873
uint16_t ssen_cnt
Definition: jsondef.h:3882
uint16_t event_cnt
Definition: jsondef.h:3574
float battlev
Definition: jsondef.h:3431
uint16_t bcreg_cnt
Definition: jsondef.h:3878
int iretn
Definition: rw_test.cpp:37
uint16_t piece_cnt
Definition: jsondef.h:3570
float range
Definition: jsondef.h:3588
cartpos geoc
Definition: convertdef.h:739
JSON Lunar Centered Inertial Attitude.
Definition: jsondef.h:266
char lastevent[40+1]
Last event.
Definition: jsondef.h:3558
float moonsep
Separation between sun/satellite and sun/limbofmoon vectors in radians.
Definition: convertdef.h:748
double utc
Master time for location, in Modified Julian Day.
Definition: convertdef.h:879
double utc
Overall Node time.
Definition: jsondef.h:3592
Angle.
Definition: jsondef.h:95
uint16_t tcv_cnt
Definition: jsondef.h:3888
float earthsep
Separation between sun/satellite and sun/limbofearth vectors in radians.
Definition: convertdef.h:746
Definition: jsondef.h:1199
Length.
Definition: jsondef.h:67
JSON Geocentric Spherical.
Definition: jsondef.h:257
uint16_t psen_cnt
Definition: jsondef.h:3877
Energy.
Definition: jsondef.h:111
JSON Geocentric Position.
Definition: jsondef.h:251
JSON attstruc.
Definition: jsondef.h:240
uint16_t pload_cnt
Definition: jsondef.h:3875
float sunradiance
Watts per square meter per steradian.
Definition: convertdef.h:752
qatt lvlh
Definition: convertdef.h:827
rvector v
1st derivative: Omega - angular velocity
Definition: convertdef.h:481
Physics Simulation Structure.
Definition: jsondef.h:3411
Angular rate.
Definition: jsondef.h:97
uint16_t flags
Definition: jsondef.h:3579
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
uint16_t prop_cnt
Definition: jsondef.h:3876
uint16_t telem_cnt
Definition: jsondef.h:3889
uint16_t port_cnt
Definition: jsondef.h:3572
geoidpos selg
Definition: convertdef.h:742
rvector s
Location.
Definition: convertdef.h:163
JSON Name type.
Definition: jsondef.h:206
JSON Lunar Centered Inertial Position.
Definition: jsondef.h:249
Speed.
Definition: jsondef.h:87
JSON Earth Centered Inertial Attitude.
Definition: jsondef.h:268
float hcap
Definition: jsondef.h:3424
Torque.
Definition: jsondef.h:107
uint16_t txr_cnt
Definition: jsondef.h:3893
JSON LVLH Attitude.
Definition: jsondef.h:270
eventstruc
Definition: jsondef.h:156
uint16_t tnc_cnt
Definition: jsondef.h:3892
attstruc att
attstruc for this time.
Definition: convertdef.h:883
Acceleration.
Definition: jsondef.h:89
uint16_t pvstrg_cnt
Definition: jsondef.h:3883
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
double utcoffset
MJD Offset between system UT and simulated UT.
Definition: jsondef.h:3590
uint16_t gps_cnt
Definition: jsondef.h:3869
uint32_t downtime
Seconds Node will be down.
Definition: jsondef.h:3582
uint16_t user_cnt
Definition: jsondef.h:3576
uint16_t batt_cnt
Definition: jsondef.h:3864
qatt selc
Definition: convertdef.h:829
char name[40+1]
Node Name.
Definition: jsondef.h:3556
uint16_t state
Operational state.
Definition: jsondef.h:3564
uint16_t bus_cnt
Definition: jsondef.h:3865
Date.
Definition: jsondef.h:75
int32_t json_addentry(jsonentry entry, cosmosstruc *cinfo)
Enter an entry into the JSON Namespace.
Definition: jsonlib.cpp:1118
double utcstart
Mission start time.
Definition: jsondef.h:3594
qatt icrf
Definition: convertdef.h:830
double lasteventutc
Last event UTC.
Definition: jsondef.h:3560
JSON Geodetic Position.
Definition: jsondef.h:255
string name
Definition: cubesat2obj.cpp:6
locstruc loc
Location structure.
Definition: jsondef.h:3596
Full COSMOS Event structure.
Definition: jsondef.h:1093
double h
Height in meters.
Definition: vector.h:229
JSON 32 bit integer type.
Definition: jsondef.h:196
int32_t stateflag
Definition: agent_data-2-0.cpp:78
uint16_t vertex_cnt
Definition: jsondef.h:3567
uint16_t cpu_cnt
Definition: jsondef.h:3867
JSON Topocentric Attitude.
Definition: jsondef.h:262
uint16_t rw_cnt
Definition: jsondef.h:3880
double lon
Longitude in radians.
Definition: vector.h:227
float elto
Definition: jsondef.h:3587
float powuse
Definition: jsondef.h:3433
cartpos sci
Definition: convertdef.h:738
JSON Agent Heartbeat.
Definition: jsondef.h:242
agentstruc
Definition: jsondef.h:148
JSON double precision floating vertex type.
Definition: jsondef.h:200
posstruc pos
posstruc for this time.
Definition: convertdef.h:881
gvector s
Position vector.
Definition: convertdef.h:263
Agent control structure.
Definition: jsondef.h:1006
double lat
Latitude in radians.
Definition: vector.h:225
qatt topo
Definition: convertdef.h:826
float mass
Definition: jsondef.h:3425
float sunsize
Radius of sun in radians.
Definition: convertdef.h:750
JSON 32 bit unsigned integer type.
Definition: jsondef.h:190
NetworkType ntype
Definition: agent_node.cpp:50
uint16_t ant_cnt
Definition: jsondef.h:3863
quaternion s
0th derivative: Quaternion
Definition: convertdef.h:479
DeviceCpu cpu
Definition: agent_example.cpp:58
uint16_t face_cnt
Definition: jsondef.h:3569
Time.
Definition: jsondef.h:73
uint16_t rxr_cnt
Definition: jsondef.h:3881
double col[3]
Definition: vector.h:55
JSON single precision floating vertex type.
Definition: jsondef.h:198
JSON locstruc type.
Definition: jsondef.h:276
cartpos eci
Definition: convertdef.h:737
uint16_t rot_cnt
Definition: jsondef.h:3879
uint16_t thst_cnt
Definition: jsondef.h:3890
Random Access Memory and Disk Storage.
Definition: jsondef.h:133
float azfrom
Alt/Az/Range info.
Definition: jsondef.h:3584
geoidpos geod
Definition: convertdef.h:741
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
float azto
Definition: jsondef.h:3586
uint16_t tcu_cnt
Definition: jsondef.h:3887
JSON posstruc.
Definition: jsondef.h:238
static string node
Definition: agent_monitor.cpp:126
uint16_t type
Node Type as listed in NODE_TYPE.
Definition: jsondef.h:3562
cartpos icrf
Definition: convertdef.h:736
uint16_t mtr_cnt
Definition: jsondef.h:3874
uint16_t cam_cnt
Definition: jsondef.h:3866
physicsstruc
Definition: jsondef.h:154
Area.
Definition: jsondef.h:83
JSON Selenocentric Position.
Definition: jsondef.h:253
JSON Solar Barycentric Position.
Definition: jsondef.h:244
physicsstruc phys
Definition: jsondef.h:3597
float elfrom
Definition: jsondef.h:3585
Moment of Inertia.
Definition: jsondef.h:71
JSON quaternion type.
Definition: jsondef.h:216
uint16_t htr_cnt
Definition: jsondef.h:3870
float powgen
Definition: jsondef.h:3432
rvector v
Velocity.
Definition: convertdef.h:165
uint16_t stt_cnt
Definition: jsondef.h:3884
JSON Selenographic Position.
Definition: jsondef.h:259
Mass.
Definition: jsondef.h:69
int32_t json_mapvertexentry ( uint16_t  vidx,
cosmosstruc cinfo 
)

Add vertex entry.

Add an entry for vertex number vidx to the JSON Namespace map.

Parameters
vidxPiece number.
cmetaReference to cosmosstruc to use.
Returns
The current number of entries, if successful, negative error if the entry could not be
7581 {
7582  int32_t iretn=0;
7583 
7584  iretn = json_addentry("vertex", vidx, UINT16_MAX, (uint8_t *)&cinfo->vertexs[vidx], (uint16_t)JSON_TYPE_VECTOR, cinfo);
7585  iretn = json_addentry("vertex_x", vidx, UINT16_MAX, (uint8_t *)&cinfo->vertexs[vidx].x, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7586  iretn = json_addentry("vertex_y", vidx, UINT16_MAX, (uint8_t *)&cinfo->vertexs[vidx].y, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7587  iretn = json_addentry("vertex_z", vidx, UINT16_MAX, (uint8_t *)&cinfo->vertexs[vidx].z, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7588 
7589  if (iretn >= 0)
7590  {
7591  iretn = cinfo->jmapped;
7592  }
7593  return iretn;
7594 }
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
vector< vertexstruc > vertexs
Vector of all vertexs in node.
Definition: jsondef.h:4223
int iretn
Definition: rw_test.cpp:37
int32_t json_addentry(jsonentry entry, cosmosstruc *cinfo)
Enter an entry into the JSON Namespace.
Definition: jsonlib.cpp:1118
JSON double precision floating vertex type.
Definition: jsondef.h:200
JSON ::Vector.
Definition: jsondef.h:208
int32_t json_mapfaceentry ( uint16_t  fidx,
cosmosstruc cinfo 
)

Add face entry.

Add an entry for face number fidx to the JSON Namespace map.

Parameters
fidxPiece number.
cmetaReference to cosmosstruc to use.
Returns
The current number of entries, if successful, negative error if the entry could not be
7606 {
7607  int32_t iretn=0;
7608 
7609  iretn = json_addentry("face", fidx, UINT16_MAX, (uint8_t *)&cinfo->faces[fidx], (uint16_t)JSON_TYPE_FACESTRUC, cinfo);
7610  iretn = json_addentry("face_com", fidx, UINT16_MAX, (uint8_t *)&cinfo->faces[fidx].com, (uint16_t)JSON_TYPE_VECTOR, cinfo);
7611  iretn = json_addentry("face_normal", fidx, UINT16_MAX, (uint8_t *)&cinfo->faces[fidx].normal, (uint16_t)JSON_TYPE_VECTOR, cinfo);
7612  iretn = json_addentry("face_area", fidx, UINT16_MAX, (uint8_t *)&cinfo->faces[fidx].area, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7613  iretn = json_addentry("face_vertex_cnt", fidx, UINT16_MAX, (uint8_t *)&cinfo->faces[fidx].vertex_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7614  for (uint16_t j=0; j<cinfo->faces[fidx].vertex_cnt; ++j)
7615  {
7616  iretn = json_addentry("face_vertex_idx", fidx,j,(uint8_t *)&cinfo->faces[fidx].vertex_idx[j], (uint16_t)JSON_TYPE_UINT16, cinfo);
7617  }
7618 
7619  if (iretn >= 0)
7620  {
7621  iretn = cinfo->jmapped;
7622  }
7623  return iretn;
7624 }
vector< facestruc > faces
Vector of all faces in node.
Definition: jsondef.h:4229
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
int iretn
Definition: rw_test.cpp:37
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
int32_t json_addentry(jsonentry entry, cosmosstruc *cinfo)
Enter an entry into the JSON Namespace.
Definition: jsonlib.cpp:1118
JSON double precision floating vertex type.
Definition: jsondef.h:200
JSON ::Vector.
Definition: jsondef.h:208
Definition: jsondef.h:279
int32_t json_mappieceentry ( uint16_t  pidx,
cosmosstruc cinfo 
)

Add piece entry.

Add an entry for piece number pidx to the JSON Namespace map.

Parameters
pidxPiece number.
cmetaReference to cosmosstruc to use.
Returns
The current number of entries, if successful, negative error if the entry could not be
7636 {
7637  int32_t iretn;
7638 
7639  iretn = json_addentry("piece_name", pidx, UINT16_MAX, (uint8_t *)&cinfo->pieces[pidx].name, (uint16_t)JSON_TYPE_NAME, cinfo);
7640  // json_addentry("piece_type", pidx, UINT16_MAX, (uint8_t *)&cinfo->pieces[pidx].type, (uint16_t)JSON_TYPE_UINT16, cinfo);
7641  json_addentry("piece_cidx", pidx, UINT16_MAX, (uint8_t *)&cinfo->pieces[pidx].cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7642  json_addentry("piece_mass", pidx, UINT16_MAX, (uint8_t *)&cinfo->pieces[pidx].mass, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7643  json_addentry("piece_density", pidx, UINT16_MAX, (uint8_t *)&cinfo->pieces[pidx].density, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7644  json_addentry("piece_emi", pidx, UINT16_MAX, (uint8_t *)&cinfo->pieces[pidx].emi, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7645  json_addentry("piece_abs", pidx, UINT16_MAX, (uint8_t *)&cinfo->pieces[pidx].abs, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7646  json_addentry("piece_dim", pidx, UINT16_MAX, (uint8_t *)&cinfo->pieces[pidx].dim, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7647  json_addentry("piece_hcap", pidx, UINT16_MAX, (uint8_t *)&cinfo->pieces[pidx].hcap, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7648  json_addentry("piece_hcon", pidx, UINT16_MAX, (uint8_t *)&cinfo->pieces[pidx].hcon, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7649  json_addentry("piece_area", pidx, UINT16_MAX, (uint8_t *)&cinfo->pieces[pidx].area, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7650  json_addentry("piece_volume", pidx, UINT16_MAX, (uint8_t *)&cinfo->pieces[pidx].volume, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7651  json_addentry("piece_com", pidx, UINT16_MAX, (uint8_t *)&cinfo->pieces[pidx].com, (uint16_t)JSON_TYPE_VECTOR, cinfo);
7652  json_addentry("piece_twist", pidx, UINT16_MAX, (uint8_t *)&cinfo->pieces[pidx].twist, (uint16_t)JSON_TYPE_VECTOR, cinfo);
7653  json_addentry("piece_shove", pidx, UINT16_MAX, (uint8_t *)&cinfo->pieces[pidx].shove, (uint16_t)JSON_TYPE_VECTOR, cinfo);
7654  json_addentry("piece_face_cnt", pidx, UINT16_MAX, (uint8_t *)&cinfo->pieces[pidx].face_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
7655  for (uint16_t j=0; j<cinfo->pieces[pidx].face_cnt; ++j)
7656  {
7657  json_addentry("piece_face_idx", pidx,j,(uint8_t *)&cinfo->pieces[pidx].face_idx[j], (uint16_t)JSON_TYPE_UINT16, cinfo);
7658  }
7659 
7660  if (iretn >= 0)
7661  {
7662  iretn = cinfo->jmapped;
7663  }
7664  return iretn;
7665 }
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
int iretn
Definition: rw_test.cpp:37
JSON Name type.
Definition: jsondef.h:206
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
int32_t json_addentry(jsonentry entry, cosmosstruc *cinfo)
Enter an entry into the JSON Namespace.
Definition: jsonlib.cpp:1118
JSON ::Vector.
Definition: jsondef.h:208
vector< piecestruc > pieces
Vector of all pieces in node.
Definition: jsondef.h:4232
JSON single precision floating vertex type.
Definition: jsondef.h:198
int32_t json_togglepieceentry ( uint16_t  pidx,
cosmosstruc cinfo,
bool  state 
)

Toggle piece entry.

Toggle the enable state of an entry for piece number pidx in the JSON Namespace map.

Parameters
pidxPiece number.
cmetaReference to cosmosstruc to use.
stateDesired enable state.
Returns
0 or negative error.
7675 {
7676  int32_t iretn;
7677 
7678  iretn = json_toggleentry("piece_name", pidx, UINT16_MAX, cinfo, state);
7679 // json_toggleentry("piece_type", pidx, UINT16_MAX, cinfo, state);
7680  json_toggleentry("piece_cidx", pidx, UINT16_MAX, cinfo, state);
7681  json_toggleentry("piece_mass", pidx, UINT16_MAX, cinfo, state);
7682  json_toggleentry("piece_density", pidx, UINT16_MAX, cinfo, state);
7683  json_toggleentry("piece_emi", pidx, UINT16_MAX, cinfo, state);
7684  json_toggleentry("piece_abs", pidx, UINT16_MAX, cinfo, state);
7685  json_toggleentry("piece_dim", pidx, UINT16_MAX, cinfo, state);
7686  json_toggleentry("piece_hcap", pidx, UINT16_MAX, cinfo, state);
7687  json_toggleentry("piece_hcon", pidx, UINT16_MAX, cinfo, state);
7688  json_toggleentry("piece_area", pidx, UINT16_MAX, cinfo, state);
7689  json_toggleentry("piece_com", pidx, UINT16_MAX, cinfo, state);
7690  json_toggleentry("piece_pnt_cnt", pidx, UINT16_MAX, cinfo, state);
7691  for (uint16_t j=0; j<MAXPNT; ++j)
7692  {
7693  json_toggleentry("piece_pnt", pidx,j, cinfo, state);
7694  }
7695 
7696  return iretn;
7697 }
int iretn
Definition: rw_test.cpp:37
#define MAXPNT
Maximum number of vertexs in a structure.
Definition: jsondef.h:374
int32_t json_toggleentry(string name, uint16_t d1, uint16_t d2, cosmosstruc *cinfo, bool state)
Toggle the enable state of an entry in the JSON Namespace map.
Definition: jsonlib.cpp:1224
int32_t json_mapcompentry ( uint16_t  cidx,
cosmosstruc cinfo 
)

Add component entry.

Add an entry for component number cidx to the JSON Namespace map.

Parameters
cidxComponent number.
cmetaReference to cosmosstruc to use.
Returns
The current number of entries, if successful, 0 if the entry could not be
7709 {
7710  int32_t iretn;
7711 
7712  iretn = json_addentry("device_all_type",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].type, (uint16_t)JSON_TYPE_UINT16, cinfo);
7713  json_addentry("device_all_model",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].model, (uint16_t)JSON_TYPE_UINT16, cinfo);
7714  json_addentry("device_all_flag",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].flag, (uint16_t)JSON_TYPE_UINT16, cinfo);
7715  json_addentry("device_all_addr",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].addr, (uint16_t)JSON_TYPE_UINT16, cinfo);
7716  json_addentry("device_all_cidx",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7717  json_addentry("device_all_didx",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].didx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7718  json_addentry("device_all_pidx",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].pidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7719  json_addentry("device_all_bidx",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].bidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7720  json_addentry("device_all_portidx",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].portidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7721  json_addentry("device_all_namp",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].namp, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_CURRENT);
7722  json_addentry("device_all_nvolt",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].nvolt, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_VOLTAGE);
7723  json_addentry("device_all_amp",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].amp, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_CURRENT);
7724  json_addentry("device_all_volt",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].volt, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_VOLTAGE);
7725  json_addentry("device_all_power",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].power, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_VOLTAGE);
7726  json_addentry("device_all_drate",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].drate, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_VOLTAGE);
7727  json_addentry("device_all_temp",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].temp, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_TEMPERATURE);
7728  json_addentry("device_all_utc",cidx, UINT16_MAX, (uint8_t *)&cinfo->device[cidx].utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_DATE);
7729 
7730  if (iretn >= 0)
7731  {
7732  iretn = cinfo->jmapped;
7733  }
7734  return iretn;
7735 }
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
int iretn
Definition: rw_test.cpp:37
Temperature.
Definition: jsondef.h:79
vector< devicestruc > device
Vector of all general (common) information for devices (components) in node.
Definition: jsondef.h:4238
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
Date.
Definition: jsondef.h:75
int32_t json_addentry(jsonentry entry, cosmosstruc *cinfo)
Enter an entry into the JSON Namespace.
Definition: jsonlib.cpp:1118
JSON double precision floating vertex type.
Definition: jsondef.h:200
Electric Potential.
Definition: jsondef.h:117
Current.
Definition: jsondef.h:77
JSON single precision floating vertex type.
Definition: jsondef.h:198
int32_t json_togglecompentry ( uint16_t  cidx,
cosmosstruc cinfo,
bool  state 
)

Toggle component entry.

Toggle the enable state of an entry for component number cidx in the JSON Namespace map.

Parameters
cidxComponent number.
cmetaReference to cosmosstruc to use.
stateDesired enable state.
Returns
0 or negative error.
7745 {
7746  int32_t iretn;
7747 
7748  iretn = json_toggleentry("device_all_type",cidx, UINT16_MAX, cinfo, state);
7749  json_toggleentry("device_all_model",cidx, UINT16_MAX, cinfo, state);
7750  json_toggleentry("device_all_flag",cidx, UINT16_MAX, cinfo, state);
7751  json_toggleentry("device_all_addr",cidx, UINT16_MAX, cinfo, state);
7752  json_toggleentry("device_all_cidx",cidx, UINT16_MAX, cinfo, state);
7753  json_toggleentry("device_all_didx",cidx, UINT16_MAX, cinfo, state);
7754  json_toggleentry("device_all_pidx",cidx, UINT16_MAX, cinfo, state);
7755  json_toggleentry("device_all_bidx",cidx, UINT16_MAX, cinfo, state);
7756  json_toggleentry("device_all_portidx",cidx, UINT16_MAX, cinfo, state);
7757  json_toggleentry("device_all_namp",cidx, UINT16_MAX, cinfo, state);
7758  json_toggleentry("device_all_nvolt",cidx, UINT16_MAX, cinfo, state);
7759  json_toggleentry("device_all_amp",cidx, UINT16_MAX, cinfo, state);
7760  json_toggleentry("device_all_volt",cidx, UINT16_MAX, cinfo, state);
7761  json_toggleentry("device_all_power",cidx, UINT16_MAX, cinfo, state);
7762  json_toggleentry("device_all_drate",cidx, UINT16_MAX, cinfo, state);
7763  json_toggleentry("device_all_temp",cidx, UINT16_MAX, cinfo, state);
7764  json_toggleentry("device_all_utc",cidx, UINT16_MAX, cinfo, state);
7765 
7766  return iretn;
7767 }
int iretn
Definition: rw_test.cpp:37
int32_t json_toggleentry(string name, uint16_t d1, uint16_t d2, cosmosstruc *cinfo, bool state)
Toggle the enable state of an entry in the JSON Namespace map.
Definition: jsonlib.cpp:1224
uint16_t json_mapdeviceentry ( const devicestruc device,
cosmosstruc cinfo 
)

Add device entry.

Add entries specific to device number i to the JSON Namespace map.

Parameters
cidxComponent number.
didxDevice number.
typeDevice type number taken from DeviceType.
Returns
The current number of entries, if successful, 0 if the entry could not be added.

Antenna

Battery

Camera

Processing Unit

GPS Unit

Heater

Inertial Measurement Unit

Motor

Magnetic Torque Rod

Propellant Tank

Pressure Sensor

Photo Voltaic String

Rotor

Reaction Wheel

Radio Receiver

Elevation and Azimuth Sun Sensor

Star Tracker

SUCHI

Switch

Radio Transceiver

Thruster

Temperature Sensor

Radio Transmitter

7778 {
7779  int32_t iretn;
7780  uint16_t didx = device.didx;
7781 
7782  switch (static_cast <DeviceType>(device.type))
7783  {
7785  case DeviceType::ANT:
7786  iretn = json_addentry("device_ant_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7787  json_addentry("device_ant_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7788  json_addentry("device_ant_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7789  json_addentry("device_ant_align",didx, UINT16_MAX, (uint8_t *)&device.ant.align, (uint16_t)JSON_TYPE_QUATERNION, cinfo);
7790  json_addentry("device_ant_azim",didx, UINT16_MAX, (uint8_t *)&device.ant.azim, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7791  json_addentry("device_ant_elev",didx, UINT16_MAX, (uint8_t *)&device.ant.elev, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7792  json_addentry("device_ant_minelev",didx, UINT16_MAX, (uint8_t *)&device.ant.minelev, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7793  break;
7795  case DeviceType::BATT:
7796  iretn = json_addentry("device_batt_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7797  json_addentry("device_batt_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7798  json_addentry("device_batt_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7799  json_addentry("device_batt_cap",didx, UINT16_MAX, (uint8_t *)&device.batt.capacity, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7800  json_addentry("device_batt_eff",didx, UINT16_MAX, (uint8_t *)&device.batt.efficiency, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7801  json_addentry("device_batt_charge",didx, UINT16_MAX, (uint8_t *)&device.batt.charge, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7802  json_addentry("device_batt_amp",didx, UINT16_MAX, (uint8_t *)&device.amp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7803  json_addentry("device_batt_volt",didx, UINT16_MAX, (uint8_t *)&device.volt, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7804  json_addentry("device_batt_nvolt",didx, UINT16_MAX, (uint8_t *)&device.nvolt, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7805  json_addentry("device_batt_power",didx, UINT16_MAX, (uint8_t *)&device.power, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7806  json_addentry("device_batt_r_in",didx, UINT16_MAX, (uint8_t *)&device.batt.r_in, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7807  json_addentry("device_batt_r_out",didx, UINT16_MAX, (uint8_t *)&device.batt.r_out, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7808  json_addentry("device_batt_percentage",didx, UINT16_MAX, (uint8_t *)&device.batt.percentage, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7809  json_addentry("device_batt_time_remaining",didx, UINT16_MAX, (uint8_t *)&device.batt.time_remaining, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7810  break;
7811  case DeviceType::BCREG:
7812  iretn = json_addentry("device_bcreg_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7813  json_addentry("device_bcreg_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7814  json_addentry("device_bcreg_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7815  json_addentry("device_bcreg_volt",didx, UINT16_MAX, (uint8_t *)&device.volt, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7816  json_addentry("device_bcreg_amp",didx, UINT16_MAX, (uint8_t *)&device.amp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7817  json_addentry("device_bcreg_energy",didx, UINT16_MAX, (uint8_t *)&device.energy, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7818  json_addentry("device_bcreg_power",didx, UINT16_MAX, (uint8_t *)&device.power, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7819  break;
7820  case DeviceType::BUS:
7821  iretn = json_addentry("device_bus_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7822  json_addentry("device_bus_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7823  json_addentry("device_bus_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7824  json_addentry("device_bus_amp",didx, UINT16_MAX, (uint8_t *)&device.amp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7825  json_addentry("device_bus_volt",didx, UINT16_MAX, (uint8_t *)&device.volt, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7826  json_addentry("device_bus_nvolt",didx, UINT16_MAX, (uint8_t *)&device.nvolt, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7827  json_addentry("device_bus_power",didx, UINT16_MAX, (uint8_t *)&device.power, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7828  json_addentry("device_bus_energy",didx, UINT16_MAX, (uint8_t *)&device.energy, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7829  json_addentry("device_bus_wdt",didx, UINT16_MAX, (uint8_t *)&device.bus.wdt, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7830  break;
7832  case DeviceType::CAM:
7833  iretn = json_addentry("device_cam_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7834  json_addentry("device_cam_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7835  json_addentry("device_cam_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7836  json_addentry("device_cam_power",didx, UINT16_MAX, (uint8_t *)&device.power, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7837  json_addentry("device_cam_drate",didx, UINT16_MAX, (uint8_t *)&device.drate, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7838  json_addentry("device_cam_pwidth",didx, UINT16_MAX, (uint8_t *)&device.cam.pwidth, (uint16_t)JSON_TYPE_UINT16, cinfo);
7839  json_addentry("device_cam_pheight",didx, UINT16_MAX, (uint8_t *)&device.cam.pheight, (uint16_t)JSON_TYPE_UINT16, cinfo);
7840  json_addentry("device_cam_width",didx, UINT16_MAX, (uint8_t *)&device.cam.width, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7841  json_addentry("device_cam_height",didx, UINT16_MAX, (uint8_t *)&device.cam.height, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7842  json_addentry("device_cam_flength",didx, UINT16_MAX, (uint8_t *)&device.cam.flength, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7843  break;
7845  case DeviceType::CPU:
7846  {
7847  iretn = json_addentry("device_cpu_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7848  json_addentry("device_cpu_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7849  json_addentry("device_cpu_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7850  json_addentry("device_cpu_power",didx, UINT16_MAX, (uint8_t *)&device.power, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7851  json_addentry("device_cpu_uptime",didx, UINT16_MAX, (uint8_t *)&device.cpu.uptime, (uint16_t)JSON_TYPE_UINT32, cinfo);
7852  json_addentry("device_cpu_maxgib",didx, UINT16_MAX, (uint8_t *)&device.cpu.maxgib, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7853  json_addentry("device_cpu_maxload",didx, UINT16_MAX, (uint8_t *)&device.cpu.maxload, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7854  json_addentry("device_cpu_load",didx, UINT16_MAX, (uint8_t *)&device.cpu.load, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7855  json_addentry("device_cpu_gib",didx, UINT16_MAX, (uint8_t *)&device.cpu.gib, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7856  json_addentry("device_cpu_boot_count",didx, UINT16_MAX, (uint8_t *)&device.cpu.boot_count, (uint16_t)JSON_TYPE_UINT32, cinfo);
7857  //char tempbuf1[100];
7858  //char tempbuf2[100];
7859  //sprintf(tempbuf1, "cpu_utilization_%03u", didx);
7860  //sprintf(tempbuf2, "(\"device_cpu_load_%03u\"/\"device_cpu_maxload_%03u\")", didx, didx);
7861  //json_addentry(tempbuf1, tempbuf2, cinfo);
7862  //sprintf(tempbuf1, "memory_utilization_%03u", didx);
7863  //sprintf(tempbuf2, "(\"device_cpu_gib_%03u\"/\"device_cpu_maxgib_%03u\")", didx, didx);
7864  //json_addentry(tempbuf1, tempbuf2, cinfo);
7865  }
7866  break;
7867  case DeviceType::DISK:
7868  iretn = json_addentry("device_disk_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7869  json_addentry("device_disk_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7870  json_addentry("device_disk_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7871  json_addentry("device_disk_maxgib",didx, UINT16_MAX, (uint8_t *)&device.disk.maxgib, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7872  json_addentry("device_disk_gib",didx, UINT16_MAX, (uint8_t *)&device.disk.gib, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7873  json_addentry("device_disk_path",didx, UINT16_MAX, (uint8_t *)&device.disk.path, (uint16_t)JSON_TYPE_NAME, cinfo);
7874  //char tempbuf1[100];
7875  //char tempbuf2[100];
7876  //sprintf(tempbuf1, "disk_utilization_%03u", didx);
7877  //sprintf(tempbuf2, "(\"device_disk_gib_%03u\"/\"device_disk_maxgib_%03u\")", didx, didx);
7878  //json_addentry(tempbuf1, tempbuf2, cinfo);
7879  break;
7881  case DeviceType::GPS:
7882  iretn = json_addentry("device_gps_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7883  json_addentry("device_gps_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7884  json_addentry("device_gps_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7885  json_addentry("device_gps_dutc",didx, UINT16_MAX, (uint8_t *)&device.gps.dutc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7886  json_addentry("device_gps_geocs",didx, UINT16_MAX, (uint8_t *)&device.gps.geocs, (uint16_t)JSON_TYPE_RVECTOR, cinfo);
7887  json_addentry("device_gps_geocs_x",didx, UINT16_MAX, (uint8_t *)&device.gps.geocs.col[0], (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7888  json_addentry("device_gps_geocs_y",didx, UINT16_MAX, (uint8_t *)&device.gps.geocs.col[1], (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7889  json_addentry("device_gps_geocs_z",didx, UINT16_MAX, (uint8_t *)&device.gps.geocs.col[2], (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7890  json_addentry("device_gps_geocv",didx, UINT16_MAX, (uint8_t *)&device.gps.geocv, (uint16_t)JSON_TYPE_RVECTOR, cinfo);
7891  json_addentry("device_gps_geocv_x",didx, UINT16_MAX, (uint8_t *)&device.gps.geocv.col[0], (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7892  json_addentry("device_gps_geocv_y",didx, UINT16_MAX, (uint8_t *)&device.gps.geocv.col[1], (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7893  json_addentry("device_gps_geocv_z",didx, UINT16_MAX, (uint8_t *)&device.gps.geocv.col[2], (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7894  json_addentry("device_gps_dgeocs",didx, UINT16_MAX, (uint8_t *)&device.gps.dgeocs, (uint16_t)JSON_TYPE_RVECTOR, cinfo);
7895  json_addentry("device_gps_dgeocs_x",didx, UINT16_MAX, (uint8_t *)&device.gps.dgeocs.col[0], (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7896  json_addentry("device_gps_dgeocs_y",didx, UINT16_MAX, (uint8_t *)&device.gps.dgeocs.col[1], (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7897  json_addentry("device_gps_dgeocs_z",didx, UINT16_MAX, (uint8_t *)&device.gps.dgeocs.col[2], (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7898  json_addentry("device_gps_dgeocv",didx, UINT16_MAX, (uint8_t *)&device.gps.dgeocv, (uint16_t)JSON_TYPE_RVECTOR, cinfo);
7899  json_addentry("device_gps_dgeocv_x",didx, UINT16_MAX, (uint8_t *)&device.gps.dgeocv.col[0], (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7900  json_addentry("device_gps_dgeocv_y",didx, UINT16_MAX, (uint8_t *)&device.gps.dgeocv.col[1], (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7901  json_addentry("device_gps_dgeocv_z",didx, UINT16_MAX, (uint8_t *)&device.gps.dgeocv.col[2], (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7902  json_addentry("device_gps_geods",didx, UINT16_MAX, (uint8_t *)&device.gps.geods, (uint16_t)JSON_TYPE_GVECTOR, cinfo);
7903  json_addentry("device_gps_geods_lat",didx, UINT16_MAX, (uint8_t *)&device.gps.geods.lat, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7904  json_addentry("device_gps_geods_lon",didx, UINT16_MAX, (uint8_t *)&device.gps.geods.lon, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7905  json_addentry("device_gps_geods_h",didx, UINT16_MAX, (uint8_t *)&device.gps.geods.h, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7906  json_addentry("device_gps_geodv",didx, UINT16_MAX, (uint8_t *)&device.gps.geodv, (uint16_t)JSON_TYPE_GVECTOR, cinfo);
7907  json_addentry("device_gps_geodv_lat",didx, UINT16_MAX, (uint8_t *)&device.gps.geodv.lat, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7908  json_addentry("device_gps_geodv_lon",didx, UINT16_MAX, (uint8_t *)&device.gps.geodv.lon, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7909  json_addentry("device_gps_geodv_h",didx, UINT16_MAX, (uint8_t *)&device.gps.geodv.h, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7910  json_addentry("device_gps_dgeods",didx, UINT16_MAX, (uint8_t *)&device.gps.dgeods, (uint16_t)JSON_TYPE_GVECTOR, cinfo);
7911  json_addentry("device_gps_dgeods_lat",didx, UINT16_MAX, (uint8_t *)&device.gps.dgeods.lat, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7912  json_addentry("device_gps_dgeods_lon",didx, UINT16_MAX, (uint8_t *)&device.gps.dgeods.lon, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7913  json_addentry("device_gps_dgeods_h",didx, UINT16_MAX, (uint8_t *)&device.gps.dgeods.h, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7914  json_addentry("device_gps_dgeodv",didx, UINT16_MAX, (uint8_t *)&device.gps.dgeodv, (uint16_t)JSON_TYPE_GVECTOR, cinfo);
7915  json_addentry("device_gps_dgeodv_lat",didx, UINT16_MAX, (uint8_t *)&device.gps.dgeodv.lat, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7916  json_addentry("device_gps_dgeodv_lon",didx, UINT16_MAX, (uint8_t *)&device.gps.dgeodv.lon, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7917  json_addentry("device_gps_dgeodv_h",didx, UINT16_MAX, (uint8_t *)&device.gps.dgeodv.h, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7918  json_addentry("device_gps_heading",didx, UINT16_MAX, (uint8_t *)&device.gps.heading, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7919  json_addentry("device_gps_sats_used",didx, UINT16_MAX, (uint8_t *)&device.gps.sats_used, (uint16_t)JSON_TYPE_UINT16, cinfo);
7920  json_addentry("device_gps_sats_visible",didx, UINT16_MAX, (uint8_t *)&device.gps.sats_visible, (uint16_t)JSON_TYPE_UINT16, cinfo);
7921  json_addentry("device_gps_time_status",didx, UINT16_MAX, (uint8_t *)&device.gps.time_status, (uint16_t)JSON_TYPE_UINT16, cinfo);
7922  json_addentry("device_gps_position_type",didx, UINT16_MAX, (uint8_t *)&device.gps.position_type, (uint16_t)JSON_TYPE_UINT16, cinfo);
7923  json_addentry("device_gps_solution_status",didx, UINT16_MAX, (uint8_t *)&device.gps.solution_status, (uint16_t)JSON_TYPE_UINT16, cinfo);
7924  break;
7926  case DeviceType::HTR:
7927  iretn = json_addentry("device_htr_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7928  json_addentry("device_htr_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7929  json_addentry("device_htr_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7930  json_addentry("device_htr_state",didx, UINT16_MAX, (uint8_t *)&device.htr.state, (uint16_t)JSON_TYPE_BOOL, cinfo);
7931  break;
7933  case DeviceType::IMU:
7934  iretn = json_addentry("device_imu_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7935  json_addentry("device_imu_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7936  json_addentry("device_imu_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_TEMPERATURE);
7937  json_addentry("device_imu_amp",didx, UINT16_MAX, (uint8_t *)&device.amp, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_CURRENT);
7938  json_addentry("device_imu_volt",didx, UINT16_MAX, (uint8_t *)&device.volt, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_VOLTAGE);
7939  json_addentry("device_imu_power",didx, UINT16_MAX, (uint8_t *)&device.power, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_POWER);
7940  json_addentry("device_imu_align",didx, UINT16_MAX, (uint8_t *)&device.imu.align, (uint16_t)JSON_TYPE_QUATERNION, cinfo);
7941  json_addentry("device_imu_accel",didx, UINT16_MAX, (uint8_t *)&device.imu.accel, (uint16_t)JSON_TYPE_RVECTOR, cinfo, JSON_UNIT_ACCELERATION);
7942  json_addentry("device_imu_accel_x",didx, UINT16_MAX, (uint8_t *)&device.imu.accel.col[0], (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_ACCELERATION);
7943  json_addentry("device_imu_accel_y",didx, UINT16_MAX, (uint8_t *)&device.imu.accel.col[1], (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_ACCELERATION);
7944  json_addentry("device_imu_accel_z",didx, UINT16_MAX, (uint8_t *)&device.imu.accel.col[2], (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_ACCELERATION);
7945  json_addentry("device_imu_theta",didx, UINT16_MAX, (uint8_t *)&device.imu.theta, (uint16_t)JSON_TYPE_QUATERNION, cinfo, JSON_UNIT_NONE);
7946  json_addentry("device_imu_euler",didx, UINT16_MAX, (uint8_t *)&device.imu.euler, (uint16_t)JSON_TYPE_AVECTOR, cinfo, JSON_UNIT_ANGLE);
7947  json_addentry("device_imu_euler_h",didx, UINT16_MAX, (uint8_t *)&device.imu.euler.h, (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_ANGLE);
7948  json_addentry("device_imu_euler_e",didx, UINT16_MAX, (uint8_t *)&device.imu.euler.e, (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_ANGLE);
7949  json_addentry("device_imu_euler_b",didx, UINT16_MAX, (uint8_t *)&device.imu.euler.b, (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_ANGLE);
7950  json_addentry("device_imu_omega",didx, UINT16_MAX, (uint8_t *)&device.imu.omega, (uint16_t)JSON_TYPE_RVECTOR, cinfo, JSON_UNIT_ANGULAR_RATE);
7951  json_addentry("device_imu_alpha",didx, UINT16_MAX, (uint8_t *)&device.imu.alpha, (uint16_t)JSON_TYPE_RVECTOR, cinfo);
7952  json_addentry("device_imu_mag",didx, UINT16_MAX, (uint8_t *)&device.imu.mag, (uint16_t)JSON_TYPE_RVECTOR, cinfo, JSON_UNIT_MAGFIELD);
7953  json_addentry("device_imu_mag_x",didx, UINT16_MAX, (uint8_t *)&device.imu.mag.col[0], (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_MAGFIELD);
7954  json_addentry("device_imu_mag_y",didx, UINT16_MAX, (uint8_t *)&device.imu.mag.col[1], (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_MAGFIELD);
7955  json_addentry("device_imu_mag_z",didx, UINT16_MAX, (uint8_t *)&device.imu.mag.col[2], (uint16_t)JSON_TYPE_DOUBLE, cinfo, JSON_UNIT_MAGFIELD);
7956  json_addentry("device_imu_bdot",didx, UINT16_MAX, (uint8_t *)&device.imu.bdot, (uint16_t)JSON_TYPE_RVECTOR, cinfo);
7957  break;
7959  case DeviceType::MCC:
7960  iretn = json_addentry("device_mcc_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7961  json_addentry("device_mcc_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7962  json_addentry("device_mcc_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7963  json_addentry("device_mcc_q",didx, UINT16_MAX, (uint8_t *)&device.mcc.q, (uint16_t)JSON_TYPE_QUATERNION, cinfo);
7964  json_addentry("device_mcc_o",didx, UINT16_MAX, (uint8_t *)&device.mcc.o, (uint16_t)JSON_TYPE_RVECTOR, cinfo);
7965  json_addentry("device_mcc_a",didx, UINT16_MAX, (uint8_t *)&device.mcc.a, (uint16_t)JSON_TYPE_RVECTOR, cinfo);
7966  json_addentry("device_mcc_align",didx, UINT16_MAX, (uint8_t *)&device.mcc.align, (uint16_t)JSON_TYPE_QUATERNION, cinfo);
7967  break;
7968  case DeviceType::MOTR:
7969  iretn = json_addentry("device_motr_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7970  json_addentry("device_motr_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7971  json_addentry("device_motr_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7972  json_addentry("device_motr_rat",didx, UINT16_MAX, (uint8_t *)&device.motr.rat, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7973  json_addentry("device_motr_max",didx, UINT16_MAX, (uint8_t *)&device.motr.max, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7974  json_addentry("device_motr_spd",didx, UINT16_MAX, (uint8_t *)&device.motr.spd, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7975  break;
7977  case DeviceType::MTR:
7978  iretn = json_addentry("device_mtr_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7979  json_addentry("device_mtr_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7980  json_addentry("device_mtr_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7981  json_addentry("device_mtr_amp",didx, UINT16_MAX, (uint8_t *)&device.amp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7982  json_addentry("device_mtr_volt",didx, UINT16_MAX, (uint8_t *)&device.volt, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7983  json_addentry("device_mtr_power",didx, UINT16_MAX, (uint8_t *)&device.power, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7984  json_addentry("device_mtr_mxmom",didx, UINT16_MAX, (uint8_t *)&device.mtr.mxmom, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7985  json_addentry("device_mtr_tc",didx, UINT16_MAX, (uint8_t *)&device.mtr.tc, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7986  json_addentry("device_mtr_align",didx, UINT16_MAX, (uint8_t *)&device.mtr.align, (uint16_t)JSON_TYPE_QUATERNION, cinfo);
7987  for (uint16_t j=0; j<7; j++)
7988  {
7989  json_addentry("device_mtr_npoly",didx,j,(uint8_t *)&device.mtr.npoly+j*sizeof(float), (uint16_t)JSON_TYPE_FLOAT, cinfo);
7990  json_addentry("device_mtr_ppoly",didx,j,(uint8_t *)&device.mtr.ppoly+j*sizeof(float), (uint16_t)JSON_TYPE_FLOAT, cinfo);
7991  }
7992  json_addentry("device_mtr_mom",didx, UINT16_MAX, (uint8_t *)&device.mtr.mom, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_MAGMOMENT);
7993  json_addentry("device_mtr_rmom",didx, UINT16_MAX, (uint8_t *)&device.mtr.rmom, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7994  break;
7995  case DeviceType::PLOAD:
7996  iretn = json_addentry("device_pload_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
7997  json_addentry("device_pload_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
7998  json_addentry("device_pload_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
7999  json_addentry("device_pload_amp",didx, UINT16_MAX, (uint8_t *)&device.amp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8000  json_addentry("device_pload_volt",didx, UINT16_MAX, (uint8_t *)&device.volt, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8001  json_addentry("device_pload_power",didx, UINT16_MAX, (uint8_t *)&device.power, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8002  json_addentry("device_pload_drate",didx, UINT16_MAX, (uint8_t *)&device.drate, (uint16_t)JSON_TYPE_UINT32, cinfo);
8003  json_addentry("device_pload_key_cnt",didx, UINT16_MAX, (uint8_t *)&device.pload.key_cnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
8004  for (uint16_t j=0; j<MAXPLOADKEYCNT; j++)
8005  {
8006  json_addentry("device_pload_keyidx",didx,j,(uint8_t *)&device.pload.keyidx[j], (uint16_t)JSON_TYPE_UINT16, cinfo);
8007  json_addentry("device_pload_keyval",didx,j,(uint8_t *)&device.pload.keyval[j], (uint16_t)JSON_TYPE_FLOAT, cinfo);
8008  }
8009  break;
8011  case DeviceType::PROP:
8012  iretn = json_addentry("device_prop_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8013  json_addentry("device_prop_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8014  json_addentry("device_prop_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8015  json_addentry("device_prop_cap",didx, UINT16_MAX, (uint8_t *)&device.prop.cap, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8016  json_addentry("device_prop_lev",didx, UINT16_MAX, (uint8_t *)&device.prop.lev, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8017  break;
8019  case DeviceType::PSEN:
8020  iretn = json_addentry("device_psen_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8021  json_addentry("device_psen_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8022  json_addentry("device_psen_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8023  json_addentry("device_psen_press",didx, UINT16_MAX, (uint8_t *)&device.psen.press, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8024  break;
8026  case DeviceType::PVSTRG:
8027  iretn = json_addentry("device_pvstrg_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8028  json_addentry("device_pvstrg_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8029  json_addentry("device_pvstrg_bcidx",didx, UINT16_MAX, (uint8_t *)&device.pvstrg.bcidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8030  json_addentry("device_pvstrg_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8031  json_addentry("device_pvstrg_power",didx, UINT16_MAX, (uint8_t *)&device.power, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8032  json_addentry("device_pvstrg_efi",didx, UINT16_MAX, (uint8_t *)&device.pvstrg.effbase, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8033  json_addentry("device_pvstrg_efs",didx, UINT16_MAX, (uint8_t *)&device.pvstrg.effslope, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8034  json_addentry("device_pvstrg_max",didx, UINT16_MAX, (uint8_t *)&device.pvstrg.maxpower, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8035  break;
8037  case DeviceType::ROT:
8038  iretn = json_addentry("device_rot_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8039  json_addentry("device_rot_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8040  json_addentry("device_rot_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8041  break;
8043  case DeviceType::RW:
8044  iretn = json_addentry("device_rw_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8045  json_addentry("device_rw_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8046  json_addentry("device_rw_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_TEMPERATURE);
8047  json_addentry("device_rw_amp",didx, UINT16_MAX, (uint8_t *)&device.amp, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_CURRENT);
8048  json_addentry("device_rw_volt",didx, UINT16_MAX, (uint8_t *)&device.volt, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_VOLTAGE);
8049  json_addentry("device_rw_power",didx, UINT16_MAX, (uint8_t *)&device.power, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_POWER);
8050  json_addentry("device_rw_align",didx, UINT16_MAX, (uint8_t *)&device.rw.align, (uint16_t)JSON_TYPE_QUATERNION, cinfo);
8051  json_addentry("device_rw_mom",didx, UINT16_MAX, (uint8_t *)&device.rw.mom, (uint16_t)JSON_TYPE_RVECTOR, cinfo);
8052  json_addentry("device_rw_mxomg",didx, UINT16_MAX, (uint8_t *)&device.rw.mxomg, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8053  json_addentry("device_rw_mxalp",didx, UINT16_MAX, (uint8_t *)&device.rw.mxalp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8054  json_addentry("device_rw_tc",didx, UINT16_MAX, (uint8_t *)&device.rw.tc, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8055  json_addentry("device_rw_omg",didx, UINT16_MAX, (uint8_t *)&device.rw.omg, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_ANGULAR_RATE);
8056  json_addentry("device_rw_alp",didx, UINT16_MAX, (uint8_t *)&device.rw.alp, (uint16_t)JSON_TYPE_FLOAT, cinfo, JSON_UNIT_ANGULAR_RATE);
8057  json_addentry("device_rw_romg",didx, UINT16_MAX, (uint8_t *)&device.rw.romg, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8058  json_addentry("device_rw_ralp",didx, UINT16_MAX, (uint8_t *)&device.rw.ralp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8059  break;
8061  case DeviceType::RXR:
8062  json_addentry("device_rxr_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8063  json_addentry("device_rxr_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8064  json_addentry("device_rxr_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8065  json_addentry("device_rxr_opmode",didx, UINT16_MAX, (uint8_t *)&device.rxr.opmode, (uint16_t)JSON_TYPE_UINT16, cinfo);
8066  json_addentry("device_rxr_modulation",didx, UINT16_MAX, (uint8_t *)&device.rxr.modulation, (uint16_t)JSON_TYPE_UINT16, cinfo);
8067  json_addentry("device_rxr_flag",didx, UINT16_MAX, (uint8_t *)&device.flag, (uint16_t)JSON_TYPE_UINT32, cinfo);
8068  json_addentry("device_rxr_rssi",didx, UINT16_MAX, (uint8_t *)&device.rxr.rssi, (uint16_t)JSON_TYPE_UINT16, cinfo);
8069  json_addentry("device_rxr_pktsize",didx, UINT16_MAX, (uint8_t *)&device.rxr.pktsize, (uint16_t)JSON_TYPE_UINT16, cinfo);
8070  json_addentry("device_rxr_freq",didx, UINT16_MAX, (uint8_t *)&device.rxr.freq, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8071  json_addentry("device_rxr_maxfreq",didx, UINT16_MAX, (uint8_t *)&device.rxr.maxfreq, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8072  json_addentry("device_rxr_minfreq",didx, UINT16_MAX, (uint8_t *)&device.rxr.minfreq, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8073  json_addentry("device_rxr_powerin",didx, UINT16_MAX, (uint8_t *)&device.rxr.powerin, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8074  json_addentry("device_rxr_powerout",didx, UINT16_MAX, (uint8_t *)&device.rxr.powerout, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8075  json_addentry("device_rxr_band",didx, UINT16_MAX, (uint8_t *)&device.rxr.band, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8076  json_addentry("device_rxr_goodratio",didx, UINT16_MAX, (uint8_t *)&device.rxr.goodratio, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8077  json_addentry("device_rxr_rxutc",didx, UINT16_MAX, (uint8_t *)&device.rxr.rxutc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8078  json_addentry("device_rxr_uptime",didx, UINT16_MAX, (uint8_t *)&device.rxr.uptime, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8079  break;
8081  case DeviceType::SSEN:
8082  iretn = json_addentry("device_ssen_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8083  json_addentry("device_ssen_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8084  json_addentry("device_ssen_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8085  json_addentry("device_ssen_align",didx, UINT16_MAX, (uint8_t *)&device.ssen.align, (uint16_t)JSON_TYPE_QUATERNION, cinfo);
8086  json_addentry("device_ssen_qva",didx, UINT16_MAX, (uint8_t *)&device.ssen.qva, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8087  json_addentry("device_ssen_qvb",didx, UINT16_MAX, (uint8_t *)&device.ssen.qvb, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8088  json_addentry("device_ssen_qvc",didx, UINT16_MAX, (uint8_t *)&device.ssen.qvc, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8089  json_addentry("device_ssen_qvd",didx, UINT16_MAX, (uint8_t *)&device.ssen.qvd, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8090  json_addentry("device_ssen_azimuth",didx, UINT16_MAX, (uint8_t *)&device.ssen.azimuth, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8091  json_addentry("device_ssen_elevation",didx, UINT16_MAX, (uint8_t *)&device.ssen.elevation, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8092  break;
8094  case DeviceType::STT:
8095  iretn = json_addentry("device_stt_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8096  json_addentry("device_stt_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8097  json_addentry("device_stt_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8098  json_addentry("device_stt_align",didx, UINT16_MAX, (uint8_t *)&device.stt.align, (uint16_t)JSON_TYPE_QUATERNION, cinfo);
8099  json_addentry("device_stt_att",didx, UINT16_MAX, (uint8_t *)&device.stt.att, (uint16_t)JSON_TYPE_QUATERNION, cinfo);
8100  json_addentry("device_stt_omega",didx, UINT16_MAX, (uint8_t *)&device.stt.omega, (uint16_t)JSON_TYPE_RVECTOR, cinfo);
8101  json_addentry("device_stt_retcode",didx, UINT16_MAX, (uint8_t *)&device.stt.retcode, (uint16_t)JSON_TYPE_UINT16, cinfo);
8102  json_addentry("device_stt_status",didx, UINT16_MAX, (uint8_t *)&device.stt.status, (uint16_t)JSON_TYPE_UINT32, cinfo);
8103  break;
8105  case DeviceType::SUCHI:
8106  {
8107  iretn = json_addentry("device_suchi_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8108  json_addentry("device_suchi_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8109  json_addentry("device_suchi_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8110  json_addentry("device_suchi_align",didx, UINT16_MAX, (uint8_t *)&device.suchi.align, (uint16_t)JSON_TYPE_QUATERNION, cinfo);
8111  json_addentry("device_suchi_press",didx, UINT16_MAX, (uint8_t *)&device.suchi.press, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8112  for (uint16_t j=0; j<8; j++)
8113  {
8114  json_addentry("device_suchi_temps",didx,j,(uint8_t *)&device.suchi.temps+j*sizeof(float), (uint16_t)JSON_TYPE_FLOAT, cinfo);
8115  }
8116  }
8117  break;
8119  case DeviceType::SWCH:
8120  iretn = json_addentry("device_swch_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8121  json_addentry("device_swch_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8122  json_addentry("device_swch_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8123  json_addentry("device_swch_volt",didx, UINT16_MAX, (uint8_t *)&device.volt, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8124  json_addentry("device_swch_amp",didx, UINT16_MAX, (uint8_t *)&device.amp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8125  json_addentry("device_swch_power",didx, UINT16_MAX, (uint8_t *)&device.power, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8126  json_addentry("device_swch_energy",didx, UINT16_MAX, (uint8_t *)&device.energy, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8127  break;
8128  case DeviceType::TCU:
8129  iretn = json_addentry("device_tcu_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8130  json_addentry("device_tcu_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8131  json_addentry("device_tcu_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8132  json_addentry("device_tcu_mcnt",didx, UINT16_MAX, (uint8_t *)&device.tcu.mcnt, (uint16_t)JSON_TYPE_UINT16, cinfo);
8133  for (uint16_t j=0; j<3; j++)
8134  {
8135  json_addentry("device_tcu_mcidx",didx,j,(uint8_t *)&device.tcu.mcidx+j*sizeof(int16_t), (uint16_t)JSON_TYPE_UINT16, cinfo);
8136  }
8137  break;
8139  case DeviceType::TCV:
8140  iretn = json_addentry("device_tcv_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8141  json_addentry("device_tcv_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8142  json_addentry("device_tcv_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8143  json_addentry("device_tcv_opmode",didx, UINT16_MAX, (uint8_t *)&device.tcv.opmode, (uint16_t)JSON_TYPE_UINT16, cinfo);
8144  json_addentry("device_tcv_modulation",didx, UINT16_MAX, (uint8_t *)&device.tcv.modulation, (uint16_t)JSON_TYPE_UINT16, cinfo);
8145  json_addentry("device_tcv_flag",didx, UINT16_MAX, (uint8_t *)&device.flag, (uint16_t)JSON_TYPE_UINT16, cinfo);
8146  json_addentry("device_tcv_rssi",didx, UINT16_MAX, (uint8_t *)&device.tcv.rssi, (uint16_t)JSON_TYPE_UINT16, cinfo);
8147  json_addentry("device_tcv_pktsize",didx, UINT16_MAX, (uint8_t *)&device.tcv.pktsize, (uint16_t)JSON_TYPE_UINT16, cinfo);
8148  json_addentry("device_tcv_freq",didx, UINT16_MAX, (uint8_t *)&device.tcv.freq, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8149  json_addentry("device_tcv_maxfreq",didx, UINT16_MAX, (uint8_t *)&device.tcv.maxfreq, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8150  json_addentry("device_tcv_minfreq",didx, UINT16_MAX, (uint8_t *)&device.tcv.minfreq, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8151  json_addentry("device_tcv_powerin",didx, UINT16_MAX, (uint8_t *)&device.tcv.powerin, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8152  json_addentry("device_tcv_powerout",didx, UINT16_MAX, (uint8_t *)&device.tcv.powerout, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8153  json_addentry("device_tcv_maxpower",didx, UINT16_MAX, (uint8_t *)&device.tcv.maxpower, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8154  json_addentry("device_tcv_band",didx, UINT16_MAX, (uint8_t *)&device.tcv.band, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8155  json_addentry("device_tcv_goodratio",didx, UINT16_MAX, (uint8_t *)&device.tcv.goodratio, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8156  json_addentry("device_tcv_txutc",didx, UINT16_MAX, (uint8_t *)&device.tcv.txutc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8157  json_addentry("device_tcv_rxutc",didx, UINT16_MAX, (uint8_t *)&device.tcv.rxutc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8158  json_addentry("device_tcv_uptime",didx, UINT16_MAX, (uint8_t *)&device.tcv.uptime, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8159  break;
8160  case DeviceType::TELEM:
8161  iretn = json_addentry("device_telem_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8162  json_addentry("device_telem_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8163  json_addentry("device_telem_type",didx, UINT16_MAX, (uint8_t *)&device.type, (uint16_t)JSON_TYPE_UINT32, cinfo);
8164  json_addentry("device_telem_vuint8",didx, UINT16_MAX, (uint8_t *)&device.telem.vuint8, (uint16_t)JSON_TYPE_UINT8, cinfo);
8165  json_addentry("device_telem_vint8",didx, UINT16_MAX, (uint8_t *)&device.telem.vint8, (uint16_t)JSON_TYPE_INT8, cinfo);
8166  json_addentry("device_telem_vuint16",didx, UINT16_MAX, (uint8_t *)&device.telem.vuint16, (uint16_t)JSON_TYPE_UINT16, cinfo);
8167  json_addentry("device_telem_vint16",didx, UINT16_MAX, (uint8_t *)&device.telem.vint16, (uint16_t)JSON_TYPE_INT16, cinfo);
8168  json_addentry("device_telem_vuint32",didx, UINT16_MAX, (uint8_t *)&device.telem.vuint32, (uint16_t)JSON_TYPE_UINT32, cinfo);
8169  json_addentry("device_telem_vint32",didx, UINT16_MAX, (uint8_t *)&device.telem.vint32, (uint16_t)JSON_TYPE_INT32, cinfo);
8170  json_addentry("device_telem_vfloat",didx, UINT16_MAX, (uint8_t *)&device.telem.vfloat, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8171  json_addentry("device_telem_vdouble",didx, UINT16_MAX, (uint8_t *)&device.telem.vdouble, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8172  json_addentry("device_telem_vstring",didx, UINT16_MAX, (uint8_t *)&device.telem.vstring, (uint16_t)JSON_TYPE_STRING, cinfo);
8173  break;
8175  case DeviceType::THST:
8176  iretn = json_addentry("device_thst_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8177  json_addentry("device_thst_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8178  json_addentry("device_thst_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8179  json_addentry("device_thst_isp",didx, UINT16_MAX, (uint8_t *)&device.thst.isp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8180  json_addentry("device_thst_align",didx, UINT16_MAX, (uint8_t *)&device.thst.align, (uint16_t)JSON_TYPE_QUATERNION, cinfo);
8181  json_addentry("device_thst_flw",didx, UINT16_MAX, (uint8_t *)&device.thst.flw, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8182  break;
8183  case DeviceType::TNC:
8184  iretn = json_addentry("device_tnc_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8185  json_addentry("device_tnc_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8186  json_addentry("device_tnc_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8187  break;
8189  case DeviceType::TSEN:
8190  iretn = json_addentry("device_tsen_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8191  json_addentry("device_tsen_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8192  json_addentry("device_tsen_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8193  break;
8195  case DeviceType::TXR:
8196  iretn = json_addentry("device_txr_utc",didx, UINT16_MAX, (uint8_t *)&device.utc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8197  json_addentry("device_txr_cidx",didx, UINT16_MAX, (uint8_t *)&device.cidx, (uint16_t)JSON_TYPE_UINT16, cinfo);
8198  json_addentry("device_txr_temp",didx, UINT16_MAX, (uint8_t *)&device.temp, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8199  json_addentry("device_txr_opmode",didx, UINT16_MAX, (uint8_t *)&device.txr.opmode, (uint16_t)JSON_TYPE_UINT16, cinfo);
8200  json_addentry("device_txr_modulation",didx, UINT16_MAX, (uint8_t *)&device.txr.modulation, (uint16_t)JSON_TYPE_UINT16, cinfo);
8201  json_addentry("device_txr_flag",didx, UINT16_MAX, (uint8_t *)&device.flag, (uint16_t)JSON_TYPE_UINT32, cinfo);
8202  json_addentry("device_txr_rssi",didx, UINT16_MAX, (uint8_t *)&device.txr.rssi, (uint16_t)JSON_TYPE_UINT16, cinfo);
8203  json_addentry("device_txr_pktsize",didx, UINT16_MAX, (uint8_t *)&device.txr.pktsize, (uint16_t)JSON_TYPE_UINT16, cinfo);
8204  json_addentry("device_txr_freq",didx, UINT16_MAX, (uint8_t *)&device.txr.freq, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8205  json_addentry("device_txr_maxfreq",didx, UINT16_MAX, (uint8_t *)&device.txr.maxfreq, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8206  json_addentry("device_txr_minfreq",didx, UINT16_MAX, (uint8_t *)&device.txr.minfreq, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8207  json_addentry("device_txr_powerin",didx, UINT16_MAX, (uint8_t *)&device.txr.powerin, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8208  json_addentry("device_txr_powerout",didx, UINT16_MAX, (uint8_t *)&device.txr.powerout, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8209  json_addentry("device_txr_maxpower",didx, UINT16_MAX, (uint8_t *)&device.txr.maxpower, (uint16_t)JSON_TYPE_FLOAT, cinfo);
8210  json_addentry("device_txr_goodratio",didx, UINT16_MAX, (uint8_t *)&device.txr.goodratio, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8211  json_addentry("device_txr_txutc",didx, UINT16_MAX, (uint8_t *)&device.txr.txutc, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8212  json_addentry("device_txr_uptime",didx, UINT16_MAX, (uint8_t *)&device.txr.uptime, (uint16_t)JSON_TYPE_DOUBLE, cinfo);
8213  break;
8214  default:
8215  iretn = JSON_ERROR_NOENTRY;
8216  break;
8217  }
8218 
8219  if (iretn >= 0)
8220  {
8221  iretn = cinfo->jmapped;
8222  }
8223  return iretn;
8224 }
Radio Receiver.
Definition: jsondef.h:508
float temps[8]
Internal temperatures.
Definition: jsondef.h:3146
float powerin
Current RX Power.
Definition: jsondef.h:2424
double goodratio
Good Packet Percentage.
Definition: jsondef.h:2342
JSON 16 bit integer type.
Definition: jsondef.h:194
Magnetic Torque Rod.
Definition: jsondef.h:500
rwstruc rw
Definition: jsondef.h:3713
double goodratio
Good Packet Percentage.
Definition: jsondef.h:2526
Photo Voltaic String.
Definition: jsondef.h:514
float qva
Definition: jsondef.h:1810
quaternion align
Rotates vectors from RW frame (axis of rotation = z) to body frame.
Definition: jsondef.h:1923
JSON rvector.
Definition: jsondef.h:210
uint16_t time_status
Time Status.
Definition: jsondef.h:2186
Power.
Definition: jsondef.h:113
float tc
Field Change Time Constant.
Definition: jsondef.h:1997
Magnetic Field Strengh.
Definition: jsondef.h:123
uint16_t pktsize
Packet Size.
Definition: jsondef.h:2508
double minfreq
Minimum frequency allowed.
Definition: jsondef.h:2422
uint16_t opmode
Operating mode.
Definition: jsondef.h:2502
float charge
Charge in amp hours.
Definition: jsondef.h:2652
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
rvector a
Definition: jsondef.h:2992
double vdouble
Definition: jsondef.h:1713
double txutc
Last TX time.
Definition: jsondef.h:2528
JSON string type.
Definition: jsondef.h:204
int16_t vint16
Definition: jsondef.h:1709
uint16_t retcode
return code for
Definition: jsondef.h:2943
float max
Maximum speed in revolutions per second.
Definition: jsondef.h:2744
float power
Current Power.
Definition: jsondef.h:1613
quaternion q
attitude
Definition: jsondef.h:2990
double goodratio
Good Packet Percentage.
Definition: jsondef.h:2434
uint16_t pwidth
Definition: jsondef.h:3189
float effbase
Efficiency 0th order term.
Definition: jsondef.h:2600
uint16_t vuint16
Definition: jsondef.h:1708
rvector mag
Magnetic field in sensor frame.
Definition: jsondef.h:1873
JSON 8 bit unsigned integer type.
Definition: jsondef.h:182
Reaction Wheel.
Definition: jsondef.h:498
uint16_t modulation
Data modulation.
Definition: jsondef.h:2504
uint32_t vuint32
Definition: jsondef.h:1710
Heater.
Definition: jsondef.h:518
float height
Definition: jsondef.h:3192
float band
Input Filter bandpass.
Definition: jsondef.h:2338
Motor.
Definition: jsondef.h:520
float volt
Current Voltage.
Definition: jsondef.h:1611
float omg
Current angular velocity.
Definition: jsondef.h:1933
rvector dgeocs
Geocentric position error: x, y, z.
Definition: jsondef.h:2168
Telemetry.
Definition: jsondef.h:546
float mxalp
Maximum alpha in radians/second/second.
Definition: jsondef.h:1929
float press
Internal pressure.
Definition: jsondef.h:3144
Elevation and Azimuth Sun Sensor.
Definition: jsondef.h:494
float maxpower
Maximum power generation in Watts.
Definition: jsondef.h:2604
tcustruc tcu
Definition: jsondef.h:3719
float energy
Total energy usage.
Definition: jsondef.h:1615
float mxomg
Maximum omega in radians/second.
Definition: jsondef.h:1927
double freq
Input Frequency.
Definition: jsondef.h:2418
quaternion align
alignment quaternion
Definition: jsondef.h:2937
uint16_t key_cnt
Number of keys being used.
Definition: jsondef.h:1755
uint16_t rssi
RSSI.
Definition: jsondef.h:2322
uint16_t pktsize
Packet Size.
Definition: jsondef.h:2416
diskstruc disk
Definition: jsondef.h:3701
double rxutc
Last RX time.
Definition: jsondef.h:2530
uint32_t status
Definition: jsondef.h:2944
uint16_t modulation
Data modulation.
Definition: jsondef.h:2412
float drate
Current data rate.
Definition: jsondef.h:1617
rvector omega
Attitude rate vector.
Definition: jsondef.h:1869
uint16_t position_type
Position Type.
Definition: jsondef.h:2188
txrstruc txr
Definition: jsondef.h:3725
uint16_t rssi
RSSI.
Definition: jsondef.h:2506
int iretn
Definition: rw_test.cpp:37
BCREG.
Definition: jsondef.h:552
uint16_t mcidx[3]
Torque Rod Component indices.
Definition: jsondef.h:3034
uint16_t didx
Device specific index.
Definition: jsondef.h:1597
#define JSON_ERROR_NOENTRY
Definition: cosmos-errno.h:94
No units.
Definition: jsondef.h:65
uint8_t vuint8
Union of data.
Definition: jsondef.h:1706
float keyval[10]
Value for each key.
Definition: jsondef.h:1759
double uptime
Connection Uptime.
Definition: jsondef.h:2438
Angle.
Definition: jsondef.h:95
rvector o
Definition: jsondef.h:2991
uint16_t type
Component Type.
Definition: jsondef.h:1587
float rmom
Requested Magnetic Moment.
Definition: jsondef.h:1999
uint16_t rssi
RSSI.
Definition: jsondef.h:2414
Rotor.
Definition: jsondef.h:530
float percentage
Battery Percentage Remaining.
Definition: jsondef.h:2658
suchistruc suchi
Definition: jsondef.h:3717
float amp
Current Amperage.
Definition: jsondef.h:1609
int32_t vint32
Definition: jsondef.h:1711
quaternion align
Sensor alignment quaternion.
Definition: jsondef.h:1809
float qvc
Definition: jsondef.h:1812
double e
Elevation.
Definition: vector.h:282
double freq
Input Frequency.
Definition: jsondef.h:2326
float capacity
Capacity in amp hours.
Definition: jsondef.h:2648
JSON rvector.
Definition: jsondef.h:212
Temperature.
Definition: jsondef.h:79
float heading
GPS heading.
Definition: jsondef.h:2180
float qvb
Definition: jsondef.h:1811
float spd
Definition: jsondef.h:2747
Angular rate.
Definition: jsondef.h:97
uint16_t mcnt
Torque Rod count.
Definition: jsondef.h:3032
float romg
Requested angular velocity.
Definition: jsondef.h:1937
quaternion align
Sensor alignment quaternion.
Definition: jsondef.h:2988
double maxfreq
Maximum frequency allowed.
Definition: jsondef.h:2512
uint16_t opmode
Operating mode.
Definition: jsondef.h:2318
float minelev
Minimum elevation.
Definition: jsondef.h:2260
motrstruc motr
Definition: jsondef.h:3706
uint32_t boot_count
Number of reboots.
Definition: jsondef.h:2073
float powerout
Current TX Power.
Definition: jsondef.h:2334
float width
Definition: jsondef.h:3191
float isp
Rotation of thrust vector (+z) in to node frame.
Definition: jsondef.h:2805
rvector dgeocv
Geocentric velocity error: x, y, z.
Definition: jsondef.h:2170
double uptime
Connection Uptime.
Definition: jsondef.h:2346
quaternion align
Rotates vectors from MTR frame to Body frame.
Definition: jsondef.h:1989
uint16_t keyidx[10]
Name for each key.
Definition: jsondef.h:1757
float powerin
Current RX Power.
Definition: jsondef.h:2516
avector euler
Attitude Euler angles.
Definition: jsondef.h:1867
float rat
Definition: jsondef.h:2746
JSON Name type.
Definition: jsondef.h:206
float maxgib
Maximum disk capacity in GiB.
Definition: jsondef.h:2118
Radio Transceiver.
Definition: jsondef.h:512
float maxload
Maximum load.
Definition: jsondef.h:2064
float ppoly[7]
Terms of 6th order polynomial converting positive moment to current.
Definition: jsondef.h:1993
quaternion align
alignment quaternion
Definition: jsondef.h:1861
float vfloat
Definition: jsondef.h:1712
uint16_t pktsize
Packet Size.
Definition: jsondef.h:2324
rvector bdot
Magnetic field rate change in sensor frame.
Definition: jsondef.h:1875
mtrstruc mtr
Definition: jsondef.h:3707
double freq
Input Frequency.
Definition: jsondef.h:2510
float elev
Elevation.
Definition: jsondef.h:2258
Acceleration.
Definition: jsondef.h:89
float elevation
Definition: jsondef.h:1815
double b
Bank.
Definition: vector.h:284
double utc
Device information time stamp.
Definition: jsondef.h:1621
rxrstruc rxr
Definition: jsondef.h:3714
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
float powerout
Current TX Power.
Definition: jsondef.h:2426
uint16_t pheight
Definition: jsondef.h:3190
quaternion align
alignment quaternion
Definition: jsondef.h:3142
Thruster.
Definition: jsondef.h:524
htrstruc htr
Definition: jsondef.h:3703
quaternion theta
Attitude quaternion.
Definition: jsondef.h:1865
float mxmom
Maxiumum field strength.
Definition: jsondef.h:1995
Payload.
Definition: jsondef.h:492
SUCHI.
Definition: jsondef.h:542
float time_remaining
Time Remaining.
Definition: jsondef.h:2660
rvector geocs
Definition: jsondef.h:2164
gpsstruc gps
Definition: jsondef.h:3702
int32_t json_addentry(jsonentry entry, cosmosstruc *cinfo)
Enter an entry into the JSON Namespace.
Definition: jsonlib.cpp:1118
pvstrgstruc pvstrg
Definition: jsondef.h:3711
float gib
Current disk usage in GiB.
Definition: jsondef.h:2120
quaternion att
includes 0 and 1st order derivative
Definition: jsondef.h:2939
float efficiency
Charge conversion efficiency.
Definition: jsondef.h:2650
double txutc
Last TX time.
Definition: jsondef.h:2436
float cap
Propellant capacity in kg.
Definition: jsondef.h:2843
float band
Input Filter bandpass.
Definition: jsondef.h:2522
Camera.
Definition: jsondef.h:544
double h
Height in meters.
Definition: vector.h:229
Pressure sensor.
Definition: jsondef.h:540
JSON 32 bit integer type.
Definition: jsondef.h:196
rvector accel
Position acceleration vector.
Definition: jsondef.h:1863
uint32_t flag
Device flag - catch all for any small piece of information that might be device specific.
Definition: jsondef.h:1591
float powerin
Current RX Power.
Definition: jsondef.h:2332
JSON Boolean.
Definition: jsondef.h:188
gvector geods
Geodetic position: longitude, latitude, altitude.
Definition: jsondef.h:2172
double lon
Longitude in radians.
Definition: vector.h:227
float qvd
Definition: jsondef.h:1813
Magnetic Moment.
Definition: jsondef.h:129
rvector geocv
Geocentric velocity: x, y, z.
Definition: jsondef.h:2166
float powerout
Current TX Power.
Definition: jsondef.h:2518
sttstruc stt
Definition: jsondef.h:3716
mccstruc mcc
Definition: jsondef.h:3705
float azim
Azimuth;.
Definition: jsondef.h:2256
rvector omega
Definition: jsondef.h:2940
float lev
Propellant level in kg.
Definition: jsondef.h:2845
Power Bus.
Definition: jsondef.h:538
Propellant Tank.
Definition: jsondef.h:526
rvector mom
Moments of inertia in RW frame.
Definition: jsondef.h:1925
float flength
Definition: jsondef.h:3193
int8_t vint8
Definition: jsondef.h:1707
float effslope
Efficiency 1st order term.
Definition: jsondef.h:2602
float maxpower
Output Power limit.
Definition: jsondef.h:2428
float maxpower
Output Power limit.
Definition: jsondef.h:2520
JSON double precision floating vertex type.
Definition: jsondef.h:200
Electric Potential.
Definition: jsondef.h:117
float flw
Specific Impulse in dynes per kg per second.
Definition: jsondef.h:2803
char vstring[40+1]
Definition: jsondef.h:1714
float temp
Current Temperature.
Definition: jsondef.h:1619
double lat
Latitude in radians.
Definition: vector.h:225
uint32_t uptime
Seconds CPU has been up.
Definition: jsondef.h:2060
imustruc imu
Definition: jsondef.h:3704
JSON 8 bit signed integer type.
Definition: jsondef.h:184
float press
Current Pressure.
Definition: jsondef.h:3108
double minfreq
Minimum frequency allowed.
Definition: jsondef.h:2514
double uptime
Connection Uptime.
Definition: jsondef.h:2532
Current.
Definition: jsondef.h:77
GPS Unit.
Definition: jsondef.h:504
JSON 32 bit unsigned integer type.
Definition: jsondef.h:190
uint16_t cidx
Component Index.
Definition: jsondef.h:1595
#define MAXPLOADKEYCNT
Maximum number of Special Payload Keys.
Definition: jsondef.h:416
float npoly[7]
Terms of 6th order polynomial converting negative moment to current.
Definition: jsondef.h:1991
Processing Unit.
Definition: jsondef.h:502
Antenna.
Definition: jsondef.h:506
float alp
Current angular acceleration.
Definition: jsondef.h:1935
psenstruc psen
Definition: jsondef.h:3710
rvector alpha
Attitude acceleration vector.
Definition: jsondef.h:1871
ploadstruc pload
Definition: jsondef.h:3708
tcvstruc tcv
Definition: jsondef.h:3720
Battery.
Definition: jsondef.h:516
double col[3]
Definition: vector.h:55
float r_out
Resistance out.
Definition: jsondef.h:2656
JSON single precision floating vertex type.
Definition: jsondef.h:198
propstruc prop
Definition: jsondef.h:3709
float ralp
Requested angular acceleration.
Definition: jsondef.h:1939
float maxgib
Maximum memory capacity in GiB.
Definition: jsondef.h:2068
busstruc bus
Definition: jsondef.h:3698
gvector dgeods
Geodetic position error: longitude, latitude, altitude.
Definition: jsondef.h:2176
float r_in
Resistance in.
Definition: jsondef.h:2654
telemstruc telem
Definition: jsondef.h:3721
battstruc batt
Definition: jsondef.h:3696
uint16_t sats_visible
number of satellites visible by GPS receiver
Definition: jsondef.h:2184
quaternion align
Flow.
Definition: jsondef.h:2801
Star Tracker.
Definition: jsondef.h:532
quaternion align
Alignment.
Definition: jsondef.h:2254
double h
Heading.
Definition: vector.h:280
uint16_t sats_used
number of satellites used by GPS receiver
Definition: jsondef.h:2182
gvector geodv
Geodetic velocity: longitude, latitude, altitude.
Definition: jsondef.h:2174
double minfreq
Minimum frequency allowed.
Definition: jsondef.h:2330
TNC.
Definition: jsondef.h:550
Torque rod Control Unit.
Definition: jsondef.h:536
double dutc
UTC time error.
Definition: jsondef.h:2160
Disk Drive.
Definition: jsondef.h:548
double maxfreq
Maximum frequency allowed.
Definition: jsondef.h:2328
uint16_t opmode
Operating mode.
Definition: jsondef.h:2410
Radio Transmitter.
Definition: jsondef.h:510
float load
Current load.
Definition: jsondef.h:2062
float azimuth
Definition: jsondef.h:1814
antstruc ant
Definition: jsondef.h:3695
uint16_t solution_status
Solution Status.
Definition: jsondef.h:2190
Inertial Measurement Unit.
Definition: jsondef.h:496
JSON gvector.
Definition: jsondef.h:218
Switch.
Definition: jsondef.h:528
uint16_t bcidx
BCREG index.
Definition: jsondef.h:2598
float nvolt
Nominal Voltage.
Definition: jsondef.h:1607
double rxutc
Last RX time.
Definition: jsondef.h:2344
char path[40]
Path.
Definition: jsondef.h:2122
uint16_t modulation
Data modulation.
Definition: jsondef.h:2320
cpustruc cpu
Definition: jsondef.h:3700
gvector dgeodv
Geodetic velocity error: longitude, latitude, altitude.
Definition: jsondef.h:2178
bool state
Definition: jsondef.h:2707
ssenstruc ssen
Definition: jsondef.h:3715
float gib
Current memory usage in GiB.
Definition: jsondef.h:2070
JSON quaternion type.
Definition: jsondef.h:216
float mom
Actual Magnetic Moment.
Definition: jsondef.h:2001
float wdt
Watch Dog Timer (MJD)
Definition: jsondef.h:3075
float tc
Acceleration Time Constant.
Definition: jsondef.h:1931
Temperature Sensor.
Definition: jsondef.h:522
camstruc cam
Definition: jsondef.h:3699
double maxfreq
Maximum frequency allowed.
Definition: jsondef.h:2420
Motion Capture Camera.
Definition: jsondef.h:534
thststruc thst
Definition: jsondef.h:3722
int32_t json_toggledeviceentry ( uint16_t  didx,
DeviceType  type,
cosmosstruc cinfo,
bool  state 
)

Toggle device entry.

Toggle the enable state of the entries specific to device number i in the JSON Namespace map.

Parameters
typeDevice type number taken from DeviceType.
didxDevice number.
stateDesired enable state.
Returns
0 or negative error.

Elevation and Azimuth Sun Sensor

Inertial Measurement Unit

Reaction Wheel

Magnetic Torque Rod

Camera

Processing Unit

GPS Unit

Antenna

Radio Receiver

Radio Transmitter

Radio Transceiver

Photo Voltaic String

Battery

Heater

Motor

Pressure Sensor

Temperature Sensor

Thruster

Propellant Tank

Switch

Rotor

Star Tracker

Star Tracker

8235 {
8236  switch (type)
8237  {
8238  case DeviceType::TELEM:
8239  json_toggleentry("device_telem_utc",didx, UINT16_MAX, cinfo, state);
8240  json_toggleentry("device_telem_cidx",didx, UINT16_MAX, cinfo, state);
8241  json_toggleentry("device_telem_type",didx, UINT16_MAX, cinfo, state);
8242  json_toggleentry("device_telem_vuint8",didx, UINT16_MAX, cinfo, state);
8243  json_toggleentry("device_telem_vint8",didx, UINT16_MAX, cinfo, state);
8244  json_toggleentry("device_telem_vuint16",didx, UINT16_MAX, cinfo, state);
8245  json_toggleentry("device_telem_vint16",didx, UINT16_MAX, cinfo, state);
8246  json_toggleentry("device_telem_vuint32",didx, UINT16_MAX, cinfo, state);
8247  json_toggleentry("device_telem_vint32",didx, UINT16_MAX, cinfo, state);
8248  json_toggleentry("device_telem_vfloat",didx, UINT16_MAX, cinfo, state);
8249  json_toggleentry("device_telem_vdouble",didx, UINT16_MAX, cinfo, state);
8250  json_toggleentry("device_telem_vstring",didx, UINT16_MAX, cinfo, state);
8251  break;
8252  case DeviceType::PLOAD:
8253  json_toggleentry("device_pload_utc",didx, UINT16_MAX, cinfo, state);
8254  json_toggleentry("device_pload_cidx",didx, UINT16_MAX, cinfo, state);
8255  json_toggleentry("device_pload_temp",didx, UINT16_MAX, cinfo, state);
8256  json_toggleentry("device_pload_power",didx, UINT16_MAX, cinfo, state);
8257  json_toggleentry("device_pload_drate",didx, UINT16_MAX, cinfo, state);
8258  json_toggleentry("device_pload_key_cnt",didx, UINT16_MAX, cinfo, state);
8259  for (uint16_t j=0; j<MAXPLOADKEYCNT; j++)
8260  {
8261  json_toggleentry("device_pload_keyidx",didx,j, cinfo, state);
8262  json_toggleentry("device_pload_keyval",didx,j, cinfo, state);
8263  }
8264  break;
8266  case DeviceType::SSEN:
8267  json_toggleentry("device_ssen_utc",didx, UINT16_MAX, cinfo, state);
8268  json_toggleentry("device_ssen_cidx",didx, UINT16_MAX, cinfo, state);
8269  json_toggleentry("device_ssen_temp",didx, UINT16_MAX, cinfo, state);
8270  json_toggleentry("device_ssen_align",didx, UINT16_MAX, cinfo, state);
8271  json_toggleentry("device_ssen_qva",didx, UINT16_MAX, cinfo, state);
8272  json_toggleentry("device_ssen_qvb",didx, UINT16_MAX, cinfo, state);
8273  json_toggleentry("device_ssen_qvc",didx, UINT16_MAX, cinfo, state);
8274  json_toggleentry("device_ssen_qvd",didx, UINT16_MAX, cinfo, state);
8275  json_toggleentry("device_ssen_azimuth",didx, UINT16_MAX, cinfo, state);
8276  json_toggleentry("device_ssen_elevation",didx, UINT16_MAX, cinfo, state);
8277  break;
8279  case DeviceType::IMU:
8280  json_toggleentry("device_imu_utc",didx, UINT16_MAX, cinfo, state);
8281  json_toggleentry("device_imu_cidx",didx, UINT16_MAX, cinfo, state);
8282  json_toggleentry("device_imu_temp",didx, UINT16_MAX, cinfo, state);
8283  json_toggleentry("device_imu_amp",didx, UINT16_MAX, cinfo, state);
8284  json_toggleentry("device_imu_volt",didx, UINT16_MAX, cinfo, state);
8285  json_toggleentry("device_imu_power",didx, UINT16_MAX, cinfo, state);
8286  json_toggleentry("device_imu_align",didx, UINT16_MAX, cinfo, state);
8287  json_toggleentry("device_imu_accel",didx, UINT16_MAX, cinfo, state);
8288  json_toggleentry("device_imu_accel_x",didx, UINT16_MAX, cinfo, state);
8289  json_toggleentry("device_imu_accel_y",didx, UINT16_MAX, cinfo, state);
8290  json_toggleentry("device_imu_accel_z",didx, UINT16_MAX, cinfo, state);
8291  json_toggleentry("device_imu_omega",didx, UINT16_MAX, cinfo, state);
8292  json_toggleentry("device_imu_alpha",didx, UINT16_MAX, cinfo, state);
8293  json_toggleentry("device_imu_mag",didx, UINT16_MAX, cinfo, state);
8294  json_toggleentry("device_imu_mag_x",didx, UINT16_MAX, cinfo, state);
8295  json_toggleentry("device_imu_mag_y",didx, UINT16_MAX, cinfo, state);
8296  json_toggleentry("device_imu_mag_z",didx, UINT16_MAX, cinfo, state);
8297  json_toggleentry("device_imu_bdot",didx, UINT16_MAX, cinfo, state);
8298  break;
8300  case DeviceType::RW:
8301  json_toggleentry("device_rw_utc",didx, UINT16_MAX, cinfo, state);
8302  json_toggleentry("device_rw_cidx",didx, UINT16_MAX, cinfo, state);
8303  json_toggleentry("device_rw_temp",didx, UINT16_MAX, cinfo, state);
8304  json_toggleentry("device_rw_amp",didx, UINT16_MAX, cinfo, state);
8305  json_toggleentry("device_rw_volt",didx, UINT16_MAX, cinfo, state);
8306  json_toggleentry("device_rw_power",didx, UINT16_MAX, cinfo, state);
8307  json_toggleentry("device_rw_align",didx, UINT16_MAX, cinfo, state);
8308  json_toggleentry("device_rw_mom",didx, UINT16_MAX, cinfo, state);
8309  json_toggleentry("device_rw_mxomg",didx, UINT16_MAX, cinfo, state);
8310  json_toggleentry("device_rw_mxalp",didx, UINT16_MAX, cinfo, state);
8311  json_toggleentry("device_rw_tc",didx, UINT16_MAX, cinfo, state);
8312  json_toggleentry("device_rw_omg",didx, UINT16_MAX, cinfo, state);
8313  json_toggleentry("device_rw_alp",didx, UINT16_MAX, cinfo, state);
8314  json_toggleentry("device_rw_romg",didx, UINT16_MAX, cinfo, state);
8315  json_toggleentry("device_rw_ralp",didx, UINT16_MAX, cinfo, state);
8316  break;
8318  case DeviceType::MTR:
8319  json_toggleentry("device_mtr_utc",didx, UINT16_MAX, cinfo, state);
8320  json_toggleentry("device_mtr_cidx",didx, UINT16_MAX, cinfo, state);
8321  json_toggleentry("device_mtr_temp",didx, UINT16_MAX, cinfo, state);
8322  json_toggleentry("device_mtr_amp",didx, UINT16_MAX, cinfo, state);
8323  json_toggleentry("device_mtr_volt",didx, UINT16_MAX, cinfo, state);
8324  json_toggleentry("device_mtr_power",didx, UINT16_MAX, cinfo, state);
8325  json_toggleentry("device_mtr_mxmom",didx, UINT16_MAX, cinfo, state);
8326  json_toggleentry("device_mtr_tc",didx, UINT16_MAX, cinfo, state);
8327  json_toggleentry("device_mtr_align",didx, UINT16_MAX, cinfo, state);
8328  for (uint16_t j=0; j<7; j++)
8329  {
8330  json_toggleentry("device_mtr_npoly",didx,j, cinfo, state);
8331  json_toggleentry("device_mtr_ppoly",didx,j, cinfo, state);
8332  }
8333  json_toggleentry("device_mtr_mom",didx, UINT16_MAX, cinfo, state);
8334  json_toggleentry("device_mtr_rmom",didx, UINT16_MAX, cinfo, state);
8335  break;
8337  case DeviceType::CAM:
8338  json_toggleentry("device_cam_utc",didx, UINT16_MAX, cinfo, state);
8339  json_toggleentry("device_cam_cidx",didx, UINT16_MAX, cinfo, state);
8340  json_toggleentry("device_cam_temp",didx, UINT16_MAX, cinfo, state);
8341  json_toggleentry("device_cam_power",didx, UINT16_MAX, cinfo, state);
8342  json_toggleentry("device_cam_drate",didx, UINT16_MAX, cinfo, state);
8343  json_toggleentry("device_cam_pwidth",didx, UINT16_MAX, cinfo, state);
8344  json_toggleentry("device_cam_pheight",didx, UINT16_MAX, cinfo, state);
8345  json_toggleentry("device_cam_width",didx, UINT16_MAX, cinfo, state);
8346  json_toggleentry("device_cam_height",didx, UINT16_MAX, cinfo, state);
8347  json_toggleentry("device_cam_flength",didx, UINT16_MAX, cinfo, state);
8348  break;
8350  case DeviceType::CPU:
8351  json_toggleentry("device_cpu_utc",didx, UINT16_MAX, cinfo, state);
8352  json_toggleentry("device_cpu_cidx",didx, UINT16_MAX, cinfo, state);
8353  json_toggleentry("device_cpu_temp",didx, UINT16_MAX, cinfo, state);
8354  json_toggleentry("device_cpu_power",didx, UINT16_MAX, cinfo, state);
8355  json_toggleentry("device_cpu_uptime",didx, UINT16_MAX, cinfo, state);
8356  json_toggleentry("device_cpu_downtime",didx, UINT16_MAX, cinfo, state);
8357  json_toggleentry("device_cpu_maxgib",didx, UINT16_MAX, cinfo, state);
8358  json_toggleentry("device_cpu_maxload",didx, UINT16_MAX, cinfo, state);
8359  json_toggleentry("device_cpu_load",didx, UINT16_MAX, cinfo, state);
8360  json_toggleentry("device_cpu_gib",didx, UINT16_MAX, cinfo, state);
8361  json_toggleentry("device_cpu_boot_count",didx, UINT16_MAX, cinfo, state);
8362  break;
8363  case DeviceType::DISK:
8364  json_toggleentry("device_disk_utc",didx, UINT16_MAX, cinfo, state);
8365  json_toggleentry("device_disk_cidx",didx, UINT16_MAX, cinfo, state);
8366  json_toggleentry("device_disk_temp",didx, UINT16_MAX, cinfo, state);
8367  json_toggleentry("device_disk_maxgib",didx, UINT16_MAX, cinfo, state);
8368  json_toggleentry("device_disk_gib",didx, UINT16_MAX, cinfo, state);
8369  json_toggleentry("device_disk_path",didx, UINT16_MAX, cinfo, state);
8370  break;
8372  case DeviceType::GPS:
8373  json_toggleentry("device_gps_utc",didx, UINT16_MAX, cinfo, state);
8374  json_toggleentry("device_gps_cidx",didx, UINT16_MAX, cinfo, state);
8375  json_toggleentry("device_gps_temp",didx, UINT16_MAX, cinfo, state);
8376  json_toggleentry("device_gps_dutc",didx, UINT16_MAX, cinfo, state);
8377  json_toggleentry("device_gps_geocs",didx, UINT16_MAX, cinfo, state);
8378  json_toggleentry("device_gps_geocs_x",didx, UINT16_MAX, cinfo, state);
8379  json_toggleentry("device_gps_geocs_y",didx, UINT16_MAX, cinfo, state);
8380  json_toggleentry("device_gps_geocs_z",didx, UINT16_MAX, cinfo, state);
8381  json_toggleentry("device_gps_geocv",didx, UINT16_MAX, cinfo, state);
8382  json_toggleentry("device_gps_geocv_x",didx, UINT16_MAX, cinfo, state);
8383  json_toggleentry("device_gps_geocv_y",didx, UINT16_MAX, cinfo, state);
8384  json_toggleentry("device_gps_geocv_z",didx, UINT16_MAX, cinfo, state);
8385  json_toggleentry("device_gps_dgeocs",didx, UINT16_MAX, cinfo, state);
8386  json_toggleentry("device_gps_dgeocs_x",didx, UINT16_MAX, cinfo, state);
8387  json_toggleentry("device_gps_dgeocs_y",didx, UINT16_MAX, cinfo, state);
8388  json_toggleentry("device_gps_dgeocs_z",didx, UINT16_MAX, cinfo, state);
8389  json_toggleentry("device_gps_dgeocv",didx, UINT16_MAX, cinfo, state);
8390  json_toggleentry("device_gps_dgeocv_x",didx, UINT16_MAX, cinfo, state);
8391  json_toggleentry("device_gps_dgeocv_y",didx, UINT16_MAX, cinfo, state);
8392  json_toggleentry("device_gps_dgeocv_z",didx, UINT16_MAX, cinfo, state);
8393  json_toggleentry("device_gps_geods",didx, UINT16_MAX, cinfo, state);
8394  json_toggleentry("device_gps_geods_lat",didx, UINT16_MAX, cinfo, state);
8395  json_toggleentry("device_gps_geods_lon",didx, UINT16_MAX, cinfo, state);
8396  json_toggleentry("device_gps_geods_h",didx, UINT16_MAX, cinfo, state);
8397  json_toggleentry("device_gps_geodv",didx, UINT16_MAX, cinfo, state);
8398  json_toggleentry("device_gps_geodv_lat",didx, UINT16_MAX, cinfo, state);
8399  json_toggleentry("device_gps_geodv_lon",didx, UINT16_MAX, cinfo, state);
8400  json_toggleentry("device_gps_geodv_h",didx, UINT16_MAX, cinfo, state);
8401  json_toggleentry("device_gps_dgeods",didx, UINT16_MAX, cinfo, state);
8402  json_toggleentry("device_gps_dgeods_lat",didx, UINT16_MAX, cinfo, state);
8403  json_toggleentry("device_gps_dgeods_lon",didx, UINT16_MAX, cinfo, state);
8404  json_toggleentry("device_gps_dgeods_h",didx, UINT16_MAX, cinfo, state);
8405  json_toggleentry("device_gps_dgeodv",didx, UINT16_MAX, cinfo, state);
8406  json_toggleentry("device_gps_dgeodv_lat",didx, UINT16_MAX, cinfo, state);
8407  json_toggleentry("device_gps_dgeodv_lon",didx, UINT16_MAX, cinfo, state);
8408  json_toggleentry("device_gps_dgeodv_h",didx, UINT16_MAX, cinfo, state);
8409  json_toggleentry("device_gps_heading",didx, UINT16_MAX, cinfo, state);
8410  json_toggleentry("device_gps_sats_used",didx, UINT16_MAX, cinfo, state);
8411  json_toggleentry("device_gps_sats_visible",didx, UINT16_MAX, cinfo, state);
8412  json_toggleentry("device_gps_time_status",didx, UINT16_MAX, cinfo, state);
8413  json_toggleentry("device_gps_position_type",didx, UINT16_MAX, cinfo, state);
8414  json_toggleentry("device_gps_solution_status",didx, UINT16_MAX, cinfo, state);
8415  break;
8417  case DeviceType::ANT:
8418  json_toggleentry("device_ant_utc",didx, UINT16_MAX, cinfo, state);
8419  json_toggleentry("device_ant_cidx",didx, UINT16_MAX, cinfo, state);
8420  json_toggleentry("device_ant_temp",didx, UINT16_MAX, cinfo, state);
8421  json_toggleentry("device_ant_align",didx, UINT16_MAX, cinfo, state);
8422  json_toggleentry("device_ant_azim",didx, UINT16_MAX, cinfo, state);
8423  json_toggleentry("device_ant_elev",didx, UINT16_MAX, cinfo, state);;
8424  json_toggleentry("device_ant_minelev",didx, UINT16_MAX, cinfo, state);
8425  break;
8427  case DeviceType::RXR:
8428  json_toggleentry("device_rxr_utc",didx, UINT16_MAX, cinfo, state);
8429  json_toggleentry("device_rxr_cidx",didx, UINT16_MAX, cinfo, state);
8430  json_toggleentry("device_rxr_temp",didx, UINT16_MAX, cinfo, state);
8431  json_toggleentry("device_rxr_opmode",didx, UINT16_MAX, cinfo, state);
8432  json_toggleentry("device_rxr_modulation",didx, UINT16_MAX, cinfo, state);
8433  json_toggleentry("device_rxr_flag",didx, UINT16_MAX, cinfo, state);
8434  json_toggleentry("device_rxr_rssi",didx, UINT16_MAX, cinfo, state);
8435  json_toggleentry("device_rxr_pktsize",didx, UINT16_MAX, cinfo, state);
8436  json_toggleentry("device_rxr_freq",didx, UINT16_MAX, cinfo, state);
8437  json_toggleentry("device_rxr_maxfreq",didx, UINT16_MAX, cinfo, state);
8438  json_toggleentry("device_rxr_minfreq",didx, UINT16_MAX, cinfo, state);
8439  json_toggleentry("device_rxr_powerin",didx, UINT16_MAX, cinfo, state);
8440  json_toggleentry("device_rxr_powerout",didx, UINT16_MAX, cinfo, state);
8441  json_toggleentry("device_rxr_maxpower",didx, UINT16_MAX, cinfo, state);
8442  json_toggleentry("device_rxr_band",didx, UINT16_MAX, cinfo, state);
8443  json_toggleentry("device_rxr_goodratio",didx, UINT16_MAX, cinfo, state);
8444  json_toggleentry("device_rxr_rxutc",didx, UINT16_MAX, cinfo, state);
8445  json_toggleentry("device_rxr_uptime",didx, UINT16_MAX, cinfo, state);
8446  break;
8448  case DeviceType::TXR:
8449  json_toggleentry("device_txr_utc",didx, UINT16_MAX, cinfo, state);
8450  json_toggleentry("device_txr_cidx",didx, UINT16_MAX, cinfo, state);
8451  json_toggleentry("device_txr_temp",didx, UINT16_MAX, cinfo, state);
8452  json_toggleentry("device_txr_opmode",didx, UINT16_MAX, cinfo, state);
8453  json_toggleentry("device_txr_modulation",didx, UINT16_MAX, cinfo, state);
8454  json_toggleentry("device_txr_flag",didx, UINT16_MAX, cinfo, state);
8455  json_toggleentry("device_txr_rssi",didx, UINT16_MAX, cinfo, state);
8456  json_toggleentry("device_txr_pktsize",didx, UINT16_MAX, cinfo, state);
8457  json_toggleentry("device_txr_freq",didx, UINT16_MAX, cinfo, state);
8458  json_toggleentry("device_txr_maxfreq",didx, UINT16_MAX, cinfo, state);
8459  json_toggleentry("device_txr_minfreq",didx, UINT16_MAX, cinfo, state);
8460  json_toggleentry("device_txr_powerin",didx, UINT16_MAX, cinfo, state);
8461  json_toggleentry("device_txr_powerout",didx, UINT16_MAX, cinfo, state);
8462  json_toggleentry("device_txr_maxpower",didx, UINT16_MAX, cinfo, state);
8463  json_toggleentry("device_txr_band",didx, UINT16_MAX, cinfo, state);
8464  json_toggleentry("device_txr_goodratio",didx, UINT16_MAX, cinfo, state);
8465  json_toggleentry("device_txr_txutc",didx, UINT16_MAX, cinfo, state);
8466  json_toggleentry("device_txr_uptime",didx, UINT16_MAX, cinfo, state);
8467  break;
8469  case DeviceType::TCV:
8470  json_toggleentry("device_tcv_utc",didx, UINT16_MAX, cinfo, state);
8471  json_toggleentry("device_tcv_cidx",didx, UINT16_MAX, cinfo, state);
8472  json_toggleentry("device_tcv_temp",didx, UINT16_MAX, cinfo, state);
8473  json_toggleentry("device_tcv_opmode",didx, UINT16_MAX, cinfo, state);
8474  json_toggleentry("device_tcv_modulation",didx, UINT16_MAX, cinfo, state);
8475  json_toggleentry("device_tcv_flag",didx, UINT16_MAX, cinfo, state);
8476  json_toggleentry("device_tcv_rssi",didx, UINT16_MAX, cinfo, state);
8477  json_toggleentry("device_tcv_pktsize",didx, UINT16_MAX, cinfo, state);
8478  json_toggleentry("device_tcv_freq",didx, UINT16_MAX, cinfo, state);
8479  json_toggleentry("device_tcv_maxfreq",didx, UINT16_MAX, cinfo, state);
8480  json_toggleentry("device_tcv_minfreq",didx, UINT16_MAX, cinfo, state);
8481  json_toggleentry("device_tcv_powerin",didx, UINT16_MAX, cinfo, state);
8482  json_toggleentry("device_tcv_powerout",didx, UINT16_MAX, cinfo, state);
8483  json_toggleentry("device_tcv_maxpower",didx, UINT16_MAX, cinfo, state);
8484  json_toggleentry("device_tcv_band",didx, UINT16_MAX, cinfo, state);
8485  json_toggleentry("device_tcv_goodratio",didx, UINT16_MAX, cinfo, state);
8486  json_toggleentry("device_tcv_txutc",didx, UINT16_MAX, cinfo, state);
8487  json_toggleentry("device_tcv_rxutc",didx, UINT16_MAX, cinfo, state);
8488  json_toggleentry("device_tcv_uptime",didx, UINT16_MAX, cinfo, state);
8489  break;
8491  case DeviceType::PVSTRG:
8492  json_toggleentry("device_pvstrg_utc",didx, UINT16_MAX, cinfo, state);
8493  json_toggleentry("device_pvstrg_cidx",didx, UINT16_MAX, cinfo, state);
8494  json_toggleentry("device_pvstrg_temp",didx, UINT16_MAX, cinfo, state);
8495  json_toggleentry("device_pvstrg_power",didx, UINT16_MAX, cinfo, state);
8496  json_toggleentry("device_pvstrg_efi",didx, UINT16_MAX, cinfo, state);
8497  json_toggleentry("device_pvstrg_efs",didx, UINT16_MAX, cinfo, state);
8498  json_toggleentry("device_pvstrg_max",didx, UINT16_MAX, cinfo, state);
8499  break;
8501  case DeviceType::BATT:
8502  json_toggleentry("device_batt_utc",didx, UINT16_MAX, cinfo, state);
8503  json_toggleentry("device_batt_cidx",didx, UINT16_MAX, cinfo, state);
8504  json_toggleentry("device_batt_temp",didx, UINT16_MAX, cinfo, state);
8505  json_toggleentry("device_batt_cap",didx, UINT16_MAX, cinfo, state);
8506  json_toggleentry("device_batt_eff",didx, UINT16_MAX, cinfo, state);
8507  json_toggleentry("device_batt_charge",didx, UINT16_MAX, cinfo, state);
8508  break;
8510  case DeviceType::HTR:
8511  json_toggleentry("device_htr_utc",didx, UINT16_MAX, cinfo, state);
8512  json_toggleentry("device_htr_temp",didx, UINT16_MAX, cinfo, state);
8513  json_toggleentry("device_htr_cidx",didx, UINT16_MAX, cinfo, state);
8514  json_toggleentry("device_htr_state",didx, UINT16_MAX, cinfo, state);
8515  break;
8517  case DeviceType::MOTR:
8518  json_toggleentry("device_motr_utc",didx, UINT16_MAX, cinfo, state);
8519  json_toggleentry("device_motr_cidx",didx, UINT16_MAX, cinfo, state);
8520  json_toggleentry("device_motr_temp",didx, UINT16_MAX, cinfo, state);
8521  json_toggleentry("device_motr_rat",didx, UINT16_MAX, cinfo, state);
8522  json_toggleentry("device_motr_max",didx, UINT16_MAX, cinfo, state);
8523  json_toggleentry("device_motr_spd",didx, UINT16_MAX, cinfo, state);
8524  break;
8526  case DeviceType::PSEN:
8527  json_toggleentry("device_psen_utc",didx, UINT16_MAX, cinfo, state);
8528  json_toggleentry("device_psen_cidx",didx, UINT16_MAX, cinfo, state);
8529  json_toggleentry("device_psen_temp",didx, UINT16_MAX, cinfo, state);
8530  json_toggleentry("device_psen_press",didx, UINT16_MAX, cinfo, state);;
8531  break;
8533  case DeviceType::TSEN:
8534  json_toggleentry("device_tsen_utc",didx, UINT16_MAX, cinfo, state);
8535  json_toggleentry("device_tsen_cidx",didx, UINT16_MAX, cinfo, state);
8536  json_toggleentry("device_tsen_temp",didx, UINT16_MAX, cinfo, state);
8537  break;
8539  case DeviceType::THST:
8540  json_toggleentry("device_thst_utc",didx, UINT16_MAX, cinfo, state);
8541  json_toggleentry("device_thst_cidx",didx, UINT16_MAX, cinfo, state);
8542  json_toggleentry("device_thst_temp",didx, UINT16_MAX, cinfo, state);
8543  json_toggleentry("device_thst_isp",didx, UINT16_MAX, cinfo, state);
8544  json_toggleentry("device_thst_align",didx, UINT16_MAX, cinfo, state);
8545  json_toggleentry("device_thst_flw",didx, UINT16_MAX, cinfo, state);
8546  break;
8548  case DeviceType::PROP:
8549  json_toggleentry("device_prop_utc",didx, UINT16_MAX, cinfo, state);
8550  json_toggleentry("device_prop_cidx",didx, UINT16_MAX, cinfo, state);
8551  json_toggleentry("device_prop_temp",didx, UINT16_MAX, cinfo, state);
8552  json_toggleentry("device_prop_cap",didx, UINT16_MAX, cinfo, state);
8553  json_toggleentry("device_prop_lev",didx, UINT16_MAX, cinfo, state);
8554  break;
8556  case DeviceType::SWCH:
8557  json_toggleentry("device_swch_utc",didx, UINT16_MAX, cinfo, state);
8558  json_toggleentry("device_swch_cidx",didx, UINT16_MAX, cinfo, state);
8559  json_toggleentry("device_swch_temp",didx, UINT16_MAX, cinfo, state);
8560  json_toggleentry("device_swch_volt",didx, UINT16_MAX, cinfo, state);
8561  json_toggleentry("device_swch_amp",didx, UINT16_MAX, cinfo, state);
8562  json_toggleentry("device_swch_volt",didx, UINT16_MAX, cinfo, state);
8563  json_toggleentry("device_swch_energy",didx, UINT16_MAX, cinfo, state);
8564  break;
8566  case DeviceType::ROT:
8567  json_toggleentry("device_rot_utc",didx, UINT16_MAX, cinfo, state);
8568  json_toggleentry("device_rot_cidx",didx, UINT16_MAX, cinfo, state);
8569  json_toggleentry("device_rot_temp",didx, UINT16_MAX, cinfo, state);
8570  break;
8572  case DeviceType::STT:
8573  json_toggleentry("device_stt_utc",didx, UINT16_MAX, cinfo, state);
8574  json_toggleentry("device_stt_cidx",didx, UINT16_MAX, cinfo, state);
8575  json_toggleentry("device_stt_temp",didx, UINT16_MAX, cinfo, state);
8576  json_toggleentry("device_stt_align",didx, UINT16_MAX, cinfo, state);
8577  json_toggleentry("device_stt_att",didx, UINT16_MAX, cinfo, state);
8578  json_toggleentry("device_stt_omega",didx, UINT16_MAX, cinfo, state);
8579  json_toggleentry("device_stt_retcode",didx, UINT16_MAX, cinfo, state);
8580  json_toggleentry("device_stt_status",didx, UINT16_MAX, cinfo, state);
8581  break;
8583  case DeviceType::SUCHI:
8584  {
8585  json_toggleentry("device_suchi_utc",didx, UINT16_MAX, cinfo, state);
8586  json_toggleentry("device_suchi_cidx",didx, UINT16_MAX, cinfo, state);
8587  json_toggleentry("device_suchi_temp",didx, UINT16_MAX, cinfo, state);
8588  json_toggleentry("device_suchi_align",didx, UINT16_MAX, cinfo, state);
8589  json_toggleentry("device_suchi_press",didx, UINT16_MAX, cinfo, state);
8590  for (uint16_t j=0; j<8; j++)
8591  {
8592  json_toggleentry("device_suchi_temps",didx,j, cinfo, state);
8593  }
8594  break;
8595  }
8596  case DeviceType::MCC:
8597  json_toggleentry("device_mcc_utc",didx, UINT16_MAX, cinfo, state);
8598  json_toggleentry("device_mcc_cidx",didx, UINT16_MAX, cinfo, state);
8599  json_toggleentry("device_mcc_temp",didx, UINT16_MAX, cinfo, state);
8600  json_toggleentry("device_mcc_q",didx, UINT16_MAX, cinfo, state);
8601  json_toggleentry("device_mcc_o",didx, UINT16_MAX, cinfo, state);
8602  json_toggleentry("device_mcc_a",didx, UINT16_MAX, cinfo, state);
8603  json_toggleentry("device_mcc_align",didx, UINT16_MAX, cinfo, state);
8604  break;
8605  case DeviceType::TCU:
8606  json_toggleentry("device_tcu_utc",didx, UINT16_MAX, cinfo, state);
8607  json_toggleentry("device_tcu_cidx",didx, UINT16_MAX, cinfo, state);
8608  json_toggleentry("device_tcu_temp",didx, UINT16_MAX, cinfo, state);
8609  json_toggleentry("device_tcu_mcnt",didx, UINT16_MAX, cinfo, state);
8610  for (uint16_t j=0; j<3; j++)
8611  {
8612  json_toggleentry("device_tcu_mcidx",didx,j, cinfo, state);
8613  }
8614  break;
8615  case DeviceType::BUS:
8616  json_toggleentry("device_bus_utc",didx, UINT16_MAX, cinfo, state);
8617  json_toggleentry("device_bus_cidx",didx, UINT16_MAX, cinfo, state);
8618  json_toggleentry("device_bus_temp",didx, UINT16_MAX, cinfo, state);
8619  json_toggleentry("device_bus_amp",didx, UINT16_MAX, cinfo, state);
8620  json_toggleentry("device_bus_volt",didx, UINT16_MAX, cinfo, state);
8621  json_toggleentry("device_bus_power",didx, UINT16_MAX, cinfo, state);
8622  json_toggleentry("device_bus_energy",didx, UINT16_MAX, cinfo, state);
8623  json_toggleentry("device_bus_wdt",didx, UINT16_MAX, cinfo, state);
8624  break;
8625  case DeviceType::TNC:
8626  json_toggleentry("device_tnc_utc",didx, UINT16_MAX, cinfo, state);
8627  json_toggleentry("device_tnc_cidx",didx, UINT16_MAX, cinfo, state);
8628  json_toggleentry("device_tnc_temp",didx, UINT16_MAX, cinfo, state);
8629  break;
8630  case DeviceType::BCREG:
8631  json_toggleentry("device_bcreg_utc",didx, UINT16_MAX, cinfo, state);
8632  json_toggleentry("device_bcreg_cidx",didx, UINT16_MAX, cinfo, state);
8633  json_toggleentry("device_bcreg_temp",didx, UINT16_MAX, cinfo, state);
8634  json_toggleentry("device_bcreg_volt",didx, UINT16_MAX, cinfo, state);
8635  json_toggleentry("device_bcreg_amp",didx, UINT16_MAX, cinfo, state);
8636  json_toggleentry("device_bcreg_energy",didx, UINT16_MAX, cinfo, state);
8637  json_toggleentry("device_bcreg_power",didx, UINT16_MAX, cinfo, state);
8638  case DeviceType::COUNT:
8639  case DeviceType::NONE:
8640  break;
8641  }
8642 
8643  return 0;
8644 }
Radio Receiver.
Definition: jsondef.h:508
Magnetic Torque Rod.
Definition: jsondef.h:500
Photo Voltaic String.
Definition: jsondef.h:514
Reaction Wheel.
Definition: jsondef.h:498
Heater.
Definition: jsondef.h:518
Motor.
Definition: jsondef.h:520
Telemetry.
Definition: jsondef.h:546
Elevation and Azimuth Sun Sensor.
Definition: jsondef.h:494
Not a Component.
Definition: jsondef.h:556
BCREG.
Definition: jsondef.h:552
Rotor.
Definition: jsondef.h:530
Radio Transceiver.
Definition: jsondef.h:512
List count.
Definition: jsondef.h:554
Thruster.
Definition: jsondef.h:524
Payload.
Definition: jsondef.h:492
SUCHI.
Definition: jsondef.h:542
Camera.
Definition: jsondef.h:544
Pressure sensor.
Definition: jsondef.h:540
int32_t json_toggleentry(string name, uint16_t d1, uint16_t d2, cosmosstruc *cinfo, bool state)
Toggle the enable state of an entry in the JSON Namespace map.
Definition: jsonlib.cpp:1224
Power Bus.
Definition: jsondef.h:538
Propellant Tank.
Definition: jsondef.h:526
GPS Unit.
Definition: jsondef.h:504
#define MAXPLOADKEYCNT
Maximum number of Special Payload Keys.
Definition: jsondef.h:416
Processing Unit.
Definition: jsondef.h:502
Antenna.
Definition: jsondef.h:506
Battery.
Definition: jsondef.h:516
Star Tracker.
Definition: jsondef.h:532
TNC.
Definition: jsondef.h:550
Torque rod Control Unit.
Definition: jsondef.h:536
Disk Drive.
Definition: jsondef.h:548
Radio Transmitter.
Definition: jsondef.h:510
Inertial Measurement Unit.
Definition: jsondef.h:496
Switch.
Definition: jsondef.h:528
Temperature Sensor.
Definition: jsondef.h:522
Motion Capture Camera.
Definition: jsondef.h:534
uint16_t json_mapportentry ( uint16_t  portidx,
cosmosstruc cinfo 
)

Add port entry.

Add entries specific to port number portidx to the JSON Namespace map.

Parameters
portidxPort number.
Returns
The current number of entries, if successful, 0 if the entry could not be added.
8653 {
8654  int32_t iretn;
8655 
8656  json_addentry("port_name", portidx, UINT16_MAX, (ptrdiff_t)offsetof(portstruc,name)+portidx*sizeof(portstruc), (uint16_t)JSON_TYPE_NAME, JSON_STRUCT_PORT, cinfo);
8657  iretn = json_addentry("port_type", portidx, UINT16_MAX, (ptrdiff_t)offsetof(portstruc,type)+portidx*sizeof(portstruc), (uint16_t)JSON_TYPE_UINT16, JSON_STRUCT_PORT, cinfo);
8658 
8659  if (iretn >= 0)
8660  {
8661  iretn = cinfo->jmapped;
8662  }
8663  return iretn;
8664 }
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
int iretn
Definition: rw_test.cpp:37
JSON Name type.
Definition: jsondef.h:206
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
int32_t json_addentry(jsonentry entry, cosmosstruc *cinfo)
Enter an entry into the JSON Namespace.
Definition: jsonlib.cpp:1118
portstruc
Definition: jsondef.h:164
string name
Definition: cubesat2obj.cpp:6
Port structure.
Definition: jsondef.h:1357
int32_t json_toggleportentry ( uint16_t  portidx,
cosmosstruc cinfo,
bool  state 
)

Toggle port entry.

Toggle enable state of entries specific to port number i in the JSON Namespace map.

Parameters
portidxPort number.
stateEnable state.
Returns
The current number of entries, if successful, 0 if the entry could not be added.
8674 {
8675  int32_t iretn;
8676 
8677  json_toggleentry("port_name", portidx, UINT16_MAX, cinfo, state);
8678  iretn = json_toggleentry("port_type", portidx, UINT16_MAX, cinfo,state);
8679 
8680  return iretn;
8681 }
int iretn
Definition: rw_test.cpp:37
int32_t json_toggleentry(string name, uint16_t d1, uint16_t d2, cosmosstruc *cinfo, bool state)
Toggle the enable state of an entry in the JSON Namespace map.
Definition: jsonlib.cpp:1224
const char * json_of_wildcard ( string &  jstring,
string  wildcard,
cosmosstruc cinfo 
)

Create JSON stream from wildcard.

Generate a JSON stream based on a character string representing all the JSON Name Space names you wish to match.

Parameters
jstringPointer to a string large enough to hold the end result.
wildcardCharacter string representing a regular expression to be matched to all names in the JSON Name Space.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the string if successful, otherwise nullptr.
8693 {
8694  int32_t iretn;
8695 
8696  jstring.clear();
8697  iretn = json_out_wildcard(jstring, wildcard, cinfo);
8698  if (iretn < 0)
8699  {
8700  return nullptr;
8701  }
8702 
8703  return jstring.data();
8704 }
int32_t json_out_wildcard(string &jstring, string wildcard, cosmosstruc *cinfo)
Output JSON items from wildcard.
Definition: jsonlib.cpp:2979
int iretn
Definition: rw_test.cpp:37
const char * json_of_list ( string &  jstring,
string  list,
cosmosstruc cinfo 
)

Create JSON stream from list.

Generate a JSON stream based on a comma separated list of JSON Name Space names.

Parameters
jstringPointer to a string large enough to hold the end result.
listList to convert.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the string if successful, otherwise nullptr.
8715 {
8716  int32_t iretn;
8717  jstring.clear();
8718  iretn = json_out_list(jstring, list, cinfo);
8719  if (iretn < 0 && iretn != JSON_ERROR_EOS)
8720  return nullptr;
8721 
8722  return jstring.data();
8723 }
int iretn
Definition: rw_test.cpp:37
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
int32_t json_out_list(string &jstring, string tokens, cosmosstruc *cinfo)
Output a list of named JSON items.
Definition: jsonlib.cpp:2936
const char * json_of_table ( string &  jstring,
vector< jsonentry * >  table,
cosmosstruc cinfo 
)

Create JSON stream from entries.

Generate a JSON stream based on a vector of entries of JSON Name Space names.

Parameters
jstringPointer to a string large enough to hold the end result.
tableVector of pointers to entries from ::jsonmap.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the string if successful, otherwise nullptr.
8734 {
8735  jstring.clear();
8736  for (auto entry: table)
8737  {
8738  if (entry != nullptr)
8739  {
8740  json_out_entry(jstring, *entry, cinfo);
8741  }
8742  }
8743 
8744  return jstring.data();
8745 }
int32_t json_out_entry(string &jstring, const jsonentry &entry, cosmosstruc *cinfo)
Perform JSON output for a single JSON entry.
Definition: jsonlib.cpp:1327
const char * json_of_target ( string &  jstring,
cosmosstruc cinfo,
uint16_t  num 
)

Create JSON Track string.

Generate a JSON stream showing the variables stored in an nodestruc.

Parameters
jstringPointer to a string large enough to hold the end result.
cinfoReference to cosmosstruc to use.
numTarget index.
Returns
Pointer to the string if successful, otherwise nullptr.
8756 {
8757  int32_t iretn;
8758 
8759  jstring.clear();
8760  iretn = json_out_1d(jstring, "target_utc",num, cinfo);
8761  if (iretn < 0)
8762  {
8763  return nullptr;
8764  }
8765  iretn = json_out_1d(jstring, "target_name",num, cinfo);
8766  if (iretn < 0)
8767  {
8768  return nullptr;
8769  }
8770  iretn = json_out_1d(jstring, "target_type",num, cinfo);
8771  if (iretn < 0)
8772  {
8773  return nullptr;
8774  }
8775  iretn = json_out_1d(jstring, "target_azfrom",num, cinfo);
8776  if (iretn < 0)
8777  {
8778  return nullptr;
8779  }
8780  iretn = json_out_1d(jstring, "target_elfrom",num, cinfo);
8781  if (iretn < 0)
8782  {
8783  return nullptr;
8784  }
8785  iretn = json_out_1d(jstring, "target_azto",num, cinfo);
8786  if (iretn < 0)
8787  {
8788  return nullptr;
8789  }
8790  iretn = json_out_1d(jstring, "target_elto",num, cinfo);
8791  if (iretn < 0)
8792  {
8793  return nullptr;
8794  }
8795  iretn = json_out_1d(jstring, "target_min",num, cinfo);
8796  if (iretn < 0)
8797  {
8798  return nullptr;
8799  }
8800  iretn = json_out_1d(jstring, "target_range",num, cinfo);
8801  if (iretn < 0)
8802  {
8803  return nullptr;
8804  }
8805  iretn = json_out_1d(jstring, "target_close",num, cinfo);
8806  if (iretn < 0)
8807  {
8808  return nullptr;
8809  }
8810  iretn = json_out_1d(jstring, "target_loc_pos_geod",num, cinfo);
8811  if (iretn < 0)
8812  {
8813  return nullptr;
8814  }
8815 
8816  return jstring.data();
8817 }
int32_t json_out_1d(string &jstring, const char *token, uint16_t index, cosmosstruc *cinfo)
Perform JSON output for a single element of a 1D named JSON item.
Definition: jsonlib.cpp:2855
int iretn
Definition: rw_test.cpp:37
const char * json_of_node ( string &  jstring,
cosmosstruc cinfo 
)

Create JSON Node string.

Generate a JSON stream showing the variables stored in an nodestruc.

Parameters
jstringPointer to a string large enough to hold the end result.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the string if successful, otherwise nullptr.
8827 {
8828  int32_t iretn;
8829 
8830  jstring.clear();
8831  iretn = json_out(jstring, "node_utcstart", cinfo);
8832  if (iretn < 0)
8833  {
8834  return nullptr;
8835  }
8836  iretn = json_out(jstring, "node_utc", cinfo);
8837  if (iretn < 0)
8838  {
8839  return nullptr;
8840  }
8841  iretn = json_out(jstring, "node_name", cinfo);
8842  if (iretn < 0)
8843  {
8844  return nullptr;
8845  }
8846  iretn = json_out(jstring, "node_lastevent", cinfo);
8847  if (iretn < 0)
8848  {
8849  return nullptr;
8850  }
8851  iretn = json_out(jstring, "node_lasteventutc", cinfo);
8852  if (iretn < 0)
8853  {
8854  return nullptr;
8855  }
8856  iretn = json_out(jstring, "node_type", cinfo);
8857  if (iretn < 0)
8858  {
8859  return nullptr;
8860  }
8861  iretn = json_out(jstring, "node_mass", cinfo);
8862  if (iretn < 0)
8863  {
8864  return nullptr;
8865  }
8866  iretn = json_out(jstring, "node_moi", cinfo);
8867  if (iretn < 0)
8868  {
8869  return nullptr;
8870  }
8871  iretn = json_out(jstring, "node_battcap", cinfo);
8872  if (iretn < 0)
8873  {
8874  return nullptr;
8875  }
8876  iretn = json_out(jstring, "node_battlev", cinfo);
8877  if (iretn < 0)
8878  {
8879  return nullptr;
8880  }
8881  iretn = json_out(jstring, "node_powchg", cinfo);
8882  if (iretn < 0)
8883  {
8884  return nullptr;
8885  }
8886  iretn = json_out(jstring, "node_powmode", cinfo);
8887  if (iretn < 0)
8888  {
8889  return nullptr;
8890  }
8891  iretn = json_out(jstring, "node_powgen", cinfo);
8892  if (iretn < 0)
8893  {
8894  return nullptr;
8895  }
8896  iretn = json_out(jstring, "node_powuse", cinfo);
8897  if (iretn < 0)
8898  {
8899  return nullptr;
8900  }
8901  iretn = json_out(jstring, "node_icrf", cinfo);
8902  if (iretn < 0)
8903  {
8904  return nullptr;
8905  }
8906  iretn = json_out(jstring, "node_icrf", cinfo);
8907  if (iretn < 0)
8908  {
8909  return nullptr;
8910  }
8911 
8912  return jstring.data();
8913 }
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
int iretn
Definition: rw_test.cpp:37
const char * json_of_agent ( string &  jstring,
cosmosstruc cinfo 
)

Create JSON Agent string.

Generate a JSON stream showing the variables stored in an agentstruc.

Parameters
jstringPointer to a string large enough to hold the end result.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the string if successful, otherwise nullptr.
8924 {
8925  int32_t iretn;
8926 
8927  jstring.clear();
8928  iretn = json_out(jstring, "agent_utc", cinfo);
8929  if (iretn < 0)
8930  {
8931  return nullptr;
8932  }
8933  iretn = json_out(jstring, "agent_node", cinfo);
8934  if (iretn < 0)
8935  {
8936  return nullptr;
8937  }
8938  iretn = json_out(jstring, "agent_proc", cinfo);
8939  if (iretn < 0)
8940  {
8941  return nullptr;
8942  }
8943  iretn = json_out(jstring, "agent_user", cinfo);
8944  if (iretn < 0)
8945  {
8946  return nullptr;
8947  }
8948  iretn = json_out(jstring, "agent_aprd", cinfo);
8949  if (iretn < 0)
8950  {
8951  return nullptr;
8952  }
8953  iretn = json_out(jstring, "agent_bprd", cinfo);
8954  if (iretn < 0)
8955  {
8956  return nullptr;
8957  }
8958  iretn = json_out(jstring, "agent_port", cinfo);
8959  if (iretn < 0)
8960  {
8961  return nullptr;
8962  }
8963  iretn = json_out(jstring, "agent_bsz", cinfo);
8964  if (iretn < 0)
8965  {
8966  return nullptr;
8967  }
8968  iretn = json_out(jstring, "agent_addr", cinfo);
8969  if (iretn < 0)
8970  {
8971  return nullptr;
8972  }
8973  iretn = json_out(jstring, "agent_pid", cinfo);
8974  if (iretn < 0)
8975  {
8976  return nullptr;
8977  }
8978  iretn = json_out(jstring, "agent_stateflag", cinfo);
8979  if (iretn < 0)
8980  {
8981  return nullptr;
8982  }
8983  iretn = json_out(jstring, "agent_cpu", cinfo);
8984  if (iretn < 0)
8985  {
8986  return nullptr;
8987  }
8988  iretn = json_out(jstring, "agent_memory", cinfo);
8989  if (iretn < 0)
8990  {
8991  return nullptr;
8992  }
8993  iretn = json_out(jstring, "agent_jitter", cinfo);
8994  if (iretn < 0)
8995  {
8996  return nullptr;
8997  }
8998 
8999  return jstring.data();
9000 }
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
int iretn
Definition: rw_test.cpp:37
const char * json_of_time ( string &  jstring,
cosmosstruc cinfo 
)

Create JSON Time string.

Generate a JSON stream showing the various internal times stored in the global COSMOS data structure.

Parameters
jstringPointer to a string large enough to hold the end result.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the string if successful, otherwise nullptr.
9013 {
9014  int32_t iretn;
9015 
9016  jstring.clear();
9017  iretn = json_out(jstring, "node_utcstart", cinfo);
9018  if (iretn < 0)
9019  return nullptr;
9020  iretn = json_out(jstring, "node_utc", cinfo);
9021  if (iretn < 0)
9022  return nullptr;
9023  iretn = json_out(jstring, "node_utcoffset", cinfo);
9024  if (iretn < 0)
9025  return nullptr;
9026 
9027  return jstring.data();
9028 }
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
int iretn
Definition: rw_test.cpp:37
const char * json_of_beat ( string &  jstring,
cosmosstruc cinfo 
)

Create JSON Heart Beat string.

Create a complete JSON formatted Heartbeat string using the data currently in the global COSMOS structure.

Parameters
jstringReference to a string structure to be used to build out the JSON string.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the string if successful, otherwise nullptr.
9040 {
9041  int32_t iretn;
9042 
9043  jstring.clear();
9044  iretn = json_out(jstring, "beat", cinfo);
9045  if (iretn < 0)
9046  return nullptr;
9047 
9048  return jstring.data();
9049 }
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
int iretn
Definition: rw_test.cpp:37
const char * json_of_beacon ( string &  jstring,
cosmosstruc cinfo 
)

Create JSON Beacon string.

Create a complete JSON formatted Beacon string using the data currently in the global COSMOS structure.

Parameters
jstringReference to a string structure to be used to build out the JSON string.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the string if successful, otherwise nullptr.
9060 {
9061 // int32_t iretn;
9062 // iretn = json_out(jstring, "node_name", cinfo);
9063 // if (iretn < 0)
9064 // {
9065 // return nullptr;
9066 // }
9067 // iretn = json_out(jstring, "node_type", cinfo);
9068 // if (iretn < 0)
9069 // {
9070 // return nullptr;
9071 // }
9072 // iretn = json_out(jstring, "node_utcstart", cinfo);
9073 // if (iretn < 0)
9074 // {
9075 // return nullptr;
9076 // }
9077 // iretn = json_out(jstring, "node_utc", cinfo);
9078 // if (iretn < 0)
9079 // {
9080 // return nullptr;
9081 // }
9082 // iretn = json_out(jstring, "node_utcoffset", cinfo);
9083 // if (iretn < 0)
9084 // {
9085 // return nullptr;
9086 // }
9087 // iretn = json_out(jstring, "node_loc_pos_eci", cinfo);
9088 // if (iretn < 0)
9089 // {
9090 // return nullptr;
9091 // }
9092 // iretn = json_out(jstring, "node_loc_att_icrf", cinfo);
9093 // if (iretn < 0)
9094 // {
9095 // return nullptr;
9096 // }
9097 // iretn = json_out(jstring, "node_powgen", cinfo);
9098 // if (iretn < 0)
9099 // {
9100 // return nullptr;
9101 // }
9102 // iretn = json_out(jstring, "node_powuse", cinfo);
9103 // if (iretn < 0)
9104 // {
9105 // return nullptr;
9106 // }
9107 // iretn = json_out(jstring, "node_powchg", cinfo);
9108 // if (iretn < 0)
9109 // {
9110 // return nullptr;
9111 // }
9112 // iretn = json_out(jstring, "node_battlev", cinfo);
9113 // if (iretn < 0)
9114 // {
9115 // return nullptr;
9116 // }
9117 // iretn = json_out(jstring, "device_cpu_cnt", cinfo);
9118 // if (iretn < 0)
9119 // {
9120 // return nullptr;
9121 // }
9122 
9123 
9124 
9125 // return jstring.data();
9126 
9127  string result;
9128  char tempstring[200];
9129  result = "{\"node_utc\",\"node_name\",\"node_lastevent\",\"node_lasteventutc\",\"node_type\",\"node_state\",\"node_powgen\",\"node_powuse\",\"node_powmode\",\"node_powchg\",\"node_battlev\",\"node_loc_bearth\",\"node_loc_pos_eci\",\"node_loc_att_icrf\"";
9130 
9131  for (uint16_t i=0; i<cinfo->devspec.cpu_cnt; ++i)
9132  {
9133  sprintf(tempstring, ",\"device_cpu_utc_%03d\",\"device_cpu_temp_%03d\"", i, i);
9134  result += tempstring;
9135  sprintf(tempstring, ",\"device_cpu_gib_%03d\",\"device_cpu_load_%03d\",\"device_cpu_boot_count_%03d\"",i,i,i);
9136  result += tempstring;
9137  }
9138  result += "}";
9139 
9140 
9141  jstring.clear();
9142  return json_of_list(jstring, result, cinfo);
9143 }
int i
Definition: rw_test.cpp:37
uint16_t cpu_cnt
Definition: jsondef.h:3867
const char * json_of_list(string &jstring, string list, cosmosstruc *cinfo)
Create JSON stream from list.
Definition: jsonlib.cpp:8714
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
const char * json_of_imu ( string &  jstring,
uint16_t  num,
cosmosstruc cinfo 
)

Create JSON IMU string.

Create a complete JSON formatted IMU string for the indicated IMU using the data currently in the global COSMOS structure.

Parameters
jstringReference to a string structure to be used to build out the JSON string.
numNumber of the IMU.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the string if successful, otherwise nullptr.
9155 {
9156  int32_t iretn;
9157 
9158  jstring.clear();
9159  iretn = json_out_1d(jstring, "device_imu_att",num, cinfo);
9160  if (iretn < 0)
9161  {
9162  return nullptr;
9163  }
9164  iretn = json_out_1d(jstring, "device_imu_align",num, cinfo);
9165  if (iretn < 0)
9166  {
9167  return nullptr;
9168  }
9169  iretn = json_out_1d(jstring, "device_imu_cidx",num, cinfo);
9170  if (iretn < 0)
9171  {
9172  return nullptr;
9173  }
9174  iretn = json_out_1d(jstring, "device_imu_cnt",num, cinfo);
9175  if (iretn < 0)
9176  {
9177  return nullptr;
9178  }
9179  iretn = json_out_1d(jstring, "device_imu_mag",num, cinfo);
9180  if (iretn < 0)
9181  {
9182  return nullptr; }
9183  iretn = json_out_1d(jstring, "device_imu_bdot",num, cinfo);
9184  if (iretn < 0)
9185  {
9186  return nullptr;
9187  }
9188  iretn = json_out_1d(jstring, "device_imu_pos",num, cinfo);
9189  if (iretn < 0)
9190  {
9191  return nullptr;
9192  }
9193 
9194  return jstring.data();
9195 }
int32_t json_out_1d(string &jstring, const char *token, uint16_t index, cosmosstruc *cinfo)
Perform JSON output for a single element of a 1D named JSON item.
Definition: jsonlib.cpp:2855
int iretn
Definition: rw_test.cpp:37
const char * json_of_ephemeris ( string &  jstring,
cosmosstruc cinfo 
)
9198 {
9199  // Location
9200  jstring.clear();
9201  json_out(jstring, "node_utcstart", cinfo);
9202  json_out(jstring, "node_utc", cinfo);
9203  json_out(jstring, "node_utcoffset", cinfo);
9204  json_out(jstring, "node_name", cinfo);
9205  json_out(jstring, "node_type", cinfo);
9206  json_out(jstring, "node_loc_pos_eci", cinfo);
9207 
9208  return jstring.data();
9209 }
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
const char * json_of_utc ( string &  jstring,
cosmosstruc cinfo 
)
9212 {
9213  // Time
9214  jstring.clear();
9215  json_out(jstring, "node_utcstart", cinfo);
9216  json_out(jstring, "node_utc", cinfo);
9217  json_out(jstring, "node_utcoffset", cinfo);
9218  return jstring.data();
9219 }
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
string json_list_of_all ( cosmosstruc cinfo)

Get list of all Namespace names.

Go through the Namespace map, extracting each valid Namespace name. Return this as a JSON like list.

9226 {
9227  string result;
9228 
9229  result = "{";
9230  for (vector<jsonentry> entryrow : cinfo->jmap)
9231  {
9232  for (jsonentry entry : entryrow)
9233  {
9234  char tempstring[200];
9235  sprintf(tempstring, "\"%s\",", entry.name.c_str());
9236  result += tempstring;
9237  }
9238  }
9239  if (result[result.size()-1] == ',')
9240  {
9241  result[result.size()-1] = '}';
9242  }
9243  else
9244  {
9245  result += "}";
9246  }
9247 
9248  return result;
9249 }
JSON map offset entry.
Definition: jsondef.h:4164
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
string json_list_of_soh ( cosmosstruc cinfo)
9253 {
9254  string result;
9255  char tempstring[200];
9256 
9257  result = "{\"node_utc\",\"node_name\",\"node_lastevent\",\"node_lasteventutc\",\"node_type\",\"node_state\",\"node_powgen\",\"node_powuse\",\"node_powchg\",\"node_powmode\",\"node_battlev\",\"node_loc_bearth\",\"node_loc_pos_eci\",\"node_loc_att_icrf\"";
9258 
9259  for (uint16_t i=0; i<cinfo->devspec.pload_cnt; ++i)
9260  {
9261  sprintf(tempstring, ",\"device_pload_utc_%03d\",\"device_pload_temp_%03d\"", i, i);
9262  result += tempstring;
9263  }
9264 
9265  for (uint16_t i=0; i<cinfo->devspec.ssen_cnt; ++i)
9266  {
9267  sprintf(tempstring, ",\"device_ssen_utc_%03d\",\"device_ssen_temp_%03d\"", i, i);
9268  result += tempstring;
9269  sprintf(tempstring, ",\"device_ssen_azimuth_%03d\",\"device_ssen_elevation_%03d\",\"device_ssen_qva_%03d\",\"device_ssen_qvb_%03d\",\"device_ssen_qvc_%03d\",\"device_ssen_qvd_%03d\"",i,i,i,i,i,i);
9270  result += tempstring;
9271  }
9272 
9273  for (uint16_t i=0; i<cinfo->devspec.imu_cnt; ++i)
9274  {
9275  sprintf(tempstring, ",\"device_imu_utc_%03d\",\"device_imu_temp_%03d\"", i, i);
9276  result += tempstring;
9277  sprintf(tempstring, ",\"device_imu_accel_%03d\",\"device_imu_omega_%03d\",\"device_imu_alpha_%03d\",\"device_imu_mag_%03d\",\"device_imu_bdot_%03d\"",i,i,i,i,i);
9278  result += tempstring;
9279  }
9280 
9281  for (uint16_t i=0; i<cinfo->devspec.rw_cnt; ++i)
9282  {
9283  sprintf(tempstring, ",\"device_rw_utc_%03d\",\"device_rw_temp_%03d\"", i, i);
9284  result += tempstring;
9285  sprintf(tempstring, ",\"device_rw_omg_%03d\",\"device_rw_alp_%03d\"",i,i);
9286  result += tempstring;
9287  }
9288 
9289  for (uint16_t i=0; i<cinfo->devspec.mtr_cnt; ++i)
9290  {
9291  sprintf(tempstring, ",\"device_mtr_utc_%03d\",\"device_mtr_temp_%03d\"", i, i);
9292  result += tempstring;
9293  sprintf(tempstring, ",\"device_mtr_mom_%03d\"",i);
9294  result += tempstring;
9295  }
9296 
9297  for (uint16_t i=0; i<cinfo->devspec.cpu_cnt; ++i)
9298  {
9299  sprintf(tempstring, ",\"device_cpu_utc_%03d\",\"device_cpu_temp_%03d\"", i, i);
9300  result += tempstring;
9301  sprintf(tempstring, ",\"device_cpu_gib_%03d\",\"device_cpu_load_%03d\",\"device_cpu_boot_count_%03d\"",i,i,i);
9302  result += tempstring;
9303  }
9304 
9305  for (uint16_t i=0; i<cinfo->devspec.gps_cnt; ++i)
9306  {
9307  sprintf(tempstring, ",\"device_gps_utc_%03d\",\"device_gps_temp_%03d\"", i, i);
9308  result += tempstring;
9309  sprintf(tempstring, ",\"device_gps_geocs_%03d\",\"device_gps_geocv_%03d\",\"device_gps_dgeocs_%03d\",\"device_gps_dgeocv_%03d\"",i,i,i,i);
9310  result += tempstring;
9311  sprintf(tempstring, ",\"device_gps_geods_%03d\",\"device_gps_geodv_%03d\",\"device_gps_dgeods_%03d\",\"device_gps_dgeodv_%03d\"",i,i,i,i);
9312  result += tempstring;
9313  sprintf(tempstring, ",\"device_gps_time_status_%03d\",\"device_gps_solution_status_%03d\",\"device_gps_position_type_%03d\",\"device_gps_sats_used_%03d\"",i,i,i,i);
9314  result += tempstring;
9315  }
9316 
9317  for (uint16_t i=0; i<cinfo->devspec.ant_cnt; ++i)
9318  {
9319  sprintf(tempstring, ",\"device_ant_utc_%03d\",\"device_ant_temp_%03d\"", i, i);
9320  result += tempstring;
9321  sprintf(tempstring, ",\"device_ant_align_%03d\"",i);
9322  result += tempstring;
9323  sprintf(tempstring, ",\"device_ant_azim_%03d\"",i);
9324  result += tempstring;
9325  sprintf(tempstring, ",\"device_ant_elev_%03d\"",i);
9326  result += tempstring;
9327  }
9328 
9329  for (uint16_t i=0; i<cinfo->devspec.rxr_cnt; ++i)
9330  {
9331  sprintf(tempstring, ",\"device_rxr_utc_%03d\",\"device_rxr_temp_%03d\"", i, i);
9332  result += tempstring;
9333  sprintf(tempstring, ",\"device_rxr_flag_%03d\"",i);
9334  result += tempstring;
9335  sprintf(tempstring, ",\"device_rxr_rssi_%03d\"",i);
9336  result += tempstring;
9337  sprintf(tempstring, ",\"device_rxr_freq_%03d\",\"device_rxr_opmode_%03d\",\"device_rxr_modulation_%03d\"",i,i,i);
9338  result += tempstring;
9339  sprintf(tempstring, ",\"device_rxr_band_%03d\"",i);
9340  result += tempstring;
9341  sprintf(tempstring, ",\"device_rxr_powerin_%03d\"",i);
9342  result += tempstring;
9343  }
9344 
9345  for (uint16_t i=0; i<cinfo->devspec.txr_cnt; ++i)
9346  {
9347  sprintf(tempstring, ",\"device_txr_utc_%03d\",\"device_txr_temp_%03d\"", i, i);
9348  result += tempstring;
9349  sprintf(tempstring, ",\"device_txr_flag_%03d\"",i);
9350  result += tempstring;
9351  sprintf(tempstring, ",\"device_txr_rssi_%03d\"",i);
9352  result += tempstring;
9353  sprintf(tempstring, ",\"device_txr_freq_%03d\",\"device_txr_opmode_%03d\",\"device_txr_modulation_%03d\"",i,i,i);
9354  result += tempstring;
9355  sprintf(tempstring, ",\"device_txr_powerout_%03d\"",i);
9356  result += tempstring;
9357  }
9358 
9359  for (uint16_t i=0; i<cinfo->devspec.tcv_cnt; ++i)
9360  {
9361  sprintf(tempstring, ",\"device_tcv_utc_%03d\",\"device_tcv_temp_%03d\"", i, i);
9362  result += tempstring;
9363  sprintf(tempstring, ",\"device_tcv_flag_%03d\"",i);
9364  result += tempstring;
9365  sprintf(tempstring, ",\"device_tcv_rssi_%03d\"",i);
9366  result += tempstring;
9367  sprintf(tempstring, ",\"device_tcv_freq_%03d\",\"device_tcv_opmode_%03d\",\"device_tcv_modulation_%03d\"",i,i,i);
9368  result += tempstring;
9369  sprintf(tempstring, ",\"device_tcv_band_%03d\"",i);
9370  result += tempstring;
9371  sprintf(tempstring, ",\"device_tcv_powerin_%03d\",\"device_tcv_powerout_%03d\"",i,i);
9372  result += tempstring;
9373  }
9374 
9375  for (uint16_t i=0; i<cinfo->devspec.pvstrg_cnt; ++i)
9376  {
9377  sprintf(tempstring, ",\"device_pvstrg_utc_%03d\",\"device_pvstrg_temp_%03d\"", i, i);
9378  result += tempstring;
9379  sprintf(tempstring, ",\"device_pvstrg_power_%03d\"",i);
9380  result += tempstring;
9381  }
9382 
9383  for (uint16_t i=0; i<cinfo->devspec.batt_cnt; ++i)
9384  {
9385  sprintf(tempstring, ",\"device_batt_utc_%03d\",\"device_batt_temp_%03d\"", i, i);
9386  result += tempstring;
9387  sprintf(tempstring, ",\"device_batt_amp_%03d\",\"device_batt_volt_%03d\", \"device_batt_power_%03d\"",i, i, i);
9388  result += tempstring;
9389  sprintf(tempstring, ",\"device_batt_charge_%03d\",\"device_batt_percentage_%03d\", \"device_batt_time_remaining_%03d\"",i,i,i);
9390  result += tempstring;
9391  }
9392 
9393  for (uint16_t i=0; i<cinfo->devspec.htr_cnt; ++i)
9394  {
9395  sprintf(tempstring, ",\"device_htr_utc_%03d\",\"device_htr_temp_%03d\"", i, i);
9396  result += tempstring;
9397  sprintf(tempstring, ",\"device_htr_setvertex_%03d\"",i);
9398  result += tempstring;
9399  sprintf(tempstring, ",\"device_htr_state_%03d\"",i);
9400  result += tempstring;
9401  }
9402 
9403  for (uint16_t i=0; i<cinfo->devspec.motr_cnt; ++i)
9404  {
9405  sprintf(tempstring, ",\"device_motr_utc_%03d\",\"device_motr_temp_%03d\"", i, i);
9406  result += tempstring;
9407  sprintf(tempstring, ",\"device_motr_rat_%03d\",\"device_motr_spd_%03d\"",i,i);
9408  result += tempstring;
9409  }
9410 
9411  for (uint16_t i=0; i<cinfo->devspec.tsen_cnt; ++i)
9412  {
9413  sprintf(tempstring, ",\"device_tsen_utc_%03d\",\"device_tsen_temp_%03d\"", i, i);
9414  result += tempstring;
9415  }
9416 
9417  for (uint16_t i=0; i<cinfo->devspec.thst_cnt; ++i)
9418  {
9419  sprintf(tempstring, ",\"device_thst_utc_%03d\",\"device_thst_temp_%03d\"", i, i);
9420  result += tempstring;
9421  sprintf(tempstring, ",\"device_thst_align_%03d\",\"device_thst_flw_%03d\"",i,i);
9422  result += tempstring;
9423  }
9424 
9425  for (uint16_t i=0; i<cinfo->devspec.prop_cnt; ++i)
9426  {
9427  sprintf(tempstring, ",\"device_prop_utc_%03d\",\"device_prop_temp_%03d\"", i, i);
9428  result += tempstring;
9429  sprintf(tempstring, ",\"device_prop_lev_%03d\"",i);
9430  result += tempstring;
9431  }
9432 
9433  for (uint16_t i=0; i<cinfo->devspec.swch_cnt; ++i)
9434  {
9435  sprintf(tempstring, ",\"device_swch_utc_%03d\",\"device_swch_temp_%03d\"", i, i);
9436  result += tempstring;
9437  sprintf(tempstring, ",\"device_swch_utc_%03d\",\"device_swch_energy_%03d\",\"device_swch_amp_%03d\",\"device_swch_volt_%03d\",\"device_swch_power_%03d\"",i,i,i,i,i);
9438  result += tempstring;
9439  }
9440 
9441  for (uint16_t i=0; i<cinfo->devspec.bcreg_cnt; ++i)
9442  {
9443  sprintf(tempstring, ",\"device_bcreg_utc_%03d\",\"device_bcreg_temp_%03d\"", i, i);
9444  result += tempstring;
9445  sprintf(tempstring, ",\"device_bcreg_utc_%03d\",\"device_bcreg_energy_%03d\",\"device_bcreg_amp_%03d\",\"device_bcreg_volt_%03d\",\"device_bcreg_power_%03d\"",i,i,i,i,i);
9446  result += tempstring;
9447  }
9448 
9449  for (uint16_t i=0; i<cinfo->devspec.rot_cnt; ++i)
9450  {
9451  sprintf(tempstring, ",\"device_rot_utc_%03d\",\"device_rot_temp_%03d\"", i, i);
9452  result += tempstring;
9453  sprintf(tempstring, ",\"device_rot_angle_%03d\"",i);
9454  result += tempstring;
9455  }
9456 
9457  for (uint16_t i=0; i<cinfo->devspec.stt_cnt; ++i)
9458  {
9459  sprintf(tempstring, ",\"device_stt_utc_%03d\",\"device_stt_temp_%03d\"", i, i);
9460  result += tempstring;
9461  sprintf(tempstring, ",\"device_stt_att_%03d\",\"device_stt_omega_%03d\",\"device_stt_alpha_%03d\"",i,i,i);
9462  result += tempstring;
9463  }
9464 
9465  for (uint16_t i=0; i<cinfo->devspec.mcc_cnt; ++i)
9466  {
9467  sprintf(tempstring, ",\"device_mcc_utc_%03d\",\"device_mcc_temp_%03d\"", i, i);
9468  result += tempstring;
9469  sprintf(tempstring, ",\"device_mcc_q_%03d\"",i);
9470  result += tempstring;
9471  sprintf(tempstring, ",\"device_mcc_o_%03d\"",i);
9472  result += tempstring;
9473  sprintf(tempstring, ",\"device_mcc_a_%03d\"",i);
9474  result += tempstring;
9475  }
9476 
9477  for (uint16_t i=0; i<cinfo->devspec.tcu_cnt; ++i)
9478  {
9479  sprintf(tempstring, ",\"device_tcu_utc_%03d\",\"device_tcu_temp_%03d\"", i, i);
9480  result += tempstring;
9481  }
9482 
9483  for (uint16_t i=0; i<cinfo->devspec.bus_cnt; ++i)
9484  {
9485  sprintf(tempstring, ",\"device_bus_utc_%03d\",\"device_bus_temp_%03d\"", i, i);
9486  result += tempstring;
9487  sprintf(tempstring, ",\"device_bus_utc_%03d\",\"device_bus_energy_%03d\",\"device_bus_amp_%03d\",\"device_bus_volt_%03d\",\"device_bus_power_%03d\"",i,i,i,i,i);
9488  result += tempstring;
9489  }
9490 
9491  for (uint16_t i=0; i<cinfo->devspec.psen_cnt; ++i)
9492  {
9493  sprintf(tempstring, ",\"device_psen_utc_%03d\",\"device_psen_temp_%03d\"", i, i);
9494  result += tempstring;
9495  sprintf(tempstring, ",\"device_psen_press_%03d\"",i);
9496  result += tempstring;
9497  }
9498 
9499  for (uint16_t i=0; i<cinfo->devspec.suchi_cnt; ++i)
9500  {
9501  sprintf(tempstring, ",\"device_suchi_utc_%03d\",\"device_suchi_temp_%03d\"", i, i);
9502  result += tempstring;
9503  sprintf(tempstring, ",\"device_suchi_press_%03d\",\"device_suchi_temps_%03d\"",i,i);
9504  result += tempstring;
9505  }
9506 
9507  for (uint16_t i=0; i<cinfo->devspec.cam_cnt; ++i)
9508  {
9509  sprintf(tempstring, ",\"device_cam_utc_%03d\",\"device_cam_temp_%03d\"", i, i);
9510  result += tempstring;
9511  }
9512 
9513  for (uint16_t i=0; i<cinfo->devspec.disk_cnt; ++i)
9514  {
9515  sprintf(tempstring, ",\"device_disk_utc_%03d\",\"device_disk_temp_%03d\"", i, i);
9516  result += tempstring;
9517  sprintf(tempstring, ",\"device_disk_gib_%03d\"",i);
9518  result += tempstring;
9519  sprintf(tempstring, ",\"device_disk_path_%03d\"",i);
9520  result += tempstring;
9521  }
9522 
9523  result += "}";
9524 
9525  return result;
9526 
9527 }
uint16_t disk_cnt
Definition: jsondef.h:3868
uint16_t imu_cnt
Definition: jsondef.h:3871
uint16_t mcc_cnt
Definition: jsondef.h:3872
uint16_t suchi_cnt
Definition: jsondef.h:3885
uint16_t tsen_cnt
Definition: jsondef.h:3891
int i
Definition: rw_test.cpp:37
uint16_t swch_cnt
Definition: jsondef.h:3886
uint16_t motr_cnt
Definition: jsondef.h:3873
uint16_t ssen_cnt
Definition: jsondef.h:3882
uint16_t bcreg_cnt
Definition: jsondef.h:3878
uint16_t tcv_cnt
Definition: jsondef.h:3888
uint16_t psen_cnt
Definition: jsondef.h:3877
uint16_t pload_cnt
Definition: jsondef.h:3875
uint16_t prop_cnt
Definition: jsondef.h:3876
uint16_t txr_cnt
Definition: jsondef.h:3893
uint16_t pvstrg_cnt
Definition: jsondef.h:3883
uint16_t gps_cnt
Definition: jsondef.h:3869
uint16_t batt_cnt
Definition: jsondef.h:3864
uint16_t bus_cnt
Definition: jsondef.h:3865
uint16_t cpu_cnt
Definition: jsondef.h:3867
uint16_t rw_cnt
Definition: jsondef.h:3880
uint16_t ant_cnt
Definition: jsondef.h:3863
uint16_t rxr_cnt
Definition: jsondef.h:3881
uint16_t rot_cnt
Definition: jsondef.h:3879
uint16_t thst_cnt
Definition: jsondef.h:3890
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
uint16_t tcu_cnt
Definition: jsondef.h:3887
uint16_t mtr_cnt
Definition: jsondef.h:3874
uint16_t cam_cnt
Definition: jsondef.h:3866
uint16_t htr_cnt
Definition: jsondef.h:3870
uint16_t stt_cnt
Definition: jsondef.h:3884
string json_list_of_fullsoh ( cosmosstruc cinfo)
9530 {
9531  string result;
9532  char tempstring[200];
9533 
9534  result = "{\"node_utc\",\"node_name\",\"node_lastevent\",\"node_lasteventutc\",\"node_type\",\"node_state\",\"node_powgen\",\"node_powuse\",\"node_powchg\",\"node_powmode\",\"node_battlev\",\"node_loc_bearth\",\"node_loc_pos_eci\",\"node_loc_att_icrf\"";
9535 
9536  for (uint16_t i=0; i<cinfo->devspec.pload_cnt; ++i)
9537  {
9538  sprintf(tempstring, ",\"device_pload_utc_%03d\",\"device_pload_temp_%03d\",\"device_pload_power_%03d\"", i, i, i);
9539  result += tempstring;
9540  }
9541 
9542  for (uint16_t i=0; i<cinfo->devspec.ssen_cnt; ++i)
9543  {
9544  sprintf(tempstring, ",\"device_ssen_utc_%03d\",\"device_ssen_temp_%03d\"", i, i);
9545  result += tempstring;
9546  sprintf(tempstring, ",\"device_ssen_azimuth_%03d\",\"device_ssen_elevation_%03d\",\"device_ssen_qva_%03d\",\"device_ssen_qvb_%03d\",\"device_ssen_qvc_%03d\",\"device_ssen_qvd_%03d\"",i,i,i,i,i,i);
9547  result += tempstring;
9548  }
9549 
9550  for (uint16_t i=0; i<cinfo->devspec.imu_cnt; ++i)
9551  {
9552  sprintf(tempstring, ",\"device_imu_utc_%03d\",\"device_imu_temp_%03d\"", i, i);
9553  result += tempstring;
9554  sprintf(tempstring, ",\"device_imu_amp_%03d\",\"device_imu_volt_%03d\",\"device_imu_power_%03d\"", i, i, i);
9555  result += tempstring;
9556  sprintf(tempstring, ",\"device_imu_accel_%03d\",\"device_imu_omega_%03d\",\"device_imu_alpha_%03d\",\"device_imu_mag_%03d\",\"device_imu_bdot_%03d\"",i,i,i,i,i);
9557  result += tempstring;
9558  }
9559 
9560  for (uint16_t i=0; i<cinfo->devspec.rw_cnt; ++i)
9561  {
9562  sprintf(tempstring, ",\"device_rw_utc_%03d\",\"device_rw_temp_%03d\"", i, i);
9563  result += tempstring;
9564  sprintf(tempstring, ",\"device_rw_amp_%03d\",\"device_rw_volt_%03d\",\"device_rw_power_%03d\"", i, i, i);
9565  result += tempstring;
9566  sprintf(tempstring, ",\"device_rw_omg_%03d\",\"device_rw_alp_%03d\"",i,i);
9567  result += tempstring;
9568  }
9569 
9570  for (uint16_t i=0; i<cinfo->devspec.mtr_cnt; ++i)
9571  {
9572  sprintf(tempstring, ",\"device_mtr_utc_%03d\",\"device_mtr_temp_%03d\"", i, i);
9573  result += tempstring;
9574  sprintf(tempstring, ",\"device_mtr_amp_%03d\",\"device_mtr_volt_%03d\",\"device_mtr_power_%03d\"", i, i, i);
9575  result += tempstring;
9576  sprintf(tempstring, ",\"device_mtr_mom_%03d\"",i);
9577  result += tempstring;
9578  }
9579 
9580  for (uint16_t i=0; i<cinfo->devspec.cpu_cnt; ++i)
9581  {
9582  sprintf(tempstring, ",\"device_cpu_utc_%03d\",\"device_cpu_temp_%03d\"", i, i);
9583  result += tempstring;
9584  sprintf(tempstring, ",\"device_cpu_amp_%03d\",\"device_cpu_volt_%03d\",\"device_cpu_power_%03d\"", i, i, i);
9585  result += tempstring;
9586  sprintf(tempstring, ",\"device_cpu_gib_%03d\",\"device_cpu_load_%03d\",\"device_cpu_boot_count_%03d\"",i,i,i);
9587  result += tempstring;
9588  }
9589 
9590  for (uint16_t i=0; i<cinfo->devspec.gps_cnt; ++i)
9591  {
9592  sprintf(tempstring, ",\"device_gps_utc_%03d\",\"device_gps_temp_%03d\"", i, i);
9593  result += tempstring;
9594  sprintf(tempstring, ",\"device_gps_amp_%03d\",\"device_gps_volt_%03d\",\"device_gps_power_%03d\"", i, i, i);
9595  result += tempstring;
9596  sprintf(tempstring, ",\"device_gps_geocs_%03d\",\"device_gps_geocv_%03d\",\"device_gps_dgeocs_%03d\",\"device_gps_dgeocv_%03d\"",i,i,i,i);
9597  result += tempstring;
9598  sprintf(tempstring, ",\"device_gps_geods_%03d\",\"device_gps_geodv_%03d\",\"device_gps_dgeods_%03d\",\"device_gps_dgeodv_%03d\"",i,i,i,i);
9599  result += tempstring;
9600  sprintf(tempstring, ",\"device_gps_time_status_%03d\",\"device_gps_solution_status_%03d\",\"device_gps_position_type_%03d\",\"device_gps_sats_used_%03d\"",i,i,i,i);
9601  result += tempstring;
9602  }
9603 
9604  for (uint16_t i=0; i<cinfo->devspec.ant_cnt; ++i)
9605  {
9606  sprintf(tempstring, ",\"device_ant_utc_%03d\",\"device_ant_temp_%03d\"", i, i);
9607  result += tempstring;
9608  sprintf(tempstring, ",\"device_ant_amp_%03d\",\"device_ant_volt_%03d\",\"device_ant_power_%03d\"", i, i, i);
9609  result += tempstring;
9610  sprintf(tempstring, ",\"device_ant_align_%03d\"",i);
9611  result += tempstring;
9612  sprintf(tempstring, ",\"device_ant_azim_%03d\"",i);
9613  result += tempstring;
9614  sprintf(tempstring, ",\"device_ant_elev_%03d\"",i);
9615  result += tempstring;
9616  }
9617 
9618  for (uint16_t i=0; i<cinfo->devspec.rxr_cnt; ++i)
9619  {
9620  sprintf(tempstring, ",\"device_rxr_utc_%03d\",\"device_rxr_temp_%03d\"", i, i);
9621  result += tempstring;
9622  sprintf(tempstring, ",\"device_rxr_rxr_%03d\",\"device_rxr_volt_%03d\",\"device_rxr_power_%03d\"", i, i, i);
9623  result += tempstring;
9624  sprintf(tempstring, ",\"device_rxr_flag_%03d\"",i);
9625  result += tempstring;
9626  sprintf(tempstring, ",\"device_rxr_rssi_%03d\"",i);
9627  result += tempstring;
9628  sprintf(tempstring, ",\"device_rxr_freq_%03d\"",i);
9629  result += tempstring;
9630  sprintf(tempstring, ",\"device_rxr_band_%03d\"",i);
9631  result += tempstring;
9632  sprintf(tempstring, ",\"device_rxr_powerin_%03d\"",i);
9633  result += tempstring;
9634  }
9635 
9636  for (uint16_t i=0; i<cinfo->devspec.txr_cnt; ++i)
9637  {
9638  sprintf(tempstring, ",\"device_txr_utc_%03d\",\"device_txr_temp_%03d\"", i, i);
9639  result += tempstring;
9640  sprintf(tempstring, ",\"device_txr_amp_%03d\",\"device_txr_volt_%03d\",\"device_txr_power_%03d\"", i, i, i);
9641  result += tempstring;
9642  sprintf(tempstring, ",\"device_txr_flag_%03d\"",i);
9643  result += tempstring;
9644  sprintf(tempstring, ",\"device_txr_rssi_%03d\"",i);
9645  result += tempstring;
9646  sprintf(tempstring, ",\"device_txr_freq_%03d\"",i);
9647  result += tempstring;
9648  sprintf(tempstring, ",\"device_txr_powerout_%03d\"",i);
9649  result += tempstring;
9650  }
9651 
9652  for (uint16_t i=0; i<cinfo->devspec.tcv_cnt; ++i)
9653  {
9654  sprintf(tempstring, ",\"device_tcv_utc_%03d\",\"device_tcv_temp_%03d\"", i, i);
9655  result += tempstring;
9656  sprintf(tempstring, ",\"device_tcv_amp_%03d\",\"device_tcv_volt_%03d\",\"device_tcv_power_%03d\"", i, i, i);
9657  result += tempstring;
9658  sprintf(tempstring, ",\"device_tcv_flag_%03d\"",i);
9659  result += tempstring;
9660  sprintf(tempstring, ",\"device_tcv_rssi_%03d\"",i);
9661  result += tempstring;
9662  sprintf(tempstring, ",\"device_tcv_freq_%03d\",\"device_tcv_opmode_%03d\"",i,i);
9663  result += tempstring;
9664  sprintf(tempstring, ",\"device_tcv_band_%03d\"",i);
9665  result += tempstring;
9666  sprintf(tempstring, ",\"device_tcv_powerin_%03d\",\"device_tcv_powerout_%03d\"",i,i);
9667  result += tempstring;
9668  }
9669 
9670  for (uint16_t i=0; i<cinfo->devspec.pvstrg_cnt; ++i)
9671  {
9672  sprintf(tempstring, ",\"device_pvstrg_utc_%03d\",\"device_pvstrg_temp_%03d\"", i, i);
9673  result += tempstring;
9674  sprintf(tempstring, ",\"device_pvstrg_power_%03d\"",i);
9675  result += tempstring;
9676  }
9677 
9678  for (uint16_t i=0; i<cinfo->devspec.batt_cnt; ++i)
9679  {
9680  sprintf(tempstring, ",\"device_batt_utc_%03d\",\"device_batt_temp_%03d\"", i, i);
9681  result += tempstring;
9682  sprintf(tempstring, ",\"device_batt_amp_%03d\",\"device_batt_volt_%03d\", \"device_batt_power_%03d\"",i, i, i);
9683  result += tempstring;
9684  sprintf(tempstring, ",\"device_batt_charge_%03d\",\"device_batt_percentage_%03d\", \"device_batt_time_remaining_%03d\"",i,i,i);
9685  result += tempstring;
9686  }
9687 
9688  for (uint16_t i=0; i<cinfo->devspec.htr_cnt; ++i)
9689  {
9690  sprintf(tempstring, ",\"device_htr_utc_%03d\",\"device_htr_temp_%03d\"", i, i);
9691  result += tempstring;
9692  sprintf(tempstring, ",\"device_htr_amp_%03d\",\"device_htr_volt_%03d\",\"device_htr_power_%03d\"", i, i, i);
9693  result += tempstring;
9694  sprintf(tempstring, ",\"device_htr_setvertex_%03d\"",i);
9695  result += tempstring;
9696  sprintf(tempstring, ",\"device_htr_state_%03d\"",i);
9697  result += tempstring;
9698  }
9699 
9700  for (uint16_t i=0; i<cinfo->devspec.motr_cnt; ++i)
9701  {
9702  sprintf(tempstring, ",\"device_motr_utc_%03d\",\"device_motr_temp_%03d\"", i, i);
9703  result += tempstring;
9704  sprintf(tempstring, ",\"device_motr_amp_%03d\",\"device_motr_volt_%03d\",\"device_motr_power_%03d\"", i, i, i);
9705  result += tempstring;
9706  sprintf(tempstring, ",\"device_motr_rat_%03d\",\"device_motr_spd_%03d\"",i,i);
9707  result += tempstring;
9708  }
9709 
9710  for (uint16_t i=0; i<cinfo->devspec.tsen_cnt; ++i)
9711  {
9712  sprintf(tempstring, ",\"device_tsen_utc_%03d\",\"device_tsen_temp_%03d\"", i, i);
9713  result += tempstring;
9714  }
9715 
9716  for (uint16_t i=0; i<cinfo->devspec.thst_cnt; ++i)
9717  {
9718  sprintf(tempstring, ",\"device_thst_utc_%03d\",\"device_thst_temp_%03d\"", i, i);
9719  result += tempstring;
9720  sprintf(tempstring, ",\"device_thst_align_%03d\",\"device_thst_flw_%03d\"",i,i);
9721  result += tempstring;
9722  }
9723 
9724  for (uint16_t i=0; i<cinfo->devspec.prop_cnt; ++i)
9725  {
9726  sprintf(tempstring, ",\"device_prop_utc_%03d\",\"device_prop_temp_%03d\"", i, i);
9727  result += tempstring;
9728  sprintf(tempstring, ",\"device_prop_lev_%03d\"",i);
9729  result += tempstring;
9730  }
9731 
9732  for (uint16_t i=0; i<cinfo->devspec.swch_cnt; ++i)
9733  {
9734  sprintf(tempstring, ",\"device_swch_utc_%03d\",\"device_swch_temp_%03d\"", i, i);
9735  result += tempstring;
9736  sprintf(tempstring, ",\"device_swch_utc_%03d\",\"device_swch_energy_%03d\",\"device_swch_amp_%03d\",\"device_swch_volt_%03d\",\"device_swch_power_%03d\"",i,i,i,i,i);
9737  result += tempstring;
9738  }
9739 
9740  for (uint16_t i=0; i<cinfo->devspec.bcreg_cnt; ++i)
9741  {
9742  sprintf(tempstring, ",\"device_bcreg_utc_%03d\",\"device_bcreg_temp_%03d\"", i, i);
9743  result += tempstring;
9744  sprintf(tempstring, ",\"device_bcreg_utc_%03d\",\"device_bcreg_energy_%03d\",\"device_bcreg_amp_%03d\",\"device_bcreg_volt_%03d\",\"device_bcreg_power_%03d\"",i,i,i,i,i);
9745  result += tempstring;
9746  }
9747 
9748  for (uint16_t i=0; i<cinfo->devspec.rot_cnt; ++i)
9749  {
9750  sprintf(tempstring, ",\"device_rot_utc_%03d\",\"device_rot_temp_%03d\"", i, i);
9751  result += tempstring;
9752  sprintf(tempstring, ",\"device_rot_angle_%03d\"",i);
9753  result += tempstring;
9754  }
9755 
9756  for (uint16_t i=0; i<cinfo->devspec.stt_cnt; ++i)
9757  {
9758  sprintf(tempstring, ",\"device_stt_utc_%03d\",\"device_stt_temp_%03d\"", i, i);
9759  result += tempstring;
9760  sprintf(tempstring, ",\"device_stt_att_%03d\",\"device_stt_omega_%03d\",\"device_stt_alpha_%03d\"",i,i,i);
9761  result += tempstring;
9762  }
9763 
9764  for (uint16_t i=0; i<cinfo->devspec.mcc_cnt; ++i)
9765  {
9766  sprintf(tempstring, ",\"device_mcc_utc_%03d\",\"device_mcc_temp_%03d\"", i, i);
9767  result += tempstring;
9768  sprintf(tempstring, ",\"device_mcc_q_%03d\"",i);
9769  result += tempstring;
9770  sprintf(tempstring, ",\"device_mcc_o_%03d\"",i);
9771  result += tempstring;
9772  sprintf(tempstring, ",\"device_mcc_a_%03d\"",i);
9773  result += tempstring;
9774  }
9775 
9776  for (uint16_t i=0; i<cinfo->devspec.tcu_cnt; ++i)
9777  {
9778  sprintf(tempstring, ",\"device_tcu_utc_%03d\",\"device_tcu_temp_%03d\"", i, i);
9779  result += tempstring;
9780  }
9781 
9782  for (uint16_t i=0; i<cinfo->devspec.bus_cnt; ++i)
9783  {
9784  sprintf(tempstring, ",\"device_bus_utc_%03d\",\"device_bus_temp_%03d\"", i, i);
9785  result += tempstring;
9786  sprintf(tempstring, ",\"device_bus_utc_%03d\",\"device_bus_energy_%03d\",\"device_bus_amp_%03d\",\"device_bus_volt_%03d\",\"device_bus_power_%03d\"",i,i,i,i,i);
9787  result += tempstring;
9788  }
9789 
9790  for (uint16_t i=0; i<cinfo->devspec.psen_cnt; ++i)
9791  {
9792  sprintf(tempstring, ",\"device_psen_utc_%03d\",\"device_psen_temp_%03d\"", i, i);
9793  result += tempstring;
9794  sprintf(tempstring, ",\"device_psen_press_%03d\"",i);
9795  result += tempstring;
9796  }
9797 
9798  for (uint16_t i=0; i<cinfo->devspec.suchi_cnt; ++i)
9799  {
9800  sprintf(tempstring, ",\"device_suchi_utc_%03d\",\"device_suchi_temp_%03d\"", i, i);
9801  result += tempstring;
9802  sprintf(tempstring, ",\"device_suchi_press_%03d\",\"device_suchi_temps_%03d\"",i,i);
9803  result += tempstring;
9804  }
9805 
9806  for (uint16_t i=0; i<cinfo->devspec.cam_cnt; ++i)
9807  {
9808  sprintf(tempstring, ",\"device_cam_utc_%03d\",\"device_cam_temp_%03d\"", i, i);
9809  result += tempstring;
9810  }
9811 
9812  for (uint16_t i=0; i<cinfo->devspec.disk_cnt; ++i)
9813  {
9814  sprintf(tempstring, ",\"device_disk_utc_%03d\",\"device_disk_temp_%03d\"", i, i);
9815  result += tempstring;
9816  sprintf(tempstring, ",\"device_disk_gib_%03d\"",i);
9817  result += tempstring;
9818  sprintf(tempstring, ",\"device_disk_path_%03d\"",i);
9819  result += tempstring;
9820  }
9821 
9822  result += "}";
9823 
9824  return result;
9825 
9826 }
uint16_t disk_cnt
Definition: jsondef.h:3868
uint16_t imu_cnt
Definition: jsondef.h:3871
uint16_t mcc_cnt
Definition: jsondef.h:3872
uint16_t suchi_cnt
Definition: jsondef.h:3885
uint16_t tsen_cnt
Definition: jsondef.h:3891
int i
Definition: rw_test.cpp:37
uint16_t swch_cnt
Definition: jsondef.h:3886
uint16_t motr_cnt
Definition: jsondef.h:3873
uint16_t ssen_cnt
Definition: jsondef.h:3882
uint16_t bcreg_cnt
Definition: jsondef.h:3878
uint16_t tcv_cnt
Definition: jsondef.h:3888
uint16_t psen_cnt
Definition: jsondef.h:3877
uint16_t pload_cnt
Definition: jsondef.h:3875
uint16_t prop_cnt
Definition: jsondef.h:3876
uint16_t txr_cnt
Definition: jsondef.h:3893
uint16_t pvstrg_cnt
Definition: jsondef.h:3883
uint16_t gps_cnt
Definition: jsondef.h:3869
uint16_t batt_cnt
Definition: jsondef.h:3864
uint16_t bus_cnt
Definition: jsondef.h:3865
uint16_t cpu_cnt
Definition: jsondef.h:3867
uint16_t rw_cnt
Definition: jsondef.h:3880
uint16_t ant_cnt
Definition: jsondef.h:3863
uint16_t rxr_cnt
Definition: jsondef.h:3881
uint16_t rot_cnt
Definition: jsondef.h:3879
uint16_t thst_cnt
Definition: jsondef.h:3890
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
uint16_t tcu_cnt
Definition: jsondef.h:3887
uint16_t mtr_cnt
Definition: jsondef.h:3874
uint16_t cam_cnt
Definition: jsondef.h:3866
uint16_t htr_cnt
Definition: jsondef.h:3870
uint16_t stt_cnt
Definition: jsondef.h:3884
const char * json_of_soh ( string &  jstring,
cosmosstruc cinfo 
)
9829 {
9830  int32_t iretn;
9831 
9832  jstring.clear();
9833  // Time
9834  json_out(jstring, "node_utcoffset", cinfo);
9835 
9836  // Satellite Information
9837  string soh = json_list_of_soh(cinfo);
9838  iretn = json_out_list(jstring, soh.c_str(), cinfo);
9839  if (iretn < 0 && iretn != JSON_ERROR_EOS)
9840  return nullptr;
9841 
9842  return jstring.data();
9843 }
string json_list_of_soh(cosmosstruc *cinfo)
Definition: jsonlib.cpp:9252
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
int iretn
Definition: rw_test.cpp:37
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
int32_t json_out_list(string &jstring, string tokens, cosmosstruc *cinfo)
Output a list of named JSON items.
Definition: jsonlib.cpp:2936
const char * json_of_event ( string &  jstring,
cosmosstruc cinfo 
)

Create JSON for an event.

Generate a JSON stream that represents the current state of the eventstruc in cosmosstruc.

Parameters
jstringUser provided string for creating the JSON stream
cinfoReference to cosmosstruc to use.
Returns
Pointer to the string created.
9855 {
9856  jstring.clear();
9857  json_out(jstring, "event_utc", cinfo);
9858  if (json_get_double("event_utcexec", cinfo) != 0.) json_out(jstring, "event_utcexec", cinfo);
9859  json_out(jstring, "event_node", cinfo);
9860  json_out(jstring, "event_name", cinfo);
9861  json_out(jstring, "event_user", cinfo);
9862  json_out(jstring, "event_type", cinfo);
9863  json_out(jstring, "event_flag", cinfo);
9864  json_out(jstring, "event_data", cinfo);
9865  json_out(jstring, "event_condition", cinfo);
9866  if (json_get_double("event_dtime", cinfo) != 0.) json_out(jstring,"event_dtime", cinfo);
9867  if (json_get_double("event_ctime", cinfo) != 0.) json_out(jstring,"event_ctime", cinfo);
9868  if (json_get_double("event_denergy", cinfo) != 0.) json_out(jstring,"event_denergy", cinfo);
9869  if (json_get_double("event_cenergy", cinfo) != 0.) json_out(jstring,"event_cenergy", cinfo);
9870  if (json_get_double("event_dmass", cinfo) != 0.) json_out(jstring,"event_dmass", cinfo);
9871  if (json_get_double("event_cmass", cinfo) != 0.) json_out(jstring,"event_cmass", cinfo);
9872  if (json_get_double("event_dbytes", cinfo) != 0.) json_out(jstring,"event_dbytes", cinfo);
9873  if (json_get_double("event_cbytes", cinfo) != 0.) json_out(jstring,"event_cbytes", cinfo);
9874 
9875  return jstring.data();
9876 }
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
double json_get_double(jsonhandle &handle, cosmosstruc *cinfo)
Return double from handle.
Definition: jsonlib.cpp:3679
const char* json_of_groundcontact ( string &  jstring,
cosmosstruc cinfo 
)
9879 {
9880  int16_t i;
9881 
9882  jstring.clear();
9883  json_out(jstring, "node_utcstart", cinfo);
9884  json_out(jstring, "node_utc", cinfo);
9885  json_out(jstring, "node_utcoffset", cinfo);
9886  json_out(jstring, "gs_cnt", cinfo);
9887  for (i=0; i<*(int16_t *)json_ptrto((char *)"gs_cnt", cinfo); i++)
9888  {
9889  json_out_1d(jstring, "gs_az",i, cinfo);
9890  json_out_1d(jstring, "gs_el",i, cinfo);
9891  }
9892 
9893  return jstring.data();
9894 }
int32_t json_out_1d(string &jstring, const char *token, uint16_t index, cosmosstruc *cinfo)
Perform JSON output for a single element of a 1D named JSON item.
Definition: jsonlib.cpp:2855
int i
Definition: rw_test.cpp:37
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
uint8_t * json_ptrto(string token, cosmosstruc *cinfo)
Return the data pointer that matches a JSON name.
Definition: jsonlib.cpp:3283
const char * json_of_mtr ( string &  jstring,
uint16_t  index,
cosmosstruc cinfo 
)
9897 {
9898  jstring.clear();
9899  json_out(jstring, "node_utc", cinfo);
9900  json_out(jstring, "node_utcoffset", cinfo);
9901 
9902  json_out_1d(jstring, "device_mtr_cidx",index, cinfo);
9903  json_out_1d(jstring, "device_mtr_mom",index, cinfo);
9904  json_out_1d(jstring, "device_mtr_mom",index, cinfo);
9905  json_out_1d(jstring, "device_mtr_rmom",index, cinfo);
9906 
9907  return jstring.data();
9908 }
int32_t json_out_1d(string &jstring, const char *token, uint16_t index, cosmosstruc *cinfo)
Perform JSON output for a single element of a 1D named JSON item.
Definition: jsonlib.cpp:2855
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
const char * json_of_rw ( string &  jstring,
uint16_t  index,
cosmosstruc cinfo 
)
9912 {
9913  jstring.clear();
9914  json_out(jstring, "node_utc", cinfo);
9915  json_out(jstring, "node_utcoffset", cinfo);
9916 
9917  json_out_1d(jstring, "device_rw_utc",index, cinfo);
9918  json_out_1d(jstring, "device_rw_cidx",index, cinfo);
9919  json_out_1d(jstring, "device_rw_mom_x",index, cinfo);
9920  json_out_1d(jstring, "device_rw_mom_y",index, cinfo);
9921  json_out_1d(jstring, "device_rw_mom_z",index, cinfo);
9922  json_out_1d(jstring, "device_rw_omg",index, cinfo);
9923  json_out_1d(jstring, "device_rw_alp",index, cinfo);
9924  json_out_1d(jstring, "device_rw_romg",index, cinfo);
9925  json_out_1d(jstring, "device_rw_ralp",index, cinfo);
9926 
9927  return jstring.data();
9928 }
int32_t json_out_1d(string &jstring, const char *token, uint16_t index, cosmosstruc *cinfo)
Perform JSON output for a single element of a 1D named JSON item.
Definition: jsonlib.cpp:2855
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
const char * json_of_state_eci ( string &  jstring,
cosmosstruc cinfo 
)
9931 {
9932  jstring.clear();
9933  // json_out(jstring, "node_utc", cinfo);
9934  // json_out(jstring, "node_utcoffset", cinfo);
9935  json_out(jstring, "node_loc_pos_eci", cinfo);
9936  json_out(jstring, "node_loc_att_icrf", cinfo);
9937  return jstring.data();
9938 }
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
const char * json_of_state_geoc ( string &  jstring,
cosmosstruc cinfo 
)
9942 {
9943  jstring.clear();
9944  // json_out(jstring, "node_utc", cinfo);
9945  // json_out(jstring, "node_utcoffset", cinfo);
9946  json_out(jstring, "node_loc_pos_geoc", cinfo);
9947  json_out(jstring, "node_loc_att_geoc", cinfo);
9948  return jstring.data();
9949 }
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
const char * json_node ( string &  jstring,
cosmosstruc cinfo 
)

Dump Node description.

Create a JSON stream for general Node variables. Does not include any derivative data (eg. area).

Parameters
jstringReference to a string to build the JSON stream in.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the created JSON stream.
9961 {
9962 
9963  jstring.clear();
9964  json_out(jstring, "node_type", cinfo);
9965  json_out_character(jstring, '\n');
9966  json_out(jstring, "node_piece_cnt", cinfo);
9967  json_out_character(jstring, '\n');
9968  json_out(jstring, "node_vertex_cnt", cinfo);
9969  json_out_character(jstring, '\n');
9970  json_out(jstring, "node_face_cnt", cinfo);
9971  json_out_character(jstring, '\n');
9972  json_out(jstring, "node_device_cnt", cinfo);
9973  json_out_character(jstring, '\n');
9974  json_out(jstring, "node_port_cnt", cinfo);
9975  json_out_character(jstring, '\n');
9976 
9977  return jstring.data();
9978 }
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
int32_t json_out_character(string &jstring, char character)
Single character to JSON.
Definition: jsonlib.cpp:1558
const char * json_vertices ( string &  jstring,
cosmosstruc cinfo 
)

Dump Vertex description.

Create a JSON stream for variables specific to the Vertices of the Node. Does not include any derivative data (eg. area).

Parameters
jstringReference to a string to build the JSON stream in.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the created JSON stream.
9990 {
9991  jstring.clear();
9992  // Dump vertices
9993  uint16_t *vertex_cnt = (uint16_t *)json_ptrto((char *)"node_vertex_cnt", cinfo);
9994  if (vertex_cnt != nullptr)
9995  {
9996  for (uint16_t i=0; i<*vertex_cnt; i++)
9997  {
9998  json_out_1d(jstring, "vertex",i, cinfo);
9999  // // json_out_character(jstring, '\n');
10000  }
10001  }
10002 
10003 
10004  return jstring.data();
10005 }
int32_t json_out_1d(string &jstring, const char *token, uint16_t index, cosmosstruc *cinfo)
Perform JSON output for a single element of a 1D named JSON item.
Definition: jsonlib.cpp:2855
int i
Definition: rw_test.cpp:37
uint8_t * json_ptrto(string token, cosmosstruc *cinfo)
Return the data pointer that matches a JSON name.
Definition: jsonlib.cpp:3283
const char * json_faces ( string &  jstring,
cosmosstruc cinfo 
)

Dump Face description.

Create a JSON stream for variables specific to the cinfo->faces of the Node. Does not include any derivative data (eg. area).

Parameters
jstringReference to a string to build the JSON stream in.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the created JSON stream.
10017 {
10018  jstring.clear();
10019  // Dump faces
10020  uint16_t *face_cnt = (uint16_t *)json_ptrto((char *)"node_face_cnt", cinfo);
10021  if (face_cnt != nullptr)
10022  {
10023  for (uint16_t i=0; i<*face_cnt; i++)
10024  {
10025  json_out_1d(jstring, "face_normal",i, cinfo);
10026  // // json_out_character(jstring, '\n');
10027  json_out_1d(jstring, "face_com",i, cinfo);
10028  // // json_out_character(jstring, '\n');
10029  json_out_1d(jstring, "face_area",i, cinfo);
10030  // // json_out_character(jstring, '\n');
10031  json_out_1d(jstring, "face_vertex_cnt",i, cinfo);
10032  // // json_out_character(jstring, '\n');
10033  uint16_t cnt = (uint16_t)json_get_int((char *)"face_vertex_cnt",i, cinfo);
10034  for (uint16_t j=0; j<cnt; j++)
10035  {
10036  json_out_2d(jstring, "face_vertex_idx",i,j, cinfo);
10037  // // json_out_character(jstring, '\n');
10038  }
10039  }
10040  }
10041 
10042 
10043  return jstring.data();
10044 }
int32_t json_out_1d(string &jstring, const char *token, uint16_t index, cosmosstruc *cinfo)
Perform JSON output for a single element of a 1D named JSON item.
Definition: jsonlib.cpp:2855
int i
Definition: rw_test.cpp:37
uint8_t * json_ptrto(string token, cosmosstruc *cinfo)
Return the data pointer that matches a JSON name.
Definition: jsonlib.cpp:3283
int32_t json_get_int(jsonhandle &handle, cosmosstruc *cinfo)
Return integer from handle.
Definition: jsonlib.cpp:3360
int32_t json_out_2d(string &jstring, const char *token, uint16_t row, uint16_t col, cosmosstruc *cinfo)
Perform JSON output for a single element of a 2D named JSON item.
Definition: jsonlib.cpp:2881
const char * json_pieces ( string &  jstring,
cosmosstruc cinfo 
)

Dump Piece description.

Create a JSON stream for variables specific to the Pieces of the Node. Does not include any derivative data (eg. area).

Parameters
jstringReference to a string to build the JSON stream in.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the created JSON stream.
10056 {
10057  jstring.clear();
10058  // Dump structures
10059  uint16_t *piece_cnt = (uint16_t *)json_ptrto((char *)"node_piece_cnt", cinfo);
10060  if (piece_cnt != nullptr)
10061  {
10062  for (uint16_t i=0; i<*piece_cnt; i++)
10063  {
10064  json_out_1d(jstring, "piece_name",i, cinfo);
10065  // // json_out_character(jstring, '\n');
10066 // json_out_1d(jstring, "piece_type",i, cinfo);
10067  // // json_out_character(jstring, '\n');
10068  json_out_1d(jstring, "piece_cidx",i, cinfo);
10069  // // json_out_character(jstring, '\n');
10070  json_out_1d(jstring, "piece_mass",i, cinfo);
10071  // // json_out_character(jstring, '\n');
10072  json_out_1d(jstring, "piece_density",i, cinfo);
10073  // // json_out_character(jstring, '\n');
10074  json_out_1d(jstring, "piece_emi",i, cinfo);
10075  // // json_out_character(jstring, '\n');
10076  json_out_1d(jstring, "piece_abs",i, cinfo);
10077  // // json_out_character(jstring, '\n');
10078  json_out_1d(jstring, "piece_hcap",i, cinfo);
10079  // // json_out_character(jstring, '\n');
10080  json_out_1d(jstring, "piece_hcon",i, cinfo);
10081  // // json_out_character(jstring, '\n');
10082  json_out_1d(jstring, "piece_dim",i, cinfo);
10083  // // json_out_character(jstring, '\n');
10084  json_out_1d(jstring, "piece_area",i, cinfo);
10085  // json_out_character(jstring, '\n');
10086  json_out_1d(jstring, "piece_com",i, cinfo);
10087  // json_out_character(jstring, '\n');
10088  json_out_1d(jstring, "piece_face_cnt",i, cinfo);
10089  // json_out_character(jstring, '\n');
10090  uint16_t cnt = (uint16_t)json_get_int((char *)"piece_face_cnt",i, cinfo);
10091  for (uint16_t j=0; j<cnt; j++)
10092  {
10093  json_out_2d(jstring, "piece_face_idx",i,j, cinfo);
10094  // json_out_character(jstring, '\n');
10095  }
10096  }
10097  }
10098 
10099 
10100  return jstring.data();
10101 }
int32_t json_out_1d(string &jstring, const char *token, uint16_t index, cosmosstruc *cinfo)
Perform JSON output for a single element of a 1D named JSON item.
Definition: jsonlib.cpp:2855
int i
Definition: rw_test.cpp:37
uint8_t * json_ptrto(string token, cosmosstruc *cinfo)
Return the data pointer that matches a JSON name.
Definition: jsonlib.cpp:3283
int32_t json_get_int(jsonhandle &handle, cosmosstruc *cinfo)
Return integer from handle.
Definition: jsonlib.cpp:3360
int32_t json_out_2d(string &jstring, const char *token, uint16_t row, uint16_t col, cosmosstruc *cinfo)
Perform JSON output for a single element of a 2D named JSON item.
Definition: jsonlib.cpp:2881
const char * json_devices_general ( string &  jstring,
cosmosstruc cinfo 
)

Dump General Device description.

Create a JSON stream for variables common to all Devices in the Node. Does not include any derivative data (eg. area).

Parameters
jstringReference to a string to build the JSON stream in.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the created JSON stream.
10113 {
10114 
10115  jstring.clear();
10116  // Dump components
10117  uint16_t *device_cnt = (uint16_t *)json_ptrto((char *)"node_device_cnt", cinfo);
10118  if (device_cnt != nullptr)
10119  {
10120  for (uint16_t i=0; i<*device_cnt; i++)
10121  {
10122  json_out_1d(jstring, "device_all_type",i, cinfo);
10123  // json_out_character(jstring, '\n');
10124  json_out_1d(jstring, "device_all_model",i, cinfo);
10125  // json_out_character(jstring, '\n');
10126  json_out_1d(jstring, "device_all_didx",i, cinfo);
10127  // json_out_character(jstring, '\n');
10128  json_out_1d(jstring, "device_all_pidx",i, cinfo);
10129  // json_out_character(jstring, '\n');
10130  json_out_1d(jstring, "device_all_bidx",i, cinfo);
10131  // json_out_character(jstring, '\n');
10132  json_out_1d(jstring, "device_all_addr",i, cinfo);
10133  // json_out_character(jstring, '\n');
10134  json_out_1d(jstring, "device_all_portidx",i, cinfo);
10135  // json_out_character(jstring, '\n');
10136  json_out_1d(jstring, "device_all_nvolt",i, cinfo);
10137  // json_out_character(jstring, '\n');
10138  json_out_1d(jstring, "device_all_namp",i, cinfo);
10139  // json_out_character(jstring, '\n');
10140  json_out_1d(jstring, "device_all_flag",i, cinfo);
10141  // json_out_character(jstring, '\n');
10142  }
10143  }
10144 
10145 
10146  return jstring.data();
10147 }
int32_t json_out_1d(string &jstring, const char *token, uint16_t index, cosmosstruc *cinfo)
Perform JSON output for a single element of a 1D named JSON item.
Definition: jsonlib.cpp:2855
int i
Definition: rw_test.cpp:37
uint8_t * json_ptrto(string token, cosmosstruc *cinfo)
Return the data pointer that matches a JSON name.
Definition: jsonlib.cpp:3283
const char * json_devices_specific ( string &  jstring,
cosmosstruc cinfo 
)

Dump Specific Device description.

Create a JSON stream for variables specific to particular Devices in the Node. Does not include any derivative data (eg. area).

Parameters
jstringReference to a string to build the JSON stream in.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the created JSON stream.
10159 {
10160  uint16_t *cnt;
10161  char tstring[COSMOS_MAX_NAME+1];
10162 
10163  jstring.clear();
10164  // Dump device specific info
10165  for (uint16_t i=0; i<DeviceType::COUNT; ++i)
10166  {
10167  // Create Namespace name for Device Specific count
10168  sprintf(tstring,"device_%s_cnt",device_type_string[i].c_str());
10169  if ((cnt=(uint16_t *)json_ptrto(tstring, cinfo)) != nullptr && *cnt != 0)
10170  {
10171  // Only dump information for Devices that have non zero count
10172  for (uint16_t j=0; j<*cnt; ++j)
10173  {
10174  // Dump ploads
10175  if (!strcmp(device_type_string[i].c_str(),"pload"))
10176  {
10177  json_out_1d(jstring, "device_pload_drate",j, cinfo);
10178  // json_out_character(jstring, '\n');
10179  json_out_1d(jstring, "device_pload_key_cnt",j, cinfo);
10180  // json_out_character(jstring, '\n');
10181  for (uint16_t k=0; k<json_get_int((char *)"device_pload_key_cnt",j, cinfo); ++k)
10182  {
10183  json_out_2d(jstring, "device_pload_key_name",j,k, cinfo);
10184  // json_out_character(jstring, '\n');
10185  }
10186  continue;
10187  }
10188 
10189  // Dump Sun sensors
10190  if (!strcmp(device_type_string[i].c_str(),"ssen"))
10191  {
10192  json_out_1d(jstring, "device_ssen_align",j, cinfo);
10193  // json_out_character(jstring, '\n');
10194  continue;
10195  }
10196 
10197  // Dump IMU's
10198  if (!strcmp(device_type_string[i].c_str(),"imu"))
10199  {
10200  json_out_1d(jstring, "device_imu_align",j, cinfo);
10201  // json_out_character(jstring, '\n');
10202  continue;
10203  }
10204 
10205  // Dump Reaction Wheel
10206  if (!strcmp(device_type_string[i].c_str(),"rw"))
10207  {
10208  json_out_1d(jstring, "device_rw_align",j, cinfo);
10209  // json_out_character(jstring, '\n');
10210  json_out_1d(jstring, "device_rw_mom",j, cinfo);
10211  // json_out_character(jstring, '\n');
10212  json_out_1d(jstring, "device_rw_mxalp",j, cinfo);
10213  // json_out_character(jstring, '\n');
10214  json_out_1d(jstring, "device_rw_mxomg",j, cinfo);
10215  // json_out_character(jstring, '\n');
10216  json_out_1d(jstring, "device_rw_tc",j, cinfo);
10217  // json_out_character(jstring, '\n');
10218  continue;
10219  }
10220 
10221  // Dump Magtorque Rods
10222  if (!strcmp(device_type_string[i].c_str(),"mtr"))
10223  {
10224  json_out_1d(jstring, "device_mtr_mxmom",j, cinfo);
10225  // json_out_character(jstring, '\n');
10226  json_out_1d(jstring, "device_mtr_align",j, cinfo);
10227  // json_out_character(jstring, '\n');
10228  for (uint16_t k=0; k<7; ++k)
10229  {
10230  json_out_2d(jstring, "device_mtr_npoly",j,k, cinfo);
10231  // json_out_character(jstring, '\n');
10232  }
10233  for (uint16_t k=0; k<7; ++k)
10234  {
10235  json_out_2d(jstring, "device_mtr_ppoly",j,k, cinfo);
10236  // json_out_character(jstring, '\n');
10237  }
10238  json_out_1d(jstring, "device_mtr_tc",j, cinfo);
10239  // json_out_character(jstring, '\n');
10240  continue;
10241  }
10242 
10243  // Dump Computer systems
10244  if (!strcmp(device_type_string[i].c_str(),"cpu"))
10245  {
10246  json_out_1d(jstring, "device_cpu_maxgib",j, cinfo);
10247  // json_out_character(jstring, '\n');
10248  json_out_1d(jstring, "device_cpu_maxload",j, cinfo);
10249  // json_out_character(jstring, '\n');
10250  continue;
10251  }
10252 
10253  // Dump GPS's
10254  if (!strcmp(device_type_string[i].c_str(),"gps"))
10255  {
10256  continue;
10257  }
10258 
10259  // Dump Antennas
10260  if (!strcmp(device_type_string[i].c_str(),"ant"))
10261  {
10262  json_out_1d(jstring, "device_ant_align",j, cinfo);
10263  // json_out_character(jstring, '\n');
10264  json_out_1d(jstring, "device_ant_minelev",j, cinfo);
10265  // json_out_character(jstring, '\n');
10266  continue;
10267  }
10268 
10269  // Dump Receivers
10270  if (!strcmp(device_type_string[i].c_str(),"rxr"))
10271  {
10272  json_out_1d(jstring, "device_rxr_opmode",j, cinfo);
10273  json_out_1d(jstring, "device_rxr_modulation",j, cinfo);
10274  json_out_1d(jstring, "device_rxr_rssi",j, cinfo);
10275  json_out_1d(jstring, "device_rxr_pktsize",j, cinfo);
10276  json_out_1d(jstring, "device_rxr_freq",j, cinfo);
10277  json_out_1d(jstring, "device_rxr_maxfreq",j, cinfo);
10278  json_out_1d(jstring, "device_rxr_minfreq",j, cinfo);
10279  json_out_1d(jstring, "device_rxr_powerin",j, cinfo);
10280  json_out_1d(jstring, "device_rxr_powerout",j, cinfo);
10281  json_out_1d(jstring, "device_rxr_maxpower",j, cinfo);
10282  json_out_1d(jstring, "device_rxr_band",j, cinfo);
10283  json_out_1d(jstring, "device_rxr_goodratio",j, cinfo);
10284  json_out_1d(jstring, "device_rxr_rxutc",j, cinfo);
10285  continue;
10286  }
10287 
10288  // Dump Transmitters
10289  if (!strcmp(device_type_string[i].c_str(),"txr"))
10290  {
10291  json_out_1d(jstring, "device_txr_opmode",j, cinfo);
10292  json_out_1d(jstring, "device_txr_modulation",j, cinfo);
10293  json_out_1d(jstring, "device_txr_rssi",j, cinfo);
10294  json_out_1d(jstring, "device_txr_pktsize",j, cinfo);
10295  json_out_1d(jstring, "device_txr_freq",j, cinfo);
10296  json_out_1d(jstring, "device_txr_maxfreq",j, cinfo);
10297  json_out_1d(jstring, "device_txr_minfreq",j, cinfo);
10298  json_out_1d(jstring, "device_txr_powerin",j, cinfo);
10299  json_out_1d(jstring, "device_txr_powerout",j, cinfo);
10300  json_out_1d(jstring, "device_txr_maxpower",j, cinfo);
10301  json_out_1d(jstring, "device_txr_band",j, cinfo);
10302  json_out_1d(jstring, "device_txr_goodratio",j, cinfo);
10303  json_out_1d(jstring, "device_txr_badcnt",j, cinfo);
10304  continue;
10305  }
10306 
10307  // Dump Transceivers
10308  if (!strcmp(device_type_string[i].c_str(),"tcv"))
10309  {
10310  json_out_1d(jstring, "device_tcv_opmode",j, cinfo);
10311  json_out_1d(jstring, "device_tcv_modulation",j, cinfo);
10312  json_out_1d(jstring, "device_tcv_rssi",j, cinfo);
10313  json_out_1d(jstring, "device_tcv_pktsize",j, cinfo);
10314  json_out_1d(jstring, "device_tcv_freq",j, cinfo);
10315  json_out_1d(jstring, "device_tcv_maxfreq",j, cinfo);
10316  json_out_1d(jstring, "device_tcv_minfreq",j, cinfo);
10317  json_out_1d(jstring, "device_tcv_powerin",j, cinfo);
10318  json_out_1d(jstring, "device_tcv_powerout",j, cinfo);
10319  json_out_1d(jstring, "device_tcv_maxpower",j, cinfo);
10320  json_out_1d(jstring, "device_tcv_band",j, cinfo);
10321  json_out_1d(jstring, "device_tcv_goodratio",j, cinfo);
10322  json_out_1d(jstring, "device_tcv_badcnt",j, cinfo);
10323  continue;
10324  }
10325 
10326  // Dump solar strings
10327  if (!strcmp(device_type_string[i].c_str(),"strg"))
10328  {
10329  json_out_1d(jstring, "device_pvstrg_efi",j, cinfo);
10330  // json_out_character(jstring, '\n');
10331  json_out_1d(jstring, "device_pvstrg_efs",j, cinfo);
10332  // json_out_character(jstring, '\n');
10333  json_out_1d(jstring, "device_pvstrg_max",j, cinfo);
10334  // json_out_character(jstring, '\n');
10335  continue;
10336  }
10337 
10338  // Dump batteries
10339  if (!strcmp(device_type_string[i].c_str(),"batt"))
10340  {
10341  json_out_1d(jstring, "device_batt_cap",j, cinfo);
10342  // json_out_character(jstring, '\n');
10343  json_out_1d(jstring, "device_batt_eff",j, cinfo);
10344  // json_out_character(jstring, '\n');
10345  continue;
10346  }
10347 
10348  // Dump Heaters
10349  if (!strcmp(device_type_string[i].c_str(),"htr"))
10350  {
10351  continue;
10352  }
10353 
10354  // Dump motors
10355  if (!strcmp(device_type_string[i].c_str(),"motr"))
10356  {
10357  json_out_1d(jstring, "device_motr_rat",j, cinfo);
10358  // json_out_character(jstring, '\n');
10359  json_out_1d(jstring, "device_motr_max",j, cinfo);
10360  // json_out_character(jstring, '\n');
10361  continue;
10362  }
10363 
10364  // Dump temperature sensor
10365  if (!strcmp(device_type_string[i].c_str(),"tsen"))
10366  {
10367  continue;
10368  }
10369 
10370  // Dump thsters
10371  if (!strcmp(device_type_string[i].c_str(),"thst"))
10372  {
10373  json_out_1d(jstring, "device_thst_isp",j, cinfo);
10374  // json_out_character(jstring, '\n');
10375  json_out_1d(jstring, "device_thst_align",j, cinfo);
10376  // json_out_character(jstring, '\n');
10377  continue;
10378  }
10379 
10380  // Dump propellant tanks
10381  if (!strcmp(device_type_string[i].c_str(),"prop"))
10382  {
10383  json_out_1d(jstring, "device_prop_cap",j, cinfo);
10384  // json_out_character(jstring, '\n');
10385  continue;
10386  }
10387 
10388  // Dump Switch info
10389  if (!strcmp(device_type_string[i].c_str(),"swch"))
10390  {
10391  continue;
10392  }
10393 
10394  // Dump Rotor info
10395  if (!strcmp(device_type_string[i].c_str(),"rot"))
10396  {
10397  continue;
10398  }
10399 
10400  // Dump STT's
10401  if (!strcmp(device_type_string[i].c_str(),"stt"))
10402  {
10403  json_out_1d(jstring, "device_stt_align",j, cinfo);
10404  // json_out_character(jstring, '\n');
10405  continue;
10406  }
10407 
10408  // Dump Motion Capture info
10409  if (!strcmp(device_type_string[i].c_str(),"mcc"))
10410  {
10411  json_out_1d(jstring, "device_mcc_align",j, cinfo);
10412  // json_out_character(jstring, '\n');
10413  continue;
10414  }
10415 
10416  // Dump Torque Rod Control Unit info
10417  if (!strcmp(device_type_string[i].c_str(),"tcu"))
10418  {
10419  json_out_1d(jstring, "device_tcu_mcnt",j, cinfo);
10420  // json_out_character(jstring, '\n');
10421  for (uint16_t k=0; k<json_get_int((char *)"device_tcu_mcnt",j, cinfo); ++k)
10422  {
10423  json_out_2d(jstring, "device_tcu_mcidx",j,k, cinfo);
10424  // json_out_character(jstring, '\n');
10425  }
10426  continue;
10427  }
10428 
10429  // Dump power bus
10430  if (!strcmp(device_type_string[i].c_str(),"bus"))
10431  {
10432  continue;
10433  }
10434 
10435  // Dump pressure sensor
10436  if (!strcmp(device_type_string[i].c_str(),"psen"))
10437  {
10438  continue;
10439  }
10440 
10441  // Dump SUCHI
10442  if (!strcmp(device_type_string[i].c_str(),"suchi"))
10443  {
10444  json_out_1d(jstring, "device_suchi_align",j, cinfo);
10445  // json_out_character(jstring, '\n');
10446  continue;
10447  }
10448 
10449  // Dump Cameras
10450  if (!strcmp(device_type_string[i].c_str(),"cam"))
10451  {
10452  json_out_1d(jstring, "device_cam_pwidth",j, cinfo);
10453  // json_out_character(jstring, '\n');
10454  json_out_1d(jstring, "device_cam_pheight",j, cinfo);
10455  // json_out_character(jstring, '\n');
10456  json_out_1d(jstring, "device_cam_width",j, cinfo);
10457  // json_out_character(jstring, '\n');
10458  json_out_1d(jstring, "device_cam_height",j, cinfo);
10459  // json_out_character(jstring, '\n');
10460  json_out_1d(jstring, "device_cam_flength",j, cinfo);
10461  // json_out_character(jstring, '\n');
10462  continue;
10463  }
10464 
10465  // Dump Telemetry
10466  if (!strcmp(device_type_string[i].c_str(),"telem"))
10467  {
10468  json_out_1d(jstring, "device_telem_type",j, cinfo);
10469  // json_out_character(jstring, '\n');
10470  switch (json_get_int((char *)"device_telem_type",j, cinfo))
10471  {
10472  case TELEM_TYPE_UINT8:
10473  json_out_1d(jstring, "device_telem_vuint8",j, cinfo);
10474  // json_out_character(jstring, '\n');
10475  break;
10476  case TELEM_TYPE_INT8:
10477  json_out_1d(jstring, "device_telem_vint8",j, cinfo);
10478  // json_out_character(jstring, '\n');
10479  break;
10480  case TELEM_TYPE_UINT16:
10481  json_out_1d(jstring, "device_telem_vuint16",j, cinfo);
10482  // json_out_character(jstring, '\n');
10483  break;
10484  case TELEM_TYPE_INT16:
10485  json_out_1d(jstring, "device_telem_vint16",j, cinfo);
10486  // json_out_character(jstring, '\n');
10487  break;
10488  case TELEM_TYPE_UINT32:
10489  json_out_1d(jstring, "device_telem_vuint32",j, cinfo);
10490  // json_out_character(jstring, '\n');
10491  break;
10492  case TELEM_TYPE_INT32:
10493  json_out_1d(jstring, "device_telem_vint32",j, cinfo);
10494  // json_out_character(jstring, '\n');
10495  break;
10496  case TELEM_TYPE_FLOAT:
10497  json_out_1d(jstring, "device_telem_vfloat",j, cinfo);
10498  // json_out_character(jstring, '\n');
10499  break;
10500  case TELEM_TYPE_DOUBLE:
10501  json_out_1d(jstring, "device_telem_vdouble",j, cinfo);
10502  // json_out_character(jstring, '\n');
10503  break;
10504  case TELEM_TYPE_STRING:
10505  json_out_1d(jstring, "device_telem_vstring",j, cinfo);
10506  // json_out_character(jstring, '\n');
10507  break;
10508  }
10509  continue;
10510  }
10511 
10512  // Dump Disks
10513  if (!strcmp(device_type_string[i].c_str(),"disk"))
10514  {
10515  json_out_1d(jstring, "device_disk_maxgib",j, cinfo);
10516  // json_out_character(jstring, '\n');
10517  continue;
10518  }
10519 
10520  }
10521  }
10522  }
10523 
10524  return jstring.data();
10525 }
int32_t json_out_1d(string &jstring, const char *token, uint16_t index, cosmosstruc *cinfo)
Perform JSON output for a single element of a 1D named JSON item.
Definition: jsonlib.cpp:2855
static vector< string > device_type_string
Definition: jsonlib.cpp:47
int i
Definition: rw_test.cpp:37
Definition: jsondef.h:607
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
uint8_t * json_ptrto(string token, cosmosstruc *cinfo)
Return the data pointer that matches a JSON name.
Definition: jsonlib.cpp:3283
Definition: jsondef.h:606
Definition: jsondef.h:612
List count.
Definition: jsondef.h:554
Definition: jsondef.h:605
Definition: jsondef.h:604
Definition: jsondef.h:608
int32_t json_get_int(jsonhandle &handle, cosmosstruc *cinfo)
Return integer from handle.
Definition: jsonlib.cpp:3360
Definition: jsondef.h:611
int32_t json_out_2d(string &jstring, const char *token, uint16_t row, uint16_t col, cosmosstruc *cinfo)
Perform JSON output for a single element of a 2D named JSON item.
Definition: jsonlib.cpp:2881
Definition: jsondef.h:610
Definition: jsondef.h:609
const char * json_ports ( string &  jstring,
cosmosstruc cinfo 
)

Dump Port description.

Create a JSON stream for the Port information of the Node. Does not include any derivative data (eg. area).

Parameters
jstringReference to a string to build the JSON stream in.
cinfoReference to cosmosstruc to use.
Returns
Pointer to the created JSON stream.
10537 {
10538 
10539  jstring.clear();
10540  // Dump Port table
10541  for (uint16_t i=0; i<*(int16_t *)json_ptrto((char *)"node_port_cnt", cinfo); i++)
10542  {
10543  json_out_1d(jstring, "port_name",i, cinfo);
10544  // json_out_character(jstring, '\n');
10545  json_out_1d(jstring, "port_type",i, cinfo);
10546  // json_out_character(jstring, '\n');
10547  }
10548 
10549  return jstring.data();
10550 }
int32_t json_out_1d(string &jstring, const char *token, uint16_t index, cosmosstruc *cinfo)
Perform JSON output for a single element of a 1D named JSON item.
Definition: jsonlib.cpp:2855
int i
Definition: rw_test.cpp:37
uint8_t * json_ptrto(string token, cosmosstruc *cinfo)
Return the data pointer that matches a JSON name.
Definition: jsonlib.cpp:3283
void json_test ( cosmosstruc cinfo)
10553 {
10554  uint16_t i, j;
10555  long hash;
10556 
10557  int32_t hashcount[1480]= {0};
10558 
10559  for (i=0; i<cinfo->jmap.size(); ++i)
10560  {
10561  for (j=0; j<cinfo->jmap[i].size(); ++j)
10562  {
10563  hash = json_hash(cinfo->jmap[i][j].name);
10564 
10565  printf("%s %d %d %ld\n", cinfo->jmap[i][j].name.c_str(),i,j,hash);
10566 
10567  hashcount[hash]++;
10568  }
10569 
10570  }
10571 }
int i
Definition: rw_test.cpp:37
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
uint16_t json_hash(string hstring)
Calculate JSON HASH.
Definition: jsonlib.cpp:504
int32_t json_name_map ( string  name,
cosmosstruc cinfo,
jsonhandle handle 
)

Get hash and index in JSON Namespace map.

Using the provided name, find it's location in the provided Namespace map and set the values for the hash and index.

Parameters
nameNamespace name.
handlePointer to jsonhandle of name.
Returns
Zero, or negative error number.
10582 {
10583 
10584  if (!cinfo->jmapped)
10585  return (JSON_ERROR_NOJMAP);
10586 
10587  if (cinfo->jmap.size() == 0)
10588  return (JSON_ERROR_NOJMAP);
10589 
10590  handle.hash = json_hash(name);
10591 
10592  for (handle.index=0; handle.index<cinfo->jmap[handle.hash].size(); ++handle.index)
10593  if (name == cinfo->jmap[handle.hash][handle.index].name)
10594  {
10595  return 0;
10596  }
10597 
10598  return (JSON_ERROR_NOENTRY);
10599 }
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
#define JSON_ERROR_NOJMAP
Definition: cosmos-errno.h:93
#define JSON_ERROR_NOENTRY
Definition: cosmos-errno.h:94
uint16_t hash
Definition: jsondef.h:794
string name
Definition: cubesat2obj.cpp:6
uint16_t index
Definition: jsondef.h:796
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
uint16_t json_hash(string hstring)
Calculate JSON HASH.
Definition: jsonlib.cpp:504
int32_t json_equation_map ( string  equation,
cosmosstruc cinfo,
jsonhandle handle 
)

Get hash and index in JSON Equation map.

Using the provided text, find it's location in the provided Equation map and set the values for the hash and index. If the equation is not already in the table, add it.

Parameters
equationEquation text.
handlePointer to jsonhandle of name.
Returns
Zero, or negative error number.
10610 {
10611  const char *pointer;
10612  jsonequation tequation;
10613  char ops[] = "+-*/%&|><=!~^@#";
10614  int32_t iretn;
10615  size_t textlen;
10616 
10617  if (!cinfo->jmapped)
10618  return (JSON_ERROR_NOJMAP);
10619 
10620  if (cinfo->emap.size() == 0)
10621  return (JSON_ERROR_NOJMAP);
10622 
10623  // Equations must start and end with ')'
10624  if (equation[0] != '(' || equation[equation.length()-1] != ')')
10625  {
10626  return (JSON_ERROR_SCAN);
10627  }
10628 
10629  handle->hash = json_hash(equation);
10630 
10631  for (handle->index=0; handle->index<cinfo->emap[handle->hash].size(); ++handle->index)
10632  {
10633  if (!strcmp(equation.c_str(), cinfo->emap[handle->hash][handle->index].text))
10634  {
10635  return 0;
10636  }
10637  }
10638 
10639  // Not found. We will have to add it to the map.
10640  pointer = &equation[1];
10641 
10642  // Extract first operand
10643  if ((iretn=json_parse_operand(pointer, &tequation.operand[0], cinfo)) < 0)
10644  {
10645  return (JSON_ERROR_SCAN);
10646  }
10647 
10648  // Extract operation
10649  json_skip_white(pointer);
10650  for (tequation.operation=0; tequation.operation<(int)strlen(ops); tequation.operation++)
10651  {
10652  if ((pointer)[0] == ops[tequation.operation])
10653  break;
10654  }
10655  if (tequation.operation == (int)strlen(ops))
10656  return (JSON_ERROR_SCAN);
10657  (pointer)++;
10658 
10659  // Extract second argument
10660  if ((iretn=json_parse_operand(pointer, &tequation.operand[1], cinfo)) < 0)
10661  {
10662  return (JSON_ERROR_SCAN);
10663  }
10664 
10665  // Remove trailing )
10666  while ((pointer)[0] != 0 && (pointer)[0] != ')')
10667  (pointer)++;
10668  if ((pointer)[0] != 0)
10669  (pointer)++;
10670 
10671  textlen = equation.size()+1;
10672  if ((tequation.text = (char *)calloc(1,textlen)) == nullptr)
10673  {
10674  return (JSON_ERROR_SCAN);
10675  }
10676 
10677  // Populate the equation
10678  strcpy(tequation.text,equation.c_str());
10679 
10680  handle->index = (uint16_t)cinfo->emap[handle->hash].size();
10681  cinfo->emap[handle->hash].push_back(tequation);
10682  if (cinfo->emap[handle->hash].size() != handle->index+1u)
10683  {
10684  free(tequation.text);
10685  return (JSON_ERROR_SCAN);
10686  }
10687 
10688  return 0;
10689 
10690 }
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
int32_t json_parse_operand(const char *&ptr, jsonoperand *operand, cosmosstruc *cinfo)
Parse the next JSON equation operand out of a JSON stream.
Definition: jsonlib.cpp:5120
#define JSON_ERROR_NOJMAP
Definition: cosmos-errno.h:93
int iretn
Definition: rw_test.cpp:37
jsonoperand operand[2]
JSON equation operands.
Definition: jsondef.h:874
vector< vector< jsonequation > > emap
JSON Equation Map matrix.
Definition: jsondef.h:4211
uint16_t hash
Definition: jsondef.h:794
int32_t json_skip_white(const char *&ptr)
Skip white space in JSON string.
Definition: jsonlib.cpp:5336
JSON equation entry.
Definition: jsondef.h:865
char * text
JSON equation text.
Definition: jsondef.h:868
#define JSON_ERROR_SCAN
Definition: cosmos-errno.h:96
uint16_t index
Definition: jsondef.h:796
uint16_t operation
JSON equation operation.
Definition: jsondef.h:872
uint16_t json_hash(string hstring)
Calculate JSON HASH.
Definition: jsonlib.cpp:504
int32_t json_clone ( cosmosstruc cinfo1,
cosmosstruc cinfo2 
)

Clone cosmosstruc data areas, direct.

Copy one cosmosstruc to another.

Parameters
cinfo1Source cosmosstruc.
cinfo2Target cosmosstruc.
Returns
Zero, or negative error.
10699 {
10700  // int32_t iretn;
10701  *cinfo2 = *cinfo1;
10702  // iretn = json_repoint(cinfo2);
10703  for (uint16_t i=0; i<cinfo2->node.device_cnt; ++i)
10704  {
10705  switch(static_cast <DeviceType>(cinfo2->device[i].type))
10706  {
10707  case DeviceType::TELEM:
10708  cinfo2->devspec.telem[cinfo2->device[i].didx] = i;
10709  break;
10710  case DeviceType::PLOAD:
10711  cinfo2->devspec.pload[cinfo2->device[i].didx] = i;
10712  break;
10713  case DeviceType::SSEN:
10714  cinfo2->devspec.ssen[cinfo2->device[i].didx] = i;
10715  break;
10716  case DeviceType::IMU:
10717  cinfo2->devspec.imu[cinfo2->device[i].didx] = i;
10718  break;
10719  case DeviceType::RW:
10720  cinfo2->devspec.rw[cinfo2->device[i].didx] = i;
10721  break;
10722  case DeviceType::MTR:
10723  cinfo2->devspec.mtr[cinfo2->device[i].didx] = i;
10724  break;
10725  case DeviceType::CAM:
10726  cinfo2->devspec.cam[cinfo2->device[i].didx] = i;
10727  break;
10728  case DeviceType::CPU:
10729  cinfo2->devspec.cpu[cinfo2->device[i].didx] = i;
10730  break;
10731  case DeviceType::GPS:
10732  cinfo2->devspec.gps[cinfo2->device[i].didx] = i;
10733  break;
10734  case DeviceType::ANT:
10735  cinfo2->devspec.ant[cinfo2->device[i].didx] = i;
10736  break;
10737  case DeviceType::RXR:
10738  cinfo2->devspec.rxr[cinfo2->device[i].didx] = i;
10739  break;
10740  case DeviceType::TXR:
10741  cinfo2->devspec.txr[cinfo2->device[i].didx] = i;
10742  break;
10743  case DeviceType::TCV:
10744  cinfo2->devspec.tcv[cinfo2->device[i].didx] = i;
10745  break;
10746  case DeviceType::PVSTRG:
10747  cinfo2->devspec.pvstrg[cinfo2->device[i].didx] = i;
10748  break;
10749  case DeviceType::BATT:
10750  cinfo2->devspec.batt[cinfo2->device[i].didx] = i;
10751  break;
10752  case DeviceType::HTR:
10753  cinfo2->devspec.htr[cinfo2->device[i].didx] = i;
10754  break;
10755  case DeviceType::MOTR:
10756  cinfo2->devspec.motr[cinfo2->device[i].didx] = i;
10757  break;
10758  case DeviceType::PSEN:
10759  cinfo2->devspec.psen[cinfo2->device[i].didx] = i;
10760  break;
10761  case DeviceType::TSEN:
10762  cinfo2->devspec.tsen[cinfo2->device[i].didx] = i;
10763  break;
10764  case DeviceType::THST:
10765  cinfo2->devspec.thst[cinfo2->device[i].didx] = i;
10766  break;
10767  case DeviceType::PROP:
10768  cinfo2->devspec.prop[cinfo2->device[i].didx] = i;
10769  break;
10770  case DeviceType::SWCH:
10771  cinfo2->devspec.swch[cinfo2->device[i].didx] = i;
10772  break;
10773  case DeviceType::ROT:
10774  cinfo2->devspec.rot[cinfo2->device[i].didx] = i;
10775  break;
10776  case DeviceType::STT:
10777  cinfo2->devspec.stt[cinfo2->device[i].didx] = i;
10778  break;
10779  case DeviceType::MCC:
10780  cinfo2->devspec.mcc[cinfo2->device[i].didx] = i;
10781  break;
10782  case DeviceType::TCU:
10783  cinfo2->devspec.tcu[cinfo2->device[i].didx] = i;
10784  break;
10785  case DeviceType::BUS:
10786  cinfo2->devspec.bus[cinfo2->device[i].didx] = i;
10787  break;
10788  case DeviceType::SUCHI:
10789  cinfo2->devspec.suchi[cinfo2->device[i].didx] = i;
10790  break;
10791  case DeviceType::DISK:
10792  cinfo2->devspec.disk[cinfo2->device[i].didx] = i;
10793  break;
10794  case DeviceType::TNC:
10795  cinfo2->devspec.tnc[cinfo2->device[i].didx] = i;
10796  break;
10797  case DeviceType::BCREG:
10798  cinfo2->devspec.bcreg[cinfo2->device[i].didx] = i;
10799  break;
10800  case DeviceType::COUNT:
10801  case DeviceType::NONE:
10802  break;
10803  }
10804  }
10805 
10806 
10807  return 0;
10808 }
Radio Receiver.
Definition: jsondef.h:508
Magnetic Torque Rod.
Definition: jsondef.h:500
Photo Voltaic String.
Definition: jsondef.h:514
vector< uint16_t > mtr
Definition: jsondef.h:3907
vector< uint16_t > stt
Definition: jsondef.h:3916
uint16_t device_cnt
Definition: jsondef.h:3571
vector< uint16_t > prop
Definition: jsondef.h:3909
vector< uint16_t > bus
Definition: jsondef.h:3898
Reaction Wheel.
Definition: jsondef.h:498
Heater.
Definition: jsondef.h:518
vector< uint16_t > gps
Definition: jsondef.h:3902
vector< uint16_t > rxr
Definition: jsondef.h:3914
int i
Definition: rw_test.cpp:37
Motor.
Definition: jsondef.h:520
Telemetry.
Definition: jsondef.h:546
Elevation and Azimuth Sun Sensor.
Definition: jsondef.h:494
Not a Component.
Definition: jsondef.h:556
BCREG.
Definition: jsondef.h:552
vector< uint16_t > htr
Definition: jsondef.h:3903
vector< uint16_t > imu
Definition: jsondef.h:3904
Rotor.
Definition: jsondef.h:530
vector< uint16_t > ant
Definition: jsondef.h:3895
vector< uint16_t > rw
Definition: jsondef.h:3913
vector< uint16_t > txr
Definition: jsondef.h:3925
vector< uint16_t > pload
Definition: jsondef.h:3908
vector< uint16_t > tcu
Definition: jsondef.h:3919
vector< devicestruc > device
Vector of all general (common) information for devices (components) in node.
Definition: jsondef.h:4238
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
vector< uint16_t > suchi
Definition: jsondef.h:3917
Radio Transceiver.
Definition: jsondef.h:512
List count.
Definition: jsondef.h:554
vector< uint16_t > rot
Definition: jsondef.h:3912
Thruster.
Definition: jsondef.h:524
vector< uint16_t > tcv
Definition: jsondef.h:3920
vector< uint16_t > disk
Definition: jsondef.h:3901
Payload.
Definition: jsondef.h:492
vector< uint16_t > motr
Definition: jsondef.h:3906
SUCHI.
Definition: jsondef.h:542
vector< uint16_t > cam
Definition: jsondef.h:3899
vector< uint16_t > thst
Definition: jsondef.h:3922
Camera.
Definition: jsondef.h:544
vector< uint16_t > telem
Definition: jsondef.h:3921
Pressure sensor.
Definition: jsondef.h:540
vector< uint16_t > tsen
Definition: jsondef.h:3924
Power Bus.
Definition: jsondef.h:538
Propellant Tank.
Definition: jsondef.h:526
vector< uint16_t > cpu
Definition: jsondef.h:3900
vector< uint16_t > bcreg
Definition: jsondef.h:3897
GPS Unit.
Definition: jsondef.h:504
Processing Unit.
Definition: jsondef.h:502
Antenna.
Definition: jsondef.h:506
vector< uint16_t > tnc
Definition: jsondef.h:3923
Battery.
Definition: jsondef.h:516
Star Tracker.
Definition: jsondef.h:532
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
TNC.
Definition: jsondef.h:550
vector< uint16_t > swch
Definition: jsondef.h:3918
Torque rod Control Unit.
Definition: jsondef.h:536
Disk Drive.
Definition: jsondef.h:548
vector< uint16_t > psen
Definition: jsondef.h:3910
Radio Transmitter.
Definition: jsondef.h:510
Inertial Measurement Unit.
Definition: jsondef.h:496
Switch.
Definition: jsondef.h:528
vector< uint16_t > batt
Definition: jsondef.h:3896
vector< uint16_t > pvstrg
Definition: jsondef.h:3911
Temperature Sensor.
Definition: jsondef.h:522
vector< uint16_t > mcc
Definition: jsondef.h:3905
Motion Capture Camera.
Definition: jsondef.h:534
vector< uint16_t > ssen
Definition: jsondef.h:3915
uint32_t json_get_name_list_count ( cosmosstruc cinfo)
10811 {
10812  if (cinfo->jmapped == false) return 0;
10813 
10814  uint32_t count = 0;
10815  for (uint32_t i = 0; i < cinfo->jmap.size(); i++)
10816  {
10817  for (uint32_t j = 0; j < cinfo->jmap[i].size(); j++)
10818  {
10819  ++count;
10820  }
10821  }
10822  return count;
10823 }
uint16_t jmapped
Whether JSON map has been created.
Definition: jsondef.h:4205
int i
Definition: rw_test.cpp:37
int count
Definition: rw_test.cpp:36
vector< vector< jsonentry > > jmap
JSON Namespace Map matrix. first entry hash, second is items with that hash.
Definition: jsondef.h:4208
int32_t node_init ( string  node,
cosmosstruc cinfo 
)

Initialize Node configuration.

Load initial Node configuration file. Then calculate all derivative values (eg. COM)

Parameters
nodeNode to be initialized using node.ini. Node must be a directory in nodedir. If NULL, node.ini must be in current directory.
cinfoReference to cosmosstruc to use.
Returns
0, or negative error.

Load targeting information

10833 {
10834  int32_t iretn;
10835 
10836  if (cinfo == nullptr)
10837  return (JSON_ERROR_NOJMAP);
10838 
10839  iretn = json_setup_node(node, cinfo);
10840  if (iretn < 0)
10841  {
10842  return iretn;
10843  }
10844 
10845  node_calc(cinfo);
10846 
10848  cinfo->node.target_cnt = (uint16_t)load_target(cinfo);
10849 
10850  return 0;
10851 }
int32_t load_target(cosmosstruc *cinfo)
Load Track list.
Definition: jsonlib.cpp:11208
uint16_t target_cnt
Definition: jsondef.h:3575
#define JSON_ERROR_NOJMAP
Definition: cosmos-errno.h:93
int32_t json_setup_node(jsonnode json, cosmosstruc *cinfo, bool create_flag)
Setup JSON Namespace using Node description JSON.
Definition: jsonlib.cpp:6869
int iretn
Definition: rw_test.cpp:37
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
int32_t node_calc(cosmosstruc *cinfo)
Calculate Satellite configuration values.
Definition: jsonlib.cpp:10859
static string node
Definition: agent_monitor.cpp:126
int32_t node_calc ( cosmosstruc cinfo)

Calculate Satellite configuration values.

Using the provided satellite structure, populate the derivative static quantities and initialize any reasonable dynamic quantities.

Parameters
cinfoReference to cosmosstruc to use.
Returns
0
10860 {
10861  // uint16_t n, i, j, k;
10862  // double dm, ta, tb, tc;
10863  // rvector tv0, tv1, tv2, tv3, dv, sv;
10864 
10865  cinfo->node.phys.hcap = cinfo->node.phys.heat = 0.;
10866  cinfo->node.phys.mass = 0.;
10867  cinfo->node.phys.moi = rv_zero();
10868  cinfo->node.phys.com = rv_zero();
10869 
10870  json_recenter_node(cinfo);
10871 
10872  for (size_t n=0; n<cinfo->pieces.size(); n++)
10873  {
10874  cinfo->pieces[n].mass = cinfo->pieces[n].volume * cinfo->pieces[n].density;
10875  if (cinfo->pieces[n].mass == 0.)
10876  cinfo->pieces[n].mass = .001f;
10877 // cinfo->pieces[n].temp = 300.;
10878  cinfo->pieces[n].heat = cinfo->pieces[n].temp * cinfo->pieces[n].hcap;
10879  cinfo->node.phys.heat += cinfo->pieces[n].heat;
10880  cinfo->node.phys.mass += cinfo->pieces[n].mass;
10881  cinfo->node.phys.hcap += cinfo->pieces[n].hcap * cinfo->pieces[n].mass;
10882 
10883  }
10884 
10885  if (cinfo->node.phys.mass == 0.)
10886  {
10887  cinfo->node.phys.mass = 1.;
10888  }
10889 
10890  // Turn on power buses
10891  for (size_t n=0; n<cinfo->devspec.bus_cnt; n++)
10892  {
10893  cinfo->device[cinfo->devspec.bus[n]].flag |= DEVICE_FLAG_ON;
10894  }
10895 
10896 
10897  for (size_t n=0; n<cinfo->node.device_cnt; n++)
10898  {
10899  /*
10900  if (cinfo->device[n].pidx >= 0)
10901  {
10902  cinfo->node.com.col[0] += cinfo->pieces[cinfo->device[n].pidx].centroid.col[0] * cinfo->device[n].mass;
10903  cinfo->node.com.col[1] += cinfo->pieces[cinfo->device[n].pidx].centroid.col[1] * cinfo->device[n].mass;
10904  cinfo->node.com.col[2] += cinfo->pieces[cinfo->device[n].pidx].centroid.col[2] * cinfo->device[n].mass;
10905  }
10906  if (cinfo->device[n].pidx >= 0)
10907  {
10908  cinfo->pieces[cinfo->device[n].pidx].heat += 300. * cinfo->pieces[cinfo->device[n].pidx].hcap * cinfo->device[n].mass;
10909  cinfo->node.heat += 300. * cinfo->pieces[cinfo->device[n].pidx].hcap * cinfo->device[n].mass;
10910  }
10911  cinfo->node.mass += cinfo->device[n].mass;
10912  */
10913 // cinfo->device[n].temp = 300.;
10914  // cinfo->device[n].flag |= DEVICE_FLAG_ON;
10915  if (cinfo->device[n].flag & DEVICE_FLAG_ON)
10916  {
10917  cinfo->device[n].amp = cinfo->device[n].namp;
10918  cinfo->device[n].volt = cinfo->device[n].nvolt;
10919  cinfo->device[n].power = cinfo->device[n].amp * cinfo->device[n].volt;
10920  }
10921  if (cinfo->device[n].bidx < cinfo->devspec.bus_cnt && cinfo->device[cinfo->devspec.bus[cinfo->device[n].bidx]].volt < cinfo->device[n].volt)
10922  {
10923  cinfo->device[cinfo->devspec.bus[cinfo->device[n].bidx]].volt = cinfo->device[n].volt;
10924  }
10925  }
10926 
10927  // cinfo->node.phys.com = rv_smult(1./cinfo->node.phys.mass,cinfo->node.phys.com);
10928  cinfo->node.phys.hcap /= cinfo->node.phys.mass;
10929 
10930  for (size_t n=0; n<cinfo->pieces.size(); n++)
10931  {
10932  piecestruc *tpiece = &cinfo->pieces[n];
10933  tpiece->shove = Vector();
10934  tpiece->twist = Vector();
10935  switch (cinfo->pieces[n].face_cnt)
10936  {
10937  default:
10938  {
10939  double ta = tpiece->com.flattenx().norm();
10940  cinfo->node.phys.moi.x += tpiece->mass * ta * ta;
10941  ta = tpiece->com.flatteny().norm();
10942  cinfo->node.phys.moi.y += tpiece->mass * ta * ta;
10943  ta = tpiece->com.flattenz().norm();
10944  cinfo->node.phys.moi.z += tpiece->mass * ta * ta;
10945  }
10946  break;
10947  case 1:
10948  {
10949  tpiece->shove = -tpiece->area * (cinfo->faces[tpiece->face_idx[0]].normal.dot(tpiece->com)) * tpiece->com / (tpiece->com.norm() * tpiece->com.norm());
10950  tpiece->twist = -tpiece->area * tpiece->com.norm() * cinfo->faces[tpiece->face_idx[0]].normal - tpiece->com.norm() * tpiece->shove;
10951  }
10952  break;
10953  case 0:
10954  break;
10955  }
10956  }
10957 
10958  if (cinfo->node.phys.moi.norm() == 0.)
10959  {
10960  cinfo->node.phys.moi.clear(1.,1.,1.);
10961  }
10962 
10963  // Turn all CPU's on
10964  for (size_t n=0; n<cinfo->devspec.cpu_cnt; n++)
10965  {
10966  cinfo->device[cinfo->device[cinfo->devspec.cpu[n]].cidx].flag |= DEVICE_FLAG_ON;
10967  }
10968 
10969  // Turn on all IMU's
10970  for (size_t n=0; n<cinfo->devspec.imu_cnt; n++)
10971  {
10972  cinfo->device[cinfo->device[cinfo->devspec.imu[n]].cidx].flag |= DEVICE_FLAG_ON;
10973  }
10974 
10975  // Turn on all GPS's
10976  for (size_t n=0; n<cinfo->devspec.gps_cnt; n++)
10977  {
10978  cinfo->device[cinfo->device[cinfo->devspec.gps[n]].cidx].flag |= DEVICE_FLAG_ON;
10979  }
10980 
10981  cinfo->node.phys.battcap = 0.;
10982  for (size_t n=0; n<cinfo->devspec.batt_cnt; n++)
10983  {
10984  cinfo->node.phys.battcap += cinfo->device[cinfo->devspec.batt[n]].batt.capacity;
10985  cinfo->device[cinfo->devspec.batt[n]].batt.charge = cinfo->device[cinfo->devspec.batt[n]].batt.capacity;
10986  }
10987  cinfo->node.phys.battlev = cinfo->node.phys.battcap;
10988 
10989  // Turn off reaction wheels
10990  for (size_t i=0; i<cinfo->devspec.rw_cnt; i++)
10991  {
10992  cinfo->device[cinfo->devspec.rw[i]].rw.alp = cinfo->device[cinfo->devspec.rw[i]].rw.omg = 0.;
10993  }
10994 
10995  // Set fictional torque to zero
10996  cinfo->node.phys.ftorque = rv_zero();
10997 
10998  return 0;
10999 }
Vector moi
Definition: jsondef.h:3448
uint16_t imu_cnt
Definition: jsondef.h:3871
vector< facestruc > faces
Vector of all faces in node.
Definition: jsondef.h:4229
uint16_t device_cnt
Definition: jsondef.h:3571
Definition: eci2kep_test.cpp:33
int32_t json_recenter_node(cosmosstruc *cinfo)
Definition: jsonlib.cpp:6545
Vector & clear(double x0=0., double y0=0., double z0=0., double w0=0.)
Clear.
Definition: vector.cpp:1693
Vector com
Definition: jsondef.h:3449
vector< uint16_t > bus
Definition: jsondef.h:3898
vector< uint16_t > gps
Definition: jsondef.h:3902
double norm()
Norm.
Definition: vector.cpp:1735
int i
Definition: rw_test.cpp:37
float battcap
Definition: jsondef.h:3430
float battlev
Definition: jsondef.h:3431
double y
Definition: vector.h:713
Vector ftorque
Definition: jsondef.h:3437
vector< uint16_t > imu
Definition: jsondef.h:3904
Part structure: physical information for each piece of Node.
Definition: jsondef.h:1446
vector< uint16_t > rw
Definition: jsondef.h:3913
#define DEVICE_FLAG_ON
Definition: jsondef.h:634
Vector flattenz()
Definition: vector.cpp:2055
vector< devicestruc > device
Vector of all general (common) information for devices (components) in node.
Definition: jsondef.h:4238
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
double z
Definition: vector.h:714
float hcap
Definition: jsondef.h:3424
uint16_t gps_cnt
Definition: jsondef.h:3869
Vector flatteny()
Definition: vector.cpp:2048
uint16_t batt_cnt
Definition: jsondef.h:3864
uint16_t bus_cnt
Definition: jsondef.h:3865
double x
Definition: vector.h:712
uint16_t cpu_cnt
Definition: jsondef.h:3867
Vector com
Centroid of piece.
Definition: jsondef.h:1477
uint16_t rw_cnt
Definition: jsondef.h:3880
float area
Area in square meters.
Definition: jsondef.h:1469
rvector rv_zero()
Zero row order vector.
Definition: vector.cpp:107
float heat
Definition: jsondef.h:3427
vector< uint16_t > cpu
Definition: jsondef.h:3900
float mass
Definition: jsondef.h:3425
Vector flattenx()
Definition: vector.cpp:2041
Vector shove
Contribution of piece to linear forces.
Definition: jsondef.h:1479
vector< piecestruc > pieces
Vector of all pieces in node.
Definition: jsondef.h:4232
float mass
Mass in kg.
Definition: jsondef.h:1457
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
Vector Class.
Definition: vector.h:672
vector< uint16_t > face_idx
Array of vertices/vertexs.
Definition: jsondef.h:1475
vector< uint16_t > batt
Definition: jsondef.h:3896
Vector twist
Contribution of piece to angular forces.
Definition: jsondef.h:1481
physicsstruc phys
Definition: jsondef.h:3597
void create_databases ( cosmosstruc cinfo)

Dump tab delimited database files.

Create files that can be read in to a relational database representing the various elements of the satellite. Tables are created for Parts, Components, Devices, Temperature Sensors and Power Buses.

11007 {
11008  FILE *op;
11009  uint32_t i, j;
11010  piecestruc s;
11011  allstruc cs;
11012  rwstruc rws;
11013  imustruc ims;
11014  sttstruc sts;
11015  int32_t iretn;
11016 
11017  /*
11018  * op = fopen("target.txt","w");
11019  fprintf(op,"gs_idx gs_name gs_pos_lat gs_pos_lon gs_pos_alt gs_min gs_az gs_el\n");
11020  for (i=0; i<cinfo->node.target_cnt; i++)
11021  {
11022  fprintf(op,"%d\t%s\t%u\n",i,cinfo->target[i].name,cinfo->target[i].type);
11023  }
11024  fclose(op);
11025 */
11026 
11027  // op = fopen("piece.txt","w");
11028  // fprintf(op,"PartIndex\tName\tType\tTemperatureIndex\tComponentIndex\tMass\tEmissivity\tAbsorptivity\tDimension\tHeatCapacity\tHeatConductivity\tArea\tTemp\tHeat\tPointCount\tPoint1X\tPoint1Y\tPoint1Z\tPoint2X\tPoint2Y\tPoint2Z\tPoint3X\tPoint3Y\tPoint3Z\tPoint4X\tPoint4Y\tPoint4Z\tPoint5X\tPoint5Y\tPoint5Z\tPoint6X\tPoint6Y\tPoint6Z\tPoint7X\tPoint7Y\tPoint7Z\tPoint8X\tPoint8Y\tPoint8Z\n");
11029  // for (i=0; i<cinfo->pieces.size(); i++)
11030  // {
11031  // s = cinfo->pieces[i];
11032  // fprintf(op,"%d\t%s\t%d\t%d\t%.4f\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\t%.6f\t%u",i,s.name,s.type,s.cidx,s.mass,s.emi,s.abs,s.dim,s.hcap,s.hcon,s.area,s.pnt_cnt);
11033  // for (j=0; j<s.face_cnt; j++)
11034  // {
11035  // fprintf(op,"\t%.6f\t%.6f\t%.6f",s.vertex_idx[j].col[0],s.vertex_idx[j].col[1],s.vertex_idx[j].col[2]);
11036  // }
11037  // fprintf(op,"\n");
11038  // }
11039  // fclose(op);
11040 
11041  op = fopen("comp.txt","w");
11042  fprintf(op,"device_all_idx\tdevice_all_type\tdevice_all_didx\tdevice_all_pidx\tdevice_all_bidx\tdevice_all_namp\tdevice_all_nvolt\tdevice_all_amp\tdevice_all_volt\tdevice_all_temp\tdevice_all_on\n");
11043  for (i=0; i<cinfo->node.device_cnt; i++)
11044  {
11045  cs = cinfo->device[i];
11046  fprintf(op,"%d\t%d\t%d\t%d\t%d\t%.15g\t%.15g\n",i,cs.type,cs.didx,cs.pidx,cs.bidx,cs.amp,cs.volt);
11047  }
11048  fclose(op);
11049 
11050  op = fopen("rw.txt","w");
11051  fprintf(op,"DeviceIndex\tComponentIndex\tAlignmentQx\tAlignmentQy\tAlignmentQz\tAlignmentQw\tMomentX\tMomentY\tMomentZ\tMaxAngularSpeed\tAngularSpeed\tAngularAcceleration\n");
11052  for (i=0; i<cinfo->devspec.rw_cnt; i++)
11053  {
11054  rws = cinfo->device[cinfo->devspec.rw[i]].rw;
11055  devicestruc d = cinfo->device[cinfo->devspec.rw[i]];
11056  fprintf(op,"%d\t%d\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\n",i,d.cidx,rws.align.d.x,rws.align.d.y,rws.align.d.z,rws.align.w,rws.mom.col[0],rws.mom.col[1],rws.mom.col[2],rws.mxomg,rws.mxalp);
11057  }
11058  fclose(op);
11059 
11060  op = fopen("tsen.txt","w");
11061  fprintf(op,"TemperatureIndex\tCompIndex\tTemperature\n");
11062  for (i=0; i<cinfo->devspec.tsen_cnt; i++)
11063  {
11064  fprintf(op,"%d\t%d\t%.15g\n",i,cinfo->device[cinfo->devspec.tsen[i]].cidx,cinfo->device[cinfo->devspec.tsen[i]].temp);
11065  }
11066  fclose(op);
11067 
11068  op = fopen("strg.txt","w");
11069  fprintf(op,"DeviceIndex\tComponentIndex\tEfficiencyB\tEfficiencyM\tMaxPower\tPower\n");
11070  for (i=0; i<cinfo->devspec.pvstrg_cnt; i++)
11071  {
11072  fprintf(op,"%d\t%d\t%.15g\t%.15g\t%.15g\t%.15g\n",i,cinfo->device[cinfo->devspec.pvstrg[i]].cidx,cinfo->device[cinfo->devspec.pvstrg[i]].pvstrg.effbase,cinfo->device[cinfo->devspec.pvstrg[i]].pvstrg.effslope,cinfo->device[cinfo->devspec.pvstrg[i]].pvstrg.maxpower,cinfo->device[cinfo->devspec.pvstrg[i]].power);
11073  }
11074  fclose(op);
11075 
11076  op = fopen("batt.txt","w");
11077  fprintf(op,"DeviceIndex\tComponentIndex\tCapacity\tEfficiency\tCharge\n");
11078  for (i=0; i<cinfo->devspec.batt_cnt; i++)
11079  {
11080  fprintf(op,"%d\t%d\t%.15g\t%.15g\t%.15g\n",i,cinfo->device[cinfo->devspec.batt[i]].cidx,cinfo->device[cinfo->devspec.batt[i]].batt.capacity,cinfo->device[cinfo->devspec.batt[i]].batt.efficiency,cinfo->device[cinfo->devspec.batt[i]].batt.charge);
11081  }
11082  fclose(op);
11083 
11084  op = fopen("ssen.txt","w");
11085  fprintf(op,"DeviceIndex\tComponentIndex\tAlignmentQx\tAlignmentQy\tAlignmentQz\tAlignmentQw\tQuadrantVoltageA\tQuadrantVoltageB\tQuadrantVoltageC\tQuadrantVoltageD\tAzimuth\tElevation\n");
11086  for (i=0; i<cinfo->devspec.ssen_cnt; i++)
11087  {
11088  fprintf(op,"%d\t%d\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\n",i,cinfo->device[cinfo->devspec.ssen[i]].cidx,cinfo->device[cinfo->devspec.ssen[i]].ssen.align.d.x,cinfo->device[cinfo->devspec.ssen[i]].ssen.align.d.y,cinfo->device[cinfo->devspec.ssen[i]].ssen.align.d.z,cinfo->device[cinfo->devspec.ssen[i]].ssen.align.w,cinfo->device[cinfo->devspec.ssen[i]].ssen.qva,cinfo->device[cinfo->devspec.ssen[i]].ssen.qvb,cinfo->device[cinfo->devspec.ssen[i]].ssen.qvc,cinfo->device[cinfo->devspec.ssen[i]].ssen.qvd,cinfo->device[cinfo->devspec.ssen[i]].ssen.azimuth,cinfo->device[cinfo->devspec.ssen[i]].ssen.elevation);
11089  }
11090  fclose(op);
11091 
11092  op = fopen("imu.txt","w");
11093  fprintf(op,"DeviceIndex\tComponentIndex\tAlignmentQx\tAlignmentQy\tAlignmentQz\tAlignmentQw\tPositionX\tPositionY\tPositionZ\tVelocityX\tVelocityY\tVelocityZ\tAccelerationX\tAccelerationY\tAccelerationZ\tAttitudeQx\tAttitudeQy\tAttitudeQz\tAttitudeQw\tAngularVelocityX\tAngularVelocityY\tAngularVelocityZ\tAngularAccelerationX\tAngularAccelerationY\tAngularAccelerationZ\tMagneticFieldX\tMagneticFieldY\tMagneticFieldZ\tCalibrationQx\tCalibrationQy\tCalibrationQz\tCalibrationQw\n");
11094  for (i=0; i<cinfo->devspec.imu_cnt; i++)
11095  {
11096  ims = cinfo->device[cinfo->devspec.imu[i]].imu;
11097  devicestruc d = cinfo->device[cinfo->devspec.imu[i]];
11098  fprintf(op,"%d\t%d\t%.15g\t%.15g\t%.15g\t%.15g\n",i,d.cidx,ims.align.d.x,ims.align.d.y,ims.align.d.z,ims.align.w);
11099  }
11100  fclose(op);
11101 
11102  op = fopen("stt.txt","w");
11103  fprintf(op,"DeviceIndex\tComponentIndex\tAlignmentQx\tAlignmentQy\tAlignmentQz\tAlignmentQw\tAttitudeQx\tAttitudeQy\tAttitudeQz\tAttitudeQw\tAngularVelocityX\tAngularVelocityY\tAngularVelocityZ\tAngularAccelerationX\tAngularAccelerationY\tAngularAccelerationZ\tCalibrationQx\tCalibrationQy\tCalibrationQz\tCalibrationQw\n");
11104  for (i=0; i<cinfo->devspec.stt_cnt; i++)
11105  {
11106  sts = cinfo->device[cinfo->devspec.stt[i]].stt;
11107  devicestruc d = cinfo->device[cinfo->devspec.stt[i]];
11108  fprintf(op,"%d\t%d\t%.15g\t%.15g\t%.15g\t%.15g\n",i,d.cidx,sts.align.d.x,sts.align.d.y,sts.align.d.z,sts.align.w);
11109  }
11110  fclose(op);
11111 
11112  op = fopen("mtr.txt","w");
11113  fprintf(op,"DeviceIndex\tComponentIndex\tAlignmentQx\tAlignmentQy\tAlignmentQz\tAlignmentQw\tMagneticMomentX\tMagneticMomentY\tMagneticMomentZ\tMagneticField\n");
11114  for (i=0; i<cinfo->devspec.mtr_cnt; i++)
11115  {
11116  fprintf(op,"%d\t%d\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\n",i,cinfo->device[cinfo->devspec.mtr[i]].cidx,cinfo->device[cinfo->devspec.mtr[i]].mtr.align.d.x,cinfo->device[cinfo->devspec.mtr[i]].mtr.align.d.y,cinfo->device[cinfo->devspec.mtr[i]].mtr.align.d.z,cinfo->device[cinfo->devspec.mtr[i]].mtr.align.w,cinfo->device[cinfo->devspec.mtr[i]].mtr.npoly[0],cinfo->device[cinfo->devspec.mtr[i]].mtr.npoly[1],cinfo->device[cinfo->devspec.mtr[i]].mtr.npoly[2],cinfo->device[cinfo->devspec.mtr[i]].mtr.mom);
11117  }
11118  fclose(op);
11119 
11120  op = fopen("gps.txt","w");
11121  fprintf(op,"DeviceIndex\tComponentIndex\tLatitude\tLongitude\tAltitude\tVelocityX\tVelocityY\tVelocityZ\n");
11122  for (i=0; i<cinfo->devspec.gps_cnt; i++)
11123  {
11124  fprintf(op,"%d\t%d\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\t%.15g\n",i,cinfo->device[cinfo->devspec.gps[i]].cidx,cinfo->device[cinfo->devspec.gps[i]].gps.geocs.col[0],cinfo->device[cinfo->devspec.gps[i]].gps.geocs.col[1],cinfo->device[cinfo->devspec.gps[i]].gps.geocs.col[2],cinfo->device[cinfo->devspec.gps[i]].gps.geocv.col[0],cinfo->device[cinfo->devspec.gps[i]].gps.geocv.col[1],cinfo->device[cinfo->devspec.gps[i]].gps.geocv.col[2]);
11125  }
11126  fclose(op);
11127 
11128  op = fopen("cpu.txt","w");
11129  fprintf(op,"DeviceIndex\tComponentIndex\tLoad\tMemoryUse\tMemoryFree\tDiskUse\n");
11130  for (i=0; i<cinfo->devspec.cpu_cnt; i++)
11131  {
11132  fprintf(op,"%d\t%d\t%.8g\t%.8g\t%.8g\n",i,cinfo->device[cinfo->devspec.cpu[i]].cidx,cinfo->device[cinfo->devspec.cpu[i]].cpu.maxgib,cinfo->device[cinfo->devspec.cpu[i]].cpu.load,cinfo->device[cinfo->devspec.cpu[i]].cpu.gib);
11133  }
11134  fclose(op);
11135 
11136  op = fopen("pload.txt","w");
11137  fprintf(op,"DeviceIndex\tComponentIndex\tKeyCount");
11138  for (i=0; i<MAXPLOADKEYCNT; i++)
11139  {
11140  fprintf(op,"\tKey%d",i);
11141  }
11142  for (i=0; i<MAXPLOADKEYCNT; i++)
11143  {
11144  fprintf(op,"\tValue%d",i);
11145  }
11146  fprintf(op,"\n");
11147  for (i=0; i<cinfo->devspec.pload_cnt; i++)
11148  {
11149  fprintf(op,"%d\t%d\t%d",i,cinfo->device[cinfo->devspec.pload[i]].cidx,cinfo->device[cinfo->devspec.pload[i]].pload.key_cnt);
11150  for (j=0; j<MAXPLOADKEYCNT; j++)
11151  {
11152  fprintf(op,"\t%d",cinfo->device[cinfo->devspec.pload[i]].pload.keyidx[j]);
11153  }
11154  for (j=0; j<MAXPLOADKEYCNT; j++)
11155  {
11156  fprintf(op,"\t%.15g",cinfo->device[cinfo->devspec.pload[i]].pload.keyval[j]);
11157  }
11158  fprintf(op,"\n");
11159  }
11160  fclose(op);
11161 
11162  op = fopen("motr.txt","w");
11163  fprintf(op,"motr_idx\tmotr_cidx\tmotr_spd\tmotr_rat\tmotr_rat\n");
11164  for (i=0; i<cinfo->devspec.motr_cnt; i++)
11165  {
11166  fprintf(op,"%d\t%d\t%.15g\t%.15g\t%.15g\n",i,cinfo->device[cinfo->devspec.motr[i]].cidx,cinfo->device[cinfo->devspec.motr[i]].motr.max,cinfo->device[cinfo->devspec.motr[i]].motr.rat,cinfo->device[cinfo->devspec.motr[i]].motr.spd);
11167  }
11168  fclose(op);
11169 
11170  op = fopen("swch.txt","w");
11171  fprintf(op,"swch_idx\tswch_cidx\n");
11172  for (i=0; i<cinfo->devspec.swch_cnt; i++)
11173  {
11174  iretn = fscanf(op,"%*d\t%hu\n",&cinfo->device[cinfo->devspec.swch[i]].cidx);
11175  if (iretn < 1)
11176  {
11177  break;
11178  }
11179  }
11180  fclose(op);
11181 
11182  op = fopen("thst.txt","w");
11183  fprintf(op,"thst_idx\tthst_cidx\tthst_idx\tthst_isp\tthst_flw\n");
11184  for (i=0; i<cinfo->devspec.thst_cnt; i++)
11185  {
11186  fprintf(op,"%d\t%d\t%.15g\t%.15g\n",i,cinfo->device[cinfo->devspec.thst[i]].cidx,cinfo->device[cinfo->devspec.thst[i]].thst.isp,cinfo->device[cinfo->devspec.thst[i]].thst.flw);
11187  }
11188  fclose(op);
11189 
11190  op = fopen("prop.txt","w");
11191  fprintf(op,"prop_idx\tprop_cidx\tprop_cap\tprop_lev\n");
11192  for (i=0; i<cinfo->devspec.prop_cnt; i++)
11193  {
11194  fprintf(op,"%d\t%d\t%.15g\t%.15g\n",i,cinfo->device[cinfo->devspec.prop[i]].cidx,cinfo->device[cinfo->devspec.prop[i]].prop.cap,cinfo->device[cinfo->devspec.prop[i]].prop.lev);
11195  }
11196  fclose(op);
11197 }
double y
Y value.
Definition: vector.h:114
quaternion align
Rotates vectors from RW frame (axis of rotation = z) to body frame.
Definition: jsondef.h:1923
uint16_t imu_cnt
Definition: jsondef.h:3871
vector< uint16_t > mtr
Definition: jsondef.h:3907
vector< uint16_t > stt
Definition: jsondef.h:3916
uint16_t device_cnt
Definition: jsondef.h:3571
vector< uint16_t > prop
Definition: jsondef.h:3909
Device structure.
Definition: jsondef.h:3692
vector< uint16_t > gps
Definition: jsondef.h:3902
uint16_t tsen_cnt
Definition: jsondef.h:3891
int i
Definition: rw_test.cpp:37
float volt
Current Voltage.
Definition: jsondef.h:1611
float mxalp
Maximum alpha in radians/second/second.
Definition: jsondef.h:1929
cvector d
Orientation.
Definition: vector.h:405
uint16_t pidx
Piece index.
Definition: jsondef.h:1599
uint16_t swch_cnt
Definition: jsondef.h:3886
float mxomg
Maximum omega in radians/second.
Definition: jsondef.h:1927
quaternion align
alignment quaternion
Definition: jsondef.h:2937
uint16_t motr_cnt
Definition: jsondef.h:3873
uint16_t ssen_cnt
Definition: jsondef.h:3882
int iretn
Definition: rw_test.cpp:37
uint16_t didx
Device specific index.
Definition: jsondef.h:1597
vector< uint16_t > imu
Definition: jsondef.h:3904
uint16_t type
Component Type.
Definition: jsondef.h:1587
Part structure: physical information for each piece of Node.
Definition: jsondef.h:1446
double x
X value.
Definition: vector.h:112
uint16_t bidx
Power Bus index.
Definition: jsondef.h:1601
vector< uint16_t > rw
Definition: jsondef.h:3913
float amp
Current Amperage.
Definition: jsondef.h:1609
uint16_t pload_cnt
Definition: jsondef.h:3875
vector< uint16_t > pload
Definition: jsondef.h:3908
vector< devicestruc > device
Vector of all general (common) information for devices (components) in node.
Definition: jsondef.h:4238
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
uint16_t prop_cnt
Definition: jsondef.h:3876
All Component structure.
Definition: jsondef.h:1582
quaternion align
alignment quaternion
Definition: jsondef.h:1861
Reaction Wheel structure: z axis is aligned with axis of rotation.
Definition: jsondef.h:1920
Inertial Measurement Unit (IMU) structure.
Definition: jsondef.h:1858
uint16_t pvstrg_cnt
Definition: jsondef.h:3883
uint16_t gps_cnt
Definition: jsondef.h:3869
uint16_t batt_cnt
Definition: jsondef.h:3864
vector< uint16_t > motr
Definition: jsondef.h:3906
vector< uint16_t > thst
Definition: jsondef.h:3922
uint16_t cpu_cnt
Definition: jsondef.h:3867
uint16_t rw_cnt
Definition: jsondef.h:3880
double w
Rotation.
Definition: vector.h:407
vector< uint16_t > tsen
Definition: jsondef.h:3924
rvector mom
Moments of inertia in RW frame.
Definition: jsondef.h:1925
double z
Z value.
Definition: vector.h:116
vector< uint16_t > cpu
Definition: jsondef.h:3900
uint16_t cidx
Component Index.
Definition: jsondef.h:1595
#define MAXPLOADKEYCNT
Maximum number of Special Payload Keys.
Definition: jsondef.h:416
double col[3]
Definition: vector.h:55
uint16_t thst_cnt
Definition: jsondef.h:3890
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
vector< uint16_t > swch
Definition: jsondef.h:3918
uint16_t mtr_cnt
Definition: jsondef.h:3874
vector< uint16_t > batt
Definition: jsondef.h:3896
vector< uint16_t > pvstrg
Definition: jsondef.h:3911
Star Tracker (STT) Sructure.
Definition: jsondef.h:2934
uint16_t stt_cnt
Definition: jsondef.h:3884
vector< uint16_t > ssen
Definition: jsondef.h:3915
int32_t load_target ( cosmosstruc cinfo)

Load Track list.

Load the file target.ini into an array of targetstruc. Space for the array is automatically allocated and the number of items returned.

Parameters
cinfoReference to cosmosstruc to use.
Returns
Number of items loaded.
11209 {
11210  FILE *op;
11211  string fname;
11212  char inb[JSON_MAX_DATA];
11213  uint16_t count;
11214 
11215  fname = get_nodedir(cinfo->node.name) + "/target.ini";
11216  count = 0;
11217  if ((op=fopen(fname.c_str(),"r")) != nullptr)
11218  {
11219  //JIMNOTE: take away this resize
11220  cinfo->target.resize(MAX_NUMBER_OF_TARGETS);
11221  while (count < cinfo->target.size() && fgets(inb,JSON_MAX_DATA,op) != nullptr)
11222  {
11223  json_addentry("target_range",count, UINT16_MAX, (ptrdiff_t)offsetof(targetstruc,range)+count*sizeof(targetstruc), (uint16_t)JSON_TYPE_DOUBLE, (uint16_t)JSON_STRUCT_TARGET, cinfo);
11224  json_addentry("target_close",count, UINT16_MAX, (ptrdiff_t)offsetof(targetstruc,close)+count*sizeof(targetstruc), (uint16_t)JSON_TYPE_DOUBLE, (uint16_t)JSON_STRUCT_TARGET, cinfo);
11225  json_addentry("target_utc",count, UINT16_MAX, (ptrdiff_t)offsetof(targetstruc,utc)+count*sizeof(targetstruc), (uint16_t)JSON_TYPE_DOUBLE, (uint16_t)JSON_STRUCT_TARGET, cinfo);
11226  json_addentry("target_name",count, UINT16_MAX, (ptrdiff_t)offsetof(targetstruc,name)+count*sizeof(targetstruc), (uint16_t)JSON_TYPE_NAME, (uint16_t)JSON_STRUCT_TARGET, cinfo);
11227  json_addentry("target_type",count, UINT16_MAX, (ptrdiff_t)offsetof(targetstruc,type)+count*sizeof(targetstruc), (uint16_t)JSON_TYPE_UINT16, (uint16_t)JSON_STRUCT_TARGET, cinfo);
11228  json_addentry("target_azfrom",count, UINT16_MAX, (ptrdiff_t)offsetof(targetstruc,azfrom)+count*sizeof(targetstruc), (uint16_t)JSON_TYPE_FLOAT, (uint16_t)JSON_STRUCT_TARGET, cinfo);
11229  json_addentry("target_azto",count, UINT16_MAX, (ptrdiff_t)offsetof(targetstruc,azto)+count*sizeof(targetstruc), (uint16_t)JSON_TYPE_FLOAT, (uint16_t)JSON_STRUCT_TARGET, cinfo);
11230  json_addentry("target_elfrom",count, UINT16_MAX, (ptrdiff_t)offsetof(targetstruc,elfrom)+count*sizeof(targetstruc), (uint16_t)JSON_TYPE_FLOAT, (uint16_t)JSON_STRUCT_TARGET, cinfo);
11231  json_addentry("target_elto",count, UINT16_MAX, (ptrdiff_t)offsetof(targetstruc,elto)+count*sizeof(targetstruc), (uint16_t)JSON_TYPE_FLOAT, (uint16_t)JSON_STRUCT_TARGET, cinfo);
11232  json_addentry("target_min",count, UINT16_MAX, (ptrdiff_t)offsetof(targetstruc,min)+count*sizeof(targetstruc), (uint16_t)JSON_TYPE_FLOAT, (uint16_t)JSON_STRUCT_TARGET, cinfo);
11233  json_addentry("target_loc",count, UINT16_MAX, (ptrdiff_t)offsetof(targetstruc,loc)+count*sizeof(targetstruc), (uint16_t)JSON_TYPE_LOCSTRUC, (uint16_t)JSON_STRUCT_TARGET, cinfo);
11234  json_addentry("target_loc_pos_geod",count, UINT16_MAX, (ptrdiff_t)offsetof(targetstruc,loc.pos.geod)+count*sizeof(targetstruc), (uint16_t)JSON_TYPE_POS_GEOD, (uint16_t)JSON_STRUCT_TARGET, cinfo);
11235  json_addentry("target_loc_pos_eci",count, UINT16_MAX, (ptrdiff_t)offsetof(targetstruc,loc.pos.eci)+count*sizeof(targetstruc), (uint16_t)JSON_TYPE_POS_ECI, (uint16_t)JSON_STRUCT_TARGET, cinfo);
11236  if (json_parse(inb, cinfo) >= 0)
11237  {
11238  if (cinfo->target[count].loc.utc == 0.)
11239  {
11240  cinfo->target[count].loc.utc = currentmjd(cinfo->node.utcoffset);
11241  }
11242  // This may cause problems, but location information won't be complete without it
11243  loc_update(&cinfo->target[count].loc);
11244  ++count;
11245  }
11246  }
11247  fclose(op);
11248  //JIMNOTE: take away this resize
11249  cinfo->target.resize(count);
11250  return (count);
11251  }
11252  else
11253  return 0;
11254 }
#define MAX_NUMBER_OF_TARGETS
Definition: jsondef.h:474
Target structure.
Definition: jsondef.h:1290
int32_t json_parse(string jstring, cosmosstruc *cinfo)
Parse JSON using Name Space.
Definition: jsonlib.cpp:4799
static antstruc target
Definition: agent_antenna.cpp:160
int count
Definition: rw_test.cpp:36
JSON Earth Centered Inertial Position.
Definition: jsondef.h:247
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
JSON Name type.
Definition: jsondef.h:206
JSON 16 bit unsigned integer type.
Definition: jsondef.h:192
double utcoffset
MJD Offset between system UT and simulated UT.
Definition: jsondef.h:3590
static char fname[100]
Definition: geomag.cpp:89
char name[40+1]
Node Name.
Definition: jsondef.h:3556
int32_t json_addentry(jsonentry entry, cosmosstruc *cinfo)
Enter an entry into the JSON Namespace.
Definition: jsonlib.cpp:1118
JSON Geodetic Position.
Definition: jsondef.h:255
string name
Definition: cubesat2obj.cpp:6
int32_t loc_update(locstruc *loc)
Synchronize all frames in location structure.
Definition: convertlib.cpp:2294
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
string get_nodedir(string node, bool create_flag)
Get Current Node Directory.
Definition: datalib.cpp:1572
JSON double precision floating vertex type.
Definition: jsondef.h:200
targetstruc
Definition: jsondef.h:160
JSON single precision floating vertex type.
Definition: jsondef.h:198
JSON locstruc type.
Definition: jsondef.h:276
#define JSON_MAX_DATA
Largest JSON data.
Definition: jsondef.h:427
vector< targetstruc > target
Vector of all targets known to node.
Definition: jsondef.h:4253
int32_t update_target ( cosmosstruc cinfo)

Update Track list.

For each entry in the Track list, calculate the azimuth, elevation and range to and from the current base location.

Parameters
cinfoReference to cosmosstruc to use.
Returns
0, otherwise negative error.
11263 {
11264  int32_t iretn = 0;
11265 // rvector topo, dv, ds;
11266  for (uint32_t i=0; i<cinfo->target.size(); ++i)
11267  {
11268  iretn = update_target(cinfo->target[i].loc, cinfo->target[i]);
11269 // loc_update(&cinfo->target[i].loc);
11270 // geoc2topo(cinfo->target[i].loc.pos.geod.s,cinfo->node.loc.pos.geoc.s,topo);
11271 // topo2azel(topo, cinfo->target[i].azto, cinfo->target[i].elto);
11272 // geoc2topo(cinfo->node.loc.pos.geod.s,cinfo->target[i].loc.pos.geoc.s,topo);
11273 // topo2azel(topo, cinfo->target[i].azfrom, cinfo->target[i].elfrom);
11274 // ds = rv_sub(cinfo->target[i].loc.pos.geoc.s,cinfo->node.loc.pos.geoc.s);
11275 // cinfo->target[i].range = length_rv(ds);
11276 // dv = rv_sub(cinfo->target[i].loc.pos.geoc.v,cinfo->node.loc.pos.geoc.v);
11277 // cinfo->target[i].close = length_rv(rv_sub(ds,dv)) - length_rv(ds);
11278  }
11279  return iretn;
11280 }
int i
Definition: rw_test.cpp:37
int32_t update_target(cosmosstruc *cinfo)
Update Track list.
Definition: jsonlib.cpp:11262
int iretn
Definition: rw_test.cpp:37
vector< targetstruc > target
Vector of all targets known to node.
Definition: jsondef.h:4253
int32_t update_target ( locstruc  source,
targetstruc target 
)
11283 {
11284  rvector topo, dv, ds;
11285 
11286  loc_update(&target.loc);
11287  geoc2topo(target.loc.pos.geod.s, source.pos.geoc.s,topo);
11288  topo2azel(topo, target.azto, target.elto);
11289  geoc2topo(source.pos.geod.s, target.loc.pos.geoc.s, topo);
11290  topo2azel(topo, target.azfrom, target.elfrom);
11291  // Calculate direct vector from source to target
11292  ds = rv_sub(target.loc.pos.geoc.s, source.pos.geoc.s);
11293  target.range = length_rv(ds);
11294  // Calculate velocity of target WRT source
11295  dv = rv_sub(target.loc.pos.geoc.v, source.pos.geoc.v);
11296  // Closing speed is length of ds in 1 second minus length of ds now.
11297  target.close = length_rv(rv_sub(ds,dv)) - length_rv(ds);
11298  target.utc = target.loc.utc;
11299  return 0;
11300 }
3 element generic row vector
Definition: vector.h:53
double length_rv(rvector v)
Length of row vector.
Definition: vector.cpp:748
float azfrom
Definition: jsondef.h:1295
int32_t geoc2topo(gvector source, rvector targetgeoc, rvector &topo)
Geocentric to Topocentric.
Definition: convertlib.cpp:3033
cartpos geoc
Definition: convertdef.h:739
double utc
Master time for location, in Modified Julian Day.
Definition: convertdef.h:879
float elto
Definition: jsondef.h:1298
double utc
Definition: jsondef.h:1292
rvector s
Location.
Definition: convertdef.h:163
double range
Definition: jsondef.h:1299
double close
Definition: jsondef.h:1300
int32_t loc_update(locstruc *loc)
Synchronize all frames in location structure.
Definition: convertlib.cpp:2294
posstruc pos
posstruc for this time.
Definition: convertdef.h:881
gvector s
Position vector.
Definition: convertdef.h:263
locstruc loc
Definition: jsondef.h:1302
geoidpos geod
Definition: convertdef.h:741
float azto
Definition: jsondef.h:1297
int32_t topo2azel(rvector tpos, float &az, float &el)
Definition: convertlib.cpp:3129
rvector rv_sub(rvector a, rvector b)
Subtract two vectors.
Definition: vector.cpp:315
float elfrom
Definition: jsondef.h:1296
rvector v
Velocity.
Definition: convertdef.h:165
size_t load_dictionary ( vector< eventstruc > &  dict,
cosmosstruc cinfo,
const char *  file 
)

Load Event Dictionary.

Read a specific event dictionary for a specific node. The dictionary is stored as multiple condition based JSON event strings in a file of the specified name, in the cinfo directory of the specified node. The result is a vector of event structures.

Parameters
dictReference to vector of eventstruc.
cinfoReference to cosmosstruc to use.
fileName of dictionary file.
Returns
Number of items loaded.
11314 {
11315  FILE *op;
11316  char inb[JSON_MAX_DATA];
11317  eventstruc event;
11319  int32_t iretn;
11320 
11321  string fname = (get_nodedir(cinfo->node.name) + "/") + file;
11322  if ((op=fopen(fname.c_str(),"r")) != nullptr)
11323  {
11324  while (fgets(inb,JSON_MAX_DATA,op) != nullptr)
11325  {
11327  if (json_parse(inb, cinfo) >= 0)
11328  {
11329  if ((iretn=json_equation_map(cinfo->event[0].condition, cinfo, &handle)) < 0)
11330  continue;
11331  event = cinfo->event[0];
11332  event.utcexec = 0.;
11333  event.handle = handle;
11334  dict.push_back(event);
11335  }
11336  }
11337  fclose(op);
11338  dict.shrink_to_fit();
11339  return (dict.size());
11340  }
11341  else
11342  return 0;
11343 }
int32_t json_parse(string jstring, cosmosstruc *cinfo)
Parse JSON using Name Space.
Definition: jsonlib.cpp:4799
int iretn
Definition: rw_test.cpp:37
int32_t json_clear_cosmosstruc(int32_t type, cosmosstruc *cinfo)
Clear global data structure.
Definition: jsonlib.cpp:6268
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
eventstruc
Definition: jsondef.h:156
int32_t json_equation_map(string equation, cosmosstruc *cinfo, jsonhandle *handle)
Get hash and index in JSON Equation map.
Definition: jsonlib.cpp:10609
static char fname[100]
Definition: geomag.cpp:89
char name[40+1]
Node Name.
Definition: jsondef.h:3556
Full COSMOS Event structure.
Definition: jsondef.h:1093
gige_handle * handle
Definition: kpc9612p_recv.cpp:33
string get_nodedir(string node, bool create_flag)
Get Current Node Directory.
Definition: datalib.cpp:1572
JSON handle.
Definition: jsondef.h:791
#define JSON_MAX_DATA
Largest JSON data.
Definition: jsondef.h:427
vector< eventstruc > event
Single entry vector for event information.
Definition: jsondef.h:4250
size_t calc_events ( vector< eventstruc > &  dictionary,
cosmosstruc cinfo,
vector< eventstruc > &  events 
)

Calculate current Events.

Using the provided Event Dictionary, calculate all the Events for current state of the provided Node. The Event Dictionary will be updated with any new values so that repeating Events can be properly assessed.

Parameters
dictionaryReference to vector of eventstruc representing event dictionary.
cmetaReference to cosmosstruc to use.
cinfoReference to cosmosstruc to use.
eventsReference to vector of eventstruc representing events.
Returns
Number of events created.
11357 {
11358  double value;
11359  // const char *cp;
11360  char *sptr, *eptr;
11361 
11362  events.resize(0);
11363  for (uint32_t k=0; k<dictionary.size(); ++k)
11364  {
11365  if (!std::isnan(value=json_equation(&dictionary[k].handle, cinfo)) && value != 0. && dictionary[k].value == 0.)
11366  {
11367  dictionary[k].utc = cinfo->node.loc.utc;
11368  events.push_back(dictionary[k]);
11369  string tstring = json_get_string(dictionary[k].data, cinfo);
11370  strcpy(events[events.size()-1].data, tstring.c_str());
11371  strcpy(events[events.size()-1].node,cinfo->node.name);
11372  if ((sptr=strstr(events[events.size()-1].name,"${")) != nullptr && (eptr=strstr(sptr,"}")) != nullptr)
11373  {
11374  *eptr = 0;
11375  tstring = json_get_string(sptr+2, cinfo);
11376  strcpy(sptr, tstring.c_str());
11377  }
11378  }
11379  dictionary[k].value = value;
11380  }
11381 
11382  events.shrink_to_fit();
11383  return (events.size());
11384 }
string json_get_string(string token, cosmosstruc *cinfo)
Return string from name.
Definition: jsonlib.cpp:4045
double utc
Master time for location, in Modified Julian Day.
Definition: convertdef.h:879
static vector< eventstruc > events
Definition: propagator_simple.cpp:64
double json_equation(const char *&ptr, cosmosstruc *cinfo)
Return the results of a JSON equation.
Definition: jsonlib.cpp:4294
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
char name[40+1]
Node Name.
Definition: jsondef.h:3556
locstruc loc
Location structure.
Definition: jsondef.h:3596
gige_handle * handle
Definition: kpc9612p_recv.cpp:33
uint16_t device_type_index ( string  name)
11387 {
11388  for (size_t i=0; i<device_type_string.size(); ++i)
11389  {
11390  if (device_type_string[i] == name)
11391  {
11392  return i;
11393  }
11394  }
11395 
11396  return DeviceType::NONE;
11397 }
static vector< string > device_type_string
Definition: jsonlib.cpp:47
int i
Definition: rw_test.cpp:37
Not a Component.
Definition: jsondef.h:556
string name
Definition: cubesat2obj.cpp:6
string device_type_name ( uint32_t  type)
11400 {
11401  string result;
11403  {
11405  for (size_t i=0; i<DeviceType::COUNT; ++i)
11406  {
11407  if (device_type_string[i] == "")
11408  {
11409  device_type_string[i] = "unknown";
11410  }
11411  }
11412  }
11413 
11414  if (type < DeviceType::COUNT)
11415  {
11416  result = device_type_string[type];
11417  }
11418 
11419  return result;
11420 }
static vector< string > device_type_string
Definition: jsonlib.cpp:47
int i
Definition: rw_test.cpp:37
List count.
Definition: jsondef.h:554
std::ostream& operator<< ( std::ostream &  out,
const beatstruc b 
)
11422  {
11423  return out<<std::fixed<<std::setprecision(9)
11424  <<"\tutc\t\t"<<b.utc<<endl
11425  <<"\tnode name \t<"<<string(b.node)<<">"<<endl
11426  <<"\tagent name \t<"<<string(b.proc)<<">"<<endl
11427  <<"\tntype\t\t"<<(int)b.ntype<<endl
11428  <<"\taddress \t<"<<string(b.addr)<<">"<<endl
11429  <<"\tport\t\t"<<b.port<<endl
11430  <<"\tbuffer\t\t"<<b.bsz<<endl
11431  <<"\tperiod\t\t"<<b.bprd<<endl
11432  <<"\tuser \t\t<"<<string(b.user)<<">"<<endl
11433  <<"\tcpu %\t\t"<<b.cpu<<endl
11434  <<"\tmem %\t\t"<<b.memory<<endl
11435  <<"\tjitter\t\t"<<b.jitter<<endl
11436  <<"\texits\t\t"<<b.exists<<endl;
11437 }
NetworkType ntype
Definition: jsondef.h:932
char user[40+1]
Agent User Name.
Definition: jsondef.h:942
uint32_t bsz
Transfer buffer size.
Definition: jsondef.h:938
char addr[18]
Protocol Address.
Definition: jsondef.h:934
float memory
Agent % memory.
Definition: jsondef.h:946
bool exists
Existence Flag (if beat exists then flag is set to true, false otherwise)
Definition: jsondef.h:950
char proc[40+1]
Heartbeat Agent Name.
Definition: jsondef.h:930
double jitter
Agent heartbeat jitter [sec].
Definition: jsondef.h:948
char node[40+1]
Definition: jsondef.h:928
uint16_t port
AGENT port.
Definition: jsondef.h:936
float cpu
Agent % CPU.
Definition: jsondef.h:944
double utc
Definition: jsondef.h:926
double bprd
Heartbeat period in seconds.
Definition: jsondef.h:940
int32_t json_clone ( cosmosstruc cinfo)
int32_t json_repoint ( cosmosstruc cinfo)
int32_t json_addentry ( string  name,
string  value,
cosmosstruc cinfo 
)
int32_t json_out_tvector ( string &  jstring,
rvector  value 
)
uint8_t* json_ptrto_1d ( const char *  token,
uint16_t  index1,
cosmosstruc cinfo 
)
uint8_t* json_ptrto_2d ( const char *  token,
uint16_t  index1,
uint16_t  index2,
cosmosstruc cinfo 
)
int32_t json_scan ( char *  istring)
int32_t json_convert_int32 ( string  object)
uint32_t json_convert_uint32 ( string  object)
int16_t json_convert_int16 ( string  object)
uint16_t json_convert_uint16 ( string  object)
float json_convert_float ( string  object)
const char* json_of_groundcontact ( cosmosstruc cinfo)
const char* json_of_groundstation ( string &  jstring,
cosmosstruc cinfo 
)
const char* json_of_log ( string &  jstring,
cosmosstruc cinfo 
)
bool json_static ( char *  json_extended_name)
bool json_dynamic ( char *  json_extended_name)
string port_type_name ( uint32_t  type)