コード例 #1
0
            /// <summary>
            ///     Executes the action
            /// </summary>
            /// <param name="e"></param>
            protected override void OnClick(EventArgs e)
            {
                Step newStep = (Step)acceptor.getFactory().createStep();

                newStep.Enclosing = TimeLineControl.TestCase;

                SubStep subStep = (SubStep)acceptor.getFactory().createSubStep();

                subStep.Name = "Substep 1";
                newStep.appendSubSteps(subStep);

                TestCase testCase = GetTestCase();

                if (Step != null)
                {
                    newStep.Name = "NewStep";
                    int index = TimeLineControl.Steps.IndexOf(Step);
                    testCase.Steps.Insert(index + 1, newStep);
                    newStep.setFather(testCase);
                }
                else
                {
                    newStep.Name = "Step " + (TimeLineControl.Steps.Count + 1);
                    testCase.Steps.Add(newStep);
                    newStep.setFather(testCase);
                }

                base.OnClick(e);
            }
コード例 #2
0
        /// <summary>
        /// Imports the subsequence stored in the database
        /// </summary>
        /// <param name="frame"></param>
        private void importSubSequence(DataDictionary.Tests.Frame frame)
        {
            string sql = "SELECT TestSequenceID, TestSequenceName FROM TSW_TestSequence";

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

            adapter.Fill(dataSet);

            if (dataSet.Tables.Count > 0)
            {
                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    int    subSequenceID   = (int)dataRow.ItemArray.GetValue(0);
                    string subSequenceName = (string)dataRow.ItemArray.GetValue(1);

                    DataDictionary.Tests.SubSequence newSubSequence = (DataDictionary.Tests.SubSequence)DataDictionary.Generated.acceptor.getFactory().createSubSequence();
                    newSubSequence.Name = subSequenceName;
                    importInitialValues(newSubSequence, subSequenceID);
                    importSteps(newSubSequence);

                    DataDictionary.Tests.SubSequence oldSubSequence = frame.findSubSequence(subSequenceName);
                    if (oldSubSequence != null)
                    {
                        int cnt = 0;
                        foreach (DataDictionary.Tests.TestCase oldTestCase in oldSubSequence.TestCases)
                        {
                            if (cnt < newSubSequence.TestCases.Count)
                            {
                                DataDictionary.Tests.TestCase newTestCase = newSubSequence.TestCases[cnt] as DataDictionary.Tests.TestCase;
                                if (newTestCase != null)
                                {
                                    if (oldTestCase.Name.Equals(newTestCase.Name))
                                    {
                                        newTestCase.Merge(oldTestCase);
                                    }
                                    else
                                    {
                                        throw new Exception(newTestCase.FullName + " is found instead of " + oldTestCase.FullName + " while importing sub-sequence " + newSubSequence.FullName);
                                    }
                                }
                            }
                            else
                            {
                                throw new Exception("The test case " + oldTestCase.FullName + " is not present in the new data base");
                            }
                            cnt++;
                        }

                        oldSubSequence.Delete();
                    }

                    frame.appendSubSequences(newSubSequence);
                }
            }
            else
            {
                Log.Error("Cannot find table TSW_TestSequence in database");
            }
        }
コード例 #3
0
        /// <summary>
        ///     Creates a step in a test case
        /// </summary>
        /// <param name="enclosing"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        protected Step CreateStep(TestCase enclosing, string name)
        {
            Step retVal = (Step)Factory.createStep();

            enclosing.appendSteps(retVal);
            retVal.Name = name;

            return(retVal);
        }
コード例 #4
0
        /// <summary>
        ///     Creates a test case in the enclosing test sub sequence
        /// </summary>
        /// <param name="enclosing"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        protected TestCase CreateTestCase(SubSequence enclosing, string name)
        {
            TestCase retVal = (TestCase)Factory.createTestCase();

            enclosing.appendTestCases(retVal);
            retVal.Name = name;

            return(retVal);
        }
コード例 #5
0
 /// <summary>
 /// Consctructor: creates a report for a selected test case
 /// </summary>
 /// <param name="aTestCase"></param>
 public TestReport(DataDictionary.Tests.TestCase aTestCase)
 {
     InitializeComponent();
     EFSSystem              = aTestCase.EFSSystem;
     reportHandler          = new TestsCoverageReportHandler(aTestCase.Dictionary);
     reportHandler.TestCase = aTestCase;
     InitializeCheckBoxes(3);
     TxtB_Path.Text = reportHandler.FileName;
 }
コード例 #6
0
        /// <summary>
        ///     Indicates whether the timeline should display the element
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public override bool ShouldDisplayModelElement(IModelElement element)
        {
            bool retVal = element == null;

            retVal = retVal || (Translation != null && Translation.IsParent(element));
            retVal = retVal || (SubSequence != null && SubSequence.IsParent(element));
            retVal = retVal || (TestCase != null && TestCase.IsParent(element));

            return(retVal);
        }
コード例 #7
0
        public void InsertTest(object sender, EventArgs args)
        {
            TextEntry dataEntry = new TextEntry();

            dataEntry.ShowDialog();

            TestCase    driverId            = null;
            SubSequence driverIdSubSequence = Item.Frame.findSubSequence("IN Driver id");

            foreach (TestCase testCase in driverIdSubSequence.TestCases)
            {
                if (testCase.Name == "IN Driver Id")
                {
                    driverId = testCase;
                    break;
                }
            }

            if (driverId != null)
            {
                TestCase duplicate = driverId.Duplicate() as TestCase;
                if (duplicate != null)
                {
                    duplicate.Name = "IN " + dataEntry.Value;
                    foreach (Step step in duplicate.Steps)
                    {
                        foreach (SubStep subStep in step.SubSteps)
                        {
                            foreach (Action action in subStep.Actions)
                            {
                                action.ExpressionText = action.ExpressionText.Replace("DriverId", dataEntry.Value);
                            }
                            foreach (Expectation expectation in subStep.Expectations)
                            {
                                expectation.ExpressionText = expectation.ExpressionText.Replace("DriverId",
                                                                                                dataEntry.Value);
                            }
                        }
                    }
                }

                Item.appendTestCases(duplicate);
            }
        }
コード例 #8
0
            /// <summary>
            ///     Gets the test case in which steps should be created
            /// </summary>
            private TestCase GetTestCase()
            {
                TestCase retVal = TimeLineControl.TestCase;

                if (retVal == null)
                {
                    if (TimeLineControl.SubSequence != null)
                    {
                        if (TimeLineControl.SubSequence.TestCases.Count == 0)
                        {
                            retVal = (TestCase)acceptor.getFactory().createTestCase();
                            TimeLineControl.SubSequence.appendTestCases(retVal);
                        }
                        else
                        {
                            retVal = (TestCase)TimeLineControl.SubSequence.TestCases[
                                TimeLineControl.SubSequence.TestCases.Count - 1];
                        }
                    }
                }

                return(retVal);
            }
コード例 #9
0
        /// <summary>
        /// Describes a specific Subset-076 specification issue
        /// </summary>
        /// <param name="paragraph"></param>
        private void DescribeSpecIssue(Paragraph paragraph)
        {
            if (paragraph.SubParagraphs.Count > 0)
            {
                Report.AddSubParagraph(paragraph.Name);
                Report.AddTable(new[] { "SubSequence", "Test case", "Step", "Comment" }, new[] { 60, 20, 10, 80 });
                foreach (Paragraph subParagraph in paragraph.SubParagraphs)
                {
                    DescribeSpecIssue(subParagraph);
                }
                Report.CloseSubParagraph();
            }
            else
            {
                Report.AddRow(paragraph.ExpressionText);
                Report.SetLastRowColor(IssueColor(paragraph));

                if (paragraph.Implementations.Count > 0)
                {
                    foreach (ReqRef reqRef in paragraph.Implementations)
                    {
                        SubSequence subSequence = EnclosingFinder <SubSequence> .find(reqRef, true);

                        TestCase testCase = EnclosingFinder <TestCase> .find(reqRef, true);

                        Step step = EnclosingFinder <Step> .find(reqRef, true);

                        Report.AddRow(
                            subSequence != null ? subSequence.Name : "",
                            testCase != null ? testCase.getFeature().ToString(CultureInfo.InvariantCulture) : "",
                            step != null ? step.getTCS_Order().ToString(CultureInfo.InvariantCulture) : "",
                            reqRef.Comment);
                    }
                }
            }
        }
