This commit is contained in:
2021-04-28 09:29:19 +02:00
parent 84e20e54cc
commit a9f0de27e6
1030 changed files with 14567 additions and 227310 deletions
+144 -44
View File
@@ -93,13 +93,10 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
@@ -107,6 +104,7 @@ import javax.swing.JSpinner;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingUtilities;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
@@ -154,11 +152,13 @@ public class ScreenPanel7 extends Panel {
String camServerUrl;
String instanceName;
Overlay titleOv = null;
Overlay backgOv = null;
//int integration = 0;
boolean persistCameraState;
Map<String, List<String>> groups;
Map<String, String> aliases;
final Logger logger;
List<String> types;
public class CameraState extends Config {
@@ -392,6 +392,7 @@ public class ScreenPanel7 extends Panel {
logger = Logger.getLogger(getClass().getName());
try {
initComponents();
spinnerBackground.setVisible(false);
spinnerThreshold.setVisible(false);
btFixColormapRange.setVisible(false);
setGoodRegionOptionsVisible(false);
@@ -407,10 +408,18 @@ public class ScreenPanel7 extends Panel {
setPersistedComponents(new Component[]{buttonTitle});
comboCameras.setEnabled(false);
comboType.setEnabled(false);
if (App.hasArgument(ARG_LIST) || App.hasArgument(ARG_TYPE)){
if (App.hasArgument(ARG_LIST)){
comboType.setVisible(false);
labelType.setVisible(false);
}
if (App.hasArgument(ARG_TYPE)){
types = new ArrayList<>();
for (String token : App.getArgumentValue(ARG_TYPE).split(",")){
if (!token.isBlank()){
types.add(token.trim());
}
}
}
SwingUtils.setEnumCombo(comboColormap, Colormap.class);
if (App.hasArgument("poll")) {
@@ -821,21 +830,28 @@ public class ScreenPanel7 extends Panel {
);
} else {
String[] types = new String[]{"All"};
try (CameraServer srv = newCameraServer()) {
groups = srv.getCameraGroups();
comboType.setModel(new javax.swing.DefaultComboBoxModel(Arr.insert(Arr.sort(groups.keySet().toArray(new String[0])), "All", 0)));
groups = srv.getCameraGroups();
types = Arr.insert(Arr.sort(groups.keySet().toArray(new String[0])), "All", 0);
aliases = srv.getCameraAliases();
} catch (Exception ex){
groups = null;
aliases = null;
}
if (this.types!=null){
types = this.types.toArray(new String[0]);
}
comboType.setModel(new javax.swing.DefaultComboBoxModel(types));
usingServer = buttonServer.isSelected();
updateCameraList();
comboCameras.setEnabled(true);
comboType.setEnabled(true);
setComboCameraSelection(null);
setComboTypeSelection("All");
if (Arr.containsEqual(types, "All")){
setComboTypeSelection("All");
}
updateCameraList();
if (comboCameras.getModel().getSize() > 0) {
try {
@@ -853,10 +869,7 @@ public class ScreenPanel7 extends Panel {
}
boolean isVisible(String camera) {
if (App.hasArgument(ARG_TYPE)){
return getCameraTypes(camera).contains(App.getArgumentValue(ARG_TYPE));
}
return ((comboType.getSelectedIndex() == 0) || (getCameraTypes(camera).contains(comboType.getSelectedItem())));
return ((comboType.getSelectedItem().toString().toLowerCase().equals("all")) || (getCameraTypes(camera).contains(comboType.getSelectedItem())));
}
DefaultComboBoxModel getCameraList(boolean fromServer) throws Exception {
@@ -1006,11 +1019,31 @@ public class ScreenPanel7 extends Panel {
}
synchronized (lockOverlays) {
renderer.updateOverlays(to, titleOv);
renderer.updateOverlays(to, titleOv);
titleOv = to;
}
}
}
void manageOverlayErrorOverlay(boolean error) {
if ((error) != (backgOv != null)){
Overlay bo = null;
if (error){
String text = "Invalid image background";
Font font = new Font("Arial", Font.PLAIN, 14);
bo = new Text(renderer.getPenErrorText(), text, font, new Point(-SwingUtils.getTextSize(text, renderer.getGraphics().getFontMetrics(font)).width - 14, 46));
bo.setFixed(true);
bo.setAnchor(Overlay.ANCHOR_VIEWPORT_OR_IMAGE_TOP_RIGHT);
}
synchronized (lockOverlays) {
renderer.updateOverlays(bo,backgOv);
backgOv = bo;
}
}
}
@Override
public void onStateChange(State state, State former) {
@@ -1076,6 +1109,7 @@ public class ScreenPanel7 extends Panel {
this.cameraName = cameraName;
if (changed || buttonDirect.isSelected()) {
spinnerBackground.setVisible(false);
spinnerThreshold.setVisible(false);
checkThreshold.setEnabled(false);
checkRotation.setEnabled(false);
@@ -1524,11 +1558,31 @@ public class ScreenPanel7 extends Panel {
btFixColormapRange.setVisible(buttonAutomatic.isSelected());
spinnerMin.setEnabled(buttonManual.isSelected());
spinnerMax.setEnabled(buttonManual.isSelected());
boolean signed = spinnerBackground.isVisible() && "signed".equals(spinnerBackground.getValue());
Integer min = signed ? -65535: 0;
if (!min.equals(((SpinnerNumberModel)spinnerMin.getModel()).getMinimum())){
spinnerMin.setModel(new SpinnerNumberModel(0, min.intValue(), 65535, 1));
spinnerMax.setModel(new SpinnerNumberModel(255, min.intValue(), 65535, 1));
if ((Integer)((SpinnerNumberModel)spinnerMin.getModel()).getValue() < min){
spinnerMin.setValue(min);
}
if ((Integer)((SpinnerNumberModel)spinnerMax.getModel()).getValue() < min){
spinnerMax.setValue(min);
}
}
if (!Double.isNaN(config.colormapMin)) {
spinnerMin.setValue(Math.min(Math.max((int) config.colormapMin, 0), 65535));
Integer value = Math.min(Math.max((int) config.colormapMin, min), 65535);
if (spinnerMin.getModel().getValue()!= value){
spinnerMin.setValue(value);
}
}
if (!Double.isNaN(config.colormapMax)) {
spinnerMax.setValue(Math.min(Math.max((int) config.colormapMax, 0), 65535));
Integer value = Math.min(Math.max((int) config.colormapMax, min), 65535);
if (spinnerMax.getModel().getValue()!= value){
spinnerMax.setValue(value);
}
}
}
} catch (Exception ex) {
@@ -1539,6 +1593,7 @@ public class ScreenPanel7 extends Panel {
void updatePipelineProperties() {
goodRegion = checkGoodRegion.isSelected();
spinnerBackground.setVisible(checkBackground.isSelected());
spinnerThreshold.setVisible(checkThreshold.isSelected());
setGoodRegionOptionsVisible(goodRegion);
slicing = goodRegion && checkSlicing.isSelected();
@@ -1557,7 +1612,14 @@ public class ScreenPanel7 extends Panel {
updatingServerControls = true;
if (server.isStarted()) {
try {
checkBackground.setSelected(server.getBackgroundSubtraction());
checkBackground.setSelected(server.isBackgroundSubtractionEnabled());
setBackgoundControl(server.getBackgroundSubtraction());
Object bg = server.getBackgroundSubtraction();
if (bg.equals("signed") || bg.equals("passive")){
spinnerBackground.setValue(bg);
} else {
spinnerBackground.setValue("normal");
}
Double threshold = (server.getThreshold());
checkThreshold.setSelected(threshold != null);
spinnerThreshold.setValue((threshold == null) ? 0 : threshold);
@@ -1607,7 +1669,7 @@ public class ScreenPanel7 extends Panel {
boolean changedPipelinePars(Map pars1, Map pars2) {
String[] keys = new String[]{"image_background_enable", "image_threshold", "image_good_region",
"threshold", "gfscale", "image_slices", "number_of_slices", "scale", "orientation"};
"threshold", "gfscale", "image_slices", "number_of_slices", "scale", "orientation", "image_background_ok"};
for (String key : keys) {
Object o1 = pars1.get(key);
Object o2 = pars2.get(key);
@@ -1621,13 +1683,21 @@ public class ScreenPanel7 extends Panel {
}
return false;
}
void setBackgoundControl(Object background){
spinnerBackground.setValue((background.equals("signed") || background.equals("passive")) ? background : "normal");
}
void updatePipelineControls(Map pars) {
if (pars != null) {
updatingServerControls = true;
try {
boolean background = (boolean) pars.get("image_background_enable");
checkBackground.setSelected(background);
Object background = pars.get("image_background_enable");
checkBackground.setSelected(!background.equals("") && !background.equals(false) && !background.equals("false"));
setBackgoundControl(background);
manageOverlayErrorOverlay(Boolean.FALSE.equals(pars.get("image_background_ok")));
Double threshold = (Double) (pars.get("image_threshold"));
checkThreshold.setSelected(threshold != null);
spinnerThreshold.setValue((threshold == null) ? 0 : threshold);
@@ -2357,13 +2427,17 @@ public class ScreenPanel7 extends Panel {
boolean getLaserState(int bunch) throws Exception {
//return (Epics.get("SIN-TIMAST-TMA:Beam-Las-Delay-Sel", Integer.class) == 0);
if (bunch<=0){
return getLaserState(1) && getLaserState(2);
try{
if (bunch<=0){
return getLaserState(1) && getLaserState(2);
}
if (bunch==2){
return (Epics.get("SWISSFEL-STATUS:Bunch-2-OnDelay-Sel", Integer.class) == 0);
}
return (Epics.get("SWISSFEL-STATUS:Bunch-1-OnDelay-Sel", Integer.class) == 0);
} catch (Exception ex){
return false;
}
if (bunch==2){
return (Epics.get("SWISSFEL-STATUS:Bunch-2-OnDelay-Sel", Integer.class) == 0);
}
return (Epics.get("SWISSFEL-STATUS:Bunch-1-OnDelay-Sel", Integer.class) == 0);
}
void elog(String logbook, String title, String message, String[] attachments) throws Exception {
@@ -3016,6 +3090,7 @@ public class ScreenPanel7 extends Panel {
labelAvFrames = new javax.swing.JLabel();
labelAvMode = new javax.swing.JLabel();
spinnerAvMode = new javax.swing.JSpinner();
spinnerBackground = new javax.swing.JSpinner();
topPanel = new javax.swing.JPanel();
toolBar = new javax.swing.JToolBar();
buttonSidePanel = new javax.swing.JToggleButton();
@@ -3542,7 +3617,7 @@ public class ScreenPanel7 extends Panel {
labelMode.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
labelMode.setText("Mode:");
spinnerRotationMode.setModel(new javax.swing.SpinnerListModel(new String[] {"constant", "reflect", "nearest", "mirror", "wrap"}));
spinnerRotationMode.setModel(new javax.swing.SpinnerListModel(new String[] {"constant", "reflect", "nearest", "mirror", "wrap", "ortho"}));
spinnerRotationMode.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerRotationAngleStateChanged(evt);
@@ -3589,6 +3664,13 @@ public class ScreenPanel7 extends Panel {
}
});
spinnerBackground.setModel(new javax.swing.SpinnerListModel(new String[] {"normal", "signed", "passive"}));
spinnerBackground.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerBackgroundStateChanged(evt);
}
});
javax.swing.GroupLayout panelScreen2Layout = new javax.swing.GroupLayout(panelScreen2);
panelScreen2.setLayout(panelScreen2Layout);
panelScreen2Layout.setHorizontalGroup(
@@ -3622,30 +3704,33 @@ public class ScreenPanel7 extends Panel {
.addComponent(labelConstant, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(labelMode, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(labelGrThreshold, javax.swing.GroupLayout.Alignment.TRAILING))))
.addGap(2, 2, 2)
.addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(spinnerGrThreshold, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spinnerGrScale)
.addComponent(spinnerThreshold)
.addComponent(spinnerRotationOrder)
.addComponent(spinnerRotationMode)
.addComponent(spinnerRotationAngle)
.addComponent(spinnerRotationConstant)
.addComponent(spinnerAvFrames)
.addComponent(spinnerAvMode)))
.addGap(2, 2, 2))
.addGroup(panelScreen2Layout.createSequentialGroup()
.addComponent(checkBackground)
.addGap(0, 0, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(spinnerGrThreshold, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spinnerGrScale, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(spinnerThreshold, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(spinnerRotationOrder, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(spinnerRotationMode, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(spinnerRotationAngle, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(spinnerRotationConstant, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(spinnerAvFrames, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(spinnerAvMode, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(spinnerBackground, javax.swing.GroupLayout.Alignment.TRAILING))
.addContainerGap())
);
panelScreen2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerAvFrames, spinnerAvMode, spinnerGrScale, spinnerGrThreshold, spinnerRotationAngle, spinnerRotationConstant, spinnerRotationMode, spinnerRotationOrder, spinnerThreshold});
panelScreen2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerAvFrames, spinnerAvMode, spinnerBackground, spinnerGrScale, spinnerGrThreshold, spinnerRotationAngle, spinnerRotationConstant, spinnerRotationMode, spinnerRotationOrder, spinnerThreshold});
panelScreen2Layout.setVerticalGroup(
panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelScreen2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(checkBackground)
.addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(checkBackground)
.addComponent(spinnerBackground, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(2, 2, 2)
.addGroup(panelScreen2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(checkThreshold)
@@ -3690,7 +3775,7 @@ public class ScreenPanel7 extends Panel {
.addContainerGap())
);
panelScreen2Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {spinnerGrScale, spinnerGrThreshold, spinnerRotationAngle, spinnerRotationConstant, spinnerRotationMode, spinnerRotationOrder, spinnerThreshold});
panelScreen2Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {spinnerAvFrames, spinnerAvMode, spinnerBackground, spinnerGrScale, spinnerGrThreshold, spinnerRotationAngle, spinnerRotationConstant, spinnerRotationMode, spinnerRotationOrder, spinnerThreshold});
javax.swing.GroupLayout sidePanelLayout = new javax.swing.GroupLayout(sidePanel);
sidePanel.setLayout(sidePanelLayout);
@@ -4161,7 +4246,9 @@ public class ScreenPanel7 extends Panel {
if (!updatingServerControls) {
try {
if (server.isStarted()) {
server.setBackgroundSubtraction(checkBackground.isSelected());
spinnerBackground.setVisible(checkBackground.isSelected());
Object bg_mode = checkBackground.isSelected() ? String.valueOf(spinnerBackground.getValue()) : false;
server.setBackgroundSubtraction(bg_mode.equals("normal") ? true : bg_mode);
}
} catch (Exception ex) {
showException(ex);
@@ -4531,6 +4618,18 @@ public class ScreenPanel7 extends Panel {
checkAveragingActionPerformed(null);
}//GEN-LAST:event_spinnerAvFramesStateChanged
private void spinnerBackgroundStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerBackgroundStateChanged
if (!updatingServerControls) {
try {
Object bg_mode = String.valueOf(spinnerBackground.getValue());
server.setBackgroundSubtraction((bg_mode=="normal") ? true : bg_mode);
} catch (Exception ex) {
showException(ex);
updatePipelineControls();
}
}
}//GEN-LAST:event_spinnerBackgroundStateChanged
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btFixColormapRange;
private javax.swing.JRadioButton buttonAutomatic;
@@ -4604,6 +4703,7 @@ public class ScreenPanel7 extends Panel {
private javax.swing.JPanel sidePanel;
private javax.swing.JSpinner spinnerAvFrames;
private javax.swing.JSpinner spinnerAvMode;
private javax.swing.JSpinner spinnerBackground;
private javax.swing.JSpinner spinnerGrScale;
private javax.swing.JSpinner spinnerGrThreshold;
private javax.swing.JSpinner spinnerMax;