| import json |
| import time |
|
|
| |
| |
| globs = { |
| "dey": 1, |
| "wek": 1, |
| "v_hid": 0, |
| "v_min": 0, |
| "ph": 7.0 |
| } |
|
|
| |
| def create_json_from_globals(week, day, hour, ph): |
| return { |
| "week": week, |
| "day": day, |
| "hour": hour, |
| "ph": ph |
| } |
|
|
| |
| current_week = globs["wek"] |
| current_day = globs["dey"] |
| current_hour = globs["v_hid"] |
|
|
| |
| combined_data = [] |
|
|
| |
| while True: |
| |
| if globs["wek"] != current_week or globs["dey"] != current_day or globs["v_hid"] != current_hour: |
| current_week = globs["wek"] |
| current_day = globs["dey"] |
| current_hour = globs["v_hid"] |
| |
| json_data = create_json_from_globals(current_week, current_day, current_hour, globs["ph"]) |
| |
| combined_data.append(json_data) |
|
|
| |
| if current_hour == 0 and current_day == 1: |
| filename = 'combined_data.json' |
| with open(filename, 'w') as f: |
| json.dump(combined_data, f, indent=4) |
| combined_data = [] |
|
|
| |
| time.sleep(60) |
|
|
| |
| if globs["wek"] > 30: |
| break |