nidas v1.2.3
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
35namespace nidas { namespace dynld { namespace raf {
36
37using namespace nidas::core;
38
39
40class DSMArincSensor;
41
42
50{
51
52public:
54 virtual ~UDPArincSensor();
55
56 virtual void validate();
57
58 virtual void open(int flags);
59
60 virtual void close();
61
66 virtual Sample* nextSample()
67 {
69
70 if (samp) {
71 const char *input = (const char *)samp->getConstVoidDataPtr();
72 if (input[0] == 'S') // status packet
73 extractStatus(input, samp->getDataByteLength());
74 }
75 return samp;
76 }
77
78 void extractStatus(const char *msg, int len);
79
80 void printStatus(std::ostream& ostr) throw();
81
82
83 bool process(const Sample* samp,std::list<const Sample*>& results);
84
85 void registerArincSensor(int channel, DSMArincSensor* sensor)
86 { _arincSensors[channel] = sensor; }
87
88
89protected:
90 // Methods to decode pieces of the APMP and RXP packets.
91 unsigned long decodeIRIG(unsigned char *);
92 long long decodeTIMER(const rxp&);
93 int bcd_to_decimal(unsigned char x) { return x - 6 * (x >> 4); }
94
95 // Data ships Big Endian.
97
100 unsigned int _prevRXPseqNum[8], _badRXPseqCnt[8];
101 unsigned int _badStatusCnt;
103
105 std::string _ipAddr;
106
108 unsigned int _statusPort;
109
110 static const int MAX_CHANNELS;
111
118 std::map<std::string, int> configStatus;
119
120
121private:
122 // PID for process that intializes and controls ENET unit.
124
125 // Decoded IRIG time for a given APMP packet.
126 char irigHHMMSS[32];
127
128 // Channel #, AltaARINC sensor.
129 std::map<int, DSMArincSensor*> _arincSensors;
130};
131
132}}} // namespace nidas namespace dynld namespace raf
133#endif
virtual Sample * nextSample()
Extract the next sample from the buffer.
Definition DSMSensor.h:725
Interface to a data sample.
Definition Sample.h:190
Sensor class using a UDPSocketIODevice for reading from a UDP socket.
Definition UDPSocketSensor.h:61
A sensor connected to an ARINC port.
Definition DSMArincSensor.h:92
ARINC over UDP, data received from the Alta ARINC to Ethernet appliance.
Definition UDPArincSensor.h:50
unsigned long decodeIRIG(unsigned char *)
Definition UDPArincSensor.cc:271
void extractStatus(const char *msg, int len)
Definition UDPArincSensor.cc:303
static const int MAX_CHANNELS
Definition UDPArincSensor.h:110
unsigned int _prevRXPseqNum[8]
Definition UDPArincSensor.h:100
void printStatus(std::ostream &ostr)
Definition UDPArincSensor.cc:326
unsigned int _badAPMPseqCnt
Definition UDPArincSensor.h:99
virtual Sample * nextSample()
Over-ride default nextSample() so we can extract some status bits as the data passes through.
Definition UDPArincSensor.h:66
pid_t _ctrl_pid
Definition UDPArincSensor.h:123
char irigHHMMSS[32]
Definition UDPArincSensor.h:126
long long decodeTIMER(const rxp &)
Definition UDPArincSensor.cc:284
unsigned int _statusPort
Status port number for the alta_ctrl program.
Definition UDPArincSensor.h:108
virtual ~UDPArincSensor()
Definition UDPArincSensor.cc:59
unsigned int _prevAPMPseqNum
Definition UDPArincSensor.h:99
bool process(const Sample *samp, std::list< const Sample * > &results)
Process a raw sample, which in this case means do a sscanf on the character string contents,...
Definition UDPArincSensor.cc:174
unsigned int _badRXPseqCnt[8]
Definition UDPArincSensor.h:100
virtual void validate()
Implementation of DSMSensor::validate for a Character Sensor.
Definition UDPArincSensor.cc:80
std::map< int, DSMArincSensor * > _arincSensors
Definition UDPArincSensor.h:129
virtual void open(int flags)
Open the sensor device port for real-time sampling.
Definition UDPArincSensor.cc:97
unsigned int _badStatusCnt
Definition UDPArincSensor.h:101
std::string _ipAddr
IP address of the Alta ARINC ENET appliance.
Definition UDPArincSensor.h:105
UDPArincSensor()
Definition UDPArincSensor.cc:51
void registerArincSensor(int channel, DSMArincSensor *sensor)
Definition UDPArincSensor.h:85
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:118
static const nidas::util::EndianConverter * bigEndian
Definition UDPArincSensor.h:96
virtual void close()
close my associated device.
Definition UDPArincSensor.cc:152
int bcd_to_decimal(unsigned char x)
Definition UDPArincSensor.h:93
Virtual base class declaring methods for converting numeric values between little-endian and big-endi...
Definition EndianConverter.h:304
The essential core classes of nidas.
Definition A2DConverter.h:31
Sample * getSample(sampleType type, unsigned int len)
A convienence method for getting a sample of an enumerated type from a pool.
Definition Sample.cc:70
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
int len
Definition sing.cc:948
Definition AltaEnet.h:33