COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
daughter_01.cpp File Reference
#include "support/configCosmos.h"
#include "support/elapsedtime.h"
#include "support/timeutils.h"
#include "agent/agentclass.h"
#include <iostream>
#include <string>
Include dependency graph for daughter_01.cpp:

Functions

int32_t are_you_out_there (string &request, string &response, Agent *cdata)
 
int main (int argc, char **argv)
 

Variables

static Agentagent
 ensure the Agent constructor creates only one instance per process More...
 
string node_name = "daughter_01"
 
string agent_name = "allison"
 
string node_agent_name = "["+node_name+":"+agent_name+"]"
 

Function Documentation

int32_t are_you_out_there ( string &  request,
string &  response,
Agent cdata 
)
95 {
96  // Send response back to the agent who made the request
97  response = "Yes! I am the one they call " + node_agent_name + ".";
98  return 0;
99 }
string node_agent_name
Definition: daughter_01.cpp:45
int main ( int  argc,
char **  argv 
)
48 {
49  // construct agent
50  cout << node_agent_name << " starting..."<<endl;
51  agent = new Agent(node_name, agent_name, 1.);
52 
53  // exit with error if unable to start agent
54  if(agent->last_error() < 0) {
55  cout<<"error: unable to start "<<node_agent_name<<" ("<<agent->last_error()<<") "<<cosmos_error_string(agent->last_error())<<endl;
56  exit(1);
57  } else {
58  cout << node_agent_name << " started."<<endl;
59  }
60 
61  // add custom request functions for this agent
62  agent->add_request("are_you_out_there", are_you_out_there, "\n\t\trequest to support the reporting of existence");
63 
64  cosmosstruc* c = agent->cinfo;
65  // set the orbital elements (psuedo ISS orbit)
66  c->a = 6738000; // 6738 km
67  c->e = 0.0001640; // no units!
68  c->i = 51.6407 * (M_PI/180.0); // radians
69  c->O = 126.7653 * (M_PI/180.0); // radians
70  c->w = 163.1572 * (M_PI/180.0); // radians
71  c->tau = 1.0;
72 
73  // n = mean angular motion (rad/s) [ used to find a in TLEs ]
74  c->n = pow( (c->mu / pow(c->a,3.0) ), (0.5) );
75  // T = period of orbit (seconds)
76  c->T = ( 2.0 * M_PI ) / c->n;
77 
78 
79  while (agent->running()) {
80 
81  cout<<node_agent_name<<" running..."<<endl;
82 
83  // see if you can locate the mothership
84  // see if you can locate each of the other daughters
85 
86  // Sleep for 5 sec
87  COSMOS_SLEEP(5.);
88  }
89  return 0;
90 }
int32_t are_you_out_there(string &request, string &response, Agent *cdata)
Definition: daughter_01.cpp:94
double O
Definition: jsondef.h:4336
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 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
Definition: agentclass.h:139
static Agent * agent
ensure the Agent constructor creates only one instance per process
Definition: daughter_01.cpp:42
double mu
Definition: jsondef.h:4350
int32_t last_error()
Definition: agentclass.cpp:414
double T
Definition: jsondef.h:4356
double w
Definition: jsondef.h:4338
string node_name
Definition: daughter_01.cpp:43
cosmosstruc * cinfo
Definition: agentclass.h:346
double n
Definition: jsondef.h:4353
Definition: jsondef.h:4199
double a
Definition: jsondef.h:4320
double tau
Definition: jsondef.h:4340
double i
Definition: jsondef.h:4334
string agent_name
Definition: daughter_01.cpp:44
double e
Definition: jsondef.h:4322
string node_agent_name
Definition: daughter_01.cpp:45

Variable Documentation

Agent* agent
static

ensure the Agent constructor creates only one instance per process

string node_name = "daughter_01"
string agent_name = "allison"
string node_agent_name = "["+node_name+":"+agent_name+"]"