mtconnect / cppagent

C++ Agent toolkit - Pre-built binaries, visit: https://github.com/mtconnect/cppagent/releases Docker images available at https://hub.docker.com/repositories/mtconnect
http://mtcup.org/
Apache License 2.0
141 stars 91 forks source link

Duplicate DataItem id error for Device File with multiple Devices defined #482

Closed shaurabhsingh closed 2 months ago

shaurabhsingh commented 2 months ago

Getting the following error with the agent:

2024-08-08T12:41:32.197067Z (0x00001bac) [info] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig: Starting agent on port 5000
2024-08-08T12:41:32.203099Z (0x00001bac) [debug] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->AgentConfiguration::loadSinks: Cannot find file './schemas/'  in path "C:\\Users\\ssing\\OneDrive\\Documents\\MTConnect Standard\\Agent\\agent-2.2.0.3-win64\\agent-2.2.0.3-win64\\ros agent"
2024-08-08T12:41:32.203099Z (0x00001bac) [error] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->AgentConfiguration::loadSinks: RestService loading Files: Cannot resolve path: ./schemas/ in data path
2024-08-08T12:41:32.204077Z (0x00001bac) [info] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->Agent::initialize->Agent::loadXMLDeviceFile: MTConnect Schema Version of file: C:\Users\ssing\OneDrive\Documents\MTConnect Standard\Agent\agent-2.2.0.3-win64\agent-2.2.0.3-win64\ros agent\combined.xml = 2.0
2024-08-08T12:41:32.209587Z (0x00001bac) [info] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->AgentConfiguration::loadAdapters: shdr: Adding adapter for robot: robot1
2024-08-08T12:41:32.209587Z (0x00001bac) [error] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->AgentConfiguration::loadAdapters: Duplicate component id: _localhost_7996 for device Agent, skipping
2024-08-08T12:41:32.209587Z (0x00001bac) [fatal] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->AgentConfiguration::loadAdapters: Device Agent: Duplicatie data item id  '_localhost_7996_connection_status', Exiting

Have tried with v2.2.0.3 and v2.3.0.16 versions and both failed. But it did work with v2.1.0.1 agent.

My guess: Since the device xml has multiple devices and the agent is generating the same id for ConnectionStatus for all the devices, it is creating the duplicate dataitem id error.

Device File: https://github.com/mtconnect/ros_mtconnect_2/blob/master/simulator/src/deviceFiles/combined.xml

wsobel commented 2 months ago

This is related to the config file and the adapters. It’s saying there are two identical adapter entries in the file. Can you attach the agent.cfg file?

shaurabhsingh commented 2 months ago

Devices = combined.xml
ServiceName = MTConnect Agent 1
Port = 5000
BufferSize = 17
IgnoreTimestamps = true
PreserveUUID = false

SchemaVersion = 2.0

Adapters { 
 robot1 { 
    FilterDuplicates  =  yes
    AutoAvailable  =  no
    Device = robot
    Host = localhost
    Port = 7996
  }
 cnc1 { 
    FilterDuplicates  =  yes
    AutoAvailable  =  no
    Device = cnc
    Host = localhost
    Port = 7896
  }
 conv1 { 
    FilterDuplicates  =  yes
    AutoAvailable  =  no
    Device = conv
    Host = localhost
    Port = 7796
  }
 b1 { 
    FilterDuplicates  =  yes
    AutoAvailable  =  no
    Device = buffer
    Host = localhost
    Port = 7696
  }
 cmm1 { 
    FilterDuplicates  =  yes
    AutoAvailable  =  no
    Device = cmm
    Host = localhost
    Port = 7596
  }
 conv2 { 
    FilterDuplicates  =  yes
    AutoAvailable  =  no
    Device = conv2
    Host = localhost
    Port = 7496
  }
 }

Files {
  schemas { 
    Location = /schemas/
    Path = ./schemas/
  }
}

# Logger Configuration
logger_config
{
    logging_level = debug
    output = file agent.log
}
wsobel commented 2 months ago

I'll test this locally and see what's happening.

wsobel commented 2 months ago

I'm having trouble reproducing. Any other information about the environment?

wsobel commented 2 months ago

Here's what I get:

