COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
agent_monitor.cpp File Reference
#include "support/configCosmos.h"
#include "agent/agentclass.h"
#include "support/jsonlib.h"
#include "support/convertlib.h"
#include "support/datalib.h"
#include "agent/command_queue.h"
#include <iostream>
#include <iomanip>
#include <list>
#include <fstream>
#include <sstream>
Include dependency graph for agent_monitor.cpp:

Functions

int32_t request_get_command_queue_size (string &request, string &response, Agent *agent)
 
int32_t request_get_event (string &request, string &response, Agent *agent)
 
int32_t request_del_event (string &request, string &response, Agent *agent)
 
int32_t request_del_event_id (string &request, string &response, Agent *agent)
 
int32_t request_add_event (string &request, string &response, Agent *agent)
 
int32_t request_run (string &request, string &response, Agent *agent)
 
int32_t request_soh (string &request, string &response, Agent *agent)
 
int32_t request_reopen_exec (string &request, string &response, Agent *agent)
 
int32_t request_set_logstride_exec (string &request, string &response, Agent *agent)
 
int32_t request_reopen_soh (string &request, string &response, Agent *agent)
 
int32_t request_set_logperiod (string &request, string &response, Agent *agent)
 
int32_t request_set_logstring (string &request, string &response, Agent *agent)
 
int32_t request_get_logstring (string &request, string &response, Agent *agent)
 
int32_t request_set_logstride_soh (string &request, string &response, Agent *agent)
 
void collect_data_loop ()
 
int main (int argc, char *argv[])
 
void print_command ()
 Prints the command information stored in local the copy of agent->cinfo->event[0].l. More...
 

Variables

static Agentagent
 
static string incoming_dir
 
static string outgoing_dir
 
static string temp_dir
 
static string nodename
 
static double logdate_exec =0.
 
static double newlogstride_exec = 900. / 86400.
 
static double logstride_exec = 0.
 
static CommandQueue cmd_queue
 
static string jjstring
 
static string myjstring
 
static thread cdthread
 
static string logstring
 
static vector< jsonentry * > logtable
 
static double logdate_soh =0.
 
static int32_t newlogperiod = 10
 
static int32_t logperiod = 0
 
static double newlogstride_soh = 900. / 86400.
 
static double logstride_soh = 0.
 
static vector< eventstruceventdict
 
static vector< eventstrucevents
 
static double cmjd
 
static beatstruc iscbeat
 
static string node = "hiakasat"
 

Function Documentation

