为录波状态添加固定通信配置;
添加录波数据回复数据帧数校验; 添加阻止读取报文打印输出逻辑; 增加读写报文间隔时间, 避免回复报文接收失败;
This commit is contained in:
@@ -128,7 +128,7 @@ class LaminaController:
|
|||||||
else:
|
else:
|
||||||
self.__com = None
|
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_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.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
|
self.retry = kwargs['retry'] if 'retry' in kwargs.keys() else 1
|
||||||
@@ -196,8 +196,9 @@ class LaminaController:
|
|||||||
if self.flag_print:
|
if self.flag_print:
|
||||||
print("Send Frame: ", trans_list_to_str(frame))
|
print("Send Frame: ", trans_list_to_str(frame))
|
||||||
|
|
||||||
|
time.sleep(10 * self.time_gap)
|
||||||
if self.__read_frame():
|
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'])
|
print_display(self.output['Regs'])
|
||||||
self.log['read'] += 1
|
self.log['read'] += 1
|
||||||
break
|
break
|
||||||
@@ -246,6 +247,10 @@ class LaminaController:
|
|||||||
def frame_record(self) -> bool:
|
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
|
self.block['data']['file_block_size'] = 240
|
||||||
# 读取config
|
# 读取config
|
||||||
self.block['data']['type'] = 'record_cfg'
|
self.block['data']['type'] = 'record_cfg'
|
||||||
@@ -258,7 +263,7 @@ class LaminaController:
|
|||||||
if ret := self.__transfer_data(frame_master):
|
if ret := self.__transfer_data(frame_master):
|
||||||
frame_data_cfg.append(self.output['record'])
|
frame_data_cfg.append(self.output['record'])
|
||||||
if self.output['record']['seq'] == 0:
|
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'
|
self.block['data']['step'] = 'next'
|
||||||
frame_master = make_frame_modbus(self.block['data'])
|
frame_master = make_frame_modbus(self.block['data'])
|
||||||
elif (self.output['record']['seq']) >= self.output['record']['total']:
|
elif (self.output['record']['seq']) >= self.output['record']['total']:
|
||||||
@@ -277,14 +282,16 @@ class LaminaController:
|
|||||||
if ret := self.__transfer_data(frame_master):
|
if ret := self.__transfer_data(frame_master):
|
||||||
frame_data_record.append(self.output['record'])
|
frame_data_record.append(self.output['record'])
|
||||||
if self.output['record']['seq'] == 0:
|
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'
|
self.block['data']['step'] = 'next'
|
||||||
frame_master = make_frame_modbus(self.block['data'])
|
frame_master = make_frame_modbus(self.block['data'])
|
||||||
elif (self.output['record']['seq']) >= self.output['record']['total']:
|
elif (self.output['record']['seq']) >= self.output['record']['total']:
|
||||||
ret = False
|
ret = False
|
||||||
pbar and pbar.update()
|
pbar and pbar.update()
|
||||||
pbar and pbar.close()
|
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: 未取得录波数据.")
|
print("Operation_Record: 未取得录波数据.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user