Inheritance: Generated.Structure, ISubDeclarator, IFinder
コード例 #1
0
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="structure">The structure that we are trying to find the unified structure for</param>
        public UnifiedStructure(Structure structure)
        {
            Name = structure.Name;
            UnifiedStructure = this;

            Rebuild(structure);
        }
コード例 #2
0
        private static string format_euroloop_message(DBMessage message)
        {
            EfsSystem system = EfsSystem.Instance;

            NameSpace      nameSpace     = findNameSpace("Messages.EUROLOOP");
            Structure      structureType = (Structure)system.FindType(nameSpace, "Message");
            StructureValue structure     = new StructureValue(structureType);

            int currentIndex = 0;

            FillStructure(nameSpace, message.Fields, ref currentIndex, structure);


            // then we fill the packets
            IVariable subSequenceVariable;

            if (structure.SubVariables.TryGetValue("Sequence1", out subSequenceVariable))
            {
                subSequenceVariable.Value = get_message_packets(message, nameSpace, system);
            }
            else
            {
                throw new Exception("Cannot find SubSequence in variable");
            }

            return(structure.Name);
        }
コード例 #3
0
        /// <summary>
        ///     Adds all the structures that are updated (directly or indirectly) to the list of merged structures,
        ///     then adds all structures updating it, as long as there is only one update per structure
        /// </summary>
        /// <param name="structure"></param>
        public void Rebuild(Structure structure)
        {
            MergedStructures = new List<Structure>();

            // Find the base structure
            Structure current = structure;
            Structure next = current.Updates as Structure;
            while (next != null)
            {
                current = next;
                next = current.Updates as Structure;
            }

            // current is now the structure at the start of the update chain
            while (current != null)
            {
                MergedStructures.Add(current);
                if (current.UpdatedBy.Count == 1)
                {
                    current = current.UpdatedBy[0] as Structure;
                }
                else
                {
                    current = null;
                }
            }

            ApplyUpdates();
        }
コード例 #4
0
        public override void visit(Generated.Variable obj, bool visitSubNodes)
        {
            DataDictionary.Variables.Variable variable = obj as Variables.Variable;

            if (variable != null)
            {
                if (variable.Type == null)
                {
                    variable.AddError("Cannot find type for variable");
                }
                else
                {
                    Types.Structure structure = variable.Type as Types.Structure;
                    if (structure != null)
                    {
                        foreach (Types.StructureElement element in structure.Elements)
                        {
                            if (!ValidMode(variable.Mode, element.Mode))
                            {
                                variable.AddWarning("Invalid mode for " + element.Name);
                            }
                        }
                    }
                }
                if (Utils.Utils.isEmpty(variable.Comment) && variable.Type != null && Utils.Utils.isEmpty(variable.Type.Comment))
                {
                    variable.AddInfo("Missing variable semantics. Update the 'Comment' associated to the variable or to the corresponding type");
                }
            }

            base.visit(obj, visitSubNodes);
        }
コード例 #5
0
        public override Structure createStructure()
        {
            Structure retVal = new Types.Structure();

            _defaultValueSetter.SetDefaultValue(retVal);

            return(retVal);
        }
コード例 #6
0
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="structure">The structure that we are trying to find the unified structure for</param>
        public UnifiedStructure(Structure structure)
        {
            Name = structure.Name;

            KeepAllUpdates(structure);

            Enclosing = MergedStructures[0].Enclosing;

            ApplyUpdates();
        }
コード例 #7
0
            /// <summary>
            ///     Creates the unified structure
            /// </summary>
            /// <param name="obj"></param>
            /// <param name="visitSubNodes"></param>
            public override void visit(Generated.Structure obj, bool visitSubNodes)
            {
                Structure structure = obj as Structure;

                if (structure != null)
                {
                    structure.ComputeUnifiedStructure();
                }

                base.visit(obj, visitSubNodes);
            }
