UltimaSerial DataqFileII.ocx
 

Windaq add-ons
Windaq Add-ons

The following info is provided absolutely "AS IS"

DataqFileII is an undocumented File ActiveX control from DATAQ. It is a super set of the standard DataqFile control.

What's new comparing to ReadDataqFile:

  1. Supports both .WDQ and .WDC file format
  2. Supports Time-stamped Commented Event Markers and UserAnnotations

Limitations:

  1. Does not support packed HiRes .WDH files
  2. Does not support time-stamped event markers in .WDC file

indicates new features comparing to DataqFile control

Like DataqFile control, it contains two parts, ReadDataqFileII and WriteDataFileII. We are going to show their extra features

ReadDataqFileII

Properties

  • ChannelCount
    • This property returns the number of channels recorded in the WinDaq file.
  • CurrentLocation
    • Returns the current location in the file in terms of scans from the beginning.
  • EventCount
    • Returns the total counts of event markers in the .WDC file trailer
    • Syntax: Total= ReadDataqFileII1.EventCount
  • FileName
    • Specifies the path and the file name of the file to read
  • TotalScans
    • Returns the total scans of the file being read
  • SampleRate
    • Returns the sample rate of the file being read
  • EventDTStamp
    • Returns the Date/Time stamp of a specified event
  • EventLocation
    • Returns the offset of a specified event in terms of scans
    • Syntax: Location = ReadDataqFileII1.EventLocation(i)
  • UserChnAn 
    • Returns the user channel annotation of a specified channel
    • Syntax: Location = ReadDataqFileII1.UserChnAn  (i)
  • EventComment
    • Returns the user comment for a specified event
    • Syntax: Location = ReadDataqFileII1.EventComment (i)

Methods

  • Close
    • Closes the file
  • EUTag
    • Returns the engineering units tag of a specified channel
  • GetData
    • This function returns the specified amount of data back in variant form (e.g., in order to plot data in a chart). There are two parameters for this function:

      The first parameter sets the number of channel scans to be returned. One scan is defined as one pass through all enabled channels (i.e., one sample per channel). This value must be between 1 and 32,767.

      The second parameter defines the format of the data returned. Valid settings are: 0 for 2’s complement binary data (FormatBinary); and 1 for data scaled in engineering units (FormatScaled)

  • GetDataEx
    • Acquire data and place in buffer. Data is scaled in engineering units.

      The first parameter is a one dimensional array of double floating point values scaled in engineering units.

      The second parameter is the number of data points (sets of data values, one for each channel).

      Sometimes it is necessary to process the data before it is displayed. The variant returned from GetData is difficult to access in VB since variant operation controls are not easy to find. The GetDataEx method may be used in these instances.

      This data format cannot be used with LabView or Visual Studio.Net

  • GetDataExB
    • Like GetDataEx, but in raw 16-bit integer format
  • GetIntrcpt
    • Offset when converting integer raw data to engineering data
  • GetSlope
    • Scale when converting integer raw data to engineering data
  • GoToEventMarker 
    • Similar to GoToMark, but checks only bit 1 instead of both bit 0 and 1 of channel readings

  • GoToMark
    • Search for user event mark. If the lowest two bits of channel readings are 1s. It will be considered as the mark
  • Location2Time
    • Convert scan offset to local time
  • MoveTo
    • Moves the file pointer within a WinDaq file. The pointer moves on a scan-by-scan basis where scan is defined as one pass through all enabled channels. The pointer is located at the leftmost position on the chart. There are two parameters for this function:

      The first parameter is the offset and is limited by the number of scans in the file. If the offset is a positive number, the pointer will move forward in time. If the offset is negative, the pointer will move backward.

      The second parameter is the reference (i.e., point of origin, where to offset the pointer from). A value of 0 would offset from the beginning of the file. A value other than 0 offsets from the current position.

      If you wish to see a visual representation you must also re-plot the data every time you move the pointer.

      To convert to seconds, use the SampleRate. For example, if the SampleRate is 1000 samples per second and you would like to move 2 seconds into the file use 2000 as the offset and 0 as the origin

  • Open
    • Opens the file

Events

  • EndOfFile
  • FileError
  • ControlError

WriteDataqFileII

Properties

  • ChannelCount
    • Specifies the number of channels to write to the file
  • FileName
    • Specifies the path and name of the file you are creating
  • SampleRate
    • Specifies the sample rate (per channel)
  • UserChnAn
    • Specify user channel annotation
    • Syntax: WriteDataqFileII1.UserChnAn(0) = "www.ultimaserial.com "

