i am trying to select an existing Part-Program on an sinumerik based machine using OPC-UA. I wrote an application to connect to the Server and so stuff using the OPC Foudnation model and sample applications - works fine so fare.
one Problem is to access the function Methods/Filehandling/Select UaExpert-Screenshot
i already did some research on the internet und found several unanswered questions dealing with that issue.
i tried to use the method as follows:
NodeId objectId = new NodeId("ns=2;s=/Methods/Filehandling");
NodeId methodId = new NodeId("ns=2;s=/Methods/Filehandling/Select");
inputArguments[0] = "Sinumerik/FileSystem/Part Program/000_TEST_OPC_2.MPF";
inputArguments[1] = 1;
//verify, the nodeIds are Valid
var resultobject = CorrespondingOPCNode.CorrespondingSession.ReadNode(objectId);
var resultmethod = CorrespondingOPCNode.CorrespondingSession.ReadNode(methodId);
var resultFile = CorrespondingOPCNode.CorrespondingSession.ReadNode(new NodeId("ns=2;s=" +(string)inputArguments[0]));
IList<object> results = CorrespondingOPCNode.CorrespondingSession!.Call(resultobject.NodeId,
resultmethod.NodeId, inputArguments.ToArray());
all nodeids are valid, but the "Call" returns a "BadNodeIdUnknown" Exception and i cannot figure out why. I also looked in the log of UaExpert after calling the method interactively showing the call-inputs in detail:
12:44:35.189Z|6|4A38* --> UaSession::call [Session=1] 12:44:35.189Z|7|4A38* ObjectId: ns=2;s=/Methods/Filehandling 12:44:35.189Z|7|4A38* MethodId: ns=2;s=/Methods/Filehandling/Select 12:44:35.189Z|7|4A38* Number of InputArguments: 2 12:44:35.189Z|7|4A38* Argument[0] = Sinumerik/FileSystem/Part Program/000_TEST_OPC_2.MPF 12:44:35.189Z|7|4A38* Argument1 = 1 12:44:35.189Z|4|4A38* CALL OpcUa_ClientApi_Call [Session=1] 12:44:35.252Z|4|4A38* DONE OpcUa_ClientApi_Call [ret=0x0,status=0x0] 12:44:35.252Z|7|4A38* Number of NoOfInputArgumentResults: 2 12:44:35.252Z|7|4A38* InputArgumentResults[0] = Good 12:44:35.253Z|7|4A38* InputArgumentResults1 = Good 12:44:35.253Z|7|4A38* Number of NoOfOutputArguments: 1 12:44:35.253Z|7|4A38* OutputArguments[0] = 0
does anyone have any suggestions, how to call that method? Thanks in advance!
Edit: as suggested i made a trace with wireshark:
when uscing UaExpert: when using own code:
so obviously there is an issue with the types of the inputparameters - but this shoudl lead to an BadInvalidArgument Exception?
Thanks to @Kevin Herron and his suggestion i found out, that the transmitted value for the chanel number was "1" as Int32, where an UInt32 is expected. So i changed the code to the following (debug-state, showing the differences)
so besides the change
inputArguments[0] = resultFile.NodeId;, which i alreaday tried before with no luck, the Problem was to format theinputArguments[1] = (UInt32)1;properly.What i still not understand is, why the errormessage was "BadNodeIdUnknown", i think maybe because the transmitted argumenttypes do not match any existing function... Anyways. Its working This way. Thanks to all for your help!