nidas v1.2.3
Uio48Sensor.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 ** 2021, 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_UIO48SENSOR_H
28#define NIDAS_DYNLD_UIO48SENSOR_H
29
30#include <nidas/Config.h>
34
35#ifdef HAVE_UIO48_H
36#include <uio48.h>
37#include <nidas/util/BitArray.h>
38#endif
39
40
41namespace nidas { namespace dynld {
42
43using namespace nidas::core;
44
45#ifdef HAVE_UIO48_H
46
50class Uio48 {
51public:
52
53 Uio48(int npins = 48);
54 ~Uio48();
55
56 int getFd() const { return _fd; }
57
63 void open(const std::string& device);
64
70 void close();
71
77 int getNumPins() const
78 {
79 return _npins;
80 }
81
88 void clearPins(const nidas::util::BitArray& which);
89
97 void setPins(const nidas::util::BitArray& which);
98
106 void setPins(const nidas::util::BitArray& which,
107 const nidas::util::BitArray& val);
108
115
116 const std::string& getName() const { return _devName; }
117
118private:
119 std::string _devName;
120 int _fd;
121 int _npins;
122
124 Uio48(const Uio48&);
125
127 Uio48& operator=(const Uio48&);
128
129};
130#endif
131
135class Uio48Sensor : public DSMSensor {
136public:
137
138 Uio48Sensor();
139 ~Uio48Sensor();
140
147 void open(int flags);
148
150
152
156 void init();
157
161 void validate();
162
163 bool process(const Sample* insamp,std::list<const Sample*>& results) throw();
164
165#ifdef HAVE_UIO48_H
166
172 void close();
173
174 class Uio48IODevice: public UnixIODevice {
175 public:
176 Uio48IODevice(): UnixIODevice() {}
177 // pipe is opened by sensor open method.
178 void open(int) {}
179
180 void setFd(int val) { _fd = val; }
181 };
182
183 class Uio48LooperClient : public LooperClient {
184 public:
185 Uio48LooperClient(const DSMSensor& sensor, Uio48& uio, int pipefd);
186
187 void looperNotify();
188
189 void setFd(int val) { _pipefd = val; }
190 private:
191 const DSMSensor& _sensor;
192 Uio48& _uio;
193 int _pipefd;
194 std::vector<unsigned char> _buffer;
195
197 Uio48LooperClient(const Uio48LooperClient&);
198
200 Uio48LooperClient& operator=(const Uio48LooperClient&);
201
202 };
203
204#endif
205
206private:
207
209
211
212#ifdef HAVE_UIO48_H
213
214 Uio48 _uio48;
215
216 int _pipefds[2];
217
218 Uio48IODevice *_iodevice;
219
220 Uio48LooperClient _looperClient;
221#endif
222
225
228};
229
230}} // namespace nidas namespace dynld
231
232#endif // NIDAS_DYNLD_UIO48SENSOR_H
DSMSensor provides the basic support for reading, processing and distributing samples from a sensor a...
Definition DSMSensor.h:88
virtual void close()
close my associated device.
Definition DSMSensor.cc:344
An interface to an IO device.
Definition IODevice.h:42
Interface of a client of Looper.
Definition LooperClient.h:38
A scanner of sample data.
Definition SampleScanner.h:74
Class describing a group of variables that are sampled and handled together.
Definition SampleTag.h:88
Interface to a data sample.
Definition Sample.h:190
A basic Unix I/O device, such as a named pipe, or a watched file.
Definition UnixIODevice.h:49
Nidas sensor support for UIO48 digital I/O chip on a PCM-C418 Vortex CPU.
Definition Uio48Sensor.h:135
~Uio48Sensor()
Definition Uio48Sensor.cc:166
SampleTag * _stag
Definition Uio48Sensor.h:210
void init()
Definition Uio48Sensor.cc:170
IODevice * buildIODevice()
Factory method for an IODevice for this DSMSensor.
Definition Uio48Sensor.cc:226
Uio48Sensor & operator=(const Uio48Sensor &)
No assignment.
void open(int flags)
Open the UIO48 device and the pipe which sends data to Nidas.
Definition Uio48Sensor.cc:271
SampleScanner * buildSampleScanner()
Factory method for a SampleScanner for this DSMSensor.
Definition Uio48Sensor.cc:238
Uio48Sensor(const Uio48Sensor &)
No copying.
int _nvars
Definition Uio48Sensor.h:208
Uio48Sensor()
Definition Uio48Sensor.cc:158
bool process(const Sample *insamp, std::list< const Sample * > &results)
Apply further necessary processing to a raw sample from this DSMSensor.
Definition Uio48Sensor.cc:194
void validate()
Definition Uio48Sensor.cc:174
A class for holding bits.
Definition BitArray.h:39
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
static string device
Definition sing.cc:60