def control(self, devices, control, GPIO): import growControl as gc oldStatus = self.status testOn = gc.getMinuteDiff(self.timeOn) testOff = gc.getMinuteDiff(self.timeOff) if testOn >= 0 and testOff < 0: # time in the off times, set light off self.status = self.relayOn print "Controling Light" + str(self.id) + ": Set to On" else: # if the light is not between the off times, it should be on self.status = self.relayOff print "Controling Light" + str(self.id) + ": Set to Off" if oldStatus != self.status: print "STATUS CHANGE: LIGHT " + str(seld.id) # this must always be the last thing to run in the control method # it checks if any of the temperature sensors are exceeding the limit set in control and if so, sets light to low # by being the last check in the control method, it insures a high temp will cause light on for d in devices: if d.growType == "tempSensor": if d.lastTemp >control.MaxTemp: self.status = self.relayOff gc.errorDisplay("-- Light " + str(self.id) + " status changed because of high reading on Temp Sensor " + str(d.id)) GPIO.output(self.pin, self.status) #finally set the light value
def control(self, devices, control, GPIO): import growControl as gc oldStatus = self.status #record the original status so we know if it changes #run checks to see what type of fan and what controls to use, then actually control it if self.fanOnType == 1: #print "fanOnType == 1" testOn = gc.getMinuteDiff(self.fanOnAt) testOff = gc.getMinuteDiff(self.fanOffAt) #print "" #print "Fan " + str(self.id) + " testOn = " + str(testOn) #print "Fan " + str(self.id) + " testOff = " + str(testOn) if testOn >= 0 and testOff < 0: # time in the off times, set fan off self.status = self.relayOn print "Controling Fan" + str(self.id) + ": Set to On" else: # if the fan is not between the off times, it should be on self.status = self.relayOff print "Controling Fan" + str(self.id) + ": Set to Off" elif self.fanOnType ==2: # this type runs for fanOnAt minutes, then turns off for fanOffAt minutes print "fanOnType == 2 is not yet supported, please change the type of fan #" + str(self.id) elif self.fanOnType ==3: # this type is always on print "fanOnType == 3" self.status = self.relayOn else: print "In fan" + str(self.id) + " fanOnType not defined or not recognized, setting to always on" self.status = self.relayOn if oldStatus != self.status: print "STATUS CHANGE: FAN " + str(self.id) #this should always be the last thing to run in the control method # it checks if any of the temperature sensors are exceeding the limit set in control and if so, sets fan to high #by being the last check in the control method, it insures a high temp will cause fans on for d in devices: if d.growType == "tempSensor": if d.lastTemp > control.MaxTemp: self.status = self.relayOn gc.errorDisplay("-- Fan " + str(self.id) + " status changed because of high reading on Temp Sensor " + str(d.id)) GPIO.output(self.pin, self.status) #finally set the fan value