Ejemplo n.º 1
0
        /// <summary>
        /// Merge node design into the instance
        /// </summary>
        /// <param name="mergedInstance"></param>
        /// <param name="source"></param>
        public static void MergeIn(this InstanceDesign mergedInstance, NodeDesign source)
        {
            if (source.DisplayName != null && !source.DisplayName.IsAutogenerated)
            {
                mergedInstance.DisplayName = source.DisplayName;
            }
            if (source.Description != null && !source.Description.IsAutogenerated)
            {
                mergedInstance.Description = source.Description;
            }

            if (source is InstanceDesign instance)
            {
                if (mergedInstance.SymbolicName != source.SymbolicName)
                {
                    mergedInstance.SymbolicName = source.SymbolicName;
                    mergedInstance.BrowseName   = source.BrowseName;
                    mergedInstance.DisplayName  = source.DisplayName;
                }
                mergedInstance.ReferenceType = instance.ReferenceType;
                if (instance.ModellingRuleSpecified)
                {
                    mergedInstance.ModellingRule          = instance.ModellingRule;
                    mergedInstance.ModellingRuleSpecified = true;
                }
                // Merge in instance design
                switch (instance)
                {
                case VariableDesign variable:
                    mergedInstance.MergeIn(variable);
                    break;

                case ObjectDesign objectd:
                    mergedInstance.MergeIn(objectd);
                    break;

                case MethodDesign method:
                    mergedInstance.MergeIn(method);
                    break;
                }
            }
            else
            {
                // Merge in type design
                switch (source)
                {
                case VariableTypeDesign variableType:
                    mergedInstance.MergeIn(variableType);
                    break;

                case ObjectTypeDesign objectType:
                    mergedInstance.MergeIn(objectType);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Merge with method design
 /// </summary>
 /// <param name="mergedInstance"></param>
 /// <param name="method"></param>
 private static void MergeIn(this InstanceDesign mergedInstance, MethodDesign method)
 {
     if (!(mergedInstance is MethodDesign mergedMethod))
     {
         throw new ArgumentException(nameof(mergedInstance));
     }
     if (method.NonExecutableSpecified)
     {
         mergedMethod.NonExecutable          = method.NonExecutable;
         mergedMethod.NonExecutableSpecified = true;
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Merge with type design
        /// </summary>
        /// <param name="mergedInstance"></param>
        /// <param name="objectType"></param>
        private static void MergeIn(this InstanceDesign mergedInstance, ObjectTypeDesign objectType)
        {
            if (!(mergedInstance is ObjectDesign mergedObject))
            {
                throw new ArgumentException(nameof(mergedInstance));
            }
            mergedObject.TypeDefinition     = objectType.SymbolicId;
            mergedObject.TypeDefinitionNode = objectType;

            if (objectType.SupportsEventsSpecified)
            {
                mergedObject.SupportsEvents          = objectType.SupportsEvents;
                mergedObject.SupportsEventsSpecified = true;
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Merge in variable design
 /// </summary>
 /// <param name="mergedInstance"></param>
 /// <param name="variable"></param>
 private static void MergeIn(this InstanceDesign mergedInstance, VariableDesign variable)
 {
     if (!(mergedInstance is VariableDesign mergedVariable))
     {
         throw new ArgumentException(nameof(mergedInstance));
     }
     if (variable.TypeDefinition != null &&
         variable.TypeDefinition != Constants.BaseDataVariableType)
     {
         mergedVariable.TypeDefinition     = variable.TypeDefinition;
         mergedVariable.TypeDefinitionNode = variable.TypeDefinitionNode;
     }
     if (variable.DecodedValue != null)
     {
         mergedVariable.DecodedValue = variable.DecodedValue;
     }
     if (variable.DataType != null &&
         variable.DataType != Constants.BaseDataType)
     {
         mergedVariable.DataType     = variable.DataType;
         mergedVariable.DataTypeNode = variable.DataTypeNode;
     }
     if (variable.ValueRankSpecified)
     {
         mergedVariable.ValueRank          = variable.ValueRank;
         mergedVariable.ValueRankSpecified = true;
     }
     if (!string.IsNullOrEmpty(variable.ArrayDimensions))
     {
         mergedVariable.ArrayDimensions = variable.ArrayDimensions;
     }
     if (variable.AccessLevelSpecified)
     {
         mergedVariable.AccessLevel          = variable.AccessLevel;
         mergedVariable.AccessLevelSpecified = true;
     }
     if (variable.MinimumSamplingIntervalSpecified)
     {
         mergedVariable.MinimumSamplingInterval          = variable.MinimumSamplingInterval;
         mergedVariable.MinimumSamplingIntervalSpecified = true;
     }
     if (variable.HistorizingSpecified)
     {
         mergedVariable.Historizing          = variable.Historizing;
         mergedVariable.HistorizingSpecified = true;
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Merge in object design
        /// </summary>
        /// <param name="mergedInstance"></param>
        /// <param name="objectDesign"></param>
        private static void MergeIn(this InstanceDesign mergedInstance, ObjectDesign objectDesign)
        {
            if (!(mergedInstance is ObjectDesign mergedObject))
            {
                throw new ArgumentException(nameof(mergedInstance));
            }
            if (objectDesign.TypeDefinition != null &&
                objectDesign.TypeDefinition != Constants.BaseObjectType)
            {
                mergedObject.TypeDefinition     = objectDesign.TypeDefinition;
                mergedObject.TypeDefinitionNode = objectDesign.TypeDefinitionNode;
            }

            if (objectDesign.SupportsEventsSpecified)
            {
                mergedObject.SupportsEvents          = objectDesign.SupportsEvents;
                mergedObject.SupportsEventsSpecified = true;
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Returns the browse path to the instance.
 /// </summary>
 public static string GetBrowsePath(this InstanceDesign instance, string basePath)
 {
     return(CreateSymbolicId(basePath, instance.SymbolicName.Name));
 }