This is an automated email from the ASF dual-hosted git repository.

ldywicki pushed a commit to branch opc-ua-events
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 66ec6b996c96db81be4f3c16f21aeb9f0d4bb355
Author: Łukasz Dywicki <l...@code-house.org>
AuthorDate: Mon Aug 5 18:01:46 2024 +0200

    Include wider pool of OPC-UA types in mspec.
    
    Signed-off-by: Łukasz Dywicki <l...@code-house.org>
---
 .../readwrite/UserIdentityTokenDefinition.java     | 166 ---------------------
 .../opcua/protocol/OpcuaSubscriptionHandle.java    |  25 +++-
 protocols/opcua/src/main/xslt/opc-manual.xsl       |  28 ++--
 3 files changed, 32 insertions(+), 187 deletions(-)

diff --git 
a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/UserIdentityTokenDefinition.java
 
b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/UserIdentityTokenDefinition.java
deleted file mode 100644
index 40c68160ba..0000000000
--- 
a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/UserIdentityTokenDefinition.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.plc4x.java.opcua.readwrite;
-
-import static org.apache.plc4x.java.spi.codegen.fields.FieldReaderFactory.*;
-import static org.apache.plc4x.java.spi.codegen.fields.FieldWriterFactory.*;
-import static org.apache.plc4x.java.spi.codegen.io.DataReaderFactory.*;
-import static org.apache.plc4x.java.spi.codegen.io.DataWriterFactory.*;
-import static org.apache.plc4x.java.spi.generation.StaticHelper.*;
-
-import java.time.*;
-import java.util.*;
-import org.apache.plc4x.java.api.exceptions.*;
-import org.apache.plc4x.java.api.value.*;
-import org.apache.plc4x.java.spi.codegen.*;
-import org.apache.plc4x.java.spi.codegen.fields.*;
-import org.apache.plc4x.java.spi.codegen.io.*;
-import org.apache.plc4x.java.spi.generation.*;
-
-// Code generated by code-generation. DO NOT EDIT.
-
-public abstract class UserIdentityTokenDefinition implements Message {
-
-  // Abstract accessors for discriminator values.
-  public abstract String getIdentifier();
-
-  public UserIdentityTokenDefinition() {
-    super();
-  }
-
-  protected abstract void 
serializeUserIdentityTokenDefinitionChild(WriteBuffer writeBuffer)
-      throws SerializationException;
-
-  public void serialize(WriteBuffer writeBuffer) throws SerializationException 
{
-    PositionAware positionAware = writeBuffer;
-    boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get();
-    writeBuffer.pushContext("UserIdentityTokenDefinition");
-
-    // Switch field (Serialize the sub-type)
-    serializeUserIdentityTokenDefinitionChild(writeBuffer);
-
-    writeBuffer.popContext("UserIdentityTokenDefinition");
-  }
-
-  @Override
-  public int getLengthInBytes() {
-    return (int) Math.ceil((float) getLengthInBits() / 8.0);
-  }
-
-  @Override
-  public int getLengthInBits() {
-    int lengthInBits = 0;
-    UserIdentityTokenDefinition _value = this;
-    boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get();
-
-    // Length of sub-type elements will be added by sub-type...
-
-    return lengthInBits;
-  }
-
-  public static UserIdentityTokenDefinition staticParse(ReadBuffer readBuffer, 
Object... args)
-      throws ParseException {
-    PositionAware positionAware = readBuffer;
-    if ((args == null) || (args.length != 1)) {
-      throw new PlcRuntimeException(
-          "Wrong number of arguments, expected 1, but got " + args.length);
-    }
-    String identifier;
-    if (args[0] instanceof String) {
-      identifier = (String) args[0];
-    } else if (args[0] instanceof String) {
-      identifier = String.valueOf((String) args[0]);
-    } else {
-      throw new PlcRuntimeException(
-          "Argument 0 expected to be of type String or a string which is 
parseable but was "
-              + args[0].getClass().getName());
-    }
-    return staticParse(readBuffer, identifier);
-  }
-
-  public static UserIdentityTokenDefinition staticParse(ReadBuffer readBuffer, 
String identifier)
-      throws ParseException {
-    readBuffer.pullContext("UserIdentityTokenDefinition");
-    PositionAware positionAware = readBuffer;
-    boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get();
-
-    // Switch Field (Depending on the discriminator values, passes the 
instantiation to a sub-type)
-    UserIdentityTokenDefinitionBuilder builder = null;
-    if (EvaluationHelper.equals(identifier, (String) "anonymous")) {
-      builder =
-          AnonymousIdentityToken.staticParseUserIdentityTokenDefinitionBuilder(
-              readBuffer, identifier);
-    } else if (EvaluationHelper.equals(identifier, (String) "username")) {
-      builder =
-          UserNameIdentityToken.staticParseUserIdentityTokenDefinitionBuilder(
-              readBuffer, identifier);
-    } else if (EvaluationHelper.equals(identifier, (String) "certificate")) {
-      builder =
-          
X509IdentityToken.staticParseUserIdentityTokenDefinitionBuilder(readBuffer, 
identifier);
-    } else if (EvaluationHelper.equals(identifier, (String) "identity")) {
-      builder =
-          
IssuedIdentityToken.staticParseUserIdentityTokenDefinitionBuilder(readBuffer, 
identifier);
-    }
-    if (builder == null) {
-      throw new ParseException(
-          "Unsupported case for discriminated type"
-              + " parameters ["
-              + "identifier="
-              + identifier
-              + "]");
-    }
-
-    readBuffer.closeContext("UserIdentityTokenDefinition");
-    // Create the instance
-    UserIdentityTokenDefinition _userIdentityTokenDefinition = builder.build();
-    return _userIdentityTokenDefinition;
-  }
-
-  public interface UserIdentityTokenDefinitionBuilder {
-    UserIdentityTokenDefinition build();
-  }
-
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) {
-      return true;
-    }
-    if (!(o instanceof UserIdentityTokenDefinition)) {
-      return false;
-    }
-    UserIdentityTokenDefinition that = (UserIdentityTokenDefinition) o;
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    return Objects.hash();
-  }
-
-  @Override
-  public String toString() {
-    WriteBufferBoxBased writeBufferBoxBased = new WriteBufferBoxBased(true, 
true);
-    try {
-      writeBufferBoxBased.writeSerializable(this);
-    } catch (SerializationException e) {
-      throw new RuntimeException(e);
-    }
-    return "\n" + writeBufferBoxBased.getBox().toString() + "\n";
-  }
-}
diff --git 
a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java
 
