Skip to content

Commit

Permalink
ref: changed debug output for signals
Browse files Browse the repository at this point in the history
  • Loading branch information
Uhutown committed Oct 21, 2024
1 parent 125f92a commit cd28b59
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -242,6 +244,8 @@ private void tryBlock(final List<SignalBoxPathway> 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);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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))
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,9 @@ private void changeIfPresent(final List<ConfigProperty> 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();
}
});

Expand All @@ -127,8 +125,10 @@ private void changeSignals(final List<ConfigProperty> 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<ConfigProperty> values,
Expand Down

0 comments on commit cd28b59

Please sign in to comment.