UltraScan III
List of all members | Public Member Functions | Static Public Member Functions | Private Slots | Private Attributes
US_TimeState Class Reference

A class for Time State details in time-indexed data records. More...

#include "us_time_state.h"

Inheritance diagram for US_TimeState:
Inheritance graph
[legend]
Collaboration diagram for US_TimeState:
Collaboration graph
[legend]

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

US_TimeState::US_TimeState ( )

Constructor for US_TimeState class.

Definition at line 13 of file us_time_state.cpp.

Member Function Documentation

int US_TimeState::close_read_data ( void  )

Close the input data file.

Returns
Status flag (0->OK).

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.

Returns
Status flag (0->OK).

Definition at line 347 of file us_time_state.cpp.

double US_TimeState::d8word ( char *  cbuf)
privateslot

Get a double (F8) from a data byte array.

Definition at line 1067 of file us_time_state.cpp.

int US_TimeState::dbCreate ( US_DB2 dbP,
const int  expID,
const QString  fpath 
)
static

Static function to create a new TMST record in DB.

Parameters
dbPPointer to opened DB connection
expIDExperiment ID of new record
fpathFile path of local TMST from which to create
Returns
New timestateID (<0 if error)

Definition at line 817 of file us_time_state.cpp.

int US_TimeState::dbDelete ( US_DB2 dbP,
const int  tmstID 
)
static

Static function to delete a TMST record from DB.

Parameters
dbPPointer to opened DB connection
tmstIDThe timestate ID of record to delete
Returns
Status of action (US_DB2::OK,...)

Definition at line 904 of file us_time_state.cpp.

int US_TimeState::dbDownload ( US_DB2 dbP,
const int  tmstID,
const QString  fpath 
)
static

Static function to download a TMST binary data record from DB.

Parameters
dbPPointer to opened DB connection
tmstIDThe timestate ID of record to download
fpathFull path to local file to which to download
Returns
Status of action (US_DB2::OK,...)

Definition at line 1000 of file us_time_state.cpp.

int US_TimeState::dbExamine ( US_DB2 dbP,
int *  tmstIdP = 0,
int *  expIdP = 0,
QString *  fnameP = 0,
QString *  xdefsP = 0,
QString *  cksumP = 0,
QDateTime *  lastupdP = 0 
)
static

Static function to examine a TMST record in DB.

Parameters
dbPPointer to opened DB connection
tmstIdPPointer to TMST db ID (NULL to use expID)
expIdPPointer to experiment db ID (NULL to use tmstID)
fnamePPointer for return of .tmst base filename
xdefsPPointer for return of .xml definitions string
cksumPPointer for return of binary data cksum+size string
lastupdPPointer for return of last-updated datetime
Returns
Status of action (US_DB2::OK,...)

Definition at line 916 of file us_time_state.cpp.

int US_TimeState::dbUpload ( US_DB2 dbP,
const int  tmstID,
const QString  fpath 
)
static

Static function to upload a TMST binary data record to DB.

Parameters
dbPPointer to opened DB connection
tmstIDThe timestate ID of record to upload
fpathFull path to local file from which to upload
Returns
Status of action (US_DB2::OK,...)

Definition at line 1011 of file us_time_state.cpp.

double US_TimeState::dword ( char *  cbuf)
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.

Parameters
statusStatus value whose error message is to be fetched.
Returns
Error message string corresponding to given status.

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.

Parameters
keysPPointer for return of record field keys.
fmtsPOptional pointer for return of field format strings.
Returns
Number of key strings in returned list.

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).

Returns
Status flag (0->OK).

Definition at line 333 of file us_time_state.cpp.

float US_TimeState::fword ( char *  cbuf)
privateslot

Get a float (F4) from a data byte array.

Definition at line 1051 of file us_time_state.cpp.

int US_TimeState::hword ( char *  dba)
privateslot

Get a signed half-word (I2) from a data byte array.

Definition at line 1036 of file us_time_state.cpp.

int US_TimeState::iword ( char *  cbuf)
privateslot

Get a full-word (I4) from a data byte array.

Definition at line 1043 of file us_time_state.cpp.

int US_TimeState::key_parameters ( const QString  key,
int *  rfmtP,
int *  rlenP,
int *  roffP 
)
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.

Returns
Error message string for the last error that occurred.

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.

Parameters
fpathFull path to the input TMST file.
Returns
Status flag (0->OK).

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.

Parameters
fpathFull path to the output TMST file.
timeincTime increment (default 0.0 flags not used).
ftimeFirst record's time (default 0.0).
Returns
Status flag (0->OK)

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.

Parameters
rtimexTime index of record to read (or -1 for "next").
Returns
Status flag (0->OK).

Definition at line 564 of file us_time_state.cpp.

int US_TimeState::set_error ( int  status)
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.

Parameters
keyKey string identifying the field.
formatFormat string for field ("I4", "F4", ...).
Returns
Status flag (0->OK)

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.

Parameters
fkeysKey strings identifying fields.
ffmtsFormat strings identifying fields.
Returns
Status flag (0->OK)

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.

Parameters
fkeysKey+format strings identifying fields, where each string has a key, a blank, and a format substring.
Returns
Status flag (0->OK)

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.

Parameters
keyKey to which field to set.
ivalueInteger value to set.
Returns
Status flag (0->OK).

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.

