Пример #1
0
    def Query_Data_From_Database(self, ID):
        ## connect database, query previous one day data from Database
        # Database = database_dict()
        Blood_oxygen = []
        Diastolic_BP = []
        Pulses = []
        Systolic_BP = []

        info = DataBaseModule()
        info.authen('admin', '123456')
        info = info.search(ID)
        # Username = input("")
        #get dictionary from database
        for key in self.infoDB:
            if key == ID:
                _Diastolic_BP = info['Diastolic_BP']
                _Systolic_BP = info['Systolic_BP']
                _oxygen = info['blood_oxygen']
                _Pulse = info['heartrate']
                Diastolic_BP.append(int(_Diastolic_BP))
                Systolic_BP.append(int(_Systolic_BP))
                Blood_oxygen.append(int(_oxygen))
                Pulses.append(int(_Pulse))

        return Blood_oxygen, Diastolic_BP, Systolic_BP, Pulses
Пример #2
0
def input_thread():
    # authentication for databese
    # no use in this program
    # authenDB = {'admin': "123456"}
    username = '******'
    password = '******'

    # initialize the database
    mydatabase = DataBaseModule()
    mydatabase.authen(username, password)

    for line in open("userdata.txt"):
        element = line.split()
        information = input_api(element[0], element[1], element[2], element[3],
                                element[4], element[5], element[6], element[7],
                                element[8])
        information.implement_filter()

        # Write data to the database
        user_id, data_dic = information.return_request(2)
        mydatabase.insert(user_id, data_dic)

        # Uniform variable name
        data_dic["Heart_O2_Level"] = data_dic.pop("blood_oxygen")
        data_dic["Heart_Rate"] = data_dic.pop("heartrate")
        data_dic["Body_temp"] = data_dic.pop("temperature")

        input_queue.put(data_dic)
        time.sleep(1)
#from AI_module import AI_module
from analyzer import Analyzer
from Database_Module import DataBaseModule
from input_api import input_api
from time import ctime
from OutputAlert_module import receive_basic_iuput_data
import time

#source of input signals
txtFile = "./example.txt"

# admin login
DB = DataBaseModule()
username = '******'
password = '******'
DB.authen(username, password)


class MultiThreads:
    def __init__(self):
        self.printed = False
        self.output = {}
        self.inputbuffer = []

    def inputpart(self):
        print('[InputModule]start working')
        with open(txtFile) as f:
            #read inputstream by line
            for line in f.readlines():
                infoLine = line.strip().split(" ")
                inputs = input_api(infoLine[0], infoLine[1], infoLine[2], \