UltraScan III
us_time_state.h
Go to the documentation of this file.
1 #ifndef US_TIMESTATE_H
3 #define US_TIMESTATE_H
4 
5 #include <QtCore>
6 #include "us_extern.h"
7 #include "us_util.h"
8 #include "us_db2.h"
9 
10 #define _TMST_MAGI_ "USTS"
11 #define _TMST_VERS_ "1.0"
12 #define _TMST_INOVAL_ ((1<<15)-1)
13 #define _TMST_FNOVAL_ ((pow(2.0,19.0)-1.0)/4.0)
14 
23 class US_UTIL_EXTERN US_TimeState : public QObject
24 {
25  public:
26 
28  US_TimeState();
29 
39  int open_write_data( QString, double = 0.0, double = 0.0 );
40 
45  int set_key( QString, QString );
46 
51  int set_keys( QStringList&, QStringList& );
52 
57  int set_keys( QStringList& );
58 
63  int set_value( QString, int );
64 
69  int set_value( QString, double );
70 
75  int set_value( QString, QString );
76 
79  int flush_record( void );
80 
84  int write_defs( double = 0.0 );
85 
88  int close_write_data( void );
89 
93  int open_read_data( QString );
94 
97  int time_count( );
98 
104  int time_range( bool*, double*, double* );
105 
110  int field_keys( QStringList*, QStringList* );
111 
115  int read_record( int = -1 );
116 
122  int time_ivalue( const QString, int* = 0 );
123 
129  double time_dvalue( const QString, int* = 0 );
130 
136  QString time_svalue( const QString, int* = 0 );
137 
140  int close_read_data( void );
141 
145  QString error_message( int );
146 
149  QString last_error_message( void );
150 
156  static int dbCreate ( US_DB2*, const int, const QString );
157 
162  static int dbDelete ( US_DB2*, const int );
163 
173  static int dbExamine ( US_DB2*, int* = 0, int* = 0, QString* = 0,
174  QString* = 0, QString* = 0, QDateTime* = 0 );
175 
181  static int dbDownload( US_DB2*, const int, const QString );
182 
188  static int dbUpload ( US_DB2*, const int, const QString );
189 
190  private:
191 
192  QFile* fileo;
193  QFile* filei;
194 
195  QDataStream* dso;
196  QDataStream* dsi;
197 
198  QString filename;
199  QString filepath;
200  QString fvers;
201  QString error_msg;
202 
203  bool lit_endian;
204  bool wr_open;
205  bool rd_open;
206  bool const_ti;
207 
208  int dbg_level;
209  int int_size;
210  int ntimes;
211  int nvalues;
212  int timex;
213  int fhdr_size;
214  int rec_size;
215 
216  double time_inc;
217  double time_first;
218 
219  qint64 file_size;
220 
221  char* cdata;
222  char cwork[ 256 ];
223 
224  QStringList keys;
225  QStringList fmts;
226  QList< int > offs;
227 
228  private slots:
229 
231  int uhword ( char* );
233  int hword ( char* );
235  int iword ( char* );
237  float fword ( char* );
239  double dword ( char* );
241  double d8word ( char* );
243  void store_hword ( char*, int );
245  void store_iword ( char*, int );
247  void store_fword ( char*, double );
249  void store_dword ( char*, double );
251  void store_hwords( char*, int*, int );
253  void store_iwords( char*, int*, int );
255  void store_fwords( char*, double*, int );
257  int set_error ( int );
259  int key_parameters( const QString, int*, int*, int* );
260 };
261 #endif
262