[2024-08-08 10:29:06.715175] [0x00000001f9f5cc00] [debug]   Cannot file path: "/etc/mtconnect", No such file or directory
[2024-08-08 10:29:06.715429] [0x00000001f9f5cc00] [debug]   Cannot file path: "/usr/local/etc/mtconnect", No such file or directory
[2024-08-08 10:29:06.715444] [0x00000001f9f5cc00] [debug]   Cannot file path: "/usr/local/share/mtconnect", No such file or directory
MTConnect Agent Version 2.4.0.1 - built on Fri Jul  5 10:14:00 2024
[2024-08-08 10:29:06.715558] [0x00000001f9f5cc00] [debug]   Found file 'agent.cfg'  in path "/Users/will/projects/MTConnect/agent/issues/482_duplicate_data_item"
[2024-08-08 10:29:06.715576] [0x00000001f9f5cc00] [debug]   Loading configuration from: "/Users/will/projects/MTConnect/agent/issues/482_duplicate_data_item/agent.cfg"
Loading configuration from:"/Users/will/projects/MTConnect/agent/issues/482_duplicate_data_item/agent.cfg"
2024-08-08T14:29:06.717210Z (0x00000001f9f5cc00) [debug] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig: Searching config paths for combined.xml
2024-08-08T14:29:06.717242Z (0x00000001f9f5cc00) [debug] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig:   "/Users/will/projects/MTConnect/agent/issues/482_duplicate_data_item"
2024-08-08T14:29:06.717259Z (0x00000001f9f5cc00) [debug] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig:   "/Users/will/projects/MTConnect/agent/build/build/static-armv8/agent/Debug"
2024-08-08T14:29:06.717277Z (0x00000001f9f5cc00) [debug] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig: Found file 'combined.xml'  in path "/Users/will/projects/MTConnect/agent/issues/482_duplicate_data_item"
2024-08-08T14:29:06.717342Z (0x00000001f9f5cc00) [info] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig: Starting agent on port 5001
2024-08-08T14:29:06.727173Z (0x00000001f9f5cc00) [debug] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->AgentConfiguration::loadSinks: Cannot find file './schemas/'  in path "/Users/will/projects/MTConnect/agent/issues/482_duplicate_data_item"
2024-08-08T14:29:06.727213Z (0x00000001f9f5cc00) [error] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->AgentConfiguration::loadSinks: RestService loading Files: Cannot resolve path: ./schemas/ in data path
2024-08-08T14:29:06.728905Z (0x00000001f9f5cc00) [info] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->Agent::initialize->Agent::loadXMLDeviceFile: MTConnect Schema Version of file: /Users/will/projects/MTConnect/agent/issues/482_duplicate_data_item/combined.xml = 1.5
2024-08-08T14:29:12.496859Z (0x00000001f9f5cc00) [info] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->AgentConfiguration::loadAdapters: shdr: Adding adapter for robot: robot1
2024-08-08T14:29:12.500187Z (0x00000001f9f5cc00) [info] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->AgentConfiguration::loadAdapters: shdr: Adding adapter for cnc: cnc1
2024-08-08T14:29:12.503679Z (0x00000001f9f5cc00) [info] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->AgentConfiguration::loadAdapters: shdr: Adding adapter for conv: conv1
2024-08-08T14:29:12.507083Z (0x00000001f9f5cc00) [info] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->AgentConfiguration::loadAdapters: shdr: Adding adapter for buffer: b1
2024-08-08T14:29:12.510279Z (0x00000001f9f5cc00) [info] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->AgentConfiguration::loadAdapters: shdr: Adding adapter for cmm: cmm1
2024-08-08T14:29:12.512954Z (0x00000001f9f5cc00) [info] MAIN->AgentConfiguration::initialize->AgentConfiguration::loadConfig->AgentConfiguration::loadAdapters: shdr: Adding adapter for conv2: conv2
2024-08-08T14:29:12.519608Z (0x000000016ff13000) [debug] Connector::resolved->Connector::connect: Connecting to data source: localhost on port: 7996
2024-08-08T14:29:12.520022Z (0x000000016ff13000) [debug] Connector::resolved->Connector::connect: Connecting to data source: localhost on port: 7896
shaurabhsingh commented 2 months ago

Could you try with v2.2.0.3 or v2.3.0.16 agent releases?

wsobel commented 2 months ago

2.4.0.1

wsobel commented 2 months ago

It is mostly the same as the 2.3 agents, just with a few new features. 2.3.0.16 should work as well.

wsobel commented 2 months ago

Can't reproduce.

shaurabhsingh commented 2 months ago

Found it. error in the agent.cfg previously that had two adapters with same port. My bad.