Platforms to show: All Mac Windows Linux Cross-Platform

/Phidgets/Phidgets 1012.8 Test


You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Phidgets/Phidgets 1012.8 Test

This example is the version from Mon, 15th May 2022.

Project "Phidgets 1012.8 Test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() End EventHandler
End Class
Class MainWindow Inherits Window
ComputedProperty Shared Untitled As Integer
End ComputedProperty
Control list Inherits Listbox
ControlInstance list Inherits Listbox
End Control
Control channel Inherits CheckBox
ControlInstance channel(0) Inherits CheckBox
ControlInstance channel(1) Inherits CheckBox
ControlInstance channel(2) Inherits CheckBox
ControlInstance channel(3) Inherits CheckBox
ControlInstance channel(4) Inherits CheckBox
ControlInstance channel(5) Inherits CheckBox
ControlInstance channel(6) Inherits CheckBox
ControlInstance channel(7) Inherits CheckBox
ControlInstance channel(8) Inherits CheckBox
ControlInstance channel(9) Inherits CheckBox
ControlInstance channel(10) Inherits CheckBox
ControlInstance channel(11) Inherits CheckBox
ControlInstance channel(12) Inherits CheckBox
ControlInstance channel(13) Inherits CheckBox
ControlInstance channel(14) Inherits CheckBox
ControlInstance channel(15) Inherits CheckBox
End Control
Control Output_selection Inherits Label
ControlInstance Output_selection Inherits Label
End Control
Control Output_status Inherits Label
ControlInstance Output_status Inherits Label
End Control
Control quit_button Inherits PushButton
ControlInstance quit_button Inherits PushButton
EventHandler Sub Action() dim i as integer Qstop=true timer1.mode = 0 quit_button.caption = "Closing all channels now" for i=0 to 15 po(i).state=false next for i=0 to 15 po(i).close next quit End EventHandler
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() dim i as integer for i=0 to 15 call po(i).openwaitforattachment(5000) if channel(i).value then po(i).state =true rectangle1(i).FillColor = rgb(200,0,0) else po(i).state =false rectangle1(i).FillColor = rgb(0,200,0) end if next End EventHandler
End Control
Control Rectangle1 Inherits Rectangle
ControlInstance Rectangle1(0) Inherits Rectangle
ControlInstance Rectangle1(1) Inherits Rectangle
ControlInstance Rectangle1(2) Inherits Rectangle
ControlInstance Rectangle1(3) Inherits Rectangle
ControlInstance Rectangle1(4) Inherits Rectangle
ControlInstance Rectangle1(5) Inherits Rectangle
ControlInstance Rectangle1(6) Inherits Rectangle
ControlInstance Rectangle1(7) Inherits Rectangle
ControlInstance Rectangle1(8) Inherits Rectangle
ControlInstance Rectangle1(9) Inherits Rectangle
ControlInstance Rectangle1(10) Inherits Rectangle
ControlInstance Rectangle1(11) Inherits Rectangle
ControlInstance Rectangle1(12) Inherits Rectangle
ControlInstance Rectangle1(13) Inherits Rectangle
ControlInstance Rectangle1(14) Inherits Rectangle
ControlInstance Rectangle1(15) Inherits Rectangle
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control Label3 Inherits Label
ControlInstance Label3 Inherits Label
End Control
Control Label4 Inherits Label
ControlInstance Label4 Inherits Label
End Control
Control Label5 Inherits Label
ControlInstance Label5 Inherits Label
End Control
Control Label6 Inherits Label
ControlInstance Label6 Inherits Label
End Control
Control Label7 Inherits Label
ControlInstance Label7 Inherits Label
End Control
Control Label8 Inherits Label
ControlInstance Label8 Inherits Label
End Control
Control Label9 Inherits Label
ControlInstance Label9 Inherits Label
End Control
Control Label10 Inherits Label
ControlInstance Label10 Inherits Label
End Control
Control Label11 Inherits Label
ControlInstance Label11 Inherits Label
End Control
Control Label12 Inherits Label
ControlInstance Label12 Inherits Label
End Control
Control Label13 Inherits Label
ControlInstance Label13 Inherits Label
End Control
Control Label14 Inherits Label
ControlInstance Label14 Inherits Label
End Control
Control Label15 Inherits Label
ControlInstance Label15 Inherits Label
End Control
Control Label16 Inherits Label
ControlInstance Label16 Inherits Label
End Control
EventHandler Sub Open() System.DebugLog CurrentMethodName dim i as integer dim Qstop as boolean #If TargetWindows Const path = "Phidget22.dll" #Else TargetMacOS Then Const path = "/Library/Frameworks/Phidget22.framework" #Else // todo? #EndIf If PhidgetManagerMBS.LoadLibrary(path) Then MainWindow.list.AddRow "Phidget Library 22 loaded successfully" Else MsgBox PhidgetManagerMBS.LibraryLoadError Return End If // following variable is now a shared property in main // dim po(15) as MyPhidgetDigitalOutput for i=0 to 15 po(i) = new MyPhidgetDigitalOutput po(i).channel = i next call po(0).openwaitforattachment(5000) list.addrow "handle from myphidgetoutput = "+str(po(0).Handle)+endofline list.addrow "device name of phidget = "+po(0).devicename+endofline list.addrow "serial number of phidget = "+str(po(0).deviceserialnumber)+endofline Qstop=false Exception err msgbox "Could not find the targeted I/O board, or could not communicate with it" End EventHandler
Property Qstop As boolean = false
Property Shared po(24) As MyPhidgetDigitalOutput
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class MyPhidgetManager Inherits PhidgetManagerMBS
EventHandler Sub Attached(phid as PhidgetMBS) System.DebugLog CurrentMethodName MainWindow.list.AddRow "Device attached" MainWindow.list.AddRow " Name: " + phid.DeviceName MainWindow.list.AddRow " Serialnumber: " + Str(phid.DeviceSerialNumber) MainWindow.list.AddRow " Device ID: " + Str(phid.DeviceID) MainWindow.list.AddRow " Device Label: " + phid.DeviceLabel MainWindow.list.AddRow " Channel: " + Str(phid.Channel) MainWindow.list.AddRow " ChannelClass: " + Str(phid.ChannelClass)+" "+phid.ChannelClassName MainWindow.list.AddRow " ChannelSubclass: " + Str(phid.ChannelSubclass) MainWindow.list.AddRow "" 'dim s1 as string ' 's1 = s1+"Device attached"+endofline 's1 = s1+ " Name: " + phid.DeviceName+endofline 's1 = s1+ " Serialnumber: " + Str(phid.DeviceSerialNumber)+endofline 's1 = s1+ " Device ID: " + Str(phid.DeviceID)+endofline 's1 = s1+ " Device Label: " + phid.DeviceLabel+endofline 's1 = s1+ " Channel: " + Str(phid.Channel) 's1 = s1+ " ChannelClass: " + Str(phid.ChannelClass)+" "+phid.ChannelClassName+endofline 's1 = s1+ " ChannelSubclass: " + Str(phid.ChannelSubclass)+endofline ' ' 'msgbox s1 End EventHandler
EventHandler Sub Detached(phid as PhidgetMBS) System.DebugLog CurrentMethodName MainWindow.list.AddRow "Device detached" MainWindow.list.AddRow " Name: " + phid.DeviceName MainWindow.list.AddRow " Serialnumber: " + Str(phid.DeviceSerialNumber) MainWindow.list.AddRow " Device ID: " + Str(phid.DeviceID) MainWindow.list.AddRow " Device Label: " + phid.DeviceLabel MainWindow.list.AddRow " Channel: " + Str(phid.Channel) MainWindow.list.AddRow " ChannelClass: " + Str(phid.ChannelClass)+" "+phid.ChannelClassName MainWindow.list.AddRow " ChannelSubclass: " + Str(phid.ChannelSubclass) MainWindow.list.AddRow "" End EventHandler
EventHandler Sub Error(errorCode as Integer, errorString as String) System.DebugLog CurrentMethodName MainWindow.list.AddRow "Error: "+Str(errorCode)+": "+errorString End EventHandler
End Class
Class MyPhidgetLCDMBS Inherits PhidgetLCDMBS
EventHandler Sub Attached() System.DebugLog CurrentMethodName // MainWindow.list.AddRow "Device attached" End EventHandler
EventHandler Sub Detached() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub Error(errorCode as Integer, errorString as String) System.DebugLog CurrentMethodName System.DebugLog errorString End EventHandler
End Class
Class MyPhidgetDigitalOutput Inherits PhidgetDigitalOutputMBS
EventHandler Sub Attached() // MainWindow.list.AddRow "Output Device attached" End EventHandler
EventHandler Sub Detached() End EventHandler
EventHandler Sub Error(errorCode as Integer, errorString as String) mainwindow.list.addrow "Error for MyPhidgetOutput"+endofline mainwindow.list.addrow errorstring+endofline End EventHandler
End Class
End Project

See also:

The items on this page are in the following plugins: MBS Phidgets Plugin.


The biggest plugin in space...