def __init__(self, blinkingTime): self.tempActuatorData = ActuatorData.ActuatorData("Actuator") self.ledActivator = SimpleLedActivator.SimpleLedActivator(blinkingTime) self.ledActivator.daemon = True self.ledActivator.start() self.LedActivator = SenseHatLedActivator.SenseHatLedActivator() self.LedActivator.daemon = True self.LedActivator.start()
def __init__(self): self.tempActuatorData = ActuatorData.ActuatorData() self.simledActivator = SimpleLedActivator.SimpleLedActivator() self.simledActivator.daemon = True self.simledActivator.start() self.senledActivator = SenseHatLedActivator.SenseHatLedActivator() self.senledActivator.daemon = True self.senledActivator.start()
def __init__(self): super(TempActuatoeEmulator, self).__init__() self.data = ActuatorData.ActuatorData() self.LedActivator = SenseHatLedActivator.SenseHatLedActivator() self.light = SimpleLedActivator.SimpleLedActivator()
@author: okok_no ''' import os, sys sys.path.append('/home/pi/Desktop/workspace/iot-device/apps') import threading from sense_hat import SenseHat from labs.common import ActuatorData from labs.module03 import SenseHatLedActivator from labs.module03 import SimpleLedActivator data = ActuatorData.ActuatorData() Sense = SenseHat() LedActivator = SenseHatLedActivator.SenseHatLedActivator() light = SimpleLedActivator.SimpleLedActivator() class TempActuatoeEmulator(threading.Thread): def __init__(self): super(TempActuatoeEmulator, self).__init__() self.data = ActuatorData.ActuatorData() self.LedActivator = SenseHatLedActivator.SenseHatLedActivator() self.light = SimpleLedActivator.SimpleLedActivator() #when the temperature have unnatural quantity, then let Led show message def processMessage(self, actuadata): self.light.setEnableLedFlag(True) self.LedActivator.setEnableLedFlag(True) self.LedActivator.setDisplayMessage(actuadata) self.LedActivator.run()
from labs.module03 import SmtpClientConnector from labs.module03 import TempActuatorEmulator from labs.module03 import SimpleLedActivator from labs.module03 import CoapSimpleClientConnector from sense_hat import SenseHat from time import sleep DEFAULT_RATE_IN_SEC = 10 sen = SenseHat() Tem = TempActuatorEmulator.TempActuatoeEmulator() Sens = SensorData.SensorData() SmtpConnector = SmtpClientConnector.SmtpClientConnector() Act = ActuatorData.ActuatorData() Sim = SimpleLedActivator.SimpleLedActivator() coapConnector = CoapSimpleClientConnector.CoapSimpleClientConnector() class TempSensorAdaptor(threading.Thread): enableEmulator = False isPrevTempSet = False rateInSec = DEFAULT_RATE_IN_SEC Sens.setName('Temperature') alertDiff = 2 alertDiffb = 0 def __init__(self, rateInSec=DEFAULT_RATE_IN_SEC): super(TempSensorAdaptor, self).__init__() if rateInSec > 0: