COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
monitor_gs.cpp File Reference
Include dependency graph for monitor_gs.cpp:

Functions

int32_t query_control ()
 
int32_t query_radios ()
 
int main (int argc, char *argv[])
 

Variables

static Agentagent
 
static vector< beatstrucradiobeat
 
static beatstruc controlbeat
 
static string control_state
 

Function Documentation

int32_t query_control ( )
46 {
47  // Locate agent_control if not present
48  if (controlbeat.utc == 0.)
49  {
50  controlbeat = agent->find_agent("any", "control", 5.);
51  if (controlbeat.utc == 0.)
52  {
53  return AGENT_ERROR_DISCOVERY;
54  }
55  }
56 
57  // Send request
58  string response;
59  agent->send_request(controlbeat, "get_state", response);
60  control_state = response;
61  for (uint16_t i=response.size(); i<200; ++i)
62  {
63  control_state.push_back(' ');
64  }
65 
66  return 0;
67 }
static Agent * agent
Definition: monitor_gs.cpp:4
int i
Definition: rw_test.cpp:37
int32_t send_request(beatstruc cbeat, string request, string &output, float waitsec=5.)
Send a request over AGENT.
Definition: agentclass.cpp:424
#define AGENT_ERROR_DISCOVERY
Definition: cosmos-errno.h:112
static beatstruc controlbeat
Definition: monitor_gs.cpp:6
static string control_state
Definition: monitor_gs.cpp:7
beatstruc find_agent(string node, string agent, double waitsec=0.)
Find agent.
Definition: agentclass.cpp:559
double utc
Definition: jsondef.h:926
int32_t query_radios ( )
43 { return 0; }
int main ( int  argc,
char *  argv[] 
)
13 {
14  int32_t iretn;
15  string node = "";
16 
17  switch (argc)
18  {
19  case 2:
20  node = argv[1];
21  break;
22  }
23 
24  agent = new Agent();
25  if ((iretn = agent->wait()) < 0)
26  {
27  fprintf(agent->get_debug_fd(), "%16.10f %s Failed to start Agent %s on Node %s Dated %s : %s\n",currentmjd(), mjd2iso8601(currentmjd()).c_str(), agent->getAgent().c_str(), agent->getNode().c_str(), utc2iso8601(data_ctime(argv[0])).c_str(), cosmos_error_string(iretn).c_str());
28  exit(iretn);
29  }
30 
31  while (1)
32  {
33  iretn = query_control();
34  if (iretn >= 0)
35  {
36  printf("%s\r", control_state.c_str());
37  fflush(stdout);
38  }
39  COSMOS_SLEEP(2.);
40  }
41 }
FILE * get_debug_fd(double mjd=0.)
Definition: agentclass.cpp:2645
static Agent * agent
Definition: monitor_gs.cpp:4
string getNode()
Listen for heartbeat.
Definition: agentclass.cpp:2607
int iretn
Definition: rw_test.cpp:37
int32_t wait(State state=State::RUN, double waitsec=10.)
Definition: agentclass.cpp:398
string cosmos_error_string(int32_t cosmos_errno)
Definition: cosmos-errno.cpp:45
string getAgent()
Definition: agentclass.cpp:2609
Definition: agentclass.h:139
static string control_state
Definition: monitor_gs.cpp:7
double data_ctime(string path)
Definition: datalib.cpp:1910
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
string utc2iso8601(double utc)
ISO 8601 version of time.
Definition: timelib.cpp:1286
int32_t query_control()
Definition: monitor_gs.cpp:45
static string node
Definition: agent_monitor.cpp:126
string mjd2iso8601(double mjd)
Definition: timelib.cpp:1316

Variable Documentation

Agent* agent
static
vector<beatstruc> radiobeat
static
beatstruc controlbeat
static
string control_state
static