b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java
index a68a04fb4d..050fb624c4 100644
--- 
a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java
+++ 
b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java
@@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.plc4x.java.api.messages.PlcSubscriptionEvent;
 import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest;
 import org.apache.plc4x.java.api.model.PlcConsumerRegistration;
+import org.apache.plc4x.java.api.types.PlcSubscriptionType;
 import org.apache.plc4x.java.api.value.PlcValue;
 import org.apache.plc4x.java.opcua.context.Conversation;
 import org.apache.plc4x.java.opcua.tag.OpcuaTag;
@@ -111,12 +112,29 @@ public class OpcuaSubscriptionHandle extends 
DefaultPlcSubscriptionHandle {
                     monitoringMode = MonitoringMode.monitoringModeReporting;
             }
 
-            long clientHandle = clientHandles.getAndIncrement();
+            ExtensionObject eventFilter = 
OpcuaProtocolLogic.NULL_EXTENSION_OBJECT;
+            if (tagDefaultPlcSubscription.getPlcSubscriptionType() == 
PlcSubscriptionType.EVENT) {
+                FilterOperand filterOperand = new FilterOperand();
+                EventFilter eventFilter1 = new EventFilter(
+                    0,
+                    Arrays.asList(filterOperand),
+                    new NullExtension()
+                );
+                ExpandedNodeId expandedNodeId = new ExpandedNodeId(false, 
false,
+                    new NodeIdFourByte((short) 0, 
Integer.parseInt(eventFilter.getIdentifier())),
+                    null, null
+                );
+                eventFilter = new ExtensionObject(expandedNodeId,
+                    new ExtensionObjectEncodingMask(false, false, true),
+                    eventFilter1
+                );
+            }
 
+            long clientHandle = clientHandles.getAndIncrement();
             MonitoringParameters parameters = new MonitoringParameters(
                 clientHandle,
                 (double) cycleTime,     // sampling interval
-                OpcuaProtocolLogic.NULL_EXTENSION_OBJECT,       // filter, 
null means use default
+                eventFilter,       // filter, null means use default
                 1L,   // queue size
                 true        // discard oldest
             );
