def _apc_pvc_helper(auth): ''' @param auth: Authentication token ''' recordID = resource.get_active_record_list(auth)[0] if recordID not in resource.get_active_record_list(auth): # record not updated in realtime. return -1 APC_PVC = apc_pvc.APC_helper() PVCH = pvc_h.PVC() datatypes = [ util.raw_datatypes['ecg'][0], util.datatypes['rrintervalstatus'][0] ] # Call to get data th1 = Thread(target=resource.APC_PVC_realtime, args=[auth, recordID, [APC_PVC, PVCH], datatypes]) th1.start() th4 = Thread(target=APC_PVC.apcObj.delete_method, args=[]) th4.start() th5 = Thread(target=PVCH.delete_method, args=[]) th5.start() # Successfully finished. Astronaut docked. return 1
def atrial_fibrillation_helper(auth): ''' Returns the rr_interval data in realtime. @param auth: Authentication token ''' recordID = resource.get_active_record_list(auth)[0] if recordID not in resource.get_active_record_list(auth): # record not updated in realtime. return -1 AD = ad.AnomalyDetector() config = ConfigParser.RawConfigParser() dirname = os.path.dirname(os.path.realpath(__file__)) cfg_filename = os.path.join(dirname, '../anomaly_detector/anomaly_detector.cfg') config.read(cfg_filename) window_size = config.getint('Atrial Fibrillation', 'window_size') datatypes = [ util.datatypes['rrinterval'][0], util.datatypes['hr_quality'][0] ] resource.AF_realtime(auth, recordID, AD.af_anomaly_detect, window_size, datatypes) # Successfully finished. Astronaut docked. return 1
def ventricular_tachycardia_helper(auth): ''' @param auth: Authentication token ''' recordID = resource.get_active_record_list(auth)[0] if recordID not in resource.get_active_record_list(auth): # record not updated in realtime. return -1 VTBD = vth.VTBeatDetector() datatypes = [ util.raw_datatypes['ecg'][0], util.datatypes['rrinterval'][0], util.datatypes['rrintervalstatus'][0], util.datatypes['heartrate'][0], util.datatypes['hr_quality'][0] ] # Call to get data th1 = Thread(target=resource.VT_realtime, args=[auth, recordID, VTBD, datatypes]) th1.start() # resource.VT_realtime(auth, recordID, VTBD, datatypes) # Call to add anomaly into the data base th2 = Thread(target=VTBD.ping_AD_dict) th2.start() # VTBD.ping_AD_dict() # Call to keep VT datastructure size under limit # time.sleep(120) # while(True): # VTBD.delete_data() # time.sleep(2) # Successfully finished. Astronaut docked. return 1
def get_all_data(auth=""): ''' @param auth : Authentication token @return : The real-time record id of the current session ''' auth = util.auth_login() # Returns the required data in real-time for GUI recordID = resource.get_active_record_list(auth)[0] if recordID not in resource.get_active_record_list(auth): # record not updated in realtime. return -1 datatypes = [4113, 18] data = resource.get_all_data(auth, recordID, datatypes=datatypes) return_data = {} for i in range(0, len(datatypes)): _data = [] _data.append(data[datatypes[i]][0]) _data.append(data[datatypes[i]][int(len(data[datatypes[i]]) / 2)]) _data.append(data[datatypes[i]][len(data[datatypes[i]]) - 1]) return_data[datatypes[i]] = _data return json.dumps(return_data)
def sleep_helper(auth): ''' @param auth: Authentication token ''' recordID = resource.get_record_list(auth)[0]['id'] if recordID in resource.get_active_record_list(auth): # record should not updated in realtime. return -1 resource.sleep_ad(auth, recordID) sleepAD.initiate_sleepAD()
def get_rrecordid(auth): ''' @param auth : Authentication token @return : The real-time record id of the current session ''' try: recordID = resource.get_active_record_list(auth)[0] except: return -1 return recordID
def resp_helper(auth): ''' @param auth: Authentication token ''' recordID = resource.get_active_record_list(auth)[0] if recordID not in resource.get_active_record_list(auth): # record not updated in realtime. return -1 config = ConfigParser.RawConfigParser() config.read('../anomaly_detector/anomaly_detector.cfg') datatypes = [ util.datatypes['vt'][0], util.datatypes['minuteventilation'][0], util.raw_datatypes['resp'][0], util.datatypes['breathingrate'][0], util.datatypes['br_quality'][0], util.datatypes['inspiration'][0], util.datatypes['expiration'][0] ] resource.resp_realtime(auth, recordID, "", datatypes) # Successfully finished. Astronaut docked. return 1