use of org.phoebus.framework.jobs.JobMonitor in project phoebus by ControlSystemStudio.
the class PhoebusApplication method start.
/**
* JavaFX entry point
*
* @param initial_stage Initial Stage created by JavaFX
*/
@Override
public void start(final Stage initial_stage) throws Exception {
INSTANCE = this;
// Save original application parameters
application_parameters.addAll(getParameters().getRaw());
// Show splash screen as soon as possible..
final Splash splash = Preferences.splash ? new Splash(initial_stage) : null;
// .. then read saved state etc. in background job
JobManager.schedule("Startup", monitor -> {
final JobMonitor splash_monitor = new SplashJobMonitor(monitor, splash);
backgroundStartup(splash_monitor, splash);
});
}
use of org.phoebus.framework.jobs.JobMonitor in project phoebus by ControlSystemStudio.
the class UpdateDemo method main.
public static void main(final String[] args) throws Exception {
if (args.length != 1) {
System.err.println("Need path to installation,");
return;
}
final File install_location = new File(args[0]);
final JobMonitor monitor = new BasicJobMonitor() {
@Override
public void beginTask(final String task_name) {
System.out.println(task_name);
super.beginTask(task_name);
}
@Override
public void updateTaskName(final String task_name) {
System.out.println(task_name);
super.updateTaskName(task_name);
}
};
final Instant new_version = Update.checkForUpdate(monitor);
if (new_version != null)
Update.downloadAndUpdate(monitor, install_location);
}
use of org.phoebus.framework.jobs.JobMonitor in project phoebus by ControlSystemStudio.
the class SearchJob method run.
@Override
public void run(final JobMonitor monitor) throws Exception {
final List<ChannelInfo> channels = new ArrayList<>();
monitor.beginTask(Messages.Search, archives.size());
for (ArchiveDataSource archive : archives) {
try (final ArchiveReader reader = ArchiveReaders.createReader(archive.getUrl())) {
if (monitor.isCanceled())
break;
monitor.updateTaskName(archive.getName());
reader.getNamesByPattern(pattern).stream().map(name -> new ChannelInfo(name, archive)).forEach(info -> channels.add(info));
monitor.worked(1);
} catch (final Exception ex) {
error_handler.accept(archive.getUrl(), ex);
return;
}
}
channel_handler.accept(channels);
}
use of org.phoebus.framework.jobs.JobMonitor in project phoebus by ControlSystemStudio.
the class PACEInstance method doSaveChanges.
private void doSaveChanges(final JobMonitor monitor) {
final String text = createElogText();
final LogEntryBuilder builder = new LogEntryBuilder();
builder.title(MessageFormat.format(Messages.ELogTitleFmt, model.getTitle()));
builder.appendDescription(text);
final LogEntry entry = builder.createdDate(Instant.now()).build();
LogEntryModel logEntryModel = new LogEntryModel(entry);
new LogEntryEditorStage(gui, logEntryModel, logEntry -> {
if (logEntry != null) {
final String user = logEntryModel.getUsername();
try {
// Change PVs
model.saveUserValues(user);
// On success, clear user values
model.clearUserValues();
} catch (Exception ex) {
logger.log(Level.WARNING, "Save failed", ex);
// At least some saves failed, to revert
try {
model.revertOriginalValues();
} catch (Exception ex2) {
// Since saving didn't work, restoral will also fail.
// Hopefully those initial PVs that did get updated will
// also be restored...
logger.log(Level.WARNING, "Restore failed", ex2);
}
ExceptionDetailsErrorDialog.openError(gui, Messages.SaveError, Messages.PVWriteError, ex);
}
}
}).show();
}
Aggregations