Platforms to show: All Mac Windows Linux Cross-Platform
/Phidgets/Old Phidget Classes/Phidget RFID Test
Required plugins for this example: MBS Phidgets Plugin, MBS Util Plugin
Last modified Sun, 22th Jan 2022.
You find this example project in your MBS Xojo Plugin download as a Xojo project file within the examples folder: /Phidgets/Old Phidget Classes/Phidget RFID Test
Download this example: Phidget RFID Test.zip
Project "Phidget RFID Test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
if TargetMachO then
dim f as FolderItem = FrameworksFolderMBS(-32765).Child("Phidget21.framework")
if LoadPhidgetFrameworkMBS(f) then
MsgBox "Framework loaded"
else
MsgBox "Failed to load framework"
end if
elseif TargetWin32 then
if LoadPhidgetWindowsDLLMBS("phidget21.dll") then
MsgBox "Library loaded"
else
MsgBox "Failed to load library"
end if
elseif TargetLinux then
if LoadPhidgetLinuxLibraryMBS("phidget21.so") then
MsgBox "Library loaded"
else
MsgBox "Failed to load library"
end if
end if
End EventHandler
End Class
Class MainWindow Inherits Window
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control StaticText4 Inherits Label
ControlInstance StaticText4 Inherits Label
End Control
Control StaticText5 Inherits Label
ControlInstance StaticText5 Inherits Label
End Control
Control StaticText6 Inherits Label
ControlInstance StaticText6 Inherits Label
End Control
Control StaticText7 Inherits Label
ControlInstance StaticText7 Inherits Label
End Control
Control StaticText8 Inherits Label
ControlInstance StaticText8 Inherits Label
End Control
Control StaticText9 Inherits Label
ControlInstance StaticText9 Inherits Label
End Control
Control StaticText10 Inherits Label
ControlInstance StaticText10 Inherits Label
End Control
Control StaticText11 Inherits Label
ControlInstance StaticText11 Inherits Label
End Control
Control StaticText12 Inherits Label
ControlInstance StaticText12 Inherits Label
End Control
Control StaticText13 Inherits Label
ControlInstance StaticText13 Inherits Label
End Control
Control StaticText14 Inherits Label
ControlInstance StaticText14 Inherits Label
End Control
Control StaticText15 Inherits Label
ControlInstance StaticText15 Inherits Label
End Control
Control StaticText16 Inherits Label
ControlInstance StaticText16 Inherits Label
End Control
Control StaticText17 Inherits Label
ControlInstance StaticText17 Inherits Label
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action()
StaticText11.text=p1.GetDeviceLabel
StaticText10.text=p1.GetDeviceName
StaticText13.text=hex(p1.GetDeviceStatus)
StaticText12.text=p1.GetDeviceType
StaticText14.text=hex(p1.GetDeviceVersion)
StaticText15.text=hex(p1.GetSerialNumber)
StaticText16.text=str(p1.getAntennaOn)
StaticText17.text=str(p1.getLEDOn)
StaticText18.text=str(p1.getTagStatus)
'StaticText19.Text = str(p.getLastTag)
'p2.setDisplayString 0,"Identification ID"
'p2.setDisplayString 1,converttext(tagID)
End EventHandler
End Control
Control StaticText18 Inherits Label
ControlInstance StaticText18 Inherits Label
End Control
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
Control BevelButton1 Inherits BevelButton
ControlInstance BevelButton1 Inherits BevelButton
EventHandler Sub Action()
p1.setAntennaOn true
if p1.Lasterror <> 0 then
listbox1.AddRow "set Antenna On return error "+str(p1.Lasterror)
end if
'p2.setBacklight true
End EventHandler
End Control
Control BevelButton2 Inherits BevelButton
ControlInstance BevelButton2 Inherits BevelButton
EventHandler Sub Action()
p1.setAntennaOn false
if p1.Lasterror <> 0 then
listbox1.AddRow "set Antenna off return error "+str(p1.Lasterror)
end if
End EventHandler
End Control
Control BevelButton3 Inherits BevelButton
ControlInstance BevelButton3 Inherits BevelButton
EventHandler Sub Action()
p1.setLEDOn true
if p1.Lasterror <> 0 then
listbox1.AddRow "set LED on return error "+str(p1.Lasterror)
end if
End EventHandler
End Control
Control BevelButton4 Inherits BevelButton
ControlInstance BevelButton4 Inherits BevelButton
EventHandler Sub Action()
p1.setLEDOn false
if p1.Lasterror <> 0 then
listbox1.AddRow "set LED off return error "+str(p1.Lasterror)
end if
End EventHandler
End Control
Control StaticText91 Inherits Label
ControlInstance StaticText91 Inherits Label
End Control
Control StaticText19 Inherits Label
ControlInstance StaticText19 Inherits Label
End Control
Control TimerEffEcran Inherits Timer
ControlInstance TimerEffEcran Inherits Timer
EventHandler Sub Action()
'p2.setDisplayString 0,"Merci de vous identifier"
'p2.setDisplayString 1," "
End EventHandler
End Control
EventHandler Sub Close()
if p1 <> nil then
p1.Close
p1 = nil
end if
if p2 <> nil then
p2.Close
p2 = nil
end if
End EventHandler
EventHandler Sub Open()
' call loadPhidgetFrameworkMBS, LoadPhidgetWindowsDLLMBS or LoadPhidgetLinuxLibraryMBS
p1=new MyPhidgetRFIDMBS
// -1 for first device
'p1.Open -1
// please put your ID here to open only that device
p1.Open (112580)
p1.waitForAttachment 100
' call loadPhidgetFrameworkMBS, LoadPhidgetWindowsDLLMBS or LoadPhidgetLinuxLibraryMBS
if p1.Handle=0 then
MsgBox "Failed to create object P1."
end if
p1.setAntennaOn true
if p1.Lasterror<>0 then
MsgBox "set Antenna On return error "+str(p1.Lasterror)+" "+p1.GetErrorDescription(p1.Lasterror)
end if
End EventHandler
Sub EffEcran()
'p2.setDisplayString 0,"Identification ID"
'p2.setDisplayString 1,converttext(tagID)
TimerEffEcran.Enabled = True
TimerEffEcran.Mode = TimerEffEcran.ModeSingle
End Sub
Protected Function converttext(t as string) As string
dim u as string=ConvertEncoding(t,encodings.UTF8)
dim a,i,c as integer
dim s as string
// Phidget uses: ASCII Standard Character Set with Katakana Extension
// so we translate here a few characters manually
c=len(u)
for i=1 to c
a=asc(mid(u,i,1))
// äöüßµ–ñ∞∃αβρΣΩ÷¢
Select case a
case asc("ä")
s=s+chrb(225)
case asc("ß")
s=S+chrb(226)
case asc("€")
s=S+chrb(227)
case asc("µ")
s=S+chrb(228)
case asc("ñ")
s=S+chrb(238)
case asc("ö")
s=S+chrb(239)
case asc("∞")
s=S+chrb(&hF3)
case asc("π")
s=S+chrb(&h7F)
case asc("ü")
s=S+chrb(&hF5)
case asc("–")
s=S+chrb(&hB0)
case asc("∃")
s=s+chrb(&hD6)
case asc("α")
s=S+chrb(&hE0)
case asc("β")
s=S+chrb(&hE2)
case asc("ρ")
s=S+chrb(&hE6)
case asc("Σ")
s=s+chrb(&hF6)
case asc("Ω")
s=s+chrb(&hF4)
case asc("÷")
s=S+chrb(&hFD)
case asc("¢")
s=s+chrb(&hEC)
else
s=s+chrb(a)
end Select
next
return s
End Function
Property p1 As MyPhidgetRFIDMBS
Property p2 As MyPhidgetRFIDMBS
Property tagID As String
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MyPhidgetRFIDMBS Inherits OldPhidgetRFIDMBS
EventHandler Sub Attach()
MainWindow.ListBox1.AddRow "Attached"
End EventHandler
EventHandler Sub Detach()
MainWindow.ListBox1.AddRow "Detached"
End EventHandler
EventHandler Sub Error(errorCode as integer, errorDescription as string)
MainWindow.ListBox1.AddRow "Error "+str(errorCode)+": "+errorDescription
End EventHandler
EventHandler Sub Tag(tag as memoryblock)
dim a As String
a= Left(EncodingToHexMBS(tag),10)
MainWindow.ListBox1.AddRow "Got tag on antena : " + Str(me.GetSerialNumber) +" : " +a
MainWindow.tagID = a
setOutputState 1,True
MainWindow.EffEcran
End EventHandler
EventHandler Sub TagLost(tag as memoryblock)
setOutputState 1,False
End EventHandler
End Class
End Project
See also:
- /Phidgets/Old Phidget Classes/Phidget Manager
- /Phidgets/Old Phidget Classes/Phidget01616
- /Phidgets/Old Phidget Classes/PhidgetAccelerometer Test
- /Phidgets/Old Phidget Classes/PhidgetAccelerometer Test with Events
- /Phidgets/Old Phidget Classes/PhidgetMotorControl Test with Events
- /Phidgets/Old Phidget Classes/PhidgetTextLCD
Download this example: Phidget RFID Test.zip
The items on this page are in the following plugins: MBS Phidgets Plugin.
