COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
Cosmos::Devices::Prkx2su Class Reference

#include <prkx2su_class.h>

Collaboration diagram for Cosmos::Devices::Prkx2su:

Public Member Functions

 Prkx2su (string dev)
 
int32_t init (string device)
 
int32_t connect ()
 
int32_t disconnect ()
 
int32_t get_status (uint8_t axis)
 
float get_az ()
 
float get_el ()
 
int32_t get_az_el (float &az, float &el)
 
float get_az_offset ()
 
float get_el_offset ()
 
int32_t gotoazel (float az, float el)
 
int32_t stop (uint8_t axis)
 
int32_t ramp (uint8_t axis, uint8_t speed)
 
int32_t minimum_speed (uint8_t axis, uint8_t speed)
 
int32_t maximum_speed (uint8_t axis, uint8_t speed)
 
int32_t getdata (uint8_t axis, string &buf, uint16_t buflen)
 
int32_t send (uint8_t axis, string buf, bool force)
 
int32_t test (uint8_t axis)
 
int32_t set_sensitivity (float sensitivity)
 
int32_t get_limits (uint8_t axis)
 
int32_t write_calibration (uint8_t axis, float value)
 

Public Attributes

uint8_t azid
 
uint8_t azstatus
 
int32_t az_center
 
int32_t az_mode
 
int32_t az_offset_waiting
 
float az_offset
 
float minaz
 
float maxaz
 
float currentaz
 
float targetaz
 
uint8_t elid
 
uint8_t elstatus
 
int32_t el_offset_waiting
 
float el_offset
 
float minel
 
float maxel
 
float currentel
 
float targetel
 
float minimumel
 
float sensitivity
 
int32_t in_command
 
int32_t data_received
 
Serialserial [2]
 

Constructor & Destructor Documentation

Cosmos::Devices::Prkx2su::Prkx2su ( string  dev)
7  {
8  string device;
9 
10  device = dev + "_az";
12  device = dev + "_el";
14 
15  }
#define PRKX2SU_STOPBITS
Definition: prkx2su_class.h:14
Definition: serialclass.h:43
#define PRKX2SU_AXIS_EL
Definition: prkx2su_class.h:16
Serial * serial[2]
Definition: prkx2su_class.h:49
#define PRKX2SU_BAUD
Definition: prkx2su_class.h:11
#define PRKX2SU_AXIS_AZ
Definition: prkx2su_class.h:15
#define PRKX2SU_PARITY
Definition: prkx2su_class.h:13
#define PRKX2SU_BITS
Definition: prkx2su_class.h:12
static string device
Definition: ax25_recv.cpp:39

Member Function Documentation

int32_t Cosmos::Devices::Prkx2su::init ( string  device)
int32_t Cosmos::Devices::Prkx2su::connect ( )

Connects to am MII prkx2su antenna controller, which in turn drives a Yaesu G-5500 antenna controller.

