Add debugging permanent pipelines in ScreenPanel for SLS

This commit is contained in:
2025-12-05 11:28:55 +01:00
parent 087386c293
commit a5fdc5af59
2 changed files with 177 additions and 16 deletions

View File

@@ -46,6 +46,7 @@
<Component id="panelScreen" alignment="1" max="32767" attributes="0"/>
<Component id="panelControls" alignment="0" max="32767" attributes="0"/>
<Component id="panelParameters" alignment="0" max="32767" attributes="0"/>
<Component id="panelEpicsHandler" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
@@ -56,7 +57,9 @@
<Component id="panelScreen" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelControls" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="334" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelEpicsHandler" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="277" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -89,7 +92,7 @@
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Component id="comboScreen" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Component id="valueScreen" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -155,12 +158,12 @@
<Component id="jLabel2" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="selMirror" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel3" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="selLedPower" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel4" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonFLDown" alignment="2" min="-2" max="-2" attributes="0"/>
@@ -272,6 +275,61 @@
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelEpicsHandler">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Permanent Instance"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="ckDebugEpicsHandler" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonApplyEpicsHandler" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonApplyEpicsHandler" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="ckDebugEpicsHandler" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonApplyEpicsHandler">
<Properties>
<Property name="text" type="java.lang.String" value="Apply"/>
<Property name="toolTipText" type="java.lang.String" value="Apply changes to saved configuration"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonApplyEpicsHandlerActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="ckDebugEpicsHandler">
<Properties>
<Property name="text" type="java.lang.String" value="Debug"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ckDebugEpicsHandlerActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Component class="ch.psi.pshell.screenpanel.CamServerViewer" name="camServerViewer">

View File

@@ -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<String,String> 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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<String, Object> newCfg = camServerViewer.getServer().getInstanceConfig();
//Map<String, Object> origCfg =camServerViewer.getServer().getInstanceConfig(originalInstance);
Map<String, Object> 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;