Represents data trasmitted by a beacon.
        internal void SetBeacon(BeaconData beacon)
        {
            if (beacon.Type == BeaconID.TrackGradientMemory.TrackGradientPoint)
            {
                int param_trackPos = Math.Abs(beacon.Optional % 1000000);
                int param_gradient = beacon.Optional / 1000000;

                int idxOfGradientPtAtHere = _gPtC.IndexOf(param_trackPos);

                if (idxOfGradientPtAtHere > -1) {
                    _gPtC[idxOfGradientPtAtHere] = new GradientPoint(param_gradient, param_trackPos);
                } else {
                    _gPtC.Add(new GradientPoint(param_gradient, param_trackPos));
                }

                OnGradientPointsDataRefreshed(_gPtC);
            }
        }
Example #2
0
        internal override void SetBeacon(BeaconData beacon)
        {
            if (beacon.Type == 33) //Distance to stop point
            {
                atoReceivedData = beacon.Optional;
            }

            //Central Line ATP
            if (beacon.Type == 6)
            {
                atoReceivedData = beacon.Optional % 1000;
            }
        }
Example #3
0
 /// <summary>Is called when a beacon is passed.</summary>
 /// <param name="beacon">The beacon data.</param>
 internal override void SetBeacon(BeaconData beacon)
 {
     if (this.State != States.Disabled & this.State != States.Suppressed & this.State != States.Initializing) {
         switch (beacon.Type) {
             case 0:
             case 1:
                 // --- P -> S ---
                 if (beacon.Optional == 0) {
                     if (this.State == States.Normal | this.State == States.Pattern | this.State == States.Brake) {
                         SwitchToSx();
                     }
                 }
                 break;
             case 3:
             case 4:
                 // --- P pattern / P immediate stop ---
                 this.Position = this.Train.State.Location;
                 if (this.State != States.Service & this.State != States.Emergency) {
                     if (this.State == States.Standby & (beacon.Type != 3 | beacon.Optional != -1)) {
                         SwitchToP(States.Normal);
                     }
                     if (this.State != States.Standby) {
                         if (beacon.Signal.Aspect == 0) {
                             this.SignalPattern.SetSignal(this.Position + beacon.Signal.Distance - SignalOffset);
                             if (beacon.Type != 3 & beacon.Signal.Distance < 50.0 & !BrakeRelease) {
                                 SwitchToP(States.Emergency);
                             }
                         } else {
                             this.SignalPattern.Clear();
                         }
                     }
                 }
                 break;
         }
     }
     switch (beacon.Type) {
         case -16777213:
             // --- compatibility temporary pattern ---
             {
                 double limit = (double)(beacon.Optional & 4095) / 3.6;
                 double position = (beacon.Optional >> 12);
                 CompatibilityLimit item = new CompatibilityLimit(limit, position);
                 if (!this.CompatibilityLimits.Contains(item)) {
                     this.CompatibilityLimits.Add(item);
                 }
             }
             break;
         case -16777212:
             // --- compatibility permanent pattern ---
             if (beacon.Optional == 0) {
                 this.CompatibilityPermanentPattern.Clear();
             } else {
                 double limit = (double)beacon.Optional / 3.6;
                 this.CompatibilityPermanentPattern.SetLimit(limit, double.MinValue);
             }
             break;
     }
 }
Example #4
0
        internal void SetBeacon(BeaconData beacon)
        {
            if (beacon.Type == BeaconID.StationsMemory.StationStopProvider)
            {
                int param_doorside = beacon.Optional / 10000000;
                bool param_tbsStart = Math.Abs(beacon.Optional / 1000000 - param_doorside * 10) == 1 ? true : false;
                int param_trackPos = Math.Abs(beacon.Optional - param_doorside * 10000000 - (param_tbsStart ? 1000000 : 0));

                int idxOfStopAtHere = Stations.IndexOf(param_trackPos);

                if (idxOfStopAtHere > -1) {
                    // stop exists
                    Stations[idxOfStopAtHere] = new Station(param_doorside, param_trackPos, param_tbsStart);
                } else {
                    // stop not exist, add one then
                    Stations.Add(new Station(param_doorside, param_trackPos, param_tbsStart));
                }

                OnStationDataRefreshed(Stations);
            }
        }
