def Query_Data_From_Database(self, ID, infoDB): ## connect database, query previous one day data from Database # Database = database_dict() Heart_Rate = list() Blood_oxygen = list() Systolic = list() Diastolic = list() DataBaseModule.search(ID) # Username = input("") #get dictionary from database for key in infoDB: if key == ID: # pressure = dict.get('blood_pressure') Heart_Rate = dict.get('Heart_Rate') oxygen = dict.get('blood_oxygen') Diastolic_BP = dict.get('Diastolic_BP') Systolic_BP = dict.get('Systolic_BP') # Blood_pressure.append(pressure) Heart_Rate.append(Heart_Rate) Blood_oxygen.append(oxygen) Systolic.append(Systolic_BP) Diastolic.append(Diastolic_BP) return Heart_Rate, Blood_oxygen, Systolic, Diastolic
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
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)
def Query_Data_From_Database(self): ## connect database, query previous one day data from Database # Database = database_dict() Blood_oxygen=list() Systolic= list() Diastolic= list() heartrate=list() ID = self.ID p= DataBaseModule() infoDB= p.search(ID) # get dictionary from database for key in self._dict: # if key== ID: heartate=self._dict.get("heartrate") oxygen = self._dict.get('blood_oxygen') Diastolic_BP = self._dict.get('Diastolic_BP') Systolic_BP = self._dict.get('Systolic_BP') heartrate.append(heartate) Blood_oxygen.append(oxygen) Systolic.append(Systolic_BP) Diastolic.append(Diastolic_BP) return Blood_oxygen, heartate, Systolic,Diastolic
def Query_Data_From_Database(self, ID, infoDB): ## connect database, query previous one day data from Database # Database = database_dict() Blood_oxygen = [] Blood_pressure = [] Pulses = [] info = DataBaseModule().search(ID) # Username = input("") #get dictionary from database for key in infoDB: if key == ID: pressure = info['blood_pressure'] oxygen = info['blood_oxygen'] Pulse = info['blood_pulses'] Blood_pressure.append(pressure) Blood_oxygen.append(oxygen) Pulses.append(Pulse) return Blood_oxygen, Blood_pressure, Pulses
import threading #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(" ")