diff --git a/assets/configs/registers.json b/assets/configs/registers.json
index 18e1508..f4539a1 100644
--- a/assets/configs/registers.json
+++ b/assets/configs/registers.json
@@ -234,6 +234,126 @@
"name": "r_safe_region03",
"retain": false,
"type": "bool"
+ },
+ {
+ "addr": 40100,
+ "addr_1st": 0,
+ "addr_2nd": 0,
+ "bit_bias": 0,
+ "byte_bias": 0,
+ "function": "",
+ "len": 1,
+ "name": "signal_0",
+ "retain": false,
+ "type": "bool"
+ },
+ {
+ "addr": 40101,
+ "addr_1st": 0,
+ "addr_2nd": 0,
+ "bit_bias": 0,
+ "byte_bias": 0,
+ "function": "",
+ "len": 1,
+ "name": "signal_1",
+ "retain": false,
+ "type": "bool"
+ },
+ {
+ "addr": 40102,
+ "addr_1st": 0,
+ "addr_2nd": 0,
+ "bit_bias": 0,
+ "byte_bias": 0,
+ "function": "",
+ "len": 1,
+ "name": "signal_2",
+ "retain": false,
+ "type": "bool"
+ },
+ {
+ "addr": 40103,
+ "addr_1st": 0,
+ "addr_2nd": 0,
+ "bit_bias": 0,
+ "byte_bias": 0,
+ "function": "",
+ "len": 1,
+ "name": "signal_3",
+ "retain": false,
+ "type": "bool"
+ },
+ {
+ "addr": 40104,
+ "addr_1st": 0,
+ "addr_2nd": 0,
+ "bit_bias": 0,
+ "byte_bias": 0,
+ "function": "",
+ "len": 1,
+ "name": "signal_4",
+ "retain": false,
+ "type": "bool"
+ },
+ {
+ "addr": 40105,
+ "addr_1st": 0,
+ "addr_2nd": 0,
+ "bit_bias": 0,
+ "byte_bias": 0,
+ "function": "",
+ "len": 1,
+ "name": "signal_5",
+ "retain": false,
+ "type": "bool"
+ },
+ {
+ "addr": 40106,
+ "addr_1st": 0,
+ "addr_2nd": 0,
+ "bit_bias": 0,
+ "byte_bias": 0,
+ "function": "",
+ "len": 1,
+ "name": "signal_6",
+ "retain": false,
+ "type": "bool"
+ },
+ {
+ "addr": 40107,
+ "addr_1st": 0,
+ "addr_2nd": 0,
+ "bit_bias": 0,
+ "byte_bias": 0,
+ "function": "",
+ "len": 1,
+ "name": "signal_7",
+ "retain": false,
+ "type": "bool"
+ },
+ {
+ "addr": 40108,
+ "addr_1st": 0,
+ "addr_2nd": 0,
+ "bit_bias": 0,
+ "byte_bias": 0,
+ "function": "",
+ "len": 1,
+ "name": "signal_8",
+ "retain": false,
+ "type": "bool"
+ },
+ {
+ "addr": 40109,
+ "addr_1st": 0,
+ "addr_2nd": 0,
+ "bit_bias": 0,
+ "byte_bias": 0,
+ "function": "",
+ "len": 1,
+ "name": "signal_9",
+ "retain": false,
+ "type": "bool"
}
],
"rdwr": [
diff --git a/assets/configs/registers.xml b/assets/configs/registers.xml
index 106cfc6..4d079df 100644
--- a/assets/configs/registers.xml
+++ b/assets/configs/registers.xml
@@ -361,6 +361,196 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/code/common.py b/code/common.py
index aef6e1e..9c9ba81 100644
--- a/code/common.py
+++ b/code/common.py
@@ -28,7 +28,7 @@ def initialization():
pd.push_file_to_server(config_file, f"{user_settings}/{filename}")
pd.push_file_to_server(config_file, f"{interactive_data}/{filename}")
- io_device_autotest = {'ai_num': 0, 'ao_num': 0, 'di_num': 16, 'do_num': 16, 'extend_attr': {'mode': 'slaver', 'name': 'autotest', 'type': 'MODBUS'}, 'id': 7, 'name': 'autotest', 'type': 6}
+ io_device_autotest = {"ai_num": 0, "ao_num": 0, "di_num": 16, "do_num": 16, "extend_attr": {"mode": "slaver", "name": "autotest", "type": "MODBUS"}, "id": 7, "name": "autotest", "type": 6}
io_device_file_local = f"..\\assets\\configs\\{io_device_file}"
io_device_file_local_tmp = f"..\\assets\\configs\\{io_device_file}_tmp"
io_device_file_remote = f"{user_settings}/{io_device_file}"
@@ -84,8 +84,9 @@ def initialization():
ec.modify_system_time(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())))
# 关闭拖动
- clibs.logger.info("关闭拖动模式...")
- hr.set_drag_params(False, 1, 2)
+ if robot_type.upper()[:2] not in ["XB", "NB"]:
+ clibs.logger.info("关闭拖动模式...")
+ hr.set_drag_params(False, 1, 2)
# 关闭碰撞检测
clibs.logger.info("关闭碰撞检测...")
@@ -114,4 +115,5 @@ def initialization():
md.r_clear_alarm()
-initialization()
+if __name__ == "__main__":
+ initialization()
diff --git a/code/openapi.py b/code/openapi.py
index 4283830..cd26aa1 100644
--- a/code/openapi.py
+++ b/code/openapi.py
@@ -139,6 +139,13 @@ class ModbusRequest(object):
clibs.logger.info(f"40018-{action} 执行{actions}安全区 safe region 03")
sleep(clibs.interval)
+ def r_write_signals(self, addr: int, value): # OK | 40100 - 40109: signal_0 ~ signal_9
+ if -1 < addr < 10 and addr.is_integer():
+ self.__c.write_register(40100+addr, value)
+ clibs.logger.info(f"{40100+addr}-{value} 将寄存器 signal_{addr} 赋值为 {value}")
+ else:
+ clibs.logger.error(f"{40100+addr}-{value} 地址错误,无法赋值!")
+
@property
def w_alarm_state(self): # OK
res = self.__c.read_holding_registers(40500, 1).registers[0]
@@ -418,7 +425,10 @@ class HmiRequest(object):
return res.get("data", f"{msg_id} has no data item")
sleep(clibs.interval*2)
else: # 尝试在上一次分割的日志中查找,只做一次
- res = find_response("".join([clibs.log_path, sorted(listdir(clibs.log_path))[-3]]))
+ try:
+ res = find_response("".join([clibs.log_path, sorted(listdir(clibs.log_path))[-3]]))
+ except IndexError:
+ res = None
if res is not None:
return res.get("data", f"{msg_id} has no data item")
elif flag == 1:
@@ -428,7 +438,10 @@ class HmiRequest(object):
return res
sleep(clibs.interval*2)
else:
- res = find_response_xs("".join([clibs.log_path, sorted(listdir(clibs.log_path))[-3]]))
+ try:
+ res = find_response_xs("".join([clibs.log_path, sorted(listdir(clibs.log_path))[-3]]))
+ except IndexError:
+ res = None
if res is not None:
return res
self.__sth_wrong(11, f"无法找到请求 {msg_id} 的返回结果")