Parameters
devpointer to a character string with the serial port it is connected to.
See also
cssl_start
cssl_open
cssl_setflowcontrol
27  {
28  int32_t iretn;
29 
30  if (serial[PRKX2SU_AXIS_AZ]->get_open())
31  {
32  iretn = Prkx2su::disconnect();
33  if (iretn < 0)
34  {
35  return iretn;
36  }
37  }
38 
40  if (iretn < 0)
41  {
42  return iretn;
43  }
44 
45  iretn = serial[PRKX2SU_AXIS_AZ]->set_timeout(.5);
46  if (iretn < 0)
47  {
49  return iretn;
50  }
51 
52  iretn = Prkx2su::send(PRKX2SU_AXIS_AZ, "", true);
53  if (iretn < 0)
54  {
56  return iretn;
57  }
58 
59  if (serial[PRKX2SU_AXIS_EL]->get_open())
60  {
61  return SERIAL_ERROR_OPEN;
62  }
63 
65  if (iretn < 0)
66  {
68  return iretn;
69  }
70 
71  iretn = serial[PRKX2SU_AXIS_EL]->set_timeout(.5);
72  if (iretn < 0)
73  {
75  return iretn;
76  }
77 
78  iretn = Prkx2su::send(PRKX2SU_AXIS_EL, "", true);
79  if (iretn < 0)
80  {
82  return iretn;
83  }
84 
85  return 0;
86  }
int32_t send(uint8_t axis, string buf, bool force)
Definition: prkx2su_class.cpp:444
int iretn
Definition: rw_test.cpp:37
#define PRKX2SU_AXIS_EL
Definition: prkx2su_class.h:16
Serial * serial[2]
Definition: prkx2su_class.h:49
#define PRKX2SU_AXIS_AZ
Definition: prkx2su_class.h:15
int32_t disconnect()
Definition: prkx2su_class.cpp:91
int32_t open_device()
Definition: serialclass.cpp:60
int32_t set_timeout(int, double timeout)
Definition: serialclass.cpp:515
#define SERIAL_ERROR_OPEN
Definition: cosmos-errno.h:177
int32_t Cosmos::Devices::Prkx2su::disconnect ( )

Close currently open prkx2su.

92  {
93  int32_t iretn = 0;
94  if (serial[PRKX2SU_AXIS_AZ]->get_open())
95  {
97  }
98 
99  if (serial[PRKX2SU_AXIS_EL] != nullptr)
100  {
101  iretn = serial[PRKX2SU_AXIS_EL]->close_device();
102  }
103 
104  return iretn;
105  }
int32_t close_device()
Definition: serialclass.cpp:126
int iretn
Definition: rw_test.cpp:37
#define PRKX2SU_AXIS_EL
Definition: prkx2su_class.h:16
Serial * serial[2]
Definition: prkx2su_class.h:49
#define PRKX2SU_AXIS_AZ
Definition: prkx2su_class.h:15
int32_t Cosmos::Devices::Prkx2su::get_status ( uint8_t  axis)

Poll controller for Status and Heading. Turns calibration mode on in prkx2su.