int32_t request_get_command_queue_size ( string &  request,
string &  response,
Agent agent 
)
323 {
324  response = to_unsigned(cmd_queue.get_command_size());
325  return 0;
326 }
string to_unsigned(uint64_t value, uint16_t digits, bool zerofill)
Definition: stringlib.cpp:265
static CommandQueue cmd_queue
Definition: agent_monitor.cpp:96
size_t get_command_size()
Retrieve the size of the queue.
Definition: command_queue.h:100
int32_t request_get_event ( string &  request,
string &  response,
Agent agent 
)
329 {
330  std::ostringstream ss;
331 
332  if(cmd_queue.get_command_size()==0) {
333  ss << "the command queue is empty";
334  } else {
335  int j;
336  int32_t iretn = sscanf(request.c_str(),"get_event %d",&j);
337 
338  // if valid index then return command
339  if (iretn == 1)
340  if(j >= 0 && j < (int)cmd_queue.get_command_size() )
341  ss << cmd_queue.get_command(j);
342  else
343  ss << "<" << j << "> is not a valid command queue index (current range between 0 and " << cmd_queue.get_command_size()-1 << ")";
344 
345  // if no index given, return the entire queue
346  else if (iretn == -1)
347  for(unsigned long int i = 0; i < cmd_queue.get_command_size(); ++i)
348  {
349  Event cmd = cmd_queue.get_command(i);
350  ss << "[" << i << "]" << "[" << mjd2iso8601(cmd.getUtc()) << "]" << cmd << endl;
351  }
352  // if the user supplied something that couldn't be turned into an integer
353  else if (iretn == 0)
354  ss << "Usage:\tget_event [ index ]\t";
355  }
356 
357  response = ( ss.str().c_str());
358  return 0;
359 }
Class to manage Event information.
Definition: event.h:57
Event & get_command(int i)
Retrieve an Event by its position in the queue.
Definition: command_queue.h:107
int i
Definition: rw_test.cpp:37
int iretn
Definition: rw_test.cpp:37
static CommandQueue cmd_queue
Definition: agent_monitor.cpp:96
size_t get_command_size()
Retrieve the size of the queue.
Definition: command_queue.h:100
double getUtc()
Retrieves Event::mjd.
Definition: event.h:125
string mjd2iso8601(double mjd)
Definition: timelib.cpp:1316
int32_t request_del_event ( string &  request,
string &  response,
Agent agent 
)
398 {
399  Event cmd;
400  string line(request);
401 
402  // remove "del_event " from request string
403  line.erase(0, 10);
404 
405  //cmd.set_command(line, agent);
406  cmd.set_command(line);
407 
408  //delete command
409  int n = cmd_queue.del_command(cmd);
410 
411  response = to_unsigned(n) + " commands deleted from the queue";
412 
413  return 0;
414 }
Class to manage Event information.
Definition: event.h:57
string to_unsigned(uint64_t value, uint16_t digits, bool zerofill)
Definition: stringlib.cpp:265
static CommandQueue cmd_queue
Definition: agent_monitor.cpp:96
void set_command(string jstring)
Sets Event information from a JSON formatted string.
Definition: event.cpp:118
int32_t del_command(Event &c)
Remove all matching Event from the queue.
Definition: command_queue.cpp:488
int32_t request_del_event_id ( string &  request,
string &  response,
Agent agent 
)
363 {
364  Event cmd;
365  std::ostringstream ss;
366 
367  if(cmd_queue.get_command_size()==0) {
368  ss << "the command queue is empty";
369  } else {
370  int j;
371  int32_t iretn = sscanf(request.c_str(),"del_event_id %d",&j);
372 
373  // if valid index then return command
374  if (iretn == 1) {
375  cout<<"j = "<<j<<endl;
376  if(j >= 0 && j < (int)cmd_queue.get_command_size() ) {
377  //lookup command
378  cmd = cmd_queue.get_command(j);
379  //delete command
380  int n = cmd_queue.del_command(cmd);
381  response = to_unsigned(n) + " commands deleted from the queue";
382  } else {
383  ss << "<" << j << "> is not a valid command queue index (current range between 0 and " << cmd_queue.get_command_size()-1 << ")";
384  }
385  }
386  // if the user supplied something that couldn't be turned into an integer
387  else if (iretn == 0) {
388  ss << "Usage:\tdel_event_id [ index ]\t";
389  }
390  }
391 
392  response = ( ss.str().c_str());
393  return 0;
394 }
Class to manage Event information.
Definition: event.h:57
Event & get_command(int i)
Retrieve an Event by its position in the queue.
Definition: command_queue.h:107
int iretn
Definition: rw_test.cpp:37
string to_unsigned(uint64_t value, uint16_t digits, bool zerofill)
Definition: stringlib.cpp:265
static CommandQueue cmd_queue
Definition: agent_monitor.cpp:96
size_t get_command_size()
Retrieve the size of the queue.
Definition: command_queue.h:100
int32_t del_command(Event &c)
Remove all matching Event from the queue.
Definition: command_queue.cpp:488
int32_t request_add_event ( string &  request,
string &  response,
Agent agent 
)
418 {
419  Event cmd;
420  string line(request);
421 
422  // remove "add_event " from request string
423  line.erase(0, 10);
424 
425  //cmd.set_command(line, agent);
426  cmd.set_command(line);
427 
428  // add command
429  if(cmd.is_command())
430  cmd_queue.add_command(cmd);
431 
432  // sort the queue
433  cmd_queue.sort();
434  response = ( line.c_str());
435  return 0;
436 }
Class to manage Event information.
Definition: event.h:57
void sort()
Sort the Events in the queue by Event exectution time.
Definition: command_queue.h:210
int32_t add_command(Event &c)
Remove all matching Event from the queue.
Definition: command_queue.cpp:522
static CommandQueue cmd_queue
Definition: agent_monitor.cpp:96
void set_command(string jstring)
Sets Event information from a JSON formatted string.
Definition: event.cpp:118
bool is_command()
Determines if the Event is a command.
Definition: event.h:161
int32_t request_run ( string &  request,
string &  response,
Agent agent 
)
439 {
440  int i;
441  int32_t iretn = 0;
442  FILE *pd;
443  bool flag;
444 
445  // Run Program
446  flag = false;
447 
448  for (i=0; i<AGENTMAXBUFFER-1; i++)
449  {
450  if (flag)
451  {
452  if (request[i] != ' ')
453  break;
454  }
455  else
456  {
457  if (request[i] == ' ')
458  flag = true;
459  }
460  }
461 
462  if (i == AGENTMAXBUFFER-1)
463  {
464  response = ("unmatched");
465  }
466  else
467  {
468 #ifdef COSMOS_WIN_BUILD_MSVC
469  if ((pd=_popen(&request[i], "r")) != NULL)
470 #else
471  if ((pd=popen(&request[i],"r")) != NULL)
472 #endif
473  {
474  response.resize(AGENTMAXBUFFER);
475  iretn = fread(&response[0],1,AGENTMAXBUFFER-1,pd);
476  response[iretn] = 0;
477 
478  iretn = 0;
479 #ifdef COSMOS_WIN_BUILD_MSVC
480  _pclose(pd);
481 #else
482  pclose(pd); // close process
483 #endif
484  }
485  else
486  {
487  response.clear();
488  iretn = 0;
489  }
490  }
491 
492  return iretn;
493 }
double pd[9][150]
Definition: nrlmsise-00_data.cpp:88
int i
Definition: rw_test.cpp:37
int iretn
Definition: rw_test.cpp:37
#define AGENTMAXBUFFER
Maximum AGENT transfer buffer size.
Definition: jsondef.h:438
int32_t request_soh ( string &  request,
string &  response,
Agent agent 
)
int32_t request_reopen_exec ( string &  request,
string &  response,
Agent agent 
)
316 {
317  logdate_exec = ((cosmosstruc *)agent->cinfo)->node.loc.utc;
318  log_move(((cosmosstruc *)agent->cinfo)->node.name, "exec");
319  return 0;
320 }
void log_move(string oldpath, string newpath, bool compress)
Move log file - path version.
Definition: datalib.cpp:200
static double logdate_exec
Definition: agent_monitor.cpp:82
cosmosstruc * cinfo
Definition: agentclass.h:346
Definition: jsondef.h:4199
int32_t request_set_logstride_exec ( string &  request,
string &  response,
Agent agent 
)
310 {
311  sscanf(request.c_str(),"set_logstride_exec %lf",&newlogstride_exec);
312  return 0;
313 }
static double newlogstride_exec
Definition: agent_monitor.cpp:83
int32_t request_reopen_soh ( string &  request,
string &  response,
Agent agent 
)
497 {
498  logdate_soh = ((cosmosstruc *)agent->cinfo)->node.loc.utc;
499  log_move(((cosmosstruc *)agent->cinfo)->node.name, "soh");
500  return 0;
501 }
void log_move(string oldpath, string newpath, bool compress)
Move log file - path version.
Definition: datalib.cpp:200
static double logdate_soh
Definition: agent_monitor.cpp:113
cosmosstruc * cinfo
Definition: agentclass.h:346
Definition: jsondef.h:4199
int32_t request_set_logperiod ( string &  request,
string &  response,
Agent agent 
)
504 {
505  sscanf(request.c_str(),"set_logperiod %d",&newlogperiod);
506  return 0;
507 }
static int32_t newlogperiod
Definition: agent_monitor.cpp:114
int32_t request_set_logstring ( string &  request,
string &  response,
Agent agent 
)
510 {
511  logstring = &request[strlen("set_logstring")+1];
512  logtable.clear();
513  json_table_of_list(logtable, logstring.c_str(), agent->cinfo);
514  return 0;
515 }
int32_t json_table_of_list(vector< jsonentry * > &table, string tokens, cosmosstruc *cinfo)
Output a vector of JSON entries.
Definition: jsonlib.cpp:3086
static vector< jsonentry * > logtable
Definition: agent_monitor.cpp:112
static string logstring
Definition: agent_monitor.cpp:111
cosmosstruc * cinfo
Definition: agentclass.h:346
int32_t request_get_logstring ( string &  request,
string &  response,
Agent agent 
)
518 {
519  response = ( logstring.c_str());
520  return 0;
521 }
static string logstring
Definition: agent_monitor.cpp:111
int32_t request_set_logstride_soh ( string &  request,
string &  response,
Agent agent 
)
524 {
525  sscanf(request.c_str(),"set_logstride_soh %lf",&newlogstride_soh);
526  return 0;
527 }
static double newlogstride_soh
Definition: agent_monitor.cpp:115
void collect_data_loop ( )
530 {
531  int32_t iretn;
532  while (agent->running())
533  {
534  // Collect new data
535  iretn = agent->parsering(Agent::AgentMessage::ALL, 5., Agent::Where::HEAD, "", agent->cinfo->node.name);
536  if (iretn >= 0)
537  {
538  agent->cinfo->node.utc = currentmjd(0.);
539 
541  {
542  if (device.utc > agent->cinfo->node.utc)
543  {
544  agent->cinfo->node.utc = device.utc;
545  }
546  }
547  }
548  }
549  return;
550 }
Device structure.
Definition: jsondef.h:3692
static Agent * agent
Definition: agent_monitor.cpp:74
int iretn
Definition: rw_test.cpp:37
double utc
Overall Node time.
Definition: jsondef.h:3592
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 running()
Check if we&#39;re supposed to be running.
Definition: agentclass.cpp:391
double utc
Device information time stamp.
Definition: jsondef.h:1621
int32_t parsering(AgentMessage type=Agent::AgentMessage::ALL, float waitsec=1., Where where=Where::HEAD, string proc="", string node="")
Parse next message from ring.
Definition: agentclass.cpp:2428
char name[40+1]
Node Name.
Definition: jsondef.h:3556
Definition: inflate.h:21
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
cosmosstruc * cinfo
Definition: agentclass.h:346
static string device
Definition: ax25_recv.cpp:39
int main ( int  argc,
char *  argv[] 
)
129 {
130  int sleept;
131  double lmjd, dmjd;
132  double nextmjd;
133 
134  cout<<"Starting the monitor agent->..";
135  int32_t iretn;
136 
137  // Set node name to first argument
138  nodename = "null";
139 
140  // Establish the command channel and heartbeat
141  agent = new Agent(nodename, "monitor");
142  if ((iretn = agent->wait()) < 0)
143  {
144  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());
145  exit(iretn);
146  }
147  else
148  {
149  fprintf(agent->get_debug_fd(), "%16.10f %s Started Agent %s on Node %s Dated %s\n",currentmjd(), mjd2iso8601(currentmjd()).c_str(), agent->getAgent().c_str(), agent->getNode().c_str(), utc2iso8601(data_ctime(argv[0])).c_str());
150  }
151 
152  agent->cinfo->node.utc = 0.;
153  agent->cinfo->agent[0].aprd = .5;
154 
155  cout<<" started."<<endl;
156 
157  // Establish Executive functions
158 
159  // Set the incoming, outgoing, and temp directories
160  incoming_dir = data_base_path(nodename, "incoming", "exec") + "/";
161  if (incoming_dir.empty())
162  {
163  cout<<"unable to create directory: <"<<(nodename+"/incoming")+"/exec"<<"> ... exiting."<<endl;
164  exit(1);
165  }
166 
167  outgoing_dir = data_base_path(nodename, "outgoing", "exec") + "/";
168  if (outgoing_dir.empty())
169  {
170  cout<<"unable to create directory: <"<<(nodename+"/outgoing")+"/exec"<<"> ... exiting."<<endl;
171  exit(1);
172  }
173 
174  temp_dir = data_base_path(nodename, "temp", "exec") + "/";
175  if (temp_dir.empty())
176  {
177  cout<<"unable to create directory: <"<<(nodename+"/temp")+"/exec"<<"> ... exiting."<<endl;
178  exit(1);
179  }
180 
181  // Add agent request functions
182  if ((iretn=agent->add_request("get_command_queue_size", request_get_command_queue_size, "", "returns the current size of the command queue")))
183  exit (iretn);
184  if ((iretn=agent->add_request("del_event", request_del_event, "entry string", "deletes the specified command event from the queue according to its JSON string")))
185  exit (iretn);
186  if ((iretn=agent->add_request("del_event_id", request_del_event_id, "entry #", "deletes the specified command event from the queue according to its position")))
187  exit (iretn);
188  if ((iretn=agent->add_request("get_event", request_get_event, "[ entry # ]", "returns the requested command queue entry (or all if none specified)")))
189  exit (iretn);
190  if ((iretn=agent->add_request("add_event", request_add_event, "{\"event_name\":\"\"}{\"event_utc\":0}{\"event_utcexec\":0}{\"event_flag\":0}{\"event_type\":0}{\"event_data\":\"\"}{\"event_condition\":\"\"}", "adds the specified command event to the queue")))
191  exit (iretn);
192  if ((iretn=agent->add_request("run", request_run, "", "run the requested command")))
193  exit (iretn);
194  if ((iretn=agent->add_request("reopen_exec", request_reopen_exec)))
195  exit (iretn);
196  if ((iretn=agent->add_request("set_logstride_exec", request_set_logstride_exec)))
197  exit (iretn);
198 
199  // Establish SOH functions
200 
201  if ((iretn=agent->add_request("reopen_soh", request_reopen_soh)))
202  exit (iretn);
203  if ((iretn=agent->add_request("set_logperiod" ,request_set_logperiod)))
204  exit (iretn);
205  if ((iretn=agent->add_request("set_logstring", request_set_logstring)))
206  exit (iretn);
207  if ((iretn=agent->add_request("get_logstring", request_get_logstring)))
208  exit (iretn);
209  if ((iretn=agent->add_request("set_logstride_soh", request_set_logstride_soh)))
210  exit (iretn);
211 
212  // Create default logstring
214  printf("logstring: %s\n", logstring.c_str());
216  // agent_set_sohstring(agent->cinfo, logstring.c_str());
217 
218  load_dictionary(eventdict, agent->cinfo, (const char *)"events.dict");
219 
220  // Start thread to collect SOH data
221  cdthread = thread(collect_data_loop);
222 
223  // Start performing the body of the agent
224  nextmjd = currentmjd();
225  lmjd = currentmjd();
226  while(agent->running())
227  {
228  nextmjd += agent->cinfo->agent[0].aprd/86400.;
229  dmjd = (cmjd-lmjd)*86400.;
230  agent->cinfo->node.utc = cmjd = currentmjd();
231 
232  // Check if the SOH logperiod has changed
233  if (newlogperiod != logperiod )
234  {
237  log_move(agent->cinfo->node.name, "soh");
238  }
239 
240  // Check if either of the logstride have changed
242  {
244  logdate_exec = currentmjd(0.);
245  log_move(nodename, "exec");
246  }
247 
249  {
251  logdate_soh = currentmjd(0.);
252  log_move(nodename, "soh");
253  }
254 
255  // Check if either of the logstride have expired
257  {
259  log_move(nodename, "exec");
260  }
261 
263  {
265  log_move(nodename, "soh");
266  }
267 
268  // Perform SOH specific functions
269  if (agent->cinfo->node.utc != 0.)
270  {
273  agent->post(Agent::AgentMessage::SOH, json_of_table(myjstring, logtable, agent->cinfo));
275  for (uint32_t k=0; k<events.size(); ++k)
276  {
277  memcpy(&agent->cinfo->event[0],&events[k],sizeof(eventstruc));
278  strcpy(agent->cinfo->event[0].condition,agent->cinfo->emap[events[k].handle.hash][events[k].handle.index].text);
280  }
281  }
282 
283  // Check if SOH logperiod has expired
284  if (dmjd-logperiod > -logperiod/20.)
285  {
286  lmjd = cmjd;
287  if (agent->cinfo->node.utc != 0. && logstring.size())
288  {
290  }
291  }
292 
293  // Perform Executive specific functions
294  //cmd_queue.load_commands(incoming_dir, agent);
298 
299  sleept = (int)((nextmjd-currentmjd())*86400000000.);
300  if (sleept < 0) sleept = 0;
301  COSMOS_USLEEP(sleept);
302  }
303 
304  agent->shutdown();
305  cdthread.join();
306 }
static double cmjd
Definition: agent_monitor.cpp:121
static double newlogstride_soh
Definition: agent_monitor.cpp:115
int32_t request_del_event(string &request, string &response, Agent *agent)
Definition: agent_monitor.cpp:397
int32_t request_get_command_queue_size(string &request, string &response, Agent *agent)
Definition: agent_monitor.cpp:322
string json_list_of_soh(cosmosstruc *cinfo)
Definition: jsonlib.cpp:9252
#define DATA_LOG_TYPE_EVENT
Definition: datalib.h:109
static double logstride_soh
Definition: agent_monitor.cpp:116
FILE * get_debug_fd(double mjd=0.)
Definition: agentclass.cpp:2645
size_t calc_events(vector< eventstruc > &dictionary, cosmosstruc *cinfo, vector< eventstruc > &events)
Calculate current Events.
Definition: jsonlib.cpp:11356
static string temp_dir
Definition: agent_monitor.cpp:78
static Agent * agent
Definition: agent_monitor.cpp:74
string getNode()
Listen for heartbeat.
Definition: agentclass.cpp:2607
const char * json_of_table(string &jstring, vector< jsonentry * > table, cosmosstruc *cinfo)
Create JSON stream from entries.
Definition: jsonlib.cpp:8733
int32_t update_target(cosmosstruc *cinfo)
Update Track list.
Definition: jsonlib.cpp:11262
int32_t save_commands(string temp_dir, string name=".queue")
Save the queue of Events to a file.
Definition: command_queue.cpp:353
int32_t load_commands(string incoming_dir)
Load queue of Events from a file.
Definition: command_queue.cpp:420
int iretn
Definition: rw_test.cpp:37
void log_move(string oldpath, string newpath, bool compress)
Move log file - path version.
Definition: datalib.cpp:200
static thread cdthread
Definition: agent_monitor.cpp:109
int32_t wait(State state=State::RUN, double waitsec=10.)
Definition: agentclass.cpp:398
static vector< eventstruc > eventdict
Definition: agent_monitor.cpp:118
double utc
Overall Node time.
Definition: jsondef.h:3592
vector< vector< jsonequation > > emap
JSON Equation Map matrix.
Definition: jsondef.h:4211
string data_base_path(string node, string location, string agent, string filename)
Create data file path.
Definition: datalib.cpp:767
static int32_t newlogperiod
Definition: agent_monitor.cpp:114
static CommandQueue cmd_queue
Definition: agent_monitor.cpp:96
int32_t run_commands(Agent *agent, string nodename, double logdate_exec)
Traverse the entire queue of Events, clearing those that have finished.
Definition: command_queue.cpp:261
int32_t json_table_of_list(vector< jsonentry * > &table, string tokens, cosmosstruc *cinfo)
Output a vector of JSON entries.
Definition: jsonlib.cpp:3086
static string outgoing_dir
Definition: agent_monitor.cpp:77
void collect_data_loop()
Definition: agent_monitor.cpp:529
static string nodename
Definition: agent_monitor.cpp:80
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
string cosmos_error_string(int32_t cosmos_errno)
Definition: cosmos-errno.cpp:45
uint16_t running()
Check if we&#39;re supposed to be running.
Definition: agentclass.cpp:391
int32_t post(messstruc mess)
Post a Cosmos::Agent::messstruc.
Definition: agentclass.cpp:2074
static vector< eventstruc > events
Definition: agent_monitor.cpp:119
int32_t request_reopen_exec(string &request, string &response, Agent *agent)
Definition: agent_monitor.cpp:315
int32_t request_del_event_id(string &request, string &response, Agent *agent)
Definition: agent_monitor.cpp:362
string getAgent()
Definition: agentclass.cpp:2609
int32_t add_request(string token, external_request_function function, string synopsis="", string description="")
Add internal request to Agent request list with description and synopsis.
Definition: agentclass.cpp:312
char name[40+1]
Node Name.
Definition: jsondef.h:3556
static double newlogstride_exec
Definition: agent_monitor.cpp:83
Definition: agentclass.h:139
locstruc loc
Location structure.
Definition: jsondef.h:3596
int32_t request_set_logstride_exec(string &request, string &response, Agent *agent)
Definition: agent_monitor.cpp:309
size_t load_dictionary(vector< eventstruc > &dict, cosmosstruc *cinfo, const char *file)
Load Event Dictionary.
Definition: jsonlib.cpp:11313
int32_t shutdown()
Shutdown agent gracefully.
Definition: agentclass.cpp:366
Full COSMOS Event structure.
Definition: jsondef.h:1093
static double logdate_exec
Definition: agent_monitor.cpp:82
int32_t request_set_logstring(string &request, string &response, Agent *agent)
Definition: agent_monitor.cpp:509
const char * json_of_event(string &jstring, cosmosstruc *cinfo)
Create JSON for an event.
Definition: jsonlib.cpp:9854
int32_t request_get_logstring(string &request, string &response, Agent *agent)
Definition: agent_monitor.cpp:517
static double logstride_exec
Definition: agent_monitor.cpp:84
double data_ctime(string path)
Definition: datalib.cpp:1910
int32_t request_set_logperiod(string &request, string &response, Agent *agent)
Definition: agent_monitor.cpp:503
int32_t loc_update(locstruc *loc)
Synchronize all frames in location structure.
Definition: convertlib.cpp:2294
static vector< jsonentry * > logtable
Definition: agent_monitor.cpp:112
void log_write(string node, string agent, double utc, string extra, string type, string record, string location)
Write log entry - full.
Definition: datalib.cpp:75
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
static double logdate_soh
Definition: agent_monitor.cpp:113
static string logstring
Definition: agent_monitor.cpp:111
#define DATA_LOG_TYPE_SOH
Definition: datalib.h:108
string utc2iso8601(double utc)
ISO 8601 version of time.
Definition: timelib.cpp:1286
vector< agentstruc > agent
Single entry vector for agent information.
Definition: jsondef.h:4247
int32_t request_set_logstride_soh(string &request, string &response, Agent *agent)
Definition: agent_monitor.cpp:523
static int32_t logperiod
Definition: agent_monitor.cpp:114
cosmosstruc * cinfo
Definition: agentclass.h:346
int32_t request_add_event(string &request, string &response, Agent *agent)
Definition: agent_monitor.cpp:417
vector< eventstruc > event
Single entry vector for event information.
Definition: jsondef.h:4250
int32_t request_get_event(string &request, string &response, Agent *agent)
Definition: agent_monitor.cpp:328
static string jjstring
Definition: agent_monitor.cpp:105
string mjd2iso8601(double mjd)
Definition: timelib.cpp:1316
static string incoming_dir
Definition: agent_monitor.cpp:76
static string myjstring
Definition: agent_monitor.cpp:106
int32_t request_run(string &request, string &response, Agent *agent)
Definition: agent_monitor.cpp:438
int32_t request_reopen_soh(string &request, string &response, Agent *agent)
Definition: agent_monitor.cpp:496
void print_command ( )

