implemented new --drive command to CLI

Thu, 08 Dec 2011 17:22:14 +0100

author
Malte Bayer <mbayer@neo-soft.org>
date
Thu, 08 Dec 2011 17:22:14 +0100
changeset 50
84b8ab4cd79e
parent 49
3957ff8e86c6
child 51
ec9e8cc27012

implemented new --drive command to CLI

slotUI/SlotCli.py file | annotate | diff | comparison | revisions
slotUI/freeslot.py file | annotate | diff | comparison | revisions
--- a/slotUI/SlotCli.py	Thu Dec 08 17:16:06 2011 +0100
+++ b/slotUI/SlotCli.py	Thu Dec 08 17:22:14 2011 +0100
@@ -35,6 +35,8 @@
         help="Set car lights blinking state", metavar="[on|off]")
     parser.add_option("--limit", dest="limit",
         help="Controlled SPEED LIMIT (15 = no limit)", metavar="[0-15]")
+    parser.add_option("--drive", dest="drive",
+        help="Controlled SPEED MINIMUM (0 = disabled)", metavar="[0-15]")
 
     (options, args) = parser.parse_args()
     cli = SlotCli()
@@ -64,3 +66,6 @@
     if options.limit != None:
         print "Change Speed Limit: " + cli.box.speedlimit(int(options.carid), int(options.limit))
 
+    if options.drive != None:
+        print "Change minimum Speed drive: " + cli.box.speedminimum(int(options.carid), int(options.drive))
+
--- a/slotUI/freeslot.py	Thu Dec 08 17:16:06 2011 +0100
+++ b/slotUI/freeslot.py	Thu Dec 08 17:22:14 2011 +0100
@@ -134,6 +134,20 @@
             value = chr(ord("A") + (value-10))
         return self.com.query( "L%i%s" % (carid, value) )
 
+    def speedminimum(self, carid, value):
+        """
+        Set the minimzm controller speed for a car
+        """
+        if (carid < 0) or (carid > 5):
+            return "ERR - invalid carid"
+        if (value<0) or (value>15):
+            return "ERR - invalid value"
+        # transform value 10..15 to A..F
+        if (value>9):
+            value = chr(ord("A") + (value-10))
+        return self.com.query( "S%i%s" % (carid, value) )
+
+
     def setmode(self, mode):
         """
         Switch the Blackbox mode

mercurial