-
Notifications
You must be signed in to change notification settings - Fork 147
Description
Hello,
I am trying to make use of the nodeset compiler but I got stuck at some things. This is related to #310
The first thing that seems off is the fact that I cant see the AutoId Device Types. I compiled DI and AutoID like this:
❯ node gen_nodeset.js --ns 2 --nodeset DI/Opc.Ua.Di.NodeSet2.xml --module di
❯ node gen_nodeset.js --ns 3 --nodeset Machinery/Opc.Ua.Machinery.NodeSet2.xml --module machinery
Then I added them to my server, following the approach in the README.
Now I do see the DI related nodes in the address space:
But I cant see the device types from the AutoID:
Here is the "correct" address space (open62541 server with the same nodesets loaded):
I could still manage to create an instance like this:
let rifreader_type_id = NodeId::new(4, 1003);
//...
let instance = ObjectBuilder::new(&instance_node_id, "TestRFIDReaderDeviceType", "TestRFIDReaderDeviceType")
.has_component(rifreader_type_id.clone())
.event_notifier(EventNotifier::SUBSCRIBE_TO_EVENTS)
.organized_by(NodeId::objects_folder_id())
.insert(address_space);
But I cant write a variable or call a method. I managed to set a callback function but only if I add the method as a direct component of my RfidReader:
let scan_method_id = NodeId::new(4, 7013);
//...
let instance = ObjectBuilder::new(&instance_node_id, "TestRFIDReaderDeviceType", "TestRFIDReaderDeviceType")
.has_component(rifreader_type_id.clone())
.has_component(scan_method_id.clone())
.event_notifier(EventNotifier::SUBSCRIBE_TO_EVENTS)
.organized_by(NodeId::objects_folder_id())
.insert(address_space);
address_space.register_method_handler(scan_method_id, Box::new(testMethod));
// testMethod trait impl.
struct testMethod;
impl callbacks::Method for testMethod {
fn call(
&mut self,
_session_id: &NodeId,
_session_map: Arc<RwLock<SessionManager>>,
_request: &CallMethodRequest,
) -> Result<CallMethodResult, StatusCode> {
println!("Scan method called");
let message = format!("Hello from Scan!");
Ok(CallMethodResult {
status_code: StatusCode::Good,
input_argument_results: None,
input_argument_diagnostic_infos: None,
output_arguments: Some(vec![Variant::from(message)]),
})
}
}
But this does not allow for the correct input/output arguments. I would need to use the MethodBuilder. But this doesn't work because the nodeId of this Method is already in the address space.
All this leads to the question, does this even work? Like can I load two nodesets to the server, create instances of objects and then write variables and call methods with my own callback AND the correct input and output arguments?
Any input on this is appreciated! Thank you.