nidas  v1.2-1520
UDPArincSensor.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  ** 2008, 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_raf_arinc_udp_h_
28 #define _nidas_dynld_raf_arinc_udp_h_
29 
32 #include "AltaEnet.h"
33 
34 
35 namespace nidas { namespace dynld { namespace raf {
36 
37 using namespace nidas::core;
38 
39 
40 class DSMArincSensor;
41 
42 
50 {
51 
52 public:
54  virtual ~UDPArincSensor();
55 
56  virtual void validate() throw(nidas::util::InvalidParameterException);
57 
58  virtual void open(int flags) throw(nidas::util::IOException,
60 
61  virtual void close() throw(nidas::util::IOException);
62 
67  virtual Sample* nextSample()
68  {
70 
71  if (samp) {
72  const char *input = (const char *)samp->getConstVoidDataPtr();
73  if (input[0] == 'S') // status packet
74  extractStatus(input, samp->getDataByteLength());
75  }
76  return samp;
77  }
78 
79  void extractStatus(const char *msg, int len);
80 
81  void printStatus(std::ostream& ostr) throw();
82 
83 
84  bool process(const Sample* samp,std::list<const Sample*>& results)
85  throw();
86 
87 
88  void registerArincSensor(int channel, DSMArincSensor* sensor)
89  { _arincSensors[channel] = sensor; }
90 
91 
92 protected:
93  // Methods to decode pieces of the APMP and RXP packets.
94  unsigned long decodeIRIG(unsigned char *);
95  long long decodeTIMER(const rxp&);
96  int bcd_to_decimal(unsigned char x) { return x - 6 * (x >> 4); }
97 
98  // Data ships Big Endian.
100 
102  unsigned int _prevAPMPseqNum, _badAPMPseqCnt;
103  unsigned int _prevRXPseqNum[8], _badRXPseqCnt[8];
104  unsigned int _badStatusCnt;
106 
108  std::string _ipAddr;
109 
111  unsigned int _statusPort;
112 
113  static const int MAX_CHANNELS;
114 
121  std::map<std::string, int> configStatus;
122 
123 
124 private:
125  // PID for process that intializes and controls ENET unit.
126  pid_t _ctrl_pid;
127 
128  // Decoded IRIG time for a given APMP packet.
129  char irigHHMMSS[32];
130 
131  // Channel #, AltaARINC sensor.
132  std::map<int, DSMArincSensor*> _arincSensors;
133 };
134 
135 }}} // namespace nidas namespace dynld namespace raf
136 #endif
A sensor connected to an ARINC port.
Definition: DSMArincSensor.h:91
virtual Sample * nextSample()
Over-ride default nextSample() so we can extract some status bits as the data passes through...
Definition: UDPArincSensor.h:67
static const int MAX_CHANNELS
Definition: UDPArincSensor.h:113
std::map< std::string, int > configStatus
This contains the status of config verification between what we read off the device and what is in th...
Definition: UDPArincSensor.h:121
Definition: AltaEnet.h:32
nidas::dynld::raf::UPDSocketSensor is the same as a nidas::dynld::UDPSocketSensor, but kept around for legacy reasons - it&#39;s in quite a few XMLs.
Definition: UDPSocketSensor.h:40
pid_t _ctrl_pid
Definition: UDPArincSensor.h:126
unsigned int _prevAPMPseqNum
Definition: UDPArincSensor.h:102
virtual const void * getConstVoidDataPtr() const =0
Get a const void* pointer to the data portion of the sample.
void registerArincSensor(int channel, DSMArincSensor *sensor)
Definition: UDPArincSensor.h:88
std::string _ipAddr
IP address of the Alta ARINC ENET appliance.
Definition: UDPArincSensor.h:108
ARINC over UDP, data received from the Alta ARINC to Ethernet appliance.
Definition: UDPArincSensor.h:49
Virtual base class declaring methods for converting numeric values between little-endian and big-endi...
Definition: EndianConverter.h:304
std::map< int, DSMArincSensor * > _arincSensors
Definition: UDPArincSensor.h:132
static const nidas::util::EndianConverter * bigEndian
Definition: UDPArincSensor.h:99
unsigned int _badStatusCnt
Definition: UDPArincSensor.h:104
int len
Definition: sing.cc:934
Interface to a data sample.
Definition: Sample.h:189
Definition: IOException.h:37
unsigned int getDataByteLength() const
Get the number of bytes in data portion of sample.
Definition: Sample.h:256
virtual Sample * nextSample()
Extract the next sample from the buffer.
Definition: DSMSensor.h:707
unsigned int _statusPort
Status port number for the alta_ctrl program.
Definition: UDPArincSensor.h:111
Definition: InvalidParameterException.h:35
int bcd_to_decimal(unsigned char x)
Definition: UDPArincSensor.h:96