示例#1
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);
        }
示例#2
0
        /// <summary>
        ///     Updates an expression according to translation rules
        /// </summary>
        /// <param name="step">the step in which the expression occurs</param>
        /// <param name="expression"></param>
        /// <returns>the updated string</returns>
        private string ReviewExpression(Step step, string expression)
        {
            string retVal = expression;

            if (expression.IndexOf('%') >= 0)
            {
                SubSequence subSequence = step.TestCase.SubSequence;

                retVal = retVal.Replace("%D_LRBG", format_decimal_as_str(subSequence.getD_LRBG()));
                retVal = retVal.Replace("%Level", format_level(subSequence.getLevel()));
                retVal = retVal.Replace("%Mode", format_mode(subSequence.getMode()));
                retVal = retVal.Replace("%NID_LRBG", format_decimal_as_str(subSequence.getNID_LRBG()));
                retVal = retVal.Replace("%Q_DIRLRBG", format_decimal_as_str(subSequence.getQ_DIRLRBG()));
                retVal = retVal.Replace("%Q_DIRTRAIN", format_decimal_as_str(subSequence.getQ_DIRTRAIN()));
                retVal = retVal.Replace("%Q_DLRBG", format_decimal_as_str(subSequence.getQ_DLRBG()));
                retVal = retVal.Replace("%RBC_ID", format_decimal_as_str(subSequence.getRBC_ID()));
                retVal = retVal.Replace("%RBCPhone", format_str(subSequence.getRBCPhone()));

                retVal = retVal.Replace("%Step_Distance", step.getDistance() + "");
                retVal = retVal.Replace("%Step_LevelIN", format_level(step.getLevelIN()));
                retVal = retVal.Replace("%Step_LevelOUT", format_level(step.getLevelOUT()));
                retVal = retVal.Replace("%Step_ModeIN", format_mode(step.getModeOUT()));
                retVal = retVal.Replace("%Step_ModeOUT", format_mode(step.getModeOUT()));

                int max_step_messages = 8;
                for (int i = 0; i < max_step_messages; i++)
                {
                    if (retVal.IndexOf("%Step_Messages_" + i) >= 0)
                    {
                        if (step.StepMessages.Count > i)
                        {
                            DBMessage message = step.StepMessages[i] as DBMessage;
                            if (message != null)
                            {
                                retVal = retVal.Replace("%Step_Messages_" + i, format_message(message));
                            }
                        }
                        else
                        {
                            retVal = retVal.Replace("%Step_Messages_" + i, format_default_message(expression));
                        }
                    }
                }

                if (retVal.IndexOf("%") > 0)
                {
                    step.AddError("Cannot completely translate this step");
                }
            }

            return(retVal);
        }
示例#3
0
        /// <summary>
        /// Impports all the packets for a given message
        /// </summary>
        /// <param name="aMessage"></param>
        private void importPackets(DataDictionary.Tests.DBElements.DBMessage aMessage, int TCS_order)
        {
            string sql = "SELECT TCSOrder, MessageOrder, Pac_ID, Var_Name, Var_Value FROM TSW_MessageBody ORDER BY MessageOrder, Var_Row";

            OleDbDataAdapter adapter = new OleDbDataAdapter(sql, Connection);
            DataSet          dataSet = new DataSet();

            adapter.Fill(dataSet);

            int packetNumber = 0;

            DataDictionary.Tests.DBElements.DBPacket packet = (DataDictionary.Tests.DBElements.DBPacket)DataDictionary.Generated.acceptor.getFactory().createDBPacket();
            if (dataSet.Tables.Count > 0)
            {
                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    object[] items        = dataRow.ItemArray;
                    int      order        = (int)items[0];
                    short    messageOrder = (short)items[1];
                    if (order == TCS_order && messageOrder == aMessage.MessageOrder)
                    {
                        short pacId = (short)items[2];
                        if (packetNumber != pacId)
                        {
                            if (packetNumber != 0)
                            {
                                aMessage.AddPacket(packet);
                            }
                            packet       = (DataDictionary.Tests.DBElements.DBPacket)DataDictionary.Generated.acceptor.getFactory().createDBPacket();
                            packetNumber = pacId;
                        }
                        DataDictionary.Tests.DBElements.DBField field = (DataDictionary.Tests.DBElements.DBField)DataDictionary.Generated.acceptor.getFactory().createDBField();
                        string variable = items[3] as string;
                        if (variable != null)
                        {
                            field.Variable = variable;
                        }
                        string value = items[4] as string;
                        if (value != null)
                        {
                            field.Value = DataDictionary.Tests.Translations.Translation.format_decimal(value);
                        }
                        packet.AddField(field);
                    }
                }
                if (packet != null)
                {
                    aMessage.AddPacket(packet);
                }
            }
        }
