Exemplo n.º 1
0
    def __init__(self, parent):
        """
        Perform preliminary init of all child classes, DB, etc.
        """

        # make sure GPSd is running. init the gpsd class, make sure were getting data
        # connect to the OBD interface, init it, get some sample data
        # init the database or flat file, wherever we put our data

        # assuming both of those worked, return true/ok/whatever

        # setup a filename for this data
        dt = datetime.now()
        s = dt.strftime("%Y-%m-%d_%H-%M-%S")
        self.DATA_FILE_NAME = "obdlog_" + s + ".csv"

        # set data path
        if self.DATA_FILE_PATH == "":
            self.DATA_FILE_PATH = os.path.expanduser("~")

        # intialize SunSPOT
        self.accelQueue = TuxTruck_Thread_Queue(3)
        self.accel = TuxTruck_OBDlog_SunSPOT_Reader(self, self.accelQueue,
                                                    self.SUNSPOT_PORT)

        # initialize the GPS
        self.gpsQueue = TuxTruck_Thread_Queue(3)
        self.gps = TuxTruck_OBDlog_GPS(self, self.gpsQueue)

        # initialize the OBD reader
        self.obdQueue = TuxTruck_Thread_Queue(3)
        self.obd = TuxTruck_OBDlog_OBDreader(self, self.obdQueue,
                                             self.ELMSCAN_PORT)

        # initialize the LCD
        self.lcdQueue = TuxTruck_Thread_Queue(3)
        if os.path.exists(self.LCD_PORT) and os.access(self.LCD_PORT, os.W_OK):
            self.lcd = TuxTruck_OBDlog_LCD(self, self.lcdQueue, self.LCD_PORT)
        else:
            print "LCD Port " + self.LCD_PORT + " does not exist or is not writable."