From 182d5e4982797a6d27fdb317c287a527660d6bac Mon Sep 17 00:00:00 2001
From: winup-zhou <3166832341@qq.com>
Date: Tue, 1 Oct 2024 21:53:49 +0800
Subject: [PATCH 1/9] =?UTF-8?q?=E7=BB=86=E8=8A=82=E4=BF=AE=E6=AD=A3?=
=?UTF-8?q?=EF=BC=8C=E5=AE=9A=E4=BD=8D=E7=AD=96=E7=95=A5=E9=A2=84=E7=95=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 9 +-
TGMT-CBTC-EX/TGMT-CBTC-EX.csproj | 105 -----------------------
TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj | 74 ----------------
3 files changed, 7 insertions(+), 181 deletions(-)
delete mode 100644 TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
delete mode 100644 TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
diff --git a/.gitignore b/.gitignore
index 986bb1f..915e76e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
+*.csproj
*.rsuser
*.suo
*.user
@@ -361,5 +362,9 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd
-
-*.csproj
\ No newline at end of file
+/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
+/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
+/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
+/TGMT-CBTC-EX/TickNew.cs
+/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
+/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
diff --git a/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj b/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
deleted file mode 100644
index e101fc8..0000000
--- a/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
+++ /dev/null
@@ -1,105 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {A18C1921-1E03-4FE8-A6ED-6C1FC2209F5F}
- Library
- Properties
- TGMTAts.OBCU
- TGMT-CBTC-EX
- v4.8
- 512
- false
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
- False
- ..\packages\DXDynamicTexture\Zbx1425.DXDynamicTexture-net48.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Form
-
-
- DebugWindow.cs
-
-
-
-
-
-
- DebugWindow.cs
-
-
-
-
- 1.0.0-rc1
-
-
- 1.0.0-rc3
-
-
- 2.2.2
-
-
- 1.0.0
-
-
- 4.0.13.44
-
-
- 1.0.0
-
-
-
-
- {ab7ee309-f15f-4ad4-a658-d0dd210627ce}
- TGMT-CBTC-EX_WCU
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj b/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
deleted file mode 100644
index 2145020..0000000
--- a/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {AB7EE309-F15F-4AD4-A658-D0DD210627CE}
- Library
- Properties
- TGMTAts.WCU
- TGMT-CBTC-EX_WCU
- v4.8
- 512
- false
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1.0.0-rc1
-
-
- 1.0.0-rc3
-
-
- 2.2.2
-
-
- 1.0.0
-
-
- 4.0.13.44
-
-
- 1.0.0
-
-
-
-
-
-
-
-
\ No newline at end of file
From 9590aae0a43ec16600ba113e180fd360043554e0 Mon Sep 17 00:00:00 2001
From: winup-zhou <3166832341@qq.com>
Date: Tue, 1 Oct 2024 21:54:27 +0800
Subject: [PATCH 2/9] =?UTF-8?q?=E5=AE=9A=E4=BD=8D=E7=AD=96=E7=95=A5?=
=?UTF-8?q?=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
TGMT-CBTC-EX/Inputs.cs | 19 +++----
TGMT-CBTC-EX/Load.cs | 62 +++++++++++++++++-----
TGMT-CBTC-EX/Patterns/CalculatedLimit.cs | 2 +-
TGMT-CBTC-EX/Patterns/PreTrainManager.cs | 2 +-
TGMT-CBTC-EX/TickNew.cs | 65 ++++++++++++++++--------
TGMT-CBTC-EX_WCU/Config.cs | 16 +++---
TGMT-CBTC-EX_WCU/PluginMain.cs | 42 +++++++++++----
7 files changed, 141 insertions(+), 67 deletions(-)
diff --git a/TGMT-CBTC-EX/Inputs.cs b/TGMT-CBTC-EX/Inputs.cs
index adfa9e6..4a1403d 100644
--- a/TGMT-CBTC-EX/Inputs.cs
+++ b/TGMT-CBTC-EX/Inputs.cs
@@ -36,12 +36,6 @@ private void OnB2Pressed(object sender, EventArgs e) {
selectedMode = selectingMode;
selectModeStartTime = 0;
FixIncompatibleModes();
- if (signalMode < lastSigMode) {
- // CTC->ITC 降级到RM
- // 有说实际运行中这么操作不会到RM的,不过移动授权终点不知道好没好?
- signalMode = 0;
- FixIncompatibleModes();
- }
break;
case 6:
// 切换到RM
@@ -75,7 +69,7 @@ private void SetBeaconData(AtsEx.PluginHost.Native.BeaconPassedEventArgs e) {
trackLimit.SetBeacon(e);
break;
case 96811:
- deviceCapability = e.Optional;
+ RadioAvailable = e.Optional > 0;
FixIncompatibleModes();
break;
case 96812:
@@ -83,12 +77,13 @@ private void SetBeaconData(AtsEx.PluginHost.Native.BeaconPassedEventArgs e) {
break;
case 96813:
signalMode = e.Optional / 10 % 10;
+ if (signalMode != 0) {
+ Localized = true;
+ BaliseCount = 0;
+ }
selectedMode = e.Optional / 100 % 10;
driveMode = 1;
FixIncompatibleModes();
- if(signalMode != 0&& driveMode != 0) {
- VBCount = FBCount = 1;
- }
break;
case 96810:
trackLimit.SetBeacon(e);
@@ -111,6 +106,7 @@ private void SetBeaconData(AtsEx.PluginHost.Native.BeaconPassedEventArgs e) {
break;
case 96801:
case 96802:
+ if (!Localized) BaliseCount += 1;
// TGMT 主
// TGMT 填充
signalMode = 2;
@@ -130,6 +126,7 @@ private void SetBeaconData(AtsEx.PluginHost.Native.BeaconPassedEventArgs e) {
}
break;
case 96803:
+ if (!Localized) BaliseCount += 1;
// TGMT 定位
signalMode = 2;
FixIncompatibleModes();
@@ -141,7 +138,7 @@ private void Initialize(AtsEx.PluginHost.Native.StartedEventArgs e) {
driveMode = 1;
FixIncompatibleModes();
- ITCNextSectionPos = 0;
+ ITCNextSectionPos = -114514;
movementEndpoint = SpeedLimit.inf;
nextLimit = null;
selectingMode = -1;
diff --git a/TGMT-CBTC-EX/Load.cs b/TGMT-CBTC-EX/Load.cs
index 45937e8..c4b12af 100644
--- a/TGMT-CBTC-EX/Load.cs
+++ b/TGMT-CBTC-EX/Load.cs
@@ -29,8 +29,10 @@ public partial class TGMTAts : AssemblyPluginBase {
public static int signalMode = 2;
// 1: MM; 2: AM; 3: AA
public static int doorMode = 1;
- // 0: 没有CTC,ITC; 1: 没有CTC; 2: 正常
- public static int deviceCapability = 2;
+ // 无线电
+ public static bool RadioAvailable = false;
+ // WCU可用性
+ public static bool WCUAvailable = false;
// 暂时的预选速度,-1表示没有在预选
public static int selectingMode = -1;
@@ -42,10 +44,11 @@ public partial class TGMTAts : AssemblyPluginBase {
public static int TrainNumber = 0;
public static int DestinationNumber = 0;
- public static double ITCNextSectionPos = 0;
+ public static double ITCNextSectionPos = -114514;
- public static int VBCount = 0;
- public static int FBCount = 0;
+ //定位策略
+ public static int BaliseCount = 0;
+ public static bool Localized = false;
public static double reverseStartLocation = Config.LessInf;
@@ -91,15 +94,20 @@ private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEven
}
static void FixIncompatibleModes() {
- if (selectedMode == 0) signalMode = 0; // 预选了IXL
- if (selectedMode == 1 && signalMode > 1) signalMode = 1; // 预选了ITC
- if (selectedMode == 3 && signalMode > 1) signalMode = 1; // 预选了ITC
-
- if (deviceCapability == 0) signalMode = 0; // 没有TGMT设备
- if (deviceCapability == 1 && signalMode > 1) signalMode = 1; // 没有无线电信号
+ if (BaliseCount >= 2) { Localized = true; BaliseCount = 0; }
+ if (WCUAvailable) {
+ if (selectedMode == 0 || !Localized) signalMode = 0; // 预选了IXL
+ if (signalMode == 0 && driveMode > 0) driveMode = 0; // 没信号就得是RM
+ if (Localized) {
+ if (selectedMode == 1 && signalMode > 1) signalMode = 1; // 预选了ITC
+ if (selectedMode == 3 && signalMode > 1) signalMode = 1; // 预选了ITC
+ if (!RadioAvailable && signalMode > 1) signalMode = 1; // 没有无线电信号
+ if (signalMode > 0 && driveMode == 0) driveMode = 1; // 有信号就至少是SM
+ }
+ } else {
+ signalMode = 0;
+ }
- if (signalMode > 0 && driveMode == 0) driveMode = 1; // 有信号就至少是SM
- if (signalMode == 0 && driveMode > 0) driveMode = 0; // 没信号就得是RM
}
public static int ConvertTime(int human) {
@@ -118,6 +126,34 @@ public override void Dispose() {
hHMITex.Dispose();
hTDTTex.Dispose();
+ ITCNextSectionPos = -114514;
+ movementEndpoint = SpeedLimit.inf;
+ nextLimit = null;
+ selectingMode = -1;
+ selectModeStartTime = 0;
+ pluginReady = false;
+ reverseStartLocation = Config.LessInf;
+ releaseSpeed = false;
+ ebState = 0;
+ ackMessage = 0;
+
+ DestinationNumber = TrainNumber = 0;
+
+ Ato.ResetCache();
+ PreTrainManager.ResetCache();
+
+ RadioAvailable = false;
+ WCUAvailable = false;
+ doorMode = 1;
+ signalMode = 2;
+ driveMode = 1;
+ selectedMode = 4;
+ debugMessages.Clear();
+ trackLimit = new TrackLimit();
+
+ BaliseCount = 0;
+ Localized = false;
+
Native.NativeKeys.AtsKeys[NativeAtsKeyName.A1].Pressed -= OnA1Pressed;
Native.NativeKeys.AtsKeys[NativeAtsKeyName.B1].Pressed -= OnB1Pressed;
Native.NativeKeys.AtsKeys[NativeAtsKeyName.B2].Pressed -= OnB2Pressed;
diff --git a/TGMT-CBTC-EX/Patterns/CalculatedLimit.cs b/TGMT-CBTC-EX/Patterns/CalculatedLimit.cs
index b2f7315..4318806 100644
--- a/TGMT-CBTC-EX/Patterns/CalculatedLimit.cs
+++ b/TGMT-CBTC-EX/Patterns/CalculatedLimit.cs
@@ -21,7 +21,7 @@ public static CalculatedLimit Calculate(double location, double idealdecel, doub
Array.Sort(limits, (a, b) => a.Location.CompareTo(b.Location));
int pointer = 0;
double currentTarget = Config.LessInf, nextTarget = Config.LessInf;
- while (limits[pointer].Location < location - 10) pointer++;
+ while (limits[pointer].Location < location - 1) pointer++;
for (int i = 0; i < limits.Length; i++) {
currentTarget = Math.Min(currentTarget, limits[i].AtLocation(location, idealdecel, voffset));
}
diff --git a/TGMT-CBTC-EX/Patterns/PreTrainManager.cs b/TGMT-CBTC-EX/Patterns/PreTrainManager.cs
index 168ef38..97bec94 100644
--- a/TGMT-CBTC-EX/Patterns/PreTrainManager.cs
+++ b/TGMT-CBTC-EX/Patterns/PreTrainManager.cs
@@ -40,7 +40,7 @@ public static void SetBeacon(AtsEx.PluginHost.Native.BeaconPassedEventArgs data)
}
public static SpeedLimit GetEndpoint() {
- if (Commands.Count == 0) return new SpeedLimit(0, TGMTAts.mapPlugin.MovementAuthority - Config.CTCSafetyDistance);
+ if (Commands.Count == 0 && TGMTAts.WCUAvailable) return new SpeedLimit(0, TGMTAts.mapPlugin.MovementAuthority - Config.CTCSafetyDistance);
int pointer = 0;
var time = TGMTAts.time;
while (pointer < Commands.Count && Commands[pointer].Time < time) pointer++;
diff --git a/TGMT-CBTC-EX/TickNew.cs b/TGMT-CBTC-EX/TickNew.cs
index deb619e..49a08f4 100644
--- a/TGMT-CBTC-EX/TickNew.cs
+++ b/TGMT-CBTC-EX/TickNew.cs
@@ -14,7 +14,7 @@
using System.Threading.Tasks;
using System.Windows.Forms;
-using MapPlugin = TGMTAts.WCU.PluginMain;
+using MapPlugin = TGMTAts.WCU.TGMTAts;
namespace TGMTAts.OBCU {
[PluginType(PluginType.VehiclePlugin)]
@@ -60,7 +60,13 @@ public TGMTAts(PluginBuilder services) : base(services) {
}
private void OnAllPluginsLoaded(object sender, EventArgs e) {
- mapPlugin = Plugins[PluginType.MapPlugin]["TGMT_WCU_Plugin"] as MapPlugin;
+ try {
+ mapPlugin = Plugins[PluginType.MapPlugin]["TGMT_WCU_Plugin"] as MapPlugin;
+ WCUAvailable = true;
+ } catch (Exception ex) {
+ WCUAvailable = false;
+ MessageBox.Show("找不到WCU插件,OBCU将保持在IXLC级别工作", "TGMT-CBTC-EX_OBCU");
+ }
}
public override TickResult Tick(TimeSpan elapsed) {
@@ -106,9 +112,9 @@ public override TickResult Tick(TimeSpan elapsed) {
recommendCurve = CalculatedLimit.Calculate(location,
Config.RecommendDeceleration, 0, StationManager.RecommendCurve(), movementEndpoint, trackLimit);
// 释放速度
- if (movementEndpoint.Location - location < Config.ReleaseSpeedDistance
- && movementEndpoint.Location > location
- && state.Speed < Config.ReleaseSpeed && !releaseSpeed) {
+ if (ITCNextSectionPos - location < Config.ReleaseSpeedDistance
+ && ITCNextSectionPos > location
+ && state.Speed < Config.ReleaseSpeed && !releaseSpeed && ITCNextSectionPos != -114514) {
ackMessage = 2;
}
break;
@@ -143,21 +149,28 @@ public override TickResult Tick(TimeSpan elapsed) {
nextLimit = targetCurve.NextLimit;
targetDistance = targetCurve.NextLimit.Location - location;
targetSpeed = targetCurve.NextLimit.Limit;
- if (signalMode == 1 && location > ITCNextSectionPos) {
- // 如果已冲出移动授权终点,释放速度无效
- if (releaseSpeed) Log("超出了移动授权终点, 释放速度无效");
- if (atsSound0.PlayState != PlayState.PlayingLoop) atsSound0.PlayLoop();
- recommendSpeed = 0;
- ebSpeed = 0;
- releaseSpeed = false;
+ if (signalMode == 1) {
+ if (ITCNextSectionPos == -114514) {
+ recommendSpeed = 0;
+ ebSpeed = 0;
+ ackMessage = 6;
+ } else if (location > ITCNextSectionPos) {
+ // 如果已冲出移动授权终点,释放速度无效
+ if (releaseSpeed) Log("超出了移动授权终点, 释放速度无效");
+ if (atsSound0.PlayState != PlayState.PlayingLoop) atsSound0.PlayLoop();
+ recommendSpeed = 0;
+ ebSpeed = 0;
+ releaseSpeed = false;
+ }
+ if (location < ITCNextSectionPos && location > movementEndpoint.Location) {
+ targetDistance = -10;
+ targetSpeed = 0;
+ }
}
+
}
if (releaseSpeed) {
- if (location < ITCNextSectionPos && location > movementEndpoint.Location) {
- targetDistance = -10;
- targetSpeed = 0;
- }
ebSpeed = Math.Max(ebSpeed, Config.ReleaseSpeed);
recommendSpeed = Math.Max(recommendSpeed, Config.ReleaseSpeed - Config.RecommendSpeedOffset);
}
@@ -168,8 +181,10 @@ public override TickResult Tick(TimeSpan elapsed) {
panel_[24] = driveMode;
panel_[25] = signalMode;
panel_[28] = (driveMode > 0) ? (driveMode > 1 ? doorMode : 1) : 0;
- mapPlugin.OBCULevel = signalMode;
- mapPlugin.SelfTrainLocation = state.Location;
+ if (WCUAvailable) {
+ mapPlugin.OBCULevel = signalMode;
+ mapPlugin.SelfTrainLocation = state.Location;
+ } else RadioAvailable = false;
// 显示临时预选模式
if (state.Speed != 0 || time > selectModeStartTime + Config.ModeSelectTimeout * 1000) {
@@ -184,7 +199,7 @@ public override TickResult Tick(TimeSpan elapsed) {
panel_[29] = 0;
//PSD信息
- if (signalMode >= 1 && deviceCapability == 2 && state.Speed == 0) {
+ if (signalMode >= 1 && RadioAvailable && state.Speed == 0) {
if (doorOpen) {
if (time - doorOpenTime >= 1000) {
panel_[29] = 3;
@@ -261,7 +276,7 @@ public override TickResult Tick(TimeSpan elapsed) {
// 如果没有无线电,显示无线电故障
panel_[23] = state.Speed == 0 ? 0 : 1;
- panel_[30] = deviceCapability != 2 ? 1 : 0;
+ panel_[30] = !RadioAvailable ? 1 : 0;
// ATO
atsPanel40.Value = 0;
@@ -305,7 +320,7 @@ public override TickResult Tick(TimeSpan elapsed) {
if (atsSound0.PlayState != PlayState.Stop) atsSound0.Stop();
// 低于制动缓解速度
if (ebState > 0) {
- if (location > movementEndpoint.Location) {
+ if (signalMode == 2 && location > movementEndpoint.Location) {
// 冲出移动授权终点,要求RM
ackMessage = 6;
} else {
@@ -339,9 +354,10 @@ public override TickResult Tick(TimeSpan elapsed) {
}
} else if (signalMode == 1 && !doorOpen && panel_[29] != 3) {
// ITC下冲出移动授权终点。
- if (state.Speed == 0) {
+ if (state.Speed == 0 && location > ITCNextSectionPos) {
// 停稳后降级到RM模式。等待确认。
ackMessage = 6;
+ Localized = false;
}
ebState = 1;
// 显示紧急制动、目标距离0、速度0
@@ -382,6 +398,11 @@ public override TickResult Tick(TimeSpan elapsed) {
// 显示释放速度、确认消息
if (releaseSpeed) panel_[31] = 3;
+ //定位策略
+ if (!Localized) {
+ panel_[31] = 2;
+ if (BaliseCount >= 2) { Localized = true; BaliseCount = 0; }
+ }
if (ackMessage > 0) {
panel_[35] = ackMessage;
panel_[36] = atsPanel36.Value = ((state.Time.TotalMilliseconds / 1000) % 0.5 < 0.25) ? 1 : 0;
diff --git a/TGMT-CBTC-EX_WCU/Config.cs b/TGMT-CBTC-EX_WCU/Config.cs
index bb04523..15c8230 100644
--- a/TGMT-CBTC-EX_WCU/Config.cs
+++ b/TGMT-CBTC-EX_WCU/Config.cs
@@ -9,13 +9,13 @@
namespace TGMTAts.WCU {
public static class Config {
- public const double LessInf = 100000000;
+ public const double LessInf = 0x7fffffff;
public static string PluginDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public static double TGMTTerrtoryStart = 0;
- public static double TGMTTerrtoryEnd = 100000000;
- public static string PretrainName = "pretrain";
+ public static double TGMTTerrtoryEnd = LessInf;
+ public static string PretrainName = "ptrain";
public static string PretrainTrackkey = "";
public static double CTCSignalIndex = 255;
@@ -76,11 +76,11 @@ public static void Load(string path) {
}
configFile.Close();
- dict.Cfg("TGMTTerrtoryStart", ref TGMTTerrtoryStart);
- dict.Cfg("TGMTTerrtoryEnd", ref TGMTTerrtoryEnd);
- dict.Cfg("PretrainName", ref PretrainName);
- dict.Cfg("PretrainTrackkey", ref PretrainTrackkey);
- dict.Cfg("CTCSignalIndex", ref CTCSignalIndex);
+ dict.Cfg("tgmtterrtorystart", ref TGMTTerrtoryStart);
+ dict.Cfg("tgmtterrtoryend", ref TGMTTerrtoryEnd);
+ dict.Cfg("pretrainname", ref PretrainName);
+ dict.Cfg("pretraintrackkey", ref PretrainTrackkey);
+ dict.Cfg("ctcsignalindex", ref CTCSignalIndex);
}
}
}
diff --git a/TGMT-CBTC-EX_WCU/PluginMain.cs b/TGMT-CBTC-EX_WCU/PluginMain.cs
index ae70023..c124470 100644
--- a/TGMT-CBTC-EX_WCU/PluginMain.cs
+++ b/TGMT-CBTC-EX_WCU/PluginMain.cs
@@ -8,27 +8,30 @@
using AtsEx.Extensions.PreTrainPatch;
using System.IO;
using System.Collections.Generic;
-
+using System.Windows.Forms;
namespace TGMTAts.WCU {
[PluginType(PluginType.MapPlugin)]
- public class PluginMain : AssemblyPluginBase {
- static PluginMain() {
+ public class TGMTAts : AssemblyPluginBase {
+ static TGMTAts() {
Config.Load(Path.Combine(Config.PluginDir, "TGMT_WCUConfig.txt"));
}
public double MovementAuthority { get; set; } = 0;
public int OBCULevel { get; set; } = 0;
public double SelfTrainLocation { get; set; } = 0;
+ public double NextSectionLocation { get; set; } = 0;
+ public bool AtStation { get; set; } = false;
private List SignalPatch = new List();
private Train Train;
private PreTrainPatch PreTrainPatch;
private SectionManager sectionManager;
+ private bool TrainLoaded = false;
- public PluginMain(PluginBuilder builder) : base(builder) {
+ public TGMTAts(PluginBuilder builder) : base(builder) {
Plugins.AllPluginsLoaded += OnAllPluginsLoaded;
BveHacker.ScenarioCreated += OnScenarioCreated;
}
@@ -39,14 +42,16 @@ private void OnAllPluginsLoaded(object sender, EventArgs e) {
private void OnScenarioCreated(ScenarioCreatedEventArgs e) {
+ sectionManager = e.Scenario.SectionManager;
if (!e.Scenario.Trains.ContainsKey(Config.PretrainName)) {
- throw new BveFileLoadException(string.Format("キーが {0} の他列車が見つかりませんでした。", Config.PretrainName), "TGMT-CBTC-EX_WCU");
+ TrainLoaded = false;
+ MessageBox.Show(string.Format("找不到名为 {0} 的列车,请检查Map以及插件设置", Config.PretrainName), "TGMT-CBTC-EX_WCU");
+ } else {
+ TrainLoaded = true;
+ Train = e.Scenario.Trains[Config.PretrainName];
+ PreTrainPatch = Extensions.GetExtension().Patch(nameof(PreTrainPatch), sectionManager, new PreTrainLocationConverter(Train, sectionManager));
}
- Train = e.Scenario.Trains[Config.PretrainName];
-
- sectionManager = e.Scenario.SectionManager;
- PreTrainPatch = Extensions.GetExtension().Patch(nameof(PreTrainPatch), sectionManager, new PreTrainLocationConverter(Train, sectionManager));
int pointer = 0;
while (pointer < sectionManager.Sections.Count - 1) {
SignalPatch.Add(Extensions.GetExtension().Patch(nameof(SignalPatch), sectionManager.Sections[pointer] as Section,
@@ -56,7 +61,7 @@ private void OnScenarioCreated(ScenarioCreatedEventArgs e) {
? (int)Config.CTCSignalIndex : source : source));
++pointer;
}
-
+
}
public override void Dispose() {
@@ -64,6 +69,11 @@ public override void Dispose() {
PreTrainPatch?.Dispose();
Plugins.AllPluginsLoaded -= OnAllPluginsLoaded;
BveHacker.ScenarioCreated -= OnScenarioCreated;
+ TrainLoaded = false;
+ MovementAuthority = 0;
+ OBCULevel = 0;
+ SelfTrainLocation = 0;
+ NextSectionLocation = 0;
}
private class PreTrainLocationConverter : IPreTrainLocationConverter {
@@ -81,7 +91,17 @@ public PreTrainLocation Convert(PreTrainLocation source)
public override TickResult Tick(TimeSpan elapsed) {
- MovementAuthority = Train.Location;
+ int pointer = 0;
+ while (sectionManager.Sections[pointer].Location < SelfTrainLocation)
+ pointer++;
+ if (pointer >= sectionManager.Sections.Count)
+ pointer = sectionManager.Sections.Count - 1;
+
+ var CurrentSection = sectionManager.Sections[pointer == 0 ? 0 : pointer - 1] as Section;
+ var NextSection = sectionManager.Sections[pointer] as Section;
+
+ NextSectionLocation = NextSection.Location;
+ if (TrainLoaded) MovementAuthority = Train.Location;
return new MapPluginTickResult();
}
From a975fcd43b1bdb65c9a8cd331486eba631e224e8 Mon Sep 17 00:00:00 2001
From: winup-zhou <3166832341@qq.com>
Date: Tue, 1 Oct 2024 21:58:40 +0800
Subject: [PATCH 3/9] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E5=AF=B9csproj=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=E7=9A=84=E8=BF=BD=E8=B8=AA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 7 --
TGMT-CBTC-EX/TGMT-CBTC-EX.csproj | 105 +++++++++++++++++++++++
TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj | 74 ++++++++++++++++
3 files changed, 179 insertions(+), 7 deletions(-)
create mode 100644 TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
create mode 100644 TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
diff --git a/.gitignore b/.gitignore
index 915e76e..c9a68cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,6 @@
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
-*.csproj
*.rsuser
*.suo
*.user
@@ -362,9 +361,3 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd
-/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
-/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
-/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
-/TGMT-CBTC-EX/TickNew.cs
-/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
-/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
diff --git a/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj b/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
new file mode 100644
index 0000000..e101fc8
--- /dev/null
+++ b/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
@@ -0,0 +1,105 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {A18C1921-1E03-4FE8-A6ED-6C1FC2209F5F}
+ Library
+ Properties
+ TGMTAts.OBCU
+ TGMT-CBTC-EX
+ v4.8
+ 512
+ false
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+ False
+ ..\packages\DXDynamicTexture\Zbx1425.DXDynamicTexture-net48.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ DebugWindow.cs
+
+
+
+
+
+
+ DebugWindow.cs
+
+
+
+
+ 1.0.0-rc1
+
+
+ 1.0.0-rc3
+
+
+ 2.2.2
+
+
+ 1.0.0
+
+
+ 4.0.13.44
+
+
+ 1.0.0
+
+
+
+
+ {ab7ee309-f15f-4ad4-a658-d0dd210627ce}
+ TGMT-CBTC-EX_WCU
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj b/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
new file mode 100644
index 0000000..2145020
--- /dev/null
+++ b/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
@@ -0,0 +1,74 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {AB7EE309-F15F-4AD4-A658-D0DD210627CE}
+ Library
+ Properties
+ TGMTAts.WCU
+ TGMT-CBTC-EX_WCU
+ v4.8
+ 512
+ false
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.0.0-rc1
+
+
+ 1.0.0-rc3
+
+
+ 2.2.2
+
+
+ 1.0.0
+
+
+ 4.0.13.44
+
+
+ 1.0.0
+
+
+
+
+
+
+
+
\ No newline at end of file
From daca1caae757f5003ffe28e45c19e498ff25c0e7 Mon Sep 17 00:00:00 2001
From: winup-zhou <3166832341@qq.com>
Date: Sun, 27 Oct 2024 15:40:37 +0800
Subject: [PATCH 4/9] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E9=83=A8=E5=88=86?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=B0WCU=E9=83=A8=E5=88=86=EF=BC=8C?=
=?UTF-8?q?=E9=83=A8=E5=88=86=E9=80=BB=E8=BE=91=E4=BF=AE=E6=AD=A3=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
TGMT-CBTC-EX/TGMT-CBTC-EX.csproj | 3 +--
TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj b/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
index e101fc8..ae181d9 100644
--- a/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
+++ b/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
@@ -99,7 +99,6 @@
-
-
+ COPY $(TargetPath) D:\Scenarios\CRT4\AtsEX\AtsEXPlugins\$(TargetFileName)
\ No newline at end of file
diff --git a/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj b/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
index 2145020..cd55409 100644
--- a/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
+++ b/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
@@ -68,7 +68,7 @@
-
+ COPY $(TargetPath) D:\Scenarios\新浜線(架空)\NiihamaLine\MapPlugins\$(TargetFileName)
\ No newline at end of file
From 0e2165f47317ab77ac6a9920c94e861b8ff0d7b7 Mon Sep 17 00:00:00 2001
From: winup-zhou <3166832341@qq.com>
Date: Sun, 27 Oct 2024 15:40:37 +0800
Subject: [PATCH 5/9] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E9=83=A8=E5=88=86?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=B0WCU=E9=83=A8=E5=88=86=EF=BC=8C?=
=?UTF-8?q?=E9=83=A8=E5=88=86=E9=80=BB=E8=BE=91=E4=BF=AE=E6=AD=A3=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
TGMT-CBTC-EX/Ato.cs | 3 +-
TGMT-CBTC-EX/Config.cs | 2 +-
TGMT-CBTC-EX/DoorControl.cs | 11 +++
TGMT-CBTC-EX/Inputs.cs | 36 +++----
TGMT-CBTC-EX/Load.cs | 8 +-
TGMT-CBTC-EX/Patterns/StationManager.cs | 23 +++--
TGMT-CBTC-EX/TGMT-CBTC-EX.csproj | 4 +-
TGMT-CBTC-EX/TickNew.cs | 110 ++++++++++++++--------
TGMT-CBTC-EX/UserInterface/DebugWindow.cs | 2 +-
TGMT-CBTC-EX/UserInterface/TGMTPainter.cs | 15 +--
TGMT-CBTC-EX_WCU/PluginMain.cs | 70 +++++++++++---
TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj | 3 +-
12 files changed, 194 insertions(+), 93 deletions(-)
create mode 100644 TGMT-CBTC-EX/DoorControl.cs
diff --git a/TGMT-CBTC-EX/Ato.cs b/TGMT-CBTC-EX/Ato.cs
index 5f42450..0de17cb 100644
--- a/TGMT-CBTC-EX/Ato.cs
+++ b/TGMT-CBTC-EX/Ato.cs
@@ -98,7 +98,8 @@ public static bool IsAvailable() {
&& (StationManager.NextStation.StopPosition - TGMTAts.location > Config.StationStartDistance
|| StationManager.Arrived)
// 离移动授权终点太近不能接通ATO (这是现实情况吗?)
- && (TGMTAts.movementEndpoint.Location - TGMTAts.location > 50 || TGMTAts.releaseSpeed)
+ && ((TGMTAts.signalMode == 1 && TGMTAts.movementEndpoint.Location - TGMTAts.location > 50) ||
+ (TGMTAts.signalMode == 2 && StationManager.CTCEndpoint().Location - TGMTAts.location > 50) || TGMTAts.releaseSpeed)
// CTC下离前车太近不能接通ATO (这是现实情况吗?)
&& (TGMTAts.signalMode == 1 || PreTrainManager.GetEndpoint().Location - TGMTAts.location > 50);
}
diff --git a/TGMT-CBTC-EX/Config.cs b/TGMT-CBTC-EX/Config.cs
index f8d8648..bfb1775 100644
--- a/TGMT-CBTC-EX/Config.cs
+++ b/TGMT-CBTC-EX/Config.cs
@@ -8,7 +8,7 @@ namespace TGMTAts.OBCU {
public static class Config {
- public const double LessInf = 100000000;
+ public const double LessInf = 0x7fffffff;
public static string PluginDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public static bool Debug = false;
diff --git a/TGMT-CBTC-EX/DoorControl.cs b/TGMT-CBTC-EX/DoorControl.cs
new file mode 100644
index 0000000..164afdc
--- /dev/null
+++ b/TGMT-CBTC-EX/DoorControl.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TGMTAts.OBCU {
+ internal class DoorControl {
+
+ }
+}
diff --git a/TGMT-CBTC-EX/Inputs.cs b/TGMT-CBTC-EX/Inputs.cs
index 4a1403d..9747e57 100644
--- a/TGMT-CBTC-EX/Inputs.cs
+++ b/TGMT-CBTC-EX/Inputs.cs
@@ -4,7 +4,7 @@
using System.Runtime.InteropServices;
using AtsEx.PluginHost.Plugins;
-namespace TGMTAts.OBCU{
+namespace TGMTAts.OBCU {
public partial class TGMTAts : AssemblyPluginBase {
private static bool a1Down, b1Down;
@@ -19,7 +19,7 @@ private void OnA1Pressed(object sender, EventArgs e) {
private void OnB1Pressed(object sender, EventArgs e) {
b1Down = true;
- if (a1Down && b1Down && Ato.IsAvailable()) {
+ if (a1Down && b1Down && Ato.IsAvailable()) {
driveMode = 2;
}
}
@@ -69,8 +69,10 @@ private void SetBeaconData(AtsEx.PluginHost.Native.BeaconPassedEventArgs e) {
trackLimit.SetBeacon(e);
break;
case 96811:
+ var lastRadioAvailable = RadioAvailable;
RadioAvailable = e.Optional > 0;
- FixIncompatibleModes();
+ if (lastRadioAvailable && !RadioAvailable)
+ RadioFailed = true;
break;
case 96812:
doorMode = e.Optional;
@@ -83,7 +85,7 @@ private void SetBeaconData(AtsEx.PluginHost.Native.BeaconPassedEventArgs e) {
}
selectedMode = e.Optional / 100 % 10;
driveMode = 1;
- FixIncompatibleModes();
+ if (!RadioFailed) FixIncompatibleModes();
break;
case 96810:
trackLimit.SetBeacon(e);
@@ -109,8 +111,8 @@ private void SetBeaconData(AtsEx.PluginHost.Native.BeaconPassedEventArgs e) {
if (!Localized) BaliseCount += 1;
// TGMT 主
// TGMT 填充
- signalMode = 2;
- FixIncompatibleModes();
+ if (signalMode < 1) signalMode = 1;
+ if (!RadioFailed) FixIncompatibleModes();
if (signalMode == 1) {
if (e.SignalIndex > 0) {
ITCNextSectionPos = e.Optional;
@@ -119,7 +121,7 @@ private void SetBeaconData(AtsEx.PluginHost.Native.BeaconPassedEventArgs e) {
movementEndpoint = new SpeedLimit(0, e.Optional - Config.ITCSafetyDistance);
releaseSpeed = false;
} else {
- ITCNextSectionPos = location + e.Distance;
+ ITCNextSectionPos = e.Type == 96801 ? location : location + e.Distance;
Log("红灯 移动授权终点是 " + location + e.Distance);
movementEndpoint = new SpeedLimit(0, location + e.Distance - Config.ITCSafetyDistance);
}
@@ -128,8 +130,6 @@ private void SetBeaconData(AtsEx.PluginHost.Native.BeaconPassedEventArgs e) {
case 96803:
if (!Localized) BaliseCount += 1;
// TGMT 定位
- signalMode = 2;
- FixIncompatibleModes();
break;
}
}
@@ -157,23 +157,23 @@ private void Initialize(AtsEx.PluginHost.Native.StartedEventArgs e) {
public static double time;
public static double doorOpenTime, doorCloseTime;
-
-
+
+
private void DoorOpen(AtsEx.PluginHost.Native.DoorEventArgs e) {
doorOpen = true;
doorOpenTime = time;
}
-
-
+
+
private void DoorClose(AtsEx.PluginHost.Native.DoorEventArgs e) {
doorOpen = false;
doorCloseTime = time;
}
-
- private void HornBlow(int type){
- }
-
- }
+ private void HornBlow(int type) {
+
+ }
+
+ }
}
\ No newline at end of file
diff --git a/TGMT-CBTC-EX/Load.cs b/TGMT-CBTC-EX/Load.cs
index c4b12af..63d533f 100644
--- a/TGMT-CBTC-EX/Load.cs
+++ b/TGMT-CBTC-EX/Load.cs
@@ -31,6 +31,7 @@ public partial class TGMTAts : AssemblyPluginBase {
public static int doorMode = 1;
// 无线电
public static bool RadioAvailable = false;
+ public static bool RadioFailed = false;
// WCU可用性
public static bool WCUAvailable = false;
@@ -48,6 +49,7 @@ public partial class TGMTAts : AssemblyPluginBase {
//定位策略
public static int BaliseCount = 0;
+ public static double SigUpgradePosition = Config.LessInf;
public static bool Localized = false;
public static double reverseStartLocation = Config.LessInf;
@@ -93,6 +95,10 @@ private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEven
return null;
}
+ private static void CTCUpgrade() {
+ signalMode = 2;
+ FixIncompatibleModes();
+ }
static void FixIncompatibleModes() {
if (BaliseCount >= 2) { Localized = true; BaliseCount = 0; }
if (WCUAvailable) {
@@ -107,7 +113,6 @@ static void FixIncompatibleModes() {
} else {
signalMode = 0;
}
-
}
public static int ConvertTime(int human) {
@@ -143,6 +148,7 @@ public override void Dispose() {
PreTrainManager.ResetCache();
RadioAvailable = false;
+ RadioFailed = false;
WCUAvailable = false;
doorMode = 1;
signalMode = 2;
diff --git a/TGMT-CBTC-EX/Patterns/StationManager.cs b/TGMT-CBTC-EX/Patterns/StationManager.cs
index 7a4d474..cc57504 100644
--- a/TGMT-CBTC-EX/Patterns/StationManager.cs
+++ b/TGMT-CBTC-EX/Patterns/StationManager.cs
@@ -64,25 +64,28 @@ public static void Update(AtsEx.PluginHost.Native.VehicleState state, bool doorS
public static SpeedLimit RecommendCurve() {
if (TGMTAts.signalMode > 1 && NextStation.Pass) {
return SpeedLimit.inf;
- }else{
- if (NextStation.StopPosition >= (int)Config.LessInf){
+ } else {
+ if (NextStation.StopPosition >= (int)Config.LessInf) {
return SpeedLimit.inf;
- }else if (Arrived){
+ } else if (Arrived) {
return SpeedLimit.inf;
- }else if (Stopped){
+ } else if (Stopped) {
return new SpeedLimit(0, 0);
- }else{
+ } else {
return new SpeedLimit(0, NextStation.StopPosition);
}
}
}
public static SpeedLimit CTCEndpoint() {
- if (TGMTAts.time > NextStation.RouteOpenTime) {
- return SpeedLimit.inf;
- } else {
- return new SpeedLimit(0, NextStation.StopPosition + Config.StationMotionEndpoint);
- }
+ return TGMTAts.WCUAvailable ?
+ (TGMTAts.mapPlugin.TrainHold && !NextStation.Pass ? new SpeedLimit(0, NextStation.StopPosition + Config.StationMotionEndpoint) : SpeedLimit.inf)
+ : SpeedLimit.inf;
+ //if (TGMTAts.time > NextStation.RouteOpenTime) {
+ // return SpeedLimit.inf;
+ //} else {
+ // return new SpeedLimit(0, NextStation.StopPosition + Config.StationMotionEndpoint);
+ //}
}
}
}
diff --git a/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj b/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
index e101fc8..e3e2953 100644
--- a/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
+++ b/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
@@ -46,6 +46,7 @@
+
@@ -99,7 +100,6 @@
-
-
+ COPY $(TargetPath) D:\Scenarios\CRT4\AtsEX\AtsEXPlugins\$(TargetFileName)
\ No newline at end of file
diff --git a/TGMT-CBTC-EX/TickNew.cs b/TGMT-CBTC-EX/TickNew.cs
index cefbe6d..c159d48 100644
--- a/TGMT-CBTC-EX/TickNew.cs
+++ b/TGMT-CBTC-EX/TickNew.cs
@@ -93,6 +93,15 @@ public override TickResult Tick(TimeSpan elapsed) {
trackLimit.Update(location);
StationManager.Update(state, doorOpen);
+ //CTC升级策略
+ if (WCUAvailable && !RadioFailed) {
+ if (state.Location > mapPlugin.NextSectionLocation - 5) {
+ if (signalMode < 2 && RadioAvailable) CTCUpgrade();
+ } else if (Math.Abs(StationManager.NextStation.StopPosition - location) < Config.StationStartDistance) {
+ if (RadioAvailable && (selectedMode == 2 || selectedMode == 4) && signalMode < 2) CTCUpgrade();
+ }
+ }
+
CalculatedLimit maximumCurve = null, targetCurve = null, recommendCurve = null;
switch (signalMode) {
case 0:
@@ -121,17 +130,16 @@ public override TickResult Tick(TimeSpan elapsed) {
case 2:
// CTC
releaseSpeed = false;
- movementEndpoint = StationManager.CTCEndpoint();
if (selectedMode > 0 && driveMode == 0) driveMode = 1;
maximumCurve = CalculatedLimit.Calculate(location,
- Config.EbPatternDeceleration, Config.RecommendSpeedOffset, movementEndpoint,
+ Config.EbPatternDeceleration, Config.RecommendSpeedOffset, StationManager.CTCEndpoint(),
PreTrainManager.GetEndpoint(), trackLimit);
targetCurve = CalculatedLimit.Calculate(location,
- Config.EbPatternDeceleration, 0, movementEndpoint,
+ Config.EbPatternDeceleration, 0, StationManager.CTCEndpoint(),
PreTrainManager.GetEndpoint(), trackLimit);
recommendCurve = CalculatedLimit.Calculate(location,
Config.RecommendDeceleration, 0, StationManager.RecommendCurve(),
- PreTrainManager.GetEndpoint(), movementEndpoint, trackLimit);
+ PreTrainManager.GetEndpoint(), StationManager.CTCEndpoint(), trackLimit);
break;
default:
// fallback
@@ -153,7 +161,7 @@ public override TickResult Tick(TimeSpan elapsed) {
if (ITCNextSectionPos == -114514) {
recommendSpeed = 0;
ebSpeed = 0;
- ackMessage = 6;
+ if (state.Speed == 0) ackMessage = 6;
} else if (location > ITCNextSectionPos) {
// 如果已冲出移动授权终点,释放速度无效
if (releaseSpeed) Log("超出了移动授权终点, 释放速度无效");
@@ -167,7 +175,17 @@ public override TickResult Tick(TimeSpan elapsed) {
targetSpeed = 0;
}
}
+ }
+ if (RadioFailed) {
+ if (signalMode == 2) {
+ targetDistance = -10;
+ targetSpeed = -10;
+ recommendSpeed = 0;
+ ebSpeed = 0;
+ if (atsSound0.PlayState != PlayState.PlayingLoop) atsSound0.PlayLoop();
+ if (state.Speed == 0) ackMessage = 6;
+ } else RadioFailed = false;
}
if (releaseSpeed) {
@@ -181,9 +199,16 @@ public override TickResult Tick(TimeSpan elapsed) {
panel_[24] = driveMode;
panel_[25] = signalMode;
panel_[28] = (driveMode > 0) ? (driveMode > 1 ? doorMode : 1) : 0;
+
+ //WCU通信
if (WCUAvailable) {
mapPlugin.OBCULevel = signalMode;
mapPlugin.SelfTrainLocation = state.Location;
+ mapPlugin.AtStation = Math.Abs(StationManager.NextStation.StopPosition - location) < Config.StationStartDistance;
+ mapPlugin.CurrentTime = state.Time;
+ mapPlugin.SelfTrainSpeed = state.Speed;
+ mapPlugin.StopAtPos = Math.Abs(StationManager.NextStation.StopPosition - location) < Config.DoorEnableWindow;
+ mapPlugin.RadioAvailable = RadioAvailable;
} else RadioAvailable = false;
// 显示临时预选模式
@@ -239,7 +264,7 @@ public override TickResult Tick(TimeSpan elapsed) {
}
// 显示出发信息
- if (signalMode > 1 && state.Speed == 0) {
+ if (signalMode > 1 && state.Speed == 0 && WCUAvailable) {
if (Math.Abs(StationManager.NextStation.StopPosition - location) < Config.DoorEnableWindow
&& time > StationManager.NextStation.DepartureTime - Config.DepartRequestTime * 1000 && !doorOpen && StationManager.Arrived
&& time >= StationManager.NextStation.RouteOpenTime && panel_[29] != 3) {
@@ -249,8 +274,7 @@ public override TickResult Tick(TimeSpan elapsed) {
&& StationManager.Arrived && time >= StationManager.NextStation.RouteOpenTime) {
panel_[32] = 1;
atsSound1.Play();
- } else if (Math.Abs(StationManager.NextStation.StopPosition - location) < Config.DoorEnableWindow
- && time < StationManager.NextStation.RouteOpenTime) {
+ } else if (mapPlugin.TrainHold && !StationManager.NextStation.Pass) {
panel_[32] = 4;
} else {
panel_[32] = 0;
@@ -313,6 +337,33 @@ public override TickResult Tick(TimeSpan elapsed) {
}
}
+ // 防溜、车门零速保护
+ if (state.Speed < 0.5 && handles.Power.Notch < 1 && handles.Brake.Notch < 1 && driveMode != 2) {
+ bCommand = Math.Min(Math.Max(bCommand, 1), handles.Brake.MaxServiceBrakeNotch);
+ }
+
+ if (doorOpen || panel_[32] == 4) {
+ panel_[15] = -10 * speedMultiplier;
+ panel_[16] = 0;
+ if (handles.Brake.Notch < 4) bCommand = Math.Min(Math.Max(bCommand, 1), handles.Brake.MaxServiceBrakeNotch);
+ }
+
+ // 后退监督: 每1m一次紧制 (先这么做着, 有些地区似乎是先1m之后每次0.5m)
+ if (handles.Reverser.Position == ReverserPosition.B) {
+ if (location > reverseStartLocation) reverseStartLocation = location;
+ if (location < reverseStartLocation - Config.ReverseStepDistance) {
+ if (state.Speed == 0 && handles.Power.Notch == 0) {
+ reverseStartLocation = location;
+ } else {
+ panel_[10] = 2;
+ panel_[29] = 2;
+ bCommand = Math.Max(bCommand, handles.Brake.EmergencyBrakeNotch);
+ }
+ }
+ } else if (state.Speed >= 0) {
+ reverseStartLocation = Config.LessInf;
+ }
+
// ATP 制动干预部分
if (ebSpeed > 0) {
// 有移动授权
@@ -320,7 +371,7 @@ public override TickResult Tick(TimeSpan elapsed) {
if (atsSound0.PlayState != PlayState.Stop) atsSound0.Stop();
// 低于制动缓解速度
if (ebState > 0) {
- if (signalMode == 2 && location > movementEndpoint.Location) {
+ if (signalMode == 2 && location > StationManager.CTCEndpoint().Location) {
// 冲出移动授权终点,要求RM
ackMessage = 6;
} else {
@@ -357,7 +408,6 @@ public override TickResult Tick(TimeSpan elapsed) {
if (state.Speed == 0 && location > ITCNextSectionPos) {
// 停稳后降级到RM模式。等待确认。
ackMessage = 6;
- Localized = false;
}
ebState = 1;
// 显示紧急制动、目标距离0、速度0
@@ -367,42 +417,23 @@ public override TickResult Tick(TimeSpan elapsed) {
panel_[19] = 0;
panel_[17] = 0;
bCommand = Math.Max(bCommand, handles.Brake.EmergencyBrakeNotch);
+ } else if (RadioFailed) {
+ ebState = 1;
+ panel_[10] = 2;
+ panel_[29] = 2;
+ bCommand = Math.Max(bCommand, handles.Brake.EmergencyBrakeNotch);
}
- // 防溜、车门零速保护
- if (state.Speed < 0.5 && handles.Power.Notch < 1 && handles.Brake.Notch < 1 && driveMode != 2) {
- bCommand = Math.Min(Math.Max(bCommand, 1), handles.Brake.MaxServiceBrakeNotch);
- }
-
- if (doorOpen || panel_[32] == 4) {
- panel_[15] = -10 * speedMultiplier;
- panel_[16] = 0;
- if (handles.Brake.Notch < 4) bCommand = Math.Min(Math.Max(bCommand, 1), handles.Brake.MaxServiceBrakeNotch);
- }
-
- // 后退监督: 每1m一次紧制 (先这么做着, 有些地区似乎是先1m之后每次0.5m)
- if (handles.Reverser.Position == ReverserPosition.B) {
- if (location > reverseStartLocation) reverseStartLocation = location;
- if (location < reverseStartLocation - Config.ReverseStepDistance) {
- if (state.Speed == 0 && handles.Power.Notch == 0) {
- reverseStartLocation = location;
- } else {
- panel_[10] = 2;
- panel_[29] = 2;
- bCommand = Math.Max(bCommand, handles.Brake.EmergencyBrakeNotch);
- }
- }
- } else if (state.Speed >= 0) {
- reverseStartLocation = Config.LessInf;
- }
// 显示释放速度、确认消息
if (releaseSpeed) panel_[31] = 3;
+
//定位策略
if (!Localized) {
panel_[31] = 2;
if (BaliseCount >= 2) { Localized = true; BaliseCount = 0; }
}
+
if (ackMessage > 0) {
panel_[35] = ackMessage;
panel_[36] = atsPanel36.Value = ((state.Time.TotalMilliseconds / 1000) % 0.5 < 0.25) ? 1 : 0;
@@ -418,7 +449,7 @@ public override TickResult Tick(TimeSpan elapsed) {
if (location - StationManager.NextStation.StopPosition < Config.TDTFreezeDistance) {
// 未发车
// 这里先要求至少100m的移动授权
- if (movementEndpoint.Location - location > 100) {
+ if ((signalMode == 1 && movementEndpoint.Location - location > 100) || (signalMode == 2 && StationManager.CTCEndpoint().Location - location > 100)) {
// 出站信号绿灯
if (sectogo < 0) {
// 未到发车时间
@@ -450,7 +481,7 @@ public override TickResult Tick(TimeSpan elapsed) {
// 在车站范围内
if (Math.Abs(StationManager.NextStation.StopPosition - location) < Config.DoorEnableWindow) {
// 在停车窗口内
- if (state.Speed < 5) {
+ if (state.Speed < 2) {
panel_[26] = 2;
} else {
panel_[26] = 1;
@@ -493,7 +524,8 @@ public override TickResult Tick(TimeSpan elapsed) {
}
}
- if (TGMTAts.signalMode > 1 && StationManager.NextStation.Pass && Math.Abs(StationManager.NextStation.StopPosition - location) < Config.StationStartDistance + 200) panel_[32] = 3;
+ if (TGMTAts.signalMode > 1 && StationManager.NextStation.Pass &&
+ Math.Abs(StationManager.NextStation.StopPosition - location) < Config.StationStartDistance + 200) panel_[32] = 3;
// 信号灯
if (signalMode >= 2) {
diff --git a/TGMT-CBTC-EX/UserInterface/DebugWindow.cs b/TGMT-CBTC-EX/UserInterface/DebugWindow.cs
index 382bb21..7841a82 100644
--- a/TGMT-CBTC-EX/UserInterface/DebugWindow.cs
+++ b/TGMT-CBTC-EX/UserInterface/DebugWindow.cs
@@ -27,7 +27,7 @@ private void timer1_Tick(object sender, EventArgs e) {
sb.AppendFormat("下一限速 : {0,6} {1,-4}\n", D(TGMTAts.nextLimit.Location), D(TGMTAts.nextLimit.Limit));
}
sb.AppendLine();
- sb.AppendFormat("授权终点 : {0,6}\n", D(TGMTAts.movementEndpoint.Location));
+ sb.AppendFormat("ITC授权终点 : {0,6}\n", D(TGMTAts.movementEndpoint.Location));
var pretrain = PreTrainManager.GetEndpoint();
sb.AppendFormat("前车信息 : {0,6} {1,-4}\n", D(pretrain.Location), D(pretrain.Limit));
sb.AppendFormat("车站 : {0,6} {1} {2}\n",
diff --git a/TGMT-CBTC-EX/UserInterface/TGMTPainter.cs b/TGMT-CBTC-EX/UserInterface/TGMTPainter.cs
index 2b377aa..71fe22d 100644
--- a/TGMT-CBTC-EX/UserInterface/TGMTPainter.cs
+++ b/TGMT-CBTC-EX/UserInterface/TGMTPainter.cs
@@ -55,6 +55,14 @@ public static GDIHelper PaintHMI(AtsEx.PluginHost.Native.VehicleState state) {
hHMI.BeginGDI();
hHMI.DrawImage(hmi, 0, 0);
+ var sec = Convert.ToInt32(state.Time.TotalMilliseconds) / 1000 % 60;
+ if (sec % 2 == 0) {
+ hHMI.DrawImage(colon, 214, 552);
+ hHMI.DrawImage(colon, 256, 552);
+ }
+ var min = Convert.ToInt32(state.Time.TotalMilliseconds) / 1000 / 60 % 60;
+ var hrs = Convert.ToInt32(state.Time.TotalMilliseconds) / 1000 / 3600 % 60;
+
hHMI.DrawImage(menu, 681, 66, TGMTAts.panel_[23] * 64, 64);
hHMI.DrawImage(drvmode, 589, 133, TGMTAts.panel_[24] * 64, 64);
hHMI.DrawImage(sigmode, 686, 133, TGMTAts.panel_[25] * 64, 64);
@@ -87,19 +95,12 @@ public static GDIHelper PaintHMI(AtsEx.PluginHost.Native.VehicleState state) {
hHMI.DrawImage(num0, 634, 31, D(TGMTAts.DestinationNumber, 1) * 18, 18);
hHMI.DrawImage(num0, 620, 31, D(TGMTAts.DestinationNumber, 2) * 18, 18);
- var sec = Convert.ToInt32(state.Time.TotalMilliseconds) / 1000 % 60;
- var min = Convert.ToInt32(state.Time.TotalMilliseconds) / 1000 / 60 % 60;
- var hrs = Convert.ToInt32(state.Time.TotalMilliseconds) / 1000 / 3600 % 60;
hHMI.DrawImage(num0, 186, 552, D(hrs, 1) * 18, 18);
hHMI.DrawImage(num0, 200, 552, D(hrs, 0) * 18, 18);
hHMI.DrawImage(num0, 228, 552, D(min, 1) * 18, 18);
hHMI.DrawImage(num0, 242, 552, D(min, 0) * 18, 18);
hHMI.DrawImage(num0, 270, 552, D(sec, 1) * 18, 18);
hHMI.DrawImage(num0, 284, 552, D(sec, 0) * 18, 18);
- if (sec % 2 == 0) {
- hHMI.DrawImage(colon, 214, 552);
- hHMI.DrawImage(colon, 256, 552);
- }
hHMI.EndGDI();
hHMI.Graphics.FillRectangle(overspeed[TGMTAts.panel_[10]], new Rectangle(20, 18, 80, 78));
diff --git a/TGMT-CBTC-EX_WCU/PluginMain.cs b/TGMT-CBTC-EX_WCU/PluginMain.cs
index c124470..eeb8eb4 100644
--- a/TGMT-CBTC-EX_WCU/PluginMain.cs
+++ b/TGMT-CBTC-EX_WCU/PluginMain.cs
@@ -9,6 +9,7 @@
using System.IO;
using System.Collections.Generic;
using System.Windows.Forms;
+using System.Linq;
namespace TGMTAts.WCU {
@@ -17,18 +18,42 @@ public class TGMTAts : AssemblyPluginBase {
static TGMTAts() {
Config.Load(Path.Combine(Config.PluginDir, "TGMT_WCUConfig.txt"));
}
+ //WCU -> OBCU
+ private double MA = 0;
+ public double MovementAuthority {
+ get {
+ return MA;
+ }
+ }
+ private double nextBlockLocation = 0;
+ public double NextSectionLocation {
+ get {
+ return nextBlockLocation;
+ }
+ }
+ private bool isTrainHold = false;
+ public bool TrainHold {
+ get {
+ return isTrainHold;
+ }
+ }
- public double MovementAuthority { get; set; } = 0;
+ //OBCU -> WCU
public int OBCULevel { get; set; } = 0;
public double SelfTrainLocation { get; set; } = 0;
- public double NextSectionLocation { get; set; } = 0;
+ public double SelfTrainSpeed { get; set; } = 0;
+ public TimeSpan CurrentTime { get; set; } = new TimeSpan();
public bool AtStation { get; set; } = false;
+ public bool StopAtPos { get; set; } = false;
+ public bool RadioAvailable { get; set; } = false;
private List SignalPatch = new List();
private Train Train;
private PreTrainPatch PreTrainPatch;
private SectionManager sectionManager;
+ private StationList staList;
private bool TrainLoaded = false;
+ private Station NextSta;
public TGMTAts(PluginBuilder builder) : base(builder) {
@@ -37,7 +62,7 @@ public TGMTAts(PluginBuilder builder) : base(builder) {
}
private void OnAllPluginsLoaded(object sender, EventArgs e) {
- MovementAuthority = OBCULevel = 0;
+ MA = OBCULevel = 0;
}
@@ -54,14 +79,14 @@ private void OnScenarioCreated(ScenarioCreatedEventArgs e) {
int pointer = 0;
while (pointer < sectionManager.Sections.Count - 1) {
- SignalPatch.Add(Extensions.GetExtension().Patch(nameof(SignalPatch), sectionManager.Sections[pointer] as Section,
- source => (sectionManager.Sections[pointer].Location >= SelfTrainLocation && sectionManager.Sections[pointer].Location >= Config.TGMTTerrtoryStart
- && sectionManager.Sections[pointer].Location < Config.TGMTTerrtoryEnd)
- ? (OBCULevel == 2)
+ SignalPatch.Add(Extensions.GetExtension().Patch(nameof(SignalPatch), sectionManager.Sections[pointer] as Section, source =>
+ (sectionManager.Sections[pointer].Location >= SelfTrainLocation && sectionManager.Sections[pointer].Location >= Config.TGMTTerrtoryStart && sectionManager.Sections[pointer].Location < Config.TGMTTerrtoryEnd)
+ ? (OBCULevel == 2 && RadioAvailable)
? (int)Config.CTCSignalIndex : source : source));
++pointer;
}
+ NextSta = e.Scenario.Route.Stations[0] as Station;
}
public override void Dispose() {
@@ -70,10 +95,14 @@ public override void Dispose() {
Plugins.AllPluginsLoaded -= OnAllPluginsLoaded;
BveHacker.ScenarioCreated -= OnScenarioCreated;
TrainLoaded = false;
- MovementAuthority = 0;
+ MA = 0;
OBCULevel = 0;
SelfTrainLocation = 0;
- NextSectionLocation = 0;
+ nextBlockLocation = 0;
+ isTrainHold = AtStation = false;
+ RadioAvailable = false;
+ CurrentTime = new TimeSpan();
+
}
private class PreTrainLocationConverter : IPreTrainLocationConverter {
@@ -100,8 +129,27 @@ public override TickResult Tick(TimeSpan elapsed) {
var CurrentSection = sectionManager.Sections[pointer == 0 ? 0 : pointer - 1] as Section;
var NextSection = sectionManager.Sections[pointer] as Section;
- NextSectionLocation = NextSection.Location;
- if (TrainLoaded) MovementAuthority = Train.Location;
+ if (AtStation) {
+ if (StopAtPos) {
+ int pointer_ = 0;
+ while (BveHacker.Scenario.Route.Stations[pointer_].Location < SelfTrainLocation - 25)
+ pointer_++;
+ NextSta = BveHacker.Scenario.Route.Stations[pointer_] as Station;
+ }
+ if (CurrentTime.TotalMilliseconds < (NextSta.DepertureTimeMilliseconds - NextSta.StoppageTimeMilliseconds) && NextSta.SignalFlag == true)
+ isTrainHold = true;
+ else isTrainHold = false;
+ } else {
+ int pointer_ = 0;
+ while (BveHacker.Scenario.Route.Stations[pointer_].Location < SelfTrainLocation - 25)
+ pointer_++;
+ NextSta = BveHacker.Scenario.Route.Stations[pointer_] as Station;
+ isTrainHold = false;
+ }
+
+
+ nextBlockLocation = NextSection.Location;
+ if (TrainLoaded) MA = Train.Location;
return new MapPluginTickResult();
}
diff --git a/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj b/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
index 2145020..9e10dba 100644
--- a/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
+++ b/TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
@@ -68,7 +68,6 @@
-
-
+ COPY $(TargetPath) D:\Scenarios\新浜線(架空)\NiihamaLine\MapPlugins\$(TargetFileName)
\ No newline at end of file
From b5e3a468fbdaf1d1e33d9b2499b3126f345fb730 Mon Sep 17 00:00:00 2001
From: winup-zhou <3166832341@qq.com>
Date: Sun, 27 Oct 2024 15:48:10 +0800
Subject: [PATCH 6/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF?=
=?UTF-8?q?=E7=9A=84=E5=BC=95=E7=94=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
TGMT-CBTC-EX/TGMT-CBTC-EX.csproj | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj b/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
index 788708b..12758aa 100644
--- a/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
+++ b/TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
@@ -92,8 +92,15 @@
1.0.0
+
+
+ {ab7ee309-f15f-4ad4-a658-d0dd210627ce}
+ TGMT-CBTC-EX_WCU
+
+
-
+
+
\ No newline at end of file
From 8def09667c52e741d986551a694edd39e3ee39e3 Mon Sep 17 00:00:00 2001
From: winup-zhou <3166832341@qq.com>
Date: Sun, 27 Oct 2024 22:33:10 +0800
Subject: [PATCH 7/9] =?UTF-8?q?=E5=B0=86=E8=BD=A6=E7=AB=99=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF=E5=8A=9F=E8=83=BD=E8=BF=81=E7=A7=BB=E8=87=B3WCU?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
TGMT-CBTC-EX/Config.cs | 2 +-
TGMT-CBTC-EX/Load.cs | 6 +-
TGMT-CBTC-EX/Patterns/StationManager.cs | 33 +++++++----
TGMT-CBTC-EX/TickNew.cs | 67 ++++++++++++-----------
TGMT-CBTC-EX/UserInterface/TGMTPainter.cs | 31 +++++++----
TGMT-CBTC-EX_WCU/PluginMain.cs | 31 ++++++++++-
6 files changed, 112 insertions(+), 58 deletions(-)
diff --git a/TGMT-CBTC-EX/Config.cs b/TGMT-CBTC-EX/Config.cs
index bfb1775..aad3c16 100644
--- a/TGMT-CBTC-EX/Config.cs
+++ b/TGMT-CBTC-EX/Config.cs
@@ -30,7 +30,7 @@ public static class Config {
public static double StationEndDistance = 5;
public static double StationMotionEndpoint = 3;
public static double CTCSafetyDistance = 30;
- public static double CloseRequestShowTime = 1000;
+ public static double CloseRequestShowTime = 10;
public static double ITCSafetyDistance = 20;
public static double TrainLength = 0;
diff --git a/TGMT-CBTC-EX/Load.cs b/TGMT-CBTC-EX/Load.cs
index 63d533f..bb80c22 100644
--- a/TGMT-CBTC-EX/Load.cs
+++ b/TGMT-CBTC-EX/Load.cs
@@ -43,8 +43,8 @@ public partial class TGMTAts : AssemblyPluginBase {
public static bool releaseSpeed = false;
public static int ackMessage = 0;
- public static int TrainNumber = 0;
- public static int DestinationNumber = 0;
+ public static int TrainNumber = -114514;
+ public static int DestinationNumber = -114514;
public static double ITCNextSectionPos = -114514;
//定位策略
@@ -142,7 +142,7 @@ public override void Dispose() {
ebState = 0;
ackMessage = 0;
- DestinationNumber = TrainNumber = 0;
+ DestinationNumber = TrainNumber = -114514;
Ato.ResetCache();
PreTrainManager.ResetCache();
diff --git a/TGMT-CBTC-EX/Patterns/StationManager.cs b/TGMT-CBTC-EX/Patterns/StationManager.cs
index cc57504..a792e95 100644
--- a/TGMT-CBTC-EX/Patterns/StationManager.cs
+++ b/TGMT-CBTC-EX/Patterns/StationManager.cs
@@ -2,14 +2,16 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Windows.Forms;
+using TGMTAts.WCU;
namespace TGMTAts.OBCU {
public static class StationManager {
public class Station {
+ public bool CanSetPos = true;
public int StopPosition = (int)Config.LessInf;
- public int RouteOpenTime = 0;
public int DepartureTime = 0;
public int DoorOpenType = 0;
//增加功能 跳停
@@ -27,21 +29,28 @@ public class Station {
public static void SetBeacon(AtsEx.PluginHost.Native.BeaconPassedEventArgs data) {
switch (data.Type) {
- case 96820:
- NextStation.StopPosition = Math.Abs(data.Optional);
- NextStation.Pass = data.Optional < 0;
- TGMTAts.Log("车站停车位置 " + NextStation.StopPosition.ToString());
- break;
+ //case 96820:
+ // NextStation.StopPosition = Math.Abs(data.Optional);
+ // NextStation.Pass = data.Optional < 0;
+ // TGMTAts.Log("车站停车位置 " + NextStation.StopPosition.ToString());
+ // break;
case 96821:
NextStation.DoorOpenType = data.Optional;
break;
- case 96822:
- NextStation.RouteOpenTime = TGMTAts.ConvertTime(data.Optional) * 1000;
- break;
- case 96823:
- NextStation.DepartureTime = TGMTAts.ConvertTime(data.Optional) * 1000;
- break;
+ //case 96823:
+ // NextStation.DepartureTime = TGMTAts.ConvertTime(data.Optional) * 1000;
+ // break;
+ }
+ }
+
+ public static void SetStation(double Location,bool isPass, TimeSpan DepTime) {
+ if (NextStation.CanSetPos) {
+ NextStation.StopPosition = (int)Location;
+ TGMTAts.Log("车站停车位置 " + NextStation.StopPosition.ToString());
+ NextStation.CanSetPos = false;
}
+ NextStation.Pass = isPass;
+ NextStation.DepartureTime = (int)DepTime.TotalMilliseconds;
}
public static void Update(AtsEx.PluginHost.Native.VehicleState state, bool doorState) {
diff --git a/TGMT-CBTC-EX/TickNew.cs b/TGMT-CBTC-EX/TickNew.cs
index c159d48..2ea763a 100644
--- a/TGMT-CBTC-EX/TickNew.cs
+++ b/TGMT-CBTC-EX/TickNew.cs
@@ -87,12 +87,26 @@ public override TickResult Tick(TimeSpan elapsed) {
pReverser = handles.Reverser.Position;
int pCommand = 0, bCommand = 0;
- ReverserPosition rCommand = 0;
+ ReverserPosition rCommand = handles.Reverser.Position;
double ebSpeed = 0, recommendSpeed = 0, targetSpeed = 0, targetDistance = 0;
trackLimit.Update(location);
StationManager.Update(state, doorOpen);
+ //WCU通信
+ if (WCUAvailable) {
+ //to WCU
+ mapPlugin.OBCULevel = signalMode;
+ mapPlugin.SelfTrainLocation = state.Location;
+ mapPlugin.AtStation = Math.Abs(StationManager.NextStation.StopPosition - location) < Config.StationStartDistance;
+ mapPlugin.CurrentTime = state.Time;
+ mapPlugin.SelfTrainSpeed = state.Speed;
+ mapPlugin.StopAtPos = Math.Abs(StationManager.NextStation.StopPosition - location) < Config.DoorEnableWindow;
+ mapPlugin.RadioAvailable = RadioAvailable;
+ //from WCU
+ StationManager.SetStation(mapPlugin.StationLocation, mapPlugin.NextStaPass, mapPlugin.DepTime);
+ } else RadioAvailable = false;
+
//CTC升级策略
if (WCUAvailable && !RadioFailed) {
if (state.Location > mapPlugin.NextSectionLocation - 5) {
@@ -200,17 +214,6 @@ public override TickResult Tick(TimeSpan elapsed) {
panel_[25] = signalMode;
panel_[28] = (driveMode > 0) ? (driveMode > 1 ? doorMode : 1) : 0;
- //WCU通信
- if (WCUAvailable) {
- mapPlugin.OBCULevel = signalMode;
- mapPlugin.SelfTrainLocation = state.Location;
- mapPlugin.AtStation = Math.Abs(StationManager.NextStation.StopPosition - location) < Config.StationStartDistance;
- mapPlugin.CurrentTime = state.Time;
- mapPlugin.SelfTrainSpeed = state.Speed;
- mapPlugin.StopAtPos = Math.Abs(StationManager.NextStation.StopPosition - location) < Config.DoorEnableWindow;
- mapPlugin.RadioAvailable = RadioAvailable;
- } else RadioAvailable = false;
-
// 显示临时预选模式
if (state.Speed != 0 || time > selectModeStartTime + Config.ModeSelectTimeout * 1000) {
selectingMode = -1;
@@ -249,14 +252,6 @@ public override TickResult Tick(TimeSpan elapsed) {
}
// 显示目标速度、建议速度、干预速度
- if (signalMode > 1 && state.Speed == 0 &&
- Math.Abs(StationManager.NextStation.StopPosition - location) < Config.DoorEnableWindow
- && time < StationManager.NextStation.RouteOpenTime) {
- targetDistance = 0;
- targetSpeed = -10;
- ebSpeed = recommendSpeed = 0;
- }
-
if (doorOpen) {
targetDistance = 0;
targetSpeed = -10;
@@ -265,16 +260,17 @@ public override TickResult Tick(TimeSpan elapsed) {
// 显示出发信息
if (signalMode > 1 && state.Speed == 0 && WCUAvailable) {
- if (Math.Abs(StationManager.NextStation.StopPosition - location) < Config.DoorEnableWindow
- && time > StationManager.NextStation.DepartureTime - Config.DepartRequestTime * 1000 && !doorOpen && StationManager.Arrived
- && time >= StationManager.NextStation.RouteOpenTime && panel_[29] != 3) {
+ if (!mapPlugin.TrainHold && state.Time.TotalMilliseconds > StationManager.NextStation.DepartureTime - 5000 && panel_[29] != 3 &&
+ Math.Abs(StationManager.NextStation.StopPosition - location) < Config.DoorEnableWindow) {
panel_[32] = 2;
- } else if (Math.Abs(StationManager.NextStation.StopPosition - location) < Config.DoorEnableWindow
- && time - doorOpenTime >= Config.CloseRequestShowTime * 1000 && doorOpen && time > StationManager.NextStation.DepartureTime - (Config.DepartRequestTime + 20) * 1000
- && StationManager.Arrived && time >= StationManager.NextStation.RouteOpenTime) {
+ } else if (!mapPlugin.TrainHold && state.Time.TotalMilliseconds > StationManager.NextStation.DepartureTime - Config.DepartRequestTime * 1000 &&
+ Math.Abs(StationManager.NextStation.StopPosition - location) < Config.DoorEnableWindow) {
panel_[32] = 1;
atsSound1.Play();
} else if (mapPlugin.TrainHold && !StationManager.NextStation.Pass) {
+ targetDistance = 0;
+ targetSpeed = -10;
+ ebSpeed = recommendSpeed = 0;
panel_[32] = 4;
} else {
panel_[32] = 0;
@@ -338,14 +334,15 @@ public override TickResult Tick(TimeSpan elapsed) {
}
// 防溜、车门零速保护
- if (state.Speed < 0.5 && handles.Power.Notch < 1 && handles.Brake.Notch < 1 && driveMode != 2) {
- bCommand = Math.Min(Math.Max(bCommand, 1), handles.Brake.MaxServiceBrakeNotch);
- }
+ //if (state.Speed < 0.5 && handles.Power.Notch < 1 && handles.Brake.Notch < 1 && driveMode != 2) {
+ // bCommand = Math.Min(Math.Max(bCommand, 1), handles.Brake.MaxServiceBrakeNotch);
+ //}
if (doorOpen || panel_[32] == 4) {
panel_[15] = -10 * speedMultiplier;
panel_[16] = 0;
- if (handles.Brake.Notch < 4) bCommand = Math.Min(Math.Max(bCommand, 1), handles.Brake.MaxServiceBrakeNotch);
+ //if (handles.Brake.Notch < 4) bCommand = Math.Min(Math.Max(bCommand, 1), handles.Brake.MaxServiceBrakeNotch);
+ rCommand = ReverserPosition.N;
}
// 后退监督: 每1m一次紧制 (先这么做着, 有些地区似乎是先1m之后每次0.5m)
@@ -422,6 +419,14 @@ public override TickResult Tick(TimeSpan elapsed) {
panel_[10] = 2;
panel_[29] = 2;
bCommand = Math.Max(bCommand, handles.Brake.EmergencyBrakeNotch);
+ } else if (ebSpeed == 0) {
+ if (state.Speed > 0) {
+ ebState = 1;
+ panel_[10] = 2;
+ panel_[29] = 2;
+ bCommand = Math.Max(bCommand, handles.Brake.EmergencyBrakeNotch);
+ if (atsSound0.PlayState != PlayState.PlayingLoop) atsSound0.PlayLoop();
+ }
}
@@ -549,7 +554,7 @@ public override TickResult Tick(TimeSpan elapsed) {
NotchCommandBase powerCommand = handles.Power.GetCommandToSetNotchTo(Math.Max(pCommand, handles.Power.Notch));
NotchCommandBase brakeCommand = handles.Brake.GetCommandToSetNotchTo(Math.Max(bCommand, handles.Brake.Notch));
- ReverserPositionCommandBase reverserCommand = ReverserPositionCommandBase.Continue;
+ ReverserPositionCommandBase reverserCommand = new ReverserPositionCommandBase.SetPositionCommand(rCommand);
ConstantSpeedCommand? constantSpeedCommand = ConstantSpeedCommand.Continue;
tickResult.HandleCommandSet = new HandleCommandSet(powerCommand, brakeCommand, reverserCommand, constantSpeedCommand);
diff --git a/TGMT-CBTC-EX/UserInterface/TGMTPainter.cs b/TGMT-CBTC-EX/UserInterface/TGMTPainter.cs
index 71fe22d..d7dcf06 100644
--- a/TGMT-CBTC-EX/UserInterface/TGMTPainter.cs
+++ b/TGMT-CBTC-EX/UserInterface/TGMTPainter.cs
@@ -38,7 +38,7 @@ public static void Initialize() {
numn0 = new Bitmap(Path.Combine(imgDir, "num-0.png"));
colon = new Bitmap(Path.Combine(imgDir, "colon.png"));
-
+
tdtbackoff = new Bitmap(Path.Combine(imgDir, "tdt_back_off.png"));
tdtbackred = new Bitmap(Path.Combine(imgDir, "tdt_back_red.png"));
tdtbackgreen = new Bitmap(Path.Combine(imgDir, "tdt_back_green.png"));
@@ -50,7 +50,7 @@ public static void Dispose() {
hHMI.Dispose();
hTDT.Dispose();
}
-
+
public static GDIHelper PaintHMI(AtsEx.PluginHost.Native.VehicleState state) {
hHMI.BeginGDI();
hHMI.DrawImage(hmi, 0, 0);
@@ -84,16 +84,20 @@ public static GDIHelper PaintHMI(AtsEx.PluginHost.Native.VehicleState state) {
}
hHMI.DrawImage(num0, 289, 212, D((int)Math.Abs(Math.Ceiling(state.Speed)), 0) * 18, 18);
hHMI.DrawImage(numn0, 275, 212, D((int)Math.Abs(Math.Ceiling(state.Speed)), 1) * 18, 18);
+ if (TGMTAts.TrainNumber != -114514) {
+ hHMI.DrawImage(num0, 562, 31, D(TGMTAts.TrainNumber, 0) * 18, 18);
+ hHMI.DrawImage(num0, 548, 31, D(TGMTAts.TrainNumber, 1) * 18, 18);
+ hHMI.DrawImage(num0, 534, 31, D(TGMTAts.TrainNumber, 2) * 18, 18);
+ hHMI.DrawImage(num0, 520, 31, D(TGMTAts.TrainNumber, 3) * 18, 18);
+ hHMI.DrawImage(num0, 506, 31, D(TGMTAts.TrainNumber, 4) * 18, 18);
+ }
- hHMI.DrawImage(num0, 562, 31, D(TGMTAts.TrainNumber, 0) * 18, 18);
- hHMI.DrawImage(num0, 548, 31, D(TGMTAts.TrainNumber, 1) * 18, 18);
- hHMI.DrawImage(num0, 534, 31, D(TGMTAts.TrainNumber, 2) * 18, 18);
- hHMI.DrawImage(num0, 520, 31, D(TGMTAts.TrainNumber, 3) * 18, 18);
- hHMI.DrawImage(num0, 506, 31, D(TGMTAts.TrainNumber, 4) * 18, 18);
+ if (TGMTAts.DestinationNumber != -114514) {
+ hHMI.DrawImage(num0, 648, 31, D(TGMTAts.DestinationNumber, 0) * 18, 18);
+ hHMI.DrawImage(num0, 634, 31, D(TGMTAts.DestinationNumber, 1) * 18, 18);
+ hHMI.DrawImage(num0, 620, 31, D(TGMTAts.DestinationNumber, 2) * 18, 18);
+ }
- hHMI.DrawImage(num0, 648, 31, D(TGMTAts.DestinationNumber, 0) * 18, 18);
- hHMI.DrawImage(num0, 634, 31, D(TGMTAts.DestinationNumber, 1) * 18, 18);
- hHMI.DrawImage(num0, 620, 31, D(TGMTAts.DestinationNumber, 2) * 18, 18);
hHMI.DrawImage(num0, 186, 552, D(hrs, 1) * 18, 18);
hHMI.DrawImage(num0, 200, 552, D(hrs, 0) * 18, 18);
@@ -127,6 +131,13 @@ public static GDIHelper PaintHMI(AtsEx.PluginHost.Native.VehicleState state) {
Poc(288, 221, 165, 0, tLimit), Poc(288, 221, 185, -11, tLimit), Poc(288, 221, 185, 11, tLimit)
});
}
+
+ if (TGMTAts.TrainNumber == -114514 || !TGMTAts.RadioAvailable) {
+ hHMI.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(3, 17, 34)), new Rectangle(484, 29, 95, 22));
+ }
+ if (TGMTAts.DestinationNumber == -114514 || TGMTAts.signalMode != 2 || !TGMTAts.RadioAvailable) {
+ hHMI.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(3, 17, 34)), new Rectangle(600, 29, 65, 22));
+ }
return hHMI;
}
diff --git a/TGMT-CBTC-EX_WCU/PluginMain.cs b/TGMT-CBTC-EX_WCU/PluginMain.cs
index eeb8eb4..addc2b7 100644
--- a/TGMT-CBTC-EX_WCU/PluginMain.cs
+++ b/TGMT-CBTC-EX_WCU/PluginMain.cs
@@ -37,6 +37,26 @@ public bool TrainHold {
return isTrainHold;
}
}
+ private bool StaPass = false;
+ private double NextStaLocation = 0;
+ private TimeSpan NextStaDepTime = TimeSpan.Zero;
+
+ public bool NextStaPass {
+ get {
+ return StaPass;
+ }
+ }
+ public double StationLocation {
+ get {
+ return NextStaLocation;
+ }
+ }
+ public TimeSpan DepTime {
+ get {
+ return NextStaDepTime;
+ }
+ }
+
//OBCU -> WCU
public int OBCULevel { get; set; } = 0;
@@ -135,6 +155,11 @@ public override TickResult Tick(TimeSpan elapsed) {
while (BveHacker.Scenario.Route.Stations[pointer_].Location < SelfTrainLocation - 25)
pointer_++;
NextSta = BveHacker.Scenario.Route.Stations[pointer_] as Station;
+ StaPass = NextSta.Pass;
+ NextStaLocation = NextSta.Location;
+ if (NextSta.DepertureTime != TimeSpan.Zero) {
+ NextStaDepTime = NextSta.DepertureTime;
+ } else NextStaDepTime = NextSta.DefaultTime + new TimeSpan(0, 0, 30);
}
if (CurrentTime.TotalMilliseconds < (NextSta.DepertureTimeMilliseconds - NextSta.StoppageTimeMilliseconds) && NextSta.SignalFlag == true)
isTrainHold = true;
@@ -145,9 +170,13 @@ public override TickResult Tick(TimeSpan elapsed) {
pointer_++;
NextSta = BveHacker.Scenario.Route.Stations[pointer_] as Station;
isTrainHold = false;
+ StaPass = NextSta.Pass;
+ NextStaLocation = NextSta.Location;
+ if (NextSta.DepertureTime != TimeSpan.Zero) {
+ NextStaDepTime = NextSta.DepertureTime;
+ } else NextStaDepTime = NextSta.DefaultTime + new TimeSpan(0, 0, 30);
}
-
nextBlockLocation = NextSection.Location;
if (TrainLoaded) MA = Train.Location;
From 1709dd0f34975ce97508c31ed70c38b25f72f282 Mon Sep 17 00:00:00 2001
From: winup-zhou <3166832341@qq.com>
Date: Sun, 27 Oct 2024 22:35:42 +0800
Subject: [PATCH 8/9] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=94=99=E8=AF=AF?=
=?UTF-8?q?=E7=9A=84=E5=8F=91=E8=BD=A6=E6=8C=87=E7=A4=BA=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
TGMT-CBTC-EX/TickNew.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/TGMT-CBTC-EX/TickNew.cs b/TGMT-CBTC-EX/TickNew.cs
index 2ea763a..9fee71f 100644
--- a/TGMT-CBTC-EX/TickNew.cs
+++ b/TGMT-CBTC-EX/TickNew.cs
@@ -261,7 +261,7 @@ public override TickResult Tick(TimeSpan elapsed) {
// 显示出发信息
if (signalMode > 1 && state.Speed == 0 && WCUAvailable) {
if (!mapPlugin.TrainHold && state.Time.TotalMilliseconds > StationManager.NextStation.DepartureTime - 5000 && panel_[29] != 3 &&
- Math.Abs(StationManager.NextStation.StopPosition - location) < Config.DoorEnableWindow) {
+ Math.Abs(StationManager.NextStation.StopPosition - location) < Config.DoorEnableWindow && StationManager.Arrived) {
panel_[32] = 2;
} else if (!mapPlugin.TrainHold && state.Time.TotalMilliseconds > StationManager.NextStation.DepartureTime - Config.DepartRequestTime * 1000 &&
Math.Abs(StationManager.NextStation.StopPosition - location) < Config.DoorEnableWindow) {
From 10abbcf4af13f1ae47ff7e5b5865171a4e5fe362 Mon Sep 17 00:00:00 2001
From: winup-zhou <3166832341@qq.com>
Date: Sun, 27 Oct 2024 22:38:33 +0800
Subject: [PATCH 9/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=88=E6=9C=AC?=
=?UTF-8?q?=E5=8F=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
TGMT-CBTC-EX/Properties/AssemblyInfo.cs | 2 +-
TGMT-CBTC-EX_WCU/Properties/AssemblyInfo.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/TGMT-CBTC-EX/Properties/AssemblyInfo.cs b/TGMT-CBTC-EX/Properties/AssemblyInfo.cs
index ef4ef06..fd355e2 100644
--- a/TGMT-CBTC-EX/Properties/AssemblyInfo.cs
+++ b/TGMT-CBTC-EX/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.2.*")]
+[assembly: AssemblyVersion("0.3.*")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/TGMT-CBTC-EX_WCU/Properties/AssemblyInfo.cs b/TGMT-CBTC-EX_WCU/Properties/AssemblyInfo.cs
index 64f1524..6a6cfd1 100644
--- a/TGMT-CBTC-EX_WCU/Properties/AssemblyInfo.cs
+++ b/TGMT-CBTC-EX_WCU/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.2.*")]
+[assembly: AssemblyVersion("0.3.*")]
//[assembly: AssemblyFileVersion("1.0.0.0")]