slotUI/freeslot.py

changeset 100
039ab094f79b
parent 86
79fb119cf3c3
child 116
c2fc650cc48f
equal deleted inserted replaced
99:434d60dc9b12 100:039ab094f79b
102 valid carid: 0..5 102 valid carid: 0..5
103 """ 103 """
104 if (carid < 0) or (carid > 5): 104 if (carid < 0) or (carid > 5):
105 return "ERR - invalid carid" 105 return "ERR - invalid carid"
106 cmd = -1 106 cmd = -1
107 if command == "speed": 107 if command == "accel":
108 cmd = 0 108 cmd = 0
109 if command == "brake": 109 if command == "brake":
110 cmd = 1 110 cmd = 1
111 if command == "fuel": 111 if command == "fuel":
112 cmd = 2 112 cmd = 2
113 if (cmd == -1): 113 if (cmd == -1):
114 return "ERR - invalid command" 114 return "ERR - invalid command"
115 if (value<0) or (value>15): 115 if (value<0) or (value>15):
116 return "ERR - invalid value" 116 return "ERR - invalid value"
117 if command == "accel" and value < 6:
118 return "ERR - value too low"
117 # transform value 10..15 to A..F 119 # transform value 10..15 to A..F
118 if (value>9): 120 if (value>9):
119 value = chr(ord("A") + (value-10)) 121 value = chr(ord("A") + (value-10))
120 command = "P%i%s%i" % (cmd, value, carid) 122 command = "P%i%s%i" % (cmd, value, carid)
121 response = self.com.query( command ) 123 response = self.com.query( command )

mercurial