Skip to content

Commit

Permalink
Merge pull request #15 from winup-zhou/develop
Browse files Browse the repository at this point in the history
Fix some issues.
  • Loading branch information
winup-zhou authored Jun 1, 2024
2 parents c005420 + 670b188 commit 221dc9c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 17 deletions.
26 changes: 16 additions & 10 deletions MetroAts/Signals/ATC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,17 @@ public static void Tick(double Location, double Speed, double Time, Section Curr
}

if (CurrentSection.CurrentSignalIndex < 9 || CurrentSection.CurrentSignalIndex == 34 || CurrentSection.CurrentSignalIndex >= 49) {
if (ATCType == -1) {
ATC_TokyuNoset = true;
ATC_SeibuNoset = ATC_MetroNoset = false;
} else if (ATCType == 2) {
ATC_SeibuNoset = true;
ATC_TokyuNoset = ATC_MetroNoset = false;
} else if (ATCType == 3) {
ATC_MetroNoset = true;
ATC_SeibuNoset = ATC_TokyuNoset = false;
}
if (!Noset) {
if (ATCType == -1) {
ATC_TokyuNoset = true;
ATC_SeibuNoset = ATC_MetroNoset = false;
} else if (ATCType == 2) {
ATC_SeibuNoset = true;
ATC_TokyuNoset = ATC_MetroNoset = false;
} else if (ATCType == 3) {
ATC_MetroNoset = true;
ATC_SeibuNoset = ATC_TokyuNoset = false;
}
ATC_X = true;
ATC_Stop = ATC_Proceed = ATC_P = false;
if (!Config.ATCLimitUseNeedle) {
Expand All @@ -169,6 +169,8 @@ public static void Tick(double Location, double Speed, double Time, Section Curr

BrakeCommand = MetroAts.vehicleSpec.BrakeNotches + 1;
} else {
BrakeCommand = 0;

ATC_Ding.Stop();
ATC_SignalAnnBeep.Stop();
ATC_ORPBeep.Stop();
Expand Down Expand Up @@ -448,6 +450,8 @@ public static void Tick(double Location, double Speed, double Time, Section Curr
}
}
} else {
BrakeCommand = 0;

ATC_Ding.Stop();
ATC_SignalAnnBeep.Stop();
ATC_ORPBeep.Stop();
Expand Down Expand Up @@ -512,6 +516,8 @@ public static void Tick(double Location, double Speed, double Time, Section Curr
public static void Disable() {
ATCEnable = false;

BrakeCommand = 0;

ATC_Ding.Stop();
ATC_SignalAnnBeep.Stop();
ATC_ORPBeep.Stop();
Expand Down
4 changes: 4 additions & 0 deletions MetroAts/Signals/T-DATC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ public static void Tick(double Location, double Speed, double Time, Section Curr
}
}
} else {
BrakeCommand = 0;

ATC_Ding.Stop();
ATC_PatternApproachBeep.Stop();
ATC_StationStopAnnounce.Stop();
Expand Down Expand Up @@ -374,6 +376,8 @@ public static void Tick(double Location, double Speed, double Time, Section Curr
public static void Disable() {
ATCEnable = false;

BrakeCommand = 0;

ATC_Ding.Stop();
ATC_PatternApproachBeep.Stop();
ATC_StationStopAnnounce.Stop();
Expand Down
5 changes: 5 additions & 0 deletions MetroAts/Signals/TSP-ATS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ public static void Tick(double Location, double Speed, double Time, Section next
}
} else {
ATS_TobuAts = false;

BrakeCommand = 0;

ATS_ATSEmergencyBrake = false;
//ATS_EmergencyOperation = false;
//ATS_Confirm = false;
Expand All @@ -148,6 +151,8 @@ public static void Tick(double Location, double Speed, double Time, Section next
public static void Disable() {
ATSEnable = false;

BrakeCommand = 0;

ATS_TobuAts = false;
ATS_ATSEmergencyBrake = false;
//ATS_EmergencyOperation = false;
Expand Down
59 changes: 52 additions & 7 deletions MetroAts/Tick.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public override TickResult Tick(TimeSpan elapsed) {
if (SignalEnable) {
if (SignalMode == 0) { //東武
if (ATC.ATCEnable) ATC.Disable();
ATS_P_SN.Disable();
if (ATS_P_SN.ATSEnable) ATS_P_SN.Disable();
if (KeyPosition == 1) {
if (CurrentSection.CurrentSignalIndex >= 9 && CurrentSection.CurrentSignalIndex != 34 && CurrentSection.CurrentSignalIndex < 49) {
//T-DATC
Expand Down Expand Up @@ -147,9 +147,20 @@ public override TickResult Tick(TimeSpan elapsed) {
} else if (SignalMode == 1) {//西武
if (TSP_ATS.ATSEnable) TSP_ATS.Disable();
if (T_DATC.ATCEnable) T_DATC.Disable();
ATS_P_SN.Disable();
if (ATS_P_SN.ATSEnable) ATS_P_SN.Disable();
if (CurrentSection.CurrentSignalIndex >= 9 && CurrentSection.CurrentSignalIndex != 34 && CurrentSection.CurrentSignalIndex < 49) {
ATC.Enable(state.Time.TotalMilliseconds);
ATC.Tick(state.Location, state.Speed, state.Time.TotalMilliseconds,
CurrentSection, NextSection, handles.Brake.Notch == vehicleSpec.BrakeNotches + 1, KeyPosition, false);
brakeCommand = handles.Brake.GetCommandToSetNotchTo(Math.Max(ATC.BrakeCommand, handles.Brake.Notch));
powerCommand = handles.Power.GetCommandToSetNotchTo(ATC.BrakeCommand > 0 ? 0 : handles.Power.Notch);
} else {
if (ATC.ATCEnable) ATC.Disable();
}
} else if (SignalMode == 2) {//ATC
ATS_P_SN.Disable();
if (TSP_ATS.ATSEnable) TSP_ATS.Disable();
if (T_DATC.ATCEnable) T_DATC.Disable();
if (ATS_P_SN.ATSEnable) ATS_P_SN.Disable();
if (KeyPosition != 0) {
if (ATC.ATCEnable) {
ATC.Tick(state.Location, state.Speed, state.Time.TotalMilliseconds,
Expand Down Expand Up @@ -244,6 +255,8 @@ public override TickResult Tick(TimeSpan elapsed) {
SN_Power.Value = ATS_P_SN.SN_Power;
SN_Action.Value = ATS_P_SN.SN_Action;
} else if (SignalMode == 3) {//相鉄
if (TSP_ATS.ATSEnable) TSP_ATS.Disable();
if (T_DATC.ATCEnable) T_DATC.Disable();
if (ATS_P_SN.ATSEnable) {
ATS_P_SN.Tick(state.Location, state.Speed, state.Time.TotalMilliseconds);
brakeCommand = handles.Brake.GetCommandToSetNotchTo(Math.Max(ATS_P_SN.BrakeCommand, handles.Brake.Notch));
Expand All @@ -252,6 +265,17 @@ public override TickResult Tick(TimeSpan elapsed) {
brakeCommand = handles.Brake.GetCommandToSetNotchTo(Math.Max(vehicleSpec.BrakeNotches + 1, handles.Brake.Notch));
ATS_P_SN.Enable(state.Time.TotalMilliseconds);
}

if (CurrentSection.CurrentSignalIndex >= 9 && CurrentSection.CurrentSignalIndex != 34 && CurrentSection.CurrentSignalIndex < 49) {
ATC.Enable(state.Time.TotalMilliseconds);
ATC.Tick(state.Location, state.Speed, state.Time.TotalMilliseconds,
CurrentSection, NextSection, handles.Brake.Notch == vehicleSpec.BrakeNotches + 1, KeyPosition, false);
brakeCommand = handles.Brake.GetCommandToSetNotchTo(Math.Max(ATC.BrakeCommand, handles.Brake.Notch));
powerCommand = handles.Power.GetCommandToSetNotchTo(ATC.BrakeCommand > 0 ? 0 : handles.Power.Notch);
} else {
if (ATC.ATCEnable) ATC.Disable();
}

ATC_01.Value = ATC.ATC_01;
ATC_10.Value = ATC.ATC_10;
ATC_15.Value = ATC.ATC_15;
Expand Down Expand Up @@ -333,9 +357,9 @@ public override TickResult Tick(TimeSpan elapsed) {
SN_Power.Value = ATS_P_SN.SN_Power;
SN_Action.Value = ATS_P_SN.SN_Action;
} else if (SignalMode == 4) {//非設
TSP_ATS.Disable();
T_DATC.Disable();
ATS_P_SN.Disable();
if (TSP_ATS.ATSEnable) TSP_ATS.Disable();
if (T_DATC.ATCEnable) T_DATC.Disable();
if (ATS_P_SN.ATSEnable) ATS_P_SN.Disable();
if (KeyPosition != 0) {
if (ATC.ATCEnable) {
ATC.Tick(state.Location, state.Speed, state.Time.TotalMilliseconds,
Expand Down Expand Up @@ -417,11 +441,22 @@ public override TickResult Tick(TimeSpan elapsed) {
//ATS_Confirm.Value = TSP_ATS.ATS_Confirm;
ATS_60.Value = TSP_ATS.ATS_60;
ATS_15.Value = TSP_ATS.ATS_15;

P_Power.Value = ATS_P_SN.P_Power;
P_PatternApproach.Value = ATS_P_SN.P_PatternApproach;
P_BrakeActioned.Value = ATS_P_SN.P_BrakeActioned;
P_EBActioned.Value = ATS_P_SN.P_EBActioned;
P_BrakeOverride.Value = ATS_P_SN.P_BrakeOverride;
P_PEnable.Value = ATS_P_SN.P_PEnable;
P_Fail.Value = ATS_P_SN.P_Fail;
SN_Power.Value = ATS_P_SN.SN_Power;
SN_Action.Value = ATS_P_SN.SN_Action;
}
} else {
if (TSP_ATS.ATSEnable) TSP_ATS.Disable();
if (T_DATC.ATCEnable) T_DATC.Disable();
if (ATC.ATCEnable) ATC.Disable();
if (ATS_P_SN.ATSEnable) ATS_P_SN.Disable();

ATC_01.Value = false;
ATC_10.Value = false;
Expand Down Expand Up @@ -495,6 +530,16 @@ public override TickResult Tick(TimeSpan elapsed) {
ATS_15.Value = false;

ATCNeedle_Disappear.Value = 1;
P_Power.Value = false;
P_PatternApproach.Value = false;
P_BrakeActioned.Value = false;
P_EBActioned.Value = false;
P_BrakeOverride.Value = false;
P_PEnable.Value = false;
P_Fail.Value = false;
SN_Power.Value = false;
SN_Action.Value = false;

//reverserCommand = handles.Reverser.Position;
brakeCommand = handles.Brake.GetCommandToSetNotchTo(Math.Max(vehicleSpec.BrakeNotches + 1, handles.Brake.Notch));
if (!SignalEnable && handles.Reverser.Position != ReverserPosition.N && handles.Brake.Notch != vehicleSpec.BrakeNotches + 1)
Expand Down Expand Up @@ -545,7 +590,7 @@ public override TickResult Tick(TimeSpan elapsed) {

description = BveHacker.Scenario.Vehicle.Instruments.Cab.GetDescriptionText();
leverText = (LeverText)BveHacker.MainForm.AssistantDrawer.Items.First(item => item is LeverText);
leverText.Text = $"{description} | マスコンキー: {KeyPos} 保安装置: {ATCCgSPos}";
leverText.Text = $"{description}\nマスコンキー: {KeyPos}\n保安装置: {ATCCgSPos}";

PowerOutput.Value = (int)powerCommand.GetOverridenNotch(handles.Power.Notch);
BrakeOutput.Value = (int)brakeCommand.GetOverridenNotch(handles.Brake.Notch);
Expand Down

0 comments on commit 221dc9c

Please sign in to comment.