Search in sources :

Example 1 with JobMonitor

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);
    });
}
Also used : SubJobMonitor(org.phoebus.framework.jobs.SubJobMonitor) JobMonitor(org.phoebus.framework.jobs.JobMonitor)

Example 2 with JobMonitor

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);
}
Also used : BasicJobMonitor(org.phoebus.framework.jobs.BasicJobMonitor) Instant(java.time.Instant) File(java.io.File) JobMonitor(org.phoebus.framework.jobs.JobMonitor) BasicJobMonitor(org.phoebus.framework.jobs.BasicJobMonitor)

Example 3 with JobMonitor

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);
}
Also used : ArchiveDataSource(org.csstudio.trends.databrowser3.model.ArchiveDataSource) ChannelInfo(org.csstudio.trends.databrowser3.model.ChannelInfo) JobManager(org.phoebus.framework.jobs.JobManager) JobMonitor(org.phoebus.framework.jobs.JobMonitor) JobRunnable(org.phoebus.framework.jobs.JobRunnable) ArchiveReaders(org.phoebus.archive.reader.ArchiveReaders) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) Job(org.phoebus.framework.jobs.Job) List(java.util.List) Messages(org.csstudio.trends.databrowser3.Messages) BiConsumer(java.util.function.BiConsumer) ArchiveReader(org.phoebus.archive.reader.ArchiveReader) ArchiveReader(org.phoebus.archive.reader.ArchiveReader) ArrayList(java.util.ArrayList) ArchiveDataSource(org.csstudio.trends.databrowser3.model.ArchiveDataSource) ChannelInfo(org.csstudio.trends.databrowser3.model.ChannelInfo)

Example 4 with JobMonitor

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();
}
Also used : LogEntry(org.phoebus.logbook.LogEntry) JobManager(org.phoebus.framework.jobs.JobManager) Cell(org.csstudio.display.pace.model.Cell) AppInstance(org.phoebus.framework.spi.AppInstance) LogEntryEditorStage(org.phoebus.logbook.ui.write.LogEntryEditorStage) JobMonitor(org.phoebus.framework.jobs.JobMonitor) HashMap(java.util.HashMap) Instance(org.csstudio.display.pace.model.Instance) AppDescriptor(org.phoebus.framework.spi.AppDescriptor) LogEntryModel(org.phoebus.logbook.ui.write.LogEntryModel) Instant(java.time.Instant) MessageFormat(java.text.MessageFormat) Level(java.util.logging.Level) PACEApp.logger(org.csstudio.display.pace.PACEApp.logger) Platform(javafx.application.Platform) Model(org.csstudio.display.pace.model.Model) Map(java.util.Map) URI(java.net.URI) DockPane(org.phoebus.ui.docking.DockPane) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) LogEntryBuilder(org.phoebus.logbook.LogEntryImpl.LogEntryBuilder) ExceptionDetailsErrorDialog(org.phoebus.ui.dialog.ExceptionDetailsErrorDialog) DockItemWithInput(org.phoebus.ui.docking.DockItemWithInput) GUI(org.csstudio.display.pace.gui.GUI) LogEntryModel(org.phoebus.logbook.ui.write.LogEntryModel) LogEntryBuilder(org.phoebus.logbook.LogEntryImpl.LogEntryBuilder) LogEntryEditorStage(org.phoebus.logbook.ui.write.LogEntryEditorStage) LogEntry(org.phoebus.logbook.LogEntry)

Aggregations

JobMonitor (org.phoebus.framework.jobs.JobMonitor)4 MessageFormat (java.text.MessageFormat)2 Instant (java.time.Instant)2 JobManager (org.phoebus.framework.jobs.JobManager)2 File (java.io.File)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 BiConsumer (java.util.function.BiConsumer)1 Consumer (java.util.function.Consumer)1 Level (java.util.logging.Level)1 Platform (javafx.application.Platform)1 ExtensionFilter (javafx.stage.FileChooser.ExtensionFilter)1 PACEApp.logger (org.csstudio.display.pace.PACEApp.logger)1 GUI (org.csstudio.display.pace.gui.GUI)1 Cell (org.csstudio.display.pace.model.Cell)1 Instance (org.csstudio.display.pace.model.Instance)1 Model (org.csstudio.display.pace.model.Model)1