예제 #1
0
 /// <summary>
 ///     Generates the fields from the interited interfaces, if they are missing
 /// </summary>
 public void GenerateInheritedFields()
 {
     foreach (Structure inheritedStructure in Interfaces)
     {
         foreach (StructureElement inheritedElement in inheritedStructure.Elements)
         {
             StructureElement correspondingElement = null;
             foreach (StructureElement element in Elements)
             {
                 if (element.Name.Equals(inheritedElement.Name))
                 {
                     correspondingElement = element;
                     break;
                 }
             }
             if (correspondingElement == null) // no correspondance found => create that element
             {
                 appendElements(inheritedElement.Duplicate() as StructureElement);
             }
             else // correspondace found => update that element
             {
                 correspondingElement.TypeName = inheritedElement.TypeName;
             }
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Adds a model element in this model element
        /// </summary>
        /// <param name="copy"></param>
        public override void AddModelElement(Utils.IModelElement element)
        {
            {
                StructureElement item = element as StructureElement;
                if (item != null)
                {
                    appendElements(item);
                }
            }
            {
                Procedure item = element as Procedure;
                if (item != null)
                {
                    appendProcedures(item);
                }
            }
            {
                Rules.Rule item = element as Rules.Rule;
                if (item != null)
                {
                    appendRules(item);
                }
            }

            base.AddModelElement(element);
        }
예제 #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="enclosing"></param>
        /// <param name="structureElement"></param>
        public Field(object enclosing, StructureElement structureElement)
        {
            Enclosing = enclosing;
            StructureElement = structureElement;
            Value = new DefaultValue(this);

            DeclaredElements = null;
        }
예제 #4
0
        public override StructureElement createStructureElement()
        {
            StructureElement retVal = new Types.StructureElement();

            _defaultValueSetter.SetDefaultValue(retVal);

            return(retVal);
        }
예제 #5
0
        /// <summary>
        ///     Creates a default element
        /// </summary>
        /// <param name="enclosingCollection"></param>
        /// <returns></returns>
        public static StructureElement CreateDefault(ICollection enclosingCollection)
        {
            StructureElement retVal = (StructureElement)acceptor.getFactory().createStructureElement();

            Util.DontNotify(() =>
            {
                retVal.Name = "Element" + GetElementNumber(enclosingCollection);
                retVal.Mode = acceptor.VariableModeEnumType.aInternal;
            });

            return(retVal);
        }
예제 #6
0
        /// <summary>
        ///     Determines whether a EFS structure corresponds to a packet
        /// </summary>
        /// <param name="structure"></param>
        /// <returns></returns>
        private static bool isPacket(IVariable structure)
        {
            bool retVal = false;

            foreach (ModelElement element in structure.Type.SubElements)
            {
                StructureElement subElement = element as StructureElement;
                if (subElement != null)
                {
                    if (subElement.Name == "NID_PACKET")
                    {
                        retVal = true;
                    }
                }
            }

            return(retVal);
        }
예제 #7
0
        /// <summary>
        ///     Creates a copy of the structure element in the designated dictionary. The namespace structure is copied over.
        ///     The new structure element is set to update this one.
        /// </summary>
        /// <param name="dictionary">The target dictionary of the copy</param>
        /// <returns></returns>
        public StructureElement CreateStructureElementUpdate(Dictionary dictionary)
        {
            StructureElement retVal = new StructureElement();

            retVal.Name     = Name;
            retVal.TypeName = TypeName;
            retVal.Comment  = Comment;
            retVal.setUpdates(Guid);

            String[] names = FullName.Split('.');
            names = names.Take(names.Count() - 1).ToArray();
            String[] nameSpaceRef = names.Take(names.Count() - 1).ToArray();

            NameSpace nameSpace = dictionary.GetNameSpaceUpdate(nameSpaceRef, Dictionary);
            Structure structure = nameSpace.GetStructureUpdate(names.Last(), (NameSpace)nameSpace.Updates);

            structure.appendElements(retVal);

            return(retVal);
        }
예제 #8
0
        /// <summary>
        ///     Sets the update information for this structure
        /// </summary>
        /// <param name="source">The source structure for which this structure has been created (as an update)</param>
        public override void SetUpdateInformation(ModelElement source)
        {
            base.SetUpdateInformation(source);
            Structure sourceStructure = (Structure)source;

            foreach (StructureElement element in Elements)
            {
                StructureElement baseElement = sourceStructure.FindStructureElement(element.Name);
                if (baseElement != null)
                {
                    element.SetUpdateInformation(baseElement);
                }
            }

            foreach (Procedure procedure in Procedures)
            {
                Procedure baseProcedure = sourceStructure.FindProcedure(procedure.Name);
                if (baseProcedure != null)
                {
                    procedure.SetUpdateInformation(baseProcedure);
                }
            }

            foreach (Rule rule in Rules)
            {
                Rule baseRule = sourceStructure.FindRule(rule.Name);
                if (baseRule != null)
                {
                    rule.SetUpdateInformation(baseRule);
                }
            }

            foreach (StateMachine stateMachine in StateMachines)
            {
                StateMachine baseStateMachine = sourceStructure.FindStateMachine(stateMachine.Name);
                if (baseStateMachine != null)
                {
                    stateMachine.SetUpdateInformation(baseStateMachine);
                }
            }
        }
예제 #9
0
        /// <summary>
        ///     Provides the usage description done by this statement
        /// </summary>
        /// <returns></returns>
        public virtual ModeEnum UsageDescription()
        {
            ModeEnum retVal = ModeEnum.Unknown;

            ModelElement target   = AffectedElement();
            IVariable    variable = target as IVariable;

            if (variable != null)
            {
                retVal = ConvertMode(variable.Mode);
            }

            StructureElement element = target as StructureElement;

            if (element != null)
            {
                retVal = ConvertMode(element.Mode);
            }

            return(retVal);
        }
예제 #10
0
        /// <summary>
        ///     Indicates if the given structure element is inherited from an interface or not
        /// </summary>
        /// <param name="anElement"></param>
        /// <returns></returns>
        public bool StructureElementIsInherited(StructureElement anElement)
        {
            bool retVal = false;

            foreach (Structure inheritedStructure in Interfaces)
            {
                if (inheritedStructure != null)
                {
                    foreach (StructureElement inheritedElement in inheritedStructure.Elements)
                    {
                        if (anElement.Name.Equals(inheritedElement.Name))
                        {
                            retVal = true;
                            break;
                        }
                    }
                }
            }

            return(retVal);
        }
예제 #11
0
                protected override void VisitDesignator(Designator designator)
                {
                    base.VisitDesignator(designator);

                    Utils.ModelElement current = designator.Ref as Utils.ModelElement;
                    while (current != null && !(current is NameSpace) && !(current is Parameter))
                    {
                        bool change;

                        Variable variable = current as Variable;
                        if (variable != null)
                        {
                            change           = variable.AddDependancy(DependantFunction);
                            DependancyChange = DependancyChange || change;
                        }
                        else
                        {
                            StructureElement structureElement = current as StructureElement;
                            if (structureElement != null)
                            {
                                change           = structureElement.AddDependancy(DependantFunction);
                                DependancyChange = DependancyChange || change;

                                change           = structureElement.Structure.AddDependancy(DependantFunction);
                                DependancyChange = DependancyChange || change;
                            }
                            else
                            {
                                Function function = current as Function;
                                if (function != null)
                                {
                                    change           = function.AddDependancy(DependantFunction);
                                    DependancyChange = DependancyChange || change;
                                }
                            }
                        }

                        current = current.Enclosing as Utils.ModelElement;
                    }
                }
예제 #12
0
        /// <summary>
        ///     Adds a model element in this model element
        /// </summary>
        /// <param name="element"></param>
        public override void AddModelElement(IModelElement element)
        {
            {
                StructureRef item = element as StructureRef;
                if (item != null)
                {
                    appendInterfaces(item);
                }
            }
            {
                StructureElement item = element as StructureElement;
                if (item != null)
                {
                    appendElements(item);
                }
            }
            {
                Procedure item = element as Procedure;
                if (item != null)
                {
                    appendProcedures(item);
                }
            }
            {
                StateMachine item = element as StateMachine;
                if (item != null)
                {
                    appendStateMachines(item);
                }
            }
            {
                Rule item = element as Rule;
                if (item != null)
                {
                    appendRules(item);
                }
            }

            base.AddModelElement(element);
        }
예제 #13
0
        public override StructureElement createStructureElement()
        {
            StructureElement retVal = new Types.StructureElement();

            _defaultValueSetter.SetDefaultValue(retVal);

            return retVal;
        }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="panel"></param>
 /// <param name="model"></param>
 public StructureElementModelControl(ModelDiagramPanel panel, StructureElement model)
     : base(panel, model)
 {
 }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="source"></param>
 /// <param name="target"></param>
 /// <param name="model"></param>
 public ElementReferenceArrow(Structure source, Type target, StructureElement model)
     : base(source, target, model.Name, model)
 {
 }