A class for Time State details in time-indexed data records. More...
#include "us_time_state.h"
Public Member Functions | |
US_TimeState () | |
Constructor for US_TimeState class. More... | |
int | open_write_data (QString, double=0.0, double=0.0) |
Open a file with specified path for writing. More... | |
int | set_key (QString, QString) |
Specify key and format of a data field. More... | |
int | set_keys (QStringList &, QStringList &) |
Specify keys and formats for all data fields. More... | |
int | set_keys (QStringList &) |
Specify keys and formats for all data fields. More... | |
int | set_value (QString, int) |
Set an integer value for the current record. More... | |
int | set_value (QString, double) |
Set a float value for the current record. More... | |
int | set_value (QString, QString) |
Set a character string value for the current record. More... | |
int | flush_record (void) |
Flush the current data record (write to the file). More... | |
int | write_defs (double=0.0) |
Write the definitions XML file for the last opened data file. More... | |
int | close_write_data (void) |
Flush any remaining records and close the output data file. More... | |
int | open_read_data (QString) |
Read data from a specified data file and its sister XML file. More... | |
int | time_count () |
Get the count of time data records. More... | |
int | time_range (bool *, double *, double *) |
Get the nature and parameters of the time range. More... | |
int | field_keys (QStringList *, QStringList *) |
Get record field keys and formats. More... | |
int | read_record (int=-1) |
Read the next or a specified data record. More... | |
int | time_ivalue (const QString, int *=0) |
Get a time integer value for a given key from the current record. More... | |
double | time_dvalue (const QString, int *=0) |
Get a time double value for a given key from the current record. More... | |
QString | time_svalue (const QString, int *=0) |
Get a time string value for a given key from the current record. More... | |
int | close_read_data (void) |
Close the input data file. More... | |
QString | error_message (int) |
Get the error message for a given status value. More... | |
QString | last_error_message (void) |
Get the error message for the last error. More... | |
Static Public Member Functions | |
static int | dbCreate (US_DB2 *, const int, const QString) |
Static function to create a new TMST record in DB. More... | |
static int | dbDelete (US_DB2 *, const int) |
Static function to delete a TMST record from DB. More... | |
static int | dbExamine (US_DB2 *, int *=0, int *=0, QString *=0, QString *=0, QString *=0, QDateTime *=0) |
Static function to examine a TMST record in DB. More... | |
static int | dbDownload (US_DB2 *, const int, const QString) |
Static function to download a TMST binary data record from DB. More... | |
static int | dbUpload (US_DB2 *, const int, const QString) |
Static function to upload a TMST binary data record to DB. More... | |
Private Slots | |
int | uhword (char *) |
Get an unsigned half-word (I2) from a data byte array. More... | |
int | hword (char *) |
Get a signed half-word (I2) from a data byte array. More... | |
int | iword (char *) |
Get a full-word (I4) from a data byte array. More... | |
float | fword (char *) |
Get a float (F4) from a data byte array. More... | |
double | dword (char *) |
Get a double (F4) from a data byte array. More... | |
double | d8word (char *) |
Get a double (F8) from a data byte array. More... | |
void | store_hword (char *, int) |
Put a half-word (I2) to a data byte array. More... | |
void | store_iword (char *, int) |
Put a full-word (I4) to a data byte array. More... | |
void | store_fword (char *, double) |
Put a float (F4) to a data byte array. More... | |
void | store_dword (char *, double) |
Put a double (F8) to a data byte array. More... | |
void | store_hwords (char *, int *, int) |
Put multiple half-words (I2s) to a data byte array. More... | |
void | store_iwords (char *, int *, int) |
Put multiple full-words (I4s) to a data byte array. More... | |
void | store_fwords (char *, double *, int) |
Put multiple floats (F4s) to a data byte array. More... | |
int | set_error (int) |
Set the error status and message. More... | |
int | key_parameters (const QString, int *, int *, int *) |
Get a key's parameters (format-type, length, key-offset). More... | |
Private Attributes | |
QFile * | fileo |
Output file pointer. More... | |
QFile * | filei |
Input file pointer. More... | |
QDataStream * | dso |
Output data stream pointer. More... | |
QDataStream * | dsi |
Input data stream pointer. More... | |
QString | filename |
TimeState binary base file name. More... | |
QString | filepath |
TimeState binary full file path. More... | |
QString | fvers |
File version string. More... | |
QString | error_msg |
Current error message string. More... | |
bool | lit_endian |
Flag: machine is little-endian. More... | |
bool | wr_open |
Flag: file opened for write. More... | |
bool | rd_open |
Flag: file opened for read. More... | |
bool | const_ti |
Flag: constant time increment? More... | |
int | dbg_level |
Debug level. More... | |
int | int_size |
Size of integer on this machine. More... | |
int | ntimes |
Number of times (records). More... | |
int | nvalues |
Number of values (fields) per record. More... | |
int | timex |
Current time index. More... | |
int | fhdr_size |
File header size in bytes. More... | |
int | rec_size |
Data record size in bytes. More... | |
double | time_inc |
Time increment between records. More... | |
double | time_first |
Time at first data record. More... | |
qint64 | file_size |
Input file total size in bytes. More... | |
char * | cdata |
Data pointer. More... | |
char | cwork [256] |
Character work array. More... | |
QStringList | keys |
List of value field keys. More... | |
QStringList | fmts |
List of value field formats. More... | |
QList< int > | offs |
List of field offsets in record. More... | |
A class for Time State details in time-indexed data records.
This class holds a Time State object whose primary data is a set of records for each time. Each record is a set of contiguous binary values as defined in a separate sister XML file.
Functions are provided to write out a TMST object and to read one in.
Definition at line 23 of file us_time_state.h.
US_TimeState::US_TimeState | ( | ) |
Constructor for US_TimeState class.
Definition at line 13 of file us_time_state.cpp.
int US_TimeState::close_read_data | ( | void | ) |
Close the input data file.
Definition at line 758 of file us_time_state.cpp.
int US_TimeState::close_write_data | ( | void | ) |
Flush any remaining records and close the output data file.
Definition at line 347 of file us_time_state.cpp.
|
privateslot |
Get a double (F8) from a data byte array.
Definition at line 1067 of file us_time_state.cpp.
|
static |
Static function to create a new TMST record in DB.
dbP | Pointer to opened DB connection |
expID | Experiment ID of new record |
fpath | File path of local TMST from which to create |
Definition at line 817 of file us_time_state.cpp.
|
static |
Static function to delete a TMST record from DB.
dbP | Pointer to opened DB connection |
tmstID | The timestate ID of record to delete |
Definition at line 904 of file us_time_state.cpp.
|
static |
Static function to download a TMST binary data record from DB.
dbP | Pointer to opened DB connection |
tmstID | The timestate ID of record to download |
fpath | Full path to local file to which to download |
Definition at line 1000 of file us_time_state.cpp.
|
static |
Static function to examine a TMST record in DB.
dbP | Pointer to opened DB connection |
tmstIdP | Pointer to TMST db ID (NULL to use expID) |
expIdP | Pointer to experiment db ID (NULL to use tmstID) |
fnameP | Pointer for return of .tmst base filename |
xdefsP | Pointer for return of .xml definitions string |
cksumP | Pointer for return of binary data cksum+size string |
lastupdP | Pointer for return of last-updated datetime |
Definition at line 916 of file us_time_state.cpp.
|
static |
Static function to upload a TMST binary data record to DB.
dbP | Pointer to opened DB connection |
tmstID | The timestate ID of record to upload |
fpath | Full path to local file from which to upload |
Definition at line 1011 of file us_time_state.cpp.
|
privateslot |
Get a double (F4) from a data byte array.
Definition at line 1060 of file us_time_state.cpp.
QString US_TimeState::error_message | ( | int | status | ) |
Get the error message for a given status value.
status | Status value whose error message is to be fetched. |
Definition at line 771 of file us_time_state.cpp.
int US_TimeState::field_keys | ( | QStringList * | keysP, |
QStringList * | fmtsP | ||
) |
Get record field keys and formats.
keysP | Pointer for return of record field keys. |
fmtsP | Optional pointer for return of field format strings. |
Definition at line 552 of file us_time_state.cpp.
int US_TimeState::flush_record | ( | void | ) |
Flush the current data record (write to the file).
Definition at line 333 of file us_time_state.cpp.
|
privateslot |
Get a float (F4) from a data byte array.
Definition at line 1051 of file us_time_state.cpp.
|
privateslot |
Get a signed half-word (I2) from a data byte array.
Definition at line 1036 of file us_time_state.cpp.
|
privateslot |
Get a full-word (I4) from a data byte array.
Definition at line 1043 of file us_time_state.cpp.
|
privateslot |
Get a key's parameters (format-type, length, key-offset).
Definition at line 1208 of file us_time_state.cpp.
QString US_TimeState::last_error_message | ( | void | ) |
Get the error message for the last error.
Definition at line 811 of file us_time_state.cpp.
int US_TimeState::open_read_data | ( | QString | fpath | ) |
Read data from a specified data file and its sister XML file.
fpath | Full path to the input TMST file. |
Definition at line 407 of file us_time_state.cpp.
int US_TimeState::open_write_data | ( | QString | fpath, |
double | timeinc = 0.0 , |
||
double | ftime = 0.0 |
||
) |
Open a file with specified path for writing.
Open a file for writing, given a full-path file name. Initialize the object header with time_increment and first_time values.
fpath | Full path to the output TMST file. |
timeinc | Time increment (default 0.0 flags not used). |
ftime | First record's time (default 0.0). |
Definition at line 48 of file us_time_state.cpp.
int US_TimeState::read_record | ( | int | rtimex = -1 | ) |
Read the next or a specified data record.
rtimex | Time index of record to read (or -1 for "next"). |
Definition at line 564 of file us_time_state.cpp.
|
privateslot |
Set the error status and message.
Definition at line 1197 of file us_time_state.cpp.
int US_TimeState::set_key | ( | QString | key, |
QString | format | ||
) |
Specify key and format of a data field.
key | Key string identifying the field. |
format | Format string for field ("I4", "F4", ...). |
Definition at line 94 of file us_time_state.cpp.
int US_TimeState::set_keys | ( | QStringList & | fkeys, |
QStringList & | ffmts | ||
) |
Specify keys and formats for all data fields.
fkeys | Key strings identifying fields. |
ffmts | Format strings identifying fields. |
Definition at line 123 of file us_time_state.cpp.
int US_TimeState::set_keys | ( | QStringList & | fkeys | ) |
Specify keys and formats for all data fields.
fkeys | Key+format strings identifying fields, where each string has a key, a blank, and a format substring. |
Definition at line 146 of file us_time_state.cpp.
int US_TimeState::set_value | ( | QString | key, |
int | ivalue | ||
) |
Set an integer value for the current record.
key | Key to which field to set. |
ivalue | Integer value to set. |
Definition at line 165 of file us_time_state.cpp.
int US_TimeState::set_value | ( | QString | key, |
double | dvalue | ||
) |
Set a float value for the current record.
key | Key to which field to set. |
dvalue | Double value to set. |
Definition at line 217 of file us_time_state.cpp.
int US_TimeState::set_value | ( | QString | key, |
QString | svalue | ||
) |
Set a character string value for the current record.
key | Key to which field to set. |
svalue | String value to set. |
Definition at line 270 of file us_time_state.cpp.
|
privateslot |
Put a double (F8) to a data byte array.
Definition at line 1143 of file us_time_state.cpp.
|
privateslot |
Put a float (F4) to a data byte array.
Definition at line 1133 of file us_time_state.cpp.
|
privateslot |
Put multiple floats (F4s) to a data byte array.
Definition at line 1186 of file us_time_state.cpp.
|
privateslot |
Put a half-word (I2) to a data byte array.
Definition at line 1087 of file us_time_state.cpp.
|
privateslot |
Put multiple half-words (I2s) to a data byte array.
Definition at line 1164 of file us_time_state.cpp.
|
privateslot |
Put a full-word (I4) to a data byte array.
Definition at line 1108 of file us_time_state.cpp.
|
privateslot |
Put multiple full-words (I4s) to a data byte array.
Definition at line 1175 of file us_time_state.cpp.
int US_TimeState::time_count | ( | ) |
Get the count of time data records.
Definition at line 536 of file us_time_state.cpp.
double US_TimeState::time_dvalue | ( | const QString | key, |
int * | stat = 0 |
||
) |
Get a time double value for a given key from the current record.
key | Key to which field to fetch. |
stat | Optional pointer for return of status value. |
Definition at line 653 of file us_time_state.cpp.
int US_TimeState::time_ivalue | ( | const QString | key, |
int * | stat = 0 |
||
) |
Get a time integer value for a given key from the current record.
key | Key to which field to fetch. |
stat | Optional pointer for return of status value. |
Definition at line 600 of file us_time_state.cpp.
int US_TimeState::time_range | ( | bool * | constti, |
double * | timeinc, | ||
double * | ftime | ||
) |
Get the nature and parameters of the time range.
constti | Pointer for return of constant-increment flag. |
timeinc | Pointer for return of time increment. |
ftime | Pointer for return of first time. |
Definition at line 542 of file us_time_state.cpp.
QString US_TimeState::time_svalue | ( | const QString | key, |
int * | stat = 0 |
||
) |
Get a time string value for a given key from the current record.
key | Key to which field to fetch. |
stat | Optional pointer for return of status value. |
Definition at line 707 of file us_time_state.cpp.
|
privateslot |
Get an unsigned half-word (I2) from a data byte array.
Definition at line 1027 of file us_time_state.cpp.
int US_TimeState::write_defs | ( | double | timeinc = 0.0 | ) |
Write the definitions XML file for the last opened data file.
timeinc | Time increment (0.0 -> no time increment). |
Definition at line 360 of file us_time_state.cpp.
|
private |
Data pointer.
Definition at line 221 of file us_time_state.h.
|
private |
Flag: constant time increment?
Definition at line 206 of file us_time_state.h.
|
private |
Character work array.
Definition at line 222 of file us_time_state.h.
|
private |
Debug level.
Definition at line 208 of file us_time_state.h.
|
private |
Input data stream pointer.
Definition at line 196 of file us_time_state.h.
|
private |
Output data stream pointer.
Definition at line 195 of file us_time_state.h.
|
private |
Current error message string.
Definition at line 201 of file us_time_state.h.
|
private |
File header size in bytes.
Definition at line 213 of file us_time_state.h.
|
private |
Input file total size in bytes.
Definition at line 219 of file us_time_state.h.
|
private |
Input file pointer.
Definition at line 193 of file us_time_state.h.
|
private |
TimeState binary base file name.
Definition at line 198 of file us_time_state.h.
|
private |
Output file pointer.
Definition at line 192 of file us_time_state.h.
|
private |
TimeState binary full file path.
Definition at line 199 of file us_time_state.h.
|
private |
List of value field formats.
Definition at line 225 of file us_time_state.h.
|
private |
File version string.
Definition at line 200 of file us_time_state.h.
|
private |
Size of integer on this machine.
Definition at line 209 of file us_time_state.h.
|
private |
List of value field keys.
Definition at line 224 of file us_time_state.h.
|
private |
Flag: machine is little-endian.
Definition at line 203 of file us_time_state.h.
|
private |
Number of times (records).
Definition at line 210 of file us_time_state.h.
|
private |
Number of values (fields) per record.
Definition at line 211 of file us_time_state.h.
|
private |
List of field offsets in record.
Definition at line 226 of file us_time_state.h.
|
private |
Flag: file opened for read.
Definition at line 205 of file us_time_state.h.
|
private |
Data record size in bytes.
Definition at line 214 of file us_time_state.h.
|
private |
Time at first data record.
Definition at line 217 of file us_time_state.h.
|
private |
Time increment between records.
Definition at line 216 of file us_time_state.h.
|
private |
Current time index.
Definition at line 212 of file us_time_state.h.
|
private |
Flag: file opened for write.
Definition at line 204 of file us_time_state.h.