G
Galen Somerville
I have been converting a VB6 project to VB2005 for lo these many months.
Most of my problems have been solved thanks to people like WanYuan Wang and
Mattias Sjogren. But now the Graphics aspect is the problem.
This program gets Heart sounds and ECG trace data from a USB device via an
ActiveX thread and an internal DataReciever thread in the main program. The
display is like an oscilloscope in that it sweeps across the screen in real
time.
Six sets of samples are recieved for each update. With a 1,024 X 768 screen
I collect 170 sets of samples or 1,020 pixels worth. The VB6 program will
run at 300 Hearts Beats per minute or a set of samples every 3.412
milliseconds.
The VB2005 program fails at 20 Heart Beats per minute or a set of samples
every 51.12 milliseconds.
Timing test with QueryPerformanceCounter shows the display portion takes
about 55 milliseconds. No wonder it fails !!
The following code snippets tell the story. I hope some graphics experts can
look at my dll and give advice.
Galen
When the 24 bytes are in shared memory are received from USB thread they are
read in as 12 short integers.
Marshal.Copy(New IntPtr(m_SharedMem.ToInt32()), SoundsAry, 0, QuantBy2)
After SoundsAry is received from Data Receiver thread the 12 integers have
to be separated into Heart sounds and ECG and scaled for display into a
PlotAry.
FIXCHNS:
Nloc = 0
Pos = ArgX
For Index = 0 To gParam.NumSmps - 1
CurVal = SoundsAry(Index)
CurVal = CurVal / gScreen.CrtFactor(Nloc)
CurVal = CShort(Not CurVal) + gScreen.CenterLine(Nloc)
If CurVal < 0 Then
CurVal = 5
ElseIf CurVal > gLineY - 5 Then
CurVal = gLineY - 5
ElseIf CurVal < 5 Then
CurVal = 5
End If
PlotAry(Nloc, Pos) = CurVal
Nloc = Nloc + 1
If Nloc = gParam.NumChns Then
Nloc = 0
If gbytSwpdir = 0 Then '0 is left to right. 1 is right
to left.
Pos = Pos + 1
Else
Pos = Pos - 1
End If
End If
Next Index
Then PlotAry, for these six samples, is then processed for display thusly.
Just the code for one set of samples.
For Inner = 0 To NumChns - 1 Step 1
ArgY2 = PlotAry(Inner, Index + 1)
ArgY1 = PlotAry(Inner, Index)
Obj.DoLine(ArgX3, ArgY1, ArgX4, ArgY2, glngColors(Inner +
4))
Next Inner
ArgX3 = ArgX3 + 1
ArgX4 = ArgX4 + 1
The Obj.DoLine refers to the PictDraw picturebox on frmSweep. This is a user
control ctlPictDraw.dll which is on my web site at
http://home.surewest.net/galen/download/download.html
Most of my problems have been solved thanks to people like WanYuan Wang and
Mattias Sjogren. But now the Graphics aspect is the problem.
This program gets Heart sounds and ECG trace data from a USB device via an
ActiveX thread and an internal DataReciever thread in the main program. The
display is like an oscilloscope in that it sweeps across the screen in real
time.
Six sets of samples are recieved for each update. With a 1,024 X 768 screen
I collect 170 sets of samples or 1,020 pixels worth. The VB6 program will
run at 300 Hearts Beats per minute or a set of samples every 3.412
milliseconds.
The VB2005 program fails at 20 Heart Beats per minute or a set of samples
every 51.12 milliseconds.
Timing test with QueryPerformanceCounter shows the display portion takes
about 55 milliseconds. No wonder it fails !!
The following code snippets tell the story. I hope some graphics experts can
look at my dll and give advice.
Galen
When the 24 bytes are in shared memory are received from USB thread they are
read in as 12 short integers.
Marshal.Copy(New IntPtr(m_SharedMem.ToInt32()), SoundsAry, 0, QuantBy2)
After SoundsAry is received from Data Receiver thread the 12 integers have
to be separated into Heart sounds and ECG and scaled for display into a
PlotAry.
FIXCHNS:
Nloc = 0
Pos = ArgX
For Index = 0 To gParam.NumSmps - 1
CurVal = SoundsAry(Index)
CurVal = CurVal / gScreen.CrtFactor(Nloc)
CurVal = CShort(Not CurVal) + gScreen.CenterLine(Nloc)
If CurVal < 0 Then
CurVal = 5
ElseIf CurVal > gLineY - 5 Then
CurVal = gLineY - 5
ElseIf CurVal < 5 Then
CurVal = 5
End If
PlotAry(Nloc, Pos) = CurVal
Nloc = Nloc + 1
If Nloc = gParam.NumChns Then
Nloc = 0
If gbytSwpdir = 0 Then '0 is left to right. 1 is right
to left.
Pos = Pos + 1
Else
Pos = Pos - 1
End If
End If
Next Index
Then PlotAry, for these six samples, is then processed for display thusly.
Just the code for one set of samples.
For Inner = 0 To NumChns - 1 Step 1
ArgY2 = PlotAry(Inner, Index + 1)
ArgY1 = PlotAry(Inner, Index)
Obj.DoLine(ArgX3, ArgY1, ArgX4, ArgY2, glngColors(Inner +
4))
Next Inner
ArgX3 = ArgX3 + 1
ArgX4 = ArgX4 + 1
The Obj.DoLine refers to the PictDraw picturebox on frmSweep. This is a user
control ctlPictDraw.dll which is on my web site at
http://home.surewest.net/galen/download/download.html