Phidgets Script
Posted: Fri Jun 17, 2016 3:49 pm
Na lange tijd het schrijven van een scriptje om mijn RFID labels uit mijn CD verzameling in te lezen weer gestart.
Scriptje is er nog even fine tunen.
Vergeet niet in de seetings.ini het regeltje ScriptingReferences = Phidgets.RFID;Phidget21.NET.dll toe tevoegen en de phidgets.dll file onder de root van homeseer te kopieren.
Een Device aangemaakt met ref 963 (met als naam TAG) Daarin komt de tag ID en de device gaat op on als er een tag op werdt gelegd en op off als hij weer wordt verwijderd.
Imports Phidgets.RFID
Dim WithEvents phidgetRFID As Phidgets.RFID
Private WithEvents tagTxt As String
Sub Main(ByVal varParameters)
phidgetRFID = New Phidgets.RFID()
phidgetRFID.open()
End Sub
'attach event handler..populate the details fields as well as display the attached status. enable the checkboxes to change
'the values of the attributes of the RFID reader such as enable or disable the antenna and onboard led.
Private Sub phidgetRFID_Attach(ByVal sender As Object, ByVal e As Phidgets.Events.AttachEventArgs) Handles phidgetRFID.Attach
hs.WriteLog("RFID connected", phidgetRFID.Attached & " " & (Str(phidgetRFID.SerialNumber)))
phidgetRFID.LED = True
phidgetRFID.LED = False
End Sub
'Tag event handler...we'll display the tag code in the Device string of HS3
Private Sub phidgetRFID_Tag(ByVal sender As Object, ByVal e As Phidgets.Events.TagEventArgs) Handles phidgetRFID.Tag
phidgetRFID.LED = True
phidgetRFID.outputs(1) = True
tagTxt = e.Tag
hs.SetDeviceString(300,tagTxt, True)
hs.SetDeviceValueByRef(300, 100, True)
hs.WriteLog("Tag", tagTxt)
End Sub
Private Sub phidgetRFID_RFIDTagLost(ByVal sender As Object, ByVal e As Phidgets.Events.TagEventArgs) Handles phidgetRFID.TagLost
phidgetRFID.LED = False
phidgetRFID.outputs(1) = False
tagTxt = "Geen CD"
hs.SetDeviceString(300,tagTxt, True)
hs.SetDeviceValueByRef(300, 0, True)
hs.WriteLog("Tag", tagTxt)
End Sub
Private Sub phidgetRFID_Detach(ByVal sender As Object, ByVal e As Phidgets.Events.DetachEventArgs) Handles phidgetRFID.Detach
If phidgetRFID.Attached = True Then
phidgetRFID.close()
End If
End Sub
Scriptje is er nog even fine tunen.
Vergeet niet in de seetings.ini het regeltje ScriptingReferences = Phidgets.RFID;Phidget21.NET.dll toe tevoegen en de phidgets.dll file onder de root van homeseer te kopieren.
Een Device aangemaakt met ref 963 (met als naam TAG) Daarin komt de tag ID en de device gaat op on als er een tag op werdt gelegd en op off als hij weer wordt verwijderd.
Imports Phidgets.RFID
Dim WithEvents phidgetRFID As Phidgets.RFID
Private WithEvents tagTxt As String
Sub Main(ByVal varParameters)
phidgetRFID = New Phidgets.RFID()
phidgetRFID.open()
End Sub
'attach event handler..populate the details fields as well as display the attached status. enable the checkboxes to change
'the values of the attributes of the RFID reader such as enable or disable the antenna and onboard led.
Private Sub phidgetRFID_Attach(ByVal sender As Object, ByVal e As Phidgets.Events.AttachEventArgs) Handles phidgetRFID.Attach
hs.WriteLog("RFID connected", phidgetRFID.Attached & " " & (Str(phidgetRFID.SerialNumber)))
phidgetRFID.LED = True
phidgetRFID.LED = False
End Sub
'Tag event handler...we'll display the tag code in the Device string of HS3
Private Sub phidgetRFID_Tag(ByVal sender As Object, ByVal e As Phidgets.Events.TagEventArgs) Handles phidgetRFID.Tag
phidgetRFID.LED = True
phidgetRFID.outputs(1) = True
tagTxt = e.Tag
hs.SetDeviceString(300,tagTxt, True)
hs.SetDeviceValueByRef(300, 100, True)
hs.WriteLog("Tag", tagTxt)
End Sub
Private Sub phidgetRFID_RFIDTagLost(ByVal sender As Object, ByVal e As Phidgets.Events.TagEventArgs) Handles phidgetRFID.TagLost
phidgetRFID.LED = False
phidgetRFID.outputs(1) = False
tagTxt = "Geen CD"
hs.SetDeviceString(300,tagTxt, True)
hs.SetDeviceValueByRef(300, 0, True)
hs.WriteLog("Tag", tagTxt)
End Sub
Private Sub phidgetRFID_Detach(ByVal sender As Object, ByVal e As Phidgets.Events.DetachEventArgs) Handles phidgetRFID.Detach
If phidgetRFID.Attached = True Then
phidgetRFID.close()
End If
End Sub