def run_hr_monitor(self): """ The heart of the program. This function runs the while loop that calls all other classes that are part of this assignment. It calls the classes that read the data in, find the instant heart rate, and find the average heart rates. Calls the method to destroy the display and finish running the script. """ reader = Reader(self.data_filename, self.update_time_seconds, self.data_bit_length) beat_detector = BeatDetector(self.update_time_seconds, self.signal_choice) processor_hr = HRProcessor(self.update_time_seconds, self.tachycardia, self.bradycardia, self.multi_min_avg_1, self.multi_min_avg_2) [data_array_ecg, data_array_ppg] = reader.get_next_data_instant() while reader.still_reading(): instant_hr = beat_detector.find_instant_hr(data_array_ecg, data_array_ppg) visualization_info = processor_hr.add_inst_hr( instant_hr, self.time_passed_string) self.render_information_display(visualization_info) [data_array_ecg, data_array_ppg] = reader.get_next_data_instant() time.sleep(self.seconds_between_readings) print("DONE") self.clean_up()
def test_still_reading(): for filename in filename_list: my_reader = Reader(filename, seconds_at_a_time, 16) # opens up a new instance of the Reader assert my_reader.still_reading() for i in range(0, int( seconds / seconds_at_a_time)): # read through all data points my_reader.get_next_data_instant() assert my_reader.still_reading() my_reader.load_next_data_points( ) # try to read the next information bit assert not my_reader.still_reading()
def test_get_next_data_instant(): for filename in filename_list: my_reader = Reader(filename) # opens up a new instance of the Reader [array_1, array_2] = my_reader.get_next_data_instant() assert len(array_1) == len(array_2) assert array_1 == array_2