コード例 #10
0
        private void initializeInputForLambda(TestCase aTestCase, Workbook workbook)
        {
            Step aStep = new Step();
            aStep.Name = "Step1 - Initialize input";
            aTestCase.AddModelElement(aStep);

            /*********************************** TRAIN DATA ***********************************/
            SubStep aSubStep = new SubStep();
            aSubStep.Name = "SubStep1 - Train data";
            aSubStep.setSkipEngine(true);
            aStep.AddModelElement(aSubStep);

            /* This is a lambda train => no brake models defined in the train data */
            addAction(aSubStep, String.Format("Kernel.TrainData.TrainData.Value.EBModels <- EMPTY"));
            addAction(aSubStep, String.Format("Kernel.TrainData.TrainData.Value.SBModels <- EMPTY"));
            addAction(aSubStep, String.Format("Kernel.TrainData.TrainData.Value.NormalServiceBrakeModels <- EMPTY"));
            addAction(aSubStep, String.Format("Kernel.TrainData.TrainData.Value.T_brake_emergency <- EMPTY"));
            addAction(aSubStep, String.Format("Kernel.TrainData.TrainData.Value.T_brake_service <- EMPTY"));

            /* Initializing the maximum train speed */
            /* This value must be in the range {0km/h; 200km/h}, otherwise the conversion model will not be applicable */
            addAction(aSubStep,
                String.Format(CultureInfo.InvariantCulture, "Kernel.TrainData.TrainData.Value.MaximumSpeed <- {0:0.0}",
                    180.0));

            Worksheet aWorksheet = workbook.Sheets[1] as Worksheet;
            bool isPassengerTrain;
            importCommonTrainDataInformation(aSubStep, aWorksheet, out isPassengerTrain);

            /*********************************** TRACK DATA ***********************************/
            aSubStep = new SubStep();
            aSubStep.Name = "SubStep2 - Track data";
            aSubStep.setSkipEngine(true);
            aStep.AddModelElement(aSubStep);

            /* This is a lambda train => track condition brake inhibition profile is not applicable */
            addAction(aSubStep, String.Format("Kernel.TrackDescription.TrackConditions.General.TCProfile <- []"));

            aWorksheet = workbook.Sheets[2] as Worksheet;
            importCommonTrackDataInformation(aSubStep, aWorksheet);

            /*********************************** NATIONAL VALUES ***********************************/
            aSubStep = new SubStep();
            aSubStep.Name = "SubStep3 - National values";
            aSubStep.setSkipEngine(true);
            aStep.AddModelElement(aSubStep);

            aWorksheet = workbook.Sheets[3] as Worksheet;
            importCommonNationalValuesInformation(aSubStep, aWorksheet);

            /*********************************** FIXED VALUES ***********************************/
            aSubStep = new SubStep();
            aSubStep.Name = "SubStep4 - Fixed values";
            aSubStep.setSkipEngine(true);
            aStep.AddModelElement(aSubStep);

            aWorksheet = workbook.Sheets[4] as Worksheet;
            importCommonFixedValuesInformation(aSubStep, aWorksheet);

            /****************************** BRAKE PARAMETERS (lambda) ******************************/
            aSubStep = new SubStep();
            aSubStep.Name = "SubStep5 - Brake parameters";
            aSubStep.setSkipEngine(true);
            aStep.AddModelElement(aSubStep);

            aWorksheet = workbook.Sheets[5] as Worksheet;

            Range aRange = aWorksheet.UsedRange;
            addAction(aSubStep,
                String.Format(CultureInfo.InvariantCulture,
                    "Kernel.TrainData.TrainData.Value.BrakePercentage <- {0:0.0#}",
                    (double)(aRange.Cells[3, 6] as Range).Value2));

            /*************************** INTERGRATED CORRECTION FACTORS ***************************/
            aSubStep = new SubStep();
            aSubStep.Name = "SubStep6 - Integrated correction factors";
            aSubStep.setSkipEngine(true);
            aStep.AddModelElement(aSubStep);

            aWorksheet = workbook.Sheets[8] as Worksheet;

            aRange = aWorksheet.UsedRange;

            /* Initializing Kr_int */
            int index = 0;
            double doubleValue = -1;
            double temp;
            for (int i = 0; i < 9; i++)
            {
                temp = (double)(aRange.Cells[i + 32, 2] as Range).Value2;
                if (doubleValue != temp)
                {
                    double location = (double)(aRange.Cells[i + 32, 1] as Range).Value2;
                    doubleValue = temp;
                    addAction(aSubStep,
                        String.Format(CultureInfo.InvariantCulture,
                            "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorKrInt.Val{0} <- Kernel.NationalValues.KrIntValueStruct\n{{\n    LengthStep => {1:0.0},\n    Value => {2:0.0####}\n}}",
                            index, location, doubleValue));
                    index++;
                }
            }
            addAction(aSubStep,
                String.Format(CultureInfo.InvariantCulture,
                    "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorKrInt.Val{0} <- Kernel.NationalValues.KrIntValueStruct\n{{\n    LengthStep => Default.BaseTypes.Length.Infinity,\n    Value => {1:0.0####}\n}}",
                    index, doubleValue));

            /* Case of a passenger train */
            if (isPassengerTrain)
            {
                /* Initializing Kv_int */
                double a = -1;
                double b = -1;
                double tempA, tempB;
                index = 0;
                for (int i = 0; i <= 9; i++)
                {
                    tempA = (double)(aRange.Cells[i + 5, 5] as Range).Value2;
                    tempB = (double)(aRange.Cells[i + 31, 5] as Range).Value2;
                    if (a != tempA || b != tempB)
                    {
                        double speed = (double)(aRange.Cells[i + 5, 4] as Range).Value2;
                        a = tempA;
                        b = tempB;
                        addAction(aSubStep,
                            String.Format(CultureInfo.InvariantCulture,
                                "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorKvInt_PassengerTrain.Val{0} <- Kernel.NationalValues.KvIntValue_PassengerTrainStruct\n{{\n    SpeedStep => {1:0.0},\n    ValueA => {2:0.0#},\n    ValueB => {3:0.0#}\n}}",
                                index, speed, a, b));
                        index++;
                    }
                }
                addAction(aSubStep,
                    String.Format(CultureInfo.InvariantCulture,
                        "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorKvInt_PassengerTrain.Val{0} <- Kernel.NationalValues.KvIntValue_PassengerTrainStruct\n{{\n    SpeedStep => Default.BaseTypes.Speed.Infinity,\n    ValueA => {1:0.0#},\n    ValueB => {2:0.0#}\n}}",
                        index, a, b));
            }
            else /* Case of freight trains */
            {
                /* Initializing Kv_int */
                doubleValue = -1;
                index = 0;
                for (int i = 0; i <= 9; i++)
                {
                    temp = (double)(aRange.Cells[i + 5, 2] as Range).Value2;
                    if (doubleValue != temp)
                    {
                        double speed = (double)(aRange.Cells[i + 5, 1] as Range).Value2;
                        doubleValue = temp;
                        addAction(aSubStep,
                            String.Format(CultureInfo.InvariantCulture,
                                "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorKvInt_FreightTrain.Val{0} <- Kernel.NationalValues.KvIntValue_FreightTrainStruct\n{{\n    SpeedStep => {1:0.0},\n    Value => {2:0.0#}\n}}",
                                index, speed, doubleValue));
                        index++;
                    }
                }
                addAction(aSubStep,
                    String.Format(CultureInfo.InvariantCulture,
                        "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorKvInt_FreightTrain.Val{0} <- Kernel.NationalValues.KvIntValue_FreightTrainStruct\n{{\n    SpeedStep => Default.BaseTypes.Speed.Infinity,\n    Value => {1:0.0#}\n}}",
                        index, doubleValue));
            }

            /* Initializing A_NVP12 */
            addAction(aSubStep,
                String.Format(CultureInfo.InvariantCulture,
                    "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorKvInt_PassengerTrain.A_NVP12 <- {0:0.0}",
                    (double)(aRange.Cells[44, 4] as Range).Value2));

            /* Initializing A_NVP23 */
            addAction(aSubStep,
                String.Format(CultureInfo.InvariantCulture,
                    "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorKvInt_PassengerTrain.A_NVP23 <- {0:0.0}",
                    (double)(aRange.Cells[44, 6] as Range).Value2));

            /* Initializing Kt_int */
            addAction(aSubStep,
                String.Format(CultureInfo.InvariantCulture,
                    "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorForBrakeBuildUpTime <- {0:0.0}",
                    (double)(aRange.Cells[47, 4] as Range).Value2));
        }
