84 agent =
new Agent(
"",
"");
91 printf(
"Usage: cosmos [ list | dump [soh, beat, ###] | node_name agent_name \"request [ arguments ]\" ]\n");
92 printf(
"Usage (future): cosmos [-node -makenode -updatetle ...]\n");
104 if (!strcmp(argv[1],
"dump"))
106 double lmjd = 0., dmjd;
123 if (channel ==
"soh")
125 cnum = Agent::AgentMessage::SOH;
129 if (channel ==
"beat")
131 cnum = Agent::AgentMessage::BEAT;
141 cnum = Agent::AgentMessage::ALL;
148 if ((iretn=agent->
readring(message, cnum, 1., Agent::Where::TAIL)) > 0)
153 if (!channel.empty() && cnum != pretn)
170 case Agent::AgentMessage::SOH:
173 case Agent::AgentMessage::BEAT:
177 printf(
"[%d]",pretn);
182 printf(
"%s\n",message.
jdata.c_str());
183 if (pretn < Agent::AgentMessage::BINARY)
185 if (!channel.empty())
187 printf(
"%s\n",message.
adata.c_str());
191 if ((channel==
"info") && pretn == Agent::AgentMessage::TRACK)
214 dmjd = 86400.*(agent->
cinfo->
agent[0].beat.utc-lmjd);
217 printf(
"%.15g %.4g\n",loc.
utc,dmjd);
227 else if (!strcmp(argv[1],
"list"))
229 size_t agent_count = 0;
235 for (
size_t i=agent_count; i<agent->
agent_list.size(); ++
i)
239 printf(
"[%lu] %.15g %s %s %s %hu %u\n",i,cbeat.
utc,cbeat.
node,cbeat.
proc,cbeat.
addr,cbeat.
port,cbeat.
bsz);
240 printf(
"\t%s\n",
output.c_str());
252 if (!strcmp(argv[1],
"dump"))
254 double lmjd = 0., dmjd;
265 if (channel ==
"soh")
267 cnum = Agent::AgentMessage::SOH;
271 if (channel ==
"beat")
273 cnum = Agent::AgentMessage::BEAT;
284 cnum = Agent::AgentMessage::ALL;
290 if ((iretn=agent->
readring(message, Agent::AgentMessage::ALL, 1., Agent::Where::TAIL)) > 0)
294 if (!channel.empty() && cnum != pretn)
300 if (pretn < Agent::AgentMessage::BINARY)
314 case Agent::AgentMessage::SOH:
317 case Agent::AgentMessage::BEAT:
321 printf(
"[%d]",pretn);
327 if (pretn < Agent::AgentMessage::BINARY && !channel.empty())
329 printf(
"%s\n",message.
adata.c_str());
332 if ((channel==
"info") && pretn == Agent::AgentMessage::TRACK)
355 dmjd = 86400.*(agent->
cinfo->
agent[0].beat.utc-lmjd);
358 printf(
"%.15g %.4g\n",loc.
utc,dmjd);
375 printf(
"List of available requests:\n");
377 printf(
"%s [%d]\n",
output.c_str(), nbytes);
383 for (
size_t i=0; i<(size_t)argc-4; ++
i)
386 request += argv[i+4];
389 printf(
"%s [%d]\n",
output.c_str(), nbytes);
395 fprintf(stderr,
"node-agent pair [%s:%s] not found\n",argv[1],argv[2]);
397 printf(
"Error: %d\n", nbytes);
uint16_t imu_cnt
Definition: jsondef.h:3871
AgentMessage
Type of Agent Message. Types > 127 are binary.
Definition: agentclass.h:216
beatstruc beat
Definition: agentclass.h:268
vector< uint8_t > bdata
Definition: agentclass.h:275
Definition: jsondef.h:923
int i
Definition: rw_test.cpp:37
int32_t json_parse(string jstring, cosmosstruc *cinfo)
Parse JSON using Name Space.
Definition: jsonlib.cpp:4799
int32_t send_request(beatstruc cbeat, string request, string &output, float waitsec=5.)
Send a request over AGENT.
Definition: agentclass.cpp:424
uint32_t bsz
Transfer buffer size.
Definition: jsondef.h:938
const int SERVER_WAIT_TIME
Definition: cosmos.cpp:54
char addr[18]
Protocol Address.
Definition: jsondef.h:934
float battlev
Definition: jsondef.h:3431
int iretn
Definition: rw_test.cpp:37
int32_t json_clear_cosmosstruc(int32_t type, cosmosstruc *cinfo)
Clear global data structure.
Definition: jsonlib.cpp:6268
double utc
Master time for location, in Modified Julian Day.
Definition: convertdef.h:879
devicestruc
Definition: jsondef.h:150
ElapsedTime et
Definition: agent_cpu_device_test.cpp:51
string adata
Definition: agentclass.h:276
vector< string > data_list_nodes()
Get list of Nodes, directly.
Definition: datalib.cpp:583
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
int32_t get_agent(string node, string agent, double waitsec, beatstruc &cbeat)
Get specific server.
Definition: agentclass.cpp:513
rvector s
Location.
Definition: convertdef.h:163
char proc[40+1]
Heartbeat Agent Name.
Definition: jsondef.h:930
string output
Definition: cosmos.cpp:69
char node[40+1]
Definition: jsondef.h:928
string agent_name
Definition: cosmos.cpp:71
string node_name
Definition: cosmos.cpp:70
static Agent * agent
ensure the Agent constructor creates only one instance per process
Definition: agent_001.cpp:45
double utc
Definition: convertdef.h:735
uint8_t message[300]
Definition: kpc9612p_send.cpp:36
char name[40+1]
Node Name.
Definition: jsondef.h:3556
uint16_t port
AGENT port.
Definition: jsondef.h:936
Definition: agentclass.h:139
uint16_t jlength
Definition: agentclass.h:267
locstruc loc
Location structure.
Definition: jsondef.h:3596
#define DEGOF(rad)
Degrees of a Radian value.
Definition: math/constants.h:33
int32_t pos_eci(locstruc *loc)
Set ECI position.
Definition: convertlib.cpp:258
double h
Height in meters.
Definition: vector.h:229
Storage for messages.
Definition: agentclass.h:272
nodestruc
Definition: jsondef.h:146
double lon
Longitude in radians.
Definition: vector.h:227
float powuse
Definition: jsondef.h:3433
Definition: elapsedtime.h:62
posstruc pos
posstruc for this time.
Definition: convertdef.h:881
gvector s
Position vector.
Definition: convertdef.h:263
double lat
Latitude in radians.
Definition: vector.h:225
pollstruc meta
Definition: agentclass.h:274
string jdata
Definition: agentclass.h:277
vector< agentstruc > agent
Single entry vector for agent information.
Definition: jsondef.h:4247
double utc
Definition: jsondef.h:926
static beatstruc cbeat
Definition: agent_file.cpp:92
cosmosstruc * cinfo
Definition: agentclass.h:346
vector< beatstruc > agent_list
List of active agents.
Definition: agentclass.h:349
geoidpos geod
Definition: convertdef.h:741
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
const int REQUEST_WAIT_TIME
Definition: cosmos.cpp:53
double split()
ElapsedTime::split, gets the current elapsed time since the start()
Definition: elapsedtime.cpp:234
cartpos icrf
Definition: convertdef.h:736
Inertial Measurement Unit.
Definition: jsondef.h:496
Definition: convertdef.h:876
physicsstruc phys
Definition: jsondef.h:3597
int32_t readring(messstruc &message, AgentMessage type=Agent::AgentMessage::ALL, float waitsec=1., Where where=Where::TAIL, string proc="", string node="")
Check Ring for message.
Definition: agentclass.cpp:2395
float powgen
Definition: jsondef.h:3432