Parameters
keyKey to which field to set.
dvalueDouble value to set.
Returns
Status flag (0->OK).

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.

Parameters
keyKey to which field to set.
svalueString value to set.
Returns
Status flag (0->OK).

Definition at line 270 of file us_time_state.cpp.

void US_TimeState::store_dword ( char *  dba,
double  dval 
)
privateslot

Put a double (F8) to a data byte array.

Definition at line 1143 of file us_time_state.cpp.

void US_TimeState::store_fword ( char *  dba,
double  dval 
)
privateslot

Put a float (F4) to a data byte array.

Definition at line 1133 of file us_time_state.cpp.

void US_TimeState::store_fwords ( char *  dba,
double *  dvals,
int  nvals 
)
privateslot

Put multiple floats (F4s) to a data byte array.

Definition at line 1186 of file us_time_state.cpp.

void US_TimeState::store_hword ( char *  dba,
int  ival 
)
privateslot

Put a half-word (I2) to a data byte array.

Definition at line 1087 of file us_time_state.cpp.

void US_TimeState::store_hwords ( char *  dba,
int *  ivals,
int  nvals 
)
privateslot

Put multiple half-words (I2s) to a data byte array.

Definition at line 1164 of file us_time_state.cpp.

void US_TimeState::store_iword ( char *  dba,
int  ival 
)
privateslot

Put a full-word (I4) to a data byte array.

Definition at line 1108 of file us_time_state.cpp.

void US_TimeState::store_iwords ( char *  dba,
int *  ivals,
int  nvals 
)
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.

Returns
Number of data records present in the data.

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.

Parameters
keyKey to which field to fetch.
statOptional pointer for return of status value.
Returns
Double value for given key in current record.

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.

Parameters
keyKey to which field to fetch.
statOptional pointer for return of status value.
Returns
Integer value for given key in current record.

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.

Parameters
consttiPointer for return of constant-increment flag.
timeincPointer for return of time increment.
ftimePointer for return of first time.
Returns
Number of value records (times) present in the data.

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.

Parameters
keyKey to which field to fetch.
statOptional pointer for return of status value.
Returns
String value for given key in current record.

Definition at line 707 of file us_time_state.cpp.

int US_TimeState::uhword ( char *  dba)
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.

Parameters
timeincTime increment (0.0 -> no time increment).
Returns
Status flag (0->OK).

Definition at line 360 of file us_time_state.cpp.

Member Data Documentation

char* US_TimeState::cdata
private

Data pointer.

Definition at line 221 of file us_time_state.h.

bool US_TimeState::const_ti
private

Flag: constant time increment?

Definition at line 206 of file us_time_state.h.

char US_TimeState::cwork[256]
private

Character work array.

Definition at line 222 of file us_time_state.h.

int US_TimeState::dbg_level
private

Debug level.

Definition at line 208 of file us_time_state.h.

QDataStream* US_TimeState::dsi
private

Input data stream pointer.

Definition at line 196 of file us_time_state.h.

QDataStream* US_TimeState::dso
private

Output data stream pointer.

Definition at line 195 of file us_time_state.h.

QString US_TimeState::error_msg
private

Current error message string.

Definition at line 201 of file us_time_state.h.

int US_TimeState::fhdr_size
private

File header size in bytes.

Definition at line 213 of file us_time_state.h.

qint64 US_TimeState::file_size
private

Input file total size in bytes.

Definition at line 219 of file us_time_state.h.

QFile* US_TimeState::filei
private

Input file pointer.

Definition at line 193 of file us_time_state.h.

QString US_TimeState::filename
private

TimeState binary base file name.

Definition at line 198 of file us_time_state.h.

QFile* US_TimeState::fileo
private

Output file pointer.

Definition at line 192 of file us_time_state.h.

QString US_TimeState::filepath
private

TimeState binary full file path.

Definition at line 199 of file us_time_state.h.

QStringList US_TimeState::fmts
private

List of value field formats.

Definition at line 225 of file us_time_state.h.

QString US_TimeState::fvers
private

File version string.

Definition at line 200 of file us_time_state.h.

int US_TimeState::int_size
private

Size of integer on this machine.

Definition at line 209 of file us_time_state.h.

QStringList US_TimeState::keys
private

List of value field keys.

Definition at line 224 of file us_time_state.h.

bool US_TimeState::lit_endian
private

Flag: machine is little-endian.

Definition at line 203 of file us_time_state.h.

int US_TimeState::ntimes
private

Number of times (records).

Definition at line 210 of file us_time_state.h.

int US_TimeState::nvalues
private

Number of values (fields) per record.

Definition at line 211 of file us_time_state.h.

QList< int > US_TimeState::offs
private

List of field offsets in record.

Definition at line 226 of file us_time_state.h.

bool US_TimeState::rd_open
private

Flag: file opened for read.

Definition at line 205 of file us_time_state.h.

int US_TimeState::rec_size
private

Data record size in bytes.

Definition at line 214 of file us_time_state.h.

double US_TimeState::time_first
private

Time at first data record.

Definition at line 217 of file us_time_state.h.

double US_TimeState::time_inc
private

Time increment between records.

Definition at line 216 of file us_time_state.h.

int US_TimeState::timex
private

Current time index.

Definition at line 212 of file us_time_state.h.

bool US_TimeState::wr_open
private

Flag: file opened for write.

Definition at line 204 of file us_time_state.h.


The documentation for this class was generated from the following files: