Exemple #1
0
def save_db_outdoor(Outdoor):
    with app.app_context():
        db = get_db()
        db.execute('INSERT INTO outdoor(update_time,temperature,humidity,radiation,co2,wind_direction,wind_speed,rain_snow,atmosphere)\
                   VALUES(?,?,?,?,?,?,?,?,?)',
                   [Outdoor.get_update_time(), Outdoor.get_temperature(), Outdoor.get_humidity(), Outdoor.get_radiation(),
                    Outdoor.get_co_2(),
                    Outdoor.get_wind_direction(), \
                    Outdoor.get_wind_speed(), Outdoor.get_rain(), Outdoor.get_atmosphere()])
        db.commit()
        db.close()
    print 'outdoor save success'
Exemple #2
0
def save_db_outdoor(Outdoor):
    with app.app_context():
        db = get_db()
        db.execute('INSERT INTO outdoor(update_time,temperature,humidity,radiation,co2,wind_direction,wind_speed,rain_snow,atmosphere)\
                   VALUES(?,?,?,?,?,?,?,?,?)',
                   [Outdoor.get_update_time(), Outdoor.get_temperature(), Outdoor.get_humidity(), Outdoor.get_radiation(),
                    Outdoor.get_co_2(),
                    Outdoor.get_wind_direction(),
                    Outdoor.get_wind_speed(), Outdoor.get_rain(), Outdoor.get_atmosphere()])
        db.commit()
        db.close()
    print 'outdoor save success'
Exemple #3
0
def save_db_outdoor(Outdoor):
    with app.app_context():
        db = get_db()
        db.cursor().execute(
            'insert into outdoor(update_time,temperature,humidity,radiation,co2,wind_direction,wind_speed,rain_snow,atmosphere)\
                   values(%s,%s,%s,%s,%s,%s,%s,%s,%s)', [
                Outdoor.get_update_time(),
                Outdoor.get_temperature(),
                Outdoor.get_humidity(),
                Outdoor.get_radiation(),
                Outdoor.get_co_2(),
                Outdoor.get_wind_direction(),
                Outdoor.get_wind_speed(),
                Outdoor.get_rain(),
                Outdoor.get_atmosphere()
            ])
        db.commit()
    print 'outdoor save success'
Exemple #4
0
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 = ''''''


def server_connect():
Exemple #5
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()
Exemple #6
0
def get_db_outdoor(Outdoor):
    query = "select * from outdoor where id=(select max(id) from outdoor)"
    row = query_db(query)
    Outdoor.set_update_time(row[1])
    Outdoor.set_temperature(row[2])
    Outdoor.set_humidity(row[3])
    Outdoor.set_radiation(row[4])
    Outdoor.set_co_2(row[5])
    Outdoor.set_wind_direction(Outdoor.wind_direction_data.get(str(row[6])))
    Outdoor.set_wind_speed(row[7])
    Outdoor.set_rain(row[8])
    Outdoor.set_atmosphere(row[9])
Exemple #7
0
#                 "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():
        db = get_db()