允许自定义配置文件路径;开放modbus接口,允许自定义操作

This commit is contained in:
2025-09-05 16:55:41 +08:00
parent 15009924b3
commit 33184f1ffb
4 changed files with 278 additions and 7 deletions

View File

@@ -518,7 +518,7 @@ class EcRequest:
self.c.connect((clibs.ip_addr, clibs.external_port))
logger.success(f"ec: 外部通信连接成功")
except Exception as e:
logger.success(f"ec: 外部通信连接失败 -- {e}")
logger.error(f"ec: 外部通信连接失败 -- {e}")
raise Exception()
def sr_string(self, directive, description, more_desc=""):
@@ -856,9 +856,10 @@ class PreDos(object):
class RobotInit(object):
def __init__(self, hr: HmiRequest, pd: PreDos):
def __init__(self, hr: HmiRequest, pd: PreDos, conf_path: str):
self.hr: HmiRequest = hr
self.pd: PreDos = pd
self.conf_path: str = conf_path
def robot_init(self):
# 推送配置文件
@@ -872,10 +873,12 @@ class RobotInit(object):
user_settings = "/home/luoshi/bin/controller/user_settings"
interactive_data = f"/home/luoshi/bin/controller/interactive_data/{robot_type}"
if self.conf_path == "":
self.conf_path = f"{clibs.base_path}/assets/confs"
config_files = [
f"{clibs.base_path}/assets/confs/fieldbus_device.json",
f"{clibs.base_path}/assets/confs/registers.json",
f"{clibs.base_path}/assets/confs/registers.xml"
f"{self.conf_path}/fieldbus_device.json",
f"{self.conf_path}/registers.json",
f"{self.conf_path}/assets/confs/registers.xml"
]
for config_file in config_files:
filename = os.path.basename(config_file)