@@ -204,6 +222,9 @@ public class OpcuaSubscriptionHandle extends 
DefaultPlcSubscriptionHandle {
                                 .filter(extensionObjectDefinition -> 
extensionObjectDefinition instanceof MonitoredItemNotification)
                                 .map(extensionObjectDefinition -> 
(MonitoredItemNotification) extensionObjectDefinition)
                                 .toArray(MonitoredItemNotification[]::new));
+                        } else if (notification instanceof NotificationData) {
+                            NotificationData data = (NotificationData) 
notification;
+
                         } else {
                             LOGGER.warn("Unsupported Notification type");
                         }
diff --git a/protocols/opcua/src/main/xslt/opc-manual.xsl 
b/protocols/opcua/src/main/xslt/opc-manual.xsl
index b7ccfb080c..dd949b9aa8 100644
--- a/protocols/opcua/src/main/xslt/opc-manual.xsl
+++ b/protocols/opcua/src/main/xslt/opc-manual.xsl
@@ -230,29 +230,16 @@
         ['"0"' NullExtension
         ]
 
-        <xsl:for-each 
select="/opc:TypeDictionary/opc:StructuredType[(@BaseType = 
'ua:ExtensionObject') and not(@Name = 'UserIdentityToken') and not(@Name = 
'PublishedDataSetDataType') and not(@Name = 'DataSetReaderDataType') and 
not(@Name = 'PubSubConfigurationValueDataType') and not(@Name = 
'PortableNodeId')]">
+        <xsl:for-each 
select="/opc:TypeDictionary/opc:StructuredType[((@BaseType = 
'ua:ExtensionObject') or (starts-with(@BaseType, 'tns:') and not (@BaseType = 
'tns:UserIdentityToken'))) and
+            not(@Name = 'UserIdentityToken') and
+            not(@Name = 'PublishedDataSetDataType') and
+            not(@Name = 'DataSetReaderDataType') and
+            not(@Name = 'PubSubConfigurationValueDataType') and
+            not(@Name = 'PortableNodeId')]">
             <xsl:variable name="extensionName" select="@Name"/>
             <xsl:apply-templates 
select="$file/node:UANodeSet/node:UADataType[@BrowseName=$extensionName]"/>
         </xsl:for-each>
 
-        ['"811"' DataChangeNotification
-            [implicit int 32 notificationLength 'lengthInBytes']
-            [simple int 32 noOfMonitoredItems]
-            [array ExtensionObjectDefinition('"808"')  monitoredItems count 
'noOfMonitoredItems']
-            [simple int 32 noOfDiagnosticInfos]
-            [array DiagnosticInfo  diagnosticInfos count 'noOfDiagnosticInfos']
-        ]
-        ['"916"' EventNotificationList
-            [implicit int 32 notificationLength 'lengthInBytes']
-            [simple int 32 noOfEvents]
-            [array ExtensionObjectDefinition('"919"')  events count 
'noOfEvents']
-        ]
-        ['"820"' StatusChangeNotification
-            [implicit int 32 notificationLength 'lengthInBytes']
-            [simple StatusCode status]
-            [simple DiagnosticInfo diagnosticInfo]
-        ]
-
         ['"316"' UserIdentityToken
             [implicit int 32 policyLength 'policyId.lengthInBytes  + 
userIdentityTokenDefinition.lengthInBytes']
             [simple PascalString policyId]
@@ -457,6 +444,9 @@
 // StructuredTypes
 <xsl:apply-templates select="/opc:TypeDictionary/opc:StructuredType[(@Name != 
'ExtensionObject') and (@Name != 'Variant') and (@Name != 'NodeId') and (@Name 
!= 'ExpandedNodeId') and not(@BaseType)]"/>
 
+// StructuredTypes extensions
+<!--<xsl:apply-templates select="/opc:TypeDictionary/opc:StructuredType[(@Name 
!= 'ExtensionObject') and (@Name != 'Variant') and (@Name != 'NodeId') and 
(@Name != 'ExpandedNodeId') and (@BaseType != 'ua:ExtensionObject')]"/>-->
+
 // EnumeratedTypes
 <xsl:apply-templates select="/opc:TypeDictionary/opc:EnumeratedType"/>
 

Reply via email to