diff --git a/screenpanel-sls/src/main/java/ScreenPanelSLS.form b/screenpanel-sls/src/main/java/ScreenPanelSLS.form
index 2db4f92..260ae16 100755
--- a/screenpanel-sls/src/main/java/ScreenPanelSLS.form
+++ b/screenpanel-sls/src/main/java/ScreenPanelSLS.form
@@ -46,6 +46,7 @@
+
@@ -56,7 +57,9 @@
-
+
+
+
@@ -89,7 +92,7 @@
-
+
@@ -155,12 +158,12 @@
-
+
-
+
@@ -272,6 +275,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/screenpanel-sls/src/main/java/ScreenPanelSLS.java b/screenpanel-sls/src/main/java/ScreenPanelSLS.java
index 05a27ca..986b6dd 100755
--- a/screenpanel-sls/src/main/java/ScreenPanelSLS.java
+++ b/screenpanel-sls/src/main/java/ScreenPanelSLS.java
@@ -1,4 +1,5 @@
import ch.psi.pshell.bs.StreamCamera;
+import ch.psi.pshell.camserver.ProxyClient;
import ch.psi.pshell.data.DataStore;
import ch.psi.pshell.device.Device;
import ch.psi.pshell.epics.DiscretePositioner;
@@ -19,10 +20,12 @@ import ch.psi.pshell.swing.SwingUtils.OptionResult;
import ch.psi.pshell.swing.SwingUtils.OptionType;
import ch.psi.pshell.screenpanel.Options;
import ch.psi.pshell.screenpanel.CamServerViewer;
+import ch.psi.pshell.utils.Threading;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.io.IOException;
import java.util.List;
+import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
@@ -52,9 +55,14 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
//DiscretePositioner mirror;
BinaryPositioner mirror;
BinaryPositioner ledPower;
+
+ boolean detached;
+ String detachedInstance;
+ String originalInstance;
final Logger logger;
+ Map permanentInstances;
static public void main(String[] args) {
ch.psi.pshell.workbench.Options.add();
@@ -70,6 +78,7 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
panelParameters.setVisible(false);
panelScreen.setVisible(false);
panelControls.setVisible(false);
+ panelEpicsHandler.setVisible(false);
camServerViewer.setListener(this);
this.remove(customPanel);
camServerViewer.getCustomPanel().add(customPanel);
@@ -78,6 +87,7 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
camServerViewer.setShowFit(true);
camServerViewer.setShowProfile(true);
camServerViewer.setShowReticle(true);
+ camServerViewer.getSidePanel
}
@Override
@@ -87,6 +97,14 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
SwingUtilities.invokeLater(()->{
try {
camServerViewer.initialize(App.getArgumentValue(Options.SP_MODE.getString(null)));
+ Threading.newDaemonThread(()->{
+ ProxyClient proxy = new ProxyClient(camServerViewer.getPipelineServerUrl());
+ try {
+ permanentInstances = proxy.getPemanentInstances();
+ } catch (IOException ex) {
+ Logger.getLogger(ScreenPanelSLS.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }).start();
} catch (Exception ex) {
Logger.getLogger(ScreenPanelSLS.class.getName()).log(Level.SEVERE, null, ex);
}
@@ -160,8 +178,7 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
}
@Override
- public void onOpeningStream(String name) throws Exception {
- System.out.println("Initializing stream " + name);
+ public void onOpeningStream(String name) throws Exception {
if ((devicesInitTask != null) && (devicesInitTask.isAlive())) {
devicesInitTask.interrupt();
}
@@ -184,20 +201,23 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
buttonFLUp.setEnabled(false);
selLedPower.setEnabled(false);
panelExposure.setEnabled(false);
- buttonApplyExposure.setEnabled(false);
+ buttonApplyExposure.setEnabled(false);
selMirror.setEnabled(false);
if ((name==null)|| name.isBlank()){
panelParameters.setVisible(false);
panelScreen.setVisible(false);
panelControls.setVisible(false);
- }
+ }
+ boolean wasDetached = detached && detachedInstance.startsWith(name);
+ detached = (name!=null) && name.contains("detached_instance");
+ panelEpicsHandler.setVisible(detached || wasDetached);
updateDialogTitle();
}
@Override
public void onOpenedStream(String name, String instance) throws Exception {
- System.out.println("Initialized instance: " + instance);
+ System.out.println("Initialized instance: " + instance);
String cameraName = camServerViewer.getCameraName();
List types = camServerViewer.getCameraTypes(cameraName);
boolean btr = (types!=null) && types.contains(BTR_TYPE);
@@ -216,6 +236,12 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
panelParameters.setVisible(cameraParameters);
panelScreen.setVisible(cameraControls);
panelControls.setVisible(cameraControls);
+
+ if(permanentInstances!=null){
+ boolean permanent = permanentInstances.keySet().contains(instance);
+ ckDebugEpicsHandler.setSelected(detached);
+ panelEpicsHandler.setVisible(detached || permanent);
+ }
if (cameraName!=null){
if (cameraParameters || cameraControls) {
@@ -361,15 +387,13 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
ds.setAttribute(pathRoot, "LedPower", String.valueOf(selLedPower.getComboBox().getSelectedItem()));
}
}
-
+
void updateDialogTitle() {
if (Setup.isDetached()) {
getTopLevel().setTitle(camServerViewer.getInstanceName() == null ? "ScreenPanel" : camServerViewer.getInstanceName());
}
}
-
-
////////
@SuppressWarnings("unchecked")
// //GEN-BEGIN:initComponents
@@ -397,6 +421,9 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
jLabel1 = new javax.swing.JLabel();
panelExposure = new ch.psi.pshell.swing.RegisterPanel();
buttonApplyExposure = new javax.swing.JButton();
+ panelEpicsHandler = new javax.swing.JPanel();
+ buttonApplyEpicsHandler = new javax.swing.JButton();
+ ckDebugEpicsHandler = new javax.swing.JCheckBox();
camServerViewer = new ch.psi.pshell.screenpanel.CamServerViewer();
setPreferredSize(new java.awt.Dimension(873, 600));
@@ -427,7 +454,7 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelScreenLayout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(comboScreen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGap(4, 4, 4)
.addComponent(valueScreen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
@@ -486,11 +513,11 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
.addGroup(panelControlsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel2)
.addComponent(selMirror, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGap(4, 4, 4)
.addGroup(panelControlsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel3)
.addComponent(selLedPower, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGap(4, 4, 4)
.addGroup(panelControlsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel4)
.addComponent(buttonFLDown)
@@ -536,6 +563,45 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
.addContainerGap())
);
+ panelEpicsHandler.setBorder(javax.swing.BorderFactory.createTitledBorder("Permanent Instance"));
+
+ buttonApplyEpicsHandler.setText("Apply");
+ buttonApplyEpicsHandler.setToolTipText("Apply changes to saved configuration");
+ buttonApplyEpicsHandler.setEnabled(false);
+ buttonApplyEpicsHandler.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonApplyEpicsHandlerActionPerformed(evt);
+ }
+ });
+
+ ckDebugEpicsHandler.setText("Debug");
+ ckDebugEpicsHandler.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ ckDebugEpicsHandlerActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout panelEpicsHandlerLayout = new javax.swing.GroupLayout(panelEpicsHandler);
+ panelEpicsHandler.setLayout(panelEpicsHandlerLayout);
+ panelEpicsHandlerLayout.setHorizontalGroup(
+ panelEpicsHandlerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelEpicsHandlerLayout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(ckDebugEpicsHandler)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(buttonApplyEpicsHandler)
+ .addContainerGap())
+ );
+ panelEpicsHandlerLayout.setVerticalGroup(
+ panelEpicsHandlerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelEpicsHandlerLayout.createSequentialGroup()
+ .addGap(4, 4, 4)
+ .addGroup(panelEpicsHandlerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(buttonApplyEpicsHandler)
+ .addComponent(ckDebugEpicsHandler))
+ .addContainerGap())
+ );
+
javax.swing.GroupLayout customPanelLayout = new javax.swing.GroupLayout(customPanel);
customPanel.setLayout(customPanelLayout);
customPanelLayout.setHorizontalGroup(
@@ -543,6 +609,7 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
.addComponent(panelScreen, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelControls, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelParameters, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(panelEpicsHandler, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
customPanelLayout.setVerticalGroup(
customPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -552,7 +619,9 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
.addComponent(panelScreen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelControls, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(334, Short.MAX_VALUE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(panelEpicsHandler, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(277, Short.MAX_VALUE))
);
add(customPanel, java.awt.BorderLayout.WEST);
@@ -637,7 +706,39 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
}
}//GEN-LAST:event_buttonApplyExposureActionPerformed
+ private void buttonApplyEpicsHandlerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonApplyEpicsHandlerActionPerformed
+ try{
+ Map newCfg = camServerViewer.getServer().getInstanceConfig();
+ //Map origCfg =camServerViewer.getServer().getInstanceConfig(originalInstance);
+ Map origCfg =camServerViewer.getServer().getConfig(originalInstance);
+ newCfg.remove("port");
+ newCfg.remove("no_client_timeout");
+ newCfg.remove("detached_instance");
+ origCfg.putAll(newCfg);
+ camServerViewer.getServer().setInstanceConfig(originalInstance, origCfg);
+ camServerViewer.apply();
+ this.showMessage("Success", "Success updating original pipeline configuration");
+ } catch (Exception ex) {
+ showException(ex);
+ }
+ }//GEN-LAST:event_buttonApplyEpicsHandlerActionPerformed
+
+ private void ckDebugEpicsHandlerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ckDebugEpicsHandlerActionPerformed
+ try{
+ buttonApplyEpicsHandler.setEnabled(ckDebugEpicsHandler.isSelected());
+ if (ckDebugEpicsHandler.isSelected()){
+ originalInstance = camServerViewer.getInstanceName();
+ detachedInstance = camServerViewer.detachInstance();
+ } else {
+ camServerViewer.apply();
+ }
+ } catch (Exception ex) {
+ showException(ex);
+ }
+ }//GEN-LAST:event_ckDebugEpicsHandlerActionPerformed
+
// Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton buttonApplyEpicsHandler;
private javax.swing.JButton buttonApplyExposure;
private javax.swing.JButton buttonFLDown;
private javax.swing.JButton buttonFLUp;
@@ -646,6 +747,7 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
private javax.swing.ButtonGroup buttonGroup3;
private javax.swing.ButtonGroup buttonGroup4;
private ch.psi.pshell.screenpanel.CamServerViewer camServerViewer;
+ private javax.swing.JCheckBox ckDebugEpicsHandler;
private javax.swing.JComboBox comboScreen;
private javax.swing.JPanel customPanel;
private javax.swing.JLabel jLabel1;
@@ -654,6 +756,7 @@ public class ScreenPanelSLS extends Panel implements CamServerViewer.CamServerVi
private javax.swing.JLabel jLabel4;
private javax.swing.JProgressBar jProgressBar1;
private javax.swing.JPanel panelControls;
+ private javax.swing.JPanel panelEpicsHandler;
private ch.psi.pshell.swing.RegisterPanel panelExposure;
private ch.psi.pshell.swing.RegisterPanel panelFlStep;
private javax.swing.JPanel panelParameters;