nidas v1.2.3
SyncServer.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 ** 2005, 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_SYNCSERVER_H
28#define NIDAS_DYNLD_RAF_SYNCSERVER_H
29
30#include <nidas/core/Socket.h>
31#include "SyncRecordGenerator.h"
35#include <nidas/util/Thread.h>
36#include <nidas/util/auto_ptr.h>
37
38namespace nidas { namespace dynld { namespace raf {
39
41{
43 {}
44
45 virtual void stop() = 0;
46
47 virtual ~StopSignal()
48 {};
49
50private:
53};
54
55
58{
59public:
60
61 SyncServer();
62
64
69 void
70 openStream();
71
84 void
85 init();
86
91 int
92 run();
93
94 virtual void interrupt();
95
99 void
100 read(bool once = false);
101
102 void
103 setSorterLengthSeconds(float sorter_secs)
104 {
106 }
107
108 void
109 setRawSorterLengthSeconds(float sorter_secs)
110 {
112 }
113
119 std::string
121 {
122 return _xmlFileName;
123 }
124
125 void
126 setXMLFileName(const std::string& name)
127 {
128 _xmlFileName = name;
129 }
130
131 void
133 {
134 _address.reset(addr);
135 }
136
141 void
146
147 void
148 setDataFileNames(const std::list<std::string>& dataFileNames)
149 {
150 _dataFileNames = dataFileNames;
151 }
152
160 void
162 {
164 }
165
166 void
168
169 void
171
172 static const int DEFAULT_PORT = 30001;
173
174 static const float SORTER_LENGTH_SECS;
175
176 static const float RAW_SORTER_LENGTH_SECS;
177
182 void connect(SampleOutput* output) throw();
183
189 void disconnect(SampleOutput* output) throw();
190
191private:
192
193 void
194 initProject();
195
196 void
198
199 void
200 stop();
201
202 void
203 signalStop();
204
205 void
207
210
213
214 std::string _xmlFileName;
215
216 std::list<std::string> _dataFileNames;
217
218 nidas::util::auto_ptr<nidas::util::SocketAddress> _address;
219
221
223
225
227
229
231
232 // Skip samples outside the time window.
235
237
240
241};
242
243}}} // namespace nidas namespace dynld namespace raf
244
245
246#endif // NIDAS_DYNLD_RAF_SYNCSERVER_H
247
248
Pure virtual interface of a client of Samples.
Definition SampleClient.h:38
Interface for an object that requests connections SampleOutputs.
Definition ConnectionRequester.h:43
Interface of an output stream of samples.
Definition SampleOutput.h:49
SamplePipeline sorts samples that are coming from one or more inputs.
Definition SamplePipeline.h:80
Interface to a data sample.
Definition Sample.h:190
Definition RawSampleInputStream.h:42
An implementation of a SampleInput.
Definition SampleInputStream.h:173
A class for serializing Samples on an OutputStream.
Definition SampleOutputStream.h:41
Definition SyncRecordGenerator.h:38
Definition SyncServer.h:58
SampleClient * _sampleClient
Definition SyncServer.h:224
nidas::util::auto_ptr< nidas::util::SocketAddress > _address
Definition SyncServer.h:218
void init()
Call this method to parse the project, setup sample tags, preload calibrations using the time of the ...
Definition SyncServer.cc:293
void connect(SampleOutput *output)
Implementation of SampleConnectionRequester::connect().
Definition SyncServer.cc:463
RawSampleInputStream * _inputStream
Definition SyncServer.h:211
void read(bool once=false)
Definition SyncServer.cc:411
void setStopSignal(StopSignal *stop_signal)
Set a callback function which will be called when the SyncServer reaches EOF on its input stream or s...
Definition SyncServer.h:161
void addSampleClient(SampleClient *client)
Specify a SampleClient instance to receive the sync samples instead of writing the sync samples to an...
Definition SyncServer.h:142
virtual void interrupt()
Interrupt this thread.
Definition SyncServer.cc:150
void setTimeWindow(nidas::util::UTime start, nidas::util::UTime end)
Definition SyncServer.cc:379
void stop()
Definition SyncServer.cc:190
void setDataFileNames(const std::list< std::string > &dataFileNames)
Definition SyncServer.h:148
dsm_time_t _endWindow
Definition SyncServer.h:234
StopSignal * _stop_signal
Definition SyncServer.h:226
dsm_time_t _startWindow
Definition SyncServer.h:233
static const int DEFAULT_PORT
Definition SyncServer.h:172
float _sorterLengthSecs
Definition SyncServer.h:220
int run()
This method implements the Runnable interface for Threads, but it can also be called synchronously wh...
Definition SyncServer.cc:130
void initProject()
Definition SyncServer.cc:99
void setXMLFileName(const std::string &name)
Definition SyncServer.h:126
dsm_time_t _startTime
Definition SyncServer.h:230
void signalStop()
Definition SyncServer.cc:171
void openStream()
Open the data file input stream and read the nidas header, but do not parse the project.
Definition SyncServer.cc:254
SyncRecordGenerator _syncGen
Definition SyncServer.h:209
void handleSample(nidas::core::Sample *sample)
Definition SyncServer.cc:392
void initSensors(SampleInputStream &sis)
Definition SyncServer.cc:112
SyncServer(const SyncServer &)
std::string getXMLFileName()
Return the current XML filename setting.
Definition SyncServer.h:120
SamplePipeline _pipeline
Definition SyncServer.h:208
static const float RAW_SORTER_LENGTH_SECS
Definition SyncServer.h:176
void resetAddress(nidas::util::SocketAddress *addr)
Definition SyncServer.h:132
SyncServer & operator=(const SyncServer &)
void disconnect(SampleOutput *output)
Implementation of SampleConnectionRequester::disconnect().
Definition SyncServer.cc:467
float _rawSorterLengthSecs
Definition SyncServer.h:222
void getTimeWindow(nidas::util::UTime *start, nidas::util::UTime *end)
Definition SyncServer.cc:364
SyncServer()
Definition SyncServer.cc:57
std::string _xmlFileName
Definition SyncServer.h:214
void setRawSorterLengthSeconds(float sorter_secs)
Definition SyncServer.h:109
~SyncServer()
Definition SyncServer.cc:75
static const float SORTER_LENGTH_SECS
Definition SyncServer.h:174
std::list< std::string > _dataFileNames
Definition SyncServer.h:216
nidas::core::Sample * _firstSample
Definition SyncServer.h:228
void setSorterLengthSeconds(float sorter_secs)
Definition SyncServer.h:103
SampleOutputStream * _outputStream
Definition SyncServer.h:212
An interface for a socket address.
Definition SocketAddress.h:36
Definition Thread.h:83
virtual void start()
Start the thread running, meaning execute the run method in a separate thread.
Definition Thread.cc:375
A class for parsing, formatting and doing operations on time, based on Unix time conventions,...
Definition UTime.h:95
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
long long dsm_time_t
Posix time in microseconds, the number of non-leap microseconds since 1970 Jan 1 00:00 UTC.
Definition Sample.h:62
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
Definition SyncServer.h:41
StopSignal()
Definition SyncServer.h:42
virtual ~StopSignal()
Definition SyncServer.h:47
StopSignal(const StopSignal &)
StopSignal & operator=(const StopSignal &)