Hi again,
I’m trying to create an OPC UA method with one input struct (parameters a and b, they should be multiplied) and one output struct (with parameter result).
My Structs are:
In Variables.var I created this 2 variables:
Name: InputParamsVar → Type: InputParams
Name: OutputParamsVar → Type: OutputParams
In methods.uam the method looks like this:
The method implementation calculates:
<<OutputParamsVar.result := InputParamsVar.a * InputParams.b;>>
I also enabled the structs/fields as Replicable.
However in UAExpert I dont get one expandable struct parameter. Instead it there is one input Parameter called a (but no struct) and the result which also isnt a struct and doesnt calculates anything.
My question:
-Did i configure the method incorrectly? (cause other methods with In/out params, InputOnly etc work)
-or does the B&R OPC UA server not support struct method Arguments in the way I’m exspecting?
Much Thanks in Regards! Lisa
P.S: heres my Main.st implementation:
PROGRAM _INIT
VarA := 0.0;
VarB := 0.0;
VarResult := 0;
END_PROGRAM
PROGRAM _CYCLIC
(* UaSrv_MethodOperate - check and execute method code *)
CASE Step OF
INIT: (* prepare UaSrv_MethodOperate *)
UaSrv_MethodOperate_0.Action := UaMoa_CheckIsCalled;
UaSrv_MethodOperate_0.MethodName := 'Multiply';
UaSrv_MethodOperate_0.Execute := TRUE;
Step := WAIT;
WAIT: (* check if method called *)
UaSrv_MethodOperate_0();
IF (UaSrv_MethodOperate_0.Busy) THEN
UaSrv_MethodOperate_0.Execute := FALSE;
ELSE
IF (UaSrv_MethodOperate_0.Done) THEN
ErrorID:= 0;
IF (UaSrv_MethodOperate_0.IsCalled) THEN // check if method is called from OPC UA client
Step := EXECUTE; // method is called
END_IF
UaSrv_MethodOperate_0.Execute := TRUE;
END_IF
IF (UaSrv_MethodOperate_0.Error) THEN
ErrorID:= UaSrv_MethodOperate_0.ErrorID;
Step := ERROR;
END_IF
END_IF
EXECUTE: (* execute method code *)
OutputParamsVar.result := InputParamsVar.a * InputParamsVar.b; // method code
Step := OPERATE;
OPERATE: (* start operate *)
UaSrv_MethodOperate_0.Action := UaMoa_Finished; // method is finished, wait again for call
UaSrv_MethodOperate_0.MethodName := 'Multiply';
UaSrv_MethodOperate_0.Execute := TRUE;
Step := FINISH;
FINISH: (* Finish method *)
UaSrv_MethodOperate_0();
IF (UaSrv_MethodOperate_0.Busy) THEN
UaSrv_MethodOperate_0.Execute := FALSE;
ELSE
IF (UaSrv_MethodOperate_0.Done) THEN
ErrorID:= 0;
Step := INIT; // method is finished, wait again for call
END_IF
IF (UaSrv_MethodOperate_0.Error) THEN
ErrorID:= UaSrv_MethodOperate_0.ErrorID;
Step := ERROR;
END_IF
END_IF
ERROR: (* Error - wait to go to INIT step again *)
(* Some error Handling has to be implemented *)
END_CASE;
(* UaSrv_MethodCreate - create method on OPC-UA Server *)
InputArguments[0].Name := 'inputParams';
InputArguments[0].Value := 'InputParamsVar';
OutputArguments[0].Name := 'outputParams';
OutputArguments[0].Value := 'OutputParamsVar';
UaSrv_MethodCreate_0(
Execute := ExecuteMethodCreate_0,
MethodName := 'Add',
InputArguments := InputArguments,
OutputArguments := OutputArguments);
IF NOT (UaSrv_MethodCreate_0.Busy) THEN
ExecuteMethodCreate_0 := FALSE;
IF (UaSrv_MethodCreate_0.Done) THEN
ErrorID:= 0;
END_IF
IF (UaSrv_MethodCreate_0.Error) THEN
ErrorID:= UaSrv_MethodCreate_0.ErrorID;
END_IF
END_IF
(* UaSrv_MethodDelete - delete method *)
UaSrv_MethodDelete_0(
Execute := ExecuteMethodDelete_0,
MethodName := 'Add');
IF NOT (UaSrv_MethodDelete_0.Busy) THEN
ExecuteMethodDelete_0 := FALSE;
IF (UaSrv_MethodDelete_0.Done) THEN
ErrorID:= 0;
END_IF
IF (UaSrv_MethodDelete_0.Error) THEN
ErrorID:= UaSrv_MethodDelete_0.ErrorID;
END_IF
END_IF
END_PROGRAM
PROGRAM _EXIT
(* Insert code here *)
END_PROGRAM