コード例 #8
0
        /// <summary>
        ///     Constructor for merging
        /// </summary>
        /// <param name="baseStateMachine"></param>
        /// <param name="updateStateMachine"></param>
        public UnifiedStructure(Structure baseStateMachine, Structure updateStateMachine)
        {
            Name = updateStateMachine.Name;

            MergedStructures = new List<Structure>();
            MergedStructures.Add(baseStateMachine);
            MergedStructures.Add(updateStateMachine);

            Enclosing = MergedStructures[0].Enclosing;
            setUpdates(MergedStructures[0].Guid);

            ApplyUpdates();
        }
コード例 #9
0
        /// <summary>
        ///     Refactors a single element
        /// </summary>
        /// <param name="element"></param>
        /// <param name="originalName">The original element's name</param>
        /// <param name="newName">The new element's name</param>
        private void RefactorElement(ModelElement element, string originalName, string newName)
        {
            if (element != null)
            {
                NameSpace nameSpace = element as NameSpace;
                if (nameSpace != null)
                {
                    NameSpaceRefactorer refactorer = new NameSpaceRefactorer(nameSpace);
                    foreach (Dictionary dictionary in EfsSystem.Instance.Dictionaries)
                    {
                        refactorer.visit(dictionary);
                    }
                }
                else
                {
                    // the system keeps track where the element is used
                    List <Usage>      usageList = EfsSystem.Instance.FindReferences(element);
                    SortedSet <Usage> usages    = new SortedSet <Usage>(usageList, new CompareUsages());
                    foreach (Usage usage in usages)
                    {
                        RefactorIExpressionable(element, usage.User as IExpressionable);
                        RefactorTypedElement(element, usage.User as ITypedElement);
                    }

                    if (element is StructureElement)
                    {
                        Structure structure = element.Enclosing as Structure;
                        if (structure != null && structure.IsAbstract)
                        {
                            usages = new SortedSet <Usage>(EfsSystem.Instance.FindReferences(structure));
                            foreach (Usage usage in usages)
                            {
                                if (usage.Mode == Usage.ModeEnum.Interface)
                                {
                                    Structure redefiningStructure = usage.User as Structure;
                                    if (redefiningStructure != null)
                                    {
                                        ModelElement el = redefiningStructure.FindStructureElement(originalName);
                                        if (el != null)
                                        {
                                            el.Name = newName;
                                            RefactorElement(el, originalName, newName);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #10
0
        public override void visit(BaseModelElement obj, bool visitSubNodes)
        {
            IExpressionable expressionable = obj as IExpressionable;

            if (expressionable != null)
            {
                // In case of rebuild, cleans the previously constructed tree
                if (Options.Rebuild)
                {
                    expressionable.CleanCompilation();
                }
                // Ensures that the expressionable is compiled
                expressionable.Compile();

                Structure structure = expressionable as Structure;
                if (structure != null)
                {
                    if (structure != structure.UnifiedStructure)
                    {
                        visit(structure.UnifiedStructure, visitSubNodes);
                    }
                }

                StateMachine stateMachine = expressionable as StateMachine;
                if (stateMachine != null)
                {
                    if (stateMachine != stateMachine.UnifiedStateMachine)
                    {
                        visit(stateMachine.UnifiedStateMachine, visitSubNodes);
                    }
                }
            }

            ITypedElement typedElement = obj as ITypedElement;

            if (typedElement != null)
            {
                // Ensures that the type of the corresponding element is cached
                Type type = typedElement.Type;
            }

            Function function = obj as Function;

            if (function != null)
            {
                Type returnType = function.ReturnType;
            }

            base.visit(obj, visitSubNodes);
        }
コード例 #11
0
ファイル: AddToDate.cs プロジェクト: fakoor/ERTMSFormalSpecs
        /// <summary>
        ///     Creates a EFS DateAndTimeStruct structure from a System.DateTime
        /// </summary>
        /// <param name="value">The values that will go into the structure</param>
        /// <param name="structureType">The structure type</param>
        /// <returns></returns>
        private IValue GetEfsDate(DateTime value, Structure structureType)
        {
            StructureValue retVal = new StructureValue(structureType);

            retVal.SubVariables["Year"].Value   = ToEfsInt(value.Year);
            retVal.SubVariables["Month"].Value  = ToEfsInt(value.Month);
            retVal.SubVariables["Day"].Value    = ToEfsInt(value.Day);
            retVal.SubVariables["Hour"].Value   = ToEfsInt(value.Hour);
            retVal.SubVariables["Minute"].Value = ToEfsInt(value.Minute);
            retVal.SubVariables["Second"].Value = ToEfsInt(value.Second);
            retVal.SubVariables["TTS"].Value    = ToEfsInt(value.Millisecond);

            return(retVal);
        }
コード例 #12
0
        /// <summary>
        ///     Finds the type of the structure corresponding to the provided NID_PACKET
        /// </summary>
        /// <param name="nameSpace">The namespace where the type has to be found</param>
        /// <param name="nidPacket">The id of the packet</param>
        /// <returns></returns>
        private static StructureValue FindStructure(int nidPacket)
        {
            EfsSystem system    = EfsSystem.Instance;
            Structure structure = null;
            NameSpace nameSpace = findNameSpace("Messages.PACKET.TRACK_TO_TRAIN");

            foreach (NameSpace packetNameSpace in nameSpace.NameSpaces)
            {
                Structure structureType =
                    (Structure)system.FindType(packetNameSpace, packetNameSpace.FullName + ".Message");
                StructureValue structureValue = new StructureValue(structureType);

                foreach (KeyValuePair <string, IVariable> pair in structureValue.SubVariables)
                {
                    string variableName = pair.Key;
                    if (variableName.Equals("NID_PACKET"))
                    {
                        IntValue value = pair.Value.Value as IntValue;
                        if (value.Val == nidPacket)
                        {
                            structure = structureType;
                        }
                    }
                    if (structure != null)
                    {
                        break;
                    }
                }
                if (structure != null)
                {
                    break;
                }
            }

            StructureValue retVal = null;

            if (structure != null)
            {
                retVal = new StructureValue(structure);
            }

            return(retVal);
        }
コード例 #13
0
        public string format_default_message(string expression)
        {
            string retVal = "<not a structure type>";

            int index = expression.IndexOf("<-");

            if (index > 0)
            {
                string     variableText   = expression.Substring(0, index).Trim();
                Expression expressionTree = new Parser().Expression(Dictionary, variableText);
                if (expressionTree != null)
                {
                    Structure structureType = expressionTree.GetExpressionType() as Structure;
                    retVal = structureType.DefaultValue.LiteralName;
                }
            }

            return(retVal);
        }
コード例 #14
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="aStructure"></param>
        public CustomAction(Structure aStructure)
        {
            InitializeComponent();

            myStructure = aStructure;
            CbB_StateName.DataSource = System.Enum.GetValues(typeof(StateNames));

            /* Creation of the list of check boxes */
            if (myStructure != null)
            {
                int X = 17;
                int Y = 17;
                foreach (StructureElement element in aStructure.Elements)
                {
                    if (element.Type is Structure)
                    {
                        Structure structure = DataDictionary.OverallStructureFinder.INSTANCE.findByName(myStructure.Dictionary, element.Type.FullName);
                        if (structure != null)
                        {
                            foreach (DataDictionary.Functions.Procedure procedure in structure.Procedures)
                            {
                                System.Windows.Forms.CheckBox aCheckBox = new System.Windows.Forms.CheckBox();
                                aCheckBox.AutoSize = true;
                                aCheckBox.Location = new System.Drawing.Point(X, Y);
                                aCheckBox.Name = "Cb_StateType";
                                aCheckBox.Size = new System.Drawing.Size(74, 17);
                                aCheckBox.Text = element.Name + "." + procedure.Name;
                                aCheckBox.UseVisualStyleBackColor = true;
                                this.GrB_Procedures.Controls.Add(aCheckBox);
                                Y += 20;
                                if (Y > GrB_Procedures.Height - 22)
                                {
                                    X += 407;
                                    Y = 17;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #15
0
        /// <summary>
        /// Handles the changes for this variable
        /// </summary>
        /// <param name="cacheImpact"></param>
        public override void HandleChange(CacheImpact cacheImpact)
        {
            base.HandleChange(cacheImpact);

            Structure structure = Type as Structure;

            if (structure != null)
            {
                structure.HandleChange(cacheImpact);
            }

            StructureValue enclosingStructureValue = Enclosing as StructureValue;

            if (enclosingStructureValue != null)
            {
                IVariable enclosingVariable = enclosingStructureValue.Enclosing as IVariable;
                if (enclosingVariable != null)
                {
                    enclosingVariable.HandleChange(cacheImpact);
                }
            }
        }
コード例 #16
0
        public override void visit(Generated.Structure obj, bool visitSubNodes)
        {
            DataDictionary.Types.Structure structure = obj as Types.Structure;

            if (structure != null)
            {
                foreach (Types.StructureElement element in structure.Elements)
                {
                    Types.Structure elementType = element.Type as Types.Structure;
                    if (elementType != null)
                    {
                        foreach (Types.StructureElement subElement in elementType.Elements)
                        {
                            if (!ValidMode(element.Mode, subElement.Mode))
                            {
                                element.AddWarning("Invalid mode for " + subElement.Name);
                            }
                        }
                    }
                }
            }

            base.visit(obj, visitSubNodes);
        }
コード例 #17
0
 /// <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)
 {
 }
コード例 #18
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="source"></param>
 /// <param name="target"></param>
 /// <param name="model"></param>
 public InheritanceArrow(Structure source, Structure target, Structure model)
     : base(source, target, "implements", model)
 {
 }
コード例 #19
0
        public override Structure createStructure()
        {
            Structure retVal = new Types.Structure();

            _defaultValueSetter.SetDefaultValue(retVal);

            return retVal;
        }
コード例 #20
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="panel"></param>
 /// <param name="model"></param>
 public StructureModelControl(ModelDiagramPanel panel, Structure model)
     : base(panel, model)
 {
 }
コード例 #21
0
        protected void CreateDefaultStructureValue(TextualExplanation text, Structure structure,
            bool displayStructureName = true)
        {
            if (displayStructureName)
            {
                text.WriteLine(StripUseless(structure.FullName, WritingContext()) + "{");
            }

            bool first = true;
            foreach (StructureElement element in structure.Elements)
            {
                if (!first)
                {
                    text.WriteLine(",");
                }
                InsertElement(element, text);
                first = false;
            }
            text.WriteLine();
            text.Write("}");
        }
コード例 #22
0
        /// <summary>
        ///     Applies the effect of an update
        /// </summary>
        /// <param name="updateStructure">The updating structure</param>
        private void CombineWithUpdate(Structure updateStructure)
        {
            foreach (StructureElement element in updateStructure.Elements)
            {
                ApplyElementUpdate(element, Elements);
            }

            foreach (Procedure procedure in updateStructure.Procedures)
            {
                ApplyElementUpdate(procedure, Procedures);
            }

            foreach (StateMachine stateMachine in updateStructure.StateMachines)
            {
                ApplyElementUpdate(stateMachine, StateMachines);
            }

            foreach (Rule rule in updateStructure.Rules)
            {
                ApplyElementUpdate(rule, Rules);
            }
        }
コード例 #23
0
        private static IValue FillDefaultPacket(DBMessage message, IVariable structure)
        {
            IValue retVal = structure.Value;

            if (isPacket(structure))
            {
                Structure      defaultPacketType = (Structure)structure.Type;
                StructureValue defaultPacket     = new StructureValue(defaultPacketType);

                NameSpace packetNameSpace = structure.NameSpace;

                foreach (DBPacket packet in message.Packets)
                {
                    DBField nidPacketField = packet.Fields[0] as DBField;
                    int     packetID       = int.Parse(nidPacketField.Value);

                    Structure packetType = (Structure)FindStructure(packetID).Type;

                    if (packetType == defaultPacketType)
                    {
                        int defaultPacketIndex = 0;
                        FillStructure(packetNameSpace, packet.Fields, ref defaultPacketIndex, defaultPacket);

                        retVal = defaultPacket;
                    }
                }
            }
            else
            {
                Structure      structureType = structure.Type as Structure;
                StructureValue Structure     = new StructureValue(structureType);
                if (Structure != null)
                {
                    foreach (KeyValuePair <string, IVariable> subVariable in Structure.SubVariables)
                    {
                        if (isPacket(subVariable.Value))
                        {
                            Structure      defaultPacketType = (Structure)subVariable.Value.Type;
                            StructureValue defaultPacket     = new StructureValue(defaultPacketType);

                            NameSpace packetNameSpace = subVariable.Value.NameSpace;

                            foreach (DBPacket packet in message.Packets)
                            {
                                DBField nidPacketField = packet.Fields[0] as DBField;
                                int     packetID       = int.Parse(nidPacketField.Value);

                                Structure packetType = (Structure)FindStructure(packetID).Type;

                                if (packetType == defaultPacketType)
                                {
                                    int defaultPacketIndex = 0;
                                    FillStructure(packetNameSpace, packet.Fields, ref defaultPacketIndex, defaultPacket);

                                    Structure.GetVariable(subVariable.Value.Name).Value = defaultPacket;
                                }
                            }
                        }
                    }
                    retVal = Structure;
                }
            }

            return(retVal);
        }
コード例 #24
0
        private static string format_euroradio_message(DBMessage message)
        {
            EfsSystem system = EfsSystem.Instance;

            NameSpace rbcRoot = findNameSpace("Messages.MESSAGE");

            // Get the EFS namespace corresponding to the message
            // Select the appropriate message type, tracktotrain or traintotrack
            DBField nidMessage = message.Fields[0] as DBField;
            string  msg_id     = get_namespace_from_ID(nidMessage.Value);

            NameSpace nameSpace = OverallNameSpaceFinder.INSTANCE.findByName(rbcRoot, msg_id);

            if (nameSpace == null)
            {
                throw new Exception("Message type not found in EFS");
            }

            // The EURORADIO messages are defined in the namespaces TRACK_TO_TRAIN and TRAIN_TO_TRACK, which enclose the specific message namespaces
            // So we get the message type from nameSpace.EnclosingNameSpace and the actual structure corresponding to the message in nameSpace
            Structure      enclosingStructureType = (Structure)system.FindType(nameSpace.EnclosingNameSpace, "Message");
            StructureValue Message = new StructureValue(enclosingStructureType);


            // Within the message, get the appropriate field and get that structure
            Structure      structureType = (Structure)system.FindType(nameSpace, "Message");
            StructureValue structure     = new StructureValue(structureType);


            // Fill the structure
            int currentIndex = 0;

            FillStructure(nameSpace, message.Fields, ref currentIndex, structure);

            // Fill the default packets
            int translatedPackets = 0;

            foreach (KeyValuePair <string, IVariable> subVariable in structure.SubVariables)
            {
                if (subVariable.Value.TypeName.EndsWith("Message"))
                {
                    // The structure of packets will always be a Message, but in some cases, it is a message that contains
                    // the different options for a single field in the message
                    structure.GetVariable(subVariable.Value.Name).Value = FillDefaultPacket(message, subVariable.Value);

                    translatedPackets++;
                }
            }

            // and fill the packets
            IVariable subSequenceVariable;

            if (structure.SubVariables.TryGetValue("Sequence1", out subSequenceVariable) &&
                message.Packets.Count > translatedPackets)
            {
                subSequenceVariable.Value = get_message_packets(message, nameSpace, system);
            }


            // Fill the correct field in Message with the structure.
            foreach (KeyValuePair <string, IVariable> pair in Message.SubVariables)
            {
                if (msg_id.EndsWith(pair.Key))
                {
                    pair.Value.Type  = structureType;
                    pair.Value.Value = structure;
                }
            }

            return(Message.Name);
        }
コード例 #25
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="item"></param>
 /// <param name="buildSubNodes"></param>
 public StructureElementsTreeNode(Structure item, bool buildSubNodes)
     : base(item, buildSubNodes, "Sub elements", true, false)
 {
 }
コード例 #26
0
        /// <summary>
        ///     Fills the given structure with the values provided from the database
        /// </summary>
        /// <param name="aNameSpace">Namespace of the structure</param>
        /// <param name="fields">Fields to be copied into the structure</param>
        /// <param name="index">Index (of fields list) from which we have to start copying</param>
        /// <param name="aStructure">The structure to be filled</param>
        private static void FillStructure(NameSpace aNameSpace, ArrayList fields, ref int currentIndex,
                                          StructureValue aStructure)
        {
            EfsSystem system = EfsSystem.Instance;

            int j = 0;

            while (currentIndex < fields.Count)
            {
                DBField field = fields[currentIndex] as DBField;

                KeyValuePair <string, IVariable> pair = aStructure.SubVariables.ElementAt(j);
                IVariable variable = pair.Value;

                // conditional variables can be missing in the database fields, but present in our structure => skip them
                while (!variable.Name.StartsWith(field.Variable) && j < aStructure.SubVariables.Count - 1)
                {
                    j++;
                    pair     = aStructure.SubVariables.ElementAt(j);
                    variable = pair.Value;
                }

                // We use StartsWith and not Equals because we can have N_ITER_1 and N_ITER
                if (variable.Name.StartsWith(field.Variable))
                {
                    if (variable.Type is Enum)
                    {
                        Enum type = variable.Type as Enum;
                        foreach (EnumValue enumValue in type.Values)
                        {
                            int value = int.Parse(enumValue.getValue());
                            int other = int.Parse(field.Value);
                            if (value == other)
                            {
                                variable.Value = enumValue;
                                j++;
                                break;
                            }
                        }
                    }
                    else if (variable.Type is Range)
                    {
                        Range  type = variable.Type as Range;
                        object v    = VariableConverter.INSTANCE.Convert(variable.Name, field.Value);

                        string stringValue = v as string;
                        if (stringValue != null)
                        {
                            int intValue;
                            if (int.TryParse(stringValue, out intValue))
                            {
                                v = intValue;
                            }
                        }
                        variable.Value = new IntValue(type, (int)v);
                        j++;
                    }
                    else if (variable.Type is StringType)
                    {
                        StringType type = variable.Type as StringType;
                        variable.Value = new StringValue(type, field.Value);
                        j++;
                    }
                    else
                    {
                        throw new Exception("Unhandled variable type");
                    }

                    if (variable.Name.StartsWith("N_ITER")) // we have to create a sequence
                    {
                        KeyValuePair <string, IVariable> sequencePair = aStructure.SubVariables.ElementAt(j);
                        IVariable  sequenceVariable = sequencePair.Value;
                        Collection collectionType   = (Collection)system.FindType(aNameSpace, sequenceVariable.TypeName);
                        ListValue  sequence         = new ListValue(collectionType, new List <IValue>());

                        int value = int.Parse(field.Value);
                        for (int k = 0; k < value; k++)
                        {
                            currentIndex++;
                            Structure structureType =
                                (Structure)system.FindType(aNameSpace, sequence.CollectionType.Type.FullName);
                            StructureValue structureValue = new StructureValue(structureType);
                            FillStructure(aNameSpace, fields, ref currentIndex, structureValue);
                            sequence.Val.Add(structureValue);
                        }
                        sequenceVariable.Value = sequence;
                        j++;
                    }
                }

                // Special case for X_TEXT
                if ("Sequence1".Equals(variable.Name) && "X_TEXT".Equals(field.Variable))
                {
                    KeyValuePair <string, IVariable> sequencePair = aStructure.SubVariables.ElementAt(j);
                    IVariable  sequenceVariable = sequencePair.Value;
                    Collection collectionType   = (Collection)system.FindType(aNameSpace, sequenceVariable.TypeName);
                    ListValue  sequence         = new ListValue(collectionType, new List <IValue>());
                    while (field != null && "X_TEXT".Equals(field.Variable))
                    {
                        if (string.IsNullOrEmpty(field.Value))
                        {
                            field.Value = " ";
                        }
                        Structure structureType =
                            (Structure)system.FindType(aNameSpace, sequence.CollectionType.Type.FullName);
                        StructureValue structureValue = new StructureValue(structureType);
                        FillStructure(aNameSpace, fields, ref currentIndex, structureValue);
                        sequence.Val.Add(structureValue);
                        currentIndex += 1;
                        if (currentIndex < fields.Count)
                        {
                            field = fields[currentIndex] as DBField;
                        }
                        else
                        {
                            field = null;
                        }
                    }
                    sequenceVariable.Value = sequence;
                    j++;
                }

                // if all the fields of the structue are filled, we terminated
                if (j == aStructure.SubVariables.Count)
                {
                    break;
                }
                else
                {
                    currentIndex += 1;
                }
            }
        }
コード例 #27
0
 /// <summary>
 ///     Handles a change of the model element by invalidating the cache of all element in CacheDependancy
 /// </summary>
 /// <param name="cacheImpact"></param>
 public override void HandleChange(CacheImpact cacheImpact)
 {
     base.HandleChange(cacheImpact);
     Structure.HandleChange(cacheImpact);
 }
コード例 #28
0
        private static ListValue get_message_packets(DBMessage message, NameSpace nameSpace, EfsSystem system)
        {
            ListValue retVal;

            Collection collectionType    = (Collection)system.FindType(nameSpace, "Collection1");
            Structure  subStructure1Type = (Structure)system.FindType(nameSpace, "SubStructure1");

            string packetLocation = "Messages.PACKET.";

            if (nameSpace.FullName.Contains("TRAIN_TO_TRACK"))
            {
                packetLocation += "TRAIN_TO_TRACK.Message";
            }
            else
            {
                packetLocation += "TRACK_TO_TRAIN.Message";
            }

            Structure packetStructureType = (Structure)system.FindType(nameSpace, packetLocation);

            retVal = new ListValue(collectionType, new List <IValue>());

            foreach (DBPacket packet in message.Packets)
            {
                DBField nidPacketField = packet.Fields[0] as DBField;
                if (nidPacketField.Value != "255") // 255 means "end of information"
                {
                    int            packetId     = int.Parse(nidPacketField.Value);
                    StructureValue subStructure = FindStructure(packetId);

                    int currentIndex = 0;
                    FillStructure(nameSpace, packet.Fields, ref currentIndex, subStructure);

                    StructureValue subStructure1 = new StructureValue(subStructure1Type);

                    // For Balise messages, we have an extra level of information to fill, so here we define StructureVal in one of two ways
                    StructureValue structureVal;
                    if (subStructure1.SubVariables.Count == 1 &&
                        subStructure1.SubVariables.ContainsKey("TRACK_TO_TRAIN"))
                    {
                        // For a Balise message, we have an extra level of structures for TRACK_TO_TRAIN
                        structureVal = new StructureValue(packetStructureType);

                        subStructure1.SubVariables["TRACK_TO_TRAIN"].Value = structureVal;
                    }
                    else
                    {
                        // For RBC, the collection directly holds the different packet types
                        structureVal = subStructure1;
                    }

                    // Find the right variable in the packet to add the structure we just created
                    foreach (KeyValuePair <string, IVariable> pair in structureVal.SubVariables)
                    {
                        string variableName = pair.Key;
                        if (subStructure.Structure.FullName.Contains(variableName))
                        {
                            pair.Value.Value = subStructure;

                            retVal.Val.Add(subStructure1);

                            break;
                        }
                    }
                }
            }

            return(retVal);
        }
コード例 #29
0
        /// <summary>
        ///     Creates a EFS DateAndTime structure from a System.DateTime
        /// </summary>
        /// <param name="value">The values that will go into the structure</param>
        /// <param name="structureType">The structure type</param>
        /// <returns></returns>
        private IValue GetEFSDate(DateTime value, Structure structureType)
        {
            IValue retVal = null;

            StructureValue structure = new StructureValue(structureType);

            structure.SubVariables["Year"].Value = ToEFSInt(value.Year);
            structure.SubVariables["Month"].Value = ToEFSInt(value.Month);
            structure.SubVariables["Day"].Value = ToEFSInt(value.Day);
            structure.SubVariables["Hour"].Value = ToEFSInt(value.Hour);
            structure.SubVariables["Minute"].Value = ToEFSInt(value.Minute);
            structure.SubVariables["Second"].Value = ToEFSInt(value.Second);
            structure.SubVariables["TTS"].Value = ToEFSInt(value.Millisecond);

            retVal = structure;

            return retVal;
        }
コード例 #30
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="panel"></param>
 /// <param name="model"></param>
 public InterfaceModelControl(ModelDiagramPanel panel, Structure model)
     : base(panel, model)
 {
     NormalColor = Color.LightGoldenrodYellow;
 }