Skip to content

Commit

Permalink
ITC功能改进
Browse files Browse the repository at this point in the history
  • Loading branch information
winup-zhou committed Sep 30, 2024
1 parent 59f7ec1 commit 840e961
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 38 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -362,5 +362,4 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd

**/TGMT-CBTC-EX.csproj
**/TGMT-CBTC-EX_WCU.csproj
*.csproj
7 changes: 5 additions & 2 deletions TGMT-CBTC-EX/Inputs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,15 @@ private void SetBeaconData(AtsEx.PluginHost.Native.BeaconPassedEventArgs e) {
FixIncompatibleModes();
if (signalMode == 1) {
if (e.SignalIndex > 0) {
ITCNextSectionPos = e.Optional;
Log("移动授权延伸到 " + e.Optional);
// 延伸移动授权终点
movementEndpoint = new SpeedLimit(0, e.Optional);
movementEndpoint = new SpeedLimit(0, e.Optional - Config.ITCSafetyDistance);
releaseSpeed = false;
} else {
ITCNextSectionPos = location + e.Distance;
Log("红灯 移动授权终点是 " + location + e.Distance);
movementEndpoint = new SpeedLimit(0, location + e.Distance);
movementEndpoint = new SpeedLimit(0, location + e.Distance - Config.ITCSafetyDistance);
}
}
break;
Expand All @@ -139,6 +141,7 @@ private void Initialize(AtsEx.PluginHost.Native.StartedEventArgs e) {
driveMode = 1;
FixIncompatibleModes();

ITCNextSectionPos = 0;
movementEndpoint = SpeedLimit.inf;
nextLimit = null;
selectingMode = -1;
Expand Down
1 change: 1 addition & 0 deletions TGMT-CBTC-EX/Load.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public partial class TGMTAts : AssemblyPluginBase {

public static int TrainNumber = 0;
public static int DestinationNumber = 0;
public static double ITCNextSectionPos = 0;

public static int VBCount = 0;
public static int FBCount = 0;
Expand Down
8 changes: 5 additions & 3 deletions TGMT-CBTC-EX/Patterns/CalculatedLimit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ public static CalculatedLimit Calculate(double location, double idealdecel, doub
currentTarget = Math.Min(currentTarget, limits[i].AtLocation(location, idealdecel, voffset));
}
SpeedLimit nextLimit;
var LimitSpeedDown = false;
if (pointer < limits.Length) {
var pointer_ = pointer;
for (int i = pointer; i < limits.Length; i++) {
if (nextTarget > limits[i].AtLocation(limits[pointer].Location, idealdecel, voffset)) {
pointer_ = i;
break;
LimitSpeedDown = true;
} else {
nextTarget = Math.Min(nextTarget, limits[i].AtLocation(limits[pointer].Location, idealdecel, voffset));
}
if (LimitSpeedDown) break;
}
nextTarget = Math.Min(nextTarget, limits[i].AtLocation(limits[pointer].Location, idealdecel, voffset));
}
nextLimit = new SpeedLimit(limits[pointer_].Limit, limits[pointer_].Location);
} else {
Expand Down
3 changes: 1 addition & 2 deletions TGMT-CBTC-EX/TGMT-CBTC-EX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
<PostBuildEvent>COPY $(TargetPath) D:\Scenarios\TGMT_i\AtsEX\AtsEXPlugins\$(TargetFileName)</PostBuildEvent>
</PropertyGroup>
</Project>
61 changes: 34 additions & 27 deletions TGMT-CBTC-EX/TickNew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,22 @@ public override TickResult Tick(TimeSpan elapsed) {
nextLimit = targetCurve.NextLimit;
targetDistance = targetCurve.NextLimit.Location - location;
targetSpeed = targetCurve.NextLimit.Limit;
if (location > movementEndpoint.Location) {
// 如果已冲出移动授权终点,释放速度无效
if (releaseSpeed) Log("超出了移动授权终点, 释放速度无效");
recommendSpeed = 0;
ebSpeed = 0;
releaseSpeed = false;
}
if (releaseSpeed) {
ebSpeed = Math.Max(ebSpeed, Config.ReleaseSpeed);
recommendSpeed = Math.Max(recommendSpeed, Config.ReleaseSpeed - Config.RecommendSpeedOffset);
if(signalMode == 1) {
if (location > ITCNextSectionPos) {
// 如果已冲出移动授权终点,释放速度无效
if (releaseSpeed) Log("超出了移动授权终点, 释放速度无效");
recommendSpeed = 0;
ebSpeed = 0;
releaseSpeed = false;
}
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);
}
}
}

Expand Down Expand Up @@ -217,20 +223,6 @@ public override TickResult Tick(TimeSpan elapsed) {
ebSpeed = recommendSpeed = 0;
}

panel_[11] = distanceToPixel(targetDistance);
panel_[19] = (int)targetDistance;
panel_[16] = (int)(ebSpeed * speedMultiplier);
if (driveMode < 2) {
panel_[15] = (int)(recommendSpeed * speedMultiplier);
} else {
panel_[15] = -1;
}
distanceToColor(targetSpeed, targetDistance);
targetSpeed = Math.Min(targetSpeed, Config.MaxSpeed);
panel_[17] = (int)targetSpeed;
panel_[18] = (targetSpeed < 0) ? 1 : 0;
panel_[31] = 0;

// 显示出发信息
if (signalMode > 1 && state.Speed == 0) {
if (Math.Abs(StationManager.NextStation.StopPosition - location) < Config.DoorEnableWindow
Expand All @@ -251,6 +243,20 @@ public override TickResult Tick(TimeSpan elapsed) {
} else {
panel_[32] = 0;
}

panel_[11] = distanceToPixel(targetDistance);
panel_[19] = (int)targetDistance;
panel_[16] = (int)(ebSpeed * speedMultiplier);
if (driveMode < 2) {
panel_[15] = (int)(recommendSpeed * speedMultiplier);
} else {
panel_[15] = -1;
}
distanceToColor(targetSpeed, targetDistance);
targetSpeed = Math.Min(targetSpeed, Config.MaxSpeed);
panel_[17] = (int)targetSpeed;
panel_[18] = (targetSpeed < 0) ? 1 : 0;
panel_[31] = 0;


// 如果没有无线电,显示无线电故障
Expand Down Expand Up @@ -298,7 +304,7 @@ public override TickResult Tick(TimeSpan elapsed) {
if (state.Speed == 0 && handles.Power.Notch == 0) {
// 低于制动缓解速度
if (ebState > 0) {
if (location > movementEndpoint.Location) {
if (location > ITCNextSectionPos) {
// 冲出移动授权终点,要求RM
ackMessage = 6;
} else {
Expand Down Expand Up @@ -329,7 +335,7 @@ public override TickResult Tick(TimeSpan elapsed) {
panel_[10] = 0;
}
}
} else if (signalMode == 1) {
} else if (signalMode == 1 && !doorOpen && panel_[29] != 3) {
// ITC下冲出移动授权终点。
if (state.Speed == 0) {
// 停稳后降级到RM模式。等待确认。
Expand All @@ -349,7 +355,8 @@ 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) {

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);
Expand Down
3 changes: 1 addition & 2 deletions TGMT-CBTC-EX_WCU/TGMT-CBTC-EX_WCU.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
<PostBuildEvent>COPY $(TargetPath) D:\Scenarios\新浜線(架空)\NiihamaLine\MapPlugins\$(TargetFileName)</PostBuildEvent>
</PropertyGroup>
</Project>

0 comments on commit 840e961

Please sign in to comment.