Example #1
0
class PhidgetTemp():
    def __init__(self):
        self.temperatureSensor = TemperatureSensor()
        self.temperatureSensor.setOnAttachHandler(TemperatureSensorAttached)
        self.temperatureSensor.setOnDetachHandler(TemperatureSensorDetached)
        self.temperatureSensor.setOnErrorhandler(TemperatureSensorError)
        self.temperatureSensor.setOnTemperatureChangeHandler(
            TemperatureSensorTemperatureChanged)
#         self.data_to_be_sent_bridge = []
#         self.times_to_be_sent_bridge = []

    def open(self, waitTimeMS):
        self.temperatureSensor.openPhidget()
        try:
            self.temperatureSensor.waitForAttach(waitTimeMS)
            time.sleep(0.5)
            self.temperatureSensor.setThermocoupleType(
                0, ThermocoupleType.PHIDGET_TEMPERATURE_SENSOR_K_TYPE)
            self.temperatureSensor.setThermocoupleType(
                1, ThermocoupleType.PHIDGET_TEMPERATURE_SENSOR_K_TYPE)
            self.temperatureSensor.setThermocoupleType(
                2, ThermocoupleType.PHIDGET_TEMPERATURE_SENSOR_K_TYPE)
            self.temperatureSensor.setThermocoupleType(
                3, ThermocoupleType.PHIDGET_TEMPERATURE_SENSOR_K_TYPE)
            self.temperatureSensor.setTemperatureChangeTrigger(0, 0.1)
            #             self.temperatureSensor.setTemperatureChangeTrigger(1, 0.1)
            #             self.temperatureSensor.setTemperatureChangeTrigger(2, 0.1)
            #             self.temperatureSensor.setTemperatureChangeTrigger(3, 0.1)
            return 1
        except:
            return -1

#     def BridgeData(self,e):
#         timeStamp = time.time()
#         self.data_to_be_sent_bridge.append(e.value)
#         self.times_to_be_sent_bridge.append(timeStamp)

    def getData(self):
        #return the data and times and update the lists
        thermocouple0 = self.temperatureSensor.getTemperature(0)
        thermocouple1 = self.temperatureSensor.getTemperature(1)
        thermocouple2 = self.temperatureSensor.getTemperature(2)
        thermocouple3 = self.temperatureSensor.getTemperature(3)
        timeStamp = time.time()
        data_to_return = [
            thermocouple0, thermocouple1, thermocouple2, thermocouple3,
            timeStamp
        ]
        data_to_be_sent_temperature = []
        times_to_be_sent_temperature = []
        return data_to_return

    def close(self):
        self.temperatureSensor.setEnabled(0, False)
        time.sleep(2)
        self.temperatureSensor.closePhidget()
class PhidgetTemp():
    def __init__(self):
        self.temperatureSensor = TemperatureSensor()
        self.temperatureSensor.setOnAttachHandler(TemperatureSensorAttached)
        self.temperatureSensor.setOnDetachHandler(TemperatureSensorDetached)
        self.temperatureSensor.setOnErrorhandler(TemperatureSensorError)
        self.temperatureSensor.setOnTemperatureChangeHandler(TemperatureSensorTemperatureChanged)
#         self.data_to_be_sent_bridge = []
#         self.times_to_be_sent_bridge = []
        
    def open(self,waitTimeMS):
        self.temperatureSensor.openPhidget()
        try:
            self.temperatureSensor.waitForAttach(waitTimeMS)
            time.sleep(0.5)
            self.temperatureSensor.setThermocoupleType(0, ThermocoupleType.PHIDGET_TEMPERATURE_SENSOR_K_TYPE)
            self.temperatureSensor.setThermocoupleType(1, ThermocoupleType.PHIDGET_TEMPERATURE_SENSOR_K_TYPE)
            self.temperatureSensor.setThermocoupleType(2, ThermocoupleType.PHIDGET_TEMPERATURE_SENSOR_K_TYPE)
            self.temperatureSensor.setThermocoupleType(3, ThermocoupleType.PHIDGET_TEMPERATURE_SENSOR_K_TYPE)
            self.temperatureSensor.setTemperatureChangeTrigger(0, 0.1)
#             self.temperatureSensor.setTemperatureChangeTrigger(1, 0.1)
#             self.temperatureSensor.setTemperatureChangeTrigger(2, 0.1)
#             self.temperatureSensor.setTemperatureChangeTrigger(3, 0.1)
            return 1
        except:
            return -1
    
#     def BridgeData(self,e):
#         timeStamp = time.time()
#         self.data_to_be_sent_bridge.append(e.value)
#         self.times_to_be_sent_bridge.append(timeStamp)
        
    def getData(self):
        #return the data and times and update the lists
        thermocouple0 = self.temperatureSensor.getTemperature(0)
        thermocouple1 = self.temperatureSensor.getTemperature(1)
        thermocouple2 = self.temperatureSensor.getTemperature(2)
        thermocouple3 = self.temperatureSensor.getTemperature(3)
        timeStamp = time.time()
        data_to_return = [thermocouple0,thermocouple1,thermocouple2,thermocouple3,timeStamp]
        data_to_be_sent_temperature = []
        times_to_be_sent_temperature = []
        return data_to_return
    
    def close(self):
        self.temperatureSensor.setEnabled(0,False)
        time.sleep(2)
        self.temperatureSensor.closePhidget()
Example #3
0
### put the new code here 

csv_file="goose.csv"
in_img="return-pic.jpg"
out_img="left-pic.jpg"
fmt = '%Y-%m-%d %H:%M:%S'

#f = open (csv_file)
#lineList = f.readlines()
#f.close()
#parts=(lineList[-1]).split(',')
#word1=str(parts[4])


temp1=temperatureSensor.getAmbientTemperature()
temp2=temperatureSensor.getTemperature(0)
temp_diff=abs(temp2-temp1)

#define in_nest
in_nest = False


if temp_diff > 3:
	in_nest is True
	print("Setting in_nest to True")
else:
	in_nest is False
	print("Setting in_nest to False")

start_time_in_nest=strftime(fmt, gmtime())