Parameters
axis32 bit signed integer , 0 = Azimuth, 1 = Elevation
145  {
146  int32_t iretn;
147  iretn = Prkx2su::send(axis, "BIn;", true);
148  if (iretn < 0)
149  {
150  return iretn;
151  }
152  string buf;
153  iretn = Prkx2su::getdata(axis, buf, 2000);
154  if (iretn < 0)
155  {
156  return iretn;
157  }
158  switch (axis)
159  {
160  case PRKX2SU_AXIS_AZ:
161  sscanf(buf.c_str(), "%c%c%f", &azid, &azstatus, &currentaz);
162  currentaz = RADOF(currentaz);
163  break;
164  case PRKX2SU_AXIS_EL:
165  sscanf(buf.c_str(), "%c%c%f", &elid, &elstatus, &currentel);
166  currentel = RADOF(currentel);
167  break;
168  }
169  return iretn;
170  }
uint8_t elid
Definition: prkx2su_class.h:36
int32_t send(uint8_t axis, string buf, bool force)
Definition: prkx2su_class.cpp:444
int iretn
Definition: rw_test.cpp:37
#define PRKX2SU_AXIS_EL
Definition: prkx2su_class.h:16
int32_t getdata(uint8_t axis, string &buf, uint16_t buflen)
Definition: prkx2su_class.cpp:115
#define PRKX2SU_AXIS_AZ
Definition: prkx2su_class.h:15
uint8_t azstatus
Definition: prkx2su_class.h:27
uint8_t azid
Definition: prkx2su_class.h:26
float currentaz
Definition: prkx2su_class.h:34
char buf[128]
Definition: rw_test.cpp:40
uint8_t elstatus
Definition: prkx2su_class.h:37
float currentel
Definition: prkx2su_class.h:42
#define RADOF(deg)
Radians of a Degree value.
Definition: math/constants.h:29
float Cosmos::Devices::Prkx2su::get_az ( )
354  {
355  return (currentaz);
356  }
float currentaz
Definition: prkx2su_class.h:34
float Cosmos::Devices::Prkx2su::get_el ( )
359  {
360  return (currentel);
361  }
float currentel
Definition: prkx2su_class.h:42
int32_t Cosmos::Devices::Prkx2su::get_az_el ( float &  az,
float &  el 
)
364  {
365  int32_t iretn = 0;
366 
368  if (iretn >= 0)
369  {
371  if (iretn >= 0)
372  {
373  az = currentaz;
374  el = currentel;
375  }
376  }
377  return iretn;
378  }
int iretn
Definition: rw_test.cpp:37
#define PRKX2SU_AXIS_EL
Definition: prkx2su_class.h:16
#define PRKX2SU_AXIS_AZ
Definition: prkx2su_class.h:15
float currentaz
Definition: prkx2su_class.h:34
int32_t get_status(uint8_t axis)
Definition: prkx2su_class.cpp:144
float currentel
Definition: prkx2su_class.h:42
float Cosmos::Devices::Prkx2su::get_az_offset ( )
411  {
412  return (az_offset);
413  }
float az_offset
Definition: prkx2su_class.h:31
float Cosmos::Devices::Prkx2su::get_el_offset ( )
416  {
417  return (el_offset);
418  }
float el_offset
Definition: prkx2su_class.h:39
int32_t Cosmos::Devices::Prkx2su::gotoazel ( float  az,
float  el 
)
299  {
300  int32_t iretn;
301  char out[50];
302 
303  az = fmodf(az, D2PI);
304  if (az < 0.)
305  {
306  az += D2PI;
307  }
308 // if (az < Prkx2su::minaz)
309 // {
310 // az = Prkx2su::minaz;
311 // }
312 // else if (az > Prkx2su::maxaz)
313 // {
314 // az = Prkx2su::maxaz;
315 // }
316 
317  el = fmodf(el, DPI);
318  if (el < Prkx2su::minel)
319  {
320  el = Prkx2su::minel;
321  }
322  else if (el > Prkx2su::maxel)
323  {
324  el = Prkx2su::maxel;
325  }
326 
327  float daz = az - targetaz;
328  float del = el - targetel;
329  float sep = sqrtf(daz*daz+del*del);
330 
331  if (sep > sensitivity)
332  {
333  targetaz = az;
334  targetel = el;
335  az = DEGOF(az);
336  el = DEGOF(el);
337  sprintf(out, "APn%03d.%1d\r;", static_cast <uint16_t>(az), static_cast <uint16_t>(10 * (az - static_cast <uint16_t>(az))));
338  iretn = Prkx2su::send(PRKX2SU_AXIS_AZ, out, true);
339  if (iretn >= 0)
340  {
341  sprintf(out, "APn%03d.%1d\r;", static_cast <uint16_t>(el), static_cast <uint16_t>(10 * (el - static_cast <uint16_t>(el))));
342  iretn = Prkx2su::send(PRKX2SU_AXIS_EL, out, true);
343  if (iretn >= 0)
344  {
346  }
347  }
348  }
349 
350  return 0;
351  }
float targetaz
Definition: prkx2su_class.h:35
int32_t send(uint8_t axis, string buf, bool force)
Definition: prkx2su_class.cpp:444
float sensitivity
Definition: prkx2su_class.h:45
int iretn
Definition: rw_test.cpp:37
#define PRKX2SU_AXIS_EL
Definition: prkx2su_class.h:16
int32_t get_az_el(float &az, float &el)
Definition: prkx2su_class.cpp:363
#define PRKX2SU_AXIS_AZ
Definition: prkx2su_class.h:15
float maxel
Definition: prkx2su_class.h:41
#define DEGOF(rad)
Degrees of a Radian value.
Definition: math/constants.h:33
float targetel
Definition: prkx2su_class.h:43
float currentaz
Definition: prkx2su_class.h:34
const double D2PI
Double precision 2*PI.
Definition: math/constants.h:16
float currentel
Definition: prkx2su_class.h:42
const double DPI
Double precision PI.
Definition: math/constants.h:14
float minel
Definition: prkx2su_class.h:40
int32_t Cosmos::Devices::Prkx2su::stop ( uint8_t  axis)

