Represents information about a signal or section.
示例#1
0
 // update plugin sections
 /// <summary>Updates the plugin to inform about sections.</summary>
 /// <param name="train">The train.</param>
 internal static void UpdatePluginSections(TrainManager.Train train)
 {
     if (train.Plugin != null)
     {
         OpenBveApi.Runtime.SignalData[] data = new OpenBveApi.Runtime.SignalData[16];
         int count = 0;
         int start = train.CurrentSectionIndex >= 0 ? train.CurrentSectionIndex : 0;
         for (int i = start; i < Sections.Length; i++)
         {
             OpenBveApi.Runtime.SignalData signal = GetPluginSignal(train, i);
             if (data.Length == count)
             {
                 Array.Resize <OpenBveApi.Runtime.SignalData>(ref data, data.Length << 1);
             }
             data[count] = signal;
             count++;
             if (signal.Aspect == 0 | count == 16)
             {
                 break;
             }
         }
         Array.Resize <OpenBveApi.Runtime.SignalData>(ref data, count);
         train.Plugin.UpdateSignals(data);
     }
 }
示例#2
0
 internal void SetSignal(SignalData[] signal)
 {
     //			switch (signal[0].Aspect) {
     //				case :
     //
     //					break;
     //			}
 }
示例#3
0
文件: Plugin.cs 项目: leezer3/OpenBVE
		/// <summary>Is called when the aspect in the current or in any of the upcoming sections changes, or when passing section boundaries.</summary>
		/// <param name="data">Signal information per section. In the array, index 0 is the current section, index 1 the upcoming section, and so on.</param>
		/// <remarks>The signal array is guaranteed to have at least one element. When accessing elements other than index 0, you must check the bounds of the array first.</remarks>
		public void SetSignal(SignalData[] signal) {
			int aspect = signal[0].Aspect;
			if (aspect != this.LastAspect) {
				// TODO: Your old SetSignal code goes here.
			}
		}
示例#4
0
		/// <summary>Is called to inform about signals.</summary>
		/// <param name="signal">The signal data.</param>
		internal void SetSignal(SignalData[] signal) {
			foreach (Device device in this.Devices) {
				device.SetSignal(signal);
			}
		}
示例#5
0
		/// <summary>Is called to inform about signals.</summary>
		/// <param name="signal">The signal data.</param>
		internal override void SetSignal(SignalData[] signal) {
		}
示例#6
0
 // --- constructors ---
 /// <summary>Creates a new instance of this class.</summary>
 /// <param name="type">The type of beacon.</param>
 /// <param name="optional">Optional data the beacon transmits.</param>
 /// <param name="signal">The section the beacon is attached to.</param>
 public BeaconData(int type, int optional, SignalData signal)
 {
     this.MyType     = type;
     this.MyOptional = optional;
     this.MySignal   = signal;
 }
示例#7
0
		internal override void SetSignal(SignalData[] signal) {
			if (base.LastAspects.Length == 0 || signal[0].Aspect != base.LastAspects[0]) {
				try {
					Win32SetSignal(signal[0].Aspect);
				} catch (Exception ex) {
					base.LastException = ex;
					throw;
				}
			}
		}
示例#8
0
			/// <summary>Called when the train passes a beacon.</summary>
			/// <param name="type">The beacon type.</param>
			/// <param name="sectionIndex">The section the beacon is attached to, or -1 for the next red signal.</param>
			/// <param name="optional">Optional data attached to the beacon.</param>
			internal void UpdateBeacon(int type, int sectionIndex, int optional) {
				if (sectionIndex == -1) {
					sectionIndex = this.Train.CurrentSectionIndex + 1;
					SignalData signal = null;
					while (sectionIndex < Game.Sections.Length) {
						signal = Game.GetPluginSignal(this.Train, sectionIndex);
						if (signal.Aspect == 0) break;
						sectionIndex++;
					}
					if (sectionIndex < Game.Sections.Length) {
						SetBeacon(new BeaconData(type, optional, signal));
					} else {
						SetBeacon(new BeaconData(type, optional, new SignalData(-1, double.MaxValue)));
					}
				}
				if (sectionIndex >= 0) {
					SignalData signal;
					if (sectionIndex < Game.Sections.Length) {
						signal = Game.GetPluginSignal(this.Train, sectionIndex);
					} else {
						signal = new SignalData(0, double.MaxValue);
					}
					SetBeacon(new BeaconData(type, optional, signal));
				} else {
					SetBeacon(new BeaconData(type, optional, new SignalData(-1, double.MaxValue)));
				}
			}
示例#9
0
 /// <summary>Is called when the aspect in the current or in any of the upcoming sections changes, or when passing section boundaries.</summary>
 /// <param name="data">Signal information per section. In the array, index 0 is the current section, index 1 the upcoming section, and so on.</param>
 /// <remarks>The signal array is guaranteed to have at least one element. When accessing elements other than index 0, you must check the bounds of the array first.</remarks>
 public void SetSignal(SignalData[] signal)
 {
     closedSignalDevice.trainEvent(new TrainEvent(EventTypes.EventTypeChangeSignalAspect, signal));
     speedControl.trainEvent(new TrainEvent(EventTypes.EventTypeChangeSignalAspect, signal));
 }
