def jsonToactuator(self, jsonData):
     adDict = json.loads(jsonData)
     ad = ActuatorData()
     ad.name = adDict['name']
     ad.timeStamp = adDict['timeStamp']
     ad.hasError = adDict['hasError']
     ad.command = adDict['command']
     ad.errCode = adDict['errCode']
     ad.statusCode = adDict['statusCode']
     ad.stateData = adDict['stateData']
     ad.curValue = adDict['curValue']
     return ad
Example #2
0
 def jsonToactuator(self,jsonData):
     actdataDict = json.loads(jsonData)
     print(" decode [pre] --> " + str(actdataDict))
     actdata = ActuatorData()
     actdata.name = actdataDict['name']
     actdata.time = actdataDict['timeStamp']
     actdata.hasError = actdataDict['hasError']
     actdata.command = actdataDict['command']
     actdata.errCode = actdataDict['errCode']
     actdata.statusCode = actdataDict['statusCode']
     actdata.stateData = actdataDict['stateData']
     actdata.curValue = actdataDict['curValue']
     print(" decode [post] --> " + str(actdata))
     return actdata
Example #3
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)
Example #4
0
    def jsonToActuatorData(self, jsonData):
        adDict = json.loads(jsonData)

        #print(" decode [pre] --> " + str(adDict))

        ad = ActuatorData()
        ad.name = adDict['name']
        ad.timeStamp = adDict['timeStamp']
        ad.hasError = adDict['hasError']
        ad.command = adDict['command']
        ad.errCode = adDict['errCode']
        ad.statusCode = adDict['statusCode']
        ad.stateData = adDict['stateData']
        ad.curValue = adDict['curValue']

        #print(" decode [post] --> " + str(ad))

        return ad