use of jmri.jmrit.operations.trains.TrainSwitchLists in project JMRI by JMRI.
the class PrintSwitchListAction method doAction.
@Override
public void doAction() {
if (getAutomationItem() != null) {
setRunning(true);
TrainSwitchLists trainSwitchLists = new TrainSwitchLists();
for (Location location : LocationManager.instance().getLocationsByNameList()) {
if (location.isSwitchListEnabled()) {
trainSwitchLists.buildSwitchList(location);
trainSwitchLists.printSwitchList(location, TrainManager.instance().isPrintPreviewEnabled());
}
}
// set trains switch lists printed
TrainManager.instance().setTrainsSwitchListStatus(Train.PRINTED);
}
finishAction(true);
}
use of jmri.jmrit.operations.trains.TrainSwitchLists in project JMRI by JMRI.
the class RunSwitchListChangesAction method doAction.
/**
* Creates a custom switch list for each location that is selected and
* there's new work for that location.
* <p>
* common code see RunSwitchListAction.java
* @param isChanged if set true only locations with changes will get a custom switch list.
*/
@SuppressFBWarnings(value = { "UC_USELESS_CONDITION", "RpC_REPEATED_CONDITIONAL_TEST" }, justification = "isChanged = false when called from RunSwitchListAction")
protected void doAction(boolean isChanged) {
if (getAutomationItem() != null) {
if (!Setup.isGenerateCsvSwitchListEnabled()) {
log.warn("Generate CSV Switch List isn't enabled!");
finishAction(false);
return;
}
// we do need one of these!
if (!TrainCustomSwitchList.instance().excelFileExists()) {
log.warn("Manifest creator file not found!, directory name: {}, file name: {}", TrainCustomSwitchList.instance().getDirectoryName(), TrainCustomSwitchList.instance().getFileName());
finishAction(false);
return;
}
setRunning(true);
TrainSwitchLists trainSwitchLists = new TrainSwitchLists();
TrainCsvSwitchLists trainCsvSwitchLists = new TrainCsvSwitchLists();
// this can wait thread
if (!TrainCustomManifest.instance().checkProcessReady()) {
log.warn("Timeout waiting for excel manifest program to complete previous operation, timeout value: {} seconds", Control.excelWaitTime);
}
// this can wait thread
if (!TrainCustomSwitchList.instance().checkProcessReady()) {
log.warn("Timeout waiting for excel switch list program to complete previous operation, timeout value: {} seconds", Control.excelWaitTime);
}
if (TrainCustomSwitchList.instance().doesCommonFileExist()) {
log.warn("Switch List CSV common file exists!");
}
for (Location location : LocationManager.instance().getLocationsByNameList()) {
if (location.isSwitchListEnabled() && (!isChanged || (isChanged && location.getStatus().equals(Location.MODIFIED)))) {
// also build the regular switch lists so they can be used
if (!Setup.isSwitchListRealTime()) {
trainSwitchLists.buildSwitchList(location);
}
File csvFile = trainCsvSwitchLists.buildSwitchList(location);
if (csvFile == null || !csvFile.exists()) {
log.error("CSV switch list file was not created for location {}", location.getName());
finishAction(false);
return;
}
TrainCustomSwitchList.instance().addCVSFile(csvFile);
}
}
// Processes the CSV Manifest files using an external custom program.
boolean status = TrainCustomSwitchList.instance().process();
if (status) {
try {
// wait up to 60 seconds per file
status = TrainCustomSwitchList.instance().waitForProcessToComplete();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
log.info("No switch list changes found");
}
// set trains switch lists printed
TrainManager.instance().setTrainsSwitchListStatus(Train.PRINTED);
finishAction(status);
}
}
use of jmri.jmrit.operations.trains.TrainSwitchLists in project JMRI by JMRI.
the class PrintSwitchListAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
TrainSwitchLists ts = new TrainSwitchLists();
ts.buildSwitchList(location);
ts.printSwitchList(location, isPreview);
}
use of jmri.jmrit.operations.trains.TrainSwitchLists in project JMRI by JMRI.
the class PrintSwitchListChangesAction method doAction.
@Override
public void doAction() {
if (getAutomationItem() != null) {
setRunning(true);
TrainSwitchLists trainSwitchLists = new TrainSwitchLists();
for (Location location : LocationManager.instance().getLocationsByNameList()) {
if (location.isSwitchListEnabled() && location.getStatus().equals(Location.MODIFIED)) {
trainSwitchLists.buildSwitchList(location);
trainSwitchLists.printSwitchList(location, TrainManager.instance().isPrintPreviewEnabled());
}
}
// set trains switch lists printed
TrainManager.instance().setTrainsSwitchListStatus(Train.PRINTED);
}
finishAction(true);
}
use of jmri.jmrit.operations.trains.TrainSwitchLists in project JMRI by JMRI.
the class TrainScheduleManager method buildSwitchLists.
public void buildSwitchLists() {
TrainSwitchLists trainSwitchLists = new TrainSwitchLists();
// only create switch lists once for locations with similar names
String locationName = "";
for (Location location : LocationManager.instance().getLocationsByNameList()) {
if (location.isSwitchListEnabled() && !locationName.equals(TrainCommon.splitString(location.getName()))) {
trainSwitchLists.buildSwitchList(location);
// print switch lists for locations that have changes
if (Setup.isSwitchListRealTime() && location.getStatus().equals(Location.MODIFIED)) {
trainSwitchLists.printSwitchList(location, TrainManager.instance().isPrintPreviewEnabled());
locationName = TrainCommon.splitString(location.getName());
}
}
}
// set trains switch lists printed
TrainManager.instance().setTrainsSwitchListStatus(Train.PRINTED);
}
Aggregations