Methods

  • AddComment
    • Attach a comment to event marker
    • Syntax: WriteDataqFileII1.AddComment "www.ultimaserial.com "
  • Close
    • Closes and saves the file
  • EUCal
    • Specifies the linear engineering calculation equation, it should be set up before calling Open
  • EUTag
    • Specifies engineering units of a channel, it should be set up before calling Open
  • InsertEventMarker
    • Insert an event marker, time-stamp it if the parameter is true
    • Syntax: WriteDataqFileII1.InsertEventMarker 1
  • Open
    • Creates and opens the file 
  • SaveData
    • Writes data to the file
  • SaveDataEx
    • Writes data to the file

Events

  • ControlError
  • DataError
  • FileError

 

Example:

The VB sample "GenerateCalculatedWaveform" installed with UltimaSerial is a good starting point to learn how to use the WriteDataqFile control

Listing of GenerateCalculatedWaveform:

'This program shows how to generate a calculated waveform
'
Dim buffer(1000) As Integer                          'must be big enough to handle all the data
Dim cal(2000) As Integer                               'two times of the size of buffer in this sample
Dim lastpoint As Integer

Private Sub Form_Load()
'List of data acquisition devices
DeviceList.AddItem "150RS"
DeviceList.AddItem "151RS"
DeviceList.AddItem "194"
DeviceList.AddItem "195B"
DeviceList.AddItem "190"
DeviceList.AddItem "148"
DeviceList.AddItem "158"

'List of COMM ports
ComPort.AddItem "1"
ComPort.AddItem "2"
ComPort.AddItem "3"
ComPort.AddItem "USB"
End Sub


Private Sub Start_Click()
retval = Dir$(Text1.Text)

If Len(retval) > 3 Then 'confirm filename available
    MsgBox Text1.Text + " exists, please specify a new name", vbOKOnly, "Windaq file"
    Exit Sub
End If

XChart1.Channel = 1 'Show only the calculated channel
UltimaSerial.ChannelCount = 1                  '1 channel
UltimaSerial.SampleRate = 240                  'sample rate
UltimaSerial.AcquisitionMode = NoCondition
UltimaSerial.EventLevel = 2
UltimaSerial.Device = Val(DeviceList.Text)
UltimaSerial.CommPort = Val(ComPort.Text)

UltimaSerial.Start

WriteDataqFile1.FileName = Text1.Text              'data file path
WriteDataqFile1.SampleRate = UltimaSerial.SampleRate    'specify the sample rate WriteDataqFile1.ChannelCount = 2                        '2 Channels: original + differential
WriteDataqFile1.UserChnAn(0) = "Original"               'Channel 1 annotation
WriteDataqFile1.UserChnAn(1) = "Differential"           'Channel 2 annotation
WriteDataqFile1.EUCal 100, 0, 0
WriteDataqFile1.EUTag "mmHg", 0
WriteDataqFile1.Open                                    'open the file
End Sub

Private Sub Stop_Click()
UltimaSerial.Stop
WriteDataqFile1.Close
End Sub

Private Sub UltimaSerial_DriverError(ByVal ErrorCode As Integer)
Label1.Caption = UltimaSerial.MapErrorMessage(ErrorCode)
End Sub

Private Sub UltimaSerial_NewData(ByVal Count As Integer)
If Count > 1000 Then Count = 1000                 ' to prevent buffer overflow
UltimaSerial.GetDataEx buffer(0), Count            'the data will be in the array
XChart2.ChartEx buffer(0), 1, Count                'plot the original channels here

'Derive differential channel
l& = CLng(buffer(0)) - CLng(lastpoint)
cal(0) = lastpoint
If l& > 32767 Then                              'Prevent overflow
    cal(1) = 32767
ElseIf l& < -32768 Then                         'Prevent underflow
    cal(1) = -32768
Else
    cal(1) = l&
End If

For i = 1 To Count - 1                           'evaluate the calculated channel
    l& = CLng(buffer(i)) - CLng(buffer(i - 1))
    If l& > 32767 Then                              'Prevent overflow
        cal(i * 2 + 1) = 32767
    ElseIf l& < -32768 Then                         'Prevent underflow
        cal(i * 2 + 1) = -32768
    Else
        cal(i * 2 + 1) = l&
    End If
    cal(i * 2) = buffer(i)
Next
lastpoint = buffer(Count - 1)

XChart1.ChartEx cal(0), 2, Count                  'chart the calculated channel
WriteDataqFile1.SaveDataEx cal(0), Count * 2     'stream the calculated channel to file

End Sub

 

 

 

Last update: 02/28/22

Copyright: 2000-2005  www.UltimaSerial.com