Start() private method

private Start ( ) : void
return void
        public override void Initialize()
        {
            // General section
            VACMAPresent  = GetBoolParameter("General", "VACMAPresent", true);
            RSPresent     = GetBoolParameter("General", "RSPresent", true);
            DAATPresent   = GetBoolParameter("General", "DAATPresent", false);
            TVM300Present = GetBoolParameter("General", "TVM300Present", false);

            // RS section
            RSDelayBeforeEmergencyBrakingS = GetFloatParameter("RS", "DelayBeforeEmergencyBrakingS", 4f);
            RSBlinkerFrequencyHz           = GetFloatParameter("RS", "BlinkerFrequencyHz", 1f);

            // TVM common section
            TVMCOVITInhibited = GetBoolParameter("TVM", "CovitInhibited", false);

            // TVM300 section
            TVM300TrainSpeedLimitMpS = MpS.FromKpH(GetFloatParameter("TVM300", "TrainSpeedLimitKpH", 300f));

            // VACMA section
            VACMAActivationSpeedMpS      = MpS.FromKpH(GetFloatParameter("VACMA", "ActivationSpeedKpH", 3f));
            VACMAReleasedAlertDelayS     = GetFloatParameter("VACMA", "ReleasedAlertDelayS", 2.5f);
            VACMAReleasedEmergencyDelayS = GetFloatParameter("VACMA", "ReleasedEmergencyDelayS", 5f);
            VACMAPressedAlertDelayS      = GetFloatParameter("VACMA", "PressedAlertDelayS", 55f);
            VACMAPressedEmergencyDelayS  = GetFloatParameter("VACMA", "PressedEmergencyDelayS", 60f);

            // Variables initialization
            RSBlinker = new Blinker(this);
            RSBlinker.Setup(RSBlinkerFrequencyHz);
            RSBlinker.Start();
            RSEmergencyTimer = new Timer(this);
            RSEmergencyTimer.Setup(RSDelayBeforeEmergencyBrakingS);
            VACMAPressedAlertTimer = new Timer(this);
            VACMAPressedAlertTimer.Setup(VACMAPressedAlertDelayS);
            VACMAPressedEmergencyTimer = new Timer(this);
            VACMAPressedEmergencyTimer.Setup(VACMAPressedEmergencyDelayS);
            VACMAReleasedAlertTimer = new Timer(this);
            VACMAReleasedAlertTimer.Setup(VACMAReleasedAlertDelayS);
            VACMAReleasedEmergencyTimer = new Timer(this);
            VACMAReleasedEmergencyTimer.Setup(VACMAReleasedEmergencyDelayS);

            // Cabview control names initialization
            SetCustomizedCabviewControlName(BP_AC_SF, "BP (AC) SF : Acquittement / Acknowledge");
            SetCustomizedCabviewControlName(BP_A_LS_SF, "BP (A) LS (SF) : Annulation LS (SF) / Cancel LS (SF)");
            SetCustomizedCabviewControlName(Z_ES_VA, "Z (ES) VA : Essai VACMA / Alerter test");
            SetCustomizedCabviewControlName(BP_AM_V1, "BP AM V1 : Armement manuel TVM voie 1 / TVM manual arming track 1");
            SetCustomizedCabviewControlName(BP_AM_V2, "BP AM V2 : Armement manuel TVM voie 2 / TVM manual arming track 2");
            SetCustomizedCabviewControlName(BP_DM, "BP DM : Désarmement manuel TVM / TVM manual dearming");
            SetCustomizedCabviewControlName(LS_SF, "LS (SF) : Signal Fermé / Closed Signal");
            SetCustomizedCabviewControlName(TVM_Mask, "Masque TVM / TVM mask");

            Activated = true;

            SetNextSignalAspect(Aspect.Clear_1);
        }
        protected void UpdateRS()
        {
            if (RSPresent && IsSpeedControlEnabled())
            {
                // If train is about to cross a normal signal, get its information.
                float  nextNormalSignalDistance = NextSignalDistanceM(0);
                Aspect nextNormalSignalAspect   = Aspect.None;
                if (nextNormalSignalDistance <= 5f)
                {
                    nextNormalSignalAspect = NextSignalAspect(0);
                }

                // If train is about to cross a distant signal, get its information.
                float  nextDistantSignalDistance = NextDistanceSignalDistanceM();
                Aspect nextDistantSignalAspect   = Aspect.None;
                if (nextDistantSignalDistance <= 5f)
                {
                    nextDistantSignalAspect = NextDistanceSignalAspect();
                    // Hack for Swiss signals : only approach and clear aspects are allowed on distant signals
                    if (nextDistantSignalAspect > Aspect.Approach_1)
                    {
                        nextDistantSignalAspect = Aspect.Approach_1;
                    }
                }

                if (nextNormalSignalAspect != Aspect.None || nextDistantSignalAspect != Aspect.None)
                {
                    RSLastSignalAspect = Max(nextNormalSignalAspect, nextDistantSignalAspect);
                }

                RSClosedSignal = RSOpenedSignal = false;

                if ((NormalSignalPassed || DistantSignalPassed) &&
                    !RSType1Inhibition &&
                    !TVMArmed &&
                    SpeedMpS() > 0.1f)
                {
                    if (RSLastSignalAspect == Aspect.Stop ||
                        RSLastSignalAspect == Aspect.StopAndProceed ||
                        RSLastSignalAspect == Aspect.Restricted ||
                        RSLastSignalAspect == Aspect.Approach_1 ||
                        RSLastSignalAspect == Aspect.Approach_2 ||
                        RSLastSignalAspect == Aspect.Approach_3
                        )
                    {
                        RSClosedSignal = true;
                    }
                    else
                    {
                        RSOpenedSignal = true;
                    }
                }

                if ((RSClosedSignal && !RSType2Inhibition) || (TVMClosedSignal && !RSType3Inhibition))
                {
                    if (RSPressed)
                    {
                        RSState = RSStateType.TriggeredBlinking;
                    }
                    else
                    {
                        RSEmergencyTimer.Start();
                        RSState = RSStateType.TriggeredSounding;
                    }
                }

                if (RSOpenedSignal || TVMOpenedSignal || RSCancelPressed)
                {
                    RSEmergencyTimer.Stop();
                    RSState = RSStateType.Off;
                }

                switch (RSState)
                {
                case RSStateType.Off:
                    if (RSBlinker.Started)
                    {
                        RSBlinker.Stop();
                    }
                    SetCabDisplayControl(LS_SF, 0);
                    break;

                case RSStateType.TriggeredSounding:
                    if (!RSBlinker.Started)
                    {
                        RSBlinker.Start();
                    }
                    SetCabDisplayControl(LS_SF, RSBlinker.On ? 1 : 0);

                    if (!RSPressed && RSPreviousPressed)
                    {
                        RSEmergencyTimer.Stop();
                        RSState = RSStateType.TriggeredBlinking;
                    }
                    break;

                case RSStateType.TriggeredBlinking:
                    if (!RSBlinker.Started)
                    {
                        RSBlinker.Start();
                    }
                    SetCabDisplayControl(LS_SF, RSBlinker.On ? 1 : 0);
                    break;
                }

                if (RSEmergencyTimer.Triggered)
                {
                    RSEmergencyBraking = true;
                }
                else if (RearmingButton)
                {
                    RSEmergencyBraking = false;
                }

                if (RSClosedSignal && !RSPreviousClosedSignal && !RSType1Inhibition)
                {
                    TriggerSoundPenalty1();
                }

                if (RSOpenedSignal && !RSPreviousOpenedSignal && !RSType1Inhibition)
                {
                    TriggerSoundPenalty2();
                    TriggerSoundInfo1();
                }

                RSPreviousClosedSignal = RSClosedSignal;
                RSPreviousOpenedSignal = RSOpenedSignal;

                if (TVM300Present)
                {
                    if (TVMClosedSignal && !TVMPreviousClosedSignal)
                    {
                        TriggerSoundPenalty1();
                    }

                    if (TVMOpenedSignal && !TVMPreviousOpenedSignal)
                    {
                        TriggerSoundPenalty2();
                        TriggerSoundInfo1();
                    }

                    TVMPreviousClosedSignal = TVMClosedSignal;
                    TVMPreviousOpenedSignal = TVMOpenedSignal;
                }

                if ((!RSPressed && RSPreviousPressed) || RSCancelPressed)
                {
                    TriggerSoundPenalty2();
                }

                RSPreviousPressed = RSPressed;
            }
        }