00001 
00005 #ifndef _das2_encoding_h_
00006 #define _das2_encoding_h_
00007 
00008 #include <das2/util.h>
00009 #include <das2/units.h>
00010 #include <das2/buffer.h>
00011 
00013 double getDas2Fill(void);
00014 
00016 int isDas2Fill( double value );
00017 
00018 
00019 
00020 #define DAS2DT_BE_REAL 0x0001
00021 
00022 
00023 #define DAS2DT_LE_REAL 0x0002
00024 
00025 #ifdef HOST_IS_LSB_FIRST
00026 #define DAS2DT_HOST_REAL 0x0002
00027 #else
00028 #define DAS2DT_HOST_REAL 0x0001
00029 #endif
00030 
00031 
00032 
00033 
00034 
00035 
00036 #define DAS2DT_ASCII 0x0003
00037 
00038 
00039 
00040 
00041 
00042 
00043 #define DAS2DT_TIME 0x0004
00044 
00045 
00046 #define DASENC_FMT_LEN  64
00047 #define DASENC_TYPE_LEN 48
00048 
00070 typedef struct das_encoding{
00081    unsigned int nCat;
00082    
00088    unsigned int nWidth;
00089    
00095    char sFmt[DASENC_FMT_LEN];
00096    
00102    char sType[DASENC_TYPE_LEN];
00103    
00104 } DasEncoding;
00105 
00130 DasEncoding* new_DasEncoding(int nCat, int nWidth, const char* sFmt);
00131 
00143 DasEncoding* new_DasEncoding_str(const char* sType);
00144 
00145 
00147 DasEncoding* DasEnc_copy(DasEncoding* pThis);
00148 
00149 
00157 bool DasEnc_equals(DasEncoding* pOne, DasEncoding* pTwo);
00158 
00184 void DasEnc_setAsciiFormat(DasEncoding* pThis, const char* sValFmt, 
00185                            int nFmtWidth);
00186 
00187 
00221 void DasEnc_setTimeFormat(DasEncoding* pThis, const char* sTimeFmt, 
00222                            int nFmtWidth);
00223 
00224 
00225 
00226 #define DAS2DT_BE_REAL_8 0x0801
00227 
00228 
00229 #define DAS2DT_LE_REAL_8 0x0802
00230 
00231 
00232 #ifdef HOST_IS_LSB_FIRST
00233 #define DAS2DT_DOUBLE 0x0802
00234 #else
00235 #define DAS2DT_DOUBLE 0x0801
00236 #endif
00237 
00238 
00239 #define DAS2DT_BE_REAL_4 0x0401
00240 
00241 
00242 #define DAS2DT_LE_REAL_4 0x0402
00243 
00244 
00246 #ifdef HOST_IS_LSB_FIRST
00247 #define DAS2DT_FLOAT 0x0402
00248 #else
00249 #define DAS2DT_FLOAT 0x0401
00250 #endif
00251 
00252 
00253 #define DAS2DT_ASCII_10 0x0A03
00254 #define DAS2DT_ASCII_24 0x1804 
00255 #define DAS2DT_ASCII_14 0x0E04
00256 
00257 #define DAS2DT_TIME_25 0x1904   
00258 #define DAS2DT_TIME_28 0x1c04   
00259 
00260 
00291 unsigned int DasEnc_hash(const DasEncoding* pThis);
00292 
00293 
00310 ErrorCode DasEnc_toString(DasEncoding* pThis, char* pBuf, size_t nLen);
00311 
00312 
00331 ErrorCode DasEnc_write(DasEncoding* pThis, DasBuf* pBuf, double value,
00332                        UnitType units);
00333 
00334 
00335 
00336 
00337 
00338 
00339 
00340 
00341 
00342 
00343 
00344 
00345 
00346 
00347 
00348 
00349 
00350 
00351 
00371 ErrorCode DasEnc_read(
00372    const DasEncoding* pThis, DasBuf* pBuf, UnitType units, double* pOut
00373 );
00374 
00375 #endif