Routine to stop current action. Whatever the current command is, it will cancelled before completeion.

Returns
0 or negative error.
235  {
236  int32_t iretn;
237  iretn = Prkx2su::send(axis, ";", true);
238  return iretn;
239  }
int32_t send(uint8_t axis, string buf, bool force)
Definition: prkx2su_class.cpp:444
int iretn
Definition: rw_test.cpp:37
int32_t Cosmos::Devices::Prkx2su::ramp ( uint8_t  axis,
uint8_t  speed 
)
242  {
243  int32_t iretn;
244  char out[50];
245 
246  if (speed < 1 || speed > 10)
247  return (PRKX2SU_ERROR_OUTOFRANGE);
248  sprintf(out,"WNn%03hhu;", speed);
249  iretn = Prkx2su::send(axis, out, true);
250  if (iretn < 0)
251  {
252  return iretn;
253  }
254  else
255  {
256  return (speed);
257  }
258  }
int32_t send(uint8_t axis, string buf, bool force)
Definition: prkx2su_class.cpp:444
int iretn
Definition: rw_test.cpp:37
#define PRKX2SU_ERROR_OUTOFRANGE
Definition: cosmos-errno.h:251
float speed
Definition: netperf_send.cpp:40
int32_t Cosmos::Devices::Prkx2su::minimum_speed ( uint8_t  axis,
uint8_t  speed 
)
261  {
262  int32_t iretn;
263  char out[50];
264 
265  if (speed < 1 || speed > 10)
266  return (PRKX2SU_ERROR_OUTOFRANGE);
267  sprintf(out,"WFn%03hhu;", speed);
268  iretn = Prkx2su::send(axis, out, true);
269  if (iretn < 0)
270  {
271  return iretn;
272  }
273  else
274  {
275  return (speed);
276  }
277  }
int32_t send(uint8_t axis, string buf, bool force)
Definition: prkx2su_class.cpp:444
int iretn
Definition: rw_test.cpp:37
#define PRKX2SU_ERROR_OUTOFRANGE
Definition: cosmos-errno.h:251
float speed
Definition: netperf_send.cpp:40
int32_t Cosmos::Devices::Prkx2su::maximum_speed ( uint8_t  axis,
uint8_t  speed 
)
280  {
281  int32_t iretn;
282  char out[50];
283 
284  if (speed < 1 || speed > 10)
285  return (PRKX2SU_ERROR_OUTOFRANGE);
286  sprintf(out,"WGn%03hhu;", speed);
287  iretn = Prkx2su::send(axis, out, true);
288  if (iretn < 0)
289  {
290  return iretn;
291  }
292  else
293  {
294  return (speed);
295  }
296  }
int32_t send(uint8_t axis, string buf, bool force)
Definition: prkx2su_class.cpp:444
int iretn
Definition: rw_test.cpp:37
#define PRKX2SU_ERROR_OUTOFRANGE
Definition: cosmos-errno.h:251
float speed
Definition: netperf_send.cpp:40
int32_t Cosmos::Devices::Prkx2su::getdata ( uint8_t  axis,
string &  buf,
uint16_t  buflen 
)

Routine to use in blocking mode. Reads the serial port until a New Line is received, then returns entire buffer.

