Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ModelManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ public string LoadModel(string filePath, string repositoryPath, string baseWebUr
{
foreach (var jj in ii.RequiredModel)
{
if (nodeset.Models.FirstOrDefault(m => m.ModelUri == jj.ModelUri) != null)
{
// RequiredModel is defined in the current document. Will be created later.
continue;
}

if (jj.ModelUri == Opc.Ua.Namespaces.OpcUa)
{
hasCoreModel = true;
Expand Down
19 changes: 16 additions & 3 deletions NodeSetToAML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,10 @@ private AttributeType AddModifyAttribute(AttributeSequence seq, string name, str
desiredAttribute = seq.Append(name); // not found so create a new one
}

RecreateAttributeInstance(sourceAttribute, desiredAttribute);
if (sourceAttribute != null)
{
RecreateAttributeInstance(sourceAttribute, desiredAttribute);
}

if (val.TypeInfo != null)
{
Expand Down Expand Up @@ -832,6 +835,12 @@ private AttributeType AddModifyAttribute(AttributeSequence seq, string name, str
{
Variant elementVariant = new Variant(valueAsList[index]);
ExtensionObject extensionObject = elementVariant.Value as ExtensionObject;

if (extensionObject.Encoding == ExtensionObjectEncoding.None)
{
continue;
}

NodeId typeId = ExpandedNodeId.ToNodeId(extensionObject.TypeId, m_modelManager.NamespaceUris);

Type extentionObjectType = extensionObject.Body.GetType();
Expand Down Expand Up @@ -2734,6 +2743,10 @@ private void AddNonHierarchicalReferences()
UANode targetNode = m_modelManager.FindNode<UANode>(referenceHolder.Reference.TargetId);
SystemUnitClassType targetSystemUnitClass = FindNonHierarchicalReference(referenceHolder,
targetNode);
if (targetSystemUnitClass == null)
{
continue;
}
string targetPath = GetCreatedPathName(targetNode);

string refURI = m_modelManager.FindModelUri(referenceHolder.Reference.ReferenceTypeId);
Expand All @@ -2743,8 +2756,8 @@ private void AddNonHierarchicalReferences()
referenceTypeNode.DecodedBrowseName.Name,
sourceSystemUnitClass.Name,
sourceSystemUnitClass.ID,
targetSystemUnitClass.Name,
targetSystemUnitClass.ID);
targetSystemUnitClass?.Name,
targetSystemUnitClass?.ID);

ExternalInterfaceType sourceInterface = FindOrAddSourceInterface(ref sourceSystemUnitClass,
refURI,
Expand Down
2 changes: 1 addition & 1 deletion OrderModelInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public List<ModelInfo> GetProcessOrder( List<ModelInfo> initial )
public void AddCompiled( string uri, HashSet<string> set,
Dictionary<string, ModelInfo> source )
{
if( source.TryGetValue( uri, out ModelInfo modelInfo ) )
if( source.TryGetValue( uri, out ModelInfo modelInfo ) && !set.Contains(uri))
{
if ( modelInfo.NodeSet != null &&
modelInfo.NodeSet.Models != null )
Expand Down