27#ifndef NIDAS_DYNLD_RAF_SYNCRECORDREADER_H
28#define NIDAS_DYNLD_RAF_SYNCRECORDREADER_H
39#ifdef SYNC_RECORD_JSON_OUTPUT
43namespace nidas {
namespace dynld {
namespace raf {
50 std::string(
"expected: \"") + expect +
51 "\", got: \"" + got +
"\"")
122 const std::list<const SyncRecordVariable*>
getVariables();
253#ifdef SYNC_RECORD_JSON_OUTPUT
256 const std::string& textheader)
260 std::istringstream iss(textheader);
261 std::vector<std::string>
lines;
268 lines.push_back(line);
272 header.resize(lines.size());
273 for (
unsigned int i = 0; i < lines.size(); ++
i)
275 header[
i] = lines[
i];
277 root[
"header"] = header;
285 Json::Value& header = root[
"header"];
287 std::ostringstream
oss;
288 for (
unsigned int i = 0; i < header.size(); ++
i)
290 oss << header[
i].asString() <<
"\n";
303 root[
"time"] = Json::UInt64(tt);
304 root[
"numValues"] = (
int)numValues;
311 data.resize(numValues);
315 snprintf(buf,
sizeof(buf),
"%.16g", rec[i]);
326 snprintf(buf,
sizeof(buf),
"%.16g", value);
336 Json::Value variable;
337 Json::Value values(Json::arrayValue);
344 size_t varoffset = var->getSyncRecOffset();
345 int irate = (
int)
ceil(var->getSampleRate());
346 int vlen = var->getLength();
348 values.resize(vlen*irate);
349 for (
int i = 0; i < vlen*
irate; ++
i)
353 variable[
"name"] = var->getName();
354 variable[
"values"] = values;
356 size_t lagoffset = var->getLagOffset();
359 if (!std::isnan(rec[lagoffset]))
360 vtime += (
int) rec[lagoffset];
361 variable[
"time"] = Json::UInt64(vtime);
369 const double* record,
int nvalues,
370 std::vector<const SyncRecordVariable*>& vars)
373 root[
"time"] = Json::UInt64(tt);
374 root[
"numValues"] = nvalues;
375 Json::Value& data = root[
"data"];
376 std::vector<const SyncRecordVariable*>::const_iterator
it;
377 for (it = vars.begin(); it != vars.end(); ++
it)
380 data.append(variable);
A channel for Input or Output of data.
Definition IOChannel.h:65
Pure virtual interface of a client of Samples.
Definition SampleClient.h:38
Interface to a data sample.
Definition Sample.h:190
Class describing a sampled variable.
Definition Variable.h:47
SyncRecordReader handles sync samples and provides an interface to access Variables and read sync rec...
Definition SyncRecordReader.h:86
std::string flightName
Definition SyncRecordReader.h:228
std::list< SampleTag * > sampleTags
Definition SyncRecordReader.h:216
SampleInputStream * inputStream
Definition SyncRecordReader.h:199
size_t getNumValues() const
Get number of data values in a sync record.
Definition SyncRecordReader.h:134
const std::string & getSoftwareVersion() const
Definition SyncRecordReader.h:110
nidas::util::Cond _qcond
Definition SyncRecordReader.h:238
const SyncRecordVariable * getVariable(const std::string &name) const
Get a pointer to a SyncRecordVariable, searching by name.
Definition SyncRecordReader.cc:641
std::string softwareVersion
Definition SyncRecordReader.h:230
size_t read(dsm_time_t *tt, double *ptr, size_t len)
Read a sync record.
Definition SyncRecordReader.cc:567
const std::string & getTailNumber() const
Definition SyncRecordReader.h:106
SyncRecordReader(const SyncRecordReader &)
No copying.
std::list< const SyncRecordVariable * > variables
Definition SyncRecordReader.h:218
int getLagOffset(const nidas::core::Variable *var)
Definition SyncRecordReader.cc:728
void scanHeader(const Sample *samp)
Definition SyncRecordReader.cc:207
std::string _sampleStreamConfigName
Definition SyncRecordReader.h:244
const std::string & getConfigName()
After creating a SyncRecordReader on a socket, this method returns the config name from the SampleInp...
Definition SyncRecordReader.h:185
const std::string & getProjectName() const
Definition SyncRecordReader.h:104
std::map< std::string, const SyncRecordVariable * > variableMap
Definition SyncRecordReader.h:220
SyncServer * syncServer
Definition SyncRecordReader.h:200
std::string projectName
Definition SyncRecordReader.h:224
SyncRecHeaderException * headException
Definition SyncRecordReader.h:214
const std::string & textHeader()
Definition SyncRecordReader.h:150
bool _read_sync_server
When true, explicitly read from the SyncServer, if given.
Definition SyncRecordReader.h:205
bool _debug
Definition SyncRecordReader.h:234
const Sample * nextSample()
Definition SyncRecordReader.cc:652
SyncRecordReader & operator=(const SyncRecordReader &)
No assignment.
SyncRecordReader(IOChannel *iochan)
Constructor of a SyncRecordReader to a connected IOChannel.
Definition SyncRecordReader.cc:64
size_t numDataValues
Definition SyncRecordReader.h:222
time_t startTime
Definition SyncRecordReader.h:232
int getSyncRecOffset(const nidas::core::Variable *var)
Definition SyncRecordReader.cc:758
std::string _header
Definition SyncRecordReader.h:236
time_t getStartTime() const
Get UNIX time of the start time of data in the SyncRecords.
Definition SyncRecordReader.h:115
virtual ~SyncRecordReader()
Definition SyncRecordReader.cc:166
void readKeyedQuotedValues(std::istringstream &header)
Definition SyncRecordReader.cc:541
std::deque< const Sample * > _syncRecords
Place to stash sample records received as a SampleClient.
Definition SyncRecordReader.h:242
bool _eoq
Definition SyncRecordReader.h:239
void endOfStream()
Signal the end of the sample stream, meaning EOF is reached once the queue is empty.
Definition SyncRecordReader.cc:716
virtual bool receive(const Sample *s)
Method called to pass a sample to this client.
Definition SyncRecordReader.cc:682
std::string getQuotedString(std::istringstream &str)
Definition SyncRecordReader.cc:532
void init()
Definition SyncRecordReader.cc:112
const std::list< const SyncRecordVariable * > getVariables()
Get the list of variables in a sync record.
Definition SyncRecordReader.cc:632
const std::string & getFlightName() const
Definition SyncRecordReader.h:108
std::string aircraftName
Definition SyncRecordReader.h:226
virtual void flush()
Ask that this SampleClient send out any buffered Samples that it may be holding.
Definition SyncRecordReader.cc:707
A Variable associated with a SyncRecord.
Definition SyncRecordVariable.h:39
Definition SyncServer.h:58
A wrapper class for a Posix condition variable.
Definition ThreadSupport.h:258
Definition Exception.h:35
Exception(const std::string &type, const std::string &n, const std::string &m)
Definition Exception.h:41
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
int len
Definition sing.cc:948