From 0361858576bf4c1e6562140dddc0e00de6f04a06 Mon Sep 17 00:00:00 2001 From: Erich Barnstedt Date: Thu, 18 Jan 2024 16:18:47 +0100 Subject: [PATCH] Handle edge case if type info not found. --- UANodeManager.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/UANodeManager.cs b/UANodeManager.cs index e612f5d..7288796 100644 --- a/UANodeManager.cs +++ b/UANodeManager.cs @@ -271,6 +271,11 @@ private void AddModbusNodes(ThingDescription td, BaseObjectState assetFolder, Ke _uaVariables.Add(variableId, CreateVariable(assetFolder, property.Key, new ExpandedNodeId(new NodeId(nodeID), namespaceURI), assetFolder.NodeId.NamespaceIndex, complexTypeInstance)); } } + else + { + // OPC UA type info not found, default to float + _uaVariables.Add(variableId, CreateVariable(assetFolder, property.Key, new ExpandedNodeId(DataTypes.Float), assetFolder.NodeId.NamespaceIndex)); + } } else { @@ -431,7 +436,7 @@ private void AddAsset(IList references, ThingDescription td, out Bas { Log.Logger.Information($"Map asset to node: ns={objectNodeId.NamespaceIndex}, i={objectNodeId.Identifier}."); assetFolder = (BaseObjectState)Find(ExpandedNodeId.ToNodeId(objectNodeId, Server.NamespaceUris)); - assetFolder.Description = new LocalizedText("en", td.Title + " [" + td.Name + "]"); + assetFolder.Description = new Opc.Ua.LocalizedText("en", td.Title + " [" + td.Name + "]"); } else { @@ -569,8 +574,8 @@ private BaseObjectState CreateObject(NodeState parent, string name, string descr TypeDefinitionId = typeDefinition ?? ObjectTypeIds.BaseObjectType, NodeId = new NodeId(name, namespaceIndex), BrowseName = new QualifiedName(name, namespaceIndex), - Description = new LocalizedText(null, description), - DisplayName = new LocalizedText("en", name), + Description = new Opc.Ua.LocalizedText(null, description), + DisplayName = new Opc.Ua.LocalizedText("en", name), WriteMask = AttributeWriteMask.None, UserWriteMask = AttributeWriteMask.None, EventNotifier = EventNotifiers.None @@ -588,7 +593,7 @@ private BaseDataVariableState CreateVariable(NodeState parent, string name, Expa ReferenceTypeId = ReferenceTypes.Organizes, NodeId = new NodeId(name, namespaceIndex), BrowseName = new QualifiedName(name, namespaceIndex), - DisplayName = new LocalizedText("en", name), + DisplayName = new Opc.Ua.LocalizedText("en", name), WriteMask = AttributeWriteMask.None, UserWriteMask = AttributeWriteMask.None, AccessLevel = AccessLevels.CurrentRead, @@ -608,7 +613,7 @@ private MethodState CreateMethod(NodeState parent, string name, ushort namespace ReferenceTypeId = ReferenceTypeIds.HasComponent, NodeId = new NodeId(name, namespaceIndex), BrowseName = new QualifiedName(name, namespaceIndex), - DisplayName = new LocalizedText("en", name), + DisplayName = new Opc.Ua.LocalizedText("en", name), WriteMask = AttributeWriteMask.None, UserWriteMask = AttributeWriteMask.None, Executable = true,