@Override public PVConfiguration<R, W> notifyOn(Executor onThread) { pvReaderConfiguration.notifyOn(onThread); pvWriterConfiguration.notifyOn(onThread); return this; }
public void datasourcesInSWT_CSSTudio() { // In CS-Studio, you should never change the default configuration programmatically // or you will create problems for other applications. All configuration // shoul be done on your own readers/writers. // If you are developing user interfaces in SWT, you will want to route the notifications on the SWT thread. // Import from here // import static org.csstudio.utility.pvmanager.ui.SWTUtil.*; // When creating a pv, remember to ask for notification on the SWT thread PVReader<?> pvReader = PVManager.read(channel("test")).notifyOn(swtThread()).maxRate(ofMillis(100)); }
private void pvChange(final int i) { if (pvs.get(i) != null) { pvs.get(i).close(); imagePanels.get(i).setImage(null); plots.set(i, null); } if (pvFields.get(i).getText() == null || pvFields.get(i).getText().trim().isEmpty()) { return; } SparklineGraph2DExpression plot = sparklineGraphOf(formula(pvFields.get(i).getText()), null, null); plots.set(i, plot); plots.get(i).update(plots.get(i).newUpdate().imageHeight(imagePanels.get(i).getHeight()) .imageWidth(imagePanels.get(i).getWidth())); pvs.set(i, PVManager.read(plots.get(i)) .notifyOn(swingEDT()) .readListener(new PVReaderListener<Graph2DResult>() { @Override public void pvChanged(PVReaderEvent<Graph2DResult> event) { setLastError(event.getPvReader().lastException()); if (event.getPvReader().getValue() != null) { BufferedImage image = ValueUtil.toImage(event.getPvReader().getValue().getImage()); imagePanels.get(i).setImage(image); } } }) .maxRate(ofHertz(50))); }
public void datasourcesInSwing() { // When creating UIs in swing, you will need to route notification directly // on the Event Dispatch Thread. // You can do this on a PV by PV basis, or you can change the default if // you control the whole application. // Import from here // import static org.diirt.util.concurrent.Executors.*; // Route notification for this pv on the Swing EDT PVReader<?> pvReader = PVManager.read(channel("test")).notifyOn(swingEDT()).maxRate(ofMillis(100)); // Or you can change the default PVManager.setDefaultNotificationExecutor(swingEDT()); }
public void datasourcesInJavaFX() { // When creating UIs in JavaFX, you will need to route notification directly // on the Application Thread. // You can do this on a PV by PV basis, or you can change the default if // you control the whole application. // Import from here // import static org.diirt.javafx.util.Executors.*; // Route notification for this pv on the Swing EDT PVReader<?> pvReader = PVManager.read(channel("test")).notifyOn(javaFXAT()).maxRate(ofMillis(100)); // Or you can change the default PVManager.setDefaultNotificationExecutor(javaFXAT()); }
protected void reconnect() { if (pv != null) { pv.close(); imagePanel.setImage(null); graph = null; } if (dataFormulaField.getSelectedItem() == null || dataFormulaField.getSelectedItem().toString().trim().isEmpty()) { return; } graph = createExpression(dataFormulaField.getSelectedItem().toString()); graph.update(graph.newUpdate().imageHeight(imagePanel.getHeight()) .imageWidth(imagePanel.getWidth())); pv = PVManager.read(graph) .notifyOn(swingEDT()) .readListener(new PVReaderListener<Graph2DResult>() { @Override public void pvChanged(PVReaderEvent<Graph2DResult> event) { setLastError(pv.lastException()); if (pv.getValue() != null) { BufferedImage image = ValueUtil.toImage(pv.getValue().getImage()); imagePanel.setImage(image); } } }) .maxRate(ofHertz(50)); }
.notifyOn(swingEDT()) .maxRate(TimeDuration.ofHertz(50));
private void pvNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pvNameActionPerformed if (pv != null) pv.close(); plot = waterfallPlotOf(vNumberArray(pvName.getText())).with( colorScheme(ColorScheme.multipleRangeGradient(Color.RED, Color.YELLOW, Color.BLACK, Color.WHITE, Color.YELLOW, Color.RED)), backgroundColor(getBackground().getRGB()), adaptiveRange(adaptiveRangeField.isSelected()), scrollDown(scrollDownField.isSelected()), height(plotView.getHeight()), pixelDuration(ofMillis(((Number) pixelDurationField.getValue()).intValue()))); pv = PVManager.read(plot).notifyOn(swingEDT()) .readListener(new PVReaderListener<VImage>() { @Override public void pvChanged(PVReaderEvent<VImage> event) { setLastError(pv.lastException()); if (pv.getValue() != null) { BufferedImage image = ValueUtil.toImage(pv.getValue()); plotView.setImage(image); } } }) .maxRate(TimeDuration.ofHertz(50)); }//GEN-LAST:event_pvNameActionPerformed
private void dataFormulaFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dataFormulaFieldActionPerformed if (pv != null) { pv.close(); plotView.setImage(null); plot = null; } if (dataFormulaField.getText() == null || dataFormulaField.getText().trim().isEmpty()) { return; } if (plot == null) { plot = lineGraphOf(formula(dataFormulaField.getText()), formulaArg(xColumnField.getText()), formulaArg(yColumnField.getText()), formulaArg(tooltipColumnField.getText())); } plot.update(new LineGraph2DRendererUpdate().imageHeight(plotView.getHeight()).imageWidth(plotView.getWidth()).interpolation(InterpolationScheme.LINEAR)); pv = PVManager.read(plot) .notifyOn(swingEDT()) .readListener(new PVReaderListener<Graph2DResult>() { @Override public void pvChanged(PVReaderEvent<Graph2DResult> event) { setLastError(pv.lastException()); if (pv.getValue() != null) { BufferedImage image = ValueUtil.toImage(pv.getValue().getImage()); plotView.setImage(image); } } }) .maxRate(ofHertz(50)); }//GEN-LAST:event_dataFormulaFieldActionPerformed