Exemple #1
0
    def testAddGPS(self):
        # Open connection with the database
        db = MySQLdb.connect("localhost", "root", "reverse", "ecoData")
        cursor = db.cursor()

        # Add a information to the database
        dr = GPS("1234.567865", "098765.4321", 7.20, "123.456.789")
        addToDatabase(dr)

        # Get information from the database
        cursor.execute("SELECT * FROM GPS")
        result = cursor.fetchone()
        dbId = result[0]
        dbLong = result[1]
        dbLat = result[2]
        dbSpe = result[3]
        dbTimestamp = result[4]

        # Close the connection and wipe the database
        db.close()
        cleardb()

        self.assertTrue(dbId == 1 and dbLong == "1234.567865"
                        and dbLat == "098765.4321" and dbSpe == 7.20
                        and dbTimestamp == "123.456.789")
Exemple #2
0
    def testAddPower1(self):
        # Open connection with the database
        db = MySQLdb.connect("localhost", "root", "reverse", "ecoData")
        cursor = db.cursor()

        # Add a information to the database
        dr = SensorData("1", "throttle", 7, "123.456.789")
        addToDatabase(dr)

        # Get information from the database
        cursor.execute("SELECT * FROM Throttle")
        result = cursor.fetchone()
        dbId = result[0]
        dbType = result[1]
        dbData = result[2]
        dbTimestamp = result[3]

        # Close the connection and wipe the database
        db.close()
        cleardb()

        self.assertTrue(dbId == 1 and dbType == "throttle" and dbData == "7"
                        and dbTimestamp == "123.456.789")
Exemple #3
0
        if debugging: print "Flag 1.5"

        print start_time - gps_time

        if start_time - gps_time > 1.2 or epoch < 5:
            gpsdata = getGPSData(tn, ctime)
            gps_time = start_time
        else:
            gpsdata.updateTimestamp(ctime)

        if debugging: print "Flag 2."

        # Send separate dataframes per data source, or combined.
        #with suppress_stdout():
        if telemetry: makeMessage(rpmdata, sendQueue)
        if localLogging: addToDatabase(rpmdata)
        if telemetry: makeMessage(throttledata, sendQueue)
        if localLogging: addToDatabase(throttledata)
        if telemetry: makeMessage(currentdata, sendQueue)
        if localLogging: addToDatabase(currentdata)
        if telemetry: makeMessage(voltagedata, sendQueue)
        if localLogging: addToDatabase(voltagedata)
        if telemetry: makeMessage(gpsdata, sendQueue)
        if localLogging: addToDatabase(gpsdata)

        print str(rpmdata.getData()) + " " + str(
            throttledata.getData()) + " " + str(
                gpsdata.getLongtitude()) + " " + str(gpsdata.getLattitude())

        if debugging: print "Flag 3."
        valRPM = rpmdata.getData()
Exemple #4
0
# Clear the database before running
cleardb()

lastLogTime = datetime.now().strftime('%M')
while (True):
    try:
        ctime = datetime.now().strftime('%H:%M:%S.%f')[:-3]

        # Collect rpm data to add them to database and send to ground base
        rpmObject = rpmsensor.getRPMdata(ctime)
        rpm = rpmObject.getData()

        # write the speed in km/h to the screen
        driverInterface.getSerial().write(str(rpmToKMH(rpm)))

        addToDatabase(rpmObject)

        # Collect throttle data to add them to database and send to ground base
        throttleObject = driverInterface.getThrottledata(ctime)
        throttle = throttleObject.getData()

        addToDatabase(throttleObject)

        # Collect current data to add them to database and send to ground base
        currentObject = currentsensor.getCurrentData(ctime)
        current = currentObject.getData()

        addToDatabase(currentObject)

        # Check if 3 minutes have passed to write the log
        timeNow = datetime.now().strftime('%M')