示例#1
0
    def publishMessage(self, actData):
        if actData != self.actuator_data:
            self.val = actData.getValue()

            if actData.getCommand() == 2:
                message = "DECREASE the Temperature by %.2f" % (
                    self.val) + chr(176) + "C" + " to reach the NOMINAL Temp"
            else:
                message = "INCREASE the Temperature by %.2f" % (
                    self.val) + chr(176) + "C" + " to reach the NOMINAL Temp"

            senseHat = SenseHatLedActivator.SenseHatLedActivator()
            senseHat.setDisplayMessage(message)
            print(
                "-----------------------------------------------------------------------------------------------------"
            )
            senseHat.setEnableLedFlag('enable')

            try:
                senseHat.start()
            except:
                print("Can't Activate The Actuator")
            finally:
                senseHat.enableLed = False
        self.actuator_data.updateData(actData)
示例#2
0
 def on_message(self, clientConn, data, msg):
     print("Received PUBLISH on topic {0}. Payload: {1}".format(
         str(msg.topic), str(msg.payload)))
     senledActivator = SenseHatLedActivator.SenseHatLedActivator()
     print(msg.payload)
     senledActivator.setDisplayMessage(msg.payload)
     senledActivator.setEnableLedFlag(True)
     senledActivator.run()
 def __init__(self):
     '''
     Constructor
     '''
     self.actuatorData = ActuatorData.ActuatorData()
     self.senseHat = SenseHatLedActivator.SenseHatLedActivator()
     #start my sensehat thread
     self.senseHat.start()
示例#4
0
    def processMessage(self, actuatordata):
        if (actuatordata != self.actuatordata):
            self.actuatordata = actuatordata

        if (self.actuatordata.getCommand() == self.raisetemp):
            #send notification to GPIO
            ledactivator = SenseHatLedActivator.SenseHatLedActivator()
            ledactivator.setEnableLedFlag(True)
            ledactivator.setDisplayMessage("Raise temperature.")
            print('Please raise temperature.')
            ledactivator.run()

        if (self.actuatordata.getCommand() == self.lowertemp):
            #send notification to GPIO
            ledactivator = SenseHatLedActivator.SenseHatLedActivator()
            ledactivator.setEnableLedFlag(True)
            ledactivator.setDisplayMessage("Lower temperature.")
            print('Please lower temperature.')
            ledactivator.run()
    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):
     '''
     Constructor
     '''
     self.mqttClient = mqttClient.Client()
     self.config = ConfigUtil.ConfigUtil()
     self.sensoData = SensorData.SensorData()
     self.config.loadConfig()
     self.brockerKeepAlive = 60
     self.connected_flag = False
     
     self.pemfile = "/home/raspberry/workspace/ubidots_cert.pem"
     self.authToken = 'A1E-nDuSgklKdOve42x5KXvi49lTs3pAi2'
     self.port = 8883
     self.brokerAddr = 'things.ubidots.com'
     self.password = ''
     
     self.smtp = SmtpClientConnector.SmtpClientConnector()
     self.timeStamp = str(datetime.now())
     self.senseled = SOSLed.SOSLed()
     self.sensehatled = SenseHatLedActivator.SenseHatLedActivator()
示例#8
0
    def publishMessage(self, act_data):
        if act_data != self.actuator_data:
            self.val = act_data.getValue()

            if act_data.getCommand() == 2:
                mes = "Decrease the Temperature by %.2f" % (self.val)
            else:
                mes = "Increase the Temperature by %.2f" % (self.val)
                print("______________________________________________")
            sense_hat = SenseHatLedActivator.SenseHatLedActivator()
            sense_hat.setDisplayMessage(mes)
            sense_hat.setEnableLedFlag('enable')
            #triggers the start of sense_hat

            try:
                sense_hat.start()
                #starts the execution of the sense_hat
            except:
                print("Couldn't activate Actuator !!!!!")
            finally:
                sense_hat.enableLed = False
                self.actuator_data.updateData(act_data)
示例#9
0
 def run(self):
     sensordata = SensorData.SensorData()
 #    senseHatLedActivator = SenseHatLedActivator.SenseHatLedActivator()
     senseledThread = SenseHatLedActivator.SenseHatLedActivator()
     senseledThread.start()
     #senseHatLedActivator.run()
     
     while True:
         sense = SenseHat()
         temperature = sense.get_temperature()
         sensordata.addValue(temperature)
         
         #smtp module
         if(abs(sensordata.getValue()-sensordata.getAvgValue())>=self.threshold):
             logging.info('\n  Current temp exceeds average by > ' + str(self.threshold) + '. Triggering alert...')
             smtpClientConnector = SmtpClientConnector.SmtpClientConnector()
             smtpClientConnector.publishMessage("Excessive Temp", sensordata)
             
         nomialtemp = self.config.getProperty(ConfigConst.CONSTRAINED_DEVICE,ConfigConst.NOMINAL_TEMP_KEY)
         
         #senseHat Led module
         actuatordata = ActuatorData()
         if(sensordata.getValue != nomialtemp):
             logging.info('\n temperature is different from nomialtemp')   
             actuatordata.command = 1
             actuatordata.statusCode = 1
             actuatordata.errCode = 0
             actuatordata.val = temperature
             actuatordata.stateData = temperature - float(nomialtemp)
             TempActuatorEmulator().processMessage(actuatordata, senseledThread)
         else:
             logging.info('\n temperature is equal to nomialtemp')   
             actuatordata.command = 1
             actuatordata.statusCode = 0
             actuatordata.errCode = 0
             actuatordata.val = temperature
         time.sleep(10)
示例#10
0
 def __init__(self):
     self.updateTimeStamp()
     self.sensehat = SenseHatLedActivator.SenseHatLedActivator()
示例#11
0
'''
Created on Oct 12, 2018

@author: rocky_yan
'''
import threading

from labs.common import ActuatorData
from labs.common import ConfigUtil
from labs.common import ConfigConst
from labs.module03 import SenseHatLedActivator
from distutils import command

actuatorData = ActuatorData.ActuatorData()

senseHat = SenseHatLedActivator.SenseHatLedActivator()


class TempActuatorEmulator(threading.Thread):

    command = 0

    def __init__(self):
        self.config = ConfigUtil.ConfigUtil(
            '../../../data/ConnectedDevicesConfig.props')

        print('Configuration data...\n' + str(self.config))
        senseHat.daemon = True
        senseHat.start()

    def processMessage(self, data):
示例#12
0
 def __init__(self):
     super(TempActuatoeEmulator, self).__init__()
     self.data = ActuatorData.ActuatorData()
     self.LedActivator = SenseHatLedActivator.SenseHatLedActivator()
     self.light = SimpleLedActivator.SimpleLedActivator()
示例#13
0
'''
Created on 2018年9月22日

@author: andyyuan
'''

import threading

from labs.common import ConfigUtil
from labs.common import ConfigConst
from labs.common import ActuatorData
from labs.module03 import SenseHatLedActivator

Data = ActuatorData.ActuatorData()
shla = SenseHatLedActivator.SenseHatLedActivator()


class TempActuatorEmulator(threading.Thread):
    def __init__(self):
        self.config = ConfigUtil.ConfigUtil('')
        self.config.loadConfig()
        print('Configuration data...\n' + str(self.config))
        print('============= Setting Done! =============')

        shla.daemon = True
        shla.start()

    def processMessage(self, data):
        self.nominalTemp = self.config.getProperty(ConfigConst.DEVICE_SECTION,
                                                   ConfigConst.NOMINALTEMP)
        '''