
DWDataReader - Dynamic Link Library (v4.2.0.19)

Data structure:

enum DWStatus    // status returned from library function calls
{
      DWSTAT_OK = 0,                       // status OK
      DWSTAT_ERROR = 1,                    // error occurred in the dll
      DWSTAT_ERROR_FILE_CANNOT_OPEN = 2,         // unable to open file
      DWSTAT_ERROR_FILE_ALREADY_IN_USE = 3,      // file already in use
      DWSTAT_ERROR_FILE_CORRUPT = 4,             // file corrupted
      DWSTAT_ERROR_NO_MEMORY_ALLOC = 5           // memory not allocated
      DWSTAT_ERROR_CREATE_DEST_FILE = 6,         // error creating dest. file (only for
d7z files)
      DWSTAT_ERROR_EXTRACTING_FILE = 7,               // error extracting data (only for
d7z files)
      DWSTAT_ERROR_CANNOT_OPEN_EXTRACTED_FILE = 8   // error opening extracted file (only
for d7z files)
};

enum DWChannelProps    // used for DWGetChannelProps() calls
{
      DW_DATA_TYPE = 0,           // get data type
      DW_DATA_TYPE_LEN_BYTES = 1, // get length of data type in bytes
      DW_CH_INDEX = 2,            // get channel index
      DW_CH_INDEX_LEN = 3,        // get length of channel index
      DW_CH_TYPE = 4,             // get channel type
      DW_CH_SCALE = 5,            // get channel scale
      DW_CH_OFFSET = 6,           // get channel offset
      DW_CH_XML = 7,              // get channel XML
      DW_CH_XML_LEN = 8,          // get length of channel XML
      DW_CH_XMLPROPS = 9,         // get channel XML properties
      DW_CH_XMLPROPS_LEN = 10,         // get length of channel XML properties
      DW_CH_CUSTOMPROPS = 11,           // get channel XML custom properties
      DW_CH_CUSTOMPROPS_COUNT = 12      // get length of channel XML custom properties

};

enum DWChannelType     // channel type
{
      DW_CH_TYPE_SYNC = 0,        // sync channel
      DW_CH_TYPE_ASYNC = 1,       // async channel
      DW_CH_TYPE_SV = 2           // single value channel
};

struct DWFileInfo           // structure used for data file
{
      double sample_rate;     // the sampling rate
      double start_store_time;      // absolute time of the start of storing (days)
      double duration;        // duration of data file (seconds)
};

struct DWChannel       // structure used for Dewesoft channel
{
      int index;         // unique channel identifier
      char name[100];         // the name of a channel
      char unit[20];          // the unit of a channel
      char description[200];        // the description of a channel
      unsigned int color;     // specifies the color of a channel
      int array_size;         // length of the array channel (normal array_size = 1)
      int data_type;          // channel data type – please see the data types below
};

// data types in buffer
#define MaxDataTypes 15
#define dtByte 0
#define dtShortInt 1
#define dtSmallInt 2
#define dtWord 3
#define dtInteger 4
#define dtSingle 5
#define dtInt64 6
#define dtDouble 7
#define dtLongword 8
#define dtComplexSingle 9
#define dtComplexDouble 10
#define dtText 11
#define dtBinary 12
#define dtCANPortData 13
#define dtCANFDPortData 14


struct DWEvent         // structure used for Dewesoft events
{
      int event_type;         // 1..start event; 2..stop event;...
      double time_stamp;      // relative position in seconds
      char event_text[200];   // event text
};

struct DWReducedValue  // reduced value
{
      double time_stamp;      // relative time in seconds
      double ave;             // average value
      double min;             // min value
      double max;        // max value
      double rms;             // rms value
};

struct DWArrayInfo     // array info
{
      int index;         // unique axis identifier
      char name[100];         // axis name
      char unit[20];          // axis unit
      int size;          // length of the axis size
};

struct DWCANPortData   // CAN port data
{
      Unsigned long arb_id;   // arbitration id
      char data[8];           // CAN data
};

struct DWCANFDPortData // CAN port data
{
      Unsigned long arb_id;   // arbitration id
      Unsigned char extended;
      Unsigned char reserverd1;
      Unsigned char reserverd2;
      Unsigned char dataSize;
      Unsigned char data[64];    // CAN FD data
};

struct DWComplex       // complex value
{
      double re;         // real part
      double im;         // imaginary part
};

