nidas  v1.2-1520
SE_GOESXmtr.h
Go to the documentation of this file.
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2 // vim: set shiftwidth=4 softtabstop=4 expandtab:
3 /*
4  ********************************************************************
5  ** NIDAS: NCAR In-situ Data Acquistion Software
6  **
7  ** 2006, Copyright University Corporation for Atmospheric Research
8  **
9  ** This program is free software; you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation; either version 2 of the License, or
12  ** (at your option) any later version.
13  **
14  ** This program is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** The LICENSE.txt file accompanying this software contains
20  ** a copy of the GNU General Public License. If it is not found,
21  ** write to the Free Software Foundation, Inc.,
22  ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  **
24  ********************************************************************
25 */
26 
27 #ifndef NIDAS_DYNLD_ISFF_SE_GOESXMTR_H
28 #define NIDAS_DYNLD_ISFF_SE_GOESXMTR_H
29 
30 #include "GOESXmtr.h"
31 #include <nidas/core/IOChannel.h>
32 #include <nidas/core/SampleTag.h>
33 #include <nidas/util/UTime.h>
34 #include <nidas/util/Logger.h>
36 
37 #include <string>
38 #include <iostream>
39 #include <vector>
40 
41 namespace nidas { namespace dynld { namespace isff {
42 
43 using namespace nidas::core;
44 
49 class SE_GOESXmtr: public GOESXmtr {
50 
51 public:
52 
56  SE_GOESXmtr();
57 
61  SE_GOESXmtr(const SE_GOESXmtr&);
62 
66  ~SE_GOESXmtr();
67 
71  SE_GOESXmtr* clone() const { return new SE_GOESXmtr(*this); }
72 
77  void setRFBaud(long val) throw(nidas::util::InvalidParameterException);
78 
79  int getRFBaud() const
80  {
81  return _rfBaud;
82  }
83 
84  void init() throw (nidas::util::IOException);
85 
90  int getModel() const { return _model; }
91 
92  void setModel(int val) { _model = val; }
93 
99  int getMaxRFBaud() const { return _maxRFBaud; }
100 
101  virtual bool isNewFile() const { return false; }
102 
106  void transmitData(const nidas::util::UTime& sendTime,
107  int configid,const Sample*)
108  throw (nidas::util::IOException);
109 
113  void transmitDataSE110(const nidas::util::UTime& sendTime,
114  int configid,const Sample*)
115  throw (nidas::util::IOException);
116 
117  void transmitDataSE120(const nidas::util::UTime& sendTime,
118  int configid,const Sample*)
119  throw (nidas::util::IOException);
120 
121  void close() throw (nidas::util::IOException)
122  {
123  _port.close();
124  }
125 
131  size_t send(const std::string& msg) throw(nidas::util::IOException);
132 
136  size_t send(char c) throw(nidas::util::IOException);
137 
147  std::string recv() throw(nidas::util::IOException);
148 
149  void flush() throw(nidas::util::IOException)
150  {
151  _port.flushBoth();
152  }
153 
160  static std::string fix(const std::string& msg);
161 
167  static std::string unfix(const std::string& msg);
168 
172  static char crc(const std::string& msg);
173 
174  void encodeClock(const nidas::util::UTime& ut,char* out,bool fractsecs);
175 
176  nidas::util::UTime decodeClock(const char* in);
177 
181  void wakeup() throw(nidas::util::IOException);
182 
186  void tosleep() throw(nidas::util::IOException);
187 
193  void query() throw(nidas::util::IOException);
194 
195  int detectModel() throw(nidas::util::IOException);
196 
197  bool testTransmitSE120() throw(nidas::util::IOException);
198 
199  void cancelTransmit(const nidas::util::UTime& at)
200  throw(nidas::util::IOException);
201 
207  int checkStatus() throw(nidas::util::IOException);
208 
209  void printStatus() throw();
210 
211  void printStatus(std::ostream&) throw();
212 
213  void setXmtrId() throw(nidas::util::IOException);
214 
215  unsigned long getXmtrId() throw(nidas::util::IOException);
216 
217  void setXmtrClock() throw(nidas::util::IOException);
218 
219  nidas::util::UTime getXmtrClock() throw(nidas::util::IOException);
220 
233  int getXmtrClockDelay(int nchar) const;
234 
235  unsigned long checkId() throw(nidas::util::IOException);
236 
237  int checkClock() throw(nidas::util::IOException);
238 
239  void transmitDataSE110() throw(nidas::util::IOException);
240 
241  void reset() throw(nidas::util::IOException);
242 
243  void doSelfTest() throw(nidas::util::IOException);
244 
252  int getSelfTestResults() throw(nidas::util::IOException);
253 
254  static std::string codeString(char pktType);
255 
262  void checkResponse(char ptype,const std::string& resp)
263  throw(nidas::util::IOException);
264 
271  void checkACKResponse(char ptype,const std::string& resp,char seqnum)
272  throw(nidas::util::IOException);
273 
279  void getBatteryVoltages(float &current, float& before, float& during)
280  throw(nidas::util::IOException);
281 
286  static const char SOH = '\x1';
287 
292  static const char EOT = '\x4';
293 
294  static const std::string SOH_STR;
295 
296  struct SE_Codes {
297  int value;
298  const char* msg;
299  };
300 
301  std::string getSelfTestStatusString();
302 
304  static const char PKT_GET_ID = '\x10';
305 
307  static const char PKT_SET_ID = '\x11';
308 
310  static const char PKT_SET_TIME = '\x13';
311 
313  static const char PKT_GET_TIME = '\x14';
314 
316  static const char PKT_XMT_DATA = '\x15';
317 
319  static const char PKT_CANCEL_XMT = '\x16';
320 
321  static const char PKT_GET_XMT_QUE = '\x17';
322 
323  static const char PKT_QUERY = '\x18';
324 
326  static const char PKT_SET_GLOBALS = '\x1b';
327 
329  static const char PKT_GET_GLOBALS = '\x1c';
330 
332  static const char PKT_DISPLAY_VERSION = '\x1d';
333 
335  static const char PKT_XMT_DATA_SE120 = '\x1e';
336 
337  static const char PKT_POLL_ENABLE = 0x38;
338  static const char PKT_POLL_DATA_GET = 0x39;
339  static const char PKT_POLL_DATA_SET = 0x3a;
340 
342  static const char PKT_GET_SE1200_STATUS = '\x74';
343 
344  static const char PKT_RESET_XMTR = '\x76';
345 
346  static const char PKT_SELFTEST_DISPL = '\x77';
347 
348  static const char PKT_SELFTEST_START = '\x78';
349 
350  static const char PKT_SEND_FIXED_CHAN = '\x7a';
351 
353  static const char PKT_SOFTWARE_LOAD = '\x7c';
354 
355  /* Acknowledge from xmtr to a xmt data request,
356  * load SDI script or polled xmt data req.
357  * Indicates prev. pkt was OK.
358  */
359  static const char PKT_ACKNOWLEDGE = '\x80';
360 
362  static const char PKT_ERR_RESPONSE = '\xf0';
363 
364  static struct SE_Codes cmdCodes[];
365 
366  /* Signal Engineering Error Response Codes from the xmtr
367  * for Type Code F0 (PKT_ERR_RESPONSE).
368  */
369  static const char PKT_STATUS_OK = 0;
370 
371  static const char PKT_STATUS_ILLEGAL_REQUEST = 0x01;
372 
373  static const char PKT_STATUS_ITEM_NOT_FOUND = 0x03;
374 
375  static const char PKT_STATUS_INVALID_DATE_TIME = 0x04;
376 
377  static const char PKT_STATUS_TRANSMIT_OVERLAP = 0x05;
378 
379  static const char PKT_STATUS_INVALID_CHANNEL = 0x06;
380 
381  static const char PKT_STATUS_INVALID_TRANSMIT_INTERVAL = 0x07;
382 
383  static const char PKT_STATUS_EEPROM_NOT_UPDATED = 0x08;
384 
385  static const char PKT_STATUS_INVALID_REPEAT_COUNT = 0x09;
386 
387  static const char PKT_STATUS_CLOCK_NOT_LOADED = 0x0a;
388 
389  static const char PKT_STATUS_CRC_ERROR_ON_LOAD = 0x0b;
390 
391  static const char* statusCodeStrings[];
392 
393  /* Received Packet Too Long */
394  static const char ERR_TOOLONG = 0x01;
395 
396  /* Received Packet Too Short */
397  static const char ERR_TOOSHORT = 0x02;
398 
399  /* Received Packet Checksum Error */
400  static const char ERR_CRC = 0x03;
401 
402  /* Invalid Type Code */
403  static const char ERR_BADTYPE = 0x04;
404 
405  /* SE110 only: Length Field mismatch */
406  static const char ERR_BADLEN = 0x05;
407 
408  /* Unable to Allocate Memory */
409  static const char ERR_MEMORY = 0x06;
410 
411  /* SE110 only: Invalid Sequence Number */
412  static const char ERR_SEQUENCE = 0x07;
413 
414  /* Command Timeout for multi-packet Command */
415  static const char ERR_TIMEOUT = 0x08;
416 
417  static const char* errorCodeStrings[];
418 
419  static struct selfTest {
420  short mask;
421  const char* text;
422  } selfTestCodes[2][10];
423 
424 private:
425 
427 
431  size_t read(void* buf, size_t len) throw (nidas::util::IOException);
432 
440  size_t write(const void* buf, size_t len) throw (nidas::util::IOException);
441 
442  size_t write(const struct iovec* iov, int iovcnt) throw (nidas::util::IOException);
443 
444  int _model;
445 
450 
452 
454 
456 
457  std::string _lastXmitStatus;
458 
459  std::string _softwareBuildDate;
460 
462 
464 
466 
467  size_t _xmitNbytes;
468 
472  unsigned long _activeId;
473 
474  int _rfBaud;
475 
479  SE_GOESXmtr& operator=(const SE_GOESXmtr&);
480 
481 };
482 
483 
484 }}} // namespace nidas namespace dynld namespace isff
485 
486 #endif
uint32_t crc
Definition: sing.cc:937
A class for parsing, formatting and doing operations on time, based on Unix time conventions, where leap seconds are ignored, so that there are always 60 seconds in a minute, 3600 seconds in an hour and 86400 seconds in a day.
Definition: UTime.h:76
virtual bool isNewFile() const
Definition: SE_GOESXmtr.h:101
int getRFBaud() const
Definition: SE_GOESXmtr.h:79
void setModel(int val)
Definition: SE_GOESXmtr.h:92
Support for a GOES transmitter, implemented as an IOChannel.
Definition: GOESXmtr.h:47
std::string _softwareBuildDate
Definition: SE_GOESXmtr.h:459
int getMaxRFBaud() const
Get the maximum RF baud rate supported by the transmitter.
Definition: SE_GOESXmtr.h:99
short _selfTestStatus
Definition: SE_GOESXmtr.h:461
const char * msg
Definition: SE_GOESXmtr.h:298
std::string _lastXmitStatus
Definition: SE_GOESXmtr.h:457
Definition: SE_GOESXmtr.h:419
Definition: SE_GOESXmtr.h:296
Virtual base class declaring methods for converting numeric values between little-endian and big-endi...
Definition: EndianConverter.h:304
An IOChannel implementation for a Signal Engineering GOES transmitter.
Definition: SE_GOESXmtr.h:49
int _clockDiffMsecs
Most recent value for GOES clock difference: GOES clock - system clock.
Definition: SE_GOESXmtr.h:449
bool _gpsInstalled
Definition: SE_GOESXmtr.h:465
int len
Definition: sing.cc:934
Interface to a data sample.
Definition: Sample.h:189
int _model
Definition: SE_GOESXmtr.h:444
SE_GOESXmtr * clone() const
Clone invokes default copy constructor.
Definition: SE_GOESXmtr.h:71
Header file for the nidas::util logging facility.
short mask
Definition: SE_GOESXmtr.h:420
Definition: IOException.h:37
const char * text
Definition: SE_GOESXmtr.h:421
unsigned long _activeId
Actual id read from transmitter.
Definition: SE_GOESXmtr.h:472
nidas::util::UTime _transmitSampleTime
Definition: SE_GOESXmtr.h:455
int _maxRFBaud
Definition: SE_GOESXmtr.h:463
static const nidas::util::EndianConverter * _fromBig
Definition: SE_GOESXmtr.h:426
size_t _xmitNbytes
Definition: SE_GOESXmtr.h:467
nidas::util::UTime _transmitQueueTime
Definition: SE_GOESXmtr.h:451
int value
Definition: SE_GOESXmtr.h:297
int _rfBaud
Definition: SE_GOESXmtr.h:474
nidas::util::UTime _transmitAtTime
Definition: SE_GOESXmtr.h:453
Definition: InvalidParameterException.h:35