OPC UA Plugin

The OPC UA plugin integrates two OPC UA specifications: Data Access and Alarms and Conditions.

Configuration location:

[Edge Main Folder]/configs/configurations/InputPlugins/OPCUA

These configs are only used for the Edge instance Luna.Console, executed directly from the [Edge Main Folder]. Click the "Service Application" tab above to check the location for Edge services.

Use the default DataMappings.xml and opcapplicationconfiguration.xml for most use cases. The default DataMappings.xml generate the following OPC UA Data Variables which can be used in the EventDefinition.xml

  • DisplayName: Name of the OPC UA item

  • SubscriptionName: Name of the OPC UA subscription, the item was assigned to

  • StatusCode: OPC UA Status Code of the item

  • Data: Data value of the OPC UA item

  • DataType: Translated data-type of the OPC UA item (.net datatype, not opc ua type)

  • SourceTimestamp: Timestamp when the source notified a change in value

  • ServerTimestamp: Timestamp when the Server recognized the change in value

  • StartNodeId: Node-Id of the item

If using the OPC UA Aggregations:

  • [DisplayName]Average, [DisplayName]Maximum, [DisplayName]Minimum, [DisplayName]StandardDeviation: If using the OPC UA Aggregation feature, these data points are moving aggregations according to the aggregation configuration. The DisplayName of the item is prepended to the aggregation type.

OpcUaSettings.xml

The OpcUaSettings.xml contains general information required for both Data Access as well as Alarms and Conditions.

Example configuration

<?xml version="1.0" encoding="utf-8" ?>
<OpcUaConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="https://senseforce.io/ ..\..\Schemas\opcuasettings.xsd">
  <SessionName>Senseforce Luna OPC UA Client</SessionName>
  <EndpointUrl>opc.tcp://desktop-7ql4vn4:51210/UA/SampleServer</EndpointUrl>

  <!-- Defines the maximum security level to connect with -->
  <MaxSecurityMode>SignAndEncrypt</MaxSecurityMode>

  <!--<UserName>Senseforce</UserName>
  <Password>PW1</Password>-->

  <PreferredLocales>
    <Locale>en-EN</Locale>
  </PreferredLocales>

  <SessionTimeout>700000</SessionTimeout>
  
  <!-- Regex which is used to extract variable name from StartNodeId -->
  <!-- <VariableNameRegex> myregex </VariableNameRegex> -->
  
    <!-- Regex which is used to extract a new Datapoint called NodeIdRegex
       The NodeId is used to create the value by specifying a regex. -->
  <!-- <NodeIdRegex> myRegex </NodeIdRegex> -->
  
	<!-- Set path and file name of the opc application configuration file -->
  <ApplicationConfig>
    <FilePath>$(LunaAppDataPath)configurations/InputPlugins/OPCUA</FilePath>
    <FileName>opcapplicationconfiguration.xml</FileName>
  </ApplicationConfig>
  	<!-- Set path and file name of the opc subscriptions configuration file -->
  <Subscriptions>
    <FilePath>$(LunaAppDataPath)configurations/InputPlugins/OPCUA</FilePath>
    <FileName>opcsubscriptions.xml</FileName>
  </Subscriptions>
  	<!-- Set path and file name of the opc mapping file -->
  <Mappings>
    <FilePath>$(LunaAppDataPath)configurations/InputPlugins/OPCUA</FilePath>
    <FileName>DataMappings.xml</FileName>
  </Mappings>
  <Logger>
    <!--LogLevel: Debug,Information,Warning,Error,Critical,None-->
    <LogLevel>Information</LogLevel>
  </Logger>
</OpcUaConfiguration>

Advanced settings

OPC UA Certificate handling

To establish a secure connection between SF Edge and the OPC UA server, the SF Edge certificates as well as the OPC UA server certificate need to be exchanged

  1. Copy public Senseforce Edge certificate (the public .der -file in the certs/certs - folder) to the OPC UA Server's trusted certificate folder

    1. Default OPC UA server trusted certificate folder is in [CommonApplicationData]/OPC Foundation/CertificateStores/UA Applications/certs (on the OPC UA server computer)

      1. CommonApplicationData for Windows: C:/ProgramData

      2. CommonApplicationData for unix: /usr/share (or the assemblies runtime location)

  2. Copy the the OPC UA Server certificate to the SF EOPC UA trusted certificate folder. (Configured in the SF Edge opcapplicationconfiguration.xml file)

    1. Default folder: CommonApplicationData/OPC Foundation/CertificateStores/UA Applications/certs

    2. Default behavior to get the server certificate:

      1. Start SF Edge with OPC UA Plugin (and therefore try to connect to the server)

      2. SF Edge will automatically place the server certificate in the rejected certificates folder (configured in the SF Edge opcapplicationconfiguration.xml file - default: [CommonApplicationData]/OPC Foundation/CertificateStores/RejectedCertificates/certs).

      3. Manually copy the server certificate from Rejected to Trusted folder

