49 string condition =
"";
68 node = string(argv[4]);
77 double seconds = atof(&argv[3][1]);
100 cout <<
"The command generator produces the command string to be fed into the command\n" 101 "queue which is managed by agent_exec. Commands are a subset of events\n" 102 "in COSMOS." << endl << endl;
104 cout <<
"Usage" << endl << endl;
105 cout <<
" command_generator [options]" << endl;
106 cout <<
" command_generator name command [time | +sec] [node] [condition] [repeat_flag]" << endl << endl;
109 cout <<
"Example" << endl << endl;
110 cout <<
" $ command_generator myCmd1 \"agent kauaicc_sim execsoh get_queue_size\" +10" << endl << endl;
111 cout <<
" This will run the command \"agent kauaicc_sim execsoh get_queue_size\" \n" 112 " with name 'myCmd' within 10 seconds from now." << endl << endl;
114 cout <<
"Options" << endl << endl;
116 cout <<
" -name \t = name of the command, can be a string or combination of \n " 117 " \t alphanumeric characters (ex: myCmd1)" << endl;
118 cout <<
" -command\t = the actual command to be executed, if more than one word \n" 119 " \t enclose the command string in quotes \n" 120 " \t (ex: \"agent kauaicc_sim execsoh get_queue_size\"" << endl;
121 cout <<
" -time \t = optional argument to enter the desired modified julian date\n" 122 " \t (mjd). If not entered it will use the current time. \n" 123 " \t If '+' is used instead then the number of seconds can be\n" 124 " \t inserted. For 10 seconds in the future use +10" << endl;
125 cout <<
" -node \t = optional argument to add the generated command to the command\n" 126 " \t queue on the specified node (ex: kauaicc_sim) " << endl;
132 cout <<
"Command string:" << endl;
134 cout <<
event.
generator(name, data, utc, condition, flag) << endl << endl;
138 if (!agent_mongo_soh.
exists) {
139 cout <<
"could not find agent mongo" << endl;
143 cout <<
"Could not add command to node [No Node]" << endl;
151 cout <<
"Adding command/event to node directory:" << outgoing_dir << endl;
156 cmdfile.open(outgoing_dir + outfilename);
161 if(agent_mongo_soh.
exists) {
163 string mongo_request =
"insert db " + node +
":command ";
165 agent->
send_request(agent_mongo_soh, mongo_request, out, 0);
166 cout <<
"Request agent mongo: " << mongo_request << endl;
Class to manage Event information.
Definition: event.h:57
Definition: jsondef.h:923
int32_t send_request(beatstruc cbeat, string request, string &output, float waitsec=5.)
Send a request over AGENT.
Definition: agentclass.cpp:424
string generator(string name, string data, double utc, string condition, uint32_t flag)
Definition: event.cpp:53
string data_name(string node, double mjd, string extra, string type)
Create data file name.
Definition: datalib.cpp:685
string data_base_path(string node, string location, string agent, string filename)
Create data file path.
Definition: datalib.cpp:767
bool exists
Existence Flag (if beat exists then flag is set to true, false otherwise)
Definition: jsondef.h:950
#define EVENT_FLAG_REPEAT
Repeating event.
Definition: cosmos-defs.h:171
string get_event_string()
Retrieves Event information.
Definition: event.cpp:138
static Agent * agent
ensure the Agent constructor creates only one instance per process
Definition: agent_001.cpp:45
Definition: agentclass.h:139
string name
Definition: cubesat2obj.cpp:6
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
beatstruc find_agent(string node, string agent, double waitsec=0.)
Find agent.
Definition: agentclass.cpp:559
#define EVENT_FLAG_CONDITIONAL
Conditional event.
Definition: cosmos-defs.h:169
static string node
Definition: agent_monitor.cpp:126
static string outgoing_dir
Definition: agent_exec-2-0.cpp:144