enum DWCustomPropValueType
{
      DW_CUSTOM_PROP_VAL_TYPE_EMPTY = 0,
      DW_CUSTOM_PROP_VAL_TYPE_INT64 = 1,
      DW_CUSTOM_PROP_VAL_TYPE_DOUBLE = 2,
      DW_CUSTOM_PROP_VAL_TYPE_STRING = 3,
};

struct DWCustomProp    // structure used for custom properties
{
      char key[100];                     // custom property name
      enum DWCustomPropValueType valueType;    // type of property
      union
      {
           __int64 int64Val;
           double doubleVal;
           char strVal[100];

      } value;                            // property value
};

Functions:

DWInit

DWStatus DWInit();
Return value: See above enumerator
Description: This function call must be made prior to making any other calls.

DWDeInit

DWStatus DWDeInit();
Return value: See above enumerator
Description: This function must be called at the end of the program.

DWGetVersion

int DWGetVersion();
Return value: version number
Description: This function returns the version number of the dynamic link library.

DWOpenDataFile

DWStatus DWOpenDataFile(char* file_name, DWFileInfo* file_info);
Parameters:
      file_name – DeweSoft (d7d) data file name
      file_info – function returns the file properties
Return value: See above enumerator
Description: This function opens a data file specified by file_name.

DWCloseDataFile

DWStatus DWCloseDataFile();
Return value: See above enumerator
Description: This should be called when shutting down the application or when not more
access to a data file is needed.

DWGetChannelListCount

int DWGetChannelListCount();
Return value: the number of channels; rerutn -1 in the case of an error
Description: This function returns the number of stored channels in data file.

DWGetChannelList

DWStatus DWGetChannelList(DWChannel* channel_list);
Parameters:
      channel_list – channel list
Return value: See above enumerator
Description: This function returns the list of stored channels.

DWGetChannelFactors

DWStatus DWGetChannelFactors(int ch_index, double* scale, double* offset);
Parameters:
      ch_index – channel index
      scale – channel scale
      offset – channel offset
Return value: See above enumerator
Description: This function returns channel scale and offset.

DWGetChannelProps

DWStatus DWGetChannelProps(int ch_index, enum DWChannelProps ch_prop, void* buffer, int*
max_len);
Parameters:
      ch_index – channel index
      ch_prop – channel property selector (see DWChannelProps enumerator)
      buffer – return buffer
      max_len – buffer length
Return value: See above enumerator
Description: This function returns channel property specified with the ch_prop selector.
Please note that prior retrieving a particular property buffer must be properly
allocated. For example: In case of retrieving channel XML the DWGetChannelProps() must be
first called with DW_CH_XML_LEN selector in order to retrieve the actual XML length and
use it to properly allocate buffer. Afterwards, DWGetChannelProps() is called with
DW_CH_XML selector to retrieve the actual XML data.


DWGetScaledSamplesCount

__int64 DWGetScaledSamplesCount(int ch_index);
Parameters:
      ch_index – ch. identifier
Return value: the number of samples
Description: This function returns the number of scaled samples of a channel.

DWGetScaledSamples

DWStatus DWGetScaledSamples(int ch_index, __int64 position, int count, double* data,
double* time_stamp);
Parameters:
      ch_index – ch. identifier
      position – offset position; the first sample has position 0
      count – number of samples to be returned
      data – channel values; variable should be allocated (double precision)
      time_stamp – channel time stamps; variable should be allocated (in seconds)

Return value: See above enumerator
Description: This function returns scaled data from the direct buffer.


DWGetRawSamplesCount

Description: This function returns the number of raw samples of a channel. The function
definition is identical to DWGetScaledSamplesCount().

DWGetRawSamples

Description: This function returns raw data from the direct buffer. The function
definition is identical to DWGetScaledSamples ().

DWGetBinarySamplesCount

__int64 DWGetBinarySamplesCount(int ch_index);
Parameters:
      ch_index – ch. identifier
Return value: the number of samples in binary channel
Description: This function returns the number of samples in a binary channel.

DWGetBinarySamples

DWStatus DWGetBinarySamples(int ch_index, __int64 sampleIndex, char* data, double*
time_stamp, int* datalen);
Parameters:
      ch_index – ch. identifier
      sampleIndex – index of sample to retrieve; the first sample has position 0
      data – binary values corresponding to retrieved sample; variable should be
