Example #1
0
 def heating(self, Indoor, Parameter, Control):
     if Indoor.get_temperature(
     ) < Parameter.hearting_start_lowest_temperature:
         Control.set_heating("on")
     elif Indoor.get_temperature(
     ) > Parameter.hearting_stop_highest_temperature:
         Control.set_heating("off")
Example #2
0
 def fogging(self, Indoor, Parameter, Control):
     if Indoor.get_temperature() > Parameter.temperature_to_open_fogging + 1:
         Control.set_fogging("on")
         # if Control.get_thermal_screen()=="on"
         # Control.set_thermal_screen("off")
     elif Indoor.get_temperature() < Parameter.temperature_to_open_fogging - 1:
         Control.set_fogging("off")
Example #3
0
 def cooling_pump(self, Indoor, Parameter, Control):
     if Indoor.get_temperature() > (
             Parameter.temperature_to_open_cooling_pad + 1):
         Control.set_cooling_pad("on")
     elif Indoor.get_temperature() < (
             Parameter.temperature_to_open_cooling_pad -
             1):  # 此时侧窗是与湿帘风机对应的,所以暂时不需要考虑90度方向的侧窗是否关闭
         Control.set_cooling_pad("off")
Example #4
0
def save_db_indoor(Indoor):
    with app.app_context():
        db = get_db()
        db.execute('INSERT INTO indoor(node_number,update_time,temperature,humidity,radiation,co2) VALUES(?,?,?,?,?,?)',
                   [Indoor.get_name(), Indoor.get_update_time(), Indoor.get_temperature(), Indoor.get_humidity(),
                    Indoor.get_radiation(), Indoor.get_co2()])
        db.commit()
        db.close()
    print 'indoor save success'
Example #5
0
def save_db_indoor(Indoor):
    with app.app_context():
        db = get_db()
        db.execute('INSERT INTO indoor(node_number,update_time,temperature,humidity,radiation,co2) VALUES(?,?,?,?,?,?)',
                   [Indoor.get_name(), Indoor.get_update_time(), Indoor.get_temperature(), Indoor.get_humidity(),
                    Indoor.get_radiation(), Indoor.get_co2()])
        db.commit()
        db.close()
    print 'indoor save success'
Example #6
0
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()
Example #7
0
def save_db_indoor(Indoor):
    with app.app_context():
        db = get_db()
        indoor_node = "indoor_node_" + Indoor.get_name()
        db.cursor().execute(
            'insert into ' + indoor_node +
            '(node,update_time,temperature,humidity,radiation,co2) values(%s,%s,%s,%s,%s,%s)',
            [
                Indoor.get_name(),
                get_current_time(),
                Indoor.get_temperature(),
                Indoor.get_humidity(),
                Indoor.get_radiation(),
                Indoor.get_co2()
            ])
        db.commit()
        db.cursor().close()
        db.close()
    print 'indoor save success'
Example #8
0
# 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)
Example #9
0
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 = ''''''
Example #10
0
 def co2(self, Indoor, Parameter, Control):
     if Indoor.get_co2() < Parameter.co2_lower_limit:
         Control.set_co2("on")
     elif Indoor.get_co2() > Parameter.co2_upper_limit:
         Control.set_co2("off")
Example #11
0
File: main.py Project: tj621/hzheng
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()
Example #12
0
#                 "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():
Example #13
0
 def cooling_pump(self, Indoor, Parameter, Control):
     if Indoor.get_temperature() > (Parameter.temperature_to_open_cooling_pad + 1):
         Control.set_cooling_pad("on")
     elif Indoor.get_temperature() < (
         Parameter.temperature_to_open_cooling_pad - 1):  # 此时侧窗是与湿帘风机对应的,所以暂时不需要考虑90度方向的侧窗是否关闭
         Control.set_cooling_pad("off")
Example #14
0
 def heating(self, Indoor, Parameter, Control):
     if Indoor.get_temperature() < Parameter.hearting_start_lowest_temperature:
         Control.set_heating("on")
     elif Indoor.get_temperature() > Parameter.hearting_stop_highest_temperature:
         Control.set_heating("off")
Example #15
0
                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()
Example #16
0
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()
Example #17
0
def get_db_indoor(Indoor):
    sheet_name = 'indoor_node_' + str(Indoor.get_name())
    query = "SELECT * FROM " + sheet_name + " WHERE id=(select max(id) from " + sheet_name + ")"
    row = query_db(query)
    Indoor.set_name(row[1])
    Indoor.set_update_time(row[2])
    Indoor.set_temperature(row[3])
    Indoor.set_humidity(row[4])
    Indoor.set_radiation(row[6])
    Indoor.set_co2(row[6])
Example #18
0
'''
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)