Example #1
0
        public override void trainEvent(TrainEvent _event)
        {
            VirtualKeys key;

            if (_event.getEventType() == EventTypes.EventTypeBlowHorn ||
                _event.getEventType() == EventTypes.EventTypeChangeBrake ||
                _event.getEventType() == EventTypes.EventTypeChangeDoors ||
                _event.getEventType() == EventTypes.EventTypeChangePower ||
                _event.getEventType() == EventTypes.EventTypeSwitchReverser)
            {
                time = globalTime;
            }

            if (_event.getEventType() == EventTypes.EventTypeKeyDown)
            {
                key = (VirtualKeys) _event.getEventData();

                if (key == VirtualKeys.S && !hold)
                    resetHolding();
            }

            if (_event.getEventType() == EventTypes.EventTypeKeyUp)
            {
                key = (VirtualKeys) _event.getEventData();

                if (key == VirtualKeys.S)
                {
                    hold = false;
                    time = globalTime;
                }
            }
        }
Example #2
0
        public override void trainEvent(TrainEvent _event)
        {
            if (_event.getEventType() == EventTypes.EventTypeChangeSignalAspect)
            {
                OpenBveApi.Runtime.SignalData[] signal = (OpenBveApi.Runtime.SignalData[]) _event.getEventData();

                /* The first condition ensures that the train is really crossing a signal, and
                 * that is not an other signal whose aspect is changing. */

                if (System.Math.Abs(signal[0].Distance) < signalCrossingDistance)
                {
                    if (signal[0].Aspect <= signalAspectForConsideringClosed)
                        this.crossingClosedSignal();
                    else
                    {
                        controlManager.stopBlinking(cabControls.LSSF);
                        controlManager.setState(cabControls.LSSF, 0);
                    }
                }
            }

            if (_event.getEventType() == EventTypes.EventTypeGetBeacon)
            {
                OpenBveApi.Runtime.BeaconData beacon = (OpenBveApi.Runtime.BeaconData) _event.getEventData();

                if (beacon.Type == Beacons.RepeatedSignal)
                    this.crossingClosedSignal();
            }

            if (_event.getEventType() == EventTypes.EventTypeKeyDown)
            {
                OpenBveApi.Runtime.VirtualKeys key = (OpenBveApi.Runtime.VirtualKeys) _event.getEventData();
                if (key == ackKey)
                {
                    if (closedSignal)
                    {
                        controlManager.stopBlinking(cabControls.LSSF);
                        controlManager.setState(cabControls.LSSF, 1);
                    }
                    this.reset();
                }
            }
        }
Example #3
0
        public override void trainEvent(TrainEvent _event)
        {
            if (_event.getEventType() == EventTypes.EventTypeGetBeacon)
            {
                BeaconData beacon = (BeaconData) _event.getEventData();

                if (beacon.Type == Beacons.KvbControl)
                {
                    if (beacon.Optional == KvbEnable && !enabled)
                    {
                        controlManager.setState(cabControls.GreenKVB, (int) GreenKvbAspects.running);
                        controlManager.setState(cabControls.YellowKVB, (int) YellowKvbAspects.running);
                        reset();
                        enabled = true;
                    }
                    else if (beacon.Optional == KvbDisable)
                    {
                        controlManager.setState(cabControls.GreenKVB, (int) GreenKvbAspects.none);
                        controlManager.setState(cabControls.YellowKVB, (int) YellowKvbAspects.none);
                        enabled = false;
                    }
                }

                if (enabled)
                {
                    if (beacon.Type == Beacons.Signal)
                    {
                        if (beacon.Signal.Aspect == 0)
                            stopTrain();
                        else if (beacon.Signal.Aspect <= ClosedSignal.signalAspectForConsideringClosed)
                            signalAspect = false;
                        else
                            signalAspect = true;
                    }

                    if (beacon.Type == Beacons.NextSignal)
                    {
                        if (!signalAspect)
                        {
                            controlManager.setState(cabControls.GreenKVB, (int) GreenKvbAspects.none);
                            if (beacon.Optional >= 0)
                            {
                                speedLimiter.startDecelerationControl(currentSpeed, location, location + (int) Math.Round(beacon.Signal.Distance), DecelerationControlType.low);
                                controlManager.setState(cabControls.YellowKVB, (int) YellowKvbAspects.double0);
                            }
                            else
                            {
                                speedLimiter.startDecelerationControl(currentSpeed, location, (int) Math.Round(beacon.Signal.Distance), DecelerationControlType.strong);
                                controlManager.setState(cabControls.YellowKVB, (int) YellowKvbAspects.triple0);
                            }
                        }
                        else
                        {
                            speedLimiter.stopDecelerationControl();
                            controlManager.setState(cabControls.GreenKVB, (int) GreenKvbAspects.running);
                            controlManager.setState(cabControls.YellowKVB, (int) YellowKvbAspects.running);
                        }
                    }

                    if (beacon.Type == Beacons.SpeedLimit)
                        newSpeedLimit = new Speed(kmhToMs((double) beacon.Optional));

                    if (beacon.Type == Beacons.TargetDistance)
                        targetDistance = beacon.Optional;

                    if (targetDistance != -1 && newSpeedLimit.KilometersPerHour != -1)
                        speedLimiter.setTargetSpeed(newSpeedLimit,targetDistance);
                }
            }
        }
Example #4
0
 public abstract void trainEvent(TrainEvent _event);