@@ -1553,9 +1553,17 @@ private AttributeType AddModifyAttribute(AttributeSequence seq, string name, Nod
15531553 }
15541554
15551555
1556- private void OverrideBooleanAttribute ( AttributeSequence seq , string AttributeName , Boolean value )
1556+ private AttributeType OverrideBooleanAttribute ( AttributeSequence seq ,
1557+ string AttributeName ,
1558+ Boolean value ,
1559+ bool typeOnly = false )
15571560 {
15581561 var at = AddModifyAttribute ( seq , AttributeName , "Boolean" , value ) ;
1562+ if ( at != null && typeOnly )
1563+ {
1564+ at . AdditionalInformation . Append ( "OpcUa:TypeOnly" ) ;
1565+ }
1566+ return at ;
15591567 }
15601568
15611569
@@ -2560,14 +2568,17 @@ private void SetArrayDimensions( AttributeSequence attributes, string arrayDimen
25602568
25612569 #region ICL
25622570
2563- private void OverrideAttribute ( IClassWithBaseClassReference owner , string Name , string AttType , object val )
2571+ private void OverrideAttribute ( IClassWithBaseClassReference owner ,
2572+ string Name ,
2573+ string AttType ,
2574+ object value )
25642575 {
25652576 var atts = owner . GetInheritedAttributes ( ) ;
25662577 foreach ( var aa in atts )
25672578 {
25682579 if ( aa . Name == Name )
25692580 {
2570- if ( aa . AttributeDataType == AttType && aa . AttributeValue . Equals ( val ) )
2581+ if ( aa . AttributeDataType == AttType && aa . AttributeValue . Equals ( value ) )
25712582 {
25722583 return ; // no need to override
25732584 }
@@ -2577,7 +2588,9 @@ private void OverrideAttribute(IClassWithBaseClassReference owner, string Name,
25772588 AttributeType a = owner . Attribute . Append ( ) ;
25782589 a . Name = Name ;
25792590 a . AttributeDataType = AttType ;
2580- a . AttributeValue = val ;
2591+ a . AttributeValue = value ;
2592+
2593+ a . AdditionalInformation . Append ( "OpcUa:TypeOnly" ) ;
25812594 }
25822595
25832596 private void ProcessReferenceType ( ref InterfaceClassLibType icl , NodeId nodeId )
@@ -2621,43 +2634,54 @@ private void ProcessReferenceType(ref InterfaceClassLibType icl, NodeId nodeId)
26212634 // Only sets it if it is true -
26222635 // It doesn't matter if 'References' is set x times,
26232636 // it would take more time to look it up each time
2624- OverrideBooleanAttribute ( added . Attribute , "IsAbstract" , refnode . IsAbstract ) ;
2637+ RemoveUnwantedNodeIdAttribute (
2638+ OverrideBooleanAttribute (
2639+ added . Attribute , "IsAbstract" , refnode . IsAbstract , typeOnly : true ) ) ;
26252640
26262641 // override any attribute values
26272642 if ( BaseNodeId != null )
26282643 {
26292644 var basenode = FindNode < NodeSet . UAReferenceType > ( BaseNodeId ) ;
2630-
2631- if ( basenode . IsAbstract != refnode . IsAbstract )
2632- OverrideBooleanAttribute ( added . Attribute , "IsAbstract" , refnode . IsAbstract ) ;
2645+
26332646 if ( basenode . Symmetric != refnode . Symmetric )
2634- OverrideBooleanAttribute ( added . Attribute , "Symmetric" , refnode . Symmetric ) ;
2647+ {
2648+ RemoveUnwantedNodeIdAttribute (
2649+ OverrideBooleanAttribute (
2650+ added . Attribute , "Symmetric" , refnode . Symmetric , typeOnly : true ) ) ;
2651+ }
26352652
26362653 if ( refnode . InverseName != null )
26372654 {
26382655 AttributeType inverseNameAttribute = AddModifyAttribute ( added . Attribute ,
26392656 "InverseName" , "LocalizedText" , refnode . InverseName [ 0 ] . Value ) ;
2640-
2641- if ( inverseNameAttribute != null )
2642- {
2643- AttributeType unwantedNodeIdAttribute = inverseNameAttribute . Attribute [ "NodeId" ] ;
2644- if ( unwantedNodeIdAttribute != null )
2645- {
2646- inverseNameAttribute . Attribute . RemoveElement ( unwantedNodeIdAttribute ) ;
2647- }
2648- }
2657+ RemoveUnwantedNodeIdAttribute ( inverseNameAttribute ) ;
2658+ inverseNameAttribute . AdditionalInformation . Append ( "OpcUa:TypeOnly" ) ;
26492659 }
26502660
2651- OverrideAttribute ( added , IsSource , "xs:boolean" , true ) ;
2652- OverrideAttribute ( added , RefClassConnectsToPath , "xs:string" , ( inverseAdded != null ? inverseAdded . CAEXPath ( ) : added . CAEXPath ( ) ) ) ;
2661+ // Need typeonly here
2662+ OverrideAttribute ( added , IsSource , "xs:boolean" , value : true ) ;
2663+ OverrideAttribute ( added , RefClassConnectsToPath , "xs:string" ,
2664+ ( inverseAdded != null ? inverseAdded . CAEXPath ( ) : added . CAEXPath ( ) ) ) ;
26532665
26542666 if ( inverseAdded != null )
26552667 {
26562668 if ( basenode . IsAbstract != refnode . IsAbstract )
2657- OverrideBooleanAttribute ( inverseAdded . Attribute , "IsAbstract" , refnode . IsAbstract ) ;
2669+ {
2670+ RemoveUnwantedNodeIdAttribute (
2671+ OverrideBooleanAttribute (
2672+ inverseAdded . Attribute , "IsAbstract" , refnode . IsAbstract , typeOnly : true ) ) ;
2673+ }
26582674 if ( basenode . Symmetric != refnode . Symmetric )
2659- OverrideBooleanAttribute ( inverseAdded . Attribute , "Symmetric" , refnode . Symmetric ) ;
2660- AddModifyAttribute ( inverseAdded . Attribute , "InverseName" , "LocalizedText" , refnode . DecodedBrowseName . Name ) ;
2675+ {
2676+ RemoveUnwantedNodeIdAttribute (
2677+ OverrideBooleanAttribute (
2678+ inverseAdded . Attribute , "Symmetric" , refnode . Symmetric , typeOnly : true ) ) ;
2679+ }
2680+
2681+ AttributeType inverseNameAttribute = AddModifyAttribute (
2682+ inverseAdded . Attribute , "InverseName" , "LocalizedText" , refnode . DecodedBrowseName . Name ) ;
2683+ RemoveUnwantedNodeIdAttribute ( inverseNameAttribute ) ;
2684+ inverseNameAttribute . AdditionalInformation . Append ( "OpcUa:TypeOnly" ) ;
26612685
26622686 OverrideAttribute ( inverseAdded , IsSource , "xs:boolean" , false ) ;
26632687 OverrideAttribute ( inverseAdded , RefClassConnectsToPath , "xs:string" , added . CAEXPath ( ) ) ;
@@ -2669,6 +2693,18 @@ private void ProcessReferenceType(ref InterfaceClassLibType icl, NodeId nodeId)
26692693 MinimizeNodeId ( nodeIdAttribute ) ;
26702694 }
26712695
2696+ private void RemoveUnwantedNodeIdAttribute ( AttributeType attribute )
2697+ {
2698+ if ( attribute != null )
2699+ {
2700+ AttributeType unwantedNodeIdAttribute = attribute . Attribute [ "NodeId" ] ;
2701+ if ( unwantedNodeIdAttribute != null )
2702+ {
2703+ attribute . Attribute . RemoveElement ( unwantedNodeIdAttribute ) ;
2704+ }
2705+ }
2706+ }
2707+
26722708 #endregion
26732709
26742710
0 commit comments