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

Functions

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

Variables

static Agentagent
 
static beatstruc antbeat
 
static string antbase = ""
 
static string ant_state
 

Function Documentation

int32_t query_antenna ( )
50 {
51  // Locate agent_ant if not present
52  if (antbeat.utc == 0.)
53  {
54  antbeat = agent->find_agent("any", antbase, 5.);
55  if (antbeat.utc == 0.)
56  {
57  return AGENT_ERROR_DISCOVERY;
58  }
59  }
60 
61  // Send request
62  string response;
63  agent->send_request(antbeat, "get_state", response);
64  ant_state = response;
65  for (uint16_t i=response.size(); i<200; ++i)
66  {
67  ant_state.push_back(' ');
68  }
69 
70  return 0;
71 }
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
static string ant_state
Definition: monitor_antenna.cpp:7
static beatstruc antbeat
Definition: monitor_antenna.cpp:5
#define AGENT_ERROR_DISCOVERY
Definition: cosmos-errno.h:112
static string antbase
Definition: monitor_antenna.cpp:6
beatstruc find_agent(string node, string agent, double waitsec=0.)
Find agent.
Definition: agentclass.cpp:559
double utc
Definition: jsondef.h:926
static Agent * agent
Definition: monitor_antenna.cpp:4
int main ( int  argc,
char *  argv[] 
)
12 {
13  int32_t iretn;
14  string node = "";
15 
16  switch (argc)
17  {
18  case 3:
19  node = argv[2];
20  case 2:
21  antbase = argv[1];
22  break;
23  default:
24  printf("Usage: agent_antenna antenna node");
25  exit (1);
26  }
27 
28  agent = new Agent();
29  if ((iretn = agent->wait()) < 0)
30  {
31  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());
32  exit(iretn);
33  }
34 
35  while (1)
36  {
37  iretn = query_antenna();
38  if (iretn >= 0)
39  {
40  printf("%s\r", ant_state.c_str());
41  fflush(stdout);
42  }
43  COSMOS_SLEEP(2.);
44  }
45 }
FILE * get_debug_fd(double mjd=0.)
Definition: agentclass.cpp:2645
string getNode()
Listen for heartbeat.
Definition: agentclass.cpp:2607
static string ant_state
Definition: monitor_antenna.cpp:7
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 antbase
Definition: monitor_antenna.cpp:6
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_antenna()
Definition: monitor_antenna.cpp:49
static string node
Definition: agent_monitor.cpp:126
string mjd2iso8601(double mjd)
Definition: timelib.cpp:1316
static Agent * agent
Definition: monitor_antenna.cpp:4
int32_t query_radios ( )
47 { return 0; }

Variable Documentation

Agent* agent
static
beatstruc antbeat
static
string antbase = ""
static
string ant_state
static