diff --git a/config/variables.properties b/config/variables.properties
index 7c48e33..1fa05cd 100644
--- a/config/variables.properties
+++ b/config/variables.properties
@@ -1,2 +1,2 @@
-#Mon Nov 04 14:37:52 CET 2019
-FileSequentialNumber=112
+#Mon Nov 04 14:42:13 CET 2019
+FileSequentialNumber=114
diff --git a/plugins/AthosCameras.form b/plugins/AthosCameras.form
index 401f923..1dc4777 100644
--- a/plugins/AthosCameras.form
+++ b/plugins/AthosCameras.form
@@ -18,7 +18,7 @@
-
+
@@ -203,7 +203,7 @@
-
+
@@ -217,7 +217,12 @@
-
+
+
+
+
+
+
@@ -244,7 +249,8 @@
-
+
+
@@ -294,6 +300,14 @@
+
+
+
+
+
+
+
+
diff --git a/plugins/AthosCameras.java b/plugins/AthosCameras.java
index 402603d..49bdbb6 100644
--- a/plugins/AthosCameras.java
+++ b/plugins/AthosCameras.java
@@ -3,12 +3,19 @@ import ch.psi.pshell.bs.StreamValue;
import ch.psi.pshell.core.CommandSource;
import ch.psi.pshell.device.Device;
import ch.psi.pshell.device.DeviceAdapter;
+import ch.psi.pshell.device.DeviceListener;
+import ch.psi.pshell.device.Readable.ReadableArray;
+import ch.psi.pshell.device.Readable.ReadableNumber;
+import ch.psi.pshell.device.ReadableRegister.ReadableRegisterArray;
+import ch.psi.pshell.device.ReadableRegister.ReadableRegisterNumber;
import ch.psi.pshell.imaging.Overlay;
import ch.psi.pshell.imaging.Overlays;
import ch.psi.pshell.scan.MonitorScan;
import ch.psi.pshell.swing.DataPanel;
+import ch.psi.pshell.swing.DeviceValueChart;
import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.Panel;
+import ch.psi.utils.Convert;
import ch.psi.utils.State;
import ch.psi.utils.Threading;
import ch.psi.utils.swing.MainFrame;
@@ -18,11 +25,14 @@ import java.awt.Font;
import java.awt.Point;
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.Array;
import java.nio.file.Paths;
import java.util.HashMap;
+import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
+import javax.swing.JDialog;
import javax.swing.SwingUtilities;
/**
@@ -239,6 +249,65 @@ public class AthosCameras extends Panel {
}
+
+ void showPlot(String field) throws Exception{
+ DeviceListener listener;
+ Object obj = dataPipeline.getValue(field);
+ if (field.equals("processing_parameters")) {
+ } else if ((obj != null) && (obj.getClass().isArray() || (obj instanceof Number))) {
+ DeviceValueChart chart = new DeviceValueChart();
+ Device dev = null;
+ if (obj.getClass().isArray()) {
+ dev = new ReadableRegisterArray(new ReadableArray() {
+ @Override
+ public Object read() throws IOException, InterruptedException {
+ return Convert.toDouble(dataPipeline.getValue(field));
+ }
+
+ @Override
+ public int getSize() {
+ return Array.getLength(dataPipeline.getValue(field));
+ }
+ });
+ } else {
+ dev = new ReadableRegisterNumber(new ReadableNumber() {
+ @Override
+ public Object read() throws IOException, InterruptedException {
+ return Convert.toDouble(dataPipeline.getValue(field));
+ }
+ });
+ }
+ //dev.setPolling(1000);
+ Device finalDev = dev;
+
+ listener = new DeviceAdapter() {
+ @Override
+ public void onCacheChanged(Device device, Object value, Object former, long timestamp, boolean valueChange) {
+ finalDev.updateAsync();
+ }
+ };
+ dataPipeline.getStream().addListener(listener);
+
+
+ JDialog dlg = SwingUtils.showDialog(AthosCameras.this.getTopLevel(), cameraName + " " + field, null, chart);
+
+ chart.setAsyncUpdates(true);
+ chart.setDevice(dev);
+ //chart.setAsyncUpdates(true);
+ System.out.println(chart.getAsyncUpdates());
+
+ SwingUtils.invokeDelayed(()->{chart.setAsyncUpdates(true);}, 3000);
+ //TODO:
+ //PlotBase plot = chart.getPlot();
+ //if (plot!=null){
+ // plot.setPlotBackgroundColor(Color.BLACK);
+ //}
+ }
+
+
+ }
+
+
@SuppressWarnings("unchecked")
// //GEN-BEGIN:initComponents
@@ -262,6 +331,7 @@ public class AthosCameras extends Panel {
edit_x_fit_mean = new javax.swing.JTextField();
edit_y_fit_mean = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
+ jButton1 = new javax.swing.JButton();
jPanel4 = new javax.swing.JPanel();
textCamera = new javax.swing.JTextField();
@@ -375,12 +445,19 @@ public class AthosCameras extends Panel {
jLabel4.setText("y_fit_mean");
+ jButton1.setText("Plot");
+ jButton1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButton1ActionPerformed(evt);
+ }
+ });
+
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
- .addContainerGap(19, Short.MAX_VALUE)
+ .addContainerGap(26, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel1)
.addComponent(jLabel2)
@@ -392,7 +469,11 @@ public class AthosCameras extends Panel {
.addComponent(edit_x_center_of_mass, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(edit_x_fit_mean, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(edit_y_fit_mean, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(20, Short.MAX_VALUE))
+ .addContainerGap(27, Short.MAX_VALUE))
+ .addGroup(jPanel2Layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jButton1)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -413,7 +494,8 @@ public class AthosCameras extends Panel {
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(edit_y_fit_mean, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(33, Short.MAX_VALUE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jButton1))
);
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Camera"));
@@ -443,7 +525,7 @@ public class AthosCameras extends Panel {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
- .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 505, Short.MAX_VALUE)
+ .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 491, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
@@ -495,6 +577,15 @@ public class AthosCameras extends Panel {
}
}//GEN-LAST:event_buttonOpenActionPerformed
+ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
+ try{
+
+ showPlot("x_center_of_mass");
+ } catch (Exception ex){
+ this.showException(ex);
+ }
+ }//GEN-LAST:event_jButton1ActionPerformed
+
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonOpen;
private javax.swing.JToggleButton buttonRec;
@@ -503,6 +594,7 @@ public class AthosCameras extends Panel {
private javax.swing.JTextField edit_x_fit_mean;
private javax.swing.JTextField edit_y_center_of_mass;
private javax.swing.JTextField edit_y_fit_mean;
+ private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;