--- a/slotUI/slotCli.py Sun Dec 23 09:53:00 2012 +0100 +++ b/slotUI/slotCli.py Sat Jun 22 18:21:13 2013 +0200 @@ -8,10 +8,11 @@ from optparse import OptionParser from operator import itemgetter from subprocess import Popen, PIPE +from logger import eventLogger import sys, os from copy import copy import curses -from time import sleep +from time import sleep, time import ConfigParser import SimpleXMLRPCServer @@ -19,7 +20,7 @@ import threading -VERSION = "1.8" +VERSION = "1.8.1" MAXSLOTS = 6 TERM = { "caption": "\033[1;37m\033[1;44m", @@ -119,6 +120,8 @@ self.timelimit = 0 # race timelimit self.firstpos = -1 # first position slot self.freerun = True # freerun mode = sort order by best lap + self.raceName = "Freestyle" + self.log = eventLogger("events.log") def reset_slots(self): idx = 0 @@ -256,6 +259,21 @@ curses.noecho() self.scr.nodelay(1) # disable delay on readkey + def readRaceName(self): + self.scr.nodelay(0) # enable delay on readkey + curses.echo() + self.scr.addstr(0,0, "Enter Race Name [%s]:" % ( + self.raceName), + curses.color_pair(1)) + self.scr.refresh() + name = self.scr.getstr(1,0, 15) + if name != "": + self.raceName = name + self.cleartop() + self.scr.refresh() + curses.noecho() + self.scr.nodelay(1) # disable delay on readkey + def readLimit(self, slot): limit = self.readInt("SPEEDLIMIT for %s (%i)" % ( self.slot[slot]["name"], @@ -452,6 +470,7 @@ #elif key == ord('r'): self.readLimit(3) #elif key == ord('t'): self.readLimit(4) #elif key == ord('z'): self.readLimit(5) + elif key == ord('n'): self.readRaceName() elif key == ord('a'): if self.slot[4]["drive"] > 0: self.slot[4]["drive"] -= 1 cli.box.speedminimum(4, self.slot[4]["drive"]) @@ -515,6 +534,23 @@ self.slot[slot]["status"] = "WINNER!" self.box.query("+") # stop race + tmpname = "n/a" + if not self.freerun: + tmpname = self.raceName + self.log.push([ + time(), + self.sysclk, + tmpname, + slot, + self.slot[slot]["name"], + l, + t, + self.slot[slot]["best"], + self.laplimit, + self.timelimit + ]) + + self.render_slots() if rx[:2] == "F:":