srcp-scripting-en
SRCP Scripting
pyControl
To use pyControl download the developer sources of srcpd complete SVN tree! or only the files for pyControl:
- srcp.py (see note below)
and the examples:
Note: srcp.py should be at least version 0.9.2 and Rocrail 2.0 Rev 3506.
If you want to use Keyboard.py or Keyboardflex.py and not all switches are defined in Rocrail you can insert the following line after the import of srcp succeeded:
srcp.srcpcommand.setignore_412_416(1)
This will ignore some errors/warnings about undefined devices (see also pyDemo_FB.py).
Here is a short example (without any error checking):
#!/usr/bin/env python import srcp import time SRCP_BUS=1 # use switch/signal 2 and loco 3 (they have to exist in Rocrail) mySwitch = srcp.GA(SRCP_BUS, 2) myLoco = srcp.GL(SRCP_BUS, 3) # send some switch commands mySwitch.actuate(0,0) time.sleep(1) mySwitch.actuate(1,0) time.sleep(1) mySwitch.actuate(0,0) time.sleep(1) mySwitch.actuate(1,0) time.sleep(1) myLoco.setF(1,1) # set F1 myLoco.send() # send command time.sleep(1) # wait a second myLoco.setF(2,1) # set F2 myLoco.send() # send command time.sleep(1) # wait a second myLoco.setF(1,0) # reset F1 myLoco.setF(2,0) # reset F2 myLoco.send() # send above commands together
srcp-scripting-en.txt · Last modified: 2018/11/12 08:56 by 127.0.0.1