コード例 #11
0
        private void initializeInputForGamma(TestCase aTestCase, Workbook workbook)
        {
            Step aStep = new Step();
            aStep.Name = "Step1 - Initialize input";
            aTestCase.AddModelElement(aStep);

            /*********************************** TRAIN DATA ***********************************/
            SubStep aSubStep = new SubStep();
            aSubStep.Name = "SubStep1 - Train data";
            aSubStep.setSkipEngine(true);
            aStep.AddModelElement(aSubStep);

            /* This is a gamma train => we have to initialize brake models in the train data */
            addAction(aSubStep,
                String.Format(
                    "Kernel.TrainData.TrainData.Value.EBModels <- Kernel.TrainData.BrakingParameters.EBModelSet\n{{\n    ModelSet => Kernel.TrainData.BrakingParameters.BrakingModelSet{{}},\n    Kdry_rstValuesSet => Kernel.TrainData.BrakingParameters.Kdry_rstValuesSet{{}},\n    Kwet_rstValuesSet => Kernel.TrainData.BrakingParameters.Kwet_rstValuesSet{{}}\n}}"));
            addAction(aSubStep,
                String.Format(
                    "Kernel.TrainData.TrainData.Value.SBModels <- Kernel.TrainData.BrakingParameters.SBModelSet{{}}"));

            /* Initializing the maximum train speed */
            /* I didn't find this value in ERA sheets, but I observed than their P function can exceed 160 km/h => the maximum speed should be greater than 160 km/h */
            addAction(aSubStep,
                String.Format(CultureInfo.InvariantCulture, "Kernel.TrainData.TrainData.Value.MaximumSpeed <- {0:0.0}",
                    180.0));

            Worksheet aWorksheet = workbook.Sheets[1] as Worksheet;
            bool isPassengerTrain;
            importCommonTrainDataInformation(aSubStep, aWorksheet, out isPassengerTrain);

            /*********************************** TRACK DATA ***********************************/
            aSubStep = new SubStep();
            aSubStep.Name = "SubStep2 - Track data";
            aSubStep.setSkipEngine(true);
            aStep.AddModelElement(aSubStep);

            aWorksheet = workbook.Sheets[2] as Worksheet;
            importCommonTrackDataInformation(aSubStep, aWorksheet);

            /*********************************** NATIONAL VALUES ***********************************/
            aSubStep = new SubStep();
            aSubStep.Name = "SubStep3 - National values";
            aSubStep.setSkipEngine(true);
            aStep.AddModelElement(aSubStep);

            aWorksheet = workbook.Sheets[3] as Worksheet;
            importCommonNationalValuesInformation(aSubStep, aWorksheet);

            /*********************************** FIXED VALUES ***********************************/
            aSubStep = new SubStep();
            aSubStep.Name = "SubStep4 - Fixed values";
            aSubStep.setSkipEngine(true);
            aStep.AddModelElement(aSubStep);

            aWorksheet = workbook.Sheets[4] as Worksheet;
            importCommonFixedValuesInformation(aSubStep, aWorksheet);

            /****************************** BRAKE PARAMETERS (gamma) ******************************/
            aSubStep = new SubStep();
            aSubStep.Name = "SubStep5 - Brake parameters";
            aSubStep.setSkipEngine(true);
            aStep.AddModelElement(aSubStep);

            aWorksheet = workbook.Sheets[6] as Worksheet;

            importGammaBrakeParameters(aSubStep, aWorksheet, 2, 8, true); // first combination
            importGammaBrakeParameters(aSubStep, aWorksheet, 3, 20, false); // second combination

            /**************************** Initialize time intervals ******************************/
            aSubStep = new SubStep();
            aSubStep.Name = "Initialize time intervals";
            aSubStep.setSkipEngine(true);
            aStep.AddModelElement(aSubStep);

            addAction(aSubStep, "Kernel.SpeedAndDistanceMonitoring.TargetSpeedMonitoring.InitializeTimeIntervals()");

            /**************************** CORRECTION FACTOR KDRY_RST ****************************/
            aSubStep = new SubStep();
            aSubStep.Name = "SubStep6 - Correction factor kdry_rst";
            aSubStep.setSkipEngine(true);
            aStep.AddModelElement(aSubStep);

            aWorksheet = workbook.Sheets[7] as Worksheet;
        }
