示例#1
0
 def toActuatorDataFromJson(self, jsonData):
     adDict = json.loads(jsonData)
     ad = ActuatorData()
     ad.name = adDict['name']
     ad.command = adDict['command']
     ad.val = adDict['val']
     ad.stateData = adDict['stateData']
     ad.timeStamp = adDict['timeStamp']
     
     return ad
 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
 def toActuatorDataFromJson(self, string):
     act = ActuatorData()
     data = json.loads(string)
     logging.info(data)
     act.name = data['name']
     act.value = data['current']
     act.command = data['command']
     act.min_value = data['min_value']
     act.max_value = data['max_value']
     act.total_value = data['total_value']
     act.avgTemp = data['avgTemp']
     act.timestamp = data['timestamp']
     logging.info("New actuator generated from JSon \n")
     return act
示例#4
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
示例#5
0
    def toActuatorDataFromJson(self, jsonStr) -> ActuatorData:

        #instantiate ActuatorData
        actuatorData = ActuatorData()

        #use json load to convert it to a dictionary
        jsonLoad = json.loads(jsonStr)

        #parse and add it to the actuatorData object one by one
        actuatorData.name = jsonLoad['name']
        actuatorData.command = jsonLoad['command']
        actuatorData.value = jsonLoad['value']

        #return the actuatorData reference
        return actuatorData
示例#6
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