MTConnect C++ Agent V2.1运行失败求助:如何启动及配置Adapter?
我测试从GitHub获取的MTConnect C++ Agent V2.1版本,使用Windows预编译二进制包。按照文档,在包含相关文件的bin目录执行命令:
agent.exe run agent.cfg
运行后日志出现以下错误:
2023-03-15T10:29:55.419359Z (0x000025e4) [info]
MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig:
Starting agent on port 5000 2023-03-15T10:29:55.425344Z (0x000025e4)
[warning]
MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->AgentConfiguration::loadSinks:
The following path "../styles\old" is not a regular file:
"D:@TLL_Docs\MTConnect\MTConnectCPPAgentVersion2\cppagent-2.1.0.6-win64\styles\old"
2023-03-15T10:29:55.426341Z (0x000025e4) [info]
MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->Agent::initialize->Agent::loadXMLDeviceFile:
MTConnect Schema Version of file:
D:@TLL_Docs\MTConnect\MTConnectCPPAgentVersion2\cppagent-2.1.0.6-win64\bin../simulator/VMC-3Axis.xml
= 2.0 2023-03-15T10:29:55.433323Z (0x000025e4) [info] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->AgentConfiguration::loadAdapters:
shdr: Adding adapter for VMC-3Axis: VMC-3Axis
2023-03-15T10:29:55.434320Z (0x000025e4) [debug] MAIN: Waiting for
monitor thread to exit to restart agent 2023-03-15T10:29:55.434320Z
(0x000025e4) [debug] MAIN->AgentConfiguration::monitorThread:
Monitoring files:
"D:@TLL_Docs\MTConnect\MTConnectCPPAgentVersion2\cppagent-2.1.0.6-win64\bin\agent.cfg"
and
D:@TLL_Docs\MTConnect\MTConnectCPPAgentVersion2\cppagent-2.1.0.6-win64\bin../simulator/VMC-3Axis.xml,
will warm start if they change. 2023-03-15T10:29:55.434320Z
(0x000025e4) [debug] MAIN->AgentConfiguration::monitorThread: Setting
device and config times 2023-03-15T10:29:55.435318Z (0x00004ebc)
[debug] Connector::resolved->Connector::connect: Connecting to data
source: 127.0.0.1 on port: 7878 2023-03-15T10:29:57.486013Z
(0x00004ebc) [error] Connector::connected: No connection could be made
because the target machine actively refused it: No connection could be
because the target machine actively refused it
2023-03-15T10:29:58.486920Z (0x00004ebc) [info] : reconnect: retrying
connection
我推测需要配置Adapter,但不知道具体操作方法,求正确运行MTConnect C++ Agent的步骤。
1. 启动内置的Simulator Adapter
预编译包自带了用于测试的Simulator Adapter,它会模拟机床数据并通过7878端口发送给Agent。操作如下:
- 打开新的命令提示符,切换到Agent的
simulator目录(示例路径:D:\@TLL_Docs\MTConnect\MTConnectCPPAgentVersion2\cppagent-2.1.0.6-win64\simulator) - 执行命令:
simulator.exe run VMC-3Axis.xml
该命令会启动模拟适配器,监听7878端口,与Agent配置中的连接参数匹配。
2. 重新启动MTConnect Agent
保持Simulator运行,回到bin目录的命令提示符,重新执行:
agent.exe run agent.cfg
此时Agent应能成功连接到Simulator,获取模拟数据。
3. 验证Agent运行
打开浏览器访问http://localhost:5000,若能看到MTConnect响应页面,说明Agent已正常运行。
处理额外警告
日志中的../styles\old路径警告,是因为配置文件引用了不存在的样式目录。可忽略该警告,或修改agent.cfg中的sinks配置项,移除对应的旧样式路径。
内容的提问来源于stack exchange,提问作者Muhammad Faizan Khan