コード例 #12
0
        private void fillBrakingParametersExpectations(TestCase aTestCase, int stepNumber, string name,
            string expression, List<double> distanceValues, List<double> speedValues, List<double> values)
        {
            Step aStep = new Step();
            aStep.Name = String.Format("Step{0} - {1}", stepNumber, name);
            aTestCase.AddModelElement(aStep);

            SubStep aSubStep = new SubStep();
            aSubStep.Name = String.Format("SubStep1 - Verify {0} values", name);
            aStep.AddModelElement(aSubStep);

            for (int i = 0; i < values.Count; i++)
            {
                if (values[i] != -1)
                {
                    Expectation expectation = new Expectation();
                    expectation.ExpressionText = String.Format(CultureInfo.InvariantCulture, expression,
                        Math.Round(distanceValues[i], 2), Math.Round(speedValues[i], 2), Math.Round(values[i], 4));
                    aSubStep.AddModelElement(expectation);
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// Imports the subsequence stored in the database
        /// </summary>
        /// <param name="frame"></param>
        private void importInitialValues(DataDictionary.Tests.SubSequence subSequence, int subSequenceID)
        {
            // Level is a reserved word...
            string sql = "SELECT D_LRBG, TSW_TestSeqSCItl.Level, Mode, NID_LRBG, Q_DIRLRBG, Q_DIRTRAIN, Q_DLRBG, RBC_ID, RBCPhone FROM TSW_TestSeqSCItl WHERE TestSequenceID = " + subSequenceID;

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

            adapter.Fill(dataSet);
            if (dataSet.Tables.Count > 0)
            {
                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    int    i          = 0;
                    string D_LRBG     = dataRow.ItemArray.GetValue(i++) as string;
                    string Level      = dataRow.ItemArray.GetValue(i++) as string;
                    string Mode       = dataRow.ItemArray.GetValue(i++) as string;
                    string NID_LRBG   = dataRow.ItemArray.GetValue(i++) as string;
                    string Q_DIRLRBG  = dataRow.ItemArray.GetValue(i++) as string;
                    string Q_DIRTRAIN = dataRow.ItemArray.GetValue(i++) as string;
                    string Q_DLRBG    = dataRow.ItemArray.GetValue(i++) as string;
                    string RBC_ID     = dataRow.ItemArray.GetValue(i++) as string;
                    string RBCPhone   = dataRow.ItemArray.GetValue(i++) as string;

                    subSequence.setD_LRBG(D_LRBG);
                    subSequence.setLevel(Level);
                    subSequence.setMode(Mode);
                    subSequence.setNID_LRBG(NID_LRBG);
                    subSequence.setQ_DIRLRBG(Q_DIRLRBG);
                    subSequence.setQ_DIRTRAIN(Q_DIRTRAIN);
                    subSequence.setQ_DLRBG(Q_DLRBG);
                    subSequence.setRBC_ID(RBC_ID);
                    subSequence.setRBCPhone(RBCPhone);

                    DataDictionary.Tests.TestCase testCase = (DataDictionary.Tests.TestCase)DataDictionary.Generated.acceptor.getFactory().createTestCase();
                    testCase.Name = "Setup";
                    subSequence.appendTestCases(testCase);

                    DataDictionary.Tests.Step initializeTrainDataStep = (DataDictionary.Tests.Step)DataDictionary.Generated.acceptor.getFactory().createStep();;
                    initializeTrainDataStep.setTCS_Order(0);
                    initializeTrainDataStep.setDistance(0);
                    initializeTrainDataStep.setDescription("Initialize train data");
                    initializeTrainDataStep.setTranslationRequired(true);
                    testCase.appendSteps(initializeTrainDataStep);

                    DataDictionary.Tests.Step setupStep = (DataDictionary.Tests.Step)DataDictionary.Generated.acceptor.getFactory().createStep();;
                    setupStep.setTCS_Order(0);
                    setupStep.setDistance(0);
                    setupStep.setDescription("Setup test sequence");
                    setupStep.setTranslationRequired(true);
                    testCase.appendSteps(setupStep);

                    DataDictionary.Tests.Step manualSetupStep = (DataDictionary.Tests.Step)DataDictionary.Generated.acceptor.getFactory().createStep();;
                    manualSetupStep.setTCS_Order(0);
                    manualSetupStep.setDistance(0);
                    manualSetupStep.setDescription("Manual setup test sequence");
                    manualSetupStep.setTranslationRequired(true);
                    testCase.appendSteps(manualSetupStep);
                }
            }
            else
            {
                Log.Error("Cannot find entry in table TSW_TestSeqSCItl WHERE TestSequenceID = " + subSequenceID);
            }
        }
コード例 #14
0
        /// <summary>
        ///     Creates a step in a test case
        /// </summary>
        /// <param name="enclosing"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        protected Step CreateStep(TestCase enclosing, string name)
        {
            Step retVal = (Step) Factory.createStep();
            enclosing.appendSteps(retVal);
            retVal.Name = name;

            return retVal;
        }
コード例 #15
0
        /// <summary>
        ///     Creates a section for a given test case
        /// </summary>
        /// <param name="runner">The runner to be used to execute the tests</param>
        /// <param name="aTestCase">Test case to be displayed</param>
        /// <param name="aReportConfig">The report configuration containing display details</param>
        /// <param name="activatedRuleConditions">The list that will contain the rules activated by this test case</param>
        /// <param name="createPdf">Indicates if the information about this sub-sequence has to be added to the pdf</param>
        public void CreateTestCaseSection(Runner runner, TestCase aTestCase, TestsCoverageReportHandler aReportConfig,
            HashSet<RuleCondition> activatedRuleConditions, bool createPdf)
        {
            string title = "Test case " + aTestCase.Name;
            if (createPdf)
            {
                AddSubParagraph(title);

                if (aTestCase.Requirements.Count > 0)
                {
                    AddSubParagraph(title + ": verified requirements:");
                    foreach (ReqRef reqRef in aTestCase.Requirements)
                    {
                        string text = "Requirement " + reqRef.Name;
                        if (!Utils.Utils.isEmpty(reqRef.Comment))
                        {
                            text = text + " : " + reqRef.Comment;
                        }
                        AddListItem(text);
                    }
                    CloseSubParagraph();
                }
            }

            runner.RunUntilStep(null);
            activatedRuleConditions.UnionWith(runner.EventTimeLine.GetActivatedRules());

            if (createPdf)
            {
                if (aReportConfig.AddSteps)
                {
                    foreach (Step step in aTestCase.Steps)
                    {
                        if (step.SubSteps.Count > 0)
                        {
                            SubStep firstSubStep = step.SubSteps[0] as SubStep;
                            SubStep lastSubStep = step.SubSteps[step.SubSteps.Count - 1] as SubStep;
                            double start = runner.EventTimeLine.GetSubStepActivationTime(firstSubStep);
                            double end = runner.EventTimeLine.GetNextSubStepActivationTime(lastSubStep);
                            List<RuleCondition> activatedRules = runner.EventTimeLine.GetActivatedRulesInRange(start,
                                end);

                            CreateStepSection(step, activatedRules, aReportConfig);
                        }
                    }
                }

                CreateActivatedRulesSection(title,
                    runner.EventTimeLine.GetActivatedRules(),
                    aReportConfig.Dictionary.ImplementedRules,
                    aReportConfig.AddActivatedRulesInTestCases);

                CloseSubParagraph();
            }
        }
コード例 #16
0
        /// <summary>
        ///     Imports the subsequence stored in the database
        /// </summary>
        /// <param name="subSequence"></param>
        /// <param name="subSequenceId"></param>
        private void ImportInitialValues(SubSequence subSequence, int subSequenceId)
        {
            // Level is a reserved word...
            string sql =
                "SELECT D_LRBG, TSW_TestSeqSCItl.Level, Mode, NID_LRBG, Q_DIRLRBG, Q_DIRTRAIN, Q_DLRBG, RBC_ID, RBCPhone FROM TSW_TestSeqSCItl WHERE TestSequenceID = " +
                subSequenceId;

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

            adapter.Fill(dataSet);
            if (dataSet.Tables.Count > 0)
            {
                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    int i = 0;
                    // ReSharper disable InconsistentNaming
                    string D_LRBG     = dataRow.ItemArray.GetValue(i++) as string;
                    string Level      = dataRow.ItemArray.GetValue(i++) as string;
                    string Mode       = dataRow.ItemArray.GetValue(i++) as string;
                    string NID_LRBG   = dataRow.ItemArray.GetValue(i++) as string;
                    string Q_DIRLRBG  = dataRow.ItemArray.GetValue(i++) as string;
                    string Q_DIRTRAIN = dataRow.ItemArray.GetValue(i++) as string;
                    string Q_DLRBG    = dataRow.ItemArray.GetValue(i++) as string;
                    string RBC_ID     = dataRow.ItemArray.GetValue(i++) as string;
                    string RBCPhone   = dataRow.ItemArray.GetValue(i++) as string;
                    // ReSharper restore InconsistentNaming

                    subSequence.setD_LRBG(D_LRBG);
                    subSequence.setLevel(Level);
                    subSequence.setMode(Mode);
                    subSequence.setNID_LRBG(NID_LRBG);
                    subSequence.setQ_DIRLRBG(Q_DIRLRBG);
                    subSequence.setQ_DIRTRAIN(Q_DIRTRAIN);
                    subSequence.setQ_DLRBG(Q_DLRBG);
                    subSequence.setRBC_ID(RBC_ID);
                    subSequence.setRBCPhone(RBCPhone);

                    TestCase testCase = (TestCase)acceptor.getFactory().createTestCase();
                    testCase.Name = "Setup";
                    subSequence.appendTestCases(testCase);

                    Step initializeTrainDataStep = (Step)acceptor.getFactory().createStep();

                    initializeTrainDataStep.setTCS_Order(0);
                    initializeTrainDataStep.setDistance("0");
                    initializeTrainDataStep.setDescription("Initialize train data");
                    initializeTrainDataStep.setTranslationRequired(true);
                    testCase.appendSteps(initializeTrainDataStep);

                    Step defaultValuesStep = (Step)acceptor.getFactory().createStep();

                    defaultValuesStep.setTCS_Order(0);
                    defaultValuesStep.setDistance("0");
                    defaultValuesStep.setDescription("Set default values");
                    defaultValuesStep.setTranslationRequired(true);
                    testCase.appendSteps(defaultValuesStep);

                    Step manualSetupStep = (Step)acceptor.getFactory().createStep();

                    manualSetupStep.setTCS_Order(0);
                    manualSetupStep.setDistance("0");
                    manualSetupStep.setDescription("Manual setup test sequence");
                    manualSetupStep.setTranslationRequired(false);
                    testCase.appendSteps(manualSetupStep);
                }
            }
            else
            {
                throw new Exception("Cannot find entry in table TSW_TestSeqSCItl WHERE TestSequenceID = " + subSequenceId);
            }
        }
コード例 #17
0
        /// <summary>
        ///     Imports the subsequence stored in the database
        /// </summary>
        /// <param name="frame"></param>
        /// <param name="keepManualTranslations">Indicates that manual translation for be kept during import</param>
        private void ImportSubSequence(Frame frame, bool keepManualTranslations)
        {
            const string sql = "SELECT TestSequenceID, TestSequenceName FROM TSW_TestSequence";

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

            adapter.Fill(dataSet);

            if (dataSet.Tables.Count > 0)
            {
                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    int    subSequenceId   = (int)dataRow.ItemArray.GetValue(0);
                    string subSequenceName = (string)dataRow.ItemArray.GetValue(1);

                    SubSequence newSubSequence = (SubSequence)acceptor.getFactory().createSubSequence();
                    newSubSequence.Name = subSequenceName;
                    ImportInitialValues(newSubSequence, subSequenceId);
                    ImportSteps(newSubSequence);
                    newSubSequence.setCompleted(false);

                    SubSequence previousSubSequence = frame.findSubSequence(subSequenceName);
                    if (previousSubSequence != null)
                    {
                        newSubSequence.setGuid(previousSubSequence.getGuid());
                        newSubSequence.setCompleted(previousSubSequence.getCompleted());
                        int cnt = 0;
                        foreach (TestCase previousTestCase in previousSubSequence.TestCases)
                        {
                            if (cnt < newSubSequence.TestCases.Count)
                            {
                                TestCase newTestCase = newSubSequence.TestCases[cnt] as TestCase;
                                if (newTestCase != null)
                                {
                                    if (previousTestCase.Name.Equals(newTestCase.Name))
                                    {
                                        newTestCase.Merge(previousTestCase, keepManualTranslations);
                                    }
                                    else
                                    {
                                        throw new Exception(newTestCase.FullName + " is found instead of " +
                                                            previousTestCase.FullName + " while importing sub-sequence " +
                                                            newSubSequence.FullName);
                                    }
                                }
                            }
                            else
                            {
                                throw new Exception("The test case " + previousTestCase.FullName +
                                                    " is not present in the new data base");
                            }
                            cnt++;
                        }

                        previousSubSequence.Delete();
                    }

                    frame.appendSubSequences(newSubSequence);
                }
            }
            else
            {
                throw new Exception("Cannot find table TSW_TestSequence in database");
            }
        }
