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:
Limitations:
Like DataqFile control, it
contains two parts, ReadDataqFileII and WriteDataFileII. We are going to show their extra
features
The VB sample "GenerateCalculatedWaveform"
installed with UltimaSerial is a good starting point to learn how to use
the WriteDataqFile control
'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