96 std::vector<string> nl;
106 printf(
"Usage: agent [ list | dump [soh, beat, ###] | node_name agent_name \"request [ arguments ]\" ]\n");
115 if (!strcmp(argv[1],
"dump"))
117 double lmjd = 0., dmjd;
127 if (channel ==
"soh")
129 cnum = Agent::AgentMessage::SOH;
133 if (channel ==
"beat")
135 cnum = Agent::AgentMessage::BEAT;
146 cnum = Agent::AgentMessage::ALL;
152 if ((iretn=
agent->
readring(mess, Agent::AgentMessage::ALL, 1)) > 0)
160 if (!channel.empty() && cnum != pretn)
165 if (pretn < Agent::AgentMessage::BINARY)
174 case Agent::AgentMessage::SOH:
177 case Agent::AgentMessage::BEAT:
181 printf(
"[%d]",pretn);
184 printf(
"%s:[%s:%s][%s:%s](%" PRIu64
":%" PRIu64
")\n",utc.c_str(), node.c_str(), proc.c_str(), addr.c_str(), port.c_str(), mess.
jdata.size(), mess.
adata.size());
185 if (pretn < Agent::AgentMessage::BINARY && !channel.empty())
187 printf(
"%s\n",mess.
adata.c_str());
189 if ((channel==
"info") && pretn == Agent::AgentMessage::TRACK)
214 printf(
"%.15g %.4g\n",loc.
utc,dmjd);
223 else if (!strcmp(argv[1],
"list"))
225 std::vector<beatstruc>
cbeat;
228 if (cbeat.size() > 0)
230 std::cout<<
"Number of Agents found: "<<cbeat.size()<<std::endl;
231 for (
unsigned int i=0; i<cbeat.size(); i++)
234 printf(
"[%d] %.15g %s %s %s %hu %u\n",i,cbeat[i].utc,cbeat[i].node,cbeat[i].proc,cbeat[i].addr,cbeat[i].port,cbeat[i].bsz);
235 printf(
"\t%s\n",
output.c_str());
279 if (!strcmp(argv[1],
"dump"))
281 double lmjd = 0., dmjd;
291 if (channel ==
"soh")
293 cnum = Agent::AgentMessage::SOH;
297 if (channel ==
"beat")
299 cnum = Agent::AgentMessage::BEAT;
310 cnum = Agent::AgentMessage::ALL;
316 if ((iretn=
agent->
readring(mess, Agent::AgentMessage::ALL, 1)) > 0)
324 if (!channel.empty() && cnum != pretn)
329 if (pretn < Agent::AgentMessage::BINARY)
338 case Agent::AgentMessage::SOH:
341 case Agent::AgentMessage::BEAT:
345 printf(
"[%d]",pretn);
348 printf(
"%s:[%s:%s][%s:%s](%" PRIu64
":%" PRIu64
")\n",utc.c_str(), node.c_str(), proc.c_str(), addr.c_str(), port.c_str(), mess.
jdata.size(), mess.
adata.size());
349 if (pretn < Agent::AgentMessage::BINARY && !channel.empty())
351 printf(
"%s\n",mess.
adata.c_str());
353 if ((channel==
"info") && pretn == Agent::AgentMessage::TRACK)
378 printf(
"%.15g %.4g\n",loc.
utc,dmjd);
395 printf(
"List of available requests:\n");
397 printf(
"%s [%d]\n",
output.c_str(), nbytes);
403 for (
size_t i=0; i<(size_t)argc-4; ++
i)
406 request += argv[i+4];
409 printf(
"%s [%d]\n",
output.c_str(), nbytes);
415 fprintf(stderr,
"node-agent pair [%s:%s] not found\n",argv[1],argv[2]);
417 printf(
"Error: %d\n",nbytes);
static string port
Definition: add_radio.cpp:16
uint16_t imu_cnt
Definition: jsondef.h:3871
AgentMessage
Type of Agent Message. Types > 127 are binary.
Definition: agentclass.h:216
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
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
string json_extract_namedmember(string json, string token)
Extract JSON value matching name.
Definition: jsonlib.cpp:4417
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
double utc
Definition: convertdef.h:735
char name[40+1]
Node Name.
Definition: jsondef.h:3556
Definition: agentclass.h:139
const int REQUEST_WAIT_TIME
Definition: agent_orig.cpp:61
locstruc loc
Location structure.
Definition: jsondef.h:3596
const int SERVER_WAIT_TIME
Definition: agent_orig.cpp:62
#define DEGOF(rad)
Degrees of a Radian value.
Definition: math/constants.h:33
string output
Definition: agent_orig.cpp:58
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
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
string jdata
Definition: agentclass.h:277
vector< agentstruc > agent
Single entry vector for agent information.
Definition: jsondef.h:4247
string json_convert_string(string object)
Convert JSON to string.
Definition: jsonlib.cpp:4557
static beatstruc cbeat
Definition: agent_file.cpp:92
cosmosstruc * cinfo
Definition: agentclass.h:346
geoidpos geod
Definition: convertdef.h:741
Agent * agent
Definition: agent_orig.cpp:59
devspecstruc devspec
Structure for devices (components) special data in node, by type.
Definition: jsondef.h:4241
static string node
Definition: agent_monitor.cpp:126
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
vector< beatstruc > find_agents(double waitsec=0.)
Find single server.
Definition: agentclass.cpp:605
float powgen
Definition: jsondef.h:3432