I would love a 2nd set of eyes because what I need to accomplish has to be easy I am just over thinking this thing.
First some Background: I have a program that uses Phidgets RFID readers and a weight sensor, All of this and the current state of the program works perfectly.
When the RFID reader reads a tag it makes sure the min. weight is also present and then launches a macro in another program. If the Tag goes out of range and/or the weight on the scale goes below the min. it stops, rinses and repeats when a tag is scanned again.
FYI this whole apparatus is for Behavioral Pigeon research in a college Psychology Dept. We use an industry standard program for our research but is has no customization or autonomy. That is where my app comes in, simply put it listens for the RFID and weight and if given the go it passes the info to the Psych program via simple macros the psych program will accept. The whole thing is ties to a contraption that allows the pigeons to choose when they want to run experiments for us in return for yummy birdseed rewards..... Anyway
Now for the Issue:
We now want to add a contingency to lockout greedy pigeons who has began guarding the platform so only they can access the system for food (The RFID tag is on each pigeons ankle so the system recognizes them by ID/Name)
So I added a timer that we can customize with a text box IE: 30000ms, then tied it to a checkbox so we can turn the condition on and off. That works fine. What I need is when the pigeon leaves and the system resets everything it starts the timer, If that same RFID tag is scanned again within that timer it ignores it and simply logs the scan but does not run the macro. If a different RFID scans it just runs as normal.
Here is the current Sub that handles RFID Tags and works as normal:
Pretty Basic, no shock it works fineCode:'Tag event handler...we'll display the tag code in the field on the GUI Public Sub PhidgetRfidTag(ByVal sender As Object, ByVal e As TagEventArgs) Handles PhidgetRfid.Tag MinimumStartThreshhold = CInt(FormOpt.TxtBxMinStart.Text) gramData = CInt(ActiveWeight.Text) LabelTagLive.Text = e.Tag If e.Tag IsNot Nothing Then ValidTag = True Else ValidTag = False End If If gramData > MinimumStartThreshhold Then ValidWeight = True Else ValidWeight = False End If If ValidTag And ValidWeight = True Then UpdateTextBoxNormal() '-Updates the DataGrid with Subject and RFID info. MacroExecute() '-Runs the Macro to Launch Med-PC IV Else End If End Sub
So when I add the conditions for watching if a tag string is locked out I used the following changes with odd results...
I made a simple sub to compare the incoming string to the last:
I have gotten mixed info on how to use the String.Equals function should I represent the boolean answers as True/False or 0/1? or does it matter?Code:Public Sub LockoutCompare() Dim TagScanned = LabelTagCurrent.Text Dim TagLast = LabelTagLast.Text If String.Equals(TagScanned, TagLast) = True Then Lockout = True Else Lockout = False End If End Sub
Then I added the extra conditions to the closing of sessions by simply starting the timer if the box is checked:
On the Timer Tick:Code:If FormOpt.CheckBoxDelay.Checked Then TimerLockout.Start() Lockout = True End If
And finally the changes made to the On tag Event:Code:Private Sub TimerLockout_Tick(sender As Object, e As EventArgs) Handles TimerLockout.Tick TimerLockout.Stop() Lockout = False '-Stops the timer if Previous RFID does not return then sets lockout to False End Sub
In a nutshell what I have works halfway... If I enable the checkbox it basically locks out everything haha. The answer has got to be plain enough to allow you all to shame me ...Code:'Tag event handler...we'll display the tag code in the field on the GUI Public Sub PhidgetRfidTag(ByVal sender As Object, ByVal e As TagEventArgs) Handles PhidgetRfid.Tag MinimumStartThreshhold = CInt(FormOpt.TxtBxMinStart.Text) gramData = CInt(ActiveWeight.Text) LabelTagLive.Text = e.Tag If e.Tag IsNot Nothing And FormOpt.CheckBoxDelay.Checked = False Then ValidTag = True Else ValidTag = False End If If gramData > MinimumStartThreshhold Then ValidWeight = True Else ValidWeight = False End If If FormOpt.CheckBoxDelay.Checked = True Then LockoutCompare() If Lockout = True And TimerLockout.Enabled = True Then UpdateTextBoxLockout() '-Update DataGrid to reflect Lockout TimerLockout.Start() '-Restart the Timer Else End If End If If ValidTag And ValidWeight = True Then UpdateTextBoxNormal() MacroExecute() Else End If End Sub
Anyone got something?





Reply With Quote
