Index: dialin/dg/calibration_record.py =================================================================== diff -u -ra2cdbc7e007c6bd73e12344b4c89356a20b53f4f -rab49c2b2e6bd03745f5a910780791d4b18000fd1 --- dialin/dg/calibration_record.py (.../calibration_record.py) (revision a2cdbc7e007c6bd73e12344b4c89356a20b53f4f) +++ dialin/dg/calibration_record.py (.../calibration_record.py) (revision ab49c2b2e6bd03745f5a910780791d4b18000fd1) @@ -105,7 +105,7 @@ self.logger.debug("Timeout!!!!") return False - @_publish(["current_message", "total_messages", "length", "cal_data"]) + @_publish(["current_message", "total_messages", "length", "sys_data"]) def _handler_dg_calibration_sync(self, message): """ Handles published DG calibration_record record messages. DG calibration_record records are captured for Index: dialin/hd/calibration_record.py =================================================================== diff -u -ra2cdbc7e007c6bd73e12344b4c89356a20b53f4f -rab49c2b2e6bd03745f5a910780791d4b18000fd1 --- dialin/hd/calibration_record.py (.../calibration_record.py) (revision a2cdbc7e007c6bd73e12344b4c89356a20b53f4f) +++ dialin/hd/calibration_record.py (.../calibration_record.py) (revision ab49c2b2e6bd03745f5a910780791d4b18000fd1) @@ -90,7 +90,7 @@ self.logger.debug("Timeout!!!!") return False - @_publish(["current_message", "total_messages", "length", "cal_data"]) + @_publish(["current_message", "total_messages", "length", "sys_data"]) def _handler_hd_calibration_sync(self, message): """ Handles published HD calibration_record record messages. DG calibration_record records are captured for @@ -137,7 +137,7 @@ functions = [self._prepare_pumps_record(), self._prepare_valves_record(), self._prepare_occlusion_sensors_record(), self._prepare_flow_sensors_record(), self._prepare_pressure_sensors_record(), self._prepare_temperature_sensors_record(), - self._prepare_heparin_force_record()] + self._prepare_heparin_force_sensor_record(), self._prepare_accelerometer_sensor_record()] for function in functions: # Update the groups bytes size so far to be use to padding later @@ -303,7 +303,7 @@ return hardware_group, group_byte_size - def _prepare_heparin_force_record(self): + def _prepare_heparin_force_sensor_record(self): """ Handles creating the calibration_record dictionary of the heparin force sensor hardware group. @@ -328,6 +328,30 @@ return hardware_group, group_byte_size + def _prepare_accelerometer_sensor_record(self): + """ + Handles creating the calibration_record dictionary of the accelerometer sensor hardware group. + + @return: accelerometer sensor hardware group dictionary and the byte size of this hardware group + """ + hardware_names = ['accelerometer'] + + group_byte_size = 0 + group_name = 'accelerometer_sensor' + hardware_group = OrderedDict({group_name: OrderedDict()}) + hardware = OrderedDict() + + for i in hardware_names: + hardware[i] = {'x_offset': [' self._MIN_PAYLOAD_BYTES_SPACE: @@ -266,7 +333,13 @@ # be updated with the right value later. temp_buffer[self._PAYLOAD_TOTAL_MSG_INDEX] = struct.pack(' self._DICT_VALUE_LIST_LEN: + byte_size += current_byte_size * group[key][self._CHAR_LENGTH_INDEX] + else: + byte_size += current_byte_size + return byte_size @staticmethod Index: tests/test_dg_calibration.py =================================================================== diff -u -ra2cdbc7e007c6bd73e12344b4c89356a20b53f4f -rab49c2b2e6bd03745f5a910780791d4b18000fd1 --- tests/test_dg_calibration.py (.../test_dg_calibration.py) (revision a2cdbc7e007c6bd73e12344b4c89356a20b53f4f) +++ tests/test_dg_calibration.py (.../test_dg_calibration.py) (revision ab49c2b2e6bd03745f5a910780791d4b18000fd1) @@ -21,37 +21,37 @@ status = False - cal.hd_calibration_record['pumps']['concentrate_1']['step_speed_2_flow_ratio'][1] = 34.2 - cal.hd_calibration_record['pumps']['drain']['cal_time'][1] = 96321 - cal.hd_calibration_record['pumps']['ro']['gain_3_ratio'][1] = 45.69 - cal.hd_calibration_record['volumes']['drain_line']['volume'][1] = 125.8 - cal.hd_calibration_record['volumes']['drain_line']['crc'][1] = 78 - cal.hd_calibration_record['volumes']['pre_ro_purge']['volume'][1] = 125.8 - cal.hd_calibration_record['volumes']['reservoir_1']['max_residual_fluid'][1] = 85.36 - cal.hd_calibration_record['bicarb_concentrates']['bicarb_conc_3']['reserved_space'][1] = 85.36 - cal.hd_calibration_record['fans']['fan_2']['reserved_space_2'][1] = 456.25 + cal.hd_system_record['pumps']['concentrate_1']['step_speed_2_flow_ratio'][1] = 34.2 + cal.hd_system_record['pumps']['drain']['cal_time'][1] = 96321 + cal.hd_system_record['pumps']['ro']['gain_3_ratio'][1] = 45.69 + cal.hd_system_record['volumes']['drain_line']['volume'][1] = 125.8 + cal.hd_system_record['volumes']['drain_line']['crc'][1] = 78 + cal.hd_system_record['volumes']['pre_ro_purge']['volume'][1] = 125.8 + cal.hd_system_record['volumes']['reservoir_1']['max_residual_fluid'][1] = 85.36 + cal.hd_system_record['bicarb_concentrates']['bicarb_conc_3']['reserved_space'][1] = 85.36 + cal.hd_system_record['fans']['fan_2']['reserved_space_2'][1] = 456.25 - print(cal.hd_calibration_record) + print(cal.hd_system_record) try: if status: dara = [] - cal.get_hd_calibration_record() + cal.get_hd_system_record() while True: sleep(0.2) - #print(cal.current_message, cal.total_messages, cal.cal_data) + #print(cal.current_message, cal.total_messages, cal.sys_data) - if cal.cal_data != 0: - f.write(str(cal.cal_data) + '\r') - dara.append(cal.cal_data) + if cal.sys_data != 0: + f.write(str(cal.sys_data) + '\r') + dara.append(cal.sys_data) if cal.current_message == cal.total_messages: f.close() break else: - cal.set_hd_calibration_record() + cal.set_hd_system_record() - print(cal.hd_calibration_record) + print(cal.hd_system_record) except KeyboardInterrupt: f.close() Index: tests/test_hd_records.py =================================================================== diff -u -ra2cdbc7e007c6bd73e12344b4c89356a20b53f4f -rab49c2b2e6bd03745f5a910780791d4b18000fd1 --- tests/test_hd_records.py (.../test_hd_records.py) (revision a2cdbc7e007c6bd73e12344b4c89356a20b53f4f) +++ tests/test_hd_records.py (.../test_hd_records.py) (revision ab49c2b2e6bd03745f5a910780791d4b18000fd1) @@ -1,6 +1,8 @@ import sys +import struct sys.path.append("..") from dialin.hd.hemodialysis_device import HD +from dialin.utils.utils import Utils from time import sleep @@ -13,36 +15,45 @@ sleep(2) cal = hd.calibration_record + utilities = Utils() - print(cal.hd_calibration_record) + sys = hd.system_record - #cal.hd_calibration_record['pumps']['bp']['pwm_to_speed'][1] = 17.0 - #print(cal.hd_calibration_record) - status = False + cal.hd_calibration_record['accelerometer_sensor']['accelerometer']['x_offset'][1] = 952.12 + cal.hd_calibration_record['accelerometer_sensor']['accelerometer']['y_offset'][1] = 45.2 + cal.hd_calibration_record['accelerometer_sensor']['accelerometer']['z_offset'][1] = 712.58 + cal.hd_calibration_record['accelerometer_sensor']['accelerometer']['cal_time'][1] = utilities.get_current_time_in_epoch() + print(sys.hd_system_record) + + #sys.hd_system_record['system_record']['top_level_pn'][1] = 'abcd-12345' + #sys.hd_system_record['system_record']['mfg_date'][1] = utilities.get_current_time_in_epoch() + + status = True try: if status: dara = [] - cal.get_hd_calibration_record() + #cal.get_hd_calibration_record() + sys.get_hd_system_record() while True: sleep(0.2) - #print(cal.current_message, cal.total_messages, cal.cal_data) + #print(cal.current_message, cal.total_messages, cal.sys_data) - if cal.cal_data != 0: - #f.write(str(cal.cal_data) + '\r') - dara.append(cal.cal_data) + if sys.sys_data != 0: + #f.write(str(cal.sys_data) + '\r') + #dara.append(cal.sys_data) - if cal.current_message == cal.total_messages: + if sys.current_message == sys.total_messages: #f.close() break else: - cal.set_hd_calibration_record() + #cal.set_hd_calibration_record() + sys.set_hd_system_record() - print(cal.hd_calibration_record) + #print(cal.hd_calibration_record) + print(sys.hd_system_record) except KeyboardInterrupt: #f.close() pass - - #cal.set_hd_calibration_record() \ No newline at end of file