예제 #1
0
def map():
    temp1 = request.args.get('user_id')
    session['userid'] = temp1
    graph_fall = dbAPI.select_fall_down(user_id=int(temp1))
    touch_count = dbAPI.select_touch(user_id=int(temp1))
    count_fall = dbAPI.select_fall_down_count(user_id=int(temp1))
    wake_up = dbAPI.select_wake_up(user_id=int(temp1))
    sleep = dbAPI.select_sleep(user_id=int(temp1))
    temperature = dbAPI.select_where("sensor_data",
                                     0,
                                     "num",
                                     user_id=int(temp1),
                                     sensor_id=1)
    humidity = dbAPI.select_where("sensor_data",
                                  0,
                                  "num",
                                  sensor_id=2,
                                  user_id=int(temp1))
    user_info = dbAPI.select_where("user_info", 0, "*", id=int(temp1))
    all_user_info = dbAPI.select("user_info", 0, "*")
    prot_info = dbAPI.select_prot_info(int(temp1))
    return render_template('map.html',
                           row=graph_fall,
                           data=temperature,
                           data1=user_info,
                           data2=all_user_info,
                           row1=count_fall,
                           data3=humidity,
                           wake_up=wake_up,
                           sleep=sleep,
                           touch_count=touch_count,
                           prot_info=prot_info)
예제 #2
0
def Contact():
    user_info = dbAPI.select_where("user_info", 0, "*", id=1)
    all_user_info = dbAPI.select("user_info", 0, "*")
    prot_info = dbAPI.select_prot_info(1)
    return render_template('Contacts.html',
                           data1=user_info,
                           data2=all_user_info,
                           prot_info=prot_info)
예제 #3
0
def index():
    temp1 = request.args.get('user_id')
    graph_fall = dbAPI.select_fall_down(user_id=2)
    count_fall = dbAPI.select_fall_down_count(user_id=1)
    wake_up = dbAPI.select_wake_up(user_id=1)
    sleep = dbAPI.select_sleep(user_id=1)
    temperature = dbAPI.select_where("sensor_data",
                                     0,
                                     "num",
                                     sensor_id=1,
                                     user_id=1)
    humidity = dbAPI.select_where("sensor_data",
                                  0,
                                  "num",
                                  sensor_id=2,
                                  user_id=1)
    user_info = dbAPI.select_where("user_info", 0, "*", id=1)
    all_user_info = dbAPI.select("user_info", 0, "*")
    user_avg_actibity = dbAPI.user_avg_activity()
    daily_avg_activity = dbAPI.select_user_avg(sensor_id=6)
    daily_avg_touch = dbAPI.select_user_avg(sensor_id=7)
    daily_avg_wake = dbAPI.select_daily_sleep(sensor_id=3)
    daily_avg_sleep = dbAPI.select_daily_sleep(sensor_id=4)
    daily_sleeptime = dbAPI.select_user_avg(sensor_id=3)
    daily_time = []
    if daily_sleeptime >= 60:
        daily_time.append(daily_sleeptime / 60)
        daily_time.append(daily_sleeptime - daily_time[0])
    else:
        daily_time.append('0')
        daily_time.append(daily_sleeptime)

    return render_template('index.html',
                           row=graph_fall,
                           data=temperature,
                           data1=user_info,
                           data2=all_user_info,
                           row1=count_fall,
                           data3=humidity,
                           user_avg_actibity=user_avg_actibity,
                           daily_avg_activity=daily_avg_activity,
                           daily_avg_touch=daily_avg_touch,
                           daily_avg_wake=daily_avg_wake,
                           daily_avg_sleep=daily_avg_sleep,
                           daily_time=daily_time)
예제 #4
0
def prot_info_post(data):
    if request.method == 'GET':  # SELECT
        if (data == 'name'):
            contact = request.args['contact']
            prot = dbAPI.select_where("prot_info", 1, "name", contact=contact)
        elif (data == 'contact'):
            name = request.args['name']
            prot = dbAPI.select_where("prot_info", 1, "contact", name=name)
        elif (data == 'id'):
            contact = request.args['contact']
            prot = dbAPI.select_where("prot_info", 1, "id", contact=contact)
            #print(prot)
        return str(decodeList(prot))
    else:  # POST (INSERT)
        name = request.get_json().get('name')
        contact = request.get_json().get('contact')
        #print(dbAPI.select_where("activity",1,"timestamp",id=1))
        #dbAPI.insert_data("activity",70,1)
        #dbAPI.insert_data("fall_down",1)
        dbAPI.insert_prot_info(name, contact)
        return "prot_info_post"