Parameters
axisAxis to read.
bufPointer to a char buffer
buflen32 bit signed integer indicating the maximum size of the buffer
Returns
32 bit signed integer containing the number of bytes read.
116  {
117  int32_t j;
118 
119  buf.clear();
120  while((j=serial[axis]->get_char()) >= 0)
121  {
122  buf.push_back(static_cast<char>(j));
123  if (j == ';' || static_cast<uint16_t>(buf.size()) == buflen)
124  {
125  break;
126  }
127  }
128 
129  if (j < 0)
130  {
131  return j;
132  }
133  else
134  {
135  return static_cast<int32_t>(buf.size());
136  }
137  }
Serial * serial[2]
Definition: prkx2su_class.h:49
char buf[128]
Definition: rw_test.cpp:40
int32_t Cosmos::Devices::Prkx2su::send ( uint8_t  axis,
string  buf,
bool  force 
)
445  {
446  int32_t iretn = 0;
447  string lastbuf;
448 
449  iretn = Prkx2su::test(axis);
450  if (iretn < 0)
451  {
452  return iretn;
453  }
454 
455  if (lastbuf != buf || force)
456  {
457  serial[axis]->put_string(buf);
458  lastbuf = buf;
459  }
460 
461  return iretn;
462  }
int32_t put_string(string data)
Definition: serialclass.cpp:686
int32_t test(uint8_t axis)
Definition: prkx2su_class.cpp:420
int iretn
Definition: rw_test.cpp:37
Serial * serial[2]
Definition: prkx2su_class.h:49
char buf[128]
Definition: rw_test.cpp:40
int32_t Cosmos::Devices::Prkx2su::test ( uint8_t  axis)
421  {
422  int32_t iretn;
423 
424  iretn = serial[axis]->put_string("R10;");
425  if (iretn < 0)
426  {
427  return iretn;
428  }
429 
430  string buf;
431  iretn = Prkx2su::getdata(axis, buf, 100);
432  if (iretn < 0)
433  {
434  return iretn;
435  }
436  if (buf[0] != '1' || buf[1] != 0x1 || buf[buf.size()-1] != ';')
437  {
438  return PRKX2SU_ERROR_SEND;
439  }
440 
441  return 0;
442  }
int32_t put_string(string data)
Definition: serialclass.cpp:686
int iretn
Definition: rw_test.cpp:37
Serial * serial[2]
Definition: prkx2su_class.h:49
int32_t getdata(uint8_t axis, string &buf, uint16_t buflen)
Definition: prkx2su_class.cpp:115
#define PRKX2SU_ERROR_SEND
Definition: cosmos-errno.h:252
char buf[128]
Definition: rw_test.cpp:40
int32_t Cosmos::Devices::Prkx2su::set_sensitivity ( float  sensitivity)
465  {
467  return 0;
468  }
float sensitivity
Definition: prkx2su_class.h:45
int32_t Cosmos::Devices::Prkx2su::get_limits ( uint8_t  axis)
173  {
174  string buf;
175  int32_t iretn;
176  iretn = Prkx2su::send(axis, "RH0;", true);
177  if (iretn < 0)
178  {
179  return iretn;
180  }
181  iretn = Prkx2su::getdata(axis, buf, 200);
182  if (iretn < 0)
183  {
184  return iretn;
185  }
186  switch (axis)
187  {
188  case PRKX2SU_AXIS_AZ:
189  sscanf(buf.c_str(), "%*2c%f", &minaz);
190  if (minaz > 0)
191  {
192  minaz -= 360;
193  }
194  minaz = RADOF(minaz);
195  break;
196  case PRKX2SU_AXIS_EL:
197  sscanf(buf.c_str(), "%*2c%f", &minel);
198  minel = RADOF(minel);
199  break;
200  }
201  iretn = Prkx2su::send(axis, "RI0;", true);
202  if (iretn < 0)
203  {
204  return iretn;
205  }
206  iretn = getdata(axis, buf, 200);
207  if (iretn < 0)
208  {
209  return iretn;
210  }
211  switch (axis)
212  {
213  case PRKX2SU_AXIS_AZ:
214  sscanf(buf.c_str(), "%*2c%f", &maxaz);
215  if (maxaz < 0.)
216  {
217  maxaz += 360.;
218  }
219  maxaz = RADOF(maxaz);
220  break;
221  case PRKX2SU_AXIS_EL:
222  sscanf(buf.c_str(), "%*2c%f", &maxel);
223  maxel = RADOF(maxel);
224  break;
225  }
226  return iretn;
227  }
int32_t send(uint8_t axis, string buf, bool force)
Definition: prkx2su_class.cpp:444
int iretn
Definition: rw_test.cpp:37
#define PRKX2SU_AXIS_EL
Definition: prkx2su_class.h:16
float maxaz
Definition: prkx2su_class.h:33
int32_t getdata(uint8_t axis, string &buf, uint16_t buflen)
Definition: prkx2su_class.cpp:115
#define PRKX2SU_AXIS_AZ
Definition: prkx2su_class.h:15
float maxel
Definition: prkx2su_class.h:41
float minaz
Definition: prkx2su_class.h:32
char buf[128]
Definition: rw_test.cpp:40
float minel
Definition: prkx2su_class.h:40
#define RADOF(deg)
Radians of a Degree value.
Definition: math/constants.h:29
int32_t Cosmos::Devices::Prkx2su::write_calibration ( uint8_t  axis,
float  value 
)
381  {
382  int32_t iretn;
383  char out[50];
384 
385  if (value < 0.)
386  {
387  value = 0.;
388  }
389  switch (axis)
390  {
391  case PRKX2SU_AXIS_AZ:
392  if (value > D2PI)
393  {
394  value = D2PI;
395  }
396  break;
397  case PRKX2SU_AXIS_EL:
398  if (value > DPI)
399  {
400  value = DPI;
401  }
402  }
403 
404  value = DEGOF(value);
405  sprintf(out, "Awn%03d.%1d;", (int16_t)value, (int16_t)(10 * (value - (int16_t)value)));
406  iretn = Prkx2su::send(axis, out, true);
407  return iretn;
408  }
int32_t send(uint8_t axis, string buf, bool force)
Definition: prkx2su_class.cpp:444
int iretn
Definition: rw_test.cpp:37
#define PRKX2SU_AXIS_EL
Definition: prkx2su_class.h:16
#define PRKX2SU_AXIS_AZ
Definition: prkx2su_class.h:15
#define DEGOF(rad)
Degrees of a Radian value.
Definition: math/constants.h:33
const double D2PI
Double precision 2*PI.
Definition: math/constants.h:16
const double DPI
Double precision PI.
Definition: math/constants.h:14

