重新优化安全区参数设定功能
This commit is contained in:
parent
65bd6f2bce
commit
1f4656f0b9
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,4 +5,3 @@ code/__pycache__
|
|||||||
code/testbench.py
|
code/testbench.py
|
||||||
assets/logs/
|
assets/logs/
|
||||||
assets/configs/io_device_XBC_*
|
assets/configs/io_device_XBC_*
|
||||||
assets/json/safety.safety_area.set_param.json
|
|
5
assets/json/safety.safety_area.set_param.json
Normal file
5
assets/json/safety.safety_area.set_param.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"c": {
|
||||||
|
"safety.safety_area.set_param": null
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ def initialization():
|
|||||||
hr = openapi.HmiRequest()
|
hr = openapi.HmiRequest()
|
||||||
pd = openapi.PreDos()
|
pd = openapi.PreDos()
|
||||||
# 推送配置文件
|
# 推送配置文件
|
||||||
clibs.logger.info("推送配置文件 fieldbus_device.json/registers.json/registers.xml 到控制器,并配置 IO 设备,设备号为 5...")
|
clibs.logger.info("推送配置文件 fieldbus_device.json/registers.json/registers.xml 到控制器,并配置 IO 设备,设备号为 7...")
|
||||||
robot_params = hr.get_robot_params
|
robot_params = hr.get_robot_params
|
||||||
robot_type = robot_params["robot_type"]
|
robot_type = robot_params["robot_type"]
|
||||||
security_type = robot_params["security_type"]
|
security_type = robot_params["security_type"]
|
||||||
@ -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"{user_settings}/{filename}")
|
||||||
pd.push_file_to_server(config_file, f"{interactive_data}/{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': 5, '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 = f"..\\assets\\configs\\{io_device_file}"
|
||||||
io_device_file_local_tmp = f"..\\assets\\configs\\{io_device_file}_tmp"
|
io_device_file_local_tmp = f"..\\assets\\configs\\{io_device_file}_tmp"
|
||||||
io_device_file_remote = f"{user_settings}/{io_device_file}"
|
io_device_file_remote = f"{user_settings}/{io_device_file}"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from json import load, dumps, loads, dump
|
from json import load, dumps, loads
|
||||||
from os import listdir
|
from os import listdir
|
||||||
from inspect import currentframe
|
from inspect import currentframe
|
||||||
from socket import socket, AF_INET, SOCK_STREAM
|
from socket import socket, AF_INET, SOCK_STREAM
|
||||||
@ -783,6 +783,8 @@ class HmiRequest(object):
|
|||||||
case "safety.safety_area.safety_area_enable":
|
case "safety.safety_area.safety_area_enable":
|
||||||
req["c"]["safety.safety_area.safety_area_enable"]["id"] = kwargs["id"]
|
req["c"]["safety.safety_area.safety_area_enable"]["id"] = kwargs["id"]
|
||||||
req["c"]["safety.safety_area.safety_area_enable"]["enable"] = kwargs["enable"]
|
req["c"]["safety.safety_area.safety_area_enable"]["enable"] = kwargs["enable"]
|
||||||
|
case "safety.safety_area.set_param":
|
||||||
|
req["c"]["safety.safety_area.set_param"] = kwargs["data"]
|
||||||
case _:
|
case _:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -1474,13 +1476,13 @@ class HmiRequest(object):
|
|||||||
:param percent: 0-200,整机灵敏度百分比
|
:param percent: 0-200,整机灵敏度百分比
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
res = self.get_collision_params
|
data = self.get_collision_params
|
||||||
keys = res.keys()
|
keys = data.keys()
|
||||||
kwargs.update({"enable": enable, "mode": mode, "action": action, "percent": percent})
|
kwargs.update({"enable": enable, "mode": mode, "action": action, "percent": percent})
|
||||||
for _ in keys:
|
for _ in keys:
|
||||||
if _ in kwargs.keys():
|
if _ in kwargs.keys():
|
||||||
res[_] = kwargs[_]
|
data[_] = kwargs[_]
|
||||||
self.execution("collision.set_params", data=res)
|
self.execution("collision.set_params", data=data)
|
||||||
|
|
||||||
def set_collision_state(self, collision_state: bool):
|
def set_collision_state(self, collision_state: bool):
|
||||||
"""
|
"""
|
||||||
@ -1719,7 +1721,7 @@ class HmiRequest(object):
|
|||||||
"""
|
"""
|
||||||
self.execution("safety.safety_area.safety_area_enable", protocol_flag=1, id=id, enable=enable)
|
self.execution("safety.safety_area.safety_area_enable", protocol_flag=1, id=id, enable=enable)
|
||||||
|
|
||||||
def set_safety_area_param(self, id: int, enable: bool, **kwargs): # 不生效,待确认
|
def set_safety_area_param(self, id: int, enable: bool, **kwargs):
|
||||||
"""
|
"""
|
||||||
设定单独安全区的参数
|
设定单独安全区的参数
|
||||||
:param id: 安全区 id
|
:param id: 安全区 id
|
||||||
@ -1727,15 +1729,13 @@ class HmiRequest(object):
|
|||||||
:param kwargs: 其他参数,参考 get_safety_area_params 的返回值形式
|
:param kwargs: 其他参数,参考 get_safety_area_params 的返回值形式
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
res = self.get_safety_area_params["g"]["safety_area_data"]["safety_area_setting"][id]
|
data = self.get_safety_area_params["g"]["safety_area_data"]["safety_area_setting"][id]
|
||||||
keys = res.keys()
|
keys = data.keys()
|
||||||
kwargs.update({"id": id, "enable": enable})
|
kwargs.update({"id": id, "enable": enable})
|
||||||
for _ in keys:
|
for _ in keys:
|
||||||
if _ in kwargs.keys():
|
if _ in kwargs.keys():
|
||||||
res[_] = kwargs[_]
|
data[_] = kwargs[_]
|
||||||
with open(f"{clibs.PREFIX}/json/safety.safety_area.set_param.json", mode="w", encoding="utf-8") as f:
|
self.execution("safety.safety_area.set_param", protocol_flag=1, data=data)
|
||||||
dump({"c": {"safety.safety_area.set_param": res}}, f, indent=4)
|
|
||||||
self.execution("safety.safety_area.set_param", protocol_flag=1)
|
|
||||||
self.execution("safety.safety_area.safety_area_enable", protocol_flag=1, id=id, enable=enable)
|
self.execution("safety.safety_area.safety_area_enable", protocol_flag=1, id=id, enable=enable)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user