COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
add_radio.cpp File Reference
Include dependency graph for add_radio.cpp:

Functions

int main (int argc, char *argv[])
 

Variables

static ic9100_handle ic9100
 
static Agentagent
 
static std::string nodename =""
 
static std::string radioname
 
static size_t deviceindex
 
static size_t radioindex = 9999
 
static string radiodevice =""
 
static uint16_t radioaddr
 
static string port
 
static uint16_t nodetype = NODE_TYPE_SATELLITE
 
static uint16_t model = DEVICE_MODEL_DIRECT
 
static uint16_t radiotype = static_cast<uint16_t>(DeviceType::NONE)
 
static float freq
 
static float band
 
static uint8_t opmode = static_cast<uint8_t>(DEVICE_RADIO_MODE_UNDEF)
 
double value1 = 0.
 
double value2 = 0.
 
string command = ""
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)
31 {
32  int32_t iretn;
33 
34  switch (argc)
35  {
36  case 9:
38  if (static_cast<string>("ic9100") == argv[3])
39  {
40  model = static_cast<uint16_t>(DEVICE_MODEL_IC9100);
41  radiodevice = argv[8];
42  radioaddr = stoi(radiodevice.substr(radiodevice.find(':')+1));
43  radiodevice = radiodevice.substr(0, radiodevice.find(':'));
44  }
45  else if (static_cast<string>("astrodev") == argv[3])
46  {
47  model = static_cast<uint16_t>(DEVICE_MODEL_ASTRODEV);
48  radiodevice = argv[8];
49  }
50  else if (static_cast<string>("usrp") == argv[3])
51  {
52  model = static_cast<uint16_t>(DEVICE_MODEL_USRP);
53  radiodevice = argv[8];
54  radioaddr = stoi(radiodevice.substr(radiodevice.find(':')+1));
55  radiodevice = radiodevice.substr(0, radiodevice.find(':'));
56  }
57  else if (static_cast<string>("direct") == argv[3])
58  {
59  model = static_cast<uint16_t>(DEVICE_MODEL_DIRECT);
60  radiodevice = argv[8];
61  radiodevice = "";
62  }
63  case 8:
64  if (static_cast<string>("txr") == argv[4])
65  {
66  radiotype = static_cast<uint16_t>(DeviceType::TXR);
67  }
68  else if (static_cast<string>("rxr") == argv[4])
69  {
70  radiotype = static_cast<uint16_t>(DeviceType::RXR);
71  }
72  else if (static_cast<string>("tcv") == argv[4])
73  {
74  radiotype = static_cast<uint16_t>(DeviceType::TCV);
75  }
76  freq = atof(argv[5]);
77  band = atof(argv[6]);
78  if (static_cast<string>("am") == argv[7])
79  {
80  opmode = static_cast<uint16_t>(DEVICE_RADIO_MODE_AM);
81  }
82  else if (static_cast<string>("amd") == argv[7])
83  {
84  opmode = static_cast<uint16_t>(DEVICE_RADIO_MODE_AMD);
85  }
86  else if (static_cast<string>("fm") == argv[7])
87  {
88  opmode = static_cast<uint16_t>(DEVICE_RADIO_MODE_FM);
89  }
90  else if (static_cast<string>("fmd") == argv[7])
91  {
92  opmode = static_cast<uint16_t>(DEVICE_RADIO_MODE_FMD);
93  }
94  else if (static_cast<string>("lsb") == argv[7])
95  {
96  opmode = static_cast<uint16_t>(DEVICE_RADIO_MODE_LSB);
97  }
98  else if (static_cast<string>("lsbd") == argv[7])
99  {
100  opmode = static_cast<uint16_t>(DEVICE_RADIO_MODE_LSBD);
101  }
102  else if (static_cast<string>("usb") == argv[7])
103  {
104  opmode = static_cast<uint16_t>(DEVICE_RADIO_MODE_USB);
105  }
106  else if (static_cast<string>("usbd") == argv[7])
107  {
108  opmode = static_cast<uint16_t>(DEVICE_RADIO_MODE_USBD);
109  }
110  else if (static_cast<string>("dv") == argv[7])
111  {
112  opmode = static_cast<uint16_t>(DEVICE_RADIO_MODE_DV);
113  }
114  else if (static_cast<string>("dvd") == argv[7])
115  {
116  opmode = static_cast<uint16_t>(DEVICE_RADIO_MODE_DVD);
117  }
118  else if (static_cast<string>("cw") == argv[7])
119  {
120  opmode = static_cast<uint16_t>(DEVICE_RADIO_MODE_CW);
121  }
122  else if (static_cast<string>("cwr") == argv[7])
123  {
124  opmode = static_cast<uint16_t>(DEVICE_RADIO_MODE_CWR);
125  }
126  else if (static_cast<string>("rtty") == argv[7])
127  {
128  opmode = static_cast<uint16_t>(DEVICE_RADIO_MODE_RTTY);
129  }
130  else if (static_cast<string>("rttyr") == argv[7])
131  {
132  opmode = static_cast<uint16_t>(DEVICE_RADIO_MODE_RTTYR);
133  }
134  nodename = argv[2];
135  radioname = argv[1];
136  break;
137  default:
138  printf("Usage: add_radio radioname [nodename [ic9100/astrodev txr/rxr/tcv frequency bandwidth mode {device:addr}]]\n");
139  exit (1);
140  break;
141  }
142 
143  // Establish the command channel and heartbeat
144  agent = new Agent(nodename);
145 
146  if ((iretn = agent->wait()) < 0)
147  {
148  fprintf(agent->get_debug_fd(), "%16.10f %s Failed to start Agent %s on Node %s Dated %s : %s\n",currentmjd(), mjd2iso8601(currentmjd()).c_str(), agent->getAgent().c_str(), agent->getNode().c_str(), utc2iso8601(data_ctime(argv[0])).c_str(), cosmos_error_string(iretn).c_str());
149  exit(iretn);
150  }
151 
152  if (argc > 6)
153  {
155  switch (radiotype)
156  {
157  case static_cast<uint16_t>(DeviceType::TXR):
159  deviceindex = agent->cinfo->pieces[static_cast <uint16_t>(iretn)].cidx;
161  agent->cinfo->device[deviceindex].txr.freq = freq;
162  agent->cinfo->device[deviceindex].txr.band = band;
163  agent->cinfo->device[deviceindex].txr.opmode = opmode;
164  break;
165  case static_cast<uint16_t>(DeviceType::RXR):
167  deviceindex = agent->cinfo->pieces[static_cast <uint16_t>(iretn)].cidx;
169  agent->cinfo->device[deviceindex].rxr.freq = freq;
170  agent->cinfo->device[deviceindex].rxr.band = band;
171  agent->cinfo->device[deviceindex].rxr.opmode = opmode;
172  break;
173  case static_cast<uint16_t>(DeviceType::TCV):
175  deviceindex = agent->cinfo->pieces[static_cast <uint16_t>(iretn)].cidx;
177  agent->cinfo->device[deviceindex].tcv.freq = freq;
178  agent->cinfo->device[deviceindex].tcv.band = band;
179  agent->cinfo->device[deviceindex].tcv.opmode = opmode;
180  break;
181  }
182  agent->cinfo->device[deviceindex].model = model;
184  agent->cinfo->device[deviceindex].tcv.freq = freq;
185  agent->cinfo->device[deviceindex].tcv.band = band;
186  agent->cinfo->device[deviceindex].tcv.opmode = opmode;
187  if (model == static_cast<uint16_t>(DEVICE_MODEL_IC9100))
188  {
191  if (iretn >= 0)
192  {
193  agent->cinfo->device[deviceindex].portidx = iretn;
194  }
195  }
196  else if (model == static_cast<uint16_t>(DEVICE_MODEL_TS2000))
197  {
199  if (iretn >= 0)
200  {
201  agent->cinfo->device[deviceindex].portidx = iretn;
202  }
203  }
204  else if (model == static_cast<uint16_t>(DEVICE_MODEL_USRP))
205  {
208  if (iretn >= 0)
209  {
210  agent->cinfo->device[deviceindex].portidx = iretn;
211  }
212  }
213  iretn = json_dump_node(agent->cinfo);
214  }
215 
216 }
Radio Receiver.
Definition: jsondef.h:508
Definition: jsondef.h:575
Definition: jsondef.h:561
FILE * get_debug_fd(double mjd=0.)
Definition: agentclass.cpp:2645
Definition: jsondef.h:585
Definition: jsondef.h:584
static float band
Definition: add_radio.cpp:22
string getNode()
Listen for heartbeat.
Definition: agentclass.cpp:2607
static std::string radioname
Definition: add_radio.cpp:8
Definition: jsondef.h:581
static Agent * agent
Definition: add_radio.cpp:6
Definition: jsondef.h:574
static uint16_t nodetype
Definition: add_radio.cpp:18
int iretn
Definition: rw_test.cpp:37
Definition: jsondef.h:576
int32_t wait(State state=State::RUN, double waitsec=10.)
Definition: agentclass.cpp:398
Definition: jsondef.h:567
Definition: jsondef.h:579
static size_t deviceindex
Definition: add_radio.cpp:9
Definition: cosmos-defs.h:91
int32_t json_dump_node(cosmosstruc *cinfo)
Save Node entries to disk.
Definition: jsonlib.cpp:7233
vector< devicestruc > device
Vector of all general (common) information for devices (components) in node.
Definition: jsondef.h:4238
nodestruc node
Structure for summary information in node.
Definition: jsondef.h:4220
string cosmos_error_string(int32_t cosmos_errno)
Definition: cosmos-errno.cpp:45
Definition: jsondef.h:651
Definition: jsondef.h:572
Radio Transceiver.
Definition: jsondef.h:512
Definition: jsondef.h:583
static uint16_t model
Definition: add_radio.cpp:19
string getAgent()
Definition: agentclass.cpp:2609
Definition: agentclass.h:139
static uint16_t radioaddr
Definition: add_radio.cpp:12
static float freq
Definition: add_radio.cpp:21
Definition: jsondef.h:580
static string radiodevice
Definition: add_radio.cpp:11
double data_ctime(string path)
Definition: datalib.cpp:1910
static uint8_t opmode
Definition: add_radio.cpp:23
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
static uint16_t radiotype
Definition: add_radio.cpp:20
Definition: jsondef.h:582
string utc2iso8601(double utc)
ISO 8601 version of time.
Definition: timelib.cpp:1286
Definition: jsondef.h:573
vector< piecestruc > pieces
Vector of all pieces in node.
Definition: jsondef.h:4232
Definition: jsondef.h:645
int32_t json_createpiece(cosmosstruc *cinfo, string name, DeviceType ctype, double emi, double abs, double hcap, double hcon, double density)
Create new piece.
Definition: jsonlib.cpp:722
cosmosstruc * cinfo
Definition: agentclass.h:346
Definition: jsondef.h:568
static size_t radioindex
Definition: add_radio.cpp:10
Definition: jsondef.h:560
string mjd2iso8601(double mjd)
Definition: timelib.cpp:1316
uint16_t type
Node Type as listed in NODE_TYPE.
Definition: jsondef.h:3562
Radio Transmitter.
Definition: jsondef.h:510
Definition: jsondef.h:578
static std::string nodename
Definition: add_radio.cpp:7
Definition: jsondef.h:562
Definition: jsondef.h:577
int32_t json_createport(cosmosstruc *cinfo, string name, PORT_TYPE type)
Definition: jsonlib.cpp:1086

Variable Documentation

ic9100_handle ic9100
static
Agent* agent
static
std::string nodename =""
static
std::string radioname
static
size_t deviceindex
static
size_t radioindex = 9999
static
string radiodevice =""
static
uint16_t radioaddr
static
string port
static
uint16_t nodetype = NODE_TYPE_SATELLITE
static
uint16_t model = DEVICE_MODEL_DIRECT
static
uint16_t radiotype = static_cast<uint16_t>(DeviceType::NONE)
static
float freq
static
float band
static
uint8_t opmode = static_cast<uint8_t>(DEVICE_RADIO_MODE_UNDEF)
static
double value1 = 0.
double value2 = 0.
string command = ""