worktree-test/jsonwind.py

41 lines
970 B
Python
Raw Permalink Normal View History

2021-03-03 15:39:43 +00:00
import json
#returns standard json pack for wind data
def json_wma(time,speed, direction,temperature,speed_m2,speed_max2,speed_m10,speed_max10):
wind = {"time": time, "windspeed": speed, "winddirection" : direction, "temperature": temperature,
"speed2AVG": speed_m2,"speed2max": speed_max2,"speed10AVG": speed_m10,"speed10max": speed_max10
};
wind_info = json.dumps(wind)
return wind_info
def json_concat(json_pack,topic):
concat=json.loads(json_pack)
topic_json = {"topic": topic};
concat.update(topic_json)
return json.dumps(concat)
#returns standard json pack for wind data when in debug mode
def json_debug(time,speed, direction,error_n,kompasswinkel):
j_debug = {"time": time, "windspeed": speed, "winddirection" : direction, "nErrorsSerial": error_n,
"kompasswinkel": kompasswinkel
};
debug_info = json.dumps(j_debug)
return debug_info