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;
        }
        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));
        }
        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);
        }