use of jmri.jmrit.display.layoutEditor.ConnectivityUtil in project JMRI by JMRI.
the class AutoTurnouts method turnoutUtil.
/**
* Internal method implementing the above two methods Returns 'true' if
* turnouts are set correctly, 'false' otherwise If 'set' is 'true' this
* routine will attempt to set the turnouts, if 'false' it reports what it
* finds.
*/
private boolean turnoutUtil(Section s, int seqNum, Section nextSection, ActiveTrain at, LayoutEditor le, boolean trustKnownTurnouts, boolean set, Section prevSection) {
// validate input and initialize
Transit tran = at.getTransit();
if ((s == null) || (seqNum > tran.getMaxSequence()) || (!tran.containsSection(s)) || (le == null)) {
log.error("Invalid argument when checking or setting turnouts in Section.");
return false;
}
int direction = at.getAllocationDirectionFromSectionAndSeq(s, seqNum);
if (direction == 0) {
log.error("Invalid Section/sequence arguments when checking or setting turnouts");
return false;
}
// check for no turnouts in this section
if (_dispatcher.getSignalType() == DispatcherFrame.SIGNALHEAD && (s.getForwardEntryPointList().size() <= 1) && (s.getReverseEntryPointList().size() <= 1)) {
log.debug("No entry points lists");
// no possibility of turnouts
return true;
}
// initialize connectivity utilities and beginning block pointers
ConnectivityUtil ct = le.getConnectivityUtil();
EntryPoint entryPt = null;
if (prevSection != null) {
entryPt = s.getEntryPointFromSection(prevSection, direction);
} else if (!s.containsBlock(at.getStartBlock())) {
entryPt = s.getEntryPointFromBlock(at.getStartBlock(), direction);
}
EntryPoint exitPt = null;
if (nextSection != null) {
exitPt = s.getExitPointToSection(nextSection, direction);
}
// must be in the section
Block curBlock = null;
// must start outside the section or be null
Block prevBlock = null;
// sequence number of curBlock in Section
int curBlockSeqNum = -1;
if (entryPt != null) {
curBlock = entryPt.getBlock();
prevBlock = entryPt.getFromBlock();
curBlockSeqNum = s.getBlockSequenceNumber(curBlock);
} else if (!at.isAllocationReversed() && s.containsBlock(at.getStartBlock())) {
curBlock = at.getStartBlock();
curBlockSeqNum = s.getBlockSequenceNumber(curBlock);
//Get the previous block so that we can set the turnouts in the current block correctly.
if (direction == Section.FORWARD) {
prevBlock = s.getBlockBySequenceNumber(curBlockSeqNum - 1);
} else if (direction == Section.REVERSE) {
prevBlock = s.getBlockBySequenceNumber(curBlockSeqNum + 1);
}
} else if (at.isAllocationReversed() && s.containsBlock(at.getEndBlock())) {
curBlock = at.getEndBlock();
curBlockSeqNum = s.getBlockSequenceNumber(curBlock);
//Get the previous block so that we can set the turnouts in the current block correctly.
if (direction == Section.REVERSE) {
prevBlock = s.getBlockBySequenceNumber(curBlockSeqNum + 1);
} else if (direction == Section.FORWARD) {
prevBlock = s.getBlockBySequenceNumber(curBlockSeqNum - 1);
}
} else {
if (_dispatcher.getSignalType() == DispatcherFrame.SIGNALMAST) {
//This can be considered normal where SignalMast Logic is used.
return true;
}
log.error("Error in turnout check/set request - initial Block and Section mismatch");
return false;
}
Block nextBlock = null;
// may be either in the section or the first block in the next section
// sequence number of nextBlock in Section (-1 indicates outside Section)
int nextBlockSeqNum = -1;
if (exitPt != null && curBlock == exitPt.getBlock()) {
// next Block is outside of the Section
nextBlock = exitPt.getFromBlock();
} else {
// next Block is inside the Section
if (direction == Section.FORWARD) {
nextBlock = s.getBlockBySequenceNumber(curBlockSeqNum + 1);
nextBlockSeqNum = curBlockSeqNum + 1;
} else if (direction == Section.REVERSE) {
nextBlock = s.getBlockBySequenceNumber(curBlockSeqNum - 1);
nextBlockSeqNum = curBlockSeqNum - 1;
}
if ((nextBlock == null) && (curBlock != at.getEndBlock())) {
log.error("Error in block sequence numbers when setting/checking turnouts");
return false;
}
}
ArrayList<LayoutTurnout> turnoutList = new ArrayList<LayoutTurnout>();
ArrayList<Integer> settingsList = new ArrayList<Integer>();
// get turnouts by Block
boolean turnoutsOK = true;
while (curBlock != null) {
/*No point in getting the list if the previous block is null as it will return empty and generate an error,
this will only happen on the first run. Plus working on the basis that the turnouts in the current block would have already of
been set correctly for the train to have arrived in the first place.
*/
if (prevBlock != null) {
turnoutList = ct.getTurnoutList(curBlock, prevBlock, nextBlock);
settingsList = ct.getTurnoutSettingList();
}
// loop over turnouts checking and optionally setting turnouts
for (int i = 0; i < turnoutList.size(); i++) {
Turnout to = turnoutList.get(i).getTurnout();
int setting = settingsList.get(i).intValue();
if (turnoutList.get(i) instanceof LayoutSlip) {
setting = ((LayoutSlip) turnoutList.get(i)).getTurnoutState(settingsList.get(i));
}
// check or ignore current setting based on flag, set in Options
if (!trustKnownTurnouts) {
log.debug("{}: setting turnout {} to {}", at.getTrainName(), to.getFullyFormattedDisplayName(), (setting == Turnout.CLOSED ? closedText : thrownText));
to.setCommandedState(setting);
try {
Thread.sleep(100);
} catch (Exception ex) {
}
//TODO: move this to separate thread
} else {
if (to.getKnownState() != setting) {
// turnout is not set correctly
if (set) {
// setting has been requested, is Section free and Block unoccupied
if ((s.getState() == Section.FREE) && (curBlock.getState() != Block.OCCUPIED)) {
// send setting command
log.debug("{}: turnout {} commanded to {}", at.getTrainName(), to.getFullyFormattedDisplayName(), (setting == Turnout.CLOSED ? closedText : thrownText));
to.setCommandedState(setting);
try {
Thread.sleep(100);
} catch (Exception ex) {
}
//TODO: move this to separate thread
} else {
turnoutsOK = false;
}
} else {
turnoutsOK = false;
}
} else {
log.debug("{}: turnout {} already {}, skipping", at.getTrainName(), to.getFullyFormattedDisplayName(), (setting == Turnout.CLOSED ? closedText : thrownText));
}
}
if (turnoutList.get(i) instanceof LayoutSlip) {
//Look at the state of the second turnout in the slip
setting = ((LayoutSlip) turnoutList.get(i)).getTurnoutBState(settingsList.get(i));
to = ((LayoutSlip) turnoutList.get(i)).getTurnoutB();
if (!trustKnownTurnouts) {
to.setCommandedState(setting);
} else if (to.getKnownState() != setting) {
// turnout is not set correctly
if (set) {
// setting has been requested, is Section free and Block unoccupied
if ((s.getState() == Section.FREE) && (curBlock.getState() != Block.OCCUPIED)) {
// send setting command
to.setCommandedState(setting);
} else {
turnoutsOK = false;
}
} else {
turnoutsOK = false;
}
}
}
}
if (turnoutsOK) {
// move to next Block if any
if (nextBlockSeqNum >= 0) {
prevBlock = curBlock;
curBlock = nextBlock;
curBlockSeqNum = nextBlockSeqNum;
if ((exitPt != null) && (curBlock == exitPt.getBlock())) {
// next block is outside of the Section
nextBlock = exitPt.getFromBlock();
nextBlockSeqNum = -1;
} else {
if (direction == Section.FORWARD) {
nextBlockSeqNum++;
} else {
nextBlockSeqNum--;
}
nextBlock = s.getBlockBySequenceNumber(nextBlockSeqNum);
if (nextBlock == null) {
// there is no next Block
nextBlockSeqNum = -1;
}
}
} else {
curBlock = null;
}
} else {
curBlock = null;
}
}
return turnoutsOK;
}
use of jmri.jmrit.display.layoutEditor.ConnectivityUtil in project JMRI by JMRI.
the class DestinationPoints method setRoute.
//For a clear down we need to add a message, if it is a cancel, manual clear down or I didn't mean it.
void setRoute(boolean state) {
if (log.isDebugEnabled()) {
log.debug("Set route " + src.getPoint().getDisplayName());
}
if (disposed) {
log.error("Set route called even though interlock has been disposed of");
return;
}
if (routeDetails == null) {
log.error("No route to set or clear down");
setActiveEntryExit(false);
setRouteTo(false);
setRouteFrom(false);
if ((getSignal() instanceof SignalMast) && (getEntryExitType() != EntryExitPairs.FULLINTERLOCK)) {
SignalMast mast = (SignalMast) getSignal();
mast.setHeld(false);
}
synchronized (this) {
destination = null;
}
return;
}
if (!state) {
switch(manager.getClearDownOption()) {
case EntryExitPairs.PROMPTUSER:
cancelClearOptionBox();
break;
case EntryExitPairs.AUTOCANCEL:
cancelClearInterlock(EntryExitPairs.CANCELROUTE);
break;
case EntryExitPairs.AUTOCLEAR:
cancelClearInterlock(EntryExitPairs.CLEARROUTE);
break;
default:
cancelClearOptionBox();
break;
}
if (log.isDebugEnabled()) {
log.debug("Exit " + src.getPoint().getDisplayName());
}
return;
}
if (manager.isRouteStacked(this, false)) {
manager.cancelStackedRoute(this, false);
}
/* We put the setting of the route into a seperate thread and put a glass pane in front of the layout editor.
The swing thread for flashing the icons will carry on without interuption. */
final ArrayList<Color> realColorStd = new ArrayList<Color>();
final ArrayList<Color> realColorXtra = new ArrayList<Color>();
final ArrayList<LayoutBlock> routeBlocks = new ArrayList<LayoutBlock>();
if (manager.useDifferentColorWhenSetting()) {
for (LayoutBlock lbk : routeDetails) {
routeBlocks.add(lbk);
realColorXtra.add(lbk.getBlockExtraColor());
realColorStd.add(lbk.getBlockTrackColor());
lbk.setBlockExtraColor(manager.getSettingRouteColor());
lbk.setBlockTrackColor(manager.getSettingRouteColor());
}
//Force a redraw, to reflect color change
src.getPoint().getPanel().redrawPanel();
}
ActiveTrain tmpat = null;
if (manager.getDispatcherIntegration() && jmri.InstanceManager.getNullableDefault(jmri.jmrit.dispatcher.DispatcherFrame.class) != null) {
jmri.jmrit.dispatcher.DispatcherFrame df = jmri.InstanceManager.getDefault(jmri.jmrit.dispatcher.DispatcherFrame.class);
for (ActiveTrain atl : df.getActiveTrainsList()) {
if (atl.getEndBlock() == src.getStart().getBlock()) {
if (atl.getLastAllocatedSection() == atl.getEndBlockSection()) {
if (!atl.getReverseAtEnd() && !atl.getResetWhenDone()) {
tmpat = atl;
break;
}
log.warn("Interlock will not be added to existing Active Train as it is set for back and forth operation");
}
}
}
}
final ActiveTrain at = tmpat;
Runnable setRouteRun = new Runnable() {
@Override
public void run() {
src.getPoint().getPanel().getGlassPane().setVisible(true);
try {
Hashtable<Turnout, Integer> turnoutSettings = new Hashtable<Turnout, Integer>();
ConnectivityUtil connection = new ConnectivityUtil(point.getPanel());
// Last block in the route is the one that we are protecting at the last sensor/signalmast
for (int i = 0; i < routeDetails.size(); i++) {
//if we are not using the dispatcher and the signal logic is dynamic, then set the turnouts
if (at == null && isSignalLogicDynamic()) {
if (i > 0) {
ArrayList<LayoutTurnout> turnoutlist;
int nxtBlk = i + 1;
int preBlk = i - 1;
if (i < routeDetails.size() - 1) {
turnoutlist = connection.getTurnoutList(routeDetails.get(i).getBlock(), routeDetails.get(preBlk).getBlock(), routeDetails.get(nxtBlk).getBlock());
ArrayList<Integer> throwlist = connection.getTurnoutSettingList();
for (int x = 0; x < turnoutlist.size(); x++) {
if (turnoutlist.get(x) instanceof LayoutSlip) {
int slipState = throwlist.get(x);
LayoutSlip ls = (LayoutSlip) turnoutlist.get(x);
int taState = ls.getTurnoutState(slipState);
turnoutSettings.put(ls.getTurnout(), taState);
int tbState = ls.getTurnoutBState(slipState);
ls.getTurnoutB().setCommandedState(tbState);
turnoutSettings.put(ls.getTurnoutB(), tbState);
} else {
String t = turnoutlist.get(x).getTurnoutName();
Turnout turnout = InstanceManager.turnoutManagerInstance().getTurnout(t);
turnoutSettings.put(turnout, throwlist.get(x));
if (turnoutlist.get(x).getSecondTurnout() != null) {
turnoutSettings.put(turnoutlist.get(x).getSecondTurnout(), throwlist.get(x));
}
}
}
}
}
}
if ((getEntryExitType() == EntryExitPairs.FULLINTERLOCK)) {
// was set against occupancy sensor
routeDetails.get(i).getBlock().addPropertyChangeListener(propertyBlockListener);
if (i > 0) {
routeDetails.get(i).setUseExtraColor(true);
}
} else {
// was set against occupancy sensor
routeDetails.get(i).getBlock().removePropertyChangeListener(propertyBlockListener);
}
}
if (at == null) {
if (!isSignalLogicDynamic()) {
jmri.SignalMastLogic tmSml = InstanceManager.getDefault(jmri.SignalMastLogicManager.class).getSignalMastLogic((SignalMast) src.sourceSignal);
for (Turnout t : tmSml.getAutoTurnouts((SignalMast) getSignal())) {
turnoutSettings.put(t, tmSml.getAutoTurnoutState(t, (SignalMast) getSignal()));
}
}
for (Map.Entry<Turnout, Integer> entry : turnoutSettings.entrySet()) {
entry.getKey().setCommandedState(entry.getValue());
Runnable r = new Runnable() {
@Override
public void run() {
try {
Thread.sleep(250 + manager.turnoutSetDelay);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
};
Thread thr = new Thread(r, "Entry Exit Route, turnout setting");
thr.start();
try {
thr.join();
} catch (InterruptedException ex) {
// log.info("interrupted at join " + ex);
}
}
}
src.getPoint().getPanel().redrawPanel();
if (getEntryExitType() != EntryExitPairs.SETUPTURNOUTSONLY) {
if (getEntryExitType() == EntryExitPairs.FULLINTERLOCK) {
//If our start block is already active we will set it as our lastSeenActiveBlock.
if (src.getStart().getState() == Block.OCCUPIED) {
src.getStart().removePropertyChangeListener(propertyBlockListener);
lastSeenActiveBlockObject = src.getStart().getBlock().getValue();
log.debug("Last seen value " + lastSeenActiveBlockObject);
}
}
if ((src.sourceSignal instanceof SignalMast) && (getSignal() instanceof SignalMast)) {
SignalMast smSource = (SignalMast) src.sourceSignal;
SignalMast smDest = (SignalMast) getSignal();
synchronized (this) {
sml = InstanceManager.getDefault(jmri.SignalMastLogicManager.class).newSignalMastLogic(smSource);
if (!sml.isDestinationValid(smDest)) {
//if no signalmastlogic existed then created it, but set it not to be stored.
sml.setDestinationMast(smDest);
sml.setStore(jmri.SignalMastLogic.STORENONE, smDest);
}
}
//Remove the first block as it is our start block
routeDetails.remove(0);
synchronized (this) {
smSource.setHeld(false);
//Only change the block and turnout details if this a temp signalmast logic
if (sml.getStoreState(smDest) == jmri.SignalMastLogic.STORENONE) {
LinkedHashMap<Block, Integer> blks = new LinkedHashMap<Block, Integer>();
for (int i = 0; i < routeDetails.size(); i++) {
if (routeDetails.get(i).getBlock().getState() == Block.UNKNOWN) {
routeDetails.get(i).getBlock().setState(Block.UNOCCUPIED);
}
blks.put(routeDetails.get(i).getBlock(), Block.UNOCCUPIED);
}
sml.setAutoBlocks(blks, smDest);
sml.setAutoTurnouts(turnoutSettings, smDest);
sml.initialise(smDest);
}
}
smSource.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent e) {
SignalMast source = (SignalMast) e.getSource();
source.removePropertyChangeListener(this);
setRouteFrom(true);
setRouteTo(true);
}
});
src.pd.extendedtime = true;
point.extendedtime = true;
} else {
if (src.sourceSignal instanceof SignalMast) {
SignalMast mast = (SignalMast) src.sourceSignal;
mast.setHeld(false);
} else if (src.sourceSignal instanceof SignalHead) {
SignalHead head = (SignalHead) src.sourceSignal;
head.setHeld(false);
}
setRouteFrom(true);
setRouteTo(true);
}
}
if (manager.useDifferentColorWhenSetting()) {
//final ArrayList<Color> realColorXtra = realColorXtra;
javax.swing.Timer resetColorBack = new javax.swing.Timer(manager.getSettingTimer(), new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
for (int i = 0; i < routeBlocks.size(); i++) {
LayoutBlock lbk = routeBlocks.get(i);
lbk.setBlockExtraColor(realColorXtra.get(i));
lbk.setBlockTrackColor(realColorStd.get(i));
}
src.getPoint().getPanel().redrawPanel();
}
});
resetColorBack.setRepeats(false);
resetColorBack.start();
}
if (at != null) {
jmri.Section sec = null;
if (sml != null && sml.getAssociatedSection((SignalMast) getSignal()) != null) {
sec = sml.getAssociatedSection((SignalMast) getSignal());
} else {
sec = InstanceManager.getDefault(jmri.SectionManager.class).createNewSection(src.getPoint().getDisplayName() + ":" + point.getDisplayName());
if (sec == null) {
//A Section already exists, lets grab it and check that it is one used with the Interlocking, if so carry on using that.
sec = InstanceManager.getDefault(jmri.SectionManager.class).getSection(src.getPoint().getDisplayName() + ":" + point.getDisplayName());
} else {
sec.setSectionType(jmri.Section.DYNAMICADHOC);
}
if (sec.getSectionType() == jmri.Section.DYNAMICADHOC) {
sec.removeAllBlocksFromSection();
for (LayoutBlock key : routeDetails) {
if (key != src.getStart()) {
sec.addBlock(key.getBlock());
}
}
String dir = jmri.Path.decodeDirection(src.getStart().getNeighbourDirection(routeDetails.get(0).getBlock()));
jmri.EntryPoint ep = new jmri.EntryPoint(routeDetails.get(0).getBlock(), src.getStart().getBlock(), dir);
ep.setTypeForward();
sec.addToForwardList(ep);
LayoutBlock proDestLBlock = point.getProtecting().get(0);
if (proDestLBlock != null) {
dir = jmri.Path.decodeDirection(proDestLBlock.getNeighbourDirection(point.getFacing()));
ep = new jmri.EntryPoint(point.getFacing().getBlock(), proDestLBlock.getBlock(), dir);
ep.setTypeReverse();
sec.addToReverseList(ep);
}
}
}
jmri.InstanceManager.getDefault(jmri.jmrit.dispatcher.DispatcherFrame.class).extendActiveTrainsPath(sec, at, src.getPoint().getPanel());
}
src.pd.setNXButtonState(EntryExitPairs.NXBUTTONINACTIVE);
point.setNXButtonState(EntryExitPairs.NXBUTTONINACTIVE);
} catch (RuntimeException ex) {
log.error("An error occured while setting the route");
ex.printStackTrace();
src.pd.setNXButtonState(EntryExitPairs.NXBUTTONINACTIVE);
point.setNXButtonState(EntryExitPairs.NXBUTTONINACTIVE);
if (manager.useDifferentColorWhenSetting()) {
for (int i = 0; i < routeBlocks.size(); i++) {
LayoutBlock lbk = routeBlocks.get(i);
lbk.setBlockExtraColor(realColorXtra.get(i));
lbk.setBlockTrackColor(realColorStd.get(i));
}
}
src.getPoint().getPanel().redrawPanel();
}
src.getPoint().getPanel().getGlassPane().setVisible(false);
//src.setMenuEnabled(true);
}
};
Thread thrMain = new Thread(setRouteRun, "Entry Exit Set Route");
thrMain.start();
try {
thrMain.join();
} catch (InterruptedException e) {
log.error("Interuption exception " + e.toString());
}
if (log.isDebugEnabled()) {
log.debug("finish route " + src.getPoint().getDisplayName());
}
}
use of jmri.jmrit.display.layoutEditor.ConnectivityUtil in project JMRI by JMRI.
the class Section method placeDirectionSensors.
/**
* Places direction sensors in SSL for all Signal Heads in this Section if
* the Sensors are not already present in the SSL. Only anchor point block
* boundaries that have assigned signals are considered. Only turnouts that
* have assigned signals are considered. Only level crossings that have
* assigned signals are considered. Turnouts and anchor points without
* signals are counted, and reported in warning messages during this
* procedure, if there are any missing signals. If this method has trouble,
* an error message is placed in the log describing the trouble.
*
* @param panel the panel to place direction sensors on
* @return the number or errors placing sensors; 1 is returned if no
* direction sensor is defined for this section
*/
public int placeDirectionSensors(LayoutEditor panel) {
int missingSignalsBB = 0;
int missingSignalsTurnouts = 0;
int missingSignalsLevelXings = 0;
int errorCount = 0;
if (panel == null) {
log.error("Null Layout Editor panel on call to 'placeDirectionSensors'");
return 1;
}
if (initializationNeeded) {
initializeBlocks();
}
if ((mForwardBlockingSensorName == null) || (mForwardBlockingSensorName.equals("")) || (mReverseBlockingSensorName == null) || (mReverseBlockingSensorName.equals(""))) {
log.error("Missing direction sensor in Section " + getSystemName());
return 1;
}
LayoutBlockManager layoutBlockManager = InstanceManager.getDefault(LayoutBlockManager.class);
ConnectivityUtil cUtil = panel.getConnectivityUtil();
for (int i = 0; i < mBlockEntries.size(); i++) {
Block cBlock = mBlockEntries.get(i);
LayoutBlock lBlock = layoutBlockManager.getByUserName(cBlock.getUserName());
ArrayList<PositionablePoint> anchorList = cUtil.getAnchorBoundariesThisBlock(cBlock);
for (int j = 0; j < anchorList.size(); j++) {
PositionablePoint p = anchorList.get(j);
if ((!p.getEastBoundSignal().equals("")) && (!p.getWestBoundSignal().equals(""))) {
// have a signalled block boundary
SignalHead sh = cUtil.getSignalHeadAtAnchor(p, cBlock, false);
if (sh == null) {
log.warn("Unexpected missing signal head at boundary of Block " + cBlock.getUserName());
errorCount++;
} else {
int direction = cUtil.getDirectionFromAnchor(mForwardEntryPoints, mReverseEntryPoints, p);
if (direction == EntryPoint.UNKNOWN) {
// anchor is at a Block boundary within the Section
sh = cUtil.getSignalHeadAtAnchor(p, cBlock, true);
Block otherBlock = ((p.getConnect1()).getLayoutBlock()).getBlock();
if (otherBlock == cBlock) {
otherBlock = ((p.getConnect2()).getLayoutBlock()).getBlock();
}
if (getBlockSequenceNumber(cBlock) < getBlockSequenceNumber(otherBlock)) {
direction = EntryPoint.FORWARD;
} else {
direction = EntryPoint.REVERSE;
}
}
if (!checkDirectionSensor(sh, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
}
} else {
errorCount++;
missingSignalsBB++;
}
}
ArrayList<LevelXing> xingList = cUtil.getLevelCrossingsThisBlock(cBlock);
for (int k = 0; k < xingList.size(); k++) {
LevelXing x = xingList.get(k);
LayoutBlock alBlock = ((TrackSegment) x.getConnectA()).getLayoutBlock();
LayoutBlock blBlock = ((TrackSegment) x.getConnectB()).getLayoutBlock();
LayoutBlock clBlock = ((TrackSegment) x.getConnectC()).getLayoutBlock();
LayoutBlock dlBlock = ((TrackSegment) x.getConnectD()).getLayoutBlock();
if (cUtil.isInternalLevelXingAC(x, cBlock)) {
// have an internal AC level crossing - is it signaled?
if (((x.getSignalAName() != null) && (!x.getSignalAName().equals(""))) || ((x.getSignalCName() != null) && (!x.getSignalCName().equals("")))) {
// have a signaled AC level crossing internal to this block
if ((x.getSignalAName() != null) && (!x.getSignalAName().equals(""))) {
// there is a signal at A in the level crossing
TrackNode tn = new TrackNode(x, LayoutTrack.LEVEL_XING_A, (TrackSegment) x.getConnectA(), false, 0);
TrackNode altNode = new TrackNode(x, LayoutTrack.LEVEL_XING_C, (TrackSegment) x.getConnectC(), false, 0);
SignalHead sh = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(x.getSignalAName());
if (!setDirectionSensorByConnectivity(tn, altNode, sh, cBlock, cUtil)) {
errorCount++;
}
}
if ((x.getSignalCName() != null) && (!x.getSignalCName().equals(""))) {
// there is a signal at C in the level crossing
TrackNode tn = new TrackNode(x, LayoutTrack.LEVEL_XING_C, (TrackSegment) x.getConnectC(), false, 0);
TrackNode altNode = new TrackNode(x, LayoutTrack.LEVEL_XING_A, (TrackSegment) x.getConnectA(), false, 0);
SignalHead sh = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(x.getSignalCName());
if (!setDirectionSensorByConnectivity(tn, altNode, sh, cBlock, cUtil)) {
errorCount++;
}
}
}
} else if (alBlock == lBlock) {
// have a level crossing with AC spanning a block boundary, with A in this Block
int direction = getDirectionForBlocks(alBlock, clBlock);
if (direction != EntryPoint.UNKNOWN) {
if ((x.getSignalCName() != null) && (!x.getSignalCName().equals(""))) {
SignalHead sh = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(x.getSignalCName());
if (!checkDirectionSensor(sh, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
}
} else {
errorCount++;
}
} else if (clBlock == lBlock) {
// have a level crossing with AC spanning a block boundary, with C in this Block
int direction = getDirectionForBlocks(clBlock, alBlock);
if (direction != EntryPoint.UNKNOWN) {
if ((x.getSignalAName() != null) && (!x.getSignalAName().equals(""))) {
SignalHead sh = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(x.getSignalAName());
if (!checkDirectionSensor(sh, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
}
} else {
errorCount++;
}
}
if (cUtil.isInternalLevelXingBD(x, cBlock)) {
// have an internal BD level crossing - is it signaled?
if (((x.getSignalBName() != null) && (!x.getSignalBName().equals(""))) || ((x.getSignalDName() != null) && (!x.getSignalDName().equals("")))) {
// have a signaled BD level crossing internal to this block
if ((x.getSignalBName() != null) && (!x.getSignalBName().equals(""))) {
// there is a signal at B in the level crossing
TrackNode tn = new TrackNode(x, LayoutTrack.LEVEL_XING_B, (TrackSegment) x.getConnectB(), false, 0);
TrackNode altNode = new TrackNode(x, LayoutTrack.LEVEL_XING_D, (TrackSegment) x.getConnectD(), false, 0);
SignalHead sh = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(x.getSignalBName());
if (!setDirectionSensorByConnectivity(tn, altNode, sh, cBlock, cUtil)) {
errorCount++;
}
}
if ((x.getSignalDName() != null) && (!x.getSignalDName().equals(""))) {
// there is a signal at C in the level crossing
TrackNode tn = new TrackNode(x, LayoutTrack.LEVEL_XING_D, (TrackSegment) x.getConnectD(), false, 0);
TrackNode altNode = new TrackNode(x, LayoutTrack.LEVEL_XING_B, (TrackSegment) x.getConnectB(), false, 0);
SignalHead sh = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(x.getSignalDName());
if (!setDirectionSensorByConnectivity(tn, altNode, sh, cBlock, cUtil)) {
errorCount++;
}
}
}
} else if (blBlock == lBlock) {
// have a level crossing with BD spanning a block boundary, with B in this Block
int direction = getDirectionForBlocks(blBlock, dlBlock);
if (direction != EntryPoint.UNKNOWN) {
if ((x.getSignalDName() != null) && (!x.getSignalDName().equals(""))) {
SignalHead sh = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(x.getSignalDName());
if (!checkDirectionSensor(sh, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
}
} else {
errorCount++;
}
} else if (dlBlock == lBlock) {
// have a level crossing with BD spanning a block boundary, with D in this Block
int direction = getDirectionForBlocks(dlBlock, blBlock);
if (direction != EntryPoint.UNKNOWN) {
if ((x.getSignalBName() != null) && (!x.getSignalBName().equals(""))) {
SignalHead sh = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(x.getSignalBName());
if (!checkDirectionSensor(sh, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
}
} else {
errorCount++;
}
}
}
ArrayList<LayoutTurnout> turnoutList = cUtil.getLayoutTurnoutsThisBlock(cBlock);
for (int m = 0; m < turnoutList.size(); m++) {
LayoutTurnout t = turnoutList.get(m);
if (cUtil.layoutTurnoutHasRequiredSignals(t)) {
// have a signalled turnout
if ((t.getLinkType() == LayoutTurnout.NO_LINK) && ((t.getTurnoutType() == LayoutTurnout.RH_TURNOUT) || (t.getTurnoutType() == LayoutTurnout.LH_TURNOUT) || (t.getTurnoutType() == LayoutTurnout.WYE_TURNOUT))) {
// standard turnout - nothing special
// Note: direction is for proceeding from the throat to either other track
int direction = getDirectionStandardTurnout(t, cUtil);
int altDirection = EntryPoint.FORWARD;
if (direction == EntryPoint.FORWARD) {
altDirection = EntryPoint.REVERSE;
}
if (direction == EntryPoint.UNKNOWN) {
errorCount++;
} else {
SignalHead aHead = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalA1Name());
SignalHead a2Head = null;
String a2Name = t.getSignalA2Name();
if ((a2Name != null) && (!a2Name.equals(""))) {
a2Head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(a2Name);
}
SignalHead bHead = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalB1Name());
SignalHead cHead = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalC1Name());
if (t.getLayoutBlock().getBlock() == cBlock) {
// Note: need allocation to traverse this turnout
if (!checkDirectionSensor(aHead, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
if (a2Head != null) {
if (!checkDirectionSensor(a2Head, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
}
if (!checkDirectionSensor(bHead, altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
if (!checkDirectionSensor(cHead, altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
} else {
if (((TrackSegment) t.getConnectA()).getLayoutBlock().getBlock() == cBlock) {
// throat Track Segment is in this Block
if (!checkDirectionSensor(bHead, altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
if (!checkDirectionSensor(cHead, altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
} else if (((t.getContinuingSense() == Turnout.CLOSED) && (((TrackSegment) t.getConnectB()).getLayoutBlock().getBlock() == cBlock)) || ((t.getContinuingSense() == Turnout.THROWN) && (((TrackSegment) t.getConnectC()).getLayoutBlock().getBlock() == cBlock))) {
// diverging track segment is in this block, reverse continuing sense.
if (a2Head == null) {
// single head at throat
if (!checkDirectionSensor(aHead, direction, ConnectivityUtil.CONTINUING, cUtil)) {
errorCount++;
}
} else {
// two heads at throat
if (!checkDirectionSensor(aHead, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
}
if (!checkDirectionSensor(bHead, altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
} else if (((t.getContinuingSense() == Turnout.CLOSED) && (((TrackSegment) t.getConnectC()).getLayoutBlock().getBlock() == cBlock)) || ((t.getContinuingSense() == Turnout.THROWN) && (((TrackSegment) t.getConnectB()).getLayoutBlock().getBlock() == cBlock))) {
// continuing track segment is in this block, reverse continuing sense.
if (a2Head == null) {
// single head at throat
if (!checkDirectionSensor(aHead, direction, ConnectivityUtil.DIVERGING, cUtil)) {
errorCount++;
}
} else {
// two heads at throat
if (!checkDirectionSensor(a2Head, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
}
if (!checkDirectionSensor(cHead, altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
}
}
}
} else if (t.getLinkType() != LayoutTurnout.NO_LINK) {
// special linked turnout
LayoutTurnout tLinked = getLayoutTurnoutFromTurnoutName(t.getLinkedTurnoutName(), panel);
if (tLinked == null) {
log.error("null Layout Turnout linked to turnout " + t.getTurnout().getSystemName());
} else if (t.getLinkType() == LayoutTurnout.THROAT_TO_THROAT) {
SignalHead b1Head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalB1Name());
SignalHead b2Head = null;
String hName = t.getSignalB2Name();
if ((hName != null) && (!hName.equals(""))) {
b2Head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(hName);
}
SignalHead c1Head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalC1Name());
SignalHead c2Head = null;
hName = t.getSignalC2Name();
if ((hName != null) && (!hName.equals(""))) {
c2Head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(hName);
}
int direction = getDirectionStandardTurnout(t, cUtil);
int altDirection = EntryPoint.FORWARD;
if (direction == EntryPoint.FORWARD) {
altDirection = EntryPoint.REVERSE;
}
if (direction != EntryPoint.UNKNOWN) {
if (t.getLayoutBlock().getBlock() == cBlock) {
// Note: need allocation to traverse this turnout
if (!checkDirectionSensor(b1Head, altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
if (b2Head != null) {
if (!checkDirectionSensor(b2Head, altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
}
if (!checkDirectionSensor(c1Head, altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
if (c2Head != null) {
if (!checkDirectionSensor(c2Head, altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
}
} else {
// turnout is not in this block, switch to heads of linked turnout
b1Head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(tLinked.getSignalB1Name());
hName = tLinked.getSignalB2Name();
b2Head = null;
if ((hName != null) && (!hName.equals(""))) {
b2Head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(hName);
}
c1Head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(tLinked.getSignalC1Name());
c2Head = null;
hName = tLinked.getSignalC2Name();
if ((hName != null) && (!hName.equals(""))) {
c2Head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(hName);
}
if (((t.getContinuingSense() == Turnout.CLOSED) && (((TrackSegment) t.getConnectB()).getLayoutBlock().getBlock() == cBlock)) || ((t.getContinuingSense() == Turnout.THROWN) && (((TrackSegment) t.getConnectC()).getLayoutBlock().getBlock() == cBlock))) {
// continuing track segment is in this block
if (b2Head != null) {
if (!checkDirectionSensor(b1Head, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
} else {
if (!checkDirectionSensor(b1Head, direction, ConnectivityUtil.CONTINUING, cUtil)) {
errorCount++;
}
}
if (c2Head != null) {
if (!checkDirectionSensor(c1Head, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
} else {
if (!checkDirectionSensor(c1Head, direction, ConnectivityUtil.CONTINUING, cUtil)) {
errorCount++;
}
}
} else if (((t.getContinuingSense() == Turnout.CLOSED) && (((TrackSegment) t.getConnectC()).getLayoutBlock().getBlock() == cBlock)) || ((t.getContinuingSense() == Turnout.THROWN) && (((TrackSegment) t.getConnectB()).getLayoutBlock().getBlock() == cBlock))) {
// diverging track segment is in this block
if (b2Head != null) {
if (!checkDirectionSensor(b2Head, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
} else {
if (!checkDirectionSensor(b1Head, direction, ConnectivityUtil.DIVERGING, cUtil)) {
errorCount++;
}
}
if (c2Head != null) {
if (!checkDirectionSensor(c2Head, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
} else {
if (!checkDirectionSensor(c1Head, direction, ConnectivityUtil.DIVERGING, cUtil)) {
errorCount++;
}
}
}
}
}
} else if (t.getLinkType() == LayoutTurnout.FIRST_3_WAY) {
SignalHead a1Head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalA1Name());
SignalHead a2Head = null;
String hName = t.getSignalA2Name();
if ((hName != null) && (!hName.equals(""))) {
a2Head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(hName);
}
SignalHead a3Head = null;
hName = t.getSignalA3Name();
if ((hName != null) && (!hName.equals(""))) {
a3Head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(hName);
}
SignalHead cHead = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalC1Name());
int direction = getDirectionStandardTurnout(t, cUtil);
int altDirection = EntryPoint.FORWARD;
if (direction == EntryPoint.FORWARD) {
altDirection = EntryPoint.REVERSE;
}
if (direction != EntryPoint.UNKNOWN) {
if (t.getLayoutBlock().getBlock() == cBlock) {
// Note: need allocation to traverse this turnout
if (!checkDirectionSensor(a1Head, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
if ((a2Head != null) && (a3Head != null)) {
if (!checkDirectionSensor(a2Head, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
if (!checkDirectionSensor(a3Head, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
}
if (!checkDirectionSensor(cHead, altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
} else {
// turnout is not in this block
if (((TrackSegment) t.getConnectA()).getLayoutBlock().getBlock() == cBlock) {
// throat Track Segment is in this Block
if (!checkDirectionSensor(cHead, altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
} else if (((TrackSegment) t.getConnectC()).getLayoutBlock().getBlock() == cBlock) {
// diverging track segment is in this Block
if (a2Head != null) {
if (!checkDirectionSensor(a2Head, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
} else {
if (!checkDirectionSensor(a1Head, direction, ConnectivityUtil.DIVERGING, cUtil)) {
errorCount++;
}
}
}
}
}
} else if (t.getLinkType() == LayoutTurnout.SECOND_3_WAY) {
SignalHead bHead = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalB1Name());
SignalHead cHead = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalC1Name());
SignalHead a1Head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(tLinked.getSignalA1Name());
SignalHead a3Head = null;
String hName = tLinked.getSignalA3Name();
if ((hName != null) && (!hName.equals(""))) {
a3Head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(hName);
}
int direction = getDirectionStandardTurnout(t, cUtil);
int altDirection = EntryPoint.FORWARD;
if (direction == EntryPoint.FORWARD) {
altDirection = EntryPoint.REVERSE;
}
if (direction != EntryPoint.UNKNOWN) {
if (t.getLayoutBlock().getBlock() == cBlock) {
// Note: need allocation to traverse this turnout
if (!checkDirectionSensor(bHead, altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
if (!checkDirectionSensor(cHead, altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
}
if (((TrackSegment) t.getConnectC()).getLayoutBlock().getBlock() == cBlock) {
// diverging track segment is in this Block
if (a3Head != null) {
if (!checkDirectionSensor(a3Head, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
} else {
log.warn("Turnout " + tLinked.getTurnoutName() + " - SSL for head " + a1Head.getSystemName() + " cannot handle direction sensor for second diverging track.");
errorCount++;
}
} else if (((TrackSegment) t.getConnectB()).getLayoutBlock().getBlock() == cBlock) {
// continuing track segment is in this Block
if (a3Head != null) {
if (!checkDirectionSensor(a1Head, direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
} else {
if (!checkDirectionSensor(a1Head, direction, ConnectivityUtil.CONTINUING, cUtil)) {
errorCount++;
}
}
}
}
}
} else if ((t.getTurnoutType() == LayoutTurnout.RH_XOVER) || (t.getTurnoutType() == LayoutTurnout.LH_XOVER) || (t.getTurnoutType() == LayoutTurnout.DOUBLE_XOVER)) {
// crossover turnout
// Note: direction is for proceeding from A to B (or D to C)
int direction = getDirectionXoverTurnout(t, cUtil);
int altDirection = EntryPoint.FORWARD;
if (direction == EntryPoint.FORWARD) {
altDirection = EntryPoint.REVERSE;
}
if (direction == EntryPoint.UNKNOWN) {
errorCount++;
} else {
if (((TrackSegment) t.getConnectA()).getLayoutBlock().getBlock() == cBlock) {
if ((t.getTurnoutType() == LayoutTurnout.DOUBLE_XOVER) || (t.getTurnoutType() == LayoutTurnout.RH_XOVER)) {
if (!placeSensorInCrossover(t.getSignalB1Name(), t.getSignalB2Name(), t.getSignalC1Name(), t.getSignalC2Name(), altDirection, cUtil)) {
errorCount++;
}
} else {
if (!placeSensorInCrossover(t.getSignalB1Name(), t.getSignalB2Name(), null, null, altDirection, cUtil)) {
errorCount++;
}
}
}
if (((TrackSegment) t.getConnectB()).getLayoutBlock().getBlock() == cBlock) {
if ((t.getTurnoutType() == LayoutTurnout.DOUBLE_XOVER) || (t.getTurnoutType() == LayoutTurnout.LH_XOVER)) {
if (!placeSensorInCrossover(t.getSignalA1Name(), t.getSignalA2Name(), t.getSignalD1Name(), t.getSignalD2Name(), direction, cUtil)) {
errorCount++;
}
} else {
if (!placeSensorInCrossover(t.getSignalA1Name(), t.getSignalA2Name(), null, null, direction, cUtil)) {
errorCount++;
}
}
}
if (((TrackSegment) t.getConnectC()).getLayoutBlock().getBlock() == cBlock) {
if ((t.getTurnoutType() == LayoutTurnout.DOUBLE_XOVER) || (t.getTurnoutType() == LayoutTurnout.RH_XOVER)) {
if (!placeSensorInCrossover(t.getSignalD1Name(), t.getSignalD2Name(), t.getSignalA1Name(), t.getSignalA2Name(), direction, cUtil)) {
errorCount++;
}
} else {
if (!placeSensorInCrossover(t.getSignalD1Name(), t.getSignalD2Name(), null, null, direction, cUtil)) {
errorCount++;
}
}
}
if (((TrackSegment) t.getConnectD()).getLayoutBlock().getBlock() == cBlock) {
if ((t.getTurnoutType() == LayoutTurnout.DOUBLE_XOVER) || (t.getTurnoutType() == LayoutTurnout.LH_XOVER)) {
if (!placeSensorInCrossover(t.getSignalC1Name(), t.getSignalC2Name(), t.getSignalB1Name(), t.getSignalB2Name(), altDirection, cUtil)) {
errorCount++;
}
} else {
if (!placeSensorInCrossover(t.getSignalC1Name(), t.getSignalC2Name(), null, null, altDirection, cUtil)) {
errorCount++;
}
}
}
}
} else if (t.getTurnoutType() == LayoutSlip.SINGLE_SLIP || t.getTurnoutType() == LayoutSlip.DOUBLE_SLIP) {
int direction = getDirectionSlip((LayoutSlip) t, cUtil);
int altDirection = EntryPoint.FORWARD;
if (direction == EntryPoint.FORWARD) {
altDirection = EntryPoint.REVERSE;
}
if (direction == EntryPoint.UNKNOWN) {
errorCount++;
} else {
if (!checkDirectionSensor(InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalA1Name()), altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
if (!checkDirectionSensor(InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalA2Name()), altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
if (t.getTurnoutType() == LayoutSlip.SINGLE_SLIP) {
if (!checkDirectionSensor(InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalB1Name()), altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
} else {
if (!checkDirectionSensor(InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalB1Name()), altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
if (!checkDirectionSensor(InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalB2Name()), altDirection, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
}
if (t.getTurnoutType() == LayoutSlip.SINGLE_SLIP) {
if (!checkDirectionSensor(InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalC1Name()), direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
} else {
if (!checkDirectionSensor(InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalC1Name()), direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
if (!checkDirectionSensor(InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalC2Name()), direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
}
if (!checkDirectionSensor(InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalD1Name()), direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
if (!checkDirectionSensor(InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(t.getSignalD2Name()), direction, ConnectivityUtil.OVERALL, cUtil)) {
errorCount++;
}
}
} else {
log.error("Unknown turnout type for turnout " + t.getTurnout().getSystemName() + " in Section " + getSystemName() + ".");
errorCount++;
}
} else {
// signal heads missing in turnout
missingSignalsTurnouts++;
}
}
}
// set up missing signal head message, if any
if ((missingSignalsBB + missingSignalsTurnouts + missingSignalsLevelXings) > 0) {
String s = "Section - " + getSystemName();
String uname = getUserName();
if ((uname != null) && (!uname.equals(""))) {
s = s + "(" + uname + ")";
}
if (missingSignalsBB > 0) {
s = s + ", " + (missingSignalsBB) + " anchor point signal heads missing";
}
if (missingSignalsTurnouts > 0) {
s = s + ", " + (missingSignalsTurnouts) + " turnouts missing signals";
}
if (missingSignalsLevelXings > 0) {
s = s + ", " + (missingSignalsLevelXings) + " level crossings missing signals";
}
log.warn(s);
}
return errorCount;
}
Aggregations