02/16/2023
Hello,
I am trying to interface with an RFID reader RFU6xx which implements an OPC-UA server.
I am trying to call the method ScanStart which has the inputargument of an extensionobject:
async StartScan(aduration: number, acycles: number, adataAvailable: boolean){
const scanSettingsParams = {
duration : aduration,
cycles : acycles,
dataAvailable : adataAvailable,
locationType: 0
}
try {
// NodeID for InputArguments struct type (inherits from ScanSettings)
console.log("Hello1");
const nodeID = new NodeId(NodeIdType.NUMERIC, 3010, 3);
console.log("Hello2");
// Create ExtensionObject for InputArguments
const scanSettingsObj = await this.session.constructExtensionObject(nodeID, scanSettingsParams);
console.log(scanSettingsObj);
// Populate Method call with ExtensionObject as InputArgument
const methodToCall: CallMethodRequestLike = {
methodId: ("ns=4;i=7002"),
objectId: ("ns=4;i=5002"),
inputArguments: [
{
dataType: DataType.ExtensionObject,
value: scanSettingsObj
}
]
};
console.log(methodToCall);
console.log("Hello4");
// Call method, passing ScanSettings as input argument
await this.session.call(methodToCall,(err,results) => {
if (err) {
console.log("Hello8: Error");
console.log(err);
} else {
console.log(results);
console.log("Hello7");
}
});
console.log("Hello5");
} catch (err) {
console.log("Hello6: Error");
console.log(err);
}
}
When the extension object is created, following warnings are displayed in the console:
Hello2
08:58:55.689Z :populate_data_type_manager_104:67 Error Error: Cannot find dataType Definition ! with nodeId =ns=2;i=6522... at C:\Development\Projects\sample_client_ts
ode_modules
ode-opcua-client-dynamic-extension-object\source\private\populate_data_type_manager_104.ts:46:19... at Generator.next ()... at fulfilled (C:\Development\Projects\sample_client_ts
ode_modules
ode-opcua-client-dynamic-extension-object\dist\private\populate_data_type_manager_104.js:5:58)... at processTicksAndRejections (node:internal/process/task_queues:96:5)08:58:55.701Z :populate_data_type_manager_104:67 Error Error: Cannot find dataType Definition ! with nodeId =ns=2;i=6525...
How do I construct the extensionobject the right way?
1 Guest(s)