Skip to content

Commit

Permalink
Handle edge case if type info not found.
Browse files Browse the repository at this point in the history
  • Loading branch information
barnstee committed Jan 18, 2024
1 parent 1468fa1 commit 0361858
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions UANodeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -431,7 +436,7 @@ private void AddAsset(IList<IReference> 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
{
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 0361858

Please sign in to comment.