コード例 #18
0
 /// <summary>
 /// Creates a table entry for a test case
 /// </summary>
 /// <param name="testCase"></param>
 private void IntroduceTestCase(TestCase testCase)
 {
     Report.AddRow(testCase.Name);
     Report.SetLastRowColor(Colors.LightBlue);
     ReportIssue(testCase);
 }
コード例 #19
0
        // The sheets of the workbook are:                       \\
        //                                                       \\
        // Sheet number 1,  name: Train (main)                   \\
        // Sheet number 2,  name: Track                          \\
        // Sheet number 3,  name: National values                \\
        // Sheet number 4,  name: Fixed values                   \\
        // Sheet number 5,  name: Brake parameters (lambda)      \\  L
        // Sheet number 6,  name: Brake parameters (gamma)       \\  G
        // Sheet number 7,  name: Correction factor Kdry_rst     \\  G
        // Sheet number 8,  name: Integrated correction factors  \\  L
        // Sheet number 9,  name: Lambda train deceleration      \\  L
        // Sheet number 10, name: Gamma train deceleration       \\  G
        // Sheet number 11, name: Curves Gamma train             \\  G
        // Sheet number 12, name: Calc Gamma                     \\  G (hidden)
        // Sheet number 13, name: Curves Lambda train            \\  L
        // Sheet number 14, name: Calc Lambda                    \\  L (hidden)
        /// <summary>
        ///     Launches import of the excel file in the background task
        /// </summary>
        /// <param name="arg"></param>
        public override void ExecuteWork()
        {
            if (TheDictionary != null)
            {
                Application application = new Application();
                try
                {
                    Workbook workbook = application.Workbooks.Open(FileName);
                    Worksheet trainData = workbook.Sheets[1] as Worksheet;
                    Range aRange = trainData.UsedRange;
                    string trainTypeName = (string)(aRange.Cells[14, 4] as Range).Value2;
                    bool trainIsGamma = false;
                    if (trainTypeName.Equals("Gamma"))
                    {
                        trainIsGamma = true;
                    }
                    else if (!trainTypeName.Equals("Lambda"))
                    {
                        new Exception("Unknown train type");
                    }

                    Frame newFrame = new Frame();
                    newFrame.Name = FrameName;
                    newFrame.setCycleDuration("Kernel.CycleDuration");
                    TheDictionary.AddModelElement(newFrame);

                    SubSequence newSubSequence = new SubSequence();
                    newSubSequence.Name = FrameName;
                    newFrame.AddModelElement(newSubSequence);

                    TestCase aTestCase = new TestCase();
                    aTestCase.Name = "Setup";
                    aTestCase.NeedsRequirement = false;
                    newSubSequence.AddModelElement(aTestCase);

                    intializeEFS(aTestCase, workbook);

                    aTestCase = new TestCase();
                    aTestCase.Name = "Initialize input";
                    aTestCase.NeedsRequirement = false;
                    newSubSequence.AddModelElement(aTestCase);
                    if (trainIsGamma)
                    {
                        initializeInputForGamma(aTestCase, workbook);
                    }
                    else
                    {
                        initializeInputForLambda(aTestCase, workbook);
                    }

                    aTestCase = new TestCase();
                    aTestCase.Name = "Verify input";
                    aTestCase.NeedsRequirement = false;
                    newSubSequence.AddModelElement(aTestCase);
                    if (trainIsGamma)
                    {
                        verifyInputForGamma(aTestCase, workbook);
                    }
                    else
                    {
                        verifyInputForLambda(aTestCase, workbook);
                    }

                    aTestCase = new TestCase();
                    aTestCase.Name = "Verify output";
                    aTestCase.NeedsRequirement = false;
                    newSubSequence.AddModelElement(aTestCase);
                    verifyOutputForTrains(trainIsGamma, aTestCase, workbook);
                }
                catch (Exception e)
                {
                    Log.ErrorFormat(e.Message);
                }
                application.Quit();
            }
        }
コード例 #20
0
 public void AddHandler(object sender, EventArgs args)
 {
     Item.appendTestCases(TestCase.CreateDefault(Item.TestCases));
 }
コード例 #21
0
        private void intializeEFS(TestCase aTestCase, Workbook workbook)
        {
            Step aStep = new Step();
            aStep.Name = "Step1 - Setup";
            aTestCase.AddModelElement(aStep);

            SubStep aSubStep = new SubStep();
            aSubStep.Name = "SubStep1 - Setup";
            aSubStep.setSkipEngine(true);
            aStep.AddModelElement(aSubStep);

            TestAction powerOn = new TestAction();
            powerOn.ExpressionText = "Kernel.PowerOn <- True";
            aSubStep.AddModelElement(powerOn);

            TestAction modeInitialization = new TestAction();
            modeInitialization.ExpressionText = "Kernel.Mode <- Mode.FS";
            aSubStep.AddModelElement(modeInitialization);

            TestAction levelInitialization = new TestAction();
            levelInitialization.ExpressionText =
                "Kernel.Level <- Kernel.LevelData\n{\n    Value => LevelDataStruct { Value => Level.L1 },\n    DataState => DataState.Valid\n}";
            aSubStep.AddModelElement(levelInitialization);

            TestAction odometryInitialization = new TestAction();
            odometryInitialization.ExpressionText = "Odometry.NominalDistance <- 0.0";
            aSubStep.AddModelElement(odometryInitialization);

            TestAction LRBGInitialization = new TestAction();
            LRBGInitialization.ExpressionText = "BTM.LRBG <- BTM.BaliseGroupStruct{\n" +
                                                "    NID => 0,\n" +
                                                "    Orientation => Default.Orientation.Nominal,\n" +
                                                "    Position => BTM.Position{\n" +
                                                "        Position => 0.0,\n" +
                                                "        UnderReadingAmountOdo => 0.0,\n" +
                                                "        OverReadingAmountOdo => 0.0\n" +
                                                "    },\n" +
                                                "    Timestamp => Default.DateAndTime{\n" +
                                                "        Year => 2012,\n" +
                                                "        Month => 12,\n" +
                                                "        Day => 20,\n" +
                                                "        Hour => 20,\n" +
                                                "        Minute => 12,\n" +
                                                "        Second => 20,\n" +
                                                "        TTS => 600\n" +
                                                "    }\n" +
                                                "}";
            aSubStep.AddModelElement(LRBGInitialization);
        }
