def update_indoor(): global indoor_all_state number = node_num get_db_indoor(indoor) indoor_all_state = '''{''' + indoor.build_json_array() for i in range(number - 1): temp = Indoor(str(i + 2)) indoor_all_state += ',' get_db_indoor(temp) indoor_all_state += temp.build_json_array() indoor_all_state += '''}''' print 'indoor update', get_current_time()
import sensor from autorun import auto_run_main, get_side_wait_time from control import Control from currenttime import get_current_time from database import save_db_indoor, save_db_outdoor, save_db_control, get_db_parameter, save_db_parameter, \ get_db_indoor, get_db_outdoor, delete_db_data from indoor import Indoor from outdoor import Outdoor from parameter import Parameter from scheduler import Scheduler r = requests app = Flask(__name__) # 测试节点数据 node0 = Indoor('1') # 室外环境数据 outdoor = Outdoor() c = Control() # 参数数据 p = Parameter() control_method = "computer" isConnect = False # 服务器url url = "http://121.43.106.119:8090/" start_time = get_current_time() indoor_node_data = ''''''
from indoor import Indoor from flask import Flask from flask import abort from flask import redirect import time app = Flask(__name__) node0 = Indoor() print "temperature", node0.temperature print "humidity", node0.humidity print "radiation", node0.radiation print "co2", node0.co2 node0.set_temperature(20.0) node0.set_humidity(80.0) node0.set_radiation(8000) node0.set_co2(500) print "temperature", node0.temperature print "humidity", node0.humidity print "radiation", node0.radiation print "co2", node0.co2 def get_now_time(): return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) print get_now_time()
if get_current_time() > Parameter.period1_start_lighting and get_current_time() < Parameter.period1_stop_lighting: if Outdoor.radiation > Parameter.radiation1_to_open_lighting: Control.set_lighting_1("off") stop_time = get_time() elif get_current_time() > Parameter.period2_start_lighting and get_current_time() < Parameter.period2_stop_lighting: if Outdoor.radiation > Parameter.radiation2_to_open_lighting: Control.set_lighting_1("off") stop_time2 = get_time() else: Control.set_lighting_1("off") stop_time3 = get_time() elif Control.get_lighting_1() == "off" and Control.get_lighting_2() == "on": t3 = get_time() - stop_time3 t4 = get_time() - stop_time2 t5 = get_time() - stop_time if t3 > 1750 and t3 < 1850: Control.set_lighting_2("off") if t4 > 1750 and t4 < 1850: Control.set_lighting_2("off") if t5 > 1750 and t5 < 1850: Control.set_lighting_2("off") i = Indoor() o = Outdoor() c = Control() gh = Ghauto() p = Parameter() gh.heating(i, p, c) print c.get_heating()
''' Created on 2016/06/20 @author: Zxh ''' from autorun import auto_run_main from currenttime import get_time from indoor import Indoor from outdoor import Outdoor from parameter import Parameter from arm_project.control import Control node0 = Indoor('node0') o = Outdoor() c = Control() p = Parameter() p.set_expect_humidity("80") p.set_humidity_influence_range_of_air_temperature("5") p.set_high_humidity_influence_on_air_temperature("3") p.set_low_humidity_influence_on_air_temperature("4") p.set_light_influence_on_air_temperature_slope("0.7") p.set_roof_vent_open_time("10") p.set_shade_screen_in_time("5") p.set_shade_screen_out_time("7") p.set_side_vent_time("9") start_time = get_time() auto_run_main(node0, o, c, p)
# "cooling_pump": "%s", # "cooling_fan": "%s", # "fan": "%s", # "fogging": "%s", # "heating": "%s", # "co2": "%s", # "lighting_1": "%s", # "lighting_2": "%s" # } # } # } # '''%(row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[8],row[9],row[10],row[11],row[12],row[13],row[14],row[15]) if __name__ == '__main__': print 'test start' indoor = Indoor('2') outdoor = Outdoor() control = Control() # print get_db_actutor_current_state() #d='''{"outdoor_radiation": "true","start": "2016-06-17", #"stop": "2016-08-22"}''' #print handle_query_condition(d) outdoor.get_weather_from_api() #save_db_outdoor(outdoor) # print outdoor.build_json() # temperature, humidity, radiation, co2, wind_direction, wind_speed, rain_snow,atmosphere print outdoor.get_wind_direction() outdoor.set_wind_direction_number() print outdoor.get_wind_direction() # print outdoor.get_rain() with app.app_context():
# coding=utf-8 from currenttime import get_current_time from flask import Flask, request from outdoor import Outdoor from control import Control from indoor import Indoor from scheduler import Scheduler from parameter import Parameter from database import save_db_indoor, save_db_outdoor, save_db_control, get_db_parameter, save_db_parameter from autorun import auto_run_main, get_side_wait_time import json app = Flask(__name__) node0 = Indoor('node_0') outdoor = Outdoor() c = Control() p = Parameter() get_db_parameter(p) # init parameter from database control_method = "computer" def update_indoor(): # save_db_indoor(node0) print 'indoor updated', get_current_time() def update_outdoor(): outdoor.get_weather_from_api() # save_db_outdoor(outdoor)
from control import Control from scheduler import Scheduler from indoor import Indoor from control_command import ControlCommand from werkzeug.contrib.fixers import ProxyFix from database import get_db_indoor, get_db_outdoor, get_db_control_state, save_db_control_state, save_db_indoor, \ save_db_outdoor, \ get_db_control_command, save_db_control_command, handle_query_condition, handle_indoor_data, handle_outdoor_data app = Flask(__name__) node_num = 8 outdoor = Outdoor() control = Control() indoor = Indoor() command = ControlCommand() indoor_all_state = '' web_control = False def update_indoor(): global indoor_all_state number = node_num get_db_indoor(indoor) indoor_all_state = '''{''' + indoor.build_json_array() for i in range(number - 1): temp = Indoor(str(i + 2)) indoor_all_state += ',' get_db_indoor(temp) indoor_all_state += temp.build_json_array()