Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Timer Event


Reply
 
Thread Tools Display Modes
  #1  
Old 11-25-2003, 06:27 AM
bigsidhk bigsidhk is offline
Newcomer
 
Join Date: Nov 2003
Location: Chandigarh, India
Posts: 5
Default Timer Event


Hi,

I've written a piece of hardware interfacing code, where a certain array is populated with real time data from the hardware. On top of this sits a little winsock server, serving data as requested, to client connections, from this array.

On the other end (separate application), I'm using ioComp iPlotX graphing control, with a timer set to fire every 1ms (probably firing every 55ms actually) that queries the winsock server above and receives data. this happens on every timer event. when the data comes through, it is graphed using the control. The code is currently doing 4 iterations (data fetch->graph cycles) on every timer event.

All ok so far!

The problem is that (after poring over the code), the code doesn't seem to be able to exit the procedure before the next timer event is generated. Considering the code is small, I cannot see how this is happening. My basis for the above assumption is that debug.print shows a single entry into the procedure, two loops and then another entry into the procedure and so on... but no exit!

The code is below... any and all help is most welcome!!

Thanks,


Sid

Private Sub graphTimer_Timer()

Debug.Print "entry"

Dim strChannelTag As String

For dispChannel = 0 To Plot.ChannelCount - 1
' packet format will be - "Channel1, Channel2"
' send the channel tag directly

strChannelTag = frmGraphData.Plot.Channel(dispChannel).Tag

If isConnected Then

Debug.Print "in connected", dispChannel

' send the packet
EEGClient.SendData strChannelTag & "*"

' receive data packet
' packet format will be - "ChannelValue1, ChannelValue2*"
EEGClient.GetData strChannelValue

If Len(strChannelValue) > 0 Then
' get the position of the star
starPos = InStr(strChannelValue, "*")

' get the string before that point
strChannelValue = Left(strChannelValue, starPos - 1)
End If

' parse the packet
' get the position of the comma
commaPos = InStr(strChannelValue, ",")

' we have the position
' if there is no comma, value will be zero
' malformed packet will indicate comma at the end
' packet format will be - "Channel1, Channel2"
If commaPos = 0 Or commaPos = Len(strChannelValue) Then
Exit Sub
End If

' extract the channel numbers and convert them to
' numeric values
lngChannelOneValue = Val(Trim(Mid(strChannelValue, 1, commaPos)))
lngChannelTwoValue = Val(Trim(Mid(strChannelValue, commaPos + 1)))

End If

graphval = lngChannelOneValue - lngChannelTwoValue
X = Plot.Channel(dispChannel).AddXY(runningX, graphval)

Next dispChannel

runningX = runningX + 1

Debug.Print "exit"
dispChannel = 0
End Sub
Reply With Quote
  #2  
Old 11-25-2003, 06:57 AM
Iceplug's Avatar
Iceplug Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
Default

What is the value for Plot.ChannelCount in the loop?

I also notice that you are Exiting Sub... this won't print the Debug.Print "exit" you get when the loop ends. You need Exit For for that, but you probably already knew that.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #3  
Old 11-25-2003, 09:56 PM
bigsidhk bigsidhk is offline
Newcomer
 
Join Date: Nov 2003
Location: Chandigarh, India
Posts: 5
Default

Hi, Thanks for your reply.
The channel count is 4, thats why it does 4 iterations. When I make it one, the thing executes properly.

The exit subs are on errors actually, and I don't really expect them to occur... :-)

Any ideas?

Thanks,


Sid

Quote:
Originally Posted by Iceplug
What is the value for Plot.ChannelCount in the loop?

I also notice that you are Exiting Sub... this won't print the Debug.Print "exit" you get when the loop ends. You need Exit For for that, but you probably already knew that.

Reply With Quote
  #4  
Old 11-25-2003, 11:23 PM
bigsidhk bigsidhk is offline
Newcomer
 
Join Date: Nov 2003
Location: Chandigarh, India
Posts: 5
Default

Thanks! While that 'Exit sub' wasn't the problem, it sure as hell was an indicator. I was getting malformed packets, which caused that IF to execute and exitted the sub. Now all parsing ops are within the 'If xyz len > 0' condition... and its working!

Thanks again!!


Sid
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
wbc copy to clipboard S1mon General 2 07-14-2003 09:35 AM
how do i reset my timer.. on this program... i have 1 day to do it in... ashman General 4 06-15-2003 06:26 AM
timer event Atreides General 3 02-23-2003 01:46 PM
Need help with timer, progress bar, access ... VBGestapo General 41 01-17-2002 01:28 AM
using the timer event mustang2385 General 2 11-13-2001 05:21 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->