コード例 #22
0
        /// <summary>
        /// Perform all functional tests defined in the .EFS file provided
        /// </summary>
        /// <param name="args"></param>
        /// <returns>the error code of the program</returns>
        static int Main(string[] args)
        {
            int retVal = 0;

            try
            {
                Console.Out.WriteLine("EFS Tester");

                // Load the dictionaries provided as parameters
                EFSSystem efsSystem = EFSSystem.INSTANCE;
                foreach (string arg in args)
                {
                    Console.Out.WriteLine("Loading dictionary " + arg);
                    Dictionary dictionary = Util.load(arg, efsSystem);
                    if (dictionary == null)
                    {
                        Console.Out.WriteLine("Cannot load dictionary " + arg);
                        return(-1);
                    }
                }

                // Perform functional test for each loaded dictionary
                foreach (Dictionary dictionary in efsSystem.Dictionaries)
                {
                    Console.Out.WriteLine("Processing tests from dictionary " + dictionary.Name);
                    foreach (DataDictionary.Tests.Frame frame in dictionary.Tests)
                    {
                        Console.Out.WriteLine("Executing frame " + frame.FullName);
                        foreach (DataDictionary.Tests.SubSequence subSequence in frame.SubSequences)
                        {
                            Console.Out.WriteLine("Executing sub sequence " + subSequence.FullName);
                            DataDictionary.Tests.Runner.Runner runner = new DataDictionary.Tests.Runner.Runner(subSequence);
                            runner.RunUntilStep(null);

                            bool failed = false;
                            foreach (DataDictionary.Tests.Runner.Events.Expect expect in runner.FailedExpectations())
                            {
                                Console.Out.WriteLine(" failed : " + expect.Message);
                                DataDictionary.Tests.TestCase testCase = Utils.EnclosingFinder <DataDictionary.Tests.TestCase> .find(expect.Expectation);

                                if (testCase.ImplementationCompleted)
                                {
                                    Console.Out.WriteLine(" !Unexpected failed expectation: " + expect.Message);
                                    failed = true;
                                }
                                else
                                {
                                    Console.Out.WriteLine(" .Expected failed expectation: " + expect.Message);
                                }
                            }
                            if (failed)
                            {
                                Console.Out.WriteLine("  -> Failed");
                                retVal = -1;
                            }
                            else
                            {
                                Console.Out.WriteLine("  -> Success");
                            }
                        }
                    }
                }
            }
            finally
            {
                DataDictionary.Util.UnlockAllFiles();
            }

            return(retVal);
        }
コード例 #23
0
        private void verifyInputForGamma(TestCase aTestCase, Workbook workbook)
        {
            Step aStep = new Step();
            aStep.Name = "Step1 - Verify input";
            aTestCase.AddModelElement(aStep);

            /*********************************** TRAIN DATA ***********************************/
            SubStep aSubStep = new SubStep();
            aSubStep.Name = "SubStep1 - Train data";
            aStep.AddModelElement(aSubStep);

            addAction(aSubStep, "Kernel.SpeedAndDistanceMonitoring.ReleaseSpeedMonitoring.UpdateReleaseSpeed()");
            addExpectation(aSubStep,
                "Kernel.TrainData.BrakingParameters.ConversionModel.ConversionModelIsUsed() == False");
        }
コード例 #24
0
        private void verifyInputForLambda(TestCase aTestCase, Workbook workbook)
        {
            Step aStep = new Step();
            aStep.Name = "Step1 - Verify input";
            aTestCase.AddModelElement(aStep);

            /*********************************** TRAIN DATA ***********************************/
            SubStep aSubStep = new SubStep();
            aSubStep.Name = "SubStep1 - Train data";
            aStep.AddModelElement(aSubStep);

            addAction(aSubStep, "Kernel.TrainData.BrakingParameters.ConversionModel.Initialize()");
            addAction(aSubStep, "Kernel.SpeedAndDistanceMonitoring.ReleaseSpeedMonitoring.UpdateReleaseSpeed()");
            addExpectation(aSubStep,
                "Kernel.TrainData.BrakingParameters.ConversionModel.ConversionModelIsUsed() == True");

            /********************************* BRAKE PARAMETERS *********************************/
            aSubStep = new SubStep();
            aSubStep.Name = "SubStep2 - Brake parameters";
            aStep.AddModelElement(aSubStep);

            Worksheet aWorksheet = workbook.Sheets[5] as Worksheet;

            Range aRange = aWorksheet.UsedRange;

            addAction(aSubStep, "Kernel.SpeedAndDistanceMonitoring.TargetSpeedMonitoring.InitializeTimeIntervals()");

            /* Verifying kto */
            addExpectation(aSubStep,
                String.Format(CultureInfo.InvariantCulture,
                    "Kernel.TrainData.BrakingParameters.ConversionModel.kto() == {0:0.0#}",
                    (double)(aRange.Cells[7, 6] as Range).Value2));

            if (TargetSpeed == 0)
            /* In this case, the values of T_brake_emergency_cmt and T_brake_service_cmt do not make sense (3.13.3.4.4.1) */
            {
                /* Verifying T_brake_emergency_cm0 */
                addExpectation(aSubStep,
                    String.Format(CultureInfo.InvariantCulture,
                        "Kernel.TrainData.BrakingParameters.ConversionModel.T_brake_emergency_cm0 == {0:0.0#}",
                        (double)(aRange.Cells[8, 6] as Range).Value2));

                /* Verifying T_brake_service_cm0 */
                addExpectation(aSubStep,
                    String.Format(CultureInfo.InvariantCulture,
                        "Kernel.TrainData.BrakingParameters.ConversionModel.T_brake_service_cm0 == {0:0.0#}",
                        (double)(aRange.Cells[10, 6] as Range).Value2));
            }
            else
            /* In this case, the values of T_brake_emergency_cm0 and T_brake_service_cm0 do not make sense (3.13.3.4.4.1) */
            {
                /* Verifying T_brake_emergency_cmt */
                addExpectation(aSubStep,
                    String.Format(CultureInfo.InvariantCulture,
                        "Kernel.TrainData.BrakingParameters.ConversionModel.T_brake_emergency_cmt == {0:0.0#}",
                        (double)(aRange.Cells[9, 6] as Range).Value2));

                /* Verifying T_brake_service_cmt */
                addExpectation(aSubStep,
                    String.Format(CultureInfo.InvariantCulture,
                        "Kernel.TrainData.BrakingParameters.ConversionModel.T_brake_service_cmt == {0:0.0#}",
                        (double)(aRange.Cells[11, 6] as Range).Value2));
            }

            /* Verifying T_be */
            addExpectation(aSubStep,
                String.Format(CultureInfo.InvariantCulture, "Kernel.TrainData.BrakingParameters.T_be() == {0:0.0#}",
                    (double)(aRange.Cells[12, 6] as Range).Value2));

            /* Verifying T_bs */
            addExpectation(aSubStep,
                String.Format(CultureInfo.InvariantCulture, "Kernel.TrainData.BrakingParameters.T_bs() == {0:0.0#}",
                    (double)(aRange.Cells[13, 6] as Range).Value2));

            /********************* BRAKE PARAMETERS (A_brake_emergency) *********************/
            aSubStep = new SubStep();
            aSubStep.Name = "SubStep3 - Brake parameters (A_brake_emergency)";
            aStep.AddModelElement(aSubStep);

            /* Verifying A_brake_emergency */
            double doubleValue = -1;
            double temp;
            for (int i = 16; i <= 27; i++)
            {
                temp = (double)(aRange.Cells[i, 10] as Range).Value2;
                if (doubleValue != temp)
                {
                    if (doubleValue != -1)
                    {
                        addExpectation(aSubStep,
                            String.Format(CultureInfo.InvariantCulture,
                                "ERA_BrakingCurvesVerification.Compare\n(\n    Val1 => Kernel.TrainData.BrakingParameters.ConversionModel.A_brake_emergency(V => {0:0.0########}),\n    Val2 => {1:0.0########}\n)",
                                (double)(aRange.Cells[i, 9] as Range).Value2 - 0.000000001, doubleValue));
                    }
                    doubleValue = temp;
                    double speedValue = (double)(aRange.Cells[i, 9] as Range).Value2;
                    if (Math.Abs(speedValue - Math.Round(speedValue, 8)) > 0)
                    {
                        speedValue += 0.000000001;
                    }
                    addExpectation(aSubStep,
                        String.Format(CultureInfo.InvariantCulture,
                            "ERA_BrakingCurvesVerification.Compare\n(\n    Val1 => Kernel.TrainData.BrakingParameters.ConversionModel.A_brake_emergency(V => {0:0.0########}),\n    Val2 => {1:0.0########}\n)",
                            speedValue, doubleValue));
                }
            }

            /* Verifying V_lim EBI */
            addExpectation(aSubStep,
                String.Format(CultureInfo.InvariantCulture,
                    "ERA_BrakingCurvesVerification.Compare\n(\n    Val1 => Kernel.TrainData.BrakingParameters.ConversionModel.A_brake_emergency.Val1.SpeedStep,\n    Val2 => {0:0.0########}\n)",
                    (double)(aRange.Cells[17, 9] as Range).Value2));

            /*********************** BRAKE PARAMETERS (A_brake_service) ***********************/
            aSubStep = new SubStep();
            aSubStep.Name = "SubStep4 - Brake parameters (A_brake_service)";
            aStep.AddModelElement(aSubStep);

            /* Verifying A_brake_service */
            doubleValue = -1;
            for (int i = 16; i <= 27; i++)
            {
                temp = (double)(aRange.Cells[i, 14] as Range).Value2;
                if (doubleValue != temp)
                {
                    if (doubleValue != -1)
                    {
                        addExpectation(aSubStep,
                            String.Format(CultureInfo.InvariantCulture,
                                "ERA_BrakingCurvesVerification.Compare\n(\n    Val1 => Kernel.TrainData.BrakingParameters.ConversionModel.A_brake_service(V => {0:0.0########}),\n    Val2 => {1:0.0########}\n)",
                                (double)(aRange.Cells[i, 13] as Range).Value2 - 0.000000001, doubleValue));
                    }
                    doubleValue = temp;
                    double speedValue = (double)(aRange.Cells[i, 13] as Range).Value2;
                    if (Math.Abs(speedValue - Math.Round(speedValue, 8)) > 0)
                    {
                        speedValue += 0.000000001;
                    }
                    addExpectation(aSubStep,
                        String.Format(CultureInfo.InvariantCulture,
                            "ERA_BrakingCurvesVerification.Compare\n(\n    Val1 => Kernel.TrainData.BrakingParameters.ConversionModel.A_brake_service(V => {0:0.0########}),\n    Val2 => {1:0.0########}\n)",
                            speedValue, doubleValue));
                }
            }

            /* Verifying V_lim BS */
            addExpectation(aSubStep,
                String.Format(CultureInfo.InvariantCulture,
                    "ERA_BrakingCurvesVerification.Compare\n(\n    Val1 => Kernel.TrainData.BrakingParameters.ConversionModel.A_brake_service.Val1.SpeedStep,\n    Val2 => {0:0.0########}\n)",
                    (double)(aRange.Cells[17, 13] as Range).Value2));
        }