示例#10
0
		internal override void SetSignal(SignalData[] signal) {
			#if !DEBUG
			try {
				#endif
//				if (this.Train == TrainManager.PlayerTrain) {
//					for (int i = 0; i < signal.Length; i++) {
//						Game.AddDebugMessage(i.ToString() + " - " + signal[i].Aspect.ToString(), 3.0);
//					}
//				}
				this.Api.SetSignal(signal);
				#if !DEBUG
			} catch (Exception ex) {
				base.LastException = ex;
				throw;
			}
			#endif
		}
示例#11
0
 public void SetSignal(SignalData[] signal)
 {
 }
示例#12
0
 /// <summary>Is called when the aspect in the current or in any of the upcoming sections changes, or when passing section boundaries.</summary>
 /// <param name="data">Signal information per section. In the array, index 0 is the current section, index 1 the upcoming section, and so on.</param>
 /// <remarks>The signal array is guaranteed to have at least one element. When accessing elements other than index 0, you must check the bounds of the array first.</remarks>
 public void SetSignal(SignalData[] signal)
 {
     ms.SetSignal(signal);
 }
示例#13
0
文件: Runtime.cs 项目: sladen/openbve
 // --- constructors ---
 /// <summary>Creates a new instance of this class.</summary>
 /// <param name="type">The type of beacon.</param>
 /// <param name="optional">Optional data the beacon transmits.</param>
 /// <param name="signal">The section the beacon is attached to.</param>
 public BeaconData(int type, int optional, SignalData signal)
 {
     this.MyType = type;
     this.MyOptional = optional;
     this.MySignal = signal;
 }
示例#14
0
			/// <summary>Called to update the aspects of the section. This invokes a call to SetSignal only if a change in aspect occured or when changing section boundaries.</summary>
			/// <param name="data">The sections to submit to the plugin.</param>
			internal void UpdateSignals(SignalData[] data) {
				if (data.Length != 0) {
					bool update;
					if (this.Train.CurrentSectionIndex != this.LastSection) {
						update = true;
					} else if (data.Length != this.LastAspects.Length) {
						update = true;
					} else {
						update = false;
						for (int i = 0; i < data.Length; i++) {
							if (data[i].Aspect != this.LastAspects[i]) {
								update = true;
								break;
							}
						}
					}
					if (update) {
						SetSignal(data);
						this.LastAspects = new int[data.Length];
						for (int i = 0; i < data.Length; i++) {
							this.LastAspects[i] = data[i].Aspect;
						}
					}
				}
			}
示例#15
0
文件: Plugin.cs 项目: leezer3/OpenBVE
		/// <summary>Is called when the aspect in the current or in any of the upcoming sections changes, or when passing section boundaries.</summary>
		/// <param name="signal">Signal information per section. In the array, index 0 is the current section, index 1 the upcoming section, and so on.</param>
		/// <remarks>The signal array is guaranteed to have at least one element. When accessing elements other than index 0, you must check the bounds of the array first.</remarks>
		public void SetSignal(SignalData[] signal) {
			this.Train.SetSignal(signal);
		}
示例#16
0
			/// <summary>Is called when the aspect in the current or any of the upcoming sections changes.</summary>
			/// <param name="signal">Signal information per section. In the array, index 0 is the current section, index 1 the upcoming section, and so on.</param>
			/// <remarks>This function should not be called directly. Call UpdateSignal instead.</remarks>
			internal abstract void SetSignal(SignalData[] signal);
示例#17
0
文件: Game.cs 项目: leezer3/OpenBVE
		// update plugin sections
		/// <summary>Updates the plugin to inform about sections.</summary>
		/// <param name="train">The train.</param>
		internal static void UpdatePluginSections(TrainManager.Train train) {
			if (train.Plugin != null) {
				OpenBveApi.Runtime.SignalData[] data = new OpenBveApi.Runtime.SignalData[16];
				int count = 0;
				int start = train.CurrentSectionIndex >= 0 ? train.CurrentSectionIndex : 0;
				for (int i = start; i < Sections.Length; i++) {
					OpenBveApi.Runtime.SignalData signal = GetPluginSignal(train, i);
					if (data.Length == count) {
						Array.Resize<OpenBveApi.Runtime.SignalData>(ref data, data.Length << 1);
					}
					data[count] = signal;
					count++;
					if (signal.Aspect == 0 | count == 16) {
						break;
					}
				}
				Array.Resize<OpenBveApi.Runtime.SignalData>(ref data, count);
				train.Plugin.UpdateSignals(data);
			}
		}
示例#18
0
文件: AtsSx.cs 项目: leezer3/OpenBVE
		/// <summary>Is called to inform about signals.</summary>
		/// <param name="signal">The signal data.</param>
		internal override void SetSignal(SignalData[] signal) {
			if (this.RedSignalLocation != double.MinValue) {
				for (int i = 0; i < signal.Length; i++) {
					const double visibility = 200.0;
					if (signal[i].Distance < visibility) {
						double location = this.Train.State.Location + signal[i].Distance;
						if (Math.Abs(location - this.RedSignalLocation) < 50.0) {
							if (signal[i].Aspect != 0) {
								this.RedSignalLocation = double.MinValue;
							}
						}
					}
				}
			}
		}
示例#19
0
 internal void SetSignal(SignalData[] signal)
 {
     // TODO: ATP2 set signal
 }