allocated
      time_stamp – time stamp of the retrieved sample; variable should be allocated
      data_len – number of bytes retrieved
Return value: See above enumerator
Description: This function returns binary data of the retrieved sample.



DWGetBinarySamplesEx

DWStatus DWGetBinarySamplesEx(int ch_index, __int64 sampleIndex, int count, char* data,
double* time_stamp, int* datalen);
Parameters:
      ch_index – ch. identifier
      sampleIndex – index of sample to retrieve; the first sample has position 0
      count - number of samples to be returned
      data – binary values corresponding to retrieved sample (sample format = sample bin
data length (int) + bin data (char)); variable should be allocated
      time_stamp – time stamp of the retrieved sample; variable should be allocated
      data_len – number of bytes retrieved
Return value: See above enumerator
Description: This function returns binary data of the retrieved sample.

DWGetReducedValuesCount

DWStatus DWGetReducedValuesCount(int ch_index, int* count, double* block_size);
Parameters:
      ch_index – ch. identifier
      count –a number of reduced samples
      block_size –the size of the data block in seconds
Return value: See above enumerator
Description: This function returns the number of reduced values of a channel.

DWGetReducedValues

DWStatus DWGetReducedValues(int ch_index, int position, int count, struct DWReducedValue*
data);
Parameters:
      ch_index – ch. identifier
      position – offset position; the first samlpe has position 0
      count – a number of reduced samlpes
      data –reduced values; variable should be allocated
Return value: See above enumerator
Description: This function returns scaled reduced data from the reduced buffer.

DWGetHeaderEntryCount

int DWGetHeaderEntryCount();
Return value: the number of the data header entries; returns -1 in the case of an error
Description: This function returns the number of fields in the project data header.

DWGetHeaderEntryList

DWStatus DWGetHeaderEntryList(DWChannel* channel_list);
Parameters:
      Channel_list –channel list array; variable should to be allocated
Return value: See above enumerator
Description: This function returns the header entries.

DWGetHeaderEntryText

DWStatus DWGetHeaderEntryText(int ch_index, char* text_value, int text_value_size);
Parameters:
      ch_index – ch. identifier
      text_value – entry value
      text_value_size – maximum size of the entry value
Return value: See above enumerator
Description: This function returns the data of field in the project header.

DWGetEventListCount

int DWGetEventListCount();
Return value: Returns the number of events in the data file
Description: This function returns the number of events in the data file.

DWGetEventList

DWStatus DWGetEventList(DWEvent* event_list);
Parameters:
      event_list –event list
Return value: See above enumerator
Description: This function returns the events in the data file.

DWExportHeader

DWStatus DWExportHeader(char* file_name);
Parameters:
      file_name – output file name
Return value: See above enumerator
Description: This function exports a header (*.xml) to the disk.

DWGetArrayInfoCount

int DWGetArrayInfoCount(int ch_index);
Parameters:
      ch_index – ch. identifier
Return value: Returns the number of array axis; returns -1 in the case of an error
Description: This function returns the number of axis for array channel
(DWChannel.array_size should be > 1).

DWGetArrayInfoList

DWStatus DWGetArrayInfoList(int ch_index, DWArrayInfo* array_inf_list);
Parameters:
      ch_index – ch. Identifier
      array_inf_list – list of DWArrayInfo
Return value: See above enumerator
Description: : This function returns the list of array info.

DWGetArrayIndexValue

DWStatus DWGetArrayIndexValue(int ch_index, int array_info_index, int array_value_index,
char* value, int value_size);
Parameters:
      ch_index – ch. identifier
      array_info_index – axis identifier
      array_value_index –index of value on the axis
      value – value on the axis
      value_size – maximum size of string value
Return value: See above enumerator
Description: This function returns the specific value on the axis.



Using the DWDataReader functions:

The typical scenario for using DWDataReader library functions:

   1. Call DWInit to initialize the dynamic link library

   2. Call DWOpenDataFile to open DeweSoft data file (*.d7d)

   3. Call DWGetChannelListCount to get number of channels

   4. Allocate the DWChannel structures then call DWGetChannelList to get channel list
      properties

   5. Call DWGetScaledSamplesCount to get number of all samples

   6. Allocate memory (data and time_stamp) then call DWGetScaledSamples

   7. Call DWCloseDataFile to close data file

   8. Call DWDeInit to clear and close dynamic link library