Prints the command information stored in local the copy of agent->cinfo->event[0].l.

554 {
555  string jsp;
556 
557  json_out(jsp,(char*)"event_utc", agent->cinfo);
558  json_out(jsp,(char*)"event_utcexec", agent->cinfo);
559  json_out(jsp,(char*)"event_name", agent->cinfo);
560  json_out(jsp,(char*)"event_type", agent->cinfo);
561  json_out(jsp,(char*)"event_flag", agent->cinfo);
562  json_out(jsp,(char*)"event_data", agent->cinfo);
563  json_out(jsp,(char*)"event_condition", agent->cinfo);
564  cout<<"<"<<jsp<<">"<<endl;
565 
566  return;
567 }
static Agent * agent
Definition: agent_monitor.cpp:74
int32_t json_out(string &jstring, string token, cosmosstruc *cinfo)
Perform JSON output for a single named JSON item.
Definition: jsonlib.cpp:2905
cosmosstruc * cinfo
Definition: agentclass.h:346

Variable Documentation

Agent* agent
static
string incoming_dir
static
string outgoing_dir
static
string temp_dir
static
string nodename
static
double logdate_exec =0.
static
double newlogstride_exec = 900. / 86400.
static
double logstride_exec = 0.
static
CommandQueue cmd_queue
static
string jjstring
static
string myjstring
static
thread cdthread
static
string logstring
static
vector<jsonentry*> logtable
static
double logdate_soh =0.
static
int32_t newlogperiod = 10
static
int32_t logperiod = 0
static
double newlogstride_soh = 900. / 86400.
static
double logstride_soh = 0.
static
vector<eventstruc> eventdict
static
vector<eventstruc> events
static
double cmjd
static
beatstruc iscbeat
static
string node = "hiakasat"
static