def control(): if request.method == 'POST': try: data = request.data c.set_update_time(get_current_time()) r=c.handle_post(data) save_db_control(r) return r except ValueError: return "get currently control state success" else: return c.build_json()
def control(): """ 处理服务器及其他设备对被控对象(继电器)的手动控制请求 """ global r if request.method == 'POST': try: data = request.data c.set_update_time(get_current_time()) r = c.handle_post(data) save_db_control(c) return r except: return "post error" else: return c.build_json()
def get_current_state_to_save(): global temp global auto_roof_vent_south, auto_roof_vent_north, auto_side_vent, auto_shade_screen_out, auto_shade_screen_in, auto_thermal_screen, auto_cooling_pad, auto_fogging, auto_heating, auto_co2 global auto_lighting_1, auto_lighting_2, auto_irrigation temp.set_cooling_fan(auto_cooling_pad) temp.set_roof_vent_south(auto_roof_vent_south) temp.set_roof_vent_north(auto_roof_vent_north) temp.set_side_vent(auto_side_vent) temp.set_shade_screen_north(auto_shade_screen_out) temp.set_shade_screen_south(auto_shade_screen_in) temp.set_thermal_screen(auto_thermal_screen) temp.set_fogging(auto_fogging) temp.set_heating(auto_heating) temp.set_co2(auto_co2) temp.set_lighting_1(auto_lighting_1) temp.set_lighting_2(auto_lighting_2) temp.set_irrigation(auto_irrigation) save_db_control(temp)