def toSensorDataFromJson(self, jsonData): sdDict = json.loads(jsonData) sd = SensorData() sd.name = sdDict['name'] sd.timeStamp = sdDict['timeStamp'] sd.avgValue = sdDict['avgValue'] sd.minValue = sdDict['minValue'] sd.maxValue = sdDict['maxValue'] sd.curValue = sdDict['curValue'] sd.totValue = sdDict['totValue'] sd.sampleCount = sdDict['sampleCount'] return sd
def jsonToSensorData(self, jsonData): sdDict = json.loads(jsonData) #print(" decode [pre] --> " + str(sdDict)) sd = SensorData("Temperature Sensor", 0.0, 30.0) sd.name = sdDict['name'] sd.timeStamp = sdDict['time'] sd.avgValue = sdDict['avgValue'] sd.minValue = sdDict['minValue'] sd.maxValue = sdDict['maxValue'] sd.curValue = sdDict['curValue'] #print(" decode [post] --> " + str(sd)) return sd
def toSensorDataFromJson(self,jsonData): sdDict = json.loads(jsonData) print(" decode [pre] --> " + str(sdDict)) sd = SensorData() sd.name = sdDict['name'] sd.timeStamp = sdDict['timeStamp'] sd.avgValue = sdDict['avgValue'] sd.minValue = sdDict['minValue'] sd.maxValue = sdDict['maxValue'] sd.curValue = sdDict['curValue'] sd.totValue = sdDict['totValue'] sd.sampleCount = sdDict['sampleCount'] print(" decode [post] --> " + str(sd)) return sd