From 1ddde4855a4c667a73c49e15777ad8c936e4b0f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=20=E6=B3=BD=E9=9A=86?= Date: Tue, 8 Oct 2024 16:36:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E5=BD=95=E6=B3=A2=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=BA=E5=AE=9A=E9=80=9A=E4=BF=A1=E9=85=8D?= =?UTF-8?q?=E7=BD=AE;=20=E6=B7=BB=E5=8A=A0=E5=BD=95=E6=B3=A2=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=9B=9E=E5=A4=8D=E6=95=B0=E6=8D=AE=E5=B8=A7=E6=95=B0?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C;=20=E6=B7=BB=E5=8A=A0=E9=98=BB=E6=AD=A2?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=8A=A5=E6=96=87=E6=89=93=E5=8D=B0=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E9=80=BB=E8=BE=91;=20=E5=A2=9E=E5=8A=A0=E8=AF=BB?= =?UTF-8?q?=E5=86=99=E6=8A=A5=E6=96=87=E9=97=B4=E9=9A=94=E6=97=B6=E9=97=B4?= =?UTF-8?q?,=20=E9=81=BF=E5=85=8D=E5=9B=9E=E5=A4=8D=E6=8A=A5=E6=96=87?= =?UTF-8?q?=E6=8E=A5=E6=94=B6=E5=A4=B1=E8=B4=A5;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/dev_LaminaController.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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