Example #5
0
File: ATP.cs Project: joeyfoo/SgATC
 internal override void SetBeacon(BeaconData beacon)
 {
     if (beacon.Type == 31) //Target and safety track speeds
     {
         train.atpTrackTargetSpeed = beacon.Optional / 1000;
         train.atpTrackSafetySpeed = beacon.Optional % 1000;
     }
 }
Example #6
0
 internal void SetBeacon(BeaconData beacon)
 {
     switch (beacon.Type) {
         case BeaconID.HKHRATP2.EnDisableCabSignal:
             OnCabSignallingSection = Convert.ToBoolean(beacon.Optional);
             break;
         case BeaconID.HKHRATP2.SpeedFlag:
             if (OnCabSignallingSection && beacon.Optional >= 0) {
                 int speed = beacon.Optional / 1000000;
                 int startloc = beacon.Optional - (speed * 1000000);
                 SpeedFlags.Add(new SpeedFlag(speed, startloc));
                 SpeedFlags.Sort();
             }
             break;
     }
 }
Example #7
0
		/// <summary>Is called when a beacon is passed.</summary>
		/// <param name="beacon">The beacon data.</param>
		internal override void SetBeacon(BeaconData beacon) {
			if (this.State != States.Disabled & this.State != States.Initializing) {
				switch (beacon.Type) {
					case 0:
						// --- Sx long ---
						if (beacon.Signal.Aspect == 0) {
							if (this.State == States.Chime | this.State == States.Normal) {
								this.AlarmCountdown = DurationOfAlarm;
								this.State = States.Alarm;
								UpdateRedSignalLocation(beacon);
							}
						}
						break;
					case 1:
						// --- Sx immediate stop ---
						if (beacon.Signal.Aspect == 0) {
							if (this.State == States.Chime | this.State == States.Normal | this.State == States.Alarm) {
								this.State = States.Emergency;
							}
						}
						break;
					case 2:
						// --- accidental departure ---
						if (beacon.Signal.Aspect == 0 & (beacon.Optional == 0 | beacon.Optional >= this.Train.Specs.Cars)) {
							if (this.State == States.Chime | this.State == States.Normal | this.State == States.Alarm) {
								this.State = States.Emergency;
							}
						}
						break;
				}
			}
		}
Example #8
0
		/// <summary>Is called when the train passes a beacon.</summary>
		/// <param name="beacon">The beacon data.</param>
		public void SetBeacon(BeaconData beacon) {
			// TODO: Your old SetBeaconData code goes here.
		}
Example #9
0
 /// <summary>Is called when the train passes a beacon.</summary>
 /// <param name="beacon">The beacon data.</param>
 public void SetBeacon(BeaconData beacon)
 {
     closedSignalDevice.trainEvent(new TrainEvent(EventTypes.EventTypeGetBeacon, beacon));
     speedControl.trainEvent(new TrainEvent(EventTypes.EventTypeGetBeacon, beacon));
 }
Example #10
0
 public void SetBeacon(BeaconData beacon)
 {
     atp2.SetBeacon(beacon);
     stationsMemory.SetBeacon(beacon);
     trackGradientMemory.SetBeacon(beacon);
 }
 /// <summary>Is called when the train passes a beacon.</summary>
 /// <param name="beacon">The beacon data.</param>
 public void SetBeacon(BeaconData beacon)
 {
     foreach (Script script in this.Scripts) {
         for (int i = 0; i < script.Events.Count; i++) {
             BeaconEvent f = script.Events[i] as BeaconEvent;
             if (f != null && f.Type.IsMember(beacon.Type) && f.Signal.IsMember(beacon.Signal.Aspect)) {
                 f.Trigger();
             }
         }
     }
 }
Example #12
0
 /// <summary>Is called when the train passes a beacon.</summary>
 /// <param name="beacon">The beacon data.</param>
 public void SetBeacon(BeaconData beacon)
 {
     ms.SetBeacon(beacon);
 }
Example #13
0
 internal void SetBeacon(BeaconData beacons)
 {
     foreach (Device device in devices.Values)
     {
         device.SetBeacon(beacons);
     }
 }
Example #14
0
 /// <summary>Is called when a beacon is passed.</summary>
 /// <param name="beacon">The beacon data.</param>
 internal override void SetBeacon(BeaconData beacon)
 {
     switch (beacon.Type) {
         case -16777215:
             if (beacon.Optional >= 0 & beacon.Optional <= 3) {
                 this.CompatibilityState = (CompatibilityStates)beacon.Optional;
             }
             break;
         case -16777214:
             {
                 double limit = (double)(beacon.Optional & 4095) / 3.6;
                 double position = (beacon.Optional >> 12);
                 CompatibilityLimit item = new CompatibilityLimit(limit, position);
                 if (!this.CompatibilityLimits.Contains(item)) {
                     this.CompatibilityLimits.Add(item);
                 }
             }
             break;
     }
 }
Example #15
0
		/// <summary>Is called when a beacon is passed.</summary>
		/// <param name="beacon">The beacon data.</param>
		internal override void SetBeacon(BeaconData beacon) {
		}
Example #16
0
		/// <summary>Is called when a beacon is passed.</summary>
		/// <param name="beacon">The beacon data.</param>
		internal void SetBeacon(BeaconData beacon) {
			foreach (Device device in this.Devices) {
				device.SetBeacon(beacon);
			}
		}
Example #17
0
		internal override void SetBeacon(BeaconData beacon) {
//			if (this.Train == TrainManager.PlayerTrain) {
//				Game.AddDebugMessage("Beacon, type=" + beacon.Type.ToString() + ", aspect=" + beacon.Signal.Aspect.ToString() + ", data=" + beacon.Optional.ToString(), 3.0);
//			}
			#if !DEBUG
			try {
				#endif
				this.Api.SetBeacon(beacon);
				#if !DEBUG
			} catch (Exception ex) {
				base.LastException = ex;
				throw;
			}
			#endif
		}
Example #18
0
			/// <summary>Called when the train passes a beacon.</summary>
			/// <param name="beacon">The beacon data.</param>
			/// <remarks>This function should not be called directly. Call UpdateBeacon instead.</remarks>
			internal abstract void SetBeacon(BeaconData beacon);
Example #19
0
		internal override void SetBeacon(BeaconData beacon) {
			try {
				Win32BeaconData win32Beacon;
				win32Beacon.Type = beacon.Type;
				win32Beacon.Signal = beacon.Signal.Aspect;
				win32Beacon.Distance = (float)beacon.Signal.Distance;
				win32Beacon.Optional = beacon.Optional;
				Win32SetBeaconData(ref win32Beacon.Type);
			} catch (Exception ex) {
				base.LastException = ex;
				throw;
			}
		}
Example #20
0
		// --- private functions ---
		
		/// <summary>Updates the location of the farthest known red signal from the specified beacon.</summary>
		/// <param name="beacon">The beacon that holds the distance to a known red signal.</param>
		private void UpdateRedSignalLocation(BeaconData beacon) {
			if (beacon.Signal.Distance < 1200.0) {
				double signalLocation = this.Train.State.Location + beacon.Signal.Distance;
				if (signalLocation > this.RedSignalLocation) {
					this.RedSignalLocation = signalLocation;
				}
			}
		}
Example #21
0
		/// <summary>Is called when the train passes a beacon.</summary>
		/// <param name="beacon">The beacon data.</param>
		public void SetBeacon(BeaconData beacon) {
			this.Train.SetBeacon(beacon);
		}