slotUI/slotCli.py

changeset 124
0b12a8bf23b2
parent 123
ec623e5fcbca
child 137
94d71156517b
equal deleted inserted replaced
123:ec623e5fcbca 124:0b12a8bf23b2
77 77
78 class SlotCli(): 78 class SlotCli():
79 def __init__(self, test = None, dev=""): 79 def __init__(self, test = None, dev=""):
80 self.box = Blackbox() 80 self.box = Blackbox()
81 self.nofuel = False 81 self.nofuel = False
82 self.pitfinish = False
82 if (not test): 83 if (not test):
83 self.box.connect(dev) 84 self.box.connect(dev)
84 self.rpcserver = SlotServer(self.box) 85 self.rpcserver = SlotServer(self.box)
85 self.rpcserver.start() 86 self.rpcserver.start()
86 self.slot_dummy = { 87 self.slot_dummy = {
298 #print cli.box.fueldivisor(0) 299 #print cli.box.fueldivisor(0)
299 self.box.query("F0\n") # set fuel logic disabled 300 self.box.query("F0\n") # set fuel logic disabled
300 else: 301 else:
301 #print cli.box.fueldivisor(25) 302 #print cli.box.fueldivisor(25)
302 self.box.query("F1\n") # set fuel logic enabled 303 self.box.query("F1\n") # set fuel logic enabled
304
305 if self.pitfinish:
306 self.box.query("X1\n") # set pitlane finish function
307 else:
308 #print cli.box.fueldivisor(25)
309 self.box.query("X0\n")
310
303 self.box.query("*%i\n" % live) # set live fuel info 311 self.box.query("*%i\n" % live) # set live fuel info
304 312
305 def monitor_learn(self, slot): 313 def monitor_learn(self, slot):
306 # clear garbage in UART rx buffer 314 # clear garbage in UART rx buffer
307 self.box.query("*0\n") # set live fuel info 315 self.box.query("*0\n") # set live fuel info
644 parser = OptionParser(version="%prog " + VERSION) 652 parser = OptionParser(version="%prog " + VERSION)
645 parser.add_option("--live", dest="live", action="store_true", default=False, 653 parser.add_option("--live", dest="live", action="store_true", default=False,
646 help="Run Live monitor on console", metavar="[0-5]") 654 help="Run Live monitor on console", metavar="[0-5]")
647 parser.add_option("--nofuel", dest="nofuel", action="store_true", default=False, 655 parser.add_option("--nofuel", dest="nofuel", action="store_true", default=False,
648 help="Disable Freeslot fuel management", metavar="[0-5]") 656 help="Disable Freeslot fuel management", metavar="[0-5]")
657 parser.add_option("--pit", dest="pitfinish", action="store_true", default=False,
658 help="Pitlane entry acts as finish line too", metavar="[0-5]")
649 parser.add_option("--learn", dest="learn", action="store_true", default=False, 659 parser.add_option("--learn", dest="learn", action="store_true", default=False,
650 help="Run Learning mode for [slot]", metavar="[0-5]") 660 help="Run Learning mode for [slot]", metavar="[0-5]")
651 parser.add_option("--teach", dest="playback", 661 parser.add_option("--teach", dest="playback",
652 help="Playback teach file", metavar="[filename]") 662 help="Playback teach file", metavar="[filename]")
653 663
681 # should a CLI function be started? 691 # should a CLI function be started?
682 692
683 if options.live: 693 if options.live:
684 # start the live monitor 694 # start the live monitor
685 cli.nofuel = options.nofuel 695 cli.nofuel = options.nofuel
696 cli.pitfinish = options.pitfinish
686 cli.monitor() 697 cli.monitor()
687 sys.exit(0) 698 sys.exit(0)
688 699
689 # check commandline if we have to program something 700 # check commandline if we have to program something
690 if not options.carid: 701 if not options.carid:

mercurial