diff --git a/source/dev_LaminaController.py b/source/dev_LaminaController.py index 3f1289b..68881c1 100644 --- a/source/dev_LaminaController.py +++ b/source/dev_LaminaController.py @@ -128,7 +128,7 @@ class LaminaController: else: self.__com = None - self.flag_print = 'frame_print' in kwargs.keys() + self.flag_print = kwargs['frame_print'] if 'frame_print' in kwargs.keys() else False self.time_out = kwargs['time_out'] if 'time_out' in kwargs.keys() else 1 self.time_gap = kwargs['time_gap'] if 'time_gap' in kwargs.keys() else 0.01 self.retry = kwargs['retry'] if 'retry' in kwargs.keys() else 1 @@ -196,8 +196,9 @@ class LaminaController: if self.flag_print: print("Send Frame: ", trans_list_to_str(frame)) + time.sleep(10 * self.time_gap) if self.__read_frame(): - if 'Regs' in self.output.keys(): + if (self.flag_print is not None) and 'Regs' in self.output.keys(): print_display(self.output['Regs']) self.log['read'] += 1 break @@ -246,6 +247,10 @@ class LaminaController: def frame_record(self) -> bool: """ 读取录波数据 """ + param_saved = self.flag_print, self.retry, self.time_out + self.flag_print = False + self.retry = 3 + self.time_out = 1.5 self.block['data']['file_block_size'] = 240 # 读取config self.block['data']['type'] = 'record_cfg' @@ -258,7 +263,7 @@ class LaminaController: if ret := self.__transfer_data(frame_master): frame_data_cfg.append(self.output['record']) if self.output['record']['seq'] == 0: - pbar = tqdm(total=self.output['record']['total'], desc="Record Config Reading") + pbar = tqdm(total=self.output['record']['total'] + 1, desc="Record Config Reading") self.block['data']['step'] = 'next' frame_master = make_frame_modbus(self.block['data']) elif (self.output['record']['seq']) >= self.output['record']['total']: @@ -277,14 +282,16 @@ class LaminaController: if ret := self.__transfer_data(frame_master): frame_data_record.append(self.output['record']) if self.output['record']['seq'] == 0: - pbar = tqdm(total=self.output['record']['total'], desc="Record Data Reading") + pbar = tqdm(total=self.output['record']['total'] + 1, desc="Record Data Reading") self.block['data']['step'] = 'next' frame_master = make_frame_modbus(self.block['data']) elif (self.output['record']['seq']) >= self.output['record']['total']: ret = False pbar and pbar.update() pbar and pbar.close() - if len(frame_data_record) == 0: + + self.flag_print, self.retry, self.time_out = param_saved + if (len(frame_data_record) != 32) or (len(frame_data_cfg) != 3): print("Operation_Record: 未取得录波数据.") return False