예제 #5
0
def medicine_data(data):
    if request.method == 'GET':
        user_id = request.args['user_id']
        #print(user_id)
        val = dbAPI.select_where('medicine_data',
                                 0,
                                 'name',
                                 '월',
                                 '화',
                                 '수',
                                 '목',
                                 '금',
                                 '토',
                                 '일',
                                 'time1',
                                 'time2',
                                 'time3',
                                 user_id=user_id)
        #print(val)
        return str(decodeList(val))
    else:  # POST
        name = request.get_json().get('name')
        user_id = request.get_json().get('user_id')
        mon = request.get_json().get('mon')
        tue = request.get_json().get('tue')
        wed = request.get_json().get('wed')
        thu = request.get_json().get('thu')
        fri = request.get_json().get('fri')
        sat = request.get_json().get('sat')
        sun = request.get_json().get('sun')
        time1 = request.get_json().get('time1')
        time2 = request.get_json().get('time2')
        time3 = request.get_json().get('time3')
        #print(name + user_id + time1)
        if (time2 == '000000'):
            dbAPI.insert_medicine_data(name, user_id, mon, tue, wed, thu, fri,
                                       sat, sun, time1)
        elif (time3 == '000000'):
            dbAPI.insert_medicine_data(name, user_id, mon, tue, wed, thu, fri,
                                       sat, sun, time1, time2)
        else:
            dbAPI.insert_medicine_data(name, user_id, mon, tue, wed, thu, fri,
                                       sat, sun, time1, time2, time3)
        return 'medicine_data_post'
예제 #6
0
def user_info_post(data):
    if request.method == 'GET':  # SELECT
        prot_id = request.args['prot_id']
        if (data == 'id'):
            user = dbAPI.select_where("user_info", 0, 'id', prot_id=prot_id)
        elif (data == 'name'):
            user = dbAPI.select_where("user_info", 0, "name", prot_id=prot_id)
        elif (data == 'gender'):
            user = dbAPI.select_where("user_info",
                                      0,
                                      "gender",
                                      prot_id=prot_id)
        elif (data == 'birth'):
            user = dbAPI.select_where("user_info", 0, "birth", prot_id=prot_id)
        elif (data == 'address'):
            user = dbAPI.select_where("user_info",
                                      0,
                                      "address",
                                      prot_id=prot_id)
        elif (data == 'contact'):
            user = dbAPI.select_where("user_info",
                                      0,
                                      "contact",
                                      prot_id=prot_id)
        #print(user)
        return str(decodeList(user))
    else:  # POST (INSERT)
        name = request.get_json().get('name')
        gender = request.get_json().get('gender')
        birth = request.get_json().get('birth')
        address = request.get_json().get('address')
        contact = request.get_json().get('contact')
        prot_id = request.get_json().get('prot_id')
        #print(name, contact, prot_id)
        dbAPI.insert_user_info(name, gender, birth, address, contact, prot_id)
        socketio.emit('user_info', {'data': 'uuuu'}, broadcast=True)
        return "user_info_post"
예제 #7
0
def test():
    temp1 = request.args.get('user_id')
    session['userid'] = temp1
    graph_fall = dbAPI.select_fall_down(user_id=int(temp1))
    touch_count = int(dbAPI.select_touch(user_id=int(temp1)))
    count_fall = dbAPI.select_fall_down_count(user_id=int(temp1))
    wake_up = dbAPI.select_wake_up(user_id=int(temp1))
    sleep = dbAPI.select_sleep(user_id=int(temp1))
    temperature = dbAPI.select_where("sensor_data",
                                     0,
                                     "num",
                                     user_id=int(temp1),
                                     sensor_id=1)
    humidity = dbAPI.select_where("sensor_data",
                                  0,
                                  "num",
                                  sensor_id=2,
                                  user_id=int(temp1))
    user_info = dbAPI.select_where("user_info", 0, "*", id=int(temp1))

    if (user_info[0][2] == 'f' or user_info[0][2] == 'F'):
        gender = '여성'
    else:
        gender = '남성'

    all_user_info = dbAPI.select("user_info", 0, "*")
    prot_info = dbAPI.select_prot_info(int(temp1))
    avg_realtime = int(dbAPI.select_avg_realtime(user_id=int(temp1)))
    latest_realtime = int(dbAPI.select_latest_realtime(user_id=int(temp1)))
    user_activity = dbAPI.select_where("sensor_data", 0, "*", sensor_id=8)
    sub_activity = dbAPI.select_sub_activity(sensor_id=6, user_id=int(temp1))
    sub_touch = dbAPI.select_sub_activity(sensor_id=7, user_id=int(temp1))
    sub_sleeping = dbAPI.select_sub_activity(sensor_id=6, user_id=int(temp1))
    temper_min_max = dbAPI.select_min_max(sensor_id=1, user_id=int(temp1))
    avg_wake = dbAPI.select_avg_sleep(sensor_id=3, user_id=int(temp1))
    avg_sleep = dbAPI.select_avg_sleep(sensor_id=4, user_id=int(temp1))
    ONEuser_avg_activity = dbAPI.ONEuser_avg_activity(user_id=int(temp1))
    qa = dbAPI.select_question(user_id=int(temp1))

    return render_template(
        'test.html',
        row=graph_fall,
        data=temperature,
        data1=user_info,
        data2=all_user_info,
        row1=count_fall,
        data3=humidity,
        wake_up=wake_up,
        sleep=sleep,
        touch_count=touch_count,
        prot_info=prot_info,
        avg_realtime=avg_realtime,
        latest_realtime=latest_realtime,
        user_activity=user_activity,
        sub_activity=sub_activity,
        sub_touch=sub_touch,
        sub_sleeping=sub_sleeping,
        temper_min_max=temper_min_max,
        avg_wake=avg_wake,
        avg_sleep=avg_sleep,
        ONEuser_avg_activity=dbAPI.ONEuser_avg_activity(user_id=int(temp1)),
        qa=qa,
        gender=gender)