27 #include <nidas/Config.h>
29 #ifdef HAVE_LIBNC_SERVER_RPC
31 #ifndef NIDAS_DYNLD_ISFF_NETCDFRPCCHANNEL_H
32 #define NIDAS_DYNLD_ISFF_NETCDFRPCCHANNEL_H
38 #include <nc_server_rpc.h>
44 namespace nidas {
namespace dynld {
namespace isff {
46 using namespace nidas::core;
48 class NcVarGroupFloat;
54 class NetcdfRPCChannel:
public IOChannel {
71 NetcdfRPCChannel* clone()
const {
return new NetcdfRPCChannel(*
this); }
82 IOChannel* connect() throw(nidas::util::IOException);
84 void setNonBlocking(
bool val
__attribute__ ((unused))) throw(nidas::util::IOException)
89 bool isNonBlocking()
const throw(nidas::util::IOException)
94 virtual bool isNewFile()
const {
return false; }
99 size_t read(
void*,
size_t) throw (nidas::util::IOException)
107 size_t write(
const void*,
size_t) throw (nidas::util::IOException)
115 size_t write(
const struct iovec*,
int) throw (nidas::util::IOException)
123 void write(
const Sample*) throw (nidas::util::IOException);
128 void write(datarec_float*) throw (nidas::util::IOException);
130 void close() throw (nidas::util::IOException);
137 const std::string& getName()
const
142 void setName(
const std::string& val);
144 const std::string& getServer()
const {
return _server; }
146 void setServer(
const std::string& val);
148 const std::string& getFileNameFormat()
const {
return _fileNameFormat; }
150 void setFileNameFormat(
const std::string& val);
152 const std::string& getDirectory()
const {
return _directory; }
154 void setDirectory(
const std::string& val);
156 const std::string& getCDLFileName()
const {
return _cdlFileName; }
158 void setCDLFileName(
const std::string& val) { _cdlFileName = val; }
160 void setFillValue(
float val) { _fillValue = val; }
162 float getFillValue()
const {
return _fillValue; }
168 void setTimeInterval(
int val)
173 int getTimeInterval()
const
175 return _timeInterval;
181 int getFileLength()
const {
return _fileLength; }
183 void setFileLength(
int val) { _fileLength = val; }
189 void checkError() throw(nidas::util::IOException);
191 void setRPCTimeout(
int secs);
193 int getRPCTimeout() const;
198 void setRPCBatchPeriod(
int val);
200 int getRPCBatchPeriod() const;
202 void fromDOMElement(const xercesc::DOMElement* node)
203 throw(nidas::util::InvalidParameterException);
211 std::list<const SampleTag*> getSampleTags()
const
213 return _constSampleTags;
216 void writeGlobalAttr(
const std::string& name,
const std::string& value)
219 void writeGlobalAttr(
const std::string& name,
int value)
224 friend class NcVarGroupFloat;
226 CLIENT* getRPCClient() {
return _clnt; }
228 int getConnectionId()
const {
return _connectionId; }
230 struct timeval& getRPCWriteTimeoutVal();
232 struct timeval& getRPCOtherTimeoutVal();
234 struct timeval& getRPCBatchTimeoutVal();
241 NetcdfRPCChannel(
const NetcdfRPCChannel&);
243 void writeHistory(
const std::string&) throw (nidas::util::IOException);
245 void nonBatchWrite(datarec_float*) throw (nidas::util::IOException);
247 NcVarGroupFloat* getNcVarGroupFloat(
260 std::
string _fileNameFormat;
262 std::
string _directory;
264 std::
string _cdlFileName;
279 struct timeval _rpcWriteTimeout;
281 struct timeval _rpcOtherTimeout;
283 struct timeval _rpcBatchTimeout;
287 static const
int NTRY = 10;
289 time_t _lastNonBatchWrite;
293 std::map<dsm_sample_id_t,
int> _stationIndexById;
295 std::list<NcVarGroupFloat*> _groups;
299 std::list<const
SampleTag*> _constSampleTags;
307 NetcdfRPCChannel& operator=(const NetcdfRPCChannel&);
311 class NcVarGroupFloat {
318 const std::vector<const Variable*>& getVariables()
const
320 return _sampleTag.getVariables();
323 const std::vector<ParameterT<int> >& getDimensions()
331 double getInterval()
const {
return _interval; }
335 friend class NetcdfRPCChannel;
337 void connect(NetcdfRPCChannel* conn,
float fillValue)
340 void write(NetcdfRPCChannel* conn,
const Sample* samp,
345 std::vector<ParameterT<int> > _dimensions;
364 NcVarGroupFloat(
const NcVarGroupFloat&);
366 NcVarGroupFloat& operator =(
const NcVarGroupFloat&);
373 #endif // HAVE_LIBNC_SERVER_RPC
static int __attribute__((__unused__)) cksum_test(int
unsigned int dsm_sample_id_t
Definition: Sample.h:63
A channel for Input or Output of data.
Definition: IOChannel.h:64
Interface to a data sample.
Definition: Sample.h:189
A typed Parameter, with data of type T.
Definition: Parameter.h:117
Definition: IOException.h:37
Class describing a group of variables that are sampled and handled together.
Definition: SampleTag.h:87
Interface for an object that requests connections to Inputs or Outputs.
Definition: IOChannel.h:54