Subscription creation

To finally connect to the OPC UA server and subscribe to server nodes, the opcuasubscriptions.xml file needs to be configured. Use the Senseforce OPC UA server browser to create subscriptions for either OPC UA Data Access or Alarms and Conditions.

Exemplary opcuasubscriptions.xml are found below

Data Access

The belows example subscription subscribes to two Monitored items by defining two MonitoredItem blocks (see line 29 to 44 and 45 to 60). The most relevant settings are:

To add another node id to the subscription, simply copy/paste a full MonitoredItem (eg. lines 29 to 44) and change the Identifier as described above.

<?xml version="1.0" encoding="utf-8"?>
<ListOfSubscription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
  <Subscription>
    <DisplayName>Subscription_Test</DisplayName>
    <PublishingInterval>1000</PublishingInterval>
    <KeepAliveCount>10</KeepAliveCount>
    <LifetimeCount>1000</LifetimeCount>
    <MaxNotificationsPerPublish>0</MaxNotificationsPerPublish>
    <PublishingEnabled>true</PublishingEnabled>
    <Priority>255</Priority>
    <TimestampsToReturn>Both_2</TimestampsToReturn>
    <MaxMessageCount>10</MaxMessageCount>
    <DefaultItem>
      <DisplayName>MonitoredItem</DisplayName>
      <StartNodeId i:nil="true" />
      <RelativePath i:nil="true" />
      <NodeClass>Variable_2</NodeClass>
      <AttributeId>13</AttributeId>
      <IndexRange i:nil="true" />
      <Encoding i:nil="true" />
      <MonitoringMode>Reporting_2</MonitoringMode>
      <SamplingInterval>-1</SamplingInterval>
      <Filter i:nil="true" />
      <QueueSize>0</QueueSize>
      <DiscardOldest>true</DiscardOldest>
    </DefaultItem>
    <MinLifetimeInterval>10000</MinLifetimeInterval>
    <MonitoredItems>
      <MonitoredItem>
        <DisplayName>Int16Value</DisplayName>
        <StartNodeId>
          <Identifier>ns=2;s=Int16Values</Identifier>
        </StartNodeId>
        <RelativePath i:nil="true" />
        <NodeClass>Variable_2</NodeClass>
        <AttributeId>13</AttributeId>
        <IndexRange i:nil="true" />
        <Encoding i:nil="true" />
        <MonitoringMode>Reporting_2</MonitoringMode>
        <SamplingInterval>0</SamplingInterval>
        <Filter i:nil="true" />
        <QueueSize>1</QueueSize>
        <DiscardOldest>true</DiscardOldest>
      </MonitoredItem>
      <MonitoredItem>
        <DisplayName>UInt16Value</DisplayName>
        <StartNodeId>
          <Identifier>ns=2;s=UInt16Values</Identifier>
        </StartNodeId>
        <RelativePath i:nil="true" />
        <NodeClass>Variable_2</NodeClass>
        <AttributeId>13</AttributeId>
        <IndexRange i:nil="true" />
        <Encoding i:nil="true" />
        <MonitoringMode>Reporting_2</MonitoringMode>
        <SamplingInterval>0</SamplingInterval>
        <Filter i:nil="true" />
        <QueueSize>1</QueueSize>
        <DiscardOldest>true</DiscardOldest>
      </MonitoredItem>
    </MonitoredItems>
    <DisableMonitoredItemCache>false</DisableMonitoredItemCache>
  </Subscription>
</ListOfSubscription>

Setting OPC UA hysteresis filters

OPC UA implements powerful hysteresis filter settings. To add a filter to a specific monitored item, simply replace the section "<Filter i:nil="true" />" with

<Filter i:type="DataChangeFilter">
  <Trigger>StatusValue_1</Trigger>
  <DeadbandType>1</DeadbandType>
  <DeadbandValue>1</DeadbandValue>
</Filter>

Alarms and Conditions

Use the Senseforce OPC UA Data Access browser to create an opcuasubscriptions.xml file. Replace the original file with the newly created one.

Aggregations

Use the Aggregations.xml file to define moving aggregations for one or several of your variables.

<?xml version="1.0" encoding="utf-8" ?>
<AggregationConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <AggregatedValues>
    <AggregatedValue>
      <!-- DataPointName must match a StartNode-Identifier of a monitored item
           see the subscription.xml for node-identifiers-->
      <DataPointName>10854</DataPointName>
      <AggregatorTypes>
        <!-- Allowed types are: Average, StandardDeviation, Maximum, Minimum-->
        <Type>Average</Type>
        <Type>StandardDeviation</Type>
      </AggregatorTypes>
      <!-- Defines the size of the moving aggregation window. -->
      <WindowSizeNumber>10</WindowSizeNumber>
    </AggregatedValue>
  </AggregatedValues>
</AggregationConfig>

Use one AggregatedValue Block per variable you want to aggregate. Add the following settings to each block:

Last updated