Closed manolait closed 1 year ago
Using the mapping tool is able to generate the config.json but the error log is the same as above. I have made some progress on the problem and it seems related to IoTAgent as it is not able to generate the values but it does in OCB.
So with the config file it does not work. I have tried to generate a device with the API but it does not support this "object_id" structure: "ns=1;s=temperature_tl"
by the =.
Reviewing a lot of documentation I have seen that you can do it this way "object_id": "ns*1:s*temperature_tl"
in version 1.3.4. Now you can create a new device and it works.
However the multiple configuration file does not work for version 1.3.4 which is recommended for external connections. There is no point in configuring it if you then have to add devices through the API.
My recommendation for other users who want an external access is to use only the 1.3.4 tags, the other documentation is not valid.
EDIT
Checking even more documentation with the 1.3.4 tag I can't find anywhere the option of multiple and external config file so I think this is only available in the later versions but at the same time it is incompatible with the external connections since they only work in 1.3.4.
Therefore to use the multiple and external OPC connection in the config file just configure an object and then through the API device creation add the new OPC objects but using this format: "object_id": "ns*1:s*temperature_tl"
the ; and = are from version 1.4.
can you confirm me if I am right and the multiple config is not allowed in the external version 1.3.4?
hi @manolait, multiple device configuration now works on iotagent v2, i provide you a working example to test
config.js
var config = {};
config.iota = {
logLevel: 'DEBUG',
timestamp: true,
contextBroker: {
host: 'localhost',
port: '1026',
ngsiVersion: 'v2',
jsonLdContext: 'https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld',
service: 'opcua_car',
subservice: '/demo'
},
server: {
port: 4041
},
deviceRegistry: {
type: 'mongodb'
},
mongodb: {
host: 'localhost',
port: '27017',
db: 'iotagent_opcua'
},
types: {
DeviceA: {
active: [
{
name: 'ParametersASpeed',
type: 'Number'
}
]
},
DeviceB: {
active: [
{
name: 'ParametersBVelocity',
type: 'Number'
}
]
}
},
contexts: [
{
id: 'age01_Car',
type: 'DeviceA',
mappings: [
{
ocb_id: 'ParametersASpeed',
opcua_id: 'ns=2;i=2',
object_id: 'ns=2;i=2',
inputArguments: []
}
]
},
{
id: 'age02_Car',
type: 'DeviceB',
mappings: [
{
ocb_id: 'ParametersBVelocity',
opcua_id: 'ns=3;i=2',
object_id: 'ns=3;i=2',
inputArguments: []
}
]
}
],
contextSubscriptions: [],
service: 'opcua_car',
subservice: '/demo',
providerUrl: 'http://localhost:4041',
deviceRegistrationDuration: 'P20Y',
defaultType: 'Device',
defaultResource: '/iot/opcua',
explicitAttrs: false
};
config.opcua = {
endpoint: 'opc.tcp://localhost:4840',
securityMode: 'None',
securityPolicy: 'None',
username: null,
password: null,
uniqueSubscription: false
};
config.mappingTool = {
polling: false,
agentId: 'age01_',
namespaceIgnore: '0,7',
entityId: 'age01_Car',
entityType: 'Device'
};
config.jexlTransformations = {};
config.configRetrieval = false;
config.defaultKey = 'iot';
config.defaultTransport = 'OPCUA';
config.autoprovision = true;
module.exports = config;
server-opcua.py
from opcua import Server
from random import randint
import time
server = Server()
url = "opc.tcp://127.0.0.1:4840"
server.set_endpoint(url)
name = "age01_Car"
addspace = server.register_namespace(name)
node = server.get_objects_node()
Param = node.add_object(addspace, "ParametersA")
Speed = Param.add_variable(addspace,"Speed",0, datatype=11)
Speed.set_writable()
name = "age02_Car"
addspace2 = server.register_namespace(name)
Param2 = node.add_object(addspace2, "ParametersB")
Velocity = Param2.add_variable(addspace2,"Velocity",0, datatype=11)
Velocity.set_writable()
server.start()
print("Server has started at {}".format(url))
while True:
i = randint(20,100)
print("Speed:",i)
Speed.set_value(i)
j = randint(20,100)
print("Velocity:",j)
Velocity.set_value(j)
time.sleep(2)
Hello,
I have an OPC server with different Objects and inside each object variables.
I am using the MULTIPLE_DEVICES file but I get the following error msg={"name": "DEVICE_NOT_FOUND", "message": "No device was found with id:RW1", "code":404} It seems that the contextBroker does not find it, but it is there when making the query.
When I delete either of the two and leave only one device it works correctly.
What is the problem, how can I solve it?
Configuration file
LOG ERROR: