Ejemplo n.º 1
0
        def log_internal(self, outfile,funcs, parent):
            start_time = arch.time_func()
            sr_update = 0.0
            while self.done.empty():
                t = arch.time_func() - start_time
                if not self.marked.empty():
                    m = self.marked.get()
                    print >>outfile,  t, m

                sr_start = arch.time_func()
                
                if self.paused.empty():
                    line = str(t)
                    for f in funcs:
                        value = f()
                        line = line + "," + str(value)
                    if self.done.empty():
                        print >>outfile, line

                else:
                    # tricky way to "stop" when paused
                    self.paused.put(1)
                    self.paused.get(1)
                    
                if t - sr_update > SAMPLERATE_UPDATE:
                    sr_update = t
                    sr = arch.time_func() - sr_start
                    sample_rate = 1.0 / sr
                    e = UpdateLogEvent(rate = str(int(sample_rate)))
                    wx.PostEvent(parent,e)               

            self.done.get()
            self.active.release()
Ejemplo n.º 2
0
        def monitor_internal(self, port):
            while self.done.empty():
                sleep = arch.time_func()
                
                rpm   = port.RPM()
                afr   = port.AFR()
                cas   = port.CAS()
                sk    = port.SMARTKnock()
                bodc  = port.BoostODC()
                fmafi = port.FreqMAFIn()
                fmafo = port.FreqMAFOut()

                m = port.CurrentMap()
                e = UpdateMonEvent(
                    RPM    = str(rpm  ),
                    AFR    = str(afr  ),
                    CAS    = str(cas  ),
                    SK     = str(sk   ),
                    bodc   = str(bodc ),
                    fmafi  = str(fmafi),
                    fmafo  = str(fmafo),
                    cur_map= str(m    )
                    )
                while arch.time_func() - sleep < GUI_REFRESH_TIME:
                    time.sleep(YIELD_SLEEP_TIME)

                wx.PostEvent(self.frame,e)

            self.done.get()
            self.active.release()
Ejemplo n.º 3
0
        def log_internal(self, outfile, funcs, parent):
            start_time = arch.time_func()
            sr_update = 0.0
            while self.done.empty():
                t = arch.time_func() - start_time
                if not self.marked.empty():
                    m = self.marked.get()
                    print >> outfile, t, m

                sr_start = arch.time_func()

                if self.paused.empty():
                    line = str(t)
                    for f in funcs:
                        value = f()
                        line = line + "," + str(value)
                    if self.done.empty():
                        print >> outfile, line

                else:
                    # tricky way to "stop" when paused
                    self.paused.put(1)
                    self.paused.get(1)

                if t - sr_update > SAMPLERATE_UPDATE:
                    sr_update = t
                    sr = arch.time_func() - sr_start
                    sample_rate = 1.0 / sr
                    e = UpdateLogEvent(rate=str(int(sample_rate)))
                    wx.PostEvent(parent, e)

            self.done.get()
            self.active.release()
Ejemplo n.º 4
0
        def monitor_internal(self, port):
            while self.done.empty():
                sleep = arch.time_func()

                rpm = port.RPM()
                afr = port.AFR()
                cas = port.CAS()
                sk = port.SMARTKnock()
                bodc = port.BoostODC()
                fmafi = port.FreqMAFIn()
                fmafo = port.FreqMAFOut()

                m = port.CurrentMap()
                e = UpdateMonEvent(RPM=str(rpm),
                                   AFR=str(afr),
                                   CAS=str(cas),
                                   SK=str(sk),
                                   bodc=str(bodc),
                                   fmafi=str(fmafi),
                                   fmafo=str(fmafo),
                                   cur_map=str(m))
                while arch.time_func() - sleep < GUI_REFRESH_TIME:
                    time.sleep(YIELD_SLEEP_TIME)

                wx.PostEvent(self.frame, e)

            self.done.get()
            self.active.release()
