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

Namespaces

 Coords
 
 Devices
 
 Math
 
 Physics
 
 Protocols
 
 Support
 

Classes

class  Event
 Class to manage Event information. More...
 
class  I2C
 
class  Serial
 
class  wavefront
 

Functions

std::ostream & operator<< (std::ostream &out, const Event &cmd)
 
bool operator== (const Event &cmd1, const Event &cmd2)
 

Function Documentation

std::ostream& Cosmos::operator<< ( std::ostream &  out,
const Event cmd 
)
Parameters
outReference to ostream
cmdReference to const Event
Returns
Reference to modified ostream

Writes the given Event to the given output stream (in JSON format) and returns a reference to the modified ostream.

83 {
84  JSONObject jobj;
85  jobj.addElement("event_utc", JSONValue(cmd.mjd));
86  if (cmd.utcexec != 0.)
87  {
88  jobj.addElement("event_utcexec", JSONValue(cmd.utcexec));
89  }
90  jobj.addElement("event_name", JSONValue(cmd.name));
91  jobj.addElement("event_type", JSONValue(cmd.type));
92  jobj.addElement("event_flag", JSONValue(cmd.flag));
93  jobj.addElement("event_data", JSONValue(cmd.data));
94  if (cmd.flag & EVENT_FLAG_CONDITIONAL)
95  {
96  jobj.addElement("event_condition", JSONValue(cmd.condition));
97  }
98  out << std::setprecision(15) << jobj.to_json_string();
99  return out;
100 }
uint32_t flag
Definition: event.h:70
string name
Definition: event.h:66
double mjd
Definition: event.h:62
Definition: jsonvalue.h:13
uint32_t type
Definition: event.h:68
double utcexec
Definition: event.h:64
string data
Definition: event.h:72
string condition
Definition: event.h:74
Definition: jsonobject.h:5
#define EVENT_FLAG_CONDITIONAL
Conditional event.
Definition: cosmos-defs.h:169
void addElement(string key, JSONValue value)
Definition: jsonobject.cpp:10
string to_json_string()
Definition: jsonobject.cpp:91
bool Cosmos::operator== ( const Event cmd1,
const Event cmd2 
)
Parameters
cmd1First event
cmd2Second event
Returns
True if events are exactly the same, otherwise false
104 {
105  return ( cmd1.name==cmd2.name &&
106  cmd1.mjd==cmd2.mjd &&
107  cmd1.utcexec==cmd2.utcexec &&
108  cmd1.type==cmd2.type &&
109  cmd1.flag==cmd2.flag &&
110  cmd1.data==cmd2.data &&
111  cmd1.condition==cmd2.condition);
112 }
uint32_t flag
Definition: event.h:70
string name
Definition: event.h:66
double mjd
Definition: event.h:62
uint32_t type
Definition: event.h:68
double utcexec
Definition: event.h:64
string data
Definition: event.h:72
string condition
Definition: event.h:74