From cd28b59e041575e1c79862aeedef81bee86a3d9e Mon Sep 17 00:00:00 2001 From: Cedric Date: Mon, 21 Oct 2024 21:52:09 +0200 Subject: [PATCH] ref: changed debug output for signals --- .../signals/signalbox/SignalBoxGrid.java | 4 ++++ .../signals/signalbox/SignalBoxPathway.java | 13 +++++++------ .../signals/signalbox/config/SignalConfig.java | 6 +++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/troblecodings/signals/signalbox/SignalBoxGrid.java b/src/main/java/com/troblecodings/signals/signalbox/SignalBoxGrid.java index bc4db847b..e9ef664f3 100644 --- a/src/main/java/com/troblecodings/signals/signalbox/SignalBoxGrid.java +++ b/src/main/java/com/troblecodings/signals/signalbox/SignalBoxGrid.java @@ -127,10 +127,12 @@ private boolean checkManuellResetOfProtectionWay(final Point p1) { } protected void resetPathway(final SignalBoxPathway pathway) { + System.out.println("Resetting " + pathway); pathway.resetPathway(); updatePrevious(pathway); this.startsToPath.remove(pathway.getFirstPoint()); this.endsToPath.remove(pathway.getLastPoint()); + System.out.println("Removed " + pathway); } protected void updateToNet(final SignalBoxPathway pathway) { @@ -242,6 +244,8 @@ private void tryBlock(final List pathways, final BlockPos pos) pathways.forEach(pathway -> { if (pathway.tryBlock(pos)) { updatePrevious(pathway); + System.out.println( + "Updateing Previous PW from " + pathway + " due to blocking request!"); updateToNet(pathway); } }); diff --git a/src/main/java/com/troblecodings/signals/signalbox/SignalBoxPathway.java b/src/main/java/com/troblecodings/signals/signalbox/SignalBoxPathway.java index f0e04bbf7..15382674d 100644 --- a/src/main/java/com/troblecodings/signals/signalbox/SignalBoxPathway.java +++ b/src/main/java/com/troblecodings/signals/signalbox/SignalBoxPathway.java @@ -195,10 +195,6 @@ protected void setSignals() { protected void setSignals(final SignalStateInfo lastSignal) { if (isExecutingSignalSet || tile == null) return; - System.out.println("Changeing signals for " + this + "! Call:"); - for (final StackTraceElement el : Thread.currentThread().getStackTrace()) { - System.out.println(" " + el); - } final World world = tile.getWorld(); final StateInfo identifier = new StateInfo(world, tile.getPos()); final MainSignalIdentifier startSignal = data.getStartSignal(); @@ -260,6 +256,7 @@ protected void updateSignalStates() { if (startSignal != null) { if (isBlocked) return; + System.out.println("Setting " + startSignal + " on " + this); final SignalState previous = startSignal.state; startSignal.state = SignalState.GREEN; if (!startSignal.state.equals(previous)) @@ -280,8 +277,12 @@ protected void updateSignalStates() { final SignalBoxPathway next = getNextPathway(); final SignalState previous = position.state; if (endSignal != null && next != null && !next.isEmptyOrBroken()) { - if (!next.isExecutingSignalSet) + if (!next.isExecutingSignalSet) { position.state = SignalState.GREEN; + } + if (next.isBlocked) { + position.state = SignalState.RED; + } } else { position.state = SignalState.RED; } @@ -562,12 +563,12 @@ private boolean isPowerd(final BlockPos pos) { public boolean tryBlock(final BlockPos position) { if (!data.tryBlock(position)) return false; - isBlocked = true; resetFirstSignal(); this.setPathStatus(EnumPathUsage.BLOCKED); if (!isBlocked) { getTrainNumberFromPrevious(); } + isBlocked = true; return true; } diff --git a/src/main/java/com/troblecodings/signals/signalbox/config/SignalConfig.java b/src/main/java/com/troblecodings/signals/signalbox/config/SignalConfig.java index 30e5f28c5..340bc0888 100644 --- a/src/main/java/com/troblecodings/signals/signalbox/config/SignalConfig.java +++ b/src/main/java/com/troblecodings/signals/signalbox/config/SignalConfig.java @@ -101,11 +101,9 @@ private void changeIfPresent(final List values, final ConfigInfo if (info.nextinfo != null) { loadSignalAndRunTask(info.nextinfo, (nextInfo, nextProperties, _u2) -> { changeSignals(values, info, oldProperties, nextProperties); - pathway.updatePrevious(); }); } else { changeSignals(values, info, oldProperties, null); - pathway.updatePrevious(); } }); @@ -127,8 +125,10 @@ private void changeSignals(final List values, final ConfigInfo i .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); } }); - if (!propertiesToSet.isEmpty()) + if (!propertiesToSet.isEmpty()) { SignalStateHandler.setStates(info.currentinfo, propertiesToSet); + pathway.updatePrevious(); + } } private void loadWithoutPredicate(final List values,