示例#4
0
        /// <summary>
        ///     Impports all the packets for a given message
        /// </summary>
        /// <param name="aMessage"></param>
        /// <param name="TCS_order"></param>
        // ReSharper disable once InconsistentNaming
        private void ImportPackets(DBMessage aMessage, int TCS_order)
        {
            string sql = "SELECT Pac_ID, Var_Name, Var_Value FROM TSW_MessageBody WHERE (TCSOrder = " + TCS_order +
                         ") AND (MessageOrder = " + aMessage.MessageOrder + ") ORDER BY Var_Row";

            OleDbDataAdapter adapter = new OleDbDataAdapter(sql, Connection);
            DataSet          dataSet = new DataSet();

            adapter.Fill(dataSet);

            DBPacket packet = null;

            if (dataSet.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    object[] items = dataRow.ItemArray;
                    if ("NID_PACKET".Equals(items[1]))
                    {
                        if (packet != null)
                        {
                            aMessage.AddPacket(packet);
                        }
                        packet = (DBPacket)acceptor.getFactory().createDBPacket();
                    }

                    if (packet != null)
                    {
                        DBField field    = (DBField)acceptor.getFactory().createDBField();
                        string  variable = items[1] as string;
                        if (variable != null)
                        {
                            field.Variable = variable;
                        }
                        string value = items[2] as string;
                        if (value != null)
                        {
                            field.Value = VariableConverter.INSTANCE.Convert(variable, value).ToString();
                        }
                        packet.AddField(field);
                    }
                }

                if (packet != null)
                {
                    aMessage.AddPacket(packet);
                }
            }
        }
示例#5
0
        /// <summary>
        ///     Takes the message provided and returns the corresponding message value
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string format_message(DBMessage message)
        {
            string retVal = "";

            switch (message.MessageType)
            {
            case acceptor.DBMessageType.aEUROBALISE:
                retVal = format_eurobalise_message(message);
                break;

            case acceptor.DBMessageType.aEUROLOOP:
                retVal = format_euroloop_message(message);
                break;

            case acceptor.DBMessageType.aEURORADIO:
                retVal = format_euroradio_message(message);
                break;
            }
            return(retVal);
        }
        /// <summary>
        ///     Impports all the packets for a given message
        /// </summary>
        /// <param name="aMessage"></param>
        private void importPackets(DBMessage aMessage, int TCS_order)
        {
            string sql = "SELECT Pac_ID, Var_Name, Var_Value FROM TSW_MessageBody WHERE (TCSOrder = " + TCS_order +
                         ") AND (MessageOrder = " + aMessage.MessageOrder + ") ORDER BY Var_Row";

            OleDbDataAdapter adapter = new OleDbDataAdapter(sql, Connection);
            DataSet dataSet = new DataSet();

            adapter.Fill(dataSet);

            int packetNumber = 0;
            DBPacket packet = (DBPacket) acceptor.getFactory().createDBPacket();
            if (dataSet.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    object[] items = dataRow.ItemArray;
                    short pacId = (short) items[0];
                    if (packetNumber != pacId)
                    {
                        if (packetNumber != 0)
                        {
                            aMessage.AddPacket(packet);
                        }
                        packet = (DBPacket) acceptor.getFactory().createDBPacket();
                        packetNumber = pacId;
                    }
                    DBField field = (DBField) acceptor.getFactory().createDBField();
                    string variable = items[1] as string;
                    if (variable != null)
                    {
                        field.Variable = variable;
                    }
                    string value = items[2] as string;
                    if (value != null)
                    {
                        field.Value = VariableConverter.INSTANCE.Convert(variable, value).ToString();
                    }
                    packet.AddField(field);
                }
                if (packet != null)
                {
                    aMessage.AddPacket(packet);
                }
            }
        }
        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;
                        string[] ids = subStructure.Structure.FullName.Split('.');
                        if (ids[ids.Length-2].Equals(variableName))
                        {
                            pair.Value.Value = subStructure;

                            retVal.Val.Add(subStructure1);

                            break;
                        }
                    }
                }
            }

            return retVal;
        }
        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)
            {
                string[] ids = msg_id.Split('.');
                if (ids[ids.Length-1].Equals(pair.Key))
                {
                    pair.Value.Type = structureType;
                    pair.Value.Value = structure;
                }
            }

            return Message.Name;
        }
        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;
        }
        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;
        }
 /// <summary>
 ///     Takes the message provided and returns the corresponding message value
 /// </summary>
 /// <param name="str"></param>
 /// <returns></returns>
 public static string format_message(DBMessage message)
 {
     string retVal = "";
     switch (message.MessageType)
     {
         case acceptor.DBMessageType.aEUROBALISE:
             retVal = format_eurobalise_message(message);
             break;
         case acceptor.DBMessageType.aEUROLOOP:
             retVal = format_euroloop_message(message);
             break;
         case acceptor.DBMessageType.aEURORADIO:
             retVal = format_euroradio_message(message);
             break;
     }
     return retVal;
 }
