NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Database storage of a waveform

TestStand 2.0 has a wave data type when using an IVI scope step and this is stored in the database in binary format. When looking at the HTML report file, an image of the waveform is shown. What is the format of the data in the database and what do I need to do to recreate the waveform. If it helps at all, what I'm doing is creating a web front end for viewing database entries so that I can disable report generation.
0 Kudos
Message 1 of 2
(2,987 Views)
When the data was stored the code created a safearray of bytes and the raw data is copied from the C array of double. If you fetch the value and get a pointer to the raw byte safearray data, then you can convert that to a array of double values and operate on this version of the data.

Some VB code might look like this:
Private Function ConvertByteData(RawData As Variant, vtToType As eDataTypes) As Variant
Dim i As Integer
Dim offset As Integer
Dim upperBound As Long
Dim Size As Integer
Dim b(8) As Byte
Dim dDouble() As Double
Dim fFloat() As Single
Dim sShort() As Integer
Dim lLong() As Long
Dim vtData As Variant

upperBound = UBound(RawData)

'upperBound is zero based, so add 1 before doing calc
're-dim to actual number of elements
Select Case vtToType
Case kInt
Size = 2
ReDim sShort((upperBound + 1) \ Size - 1)
Case kLong
Size = 4
ReDim lLong((upperBound + 1) \ Size - 1)
Case kFloat
Size = 4
ReDim fFloat((upperBound + 1) \ Size - 1)
Case kDouble
Size = 8
ReDim dDouble((upperBound + 1) \ Size - 1)
End Select

'copy data from source to destination
For offset = 0 To upperBound Step Size
'move each btye to local variable, cannot do memcpy from variant
For i = 0 To Size - 1
b(i) = RawData(offset + i)
Next i

Select Case vtToType
Case kInt
CopyMemory sShort(offset \ Size), b(0), Size
Case kLong
CopyMemory lLong(offset \ Size), b(0), Size
Case kFloat
CopyMemory fFloat(offset \ Size), b(0), Size
Case kDouble
CopyMemory dDouble(offset \ Size), b(0), Size
End Select

Next offset

Select Case vtToType
Case kInt
ConvertByteData = sShort
Case kLong
ConvertByteData = lLong
Case kFloat
ConvertByteData = fFloat
Case kDouble
ConvertByteData = dDouble
End Select

End Function
Scott Richardson
0 Kudos
Message 2 of 2
(2,987 Views)