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

Functions

int32_t request_hello (string &request, string &response, Agent *cdata)
 
int main (int, char **)
 agent_006 is a test agent that demonstrates the interconnectivity with another agent through the use of agent requests. This agent will receive a request from agent an agent and will send back a response to it. More...
 

Variables

static int request_counter = 0
 Count of the number of requests that have been run. More...
 
static Agentagent
 The agent constructor. More...
 

Function Documentation

int32_t request_hello ( string &  request,
string &  response,
Agent cdata 
)
79 {
80  response = "hello " + std::to_string(request_counter);
81 
82  // Send response back to agent
83  cout << "agent_006 got a request! Its response is: " << response << endl;
84 
85  // Increment counter of how many requests were run
87 
88  return 0;
89 }
string to_string(char *value)
Definition: stringlib.cpp:220
static int request_counter
Count of the number of requests that have been run.
Definition: agent_006.cpp:43
int main ( int  ,
char **   
)

agent_006 is a test agent that demonstrates the interconnectivity with another agent through the use of agent requests. This agent will receive a request from agent an agent and will send back a response to it.

Returns
int
54 {
55  cout << "Starting agent " << endl;
56 
57  // Initialize agent parameters; its name and node
58  string agentname = "006"; // Forward facing name of the agent
59  string nodename = "cubesat6"; // The node that the agent will run on
60 
61  // Construct agent with above parameters
62  agent = new Agent(nodename, agentname);
63 
64  // Define the request within the agent
65  agent->add_request("request_hello", request_hello);
66 
67  // Start executing agent
68  while(agent->running())
69  {
70  // Sleep for 1 sec
71  COSMOS_SLEEP(1.);
72  }
73 
74  return 0;
75 }
int32_t request_hello(string &request, string &response, Agent *cdata)
Definition: agent_006.cpp:78
static Agent * agent
The agent constructor.
Definition: agent_006.cpp:46
uint16_t running()
Check if we&#39;re supposed to be running.
Definition: agentclass.cpp:391
string agentname
Definition: agent_add_soh.cpp:53
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
string nodename
Definition: agent_add_soh.cpp:54

Variable Documentation

int request_counter = 0
static

Count of the number of requests that have been run.

Agent* agent
static

The agent constructor.