Email Us at [email protected]

Download N3uron
Back to videos

OPC UA Server / Creating Methods in OPC UA Server

Creating Methods in OPC UA Server

Description

In this video of our N3uron Academy, we’ll take it a step further by creating methods within the N3uron OPC UA Server and connecting to it with an OPC UA Client, specifically using UAExpert to invoke these methods. Let’s get started!

  • [06:28] Creating Methods in OPC UA Server

Transcription

[00:00] Hello everyone! Welcome back! In our last video, we configured N3uron’s OPC UA Server to demonstrate how to retrieve historical data using an OPC UA Client. Today, we’ll take it a step further by creating methods within the N3uron OPC UA Server and connecting to it with an OPC UA Client, specifically using UAExpert to invoke these methods. To follow along, ensure that your OPC UA Client supports Part 5 of the OPC UA specification, as this is crucial for calling methods on the server. We’ll also need to create an instance of the Scripting module in N3uron, where we’ll use N3uron’s Scripting API to define a custom script that the OPC UA Client can invoke as a method. First, let’s review the tags in the Real-time screen that we want to modify with this OPC UA call method.

[01:01] In this example, we’ll be adjusting the tracker positions for each station in our PV plant. We have six trackers in total that will respond to the target position setpoint. To get started, let’s create an instance of the Scripting module. Head to the Config tab, select Modules, and click on New Module. Give it a descriptive name, like Scripting, and set the Module Type to Scripting. Once this is done, save the configuration. With the Scripting module instance created, find it in the Modules list under the Explorer section, and click on it to open the configuration. Here, we’ll set up the script that contains the logic to adjust the tracker positions. Begin by creating a New Task in the Scripting module, which we’ll name OpcUaServer. Then, create a New Action for this task and name it something like Methods.

[02:01] Be sure to set this action type to External, as it will be triggered by an external call from the OPC UA Client. Next, let’s add the actual script. Click on New Script and give it a name, such as UpdateAllTrackerPositions. This script will contain the logic needed to update the tracker positions based on the input from the OPC UA Client. I already have this script prepared, so I’ll simply paste the code into the editor. Let’s go over how this script works. The script begins by receiving the target position input from the OPC UA Client, which specifies the desired angle or orientation for the trackers. To access this input, we use the event object within the script. Then, the script checks if this target position is within a safe, valid range—specifically between -90 and 90 degrees. This range is critical to ensure the trackers move only within safe operating limits.

[03:00] If the position is valid, the script proceeds to update the setpoints for each tracker in the PV plant. Here, we’re adjusting the position of six trackers in each station, from station one to station six within the PV Plant. The same target position is applied to each tracker, so they all align accordingly. Once all six trackers have been updated, the script returns a confirmation to the OPC UA Client, indicating that the update was successful. However, if the position is out of range, the script does not apply any updates and returns a message indicating the invalid position. The result is sent back through the isTrackerPositionUpdated variable, an output argument that tells us whether the update was successful. A “true” response means the update was successful, while “false” indicates an out-of-range input. With the script in place, the next step is to configure a method in the OPC UA Server to link it to the script we just created. Navigate to the Methods section in the OPC UA Server configuration and create a New Method.

[04:04] I’ll name it the same as the script, UpdateAllTrackerPositions, to keep things consistent. Then, select the script to be invoked, add a brief description, and set up an Input Argument for the tracker position that the OPC UA Client will provide. Set the data type to Int8, the value rank to Scalar, and include a short description. Next, create an Output Argument named isTrackerPositionUpdated to confirm whether the tracker positions have been updated. This enables the OPC UA Client to verify if the target setpoint was successfully applied.

[05:00] The output argument should be of Boolean data type and scalar. After defining the method, save your changes. Now we’re ready to connect with the OPC UA Client. Before we log in, make sure the user’s role that we’ll use for login has both Node Browsing and Call Method permissions enabled. Switch to the UAExpert OPC UA Client, log in to the OPC UA Server, and browse to select the method we just created. Enter the new target position for the trackers in degrees, and check the WebUI’s Real-time screen to confirm the trackers are adjusting to the new setpoint. We can see that the isTrackerPositionUpdated output argument shows “true,” indicating that the setpoint was successfully updated. To test the out-of-range handling, let’s enter a position value outside of the allowed range.

[06:04] This time, the isTrackerPositionUpdated output argument displays “false,” showing that the update failed because the input was out of range. And that’s it! We’ve now set up the OPC UA Server to accept method calls from an OPC UA Client. Thanks for watching, and see you in the next video!

 

Privacy Settings
We use cookies to enhance your experience while using our website. If you are using our Services via a browser you can restrict, block or remove cookies through your web browser settings. We also use content and scripts from third parties that may use tracking technologies. You can selectively provide your consent below to allow such third party embeds. For complete information about the cookies we use, data we collect and how we process them, please check our Privacy Policy
Youtube
Consent to display content from - Youtube
Vimeo
Consent to display content from - Vimeo
Google Maps
Consent to display content from - Google
Spotify
Consent to display content from - Spotify
Sound Cloud
Consent to display content from - Sound