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

#include <jsondef.h>

Collaboration diagram for beatstruc:

Public Member Functions

json11::Json to_json () const
 Convert class contents to JSON object. More...
 
void from_json (const string &s)
 Set class contents from JSON string. More...
 

Public Attributes

double utc = 0.
 
char node [40+1] = {}
 
char proc [40+1] = {}
 Heartbeat Agent Name. More...
 
NetworkType ntype = NetworkType::MULTICAST
 
char addr [18] = {}
 Protocol Address. More...
 
uint16_t port = 0
 AGENT port. More...
 
uint32_t bsz = 0
 Transfer buffer size. More...
 
double bprd = 0.
 Heartbeat period in seconds. More...
 
char user [40+1] = {}
 Agent User Name. More...
 
float cpu = 0.
 Agent % CPU. More...
 
float memory = 0.
 Agent % memory. More...
 
double jitter = 0.
 Agent heartbeat jitter [sec]. More...
 
bool exists = true
 Existence Flag (if beat exists then flag is set to true, false otherwise) More...
 

Detailed Description

Process heartbeat. Detailed elements of a single heartbeat of a single process.

Member Function Documentation

json11::Json beatstruc::to_json ( ) const
inline

Convert class contents to JSON object.

Returns a json11 JSON object of the class

Returns
A json11 JSON object containing every member variable within the class
956  {
957  return json11::Json::object {
958  { "utc" , utc },
959  { "node" , node },
960  { "proc" , proc },
961  { "ntype" , static_cast<int>(ntype) },
962  { "addr" , addr },
963  { "port" , port },
964  { "bsz" , static_cast<int>(bsz) },
965  { "bprd" , bprd },
966  { "user" , user },
967  { "cpu" , cpu },
968  { "memory", memory },
969  { "jitter", jitter },
970  { "exists", exists }
971  };
972  }
NetworkType ntype
Definition: jsondef.h:932
std::map< std::string, Json > object
Definition: json11.hpp:88
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
void beatstruc::from_json ( const string &  s)
inline

Set class contents from JSON string.

Parses the provided JSON-formatted string and sets the class data. String should be formatted like the string returned from to_json()

Parameters
sJSON-formatted string to set class contents to
Returns
n/a
980  {
981  string error;
983  if(error.empty()) {
984  if(!p["utc"].is_null()) { utc = p["utc"].number_value(); }
985  if(!p["node"].is_null()) { strcpy(node, p["node"].string_value().c_str()); }
986  if(!p["proc"].is_null()) { strcpy(proc, p["proc"].string_value().c_str()); }
987  if(!p["ntype"].is_null()) { ntype = static_cast<NetworkType>(p["ntype"].int_value()); }
988  if(!p["addr"].is_null()) { strcpy(addr, p["addr"].string_value().c_str()); }
989  if(!p["port"].is_null()) { port = p["port"].int_value(); }
990  if(!p["bsz"].is_null()) { bsz = p["bsz"].int_value(); }
991  if(!p["bprd"].is_null()) { bprd = p["bprd"].number_value(); }
992  if(!p["user"].is_null()) { strcpy(user, p["user"].string_value().c_str()); }
993  if(!p["cpu"].is_null()) { cpu = p["cpu"].number_value(); }
994  if(!p["memory"].is_null()) { memory = p["memory"].number_value(); }
995  if(!p["jitter"].is_null()) { jitter = p["jitter"].number_value(); }
996  if(!p["exists"].is_null()) { exists = p["exists"].bool_value(); }
997  } else {
998  cerr<<"ERROR: <"<<error<<">"<<endl;
999  }
1000  return;
1001  }
NetworkType ntype
Definition: jsondef.h:932
Definition: json11.hpp:79
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
static double * p
Definition: gauss_jackson_test.cpp:42
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
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
uint16_t port
AGENT port.
Definition: jsondef.h:936
bool bool_value() const
Definition: json11.cpp:282
NetworkType
Definition: socketlib.h:63
float cpu
Agent % CPU.
Definition: jsondef.h:944
double utc
Definition: jsondef.h:926
double bprd
Heartbeat period in seconds.
Definition: jsondef.h:940
int int_value() const
Definition: json11.cpp:281
double number_value() const
Definition: json11.cpp:280

Member Data Documentation

double beatstruc::utc = 0.

Heartbeat timestamp

char beatstruc::node[40+1] = {}

Heartbeat Node Name

char beatstruc::proc[40+1] = {}

Heartbeat Agent Name.

NetworkType beatstruc::ntype = NetworkType::MULTICAST
char beatstruc::addr[18] = {}

Protocol Address.

uint16_t beatstruc::port = 0

AGENT port.

uint32_t beatstruc::bsz = 0

Transfer buffer size.

double beatstruc::bprd = 0.

Heartbeat period in seconds.

char beatstruc::user[40+1] = {}

Agent User Name.

float beatstruc::cpu = 0.

Agent % CPU.

float beatstruc::memory = 0.

Agent % memory.

double beatstruc::jitter = 0.

Agent heartbeat jitter [sec].

bool beatstruc::exists = true

Existence Flag (if beat exists then flag is set to true, false otherwise)


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