示例#12
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);
        }
示例#13
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);
        }
示例#14
0
 /// <summary>
 ///     Adds a new message
 /// </summary>
 /// <param name="message"></param>
 public void AddMessage(DBMessage message)
 {
     allMessages().Add(message);
 }
示例#15
0
        /// <summary>
        /// Imports all the messages used by this step
        /// </summary>
        /// <param name="aStep"></param>
        private void importStepMessages(DataDictionary.Tests.Step aStep)
        {
            string sql = "SELECT TCSOrder, MessageOrder, MessageType, Var_Name, Var_Value FROM TSW_MessageHeader ORDER BY MessageOrder, Var_Row";

            OleDbDataAdapter adapter = new OleDbDataAdapter(sql, Connection);
            DataSet          dataSet = new DataSet();

            adapter.Fill(dataSet);
            if (dataSet.Tables.Count > 0)
            {
                int messageNumber = 0;
                DataDictionary.Tests.DBElements.DBMessage message = null;
                int order = -1;
                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    object[] items = dataRow.ItemArray;
                    order = (int)items[0];
                    if (order == aStep.getTCS_Order())
                    {
                        short messageOrder = (short)items[1];
                        if (messageNumber != messageOrder)  // we create a new Message
                        {
                            if (messageNumber != 0)
                            {
                                aStep.AddMessage(message);
                                importPackets(message, order);
                            }
                            short messageTypeNumber = (short)items[2];
                            DataDictionary.Generated.acceptor.DBMessageType messageType = DataDictionary.Generated.acceptor.DBMessageType.defaultDBMessageType;
                            switch (messageTypeNumber)
                            {
                            case 0:
                                messageType = DataDictionary.Generated.acceptor.DBMessageType.aEUROBALISE;
                                break;

                            case 1:
                                messageType = DataDictionary.Generated.acceptor.DBMessageType.aEUROLOOP;
                                break;

                            case 2:
                                messageType = DataDictionary.Generated.acceptor.DBMessageType.aEURORADIO;
                                break;
                            }
                            message = (DataDictionary.Tests.DBElements.DBMessage)DataDictionary.Generated.acceptor.getFactory().createDBMessage();
                            message.MessageOrder = messageOrder;
                            message.MessageType  = messageType;
                            messageNumber        = messageOrder;
                        }
                        DataDictionary.Tests.DBElements.DBField field = (DataDictionary.Tests.DBElements.DBField)DataDictionary.Generated.acceptor.getFactory().createDBField();
                        string variable = items[3] as string;
                        if (variable != null)
                        {
                            field.Variable = variable;
                        }
                        string value = items[4] as string;
                        if (value != null)
                        {
                            field.Value = DataDictionary.Tests.Translations.Translation.format_decimal(value);
                        }
                        message.AddField(field);
                    }
                }
                if (message != null)
                {
                    aStep.AddMessage(message);
                    importPackets(message, aStep.getTCS_Order());
                }
            }
        }
示例#16
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);
        }
示例#17
0
 /// <summary>
 ///     Adds a new message
 /// </summary>
 /// <param name="message"></param>
 public void AddMessage(DBMessage message)
 {
     allMessages().Add(message);
 }