OPC UA Server - Methods
The WinCC OA OPC UA server supports OPC UA methods. A method that can be called by clients is added under a defined parent node. The actions to perform within WinCC OA are defined by using Control.
Such methods can have input and output parameters. The supported parameter types are the data types supported by OPC OA (see Mapping of WinCC OA <-> OPC UA Data Types).
OPC UA methods can only be added to parent nodes of type FolderType or
                BaseObjectType. If methods are added to a parent node with a
            different type, the errors BadNodeIdUnknown or
                BadMethodInvalid are returned during runtime.
Functionality
The Control library
                    wincc_oa_path/scripts/libs/opcuaSrv_Methods.ctl must be
                reconfigured so that the function getMethodsForOpcUaSrv(int
                    managerNumber) returns a list of the available methods for the OPC UA
                server instance.
 The function returns a list of UaMethod objects. To implement
                custom methods, a new class must be created that is derived from
                    UaMethod.
The OPC UA server is loading the methods at start-up. Therefore, a restart is always required, if the library "opcuaSrv_Methods.ctl" or the methods were changed, for the changes to take effect.
Method Class
 Example
Example
For an example, see
                    wincc_oa_path/scripts/examples/libs/opcuaSrv_Methods.ctl.
                Detailed code information can directly be found within the file
                    wincc_oa_path/scripts/libs/opcuaSrv_Methods.ctl.
Constructor
The class derived from UaMethod must contain a constructor in which
                the attributes of the class must be defined. This defines, amongst other things,
                where in the OPC UA address space the function should be attached and which input
                and output parameters are required.
Execute Function
            
            In addition, the execute function of the base class must be
                overloaded.
This function is called, when the OPC UA method is executed. The function receives the value for the previously defined input parameter and a list of output parameters as reference values.
When executing the function, the output parameter list must be filled with values and an OPC UA status code must be returned that matches the return value of the method.
The values of the output parameter must match the datatypes assigned within the
                constructor. The same number of output arguments must be returned as defined within
                the constructor, otherwise the method call will fail with the return code
                    BadInternalError.
Error Analysis
-dbg 27-dbg DRV_USR3 can be used. The flag will return
                detailed information about which methods were loaded at manager start. In addition,
                further information is provided during the execution of OPC UA methods.