コード例 #25
0
        private void verifyOutputForTrains(bool trainIsGamma, TestCase aTestCase, Workbook aWorkbook)
        {
            int sheet_number;
            if (trainIsGamma)
            {
                sheet_number = 11;
            }
            else
            {
                sheet_number = 13;
            }
            if (aWorkbook.Sheets.Count >= sheet_number && sheet_number != -1)
            {
                Worksheet TrainData = aWorkbook.Sheets[2] as Worksheet;
                Range TargetRange = TrainData.UsedRange;
                double TargetDistance = (double)(TargetRange.Cells[3, 2] as Range).Value2;
                double TargetSpeed = (double)(TargetRange.Cells[2, 2] as Range).Value2;

                Worksheet worksheet = aWorkbook.Sheets[sheet_number] as Worksheet;
                List<double> speedValues = new List<double>();
                List<double> aSafeValues = new List<double>();
                List<double> aExpectedValues = new List<double>();
                List<double> ebdValues = new List<double>();
                List<double> sbdValues = new List<double>();
                List<double> ebiValues = new List<double>();
                List<double> sbi1Values = new List<double>();
                List<double> sbi2Values = new List<double>();
                List<double> warningValues = new List<double>();
                List<double> permittedValues = new List<double>();
                List<double> indicationValues = new List<double>();

                Range testRange = worksheet.UsedRange;
                double val;
                object obj;
                double lastAddedSpeedValue = double.MinValue;
                for (int i = 2; i <= testRange.Rows.Count; i++)
                {
                    val = (double)(testRange.Cells[i, 14] as Range).Value2;
                    if (val - lastAddedSpeedValue >= SpeedInterval)
                    {
                        lastAddedSpeedValue = val;
                        speedValues.Add(val);

                        if (trainIsGamma) // then we import the values of A_Safe and A_Expected
                        {
                            obj = (testRange.Cells[i, 16] as Range).Value2;
                            val = obj == null ? -1 : (double)obj;
                            aSafeValues.Add(val);

                            obj = (testRange.Cells[i, 17] as Range).Value2;
                            val = obj == null ? -1 : (double)obj;
                            aExpectedValues.Add(val);
                        }

                        if (FillEBD)
                        {
                            obj = (testRange.Cells[i, 18] as Range).Value2;
                            val = obj == null ? -1 : (double)obj;
                            ebdValues.Add(val);
                        }
                        if (FillSBD)
                        {
                            obj = (testRange.Cells[i, 19] as Range).Value2;
                            val = obj == null ? -1 : (double)obj;
                            sbdValues.Add(val);
                        }
                        if (FillEBI)
                        {
                            obj = (testRange.Cells[i, 20] as Range).Value2;
                            val = obj == null ? -1 : (double)obj;
                            ebiValues.Add(val);
                        }
                        if (FillSBI1)
                        {
                            obj = (testRange.Cells[i, 21] as Range).Value2;
                            val = obj == null ? -1 : (double)obj;
                            sbi1Values.Add(val);
                        }
                        if (FillSBI2)
                        {
                            obj = (testRange.Cells[i, 22] as Range).Value2;
                            val = obj == null ? -1 : (double)obj;
                            sbi2Values.Add(val);
                        }
                        if (FillWarning)
                        {
                            obj = (testRange.Cells[i, 24] as Range).Value2;
                            val = obj == null ? -1 : (double)obj;
                            warningValues.Add(val);
                        }
                        if (FillPermitted)
                        {
                            obj = (testRange.Cells[i, 25] as Range).Value2;
                            val = obj == null ? -1 : (double)obj;
                            permittedValues.Add(val);
                        }
                        if (FillIndication)
                        {
                            obj = (testRange.Cells[i, 26] as Range).Value2;
                            val = obj == null ? -1 : (double)obj;
                            indicationValues.Add(val);
                        }
                    }
                }

                int stepNumber = 1;

                string target =
                    "Kernel.SpeedAndDistanceMonitoring.TargetSpeedMonitoring.Target {{\n                Speed => " +
                    TargetSpeed + ".0,\n                Location => " + TargetDistance +
                    ".0,\n                Length => Default.BaseTypes.Length.Infinity }}";

                if (trainIsGamma) // then we create steps for A_Safe and A_Expected
                {
                    if (FillEBD)
                    {
                        fillBrakingParametersExpectations(aTestCase,
                            stepNumber++,
                            "A_Safe",
                            "ERA_BrakingCurvesVerification.CompareAcceleration\n(\n    Val1 => Kernel.TrainData.BrakingParameters.A_safe (\n        d => ERA_BrakingCurvesVerification.ConvertTargetDistance (\n            aTarget => " +
                            target + ",\n            d => {0:0.0}),\n        V => {1:0.0}),\n    Val2 => {2:0.0####}\n)",
                            ebdValues,
                            speedValues,
                            aSafeValues);
                    }
                    if (FillSBD)
                    {
                        fillBrakingParametersExpectations(aTestCase,
                            stepNumber++,
                            "A_Expected",
                            "ERA_BrakingCurvesVerification.CompareAcceleration\n(\n    Val1 => Kernel.TrainData.BrakingParameters.A_expected (\n        d => ERA_BrakingCurvesVerification.ConvertTargetDistance (\n            aTarget => " +
                            target + ",\n            d => {0:0.0}),\n        V => {1:0.0}),\n    Val2 => {2:0.0####}\n)",
                            sbdValues,
                            speedValues,
                            aExpectedValues);
                    }
                }

                if (FillEBD)
                {
                    fillBrakingCurvesExpectations(aTestCase,
                        stepNumber++,
                        "EBD",
                        "ERA_BrakingCurvesVerification.Compare\n(\n    Val1 => ERA_BrakingCurvesVerification.EBDDistanceFromTarget (\n        aTarget => " +
                        target + ",\n        aSpeed => {0:0.0#} ),\n    Val2 => {1:0.0#}\n)",
                        speedValues,
                        ebdValues);

                    /*fillBrakingCurvesExpectations(aTestCase, => first
                                     "EBD",
                                     "ERA_BrakingCurvesVerification.Compare\n(\n    Val1 => Kernel.SpeedAndDistanceMonitoring.TargetSpeedMonitoring.EBD\n    (\n        Distance => ERA_BrakingCurvesVerification.ConvertTargetDistance ( {1:0.0#} )\n    ),\n    Val2 => {0:0.0#}\n)",
                                     speedValues,
                                     ebdValues);

                    fillBrakingCurvesExpectations(aTestCase, => second
                                     "EBD",
                                     "ERA_BrakingCurvesVerification.Compare\n(\n    Val1 => Kernel.SpeedAndDistanceMonitoring.TargetSpeedMonitoring.EBD_Target\n    (\n        Distance => ERA_BrakingCurvesVerification.ConvertTargetDistance ( {1:0.0#} ),\n        aTarget => Kernel.MA.ClosestEOA()\n    ),\n    Val2 => {0:0.0#}\n)",
                                     speedValues,
                                     ebdValues);*/
                }
                if (FillSBD)
                {
                    fillBrakingCurvesExpectations(aTestCase,
                        stepNumber++,
                        "SBD",
                        "ERA_BrakingCurvesVerification.Compare\n(\n    Val1 => Kernel.SpeedAndDistanceMonitoring.TargetSpeedMonitoring.SupervisionStatus.SBD_Target\n    (\n        Distance => ERA_BrakingCurvesVerification.ConvertTargetDistance (\n            aTarget => " +
                        target + ",\n            d => {1:0.0#}),\n        aTarget => " + target +
                        "\n    ),\n    Val2 => {0:0.0#}\n)",
                        speedValues,
                        sbdValues);
                }
                if (FillEBI)
                {
                    fillBrakingCurvesExpectations(aTestCase,
                        stepNumber++,
                        "EBI",
                        "ERA_BrakingCurvesVerification.Compare\n(\n    Val1 => ERA_BrakingCurvesVerification.EBIDistanceFromTarget (\n        aTarget => Kernel.SpeedAndDistanceMonitoring.TargetSpeedMonitoring.Target {{\n                Speed => " +
                        TargetSpeed + ".0,\n                Location => " + TargetDistance +
                        ".0,\n                Length => Default.BaseTypes.Length.Infinity }},\n        aSpeed => {0:0.0#} ),\n    Val2 => {1:0.0#}\n)",
                        speedValues,
                        ebiValues);
                }
                if (FillSBI1)
                {
                    fillBrakingCurvesExpectations(aTestCase,
                        stepNumber++,
                        "SBI1",
                        "ERA_BrakingCurvesVerification.Compare\n(\n    Val1 => Kernel.SpeedAndDistanceMonitoring.TargetSpeedMonitoring.SupervisionStatus.d_SBI1_Target\n    (\n        Vest  => {0:0.0#},\n        aTarget => " +
                        target +
                        "\n    ),\n    Val2 => ERA_BrakingCurvesVerification.ConvertTargetDistance (\n        aTarget => " +
                        target + ",\n        d => {1:0.0#} )\n)",
                        speedValues,
                        sbi1Values);
                }
                if (FillSBI2)
                {
                    fillBrakingCurvesExpectations(aTestCase,
                        stepNumber++,
                        "SBI2",
                        "ERA_BrakingCurvesVerification.Compare\n(\n    Val1 => ERA_BrakingCurvesVerification.SBIDistanceFromTarget (\n        aTarget => Kernel.SpeedAndDistanceMonitoring.TargetSpeedMonitoring.Target {{\n                Speed => " +
                        TargetSpeed + ".0,\n                Location => " + TargetDistance +
                        ".0,\n                Length => Default.BaseTypes.Length.Infinity }},\n         aSpeed => {0:0.0#} ),\n    Val2 => {1:0.0#}\n)",
                        speedValues,
                        sbi2Values);
                }
                if (FillWarning)
                {
                    fillBrakingCurvesExpectations(aTestCase,
                        stepNumber++,
                        "Warning",
                        "ERA_BrakingCurvesVerification.Compare\n(\n    Val1 => ERA_BrakingCurvesVerification.WarningDistanceFromTarget (\n        aSpeed  => {0:0.0#},\n        aTarget => " +
                        target + "\n    ),\n    Val2 => {1:0.0#}\n)",
                        speedValues,
                        warningValues);
                }
                if (FillPermitted)
                {
                    fillBrakingCurvesExpectations(aTestCase,
                        stepNumber++,
                        "Permitted",
                        "ERA_BrakingCurvesVerification.Compare\n(\n    Val1 => ERA_BrakingCurvesVerification.PermittedDistanceFromTarget (\n        aSpeed  => {0:0.0#},\n        aTarget => " +
                        target + "\n    ),\n    Val2 => {1:0.0#}\n)",
                        speedValues,
                        permittedValues);
                }
                if (FillIndication)
                {
                    fillBrakingCurvesExpectations(aTestCase,
                        stepNumber++,
                        "Indication",
                        "ERA_BrakingCurvesVerification.Compare\n(\n    Val1 => ERA_BrakingCurvesVerification.IndicationDistanceFromTarget (\n        aSpeed  => {0:0.0#},\n        aTarget => " +
                        target + "\n    ),\n    Val2 => {1:0.0#}\n)",
                        speedValues,
                        indicationValues);
                }
            }
            else
            {
                if (sheet_number == -1)
                {
                    Log.ErrorFormat("Incorrect train type selected!!");
                }
                else
                {
                    Log.ErrorFormat("Incorrect number of sheets in the excel document!!");
                }
            }
        }
