Template:Language - Python Editing The Examples: Difference between revisions
From Phidgets Support
m (Mparadis moved page Template:Python Editing The Examples to Template:Language - Python Editing The Examples) |
No edit summary |
||
Line 33: | Line 33: | ||
Notice that you can leave out any parameter not relevant to your application for simplicity. | Notice that you can leave out any parameter not relevant to your application for simplicity. | ||
You can then manipulate the rest of the code as your application requires. A more in-depth description of programming with Phidgets | You can then manipulate the rest of the code as your application requires. A more in-depth description of programming with Phidgets can be found in our guide on [[Phidgets Programming Basics]]. |
Revision as of 23:04, 28 February 2019
Editing the Examples
To get our example code to run in a custom application, simply remove the calls to AskForDeviceParameters and PrintEventDescriptions, and hard-code the addressing parameters for your application.
If you are unsure what values to use for the addressing parameters, check the Finding The Addressing Information page.
For instance:
channelInfo = AskForDeviceParameters(ch)
ch.setDeviceSerialNumber(channelInfo.deviceSerialNumber)
ch.setHubPort(channelInfo.hubPort)
ch.setIsHubPortDevice(channelInfo.isHubPortDevice)
ch.setChannel(channelInfo.channel)
if(channelInfo.netInfo.isRemote):
ch.setIsRemote(channelInfo.netInfo.isRemote)
if(channelInfo.netInfo.serverDiscovery):
Net.enableServerDiscovery(PhidgetServerType.PHIDGETSERVER_DEVICEREMOTE)
else:
Net.addServer("Server", channelInfo.netInfo.hostname,
channelInfo.netInfo.port, channelInfo.netInfo.password, 0)
Might become:
ch.setDeviceSerialNumber(370114)
ch.setHubPort(2)
ch.setIsHubPortDevice(1)
Notice that you can leave out any parameter not relevant to your application for simplicity.
You can then manipulate the rest of the code as your application requires. A more in-depth description of programming with Phidgets can be found in our guide on Phidgets Programming Basics.