Member Data Documentation

uint8_t Cosmos::Devices::Prkx2su::azid
uint8_t Cosmos::Devices::Prkx2su::azstatus
int32_t Cosmos::Devices::Prkx2su::az_center
int32_t Cosmos::Devices::Prkx2su::az_mode
int32_t Cosmos::Devices::Prkx2su::az_offset_waiting
float Cosmos::Devices::Prkx2su::az_offset
float Cosmos::Devices::Prkx2su::minaz
float Cosmos::Devices::Prkx2su::maxaz
float Cosmos::Devices::Prkx2su::currentaz
float Cosmos::Devices::Prkx2su::targetaz
uint8_t Cosmos::Devices::Prkx2su::elid
uint8_t Cosmos::Devices::Prkx2su::elstatus
int32_t Cosmos::Devices::Prkx2su::el_offset_waiting
float Cosmos::Devices::Prkx2su::el_offset
float Cosmos::Devices::Prkx2su::minel
float Cosmos::Devices::Prkx2su::maxel
float Cosmos::Devices::Prkx2su::currentel
float Cosmos::Devices::Prkx2su::targetel
float Cosmos::Devices::Prkx2su::minimumel
float Cosmos::Devices::Prkx2su::sensitivity
int32_t Cosmos::Devices::Prkx2su::in_command
int32_t Cosmos::Devices::Prkx2su::data_received
Serial* Cosmos::Devices::Prkx2su::serial[2]

The documentation for this class was generated from the following files: