def toSensorfromJson(self, jsonData):
        sdDict = json.loads(jsonData)

        sd = SensorData('Temperature', 0, 30)
        sd.name = sdDict['name']
        sd.timeStamp = sdDict['timeStamp']
        sd.avgVal = sdDict['avgVal']
        sd.minVal = sdDict['minVal']
        sd.maxVal = sdDict['maxVal']
        sd.curVal = sdDict['curVal']

        return sd
Ejemplo n.º 2
0
 def jsonTosensor(self,jsonData):
     sensedataDict = json.loads(jsonData)
     print(" decode [pre] --> " + str(sensedataDict))
     sensedata = SensorData('Temperature',0,30)
     sensedata.name = sensedataDict['name']
     sensedata.timeStamp = sensedataDict['timeStamp']
     sensedata.avgVal = sensedataDict['avgVal']
     sensedata.minVal = sensedataDict['minVal']
     sensedata.maxVal = sensedataDict['maxVal']
     sensedata.curVal = sensedataDict['curVal']
     sensedata.totValue = sensedataDict['totValue']
     sensedata.sampleCount = sensedataDict['sampleCount']
     print(" decode [post] --> " + str(sensedata))
     return sensedata