コード例 #26
0
        /// <summary>
        /// Imports the steps in a sub sequence
        /// </summary>
        /// <param name="subSequence"></param>
        private void importSteps(DataDictionary.Tests.SubSequence subSequence)
        {
            string sql = "SELECT TCSOrder, Distance, FT_NUMBER, TC_NUMBER, ST_STEP, ST_DESCRIPTION, UserComment, ST_IO, ST_INTERFACE, ST_COMMENTS, TestLevelIn, TestLevelOut, TestModeIn, TestModeOut FROM TSW_TCStep ORDER BY TCSOrder";

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

            adapter.Fill(dataSet);
            if (dataSet.Tables.Count > 0)
            {
                DataDictionary.Tests.TestCase testCase = null;

                foreach (DataRow dataRow in dataSet.Tables[0].Rows)
                {
                    object[] items        = dataRow.ItemArray;
                    int      order        = (int)items[0];
                    int      distance     = (int)items[1];
                    int      feature      = (int)items[2];
                    int      testCaseNr   = (int)items[3];
                    string   stepType     = items[4] as string;
                    string   description  = items[5] as string;
                    string   userComment  = items[6] as string;
                    string   io           = items[7] as string;
                    string   intrface     = items[8] as string;
                    string   comment      = items[9] as string;
                    string   testLevelIn  = items[10] as string;
                    string   testLevelOut = items[11] as string;
                    string   testModeIn   = items[12] as string;
                    string   testModeOut  = items[13] as string;

                    // we do not want to import steps "Followed by" or "Preceded by"
                    if (io != null && stepType != null && !stepType.Equals("Followed by") && !stepType.Equals("Preceded by"))
                    {
                        if (testCase != null)
                        {
                            if (testCase.getFeature() != feature || testCase.getCase() != testCaseNr)
                            {
                                testCase = null;
                            }
                        }

                        if (testCase == null)
                        {
                            testCase      = (DataDictionary.Tests.TestCase)DataDictionary.Generated.acceptor.getFactory().createTestCase();
                            testCase.Name = "Feature " + feature + " Test case " + testCaseNr;
                            testCase.setCase(testCaseNr);
                            testCase.setFeature(feature);
                            subSequence.appendTestCases(testCase);
                        }

                        DataDictionary.Tests.Step step = (DataDictionary.Tests.Step)DataDictionary.Generated.acceptor.getFactory().createStep();
                        step.Name = "Step " + order;
                        step.setTCS_Order(order);
                        step.setDistance(distance);
                        step.setDescription(description);
                        step.setUserComment(userComment);
                        step.setIO_AsString(io);
                        if (intrface != null)
                        {
                            step.setInterface_AsString(intrface);
                        }
                        step.setComment(comment);
                        if (testLevelIn != null)
                        {
                            step.setLevelIN_AsString(testLevelIn);
                        }
                        if (testLevelOut != null)
                        {
                            step.setLevelOUT_AsString(testLevelOut);
                        }
                        if (testModeIn != null)
                        {
                            step.setModeIN_AsString(testModeIn);
                        }
                        if (testModeOut != null)
                        {
                            step.setModeOUT_AsString(testModeOut);
                        }
                        step.setTranslationRequired(true);

                        importStepMessages(step);

                        testCase.appendSteps(step);
                    }
                }
            }
            else
            {
                Log.Error("Cannot find sub sequence table in database");
            }
        }
コード例 #27
0
 /// <summary>
 /// Creates a table entry for a test case
 /// </summary>
 /// <param name="testCase"></param>
 private void IntroduceTestCase(TestCase testCase)
 {
     Report.AddRow(testCase.Name);
     Report.SetLastRowColor(Colors.LightBlue);
     ReportIssue(testCase);
 }