Ejemplo n.º 5
0
    def RoadDyno(self, start, stop, activedialog,sources,finished):
        self.run = None
        ######################################################################
        # Wait for the the dyno run threshold to be reached
        while self.port.RPM() < start:
            if finished():
                activedialog.EndModal(0)
                return
            
            sleep = arch.time_func()
            while arch.time_func() - sleep < GUI_REFRESH_TIME:
                time.sleep(YIELD_SLEEP_TIME)
            e = UpdateDynoEvent(cur_time = 0.0, RPM = self.port.RPM(),
                                AFR=self.port.AFR(), SK=self.port.SMARTKnock())
            wx.PostEvent(activedialog,e)
        ######################################################################

        # Start "real" run
        data = []
        
        log_evt = threading.Event()

        t = threading.Thread(None, self.port.HighSpeedLog, None,
                             (sources, data),
                             { "finished" : log_evt.isSet } )
        t.start()

        while len(data) < 2 : # wait for first data point
            time.sleep(YIELD_SLEEP_TIME)

        run = dyno.DynoRun()
        
        def parseline(d):
            d = d[-1] # last line
            d = string.split(d, ",")
            return d

        line = parseline(data)
        while int(line[1]) < stop and not finished():
            ctime = float(line[0])
            rpm   = int(line[1])
            sk    = float(line[2])
            afr   = float(line[3]) 
            e = UpdateDynoEvent(cur_time = ctime , RPM = rpm, AFR=afr,
                                SK=sk)
            wx.PostEvent(activedialog,e)
            line = parseline(data)
            
            #update GUI
            sleep = arch.time_func()
            while arch.time_func() - sleep < GUI_REFRESH_TIME:
                time.sleep(YIELD_SLEEP_TIME)                            

            # remove labels
            rundata = data[1:]
            # split lines
            
            for i in range(0, len(rundata)):
                rundata[i] = string.split(rundata[i], ",")
            run.Import(rundata, 1, time_col = 0, knock_col=2,afr_col = 3)
            activedialog.rtplot.Update(run)

        log_evt.set()
 
        t.join()

        self.run = run
        activedialog.EndModal(0)
Ejemplo n.º 6
0
    def RoadDyno(self, start, stop, activedialog, sources, finished):
        self.run = None
        ######################################################################
        # Wait for the the dyno run threshold to be reached
        while self.port.RPM() < start:
            if finished():
                activedialog.EndModal(0)
                return

            sleep = arch.time_func()
            while arch.time_func() - sleep < GUI_REFRESH_TIME:
                time.sleep(YIELD_SLEEP_TIME)
            e = UpdateDynoEvent(cur_time=0.0,
                                RPM=self.port.RPM(),
                                AFR=self.port.AFR(),
                                SK=self.port.SMARTKnock())
            wx.PostEvent(activedialog, e)
        ######################################################################

        # Start "real" run
        data = []

        log_evt = threading.Event()

        t = threading.Thread(None, self.port.HighSpeedLog, None,
                             (sources, data), {"finished": log_evt.isSet})
        t.start()

        while len(data) < 2:  # wait for first data point
            time.sleep(YIELD_SLEEP_TIME)

        run = dyno.DynoRun()

        def parseline(d):
            d = d[-1]  # last line
            d = string.split(d, ",")
            return d

        line = parseline(data)
        while int(line[1]) < stop and not finished():
            ctime = float(line[0])
            rpm = int(line[1])
            sk = float(line[2])
            afr = float(line[3])
            e = UpdateDynoEvent(cur_time=ctime, RPM=rpm, AFR=afr, SK=sk)
            wx.PostEvent(activedialog, e)
            line = parseline(data)

            #update GUI
            sleep = arch.time_func()
            while arch.time_func() - sleep < GUI_REFRESH_TIME:
                time.sleep(YIELD_SLEEP_TIME)

            # remove labels
            rundata = data[1:]
            # split lines

            for i in range(0, len(rundata)):
                rundata[i] = string.split(rundata[i], ",")
            run.Import(rundata, 1, time_col=0, knock_col=2, afr_col=3)
            activedialog.rtplot.Update(run)

        log_evt.set()

        t.join()

        self.run = run
        activedialog.EndModal(0)