diff --git a/config/config.properties b/config/config.properties index 79e395e..c3380fe 100644 --- a/config/config.properties +++ b/config/config.properties @@ -1,42 +1,42 @@ -#Wed Sep 30 11:44:30 CEST 2020 -imageSourcesFile={config}/imaging.properties -autoSaveScanData=true -simulation=false -commandExecutionEvents=true -logDaysToLive=7 -dataScanSaveOutput=false -userAuthenticator= -logLevelConsole=Off -scanStreamerPort=-1 -dataScanSaveScript=false -dataScanSaveSetpoints=false -parallelInitialization=false -scanStreamingPort=-1 -devicePoolFile={config}/devices.properties -versionTrackingManual=true +#Wed Nov 25 16:15:14 CET 2020 hostName=null userManagement=true +imageSourcesFile={config}/imaging.properties instanceName=SIM +autoSaveScanData=true +simulation=false dataServerPort=-1 hideServerMessages=false serverPort=8080 versionTrackingEnabled=true -dataPath={data}/{year}_{month}/{date}_{seq}%03d +dataPath={data}/{year}_{month}/{date}/{date}_{seq}%04d_{name} serverEnabled=false +commandExecutionEvents=true +logDaysToLive=7 dataScanReleaseRecords=false depthDimension=0 dataScanPreserveTypes=false +dataScanSaveOutput=false logLevel=Info dataScanFlushRecords=true logPath={logs}/{date}_{time} dataLayout=table deviceUpdateStrategyFile={config}/update.properties terminalEnabled=false -notificationLevel=null +notificationLevel=Completion +userAuthenticator= +logLevelConsole=Off terminalPort=3579 tasksFile={config}/tasks.properties +scanStreamerPort=-1 +dataScanSaveScript=false +dataScanSaveSetpoints=false +parallelInitialization=true +scanStreamingPort=-1 createSessionFiles=false versionTrackingLogin={context}/svcusr-hlapp_robot +devicePoolFile={config}/devices.properties +versionTrackingManual=true versionTrackingRemote=git@git.psi.ch\:pshell_config/x11ma.git dataProvider=txt saveCommandStatistics=false diff --git a/config/mail.properties b/config/mail.properties index 3911e06..de2ac9e 100644 --- a/config/mail.properties +++ b/config/mail.properties @@ -1,9 +1,10 @@ #Thu Nov 09 14:56:48 CET 2017 auth=None -from= -host= +from=pshell.sim@psi.ch +host=smtpint.psi.ch port=0 pwd= smsSuffix=@sms.switch.ch -to= +#to=armin.kleibert@psi.ch;alexandre.gobbo@psi.ch +to=alexandre.gobbo@psi.ch usr= diff --git a/config/plugins.properties b/config/plugins.properties index c2f714b..cc2997e 100644 --- a/config/plugins.properties +++ b/config/plugins.properties @@ -1,9 +1,10 @@ -Experiment.java=enabled -Eiger.java=enabled OTFScanBase.java=enabled EnergyScanBase.java=enabled DelayScanBase.java=enabled EnergyScan_TBT.java=enabled DelayScan.java=enabled EnergyScan.java=enabled -Test.java=enabled +Eiger.java=enabled +Beamline.java=enabled +Experiment.java=enabled +Test.java=disabled diff --git a/config/settings.properties b/config/settings.properties index d418652..46cc429 100644 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,18 +1,25 @@ -#Wed Nov 11 15:44:02 CET 2020 +#Tue Dec 01 10:09:37 CET 2020 HARMONIC_ID_1=1 -RSYNC_USER=e18650 -ENERGY=850.0 +RSYNC_USER=e18413 OUTLIERS_THRESHOLD=1000000000 -POL_ID_1=Circ_Plus NORM_FILE=/sls/X11MA/data/X11MA/Data1/public/PEEM/2020_09/i1904_1_0.tif AUTO_SWITCH_VALVE=true -RSYNC_PATH=XPEEMSample2-NCA-F-pristine -DRY_RUN=false -ALPHA_ID_2=45.0 -ALPHA_ID_1=15.0 +DRY_RUN=true POL_ID_2=Lin_Hor OFFSET_ID_1=-1.5 ID=ID2 -OFFSET_ID_2=-0.6 +OFFSET_ID_2=-1.3 +proposal=proposal +ENERGY=709.1 +proposer=proposer +POL_ID_1=Lin_Ver +RSYNC_HOST= +sample=sample +RSYNC_PATH=BFO_16nm +pgroup=pgroup +ALPHA_ID_2=45.0 +ALPHA_ID_1=15.0 +RSYNC_DEL=false HARMONIC_ID_2=1 FdaBrowser=true +authors=author1|author2 diff --git a/config/variables.properties b/config/variables.properties index 6426712..36bae42 100644 --- a/config/variables.properties +++ b/config/variables.properties @@ -1,2 +1,4 @@ -#Tue Nov 10 20:19:33 CET 2020 -FileSequentialNumber=3687 +#Sat Nov 28 14:51:50 CET 2020 +LastRunDate=201128 +FileSequentialNumber=4741 +DaySequentialNumber=24 diff --git a/devices/image.properties b/devices/image.properties index cb71866..8a3f660 100644 --- a/devices/image.properties +++ b/devices/image.properties @@ -1,4 +1,4 @@ -#Tue Nov 10 12:39:52 CET 2020 +#Wed Nov 25 21:29:46 CET 2020 spatialCalOffsetY=NaN spatialCalOffsetX=NaN colormapLogarithmic=false @@ -6,7 +6,7 @@ scale=1.0 grayscale=false spatialCalScaleX=NaN spatialCalScaleY=NaN -colormapMax=600.0 +colormapMax=2000.0 rescaleOffset=0.0 roiWidth=-1 colormap=Grayscale diff --git a/plugins/Beamline.form b/plugins/Beamline.form new file mode 100644 index 0000000..80cf0f0 --- /dev/null +++ b/plugins/Beamline.form @@ -0,0 +1,494 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/plugins/Beamline.java b/plugins/Beamline.java new file mode 100644 index 0000000..6cd1423 --- /dev/null +++ b/plugins/Beamline.java @@ -0,0 +1,567 @@ +import ch.psi.pshell.core.Context; +import ch.psi.pshell.swing.DeviceValuePanel; +import ch.psi.pshell.ui.Panel; +import ch.psi.utils.Arr; +import ch.psi.utils.State; +import ch.psi.utils.swing.SwingUtils; +import java.awt.Component; +import java.awt.Font; +import java.io.IOException; +import java.util.HashMap; +import javax.swing.JComboBox; +import javax.swing.JPanel; +import javax.swing.JSpinner; +import javax.swing.JToggleButton; +import javax.swing.SwingConstants; + +/** + * + */ +public class Beamline extends Panel { + + public enum ID { + ID1, + ID2, + ID1_ID2 + } + + public enum Polarization { + Circ_Plus, + Circ_Minus, + Lin_Hor, + Lin_Ver, + Lin + } + + final Component[] parameterControls; + + public Beamline() { + initComponents(); + + ((JSpinner.ListEditor) spinnerHar1.getEditor()).getTextField().setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + ((JSpinner.ListEditor) spinnerHar2.getEditor()).getTextField().setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + SwingUtils.setEnumCombo(comboID, Beamline.ID.class, true); + SwingUtils.setEnumCombo(comboPol1, Beamline.Polarization.class, true); + SwingUtils.setEnumCombo(comboPol2, Beamline.Polarization.class, true); + + Component[] parameterControls = new Component[0]; + for (JPanel panel : new JPanel[]{panelBeamline}) { + for (Class cls : new Class[]{JComboBox.class, JSpinner.class, JToggleButton.class}) { + parameterControls = Arr.append(parameterControls, SwingUtils.getComponentsByType(panel, cls)); + } + } + + Font devValueFont = deviceValuePanel1.getFont().deriveFont(8.0f); + for (Component panel : SwingUtils.getComponentsByType(panelBeamline, DeviceValuePanel.class)){ + ((DeviceValuePanel)panel).getLabel().setFont(devValueFont); + ((DeviceValuePanel)panel).getLabel().setVerticalAlignment(SwingConstants.TOP); + ((DeviceValuePanel)panel).getLabel().setVerticalTextPosition(SwingConstants.TOP); + } + + deviceValuePanel1.getLabel().setVerticalAlignment(SwingConstants.TOP); + deviceValuePanel1.getLabel().setFont(deviceValuePanel1.getFont().deriveFont(8.0f)); + + + + this.parameterControls = parameterControls; + + } + + //Overridable callbacks + @Override + public void onInitialize(int runCount) { + try { + String id = getSetting("ID"); + Double en = Double.valueOf(getSetting("ENERGY")); + String pol1 = getSetting("POL_ID_1"); + Double alp1 = Double.valueOf(getSetting("ALPHA_ID_1")); + String har1 = getSetting("HARMONIC_ID_1"); + Double off1 = Double.valueOf(getSetting("OFFSET_ID_1")); + String pol2 = getSetting("POL_ID_2"); + Double alp2 = Double.valueOf(getSetting("ALPHA_ID_2")); + String har2 = getSetting("HARMONIC_ID_2"); + Double off2 = Double.valueOf(getSetting("OFFSET_ID_2")); + comboID.setSelectedItem(id); + spinnerImgEng.setValue(en); + comboPol1.setSelectedItem(pol1); + spinnerAlp1.setValue(alp1); + spinnerHar1.setValue(har1); + spinnerOff1.setValue(off1); + comboPol2.setSelectedItem(pol2); + spinnerAlp2.setValue(alp2); + spinnerHar2.setValue(har2); + spinnerOff2.setValue(off2); + + checkAutoValve.setSelected(String.valueOf(getSetting("AUTO_SWITCH_VALVE")).equalsIgnoreCase("true")); + } catch (IOException ex) { + showException(ex); + } + } + + @Override + public void onStateChange(State state, State former) { + updateControls(); + } + + @Override + public void onExecutedFile(String fileName, Object result) { + } + + + //Callback to perform update - in event thread + @Override + protected void doUpdate() { + } + + void updateControls() { + boolean editable = getState().isInitialized() && !getState().isProcessing(); + boolean is_id1 = comboID.getSelectedIndex() != 1; + boolean is_id2 = comboID.getSelectedIndex() != 0; + buttonApply.setEnabled(editable); + + for (Component c : parameterControls) { + c.setEnabled(editable); + } + + if (editable) { + spinnerAlp1.setEnabled(is_id1 && (comboPol1.getSelectedItem() == Beamline.Polarization.Lin.toString())); + spinnerAlp2.setEnabled(is_id2 & (comboPol2.getSelectedItem() == Beamline.Polarization.Lin.toString())); + spinnerHar1.setEnabled(is_id1 ); + spinnerHar2.setEnabled(is_id2 ); + spinnerOff1.setEnabled(is_id1 ); + spinnerOff2.setEnabled(is_id2 ); + comboPol1.setEnabled(is_id1 ); + comboPol2.setEnabled(is_id2 ); + } + } + + + void setBeamlineArgs(HashMap args) { + args.put("ID", comboID.getSelectedItem()); + args.put("ENERGY", spinnerImgEng.getValue()); + args.put("POL_ID_1", comboPol1.getSelectedItem()); + args.put("ALPHA_ID_1", spinnerAlp1.getValue()); + args.put("HARMONIC_ID_1", spinnerHar1.getValue()); + args.put("OFFSET_ID_1", spinnerOff1.getValue()); + args.put("POL_ID_2", comboPol2.getSelectedItem()); + args.put("ALPHA_ID_2", spinnerAlp2.getValue()); + args.put("HARMONIC_ID_2", spinnerHar2.getValue()); + args.put("OFFSET_ID_2", spinnerOff2.getValue()); + } + + void applyBeamline() throws Context.ContextStateException { + + HashMap args = new HashMap(); + setBeamlineArgs(args); + + runAsync("templates/SetupBeamline", args).handle((ret, t) -> { + if ((t != null) && (!getContext().isAborted())) { + showException((Exception) t); + } + return t; + }); + } + + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + panelBeamline = new javax.swing.JPanel(); + jLabel3 = new javax.swing.JLabel(); + comboID = new javax.swing.JComboBox<>(); + jPanel7 = new javax.swing.JPanel(); + jLabel5 = new javax.swing.JLabel(); + comboPol1 = new javax.swing.JComboBox<>(); + jLabel6 = new javax.swing.JLabel(); + spinnerAlp1 = new javax.swing.JSpinner(); + jLabel7 = new javax.swing.JLabel(); + spinnerHar1 = new javax.swing.JSpinner(); + jLabel8 = new javax.swing.JLabel(); + spinnerOff1 = new javax.swing.JSpinner(); + deviceValuePanel2 = new ch.psi.pshell.swing.DeviceValuePanel(); + deviceValuePanel3 = new ch.psi.pshell.swing.DeviceValuePanel(); + deviceValuePanel4 = new ch.psi.pshell.swing.DeviceValuePanel(); + deviceValuePanel5 = new ch.psi.pshell.swing.DeviceValuePanel(); + jPanel9 = new javax.swing.JPanel(); + jLabel13 = new javax.swing.JLabel(); + comboPol2 = new javax.swing.JComboBox<>(); + jLabel14 = new javax.swing.JLabel(); + spinnerAlp2 = new javax.swing.JSpinner(); + jLabel15 = new javax.swing.JLabel(); + spinnerHar2 = new javax.swing.JSpinner(); + jLabel16 = new javax.swing.JLabel(); + spinnerOff2 = new javax.swing.JSpinner(); + deviceValuePanel6 = new ch.psi.pshell.swing.DeviceValuePanel(); + deviceValuePanel7 = new ch.psi.pshell.swing.DeviceValuePanel(); + deviceValuePanel8 = new ch.psi.pshell.swing.DeviceValuePanel(); + deviceValuePanel9 = new ch.psi.pshell.swing.DeviceValuePanel(); + buttonApply = new javax.swing.JButton(); + jLabel27 = new javax.swing.JLabel(); + spinnerImgEng = new javax.swing.JSpinner(); + checkAutoValve = new javax.swing.JCheckBox(); + deviceValuePanel1 = new ch.psi.pshell.swing.DeviceValuePanel(); + deviceValuePanel10 = new ch.psi.pshell.swing.DeviceValuePanel(); + + jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel3.setText("ID:"); + + comboID.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + comboID.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + comboIDActionPerformed(evt); + } + }); + + jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("ID1")); + + jLabel5.setText("Mode:"); + + comboPol1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + comboPol1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + comboPol1ActionPerformed(evt); + } + }); + + jLabel6.setText("Alpha:"); + + spinnerAlp1.setModel(new javax.swing.SpinnerNumberModel(0.0d, -360.0d, 360.0d, 1.0d)); + + jLabel7.setText("Harmonic:"); + + spinnerHar1.setModel(new javax.swing.SpinnerListModel(new String[] {"1", "3"})); + + jLabel8.setText("Offset:"); + + spinnerOff1.setModel(new javax.swing.SpinnerNumberModel(0.0d, -10.0d, 10.0d, 1.0d)); + + deviceValuePanel2.setDeviceName("id1_alpha"); + + deviceValuePanel3.setDeviceName("id1_pol"); + + deviceValuePanel4.setDeviceName("id1_harmonic"); + + deviceValuePanel5.setDeviceName("id1_offset"); + + javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); + jPanel7.setLayout(jPanel7Layout); + jPanel7Layout.setHorizontalGroup( + jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addComponent(spinnerAlp1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(deviceValuePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel7Layout.createSequentialGroup() + .addComponent(spinnerHar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(deviceValuePanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel7Layout.createSequentialGroup() + .addComponent(comboPol1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(deviceValuePanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel7Layout.createSequentialGroup() + .addComponent(spinnerOff1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(deviceValuePanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + jPanel7Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel5, jLabel6, jLabel7, jLabel8}); + + jPanel7Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboPol1, spinnerAlp1, spinnerHar1, spinnerOff1}); + + jPanel7Layout.setVerticalGroup( + jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(deviceValuePanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(comboPol1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel6) + .addComponent(spinnerAlp1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(deviceValuePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel7) + .addComponent(spinnerHar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(deviceValuePanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel8) + .addComponent(spinnerOff1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(deviceValuePanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + jPanel7Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {deviceValuePanel2, deviceValuePanel3, deviceValuePanel4, deviceValuePanel5, spinnerAlp1, spinnerHar1, spinnerOff1}); + + jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder("ID2")); + + jLabel13.setText("Mode:"); + + comboPol2.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + comboPol2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + comboPol2ActionPerformed(evt); + } + }); + + jLabel14.setText("Alpha:"); + + spinnerAlp2.setModel(new javax.swing.SpinnerNumberModel(0.0d, -360.0d, 360.0d, 1.0d)); + + jLabel15.setText("Harmonic:"); + + spinnerHar2.setModel(new javax.swing.SpinnerListModel(new String[] {"1", "3"})); + + jLabel16.setText("Offset:"); + + spinnerOff2.setModel(new javax.swing.SpinnerNumberModel(0.0d, -10.0d, 10.0d, 1.0d)); + + deviceValuePanel6.setDeviceName("id2_pol"); + + deviceValuePanel7.setDeviceName("id2_alpha"); + + deviceValuePanel8.setDeviceName("id2_harmonic"); + + deviceValuePanel9.setDeviceName("id2_offset"); + + javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9); + jPanel9.setLayout(jPanel9Layout); + jPanel9Layout.setHorizontalGroup( + jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel9Layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel15, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel16, javax.swing.GroupLayout.Alignment.TRAILING)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(spinnerOff2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(spinnerHar2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(spinnerAlp2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(comboPol2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(deviceValuePanel6, javax.swing.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE) + .addComponent(deviceValuePanel7, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addComponent(deviceValuePanel8, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addComponent(deviceValuePanel9, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + jPanel9Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel13, jLabel14, jLabel15, jLabel16}); + + jPanel9Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboPol2, spinnerAlp2, spinnerHar2, spinnerOff2}); + + jPanel9Layout.setVerticalGroup( + jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel9Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(deviceValuePanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(comboPol2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel13)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(deviceValuePanel7, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(spinnerAlp2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel14)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel15) + .addComponent(spinnerHar2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(deviceValuePanel8, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel16) + .addComponent(spinnerOff2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(deviceValuePanel9, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + jPanel9Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {deviceValuePanel6, deviceValuePanel7, deviceValuePanel8, deviceValuePanel9, spinnerAlp2, spinnerHar2, spinnerOff2}); + + buttonApply.setText("Apply"); + buttonApply.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonApplyActionPerformed(evt); + } + }); + + jLabel27.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel27.setText("Energy:"); + + spinnerImgEng.setModel(new javax.swing.SpinnerNumberModel(1000.0d, 90.0d, 2520.0d, 1.0d)); + + checkAutoValve.setText("Auto Switch Valve"); + checkAutoValve.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + checkAutoValveActionPerformed(evt); + } + }); + + deviceValuePanel1.setDeviceName("energy"); + + deviceValuePanel10.setDeviceName("energy_opt_desc"); + + javax.swing.GroupLayout panelBeamlineLayout = new javax.swing.GroupLayout(panelBeamline); + panelBeamline.setLayout(panelBeamlineLayout); + panelBeamlineLayout.setHorizontalGroup( + panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelBeamlineLayout.createSequentialGroup() + .addContainerGap() + .addGroup(panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(checkAutoValve) + .addGroup(panelBeamlineLayout.createSequentialGroup() + .addComponent(jLabel27) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(deviceValuePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addComponent(spinnerImgEng))) + .addGroup(panelBeamlineLayout.createSequentialGroup() + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(comboID, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(deviceValuePanel10, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGap(18, 18, Short.MAX_VALUE) + .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(panelBeamlineLayout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonApply, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + ); + + panelBeamlineLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel27, jLabel3}); + + panelBeamlineLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboID, deviceValuePanel1, deviceValuePanel10, spinnerImgEng}); + + panelBeamlineLayout.setVerticalGroup( + panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelBeamlineLayout.createSequentialGroup() + .addGroup(panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelBeamlineLayout.createSequentialGroup() + .addContainerGap() + .addGroup(panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(panelBeamlineLayout.createSequentialGroup() + .addGap(30, 30, 30) + .addGroup(panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(comboID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(deviceValuePanel10, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel27) + .addComponent(spinnerImgEng, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(deviceValuePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(checkAutoValve))) + .addGap(18, 18, Short.MAX_VALUE) + .addComponent(buttonApply) + .addContainerGap()) + ); + + panelBeamlineLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {comboID, deviceValuePanel1, deviceValuePanel10, spinnerImgEng}); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(panelBeamline, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(panelBeamline, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap(24, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void comboIDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboIDActionPerformed + updateControls(); + }//GEN-LAST:event_comboIDActionPerformed + + private void comboPol1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboPol1ActionPerformed + updateControls(); + }//GEN-LAST:event_comboPol1ActionPerformed + + private void comboPol2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboPol2ActionPerformed + updateControls(); + }//GEN-LAST:event_comboPol2ActionPerformed + + private void buttonApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonApplyActionPerformed + try { + applyBeamline(); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonApplyActionPerformed + + private void checkAutoValveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkAutoValveActionPerformed + try{ + setSetting("AUTO_SWITCH_VALVE", checkAutoValve.isSelected()); + } catch (Exception ex){ + showException (ex); + } + }//GEN-LAST:event_checkAutoValveActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton buttonApply; + private javax.swing.JCheckBox checkAutoValve; + private javax.swing.JComboBox comboID; + private javax.swing.JComboBox comboPol1; + private javax.swing.JComboBox comboPol2; + private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel1; + private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel10; + private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel2; + private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel3; + private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel4; + private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel5; + private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel6; + private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel7; + private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel8; + private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel9; + private javax.swing.JLabel jLabel13; + private javax.swing.JLabel jLabel14; + private javax.swing.JLabel jLabel15; + private javax.swing.JLabel jLabel16; + private javax.swing.JLabel jLabel27; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JPanel jPanel7; + private javax.swing.JPanel jPanel9; + private javax.swing.JPanel panelBeamline; + private javax.swing.JSpinner spinnerAlp1; + private javax.swing.JSpinner spinnerAlp2; + private javax.swing.JSpinner spinnerHar1; + private javax.swing.JSpinner spinnerHar2; + private javax.swing.JSpinner spinnerImgEng; + private javax.swing.JSpinner spinnerOff1; + private javax.swing.JSpinner spinnerOff2; + // End of variables declaration//GEN-END:variables +} diff --git a/plugins/DelayScan.java b/plugins/DelayScan.java index c5fd55b..277beb8 100644 --- a/plugins/DelayScan.java +++ b/plugins/DelayScan.java @@ -549,7 +549,7 @@ public class DelayScan extends Panel { try { abort(); } catch (InterruptedException ex) { - Logger.getLogger(DelayScan.class.getName()).log(Level.SEVERE, null, ex); + getLogger().log(Level.SEVERE, null, ex); } }//GEN-LAST:event_buttonAbortActionPerformed diff --git a/plugins/DelayScanBase.java b/plugins/DelayScanBase.java index 998da70..599c367 100644 --- a/plugins/DelayScanBase.java +++ b/plugins/DelayScanBase.java @@ -400,7 +400,7 @@ public class DelayScanBase extends Panel { try { abort(); } catch (InterruptedException ex) { - Logger.getLogger(DelayScan.class.getName()).log(Level.SEVERE, null, ex); + getLogger().log(Level.SEVERE, null, ex); } }//GEN-LAST:event_buttonAbortActionPerformed diff --git a/plugins/Eiger.form b/plugins/Eiger.form index 6271625..0703402 100644 --- a/plugins/Eiger.form +++ b/plugins/Eiger.form @@ -33,735 +33,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1217,9 +488,9 @@ - + - + diff --git a/plugins/Eiger.java b/plugins/Eiger.java index 9238fd3..4bc55bc 100644 --- a/plugins/Eiger.java +++ b/plugins/Eiger.java @@ -44,26 +44,11 @@ import javax.swing.table.DefaultTableModel ; * */ public class Eiger extends Panel { - - public enum ID { - ID1, - ID2, - ID1_ID2 - } - public enum Switching { Normal, Tune_Detune } - public enum Polarization { - Circ_Plus, - Circ_Minus, - Lin_Hor, - Lin_Ver, - Lin - } - public enum ImgMethod { Two_Pol, Two_Energies, @@ -78,31 +63,16 @@ public class Eiger extends Panel { public Eiger() { initComponents(); - ((JSpinner.ListEditor) spinnerHar1.getEditor()).getTextField().setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - ((JSpinner.ListEditor) spinnerHar2.getEditor()).getTextField().setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - SwingUtils.setEnumCombo(comboID, ID.class, true); SwingUtils.setEnumCombo(comboSwitch, Switching.class, true); comboSwitch.setSelectedIndex(1); - SwingUtils.setEnumCombo(comboPol1, Polarization.class, true); - SwingUtils.setEnumCombo(comboPol2, Polarization.class, true); SwingUtils.setEnumCombo(comboImgMethod, ImgMethod.class, true); Component[] parameterControls = new Component[0]; - for (JPanel panel : new JPanel[]{panelBeamline, panelImgControls, panelSpectrum}) { + for (JPanel panel : new JPanel[]{panelImgControls, panelSpectrum}) { for (Class cls : new Class[]{JComboBox.class, JSpinner.class, JToggleButton.class}) { parameterControls = Arr.append(parameterControls, SwingUtils.getComponentsByType(panel, cls)); } - } - - Font devValueFont = deviceValuePanel1.getFont().deriveFont(8.0f); - for (Component panel : SwingUtils.getComponentsByType(panelBeamline, DeviceValuePanel.class)){ - ((DeviceValuePanel)panel).getLabel().setFont(devValueFont); - ((DeviceValuePanel)panel).getLabel().setVerticalAlignment(SwingConstants.TOP); - ((DeviceValuePanel)panel).getLabel().setVerticalTextPosition(SwingConstants.TOP); - } - - deviceValuePanel1.getLabel().setVerticalAlignment(SwingConstants.TOP); - deviceValuePanel1.getLabel().setFont(deviceValuePanel1.getFont().deriveFont(8.0f)); + } parameterControls = Arr.append(parameterControls, SwingUtils.getComponentsByType(panelRoi, JButton.class)); this.parameterControls = parameterControls; setPersistedComponents(parameterControls); @@ -146,7 +116,6 @@ public class Eiger extends Panel { } }); modelRegions = (DefaultTableModel) tableRegions.getModel(); - updateRsync(); } //Overridable callbacks @@ -155,30 +124,7 @@ public class Eiger extends Panel { try { textNorm.setText(String.valueOf(getSetting("NORM_FILE"))); - removeNorm(); - - String id = getSetting("ID"); - Double en = Double.valueOf(getSetting("ENERGY")); - String pol1 = getSetting("POL_ID_1"); - Double alp1 = Double.valueOf(getSetting("ALPHA_ID_1")); - String har1 = getSetting("HARMONIC_ID_1"); - Double off1 = Double.valueOf(getSetting("OFFSET_ID_1")); - String pol2 = getSetting("POL_ID_2"); - Double alp2 = Double.valueOf(getSetting("ALPHA_ID_2")); - String har2 = getSetting("HARMONIC_ID_2"); - Double off2 = Double.valueOf(getSetting("OFFSET_ID_2")); - comboID.setSelectedItem(id); - spinnerImgEng.setValue(en); - comboPol1.setSelectedItem(pol1); - spinnerAlp1.setValue(alp1); - spinnerHar1.setValue(har1); - spinnerOff1.setValue(off1); - comboPol2.setSelectedItem(pol2); - spinnerAlp2.setValue(alp2); - spinnerHar2.setValue(har2); - spinnerOff2.setValue(off2); - - checkAutoValve.setSelected(String.valueOf(getSetting("AUTO_SWITCH_VALVE")).equalsIgnoreCase("true")); + removeNorm(); try{ spinnerOutliersThreshold.setValue(Integer.valueOf(getSetting("OUTLIERS_THRESHOLD"))); } catch (IOException ex) { @@ -192,8 +138,6 @@ public class Eiger extends Panel { @Override public void onStateChange(State state, State former) { - textDataPath.setText(getContext().getConfig().dataPath); - spinnerSeq.setValue(getContext().getFileSequentialNumber()); updateControls(); } @@ -208,16 +152,6 @@ public class Eiger extends Panel { void updateControls() { boolean editable = getState().isInitialized() && !getState().isProcessing(); - boolean is_id1 = comboID.getSelectedIndex() != 1; - boolean is_id2 = comboID.getSelectedIndex() != 0; - textDataPath.setEnabled(editable); - spinnerSeq.setEnabled(editable); - buttonDefaultPath.setEnabled(editable && !textDataPath.getText().equals(DEFAULT_PATH)); - buttonSetPath.setEnabled(editable && !textDataPath.getText().equals(getContext().getConfig().dataPath)); - buttonUndoPath.setEnabled(editable && !textDataPath.getText().equals(getContext().getConfig().dataPath)); - buttonSetSeq.setEnabled(editable && !spinnerSeq.getValue().equals(getContext().getFileSequentialNumber())); - buttonUndoSeq.setEnabled(editable && !spinnerSeq.getValue().equals(getContext().getFileSequentialNumber())); - buttonApply.setEnabled(editable); for (Component c : parameterControls) { c.setEnabled(editable); @@ -227,14 +161,6 @@ public class Eiger extends Panel { comboSwitch.setEnabled(comboImgMethod.getSelectedItem() == ImgMethod.Two_Pol.toString()); spinnerImgEng1.setEnabled(comboImgMethod.getSelectedItem() == ImgMethod.Two_Energies.toString()); spinnerImgEng2.setEnabled(comboImgMethod.getSelectedItem() == ImgMethod.Two_Energies.toString()); - spinnerAlp1.setEnabled(is_id1 && (comboPol1.getSelectedItem() == Polarization.Lin.toString())); - spinnerAlp2.setEnabled(is_id2 & (comboPol2.getSelectedItem() == Polarization.Lin.toString())); - spinnerHar1.setEnabled(is_id1 ); - spinnerHar2.setEnabled(is_id2 ); - spinnerOff1.setEnabled(is_id1 ); - spinnerOff2.setEnabled(is_id2 ); - comboPol1.setEnabled(is_id1 ); - comboPol2.setEnabled(is_id2 ); } buttonImgStart.setEnabled(getState() == State.Ready); @@ -300,18 +226,6 @@ public class Eiger extends Panel { rendererRoi.abortSelection(); } - void setBeamlineArgs(HashMap args) { - args.put("ID", comboID.getSelectedItem()); - args.put("ENERGY", spinnerImgEng.getValue()); - args.put("POL_ID_1", comboPol1.getSelectedItem()); - args.put("ALPHA_ID_1", spinnerAlp1.getValue()); - args.put("HARMONIC_ID_1", spinnerHar1.getValue()); - args.put("OFFSET_ID_1", spinnerOff1.getValue()); - args.put("POL_ID_2", comboPol2.getSelectedItem()); - args.put("ALPHA_ID_2", spinnerAlp2.getValue()); - args.put("HARMONIC_ID_2", spinnerHar2.getValue()); - args.put("OFFSET_ID_2", spinnerOff2.getValue()); - } void run2Images() throws Context.ContextStateException { @@ -371,19 +285,7 @@ public class Eiger extends Panel { return t; }); } - - void applyBeamline() throws Context.ContextStateException { - HashMap args = new HashMap(); - setBeamlineArgs(args); - - runAsync("templates/SetupBeamline", args).handle((ret, t) -> { - if ((t != null) && (!getContext().isAborted())) { - showException((Exception) t); - } - return t; - }); - } void removeNorm(){ try{ @@ -424,87 +326,12 @@ public class Eiger extends Panel { }); } } - boolean updatingRsync; - void updateRsync(){ - try{ - updatingRsync = true; - String user = null; - String path = null; - try { - user = getSetting("RSYNC_USER"); - path = getSetting("RSYNC_PATH"); - } catch (IOException ex) { - } - boolean enabled = ((user != null) && (!user.trim().isEmpty())); - textRsyncUser.setText(enabled ? user : ""); - textRsyncPath.setText((enabled && (path != null)) ? path : ""); - textRsyncUser.setEnabled(!enabled); - textRsyncPath.setEnabled(!enabled); - checkRsyncEnable.setSelected(enabled); - } finally{ - updatingRsync = false; - } - } - @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { jTabbedPane1 = new javax.swing.JTabbedPane(); - jPanel5 = new javax.swing.JPanel(); - panelDataFile = new javax.swing.JPanel(); - buttonSetSeq = new javax.swing.JButton(); - buttonUndoSeq = new javax.swing.JButton(); - buttonDefaultPath = new javax.swing.JButton(); - buttonSetPath = new javax.swing.JButton(); - buttonUndoPath = new javax.swing.JButton(); - jLabel2 = new javax.swing.JLabel(); - spinnerSeq = new javax.swing.JSpinner(); - textDataPath = new javax.swing.JTextField(); - jLabel1 = new javax.swing.JLabel(); - panelBeamline = new javax.swing.JPanel(); - jLabel3 = new javax.swing.JLabel(); - comboID = new javax.swing.JComboBox<>(); - jPanel7 = new javax.swing.JPanel(); - jLabel5 = new javax.swing.JLabel(); - comboPol1 = new javax.swing.JComboBox<>(); - jLabel6 = new javax.swing.JLabel(); - spinnerAlp1 = new javax.swing.JSpinner(); - jLabel7 = new javax.swing.JLabel(); - spinnerHar1 = new javax.swing.JSpinner(); - jLabel8 = new javax.swing.JLabel(); - spinnerOff1 = new javax.swing.JSpinner(); - deviceValuePanel2 = new ch.psi.pshell.swing.DeviceValuePanel(); - deviceValuePanel3 = new ch.psi.pshell.swing.DeviceValuePanel(); - deviceValuePanel4 = new ch.psi.pshell.swing.DeviceValuePanel(); - deviceValuePanel5 = new ch.psi.pshell.swing.DeviceValuePanel(); - jPanel9 = new javax.swing.JPanel(); - jLabel13 = new javax.swing.JLabel(); - comboPol2 = new javax.swing.JComboBox<>(); - jLabel14 = new javax.swing.JLabel(); - spinnerAlp2 = new javax.swing.JSpinner(); - jLabel15 = new javax.swing.JLabel(); - spinnerHar2 = new javax.swing.JSpinner(); - jLabel16 = new javax.swing.JLabel(); - spinnerOff2 = new javax.swing.JSpinner(); - deviceValuePanel6 = new ch.psi.pshell.swing.DeviceValuePanel(); - deviceValuePanel7 = new ch.psi.pshell.swing.DeviceValuePanel(); - deviceValuePanel8 = new ch.psi.pshell.swing.DeviceValuePanel(); - deviceValuePanel9 = new ch.psi.pshell.swing.DeviceValuePanel(); - buttonApply = new javax.swing.JButton(); - jLabel27 = new javax.swing.JLabel(); - spinnerImgEng = new javax.swing.JSpinner(); - checkAutoValve = new javax.swing.JCheckBox(); - deviceValuePanel1 = new ch.psi.pshell.swing.DeviceValuePanel(); - deviceValuePanel10 = new ch.psi.pshell.swing.DeviceValuePanel(); - jPanel6 = new javax.swing.JPanel(); - jLabel10 = new javax.swing.JLabel(); - textRsyncUser = new javax.swing.JTextField(); - jLabel18 = new javax.swing.JLabel(); - textRsyncPath = new javax.swing.JTextField(); - checkRsyncEnable = new javax.swing.JCheckBox(); - buttonSetFolder = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); panelNorm = new javax.swing.JPanel(); buttonSetNorm = new javax.swing.JButton(); @@ -577,498 +404,6 @@ public class Eiger extends Panel { buttonSpecStart = new javax.swing.JButton(); buttonSpecAbort = new javax.swing.JButton(); - panelDataFile.setBorder(javax.swing.BorderFactory.createTitledBorder("Data File")); - - buttonSetSeq.setText("Save"); - buttonSetSeq.setEnabled(false); - buttonSetSeq.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonSetSeqActionPerformed(evt); - } - }); - - buttonUndoSeq.setText("Undo"); - buttonUndoSeq.setEnabled(false); - buttonUndoSeq.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonUndoSeqActionPerformed(evt); - } - }); - - buttonDefaultPath.setText("Default"); - buttonDefaultPath.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonDefaultPathActionPerformed(evt); - } - }); - - buttonSetPath.setText("Save"); - buttonSetPath.setEnabled(false); - buttonSetPath.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonSetPathActionPerformed(evt); - } - }); - - buttonUndoPath.setText("Undo"); - buttonUndoPath.setEnabled(false); - buttonUndoPath.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonUndoPathActionPerformed(evt); - } - }); - - jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jLabel2.setText("Sequential:"); - - spinnerSeq.setModel(new javax.swing.SpinnerNumberModel(0, 0, 99999, 1)); - spinnerSeq.addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent evt) { - spinnerSeqStateChanged(evt); - } - }); - - textDataPath.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyTyped(java.awt.event.KeyEvent evt) { - textDataPathKeyTyped(evt); - } - public void keyReleased(java.awt.event.KeyEvent evt) { - textDataPathKeyReleased(evt); - } - }); - - jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jLabel1.setText("Name Pattern:"); - - javax.swing.GroupLayout panelDataFileLayout = new javax.swing.GroupLayout(panelDataFile); - panelDataFile.setLayout(panelDataFileLayout); - panelDataFileLayout.setHorizontalGroup( - panelDataFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelDataFileLayout.createSequentialGroup() - .addContainerGap() - .addGroup(panelDataFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelDataFileLayout.createSequentialGroup() - .addComponent(jLabel2) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(spinnerSeq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonSetSeq) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonUndoSeq)) - .addGroup(panelDataFileLayout.createSequentialGroup() - .addComponent(jLabel1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(textDataPath, javax.swing.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelDataFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(panelDataFileLayout.createSequentialGroup() - .addComponent(buttonSetPath) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonUndoPath)) - .addComponent(buttonDefaultPath)) - .addContainerGap()) - ); - - panelDataFileLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonDefaultPath, buttonSetPath, buttonUndoPath}); - - panelDataFileLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2}); - - panelDataFileLayout.setVerticalGroup( - panelDataFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelDataFileLayout.createSequentialGroup() - .addContainerGap() - .addGroup(panelDataFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel1) - .addComponent(textDataPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonSetPath) - .addComponent(buttonUndoPath)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelDataFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel2) - .addComponent(spinnerSeq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonSetSeq) - .addComponent(buttonUndoSeq) - .addComponent(buttonDefaultPath)) - .addContainerGap()) - ); - - panelBeamline.setBorder(javax.swing.BorderFactory.createTitledBorder("Beamline")); - - jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jLabel3.setText("ID:"); - - comboID.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); - comboID.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - comboIDActionPerformed(evt); - } - }); - - jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("ID1")); - - jLabel5.setText("Mode:"); - - comboPol1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); - comboPol1.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - comboPol1ActionPerformed(evt); - } - }); - - jLabel6.setText("Alpha:"); - - spinnerAlp1.setModel(new javax.swing.SpinnerNumberModel(0.0d, -360.0d, 360.0d, 1.0d)); - - jLabel7.setText("Harmonic:"); - - spinnerHar1.setModel(new javax.swing.SpinnerListModel(new String[] {"1", "3"})); - - jLabel8.setText("Offset:"); - - spinnerOff1.setModel(new javax.swing.SpinnerNumberModel(0.0d, -10.0d, 10.0d, 1.0d)); - - deviceValuePanel2.setDeviceName("id1_alpha"); - - deviceValuePanel3.setDeviceName("id1_pol"); - - deviceValuePanel4.setDeviceName("id1_harmonic"); - - deviceValuePanel5.setDeviceName("id1_offset"); - - javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); - jPanel7.setLayout(jPanel7Layout); - jPanel7Layout.setHorizontalGroup( - jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel7Layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel7Layout.createSequentialGroup() - .addComponent(spinnerAlp1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(deviceValuePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(jPanel7Layout.createSequentialGroup() - .addComponent(spinnerHar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(deviceValuePanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(jPanel7Layout.createSequentialGroup() - .addComponent(comboPol1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(deviceValuePanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(jPanel7Layout.createSequentialGroup() - .addComponent(spinnerOff1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(deviceValuePanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - jPanel7Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboPol1, spinnerAlp1, spinnerHar1, spinnerOff1}); - - jPanel7Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {deviceValuePanel2, deviceValuePanel3, deviceValuePanel4, deviceValuePanel5}); - - jPanel7Layout.setVerticalGroup( - jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel7Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(deviceValuePanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(comboPol1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel5)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(jLabel6) - .addComponent(spinnerAlp1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(deviceValuePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(jLabel7) - .addComponent(spinnerHar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(deviceValuePanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(jLabel8) - .addComponent(spinnerOff1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(deviceValuePanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - jPanel7Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {comboPol1, deviceValuePanel3}); - - jPanel7Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {deviceValuePanel2, spinnerAlp1}); - - jPanel7Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {deviceValuePanel4, spinnerHar1}); - - jPanel7Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {deviceValuePanel5, spinnerOff1}); - - jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder("ID2")); - - jLabel13.setText("Mode:"); - - comboPol2.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); - comboPol2.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - comboPol2ActionPerformed(evt); - } - }); - - jLabel14.setText("Alpha:"); - - spinnerAlp2.setModel(new javax.swing.SpinnerNumberModel(0.0d, -360.0d, 360.0d, 1.0d)); - - jLabel15.setText("Harmonic:"); - - spinnerHar2.setModel(new javax.swing.SpinnerListModel(new String[] {"1", "3"})); - - jLabel16.setText("Offset:"); - - spinnerOff2.setModel(new javax.swing.SpinnerNumberModel(0.0d, -10.0d, 10.0d, 1.0d)); - - deviceValuePanel6.setDeviceName("id2_pol"); - - deviceValuePanel7.setDeviceName("id2_alpha"); - - deviceValuePanel8.setDeviceName("id2_harmonic"); - - deviceValuePanel9.setDeviceName("id2_offset"); - - javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9); - jPanel9.setLayout(jPanel9Layout); - jPanel9Layout.setHorizontalGroup( - jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel9Layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel15, javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel16, javax.swing.GroupLayout.Alignment.TRAILING)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(spinnerOff2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(spinnerHar2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(spinnerAlp2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(comboPol2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(deviceValuePanel6, javax.swing.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE) - .addComponent(deviceValuePanel7, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) - .addComponent(deviceValuePanel8, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) - .addComponent(deviceValuePanel9, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - jPanel9Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboPol2, spinnerAlp2, spinnerHar2, spinnerOff2}); - - jPanel9Layout.setVerticalGroup( - jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel9Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(deviceValuePanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(comboPol2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel13)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(deviceValuePanel7, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(spinnerAlp2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel14)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(jLabel15) - .addComponent(spinnerHar2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(deviceValuePanel8, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) - .addComponent(jLabel16) - .addComponent(spinnerOff2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(deviceValuePanel9, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - jPanel9Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {comboPol2, deviceValuePanel6}); - - jPanel9Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {deviceValuePanel7, spinnerAlp2}); - - jPanel9Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {deviceValuePanel8, spinnerHar2}); - - jPanel9Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {deviceValuePanel9, spinnerOff2}); - - buttonApply.setText("Apply"); - buttonApply.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonApplyActionPerformed(evt); - } - }); - - jLabel27.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jLabel27.setText("Energy:"); - - spinnerImgEng.setModel(new javax.swing.SpinnerNumberModel(1000.0d, 90.0d, 2520.0d, 1.0d)); - - checkAutoValve.setText("Auto Switch Valve"); - checkAutoValve.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - checkAutoValveActionPerformed(evt); - } - }); - - deviceValuePanel1.setDeviceName("energy"); - - deviceValuePanel10.setDeviceName("energy_opt_desc"); - - javax.swing.GroupLayout panelBeamlineLayout = new javax.swing.GroupLayout(panelBeamline); - panelBeamline.setLayout(panelBeamlineLayout); - panelBeamlineLayout.setHorizontalGroup( - panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelBeamlineLayout.createSequentialGroup() - .addContainerGap() - .addGroup(panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(checkAutoValve) - .addGroup(panelBeamlineLayout.createSequentialGroup() - .addComponent(jLabel27) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(deviceValuePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) - .addComponent(spinnerImgEng))) - .addGroup(panelBeamlineLayout.createSequentialGroup() - .addComponent(jLabel3) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(comboID, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(deviceValuePanel10, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGroup(panelBeamlineLayout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonApply, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, Short.MAX_VALUE)) - ); - - panelBeamlineLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel27, jLabel3}); - - panelBeamlineLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboID, spinnerImgEng}); - - panelBeamlineLayout.setVerticalGroup( - panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelBeamlineLayout.createSequentialGroup() - .addGroup(panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelBeamlineLayout.createSequentialGroup() - .addContainerGap() - .addGroup(panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addGroup(panelBeamlineLayout.createSequentialGroup() - .addGap(30, 30, 30) - .addGroup(panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(comboID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel3)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(deviceValuePanel10, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(panelBeamlineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel27) - .addComponent(spinnerImgEng, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(deviceValuePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(checkAutoValve))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(buttonApply) - .addContainerGap()) - ); - - panelBeamlineLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {deviceValuePanel1, spinnerImgEng}); - - panelBeamlineLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {comboID, deviceValuePanel10}); - - jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Data Transfer")); - - jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jLabel10.setText("User:"); - - jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jLabel18.setText("Folder:"); - - checkRsyncEnable.setText("Enable"); - checkRsyncEnable.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - checkRsyncEnableActionPerformed(evt); - } - }); - - buttonSetFolder.setText("Set"); - buttonSetFolder.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - buttonSetFolderActionPerformed(evt); - } - }); - - javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); - jPanel6.setLayout(jPanel6Layout); - jPanel6Layout.setHorizontalGroup( - jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup() - .addContainerGap() - .addComponent(checkRsyncEnable) - .addGap(83, 83, 83) - .addComponent(jLabel10) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(textRsyncUser, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jLabel18) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(textRsyncPath) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonSetFolder) - .addContainerGap()) - ); - jPanel6Layout.setVerticalGroup( - jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel6Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel10) - .addComponent(textRsyncUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel18) - .addComponent(textRsyncPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(checkRsyncEnable) - .addComponent(buttonSetFolder)) - .addContainerGap()) - ); - - javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); - jPanel5.setLayout(jPanel5Layout); - jPanel5Layout.setHorizontalGroup( - jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel5Layout.createSequentialGroup() - .addGap(10, 10, 10) - .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(panelDataFile, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(panelBeamline, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addContainerGap()) - ); - jPanel5Layout.setVerticalGroup( - jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup() - .addContainerGap() - .addComponent(panelDataFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(panelBeamline, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - ); - - jTabbedPane1.addTab("Config", jPanel5); - panelNorm.setBorder(javax.swing.BorderFactory.createTitledBorder("Normalization")); buttonSetNorm.setText("Select"); @@ -1528,9 +863,9 @@ public class Eiger extends Panel { .addComponent(comboSwitch, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(deviceValuePanel11, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(deviceValuePanel12, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) - .addGap(18, 20, Short.MAX_VALUE) + .addGap(18, 18, Short.MAX_VALUE) .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGap(18, 21, Short.MAX_VALUE) + .addGap(18, 18, Short.MAX_VALUE) .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); @@ -1798,7 +1133,7 @@ public class Eiger extends Panel { this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 691, Short.MAX_VALUE) + .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 691, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -1808,24 +1143,6 @@ public class Eiger extends Panel { ); }// //GEN-END:initComponents - private void buttonSetPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetPathActionPerformed - try { - getContext().getConfig().dataPath = textDataPath.getText(); - getContext().getConfig().save(); - updateControls(); - } catch (Exception ex) { - showException(ex); - } - }//GEN-LAST:event_buttonSetPathActionPerformed - - private void textDataPathKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textDataPathKeyTyped - - }//GEN-LAST:event_textDataPathKeyTyped - - private void textDataPathKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textDataPathKeyReleased - updateControls(); - }//GEN-LAST:event_textDataPathKeyReleased - private void buttonImgStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonImgStartActionPerformed try { run2Images(); @@ -1897,50 +1214,6 @@ public class Eiger extends Panel { } }//GEN-LAST:event_buttonRemoveActionPerformed - private void buttonApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonApplyActionPerformed - try { - applyBeamline(); - } catch (Exception ex) { - showException(ex); - } - }//GEN-LAST:event_buttonApplyActionPerformed - - private void spinnerSeqStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerSeqStateChanged - updateControls(); - }//GEN-LAST:event_spinnerSeqStateChanged - - private void buttonUndoSeqActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUndoSeqActionPerformed - try { - spinnerSeq.setValue(getContext().getFileSequentialNumber()); - updateControls(); - } catch (Exception ex) { - showException(ex); - } - }//GEN-LAST:event_buttonUndoSeqActionPerformed - - private void buttonSetSeqActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetSeqActionPerformed - try { - getContext().setFileSequentialNumber(((Number) spinnerSeq.getValue()).intValue()); - updateControls(); - } catch (Exception ex) { - showException(ex); - } - }//GEN-LAST:event_buttonSetSeqActionPerformed - - private void buttonUndoPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUndoPathActionPerformed - try { - textDataPath.setText(getContext().getConfig().dataPath); - updateControls(); - } catch (Exception ex) { - showException(ex); - } - }//GEN-LAST:event_buttonUndoPathActionPerformed - - private void buttonDefaultPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDefaultPathActionPerformed - textDataPath.setText(DEFAULT_PATH); - updateControls(); - }//GEN-LAST:event_buttonDefaultPathActionPerformed - private void buttonSetNormActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetNormActionPerformed try{ JFileChooser chooser = new JFileChooser(getContext().getSetup().expandPath(getContext().getConfig().dataPath)); @@ -1983,14 +1256,6 @@ public class Eiger extends Panel { } }//GEN-LAST:event_buttonShowNormActionPerformed - private void checkAutoValveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkAutoValveActionPerformed - try{ - setSetting("AUTO_SWITCH_VALVE", checkAutoValve.isSelected()); - } catch (Exception ex){ - showException (ex); - } - }//GEN-LAST:event_checkAutoValveActionPerformed - private void textSelectOutliersMaskActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textSelectOutliersMaskActionPerformed try{ JFileChooser chooser = new JFileChooser(getContext().getSetup().expandPath(getContext().getConfig().dataPath)); @@ -2033,18 +1298,6 @@ public class Eiger extends Panel { } }//GEN-LAST:event_spinnerOutliersThresholdStateChanged - private void comboPol1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboPol1ActionPerformed - updateControls(); - }//GEN-LAST:event_comboPol1ActionPerformed - - private void comboPol2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboPol2ActionPerformed - updateControls(); - }//GEN-LAST:event_comboPol2ActionPerformed - - private void comboIDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboIDActionPerformed - updateControls(); - }//GEN-LAST:event_comboIDActionPerformed - private void buttonMeasurementsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMeasurementsActionPerformed try{ evalAsync(buttonMeasurements.isSelected() ? "start_measurements()" : "stop_measurements()"); @@ -2053,112 +1306,33 @@ public class Eiger extends Panel { } }//GEN-LAST:event_buttonMeasurementsActionPerformed - private void checkRsyncEnableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkRsyncEnableActionPerformed - if (!updatingRsync){ - try { - setSetting("RSYNC_USER", ""); - //setSetting("RSYNC_PATH", ""); - } catch (IOException ex) { - Logger.getLogger(Eiger.class.getName()).log(Level.SEVERE, null, ex); - } - if (checkRsyncEnable.isSelected()){ - String user = textRsyncUser.getText().trim(); - String path = textRsyncPath.getText().trim(); - if (!user.isEmpty()){ - try { - //this.eval("authorize_user('" + user +"', aux_file = '/scratch/.rsync.tmp')"); - this.eval("authorize_user('" + user +"')"); - setSetting("RSYNC_USER", user); - setSetting("RSYNC_PATH", path); - } catch (Exception ex) { - try { - this.evalAsync("remove_user_key()"); - } catch (Exception e) { - Logger.getLogger(Eiger.class.getName()).log(Level.SEVERE, null, e); - } - showException(ex); - } - } - } else { - try { - this.evalAsync("remove_user_key()"); - } catch (Exception e) { - Logger.getLogger(Eiger.class.getName()).log(Level.SEVERE, null, e); - } - } - updateRsync(); - } - }//GEN-LAST:event_checkRsyncEnableActionPerformed - - private void buttonSetFolderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetFolderActionPerformed - try { - String ret = SwingUtils.getString(this, "Enter destination path:", String.valueOf(getSetting("RSYNC_PATH"))); - if ((ret != null) && (!ret.trim().isEmpty())){ - setSetting("RSYNC_PATH", ret.trim()); - updateRsync(); - } - } catch (IOException ex) { - showException(ex); - } - }//GEN-LAST:event_buttonSetFolderActionPerformed - // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton buttonAdd; - private javax.swing.JButton buttonApply; - private javax.swing.JButton buttonDefaultPath; private javax.swing.JButton buttonImgAbort; private javax.swing.JButton buttonImgStart; private javax.swing.JToggleButton buttonMeasurements; private javax.swing.JButton buttonRemove; private javax.swing.JButton buttonRoiAdd; private javax.swing.JButton buttonRoiRemove; - private javax.swing.JButton buttonSetFolder; private javax.swing.JButton buttonSetNorm; - private javax.swing.JButton buttonSetPath; - private javax.swing.JButton buttonSetSeq; private javax.swing.JButton buttonShowDetectorPanel; private javax.swing.JToggleButton buttonShowNorm; private javax.swing.JButton buttonSpecAbort; private javax.swing.JButton buttonSpecStart; private javax.swing.JButton buttonTriggerDetector; - private javax.swing.JButton buttonUndoPath; - private javax.swing.JButton buttonUndoSeq; - private javax.swing.JCheckBox checkAutoValve; private javax.swing.JCheckBox checkImgAutosave; - private javax.swing.JCheckBox checkRsyncEnable; private javax.swing.JCheckBox checkSpecSaveImages; private javax.swing.JCheckBox checkSpecSaveSpectrum; private javax.swing.JCheckBox checkSpecSwitchPol; private javax.swing.JCheckBox checkSpecWithI0; - private javax.swing.JComboBox comboID; private javax.swing.JComboBox comboImgMethod; - private javax.swing.JComboBox comboPol1; - private javax.swing.JComboBox comboPol2; private javax.swing.JComboBox comboSwitch; - private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel1; - private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel10; private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel11; private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel12; - private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel2; - private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel3; - private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel4; - private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel5; - private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel6; - private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel7; - private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel8; - private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel9; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; - private javax.swing.JLabel jLabel13; - private javax.swing.JLabel jLabel14; - private javax.swing.JLabel jLabel15; - private javax.swing.JLabel jLabel16; private javax.swing.JLabel jLabel17; - private javax.swing.JLabel jLabel18; private javax.swing.JLabel jLabel19; - private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel20; private javax.swing.JLabel jLabel21; private javax.swing.JLabel jLabel22; @@ -2166,67 +1340,44 @@ public class Eiger extends Panel { private javax.swing.JLabel jLabel24; private javax.swing.JLabel jLabel25; private javax.swing.JLabel jLabel26; - private javax.swing.JLabel jLabel27; private javax.swing.JLabel jLabel28; private javax.swing.JLabel jLabel29; - private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel30; private javax.swing.JLabel jLabel31; private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel5; - private javax.swing.JLabel jLabel6; - private javax.swing.JLabel jLabel7; - private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel10; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; - private javax.swing.JPanel jPanel5; - private javax.swing.JPanel jPanel6; - private javax.swing.JPanel jPanel7; private javax.swing.JPanel jPanel8; - private javax.swing.JPanel jPanel9; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JTabbedPane jTabbedPane1; private javax.swing.JLabel labelSwitching; - private javax.swing.JPanel panelBeamline; - private javax.swing.JPanel panelDataFile; private javax.swing.JPanel panelImgControls; private javax.swing.JPanel panelNorm; private javax.swing.JPanel panelNorm1; private javax.swing.JPanel panelRoi; private javax.swing.JPanel panelSpectrum; private ch.psi.pshell.imaging.Renderer rendererRoi; - private javax.swing.JSpinner spinnerAlp1; - private javax.swing.JSpinner spinnerAlp2; - private javax.swing.JSpinner spinnerHar1; - private javax.swing.JSpinner spinnerHar2; private javax.swing.JSpinner spinnerImgAvg1; private javax.swing.JSpinner spinnerImgAvg2; - private javax.swing.JSpinner spinnerImgEng; private javax.swing.JSpinner spinnerImgEng1; private javax.swing.JSpinner spinnerImgEng2; private javax.swing.JSpinner spinnerImgExp1; private javax.swing.JSpinner spinnerImgExp2; private javax.swing.JSpinner spinnerImgMeasurements; - private javax.swing.JSpinner spinnerOff1; - private javax.swing.JSpinner spinnerOff2; private javax.swing.JSpinner spinnerOutliersThreshold; - private javax.swing.JSpinner spinnerSeq; private javax.swing.JSpinner spinnerSpecAvg; private javax.swing.JSpinner spinnerSpecExp; private javax.swing.JSpinner spinnerSpecScans; private javax.swing.JTable tableRegions; private javax.swing.JTable tableRoi; private javax.swing.JButton textClearOutliersMask; - private javax.swing.JTextField textDataPath; private javax.swing.JTextField textNorm; private javax.swing.JTextField textOutliersMask; - private javax.swing.JTextField textRsyncPath; - private javax.swing.JTextField textRsyncUser; private javax.swing.JButton textSelectOutliersMask; // End of variables declaration//GEN-END:variables } diff --git a/plugins/EnergyScan.java b/plugins/EnergyScan.java index 2e759a1..799d45b 100644 --- a/plugins/EnergyScan.java +++ b/plugins/EnergyScan.java @@ -729,7 +729,7 @@ public class EnergyScan extends Panel { try { abort(); } catch (InterruptedException ex) { - Logger.getLogger(EnergyScan.class.getName()).log(Level.SEVERE, null, ex); + getLogger().log(Level.SEVERE, null, ex); } }//GEN-LAST:event_buttonAbortActionPerformed diff --git a/plugins/EnergyScanBase.form b/plugins/EnergyScanBase.form index 2e7c82a..fc606c1 100644 --- a/plugins/EnergyScanBase.form +++ b/plugins/EnergyScanBase.form @@ -28,13 +28,8 @@ - - - - - - - + + diff --git a/plugins/EnergyScanBase.java b/plugins/EnergyScanBase.java index 5341a88..3b41308 100644 --- a/plugins/EnergyScanBase.java +++ b/plugins/EnergyScanBase.java @@ -412,7 +412,7 @@ public class EnergyScanBase extends Panel { try { abort(); } catch (InterruptedException ex) { - Logger.getLogger(EnergyScan.class.getName()).log(Level.SEVERE, null, ex); + getLogger().log(Level.SEVERE, null, ex); } }//GEN-LAST:event_buttonAbortActionPerformed diff --git a/plugins/EnergyScan_TBT.java b/plugins/EnergyScan_TBT.java index 89f2fcd..3ef05e0 100644 --- a/plugins/EnergyScan_TBT.java +++ b/plugins/EnergyScan_TBT.java @@ -645,7 +645,7 @@ public class EnergyScan_TBT extends Panel { try { abort(); } catch (InterruptedException ex) { - Logger.getLogger(EnergyScan_TBT.class.getName()).log(Level.SEVERE, null, ex); + getLogger().log(Level.SEVERE, null, ex); } }//GEN-LAST:event_buttonAbortActionPerformed diff --git a/plugins/Experiment.form b/plugins/Experiment.form index 451cabe..3b7684a 100644 --- a/plugins/Experiment.form +++ b/plugins/Experiment.form @@ -17,31 +17,35 @@ - - + + + - - - - + + + + + + + - - - + + + - + @@ -60,62 +64,60 @@ - + + + + + + + + + + + + + - - - - - + - - - - - - + + - + - - - - - + - - - - - - - - - - - - - - + - - + + + + + + + + + + + + + + - @@ -181,95 +183,11 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -296,5 +214,318 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/Experiment.java b/plugins/Experiment.java index c62a30e..29aeb60 100644 --- a/plugins/Experiment.java +++ b/plugins/Experiment.java @@ -1,5 +1,7 @@ + import ch.psi.pshell.ui.Panel; import ch.psi.utils.State; +import ch.psi.utils.swing.SwingUtils; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; @@ -10,95 +12,134 @@ import javax.swing.SwingUtilities; */ public class Experiment extends Panel { + //static String DEFAULT_PATH = "{data}/{year}_{month}/{date}_{seq}%03d"; + static String DEFAULT_PATH = "{data}/{year}_{month}/{date}/{date}_{seq}%04d_{name}"; + public Experiment() { initComponents(); + updateRsync(); } //Overridable callbacks @Override public void onInitialize(int runCount) { - SwingUtilities.invokeLater(()->{ + SwingUtilities.invokeLater(() -> { undo(); - }); + }); + textNamePattern.setText(getContext().getConfig().dataPath); } @Override public void onStateChange(State state, State former) { - + updateControls(); } @Override public void onExecutedFile(String fileName, Object result) { } - //Callback to perform update - in event thread @Override protected void doUpdate() { } - - void undo(){ + void undo() { try { - textDataRoot.setText(getContext().getSetup().expandPath("{data}")); - textDataPath.setText(getContext().getConfig().dataPath); - + textDataPath.setText(getContext().getSetup().expandPath(getContext().getConfig().dataPath)); textPGroup.setText(getContext().getSetting("pgroup") == null ? "" : getContext().getSetting("pgroup")); textProposal.setText(getContext().getSetting("proposal") == null ? "" : getContext().getSetting("proposal")); textProposer.setText(getContext().getSetting("proposer") == null ? "" : getContext().getSetting("proposer")); textSamples.setText(getContext().getSetting("sample") == null ? "" : getContext().getSetting("sample")); textAuthors.setText(getContext().getSetting("authors") == null ? "" : getContext().getSetting("authors").replace("|", "\n")); - textPrefix.setText(getContext().getSetting("prefix") == null ? "" : getContext().getSetting("prefix")); } catch (Exception ex) { - Logger.getLogger(Experiment.class.getName()).log(Level.SEVERE, null, ex); + getLogger().log(Level.SEVERE, null, ex); } - + } - - void apply(){ - + + void apply() { + try { String proposal = textProposal.getText().trim(); String pgroup = textPGroup.getText().trim(); String proposer = textProposer.getText().trim(); String samples = textSamples.getText().trim(); - String authors = textAuthors.getText().trim().replace("\n","|"); - String prefix = textPrefix.getText().trim(); - + String authors = textAuthors.getText().trim().replace("\n", "|"); + getContext().setSetting("pgroup", pgroup); getContext().setSetting("proposal", proposal); getContext().setSetting("proposer", proposer); getContext().setSetting("sample", samples); getContext().setSetting("authors", authors); - getContext().setSetting("prefix", prefix); - - getContext().getConfig().dataPath = "{data}/{year}/{month}/" + - (proposer.isEmpty() ? "bl-dev" : proposer) + "/" + - (prefix.isEmpty() ? "pshell" : prefix) + "-{date}-{time}-{name}"; - getContext().getConfig().save(); - + } catch (Exception ex) { - Logger.getLogger(Experiment.class.getName()).log(Level.SEVERE, null, ex); + getLogger().log(Level.SEVERE, null, ex); } undo(); } - - void reset(){ - + + void reset() { + try { textProposal.setText(""); textPGroup.setText(""); textProposer.setText(""); textSamples.setText(""); textAuthors.setText(""); - textPrefix.setText(""); - apply(); + apply(); } catch (Exception ex) { - Logger.getLogger(Experiment.class.getName()).log(Level.SEVERE, null, ex); + getLogger().log(Level.SEVERE, null, ex); } undo(); } - + + boolean updatingRsync; + + void updateRsync() { + try { + updatingRsync = true; + String user = null; + String host = null; + String path = null; + String remove = null; + try { + user = getSetting("RSYNC_USER"); + host = getSetting("RSYNC_HOST"); + path = getSetting("RSYNC_PATH"); + remove = getSetting("RSYNC_DEL"); + } catch (IOException ex) { + } + boolean enabled = ((user != null) && (!user.trim().isEmpty())); + textRsyncUser.setText(enabled ? user : ""); + textRsyncHost.setText(enabled ? host : ""); + textRsyncPath.setText((enabled && (path != null)) ? path : ""); + checkRsyncRemove.setSelected((remove==null) ? false : remove.toLowerCase().equals("true")); + checkRsyncEnable.setSelected(enabled); + textRsyncUser.setEnabled(!enabled); + textRsyncHost.setEnabled(!enabled); + //textRsyncPath.setEnabled(!enabled); + buttonUndoFolder.setEnabled(false); + buttonSetFolder.setEnabled(false); + + } finally { + updatingRsync = false; + } + } + + void updateControls() { + boolean editable = getState().isInitialized() && !getState().isProcessing(); + textNamePattern.setEnabled(editable); + spinnerSeq.setEnabled(editable); + buttonDefaultPath.setEnabled(editable && !textNamePattern.getText().equals(DEFAULT_PATH)); + buttonSetPath.setEnabled(editable && !textNamePattern.getText().equals(getContext().getConfig().dataPath)); + buttonUndoPath.setEnabled(editable && !textNamePattern.getText().equals(getContext().getConfig().dataPath)); + buttonSetSeq.setEnabled(editable && !spinnerSeq.getValue().equals(getContext().getFileSequentialNumber())); + buttonUndoSeq.setEnabled(editable && !spinnerSeq.getValue().equals(getContext().getFileSequentialNumber())); + buttonApply.setEnabled(editable); + + spinnerSeq.setValue(getContext().getFileSequentialNumber()); + textDataPath.setText(getContext().getSetup().expandPath(getContext().getConfig().dataPath)); + } @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents @@ -116,16 +157,32 @@ public class Experiment extends Panel { jLabel7 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); textAuthors = new javax.swing.JTextArea(); - jLabel8 = new javax.swing.JLabel(); - textPrefix = new javax.swing.JTextField(); - jPanel2 = new javax.swing.JPanel(); - jLabel1 = new javax.swing.JLabel(); - jLabel2 = new javax.swing.JLabel(); - textDataRoot = new javax.swing.JTextField(); - textDataPath = new javax.swing.JTextField(); buttonApply = new javax.swing.JButton(); buttonUndo = new javax.swing.JButton(); buttonClear = new javax.swing.JButton(); + panelDataFile = new javax.swing.JPanel(); + buttonSetSeq = new javax.swing.JButton(); + buttonUndoSeq = new javax.swing.JButton(); + buttonDefaultPath = new javax.swing.JButton(); + buttonSetPath = new javax.swing.JButton(); + buttonUndoPath = new javax.swing.JButton(); + jLabel9 = new javax.swing.JLabel(); + spinnerSeq = new javax.swing.JSpinner(); + textNamePattern = new javax.swing.JTextField(); + jLabel10 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + textDataPath = new javax.swing.JTextField(); + jPanel6 = new javax.swing.JPanel(); + jLabel11 = new javax.swing.JLabel(); + textRsyncUser = new javax.swing.JTextField(); + jLabel18 = new javax.swing.JLabel(); + textRsyncPath = new javax.swing.JTextField(); + checkRsyncEnable = new javax.swing.JCheckBox(); + buttonSetFolder = new javax.swing.JButton(); + jLabel12 = new javax.swing.JLabel(); + textRsyncHost = new javax.swing.JTextField(); + checkRsyncRemove = new javax.swing.JCheckBox(); + buttonUndoFolder = new javax.swing.JButton(); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Metadata")); @@ -149,112 +206,60 @@ public class Experiment extends Panel { jLabel7.setText("Authors:"); textAuthors.setColumns(20); - textAuthors.setRows(5); + textAuthors.setRows(4); jScrollPane1.setViewportView(textAuthors); - jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jLabel8.setText("File Prefix:"); - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(textPrefix) - .addComponent(textSamples) - .addComponent(textProposer, javax.swing.GroupLayout.DEFAULT_SIZE, 547, Short.MAX_VALUE) - .addComponent(jScrollPane1) + .addComponent(textPGroup, javax.swing.GroupLayout.DEFAULT_SIZE, 221, Short.MAX_VALUE) .addComponent(textProposal) - .addComponent(textPGroup)) + .addComponent(textProposer)) + .addGap(40, 40, 40) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(textSamples, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE)) .addContainerGap()) ); - jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel3, jLabel4, jLabel5, jLabel6, jLabel7, jLabel8}); + jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel3, jLabel4, jLabel5, jLabel6, jLabel7}); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(textPrefix, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(textProposer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(textProposal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(textPGroup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(textProposer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(textSamples, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 43, Short.MAX_VALUE)) - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) - .addContainerGap()) - ); - - jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Data Location")); - - jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jLabel1.setText("Root:"); - - jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jLabel2.setText("Path:"); - - textDataRoot.setDisabledTextColor(javax.swing.UIManager.getDefaults().getColor("TextField.foreground")); - textDataRoot.setEnabled(false); - - textDataPath.setDisabledTextColor(javax.swing.UIManager.getDefaults().getColor("TextField.foreground")); - textDataPath.setEnabled(false); - - javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); - jPanel2.setLayout(jPanel2Layout); - jPanel2Layout.setHorizontalGroup( - jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel2Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel2) - .addComponent(jLabel1)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(textDataRoot) - .addComponent(textDataPath)) - .addContainerGap()) - ); - - jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2}); - - jPanel2Layout.setVerticalGroup( - jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel2Layout.createSequentialGroup() - .addContainerGap() - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel1) - .addComponent(textDataRoot, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(textDataPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(textProposal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(textPGroup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jScrollPane1) + .addGap(5, 5, 5))) .addContainerGap()) ); @@ -279,12 +284,247 @@ public class Experiment extends Panel { } }); + panelDataFile.setBorder(javax.swing.BorderFactory.createTitledBorder("Data Location")); + + buttonSetSeq.setText("Save"); + buttonSetSeq.setEnabled(false); + buttonSetSeq.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonSetSeqActionPerformed(evt); + } + }); + + buttonUndoSeq.setText("Undo"); + buttonUndoSeq.setEnabled(false); + buttonUndoSeq.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonUndoSeqActionPerformed(evt); + } + }); + + buttonDefaultPath.setText("Default"); + buttonDefaultPath.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonDefaultPathActionPerformed(evt); + } + }); + + buttonSetPath.setText("Save"); + buttonSetPath.setEnabled(false); + buttonSetPath.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonSetPathActionPerformed(evt); + } + }); + + buttonUndoPath.setText("Undo"); + buttonUndoPath.setEnabled(false); + buttonUndoPath.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonUndoPathActionPerformed(evt); + } + }); + + jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel9.setText("Sequential:"); + + spinnerSeq.setModel(new javax.swing.SpinnerNumberModel(0, 0, 99999, 1)); + spinnerSeq.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + spinnerSeqStateChanged(evt); + } + }); + + textNamePattern.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent evt) { + textNamePatternKeyTyped(evt); + } + public void keyReleased(java.awt.event.KeyEvent evt) { + textNamePatternKeyReleased(evt); + } + }); + + jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel10.setText("Name Pattern:"); + + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel2.setText("Path:"); + + textDataPath.setDisabledTextColor(javax.swing.UIManager.getDefaults().getColor("TextField.foreground")); + textDataPath.setEnabled(false); + + javax.swing.GroupLayout panelDataFileLayout = new javax.swing.GroupLayout(panelDataFile); + panelDataFile.setLayout(panelDataFileLayout); + panelDataFileLayout.setHorizontalGroup( + panelDataFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelDataFileLayout.createSequentialGroup() + .addContainerGap() + .addGroup(panelDataFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelDataFileLayout.createSequentialGroup() + .addGroup(panelDataFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel10) + .addComponent(jLabel9)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelDataFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelDataFileLayout.createSequentialGroup() + .addComponent(spinnerSeq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonSetSeq) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonUndoSeq) + .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(textNamePattern)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(panelDataFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(panelDataFileLayout.createSequentialGroup() + .addComponent(buttonSetPath) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonUndoPath)) + .addComponent(buttonDefaultPath))) + .addGroup(panelDataFileLayout.createSequentialGroup() + .addGap(54, 54, 54) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(textDataPath))) + .addContainerGap()) + ); + + panelDataFileLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonDefaultPath, buttonSetPath, buttonUndoPath}); + + panelDataFileLayout.setVerticalGroup( + panelDataFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelDataFileLayout.createSequentialGroup() + .addContainerGap() + .addGroup(panelDataFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel10) + .addComponent(textNamePattern, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonSetPath) + .addComponent(buttonUndoPath)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelDataFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel9) + .addComponent(spinnerSeq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonSetSeq) + .addComponent(buttonUndoSeq) + .addComponent(buttonDefaultPath)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(panelDataFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(textDataPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Data Transfer")); + + jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel11.setText("User:"); + + jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel18.setText("Destination Folder:"); + + textRsyncPath.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + textRsyncPathKeyReleased(evt); + } + }); + + checkRsyncEnable.setText("Enable"); + checkRsyncEnable.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + checkRsyncEnableActionPerformed(evt); + } + }); + + buttonSetFolder.setText("Set"); + buttonSetFolder.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonSetFolderActionPerformed(evt); + } + }); + + jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel12.setText("Host:"); + + checkRsyncRemove.setText("Remove local files after transfer"); + checkRsyncRemove.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + checkRsyncRemoveActionPerformed(evt); + } + }); + + buttonUndoFolder.setText("Undo"); + buttonUndoFolder.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonUndoFolderActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); + jPanel6.setLayout(jPanel6Layout); + jPanel6Layout.setHorizontalGroup( + jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel6Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup() + .addGap(21, 21, 21) + .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel6Layout.createSequentialGroup() + .addComponent(checkRsyncRemove) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(jPanel6Layout.createSequentialGroup() + .addComponent(textRsyncPath) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonSetFolder) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonUndoFolder)))) + .addGroup(jPanel6Layout.createSequentialGroup() + .addComponent(checkRsyncEnable) + .addGap(83, 83, 83) + .addComponent(jLabel11) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(textRsyncUser) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel12) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(textRsyncHost))) + .addContainerGap()) + ); + + jPanel6Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonSetFolder, buttonUndoFolder}); + + jPanel6Layout.setVerticalGroup( + jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel6Layout.createSequentialGroup() + .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel6Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel11) + .addComponent(textRsyncUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(checkRsyncEnable) + .addComponent(jLabel12) + .addComponent(textRsyncHost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(textRsyncPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonSetFolder) + .addComponent(buttonUndoFolder)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(checkRsyncRemove)) + .addGroup(jPanel6Layout.createSequentialGroup() + .addGap(42, 42, 42) + .addComponent(jLabel18))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(buttonClear) @@ -293,71 +533,231 @@ public class Experiment extends Panel { .addGap(18, 18, 18) .addComponent(buttonApply) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(panelDataFile, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); - layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonApply, buttonUndo}); + layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonApply, buttonClear, buttonUndo}); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0) + .addComponent(panelDataFile, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonApply) .addComponent(buttonUndo) .addComponent(buttonClear)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) ); + + layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {buttonApply, buttonClear, buttonUndo}); + }// //GEN-END:initComponents private void buttonUndoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUndoActionPerformed - try{ + try { undo(); - } catch (Exception ex){ + } catch (Exception ex) { showException(ex); } }//GEN-LAST:event_buttonUndoActionPerformed private void buttonApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonApplyActionPerformed - try{ + try { apply(); - } catch (Exception ex){ + } catch (Exception ex) { showException(ex); } }//GEN-LAST:event_buttonApplyActionPerformed private void buttonClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonClearActionPerformed - try{ + try { reset(); - } catch (Exception ex){ + } catch (Exception ex) { showException(ex); - } + } }//GEN-LAST:event_buttonClearActionPerformed + private void buttonSetSeqActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetSeqActionPerformed + try { + getContext().setFileSequentialNumber(((Number) spinnerSeq.getValue()).intValue()); + updateControls(); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonSetSeqActionPerformed + + private void buttonUndoSeqActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUndoSeqActionPerformed + try { + spinnerSeq.setValue(getContext().getFileSequentialNumber()); + updateControls(); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonUndoSeqActionPerformed + + private void buttonDefaultPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDefaultPathActionPerformed + textNamePattern.setText(DEFAULT_PATH); + updateControls(); + }//GEN-LAST:event_buttonDefaultPathActionPerformed + + private void buttonSetPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetPathActionPerformed + try { + getContext().getConfig().dataPath = textNamePattern.getText(); + getContext().getConfig().save(); + updateControls(); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonSetPathActionPerformed + + private void buttonUndoPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUndoPathActionPerformed + try { + textNamePattern.setText(getContext().getConfig().dataPath); + updateControls(); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonUndoPathActionPerformed + + private void spinnerSeqStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerSeqStateChanged + updateControls(); + }//GEN-LAST:event_spinnerSeqStateChanged + + private void textNamePatternKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textNamePatternKeyTyped + + }//GEN-LAST:event_textNamePatternKeyTyped + + private void textNamePatternKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textNamePatternKeyReleased + updateControls(); + }//GEN-LAST:event_textNamePatternKeyReleased + + private void checkRsyncEnableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkRsyncEnableActionPerformed + if (!updatingRsync) { + try { + setSetting("RSYNC_USER", ""); + //setSetting("RSYNC_PATH", ""); + } catch (Exception ex) { + getLogger().log(Level.SEVERE, null, ex); + } + if (checkRsyncEnable.isSelected()) { + String user = textRsyncUser.getText().trim(); + String host = textRsyncHost.getText().trim(); + String path = textRsyncPath.getText().trim(); + boolean del = checkRsyncRemove.isEnabled(); + if (!user.isEmpty()) { + try { + //this.eval("authorize_user('" + user +"', aux_file = '/scratch/.rsync.tmp')"); + this.eval("authorize_user('" + user + "')"); + setSetting("RSYNC_USER", user); + setSetting("RSYNC_HOST", host); + setSetting("RSYNC_PATH", path); + setSetting("RSYNC_DEL", del); + } catch (Exception ex) { + try { + this.evalAsync("remove_user_key()"); + } catch (Exception e) { + getLogger().log(Level.SEVERE, null, e); + } + showException(ex); + } + } else { + showMessage("Error", "Enter a valid user name to enable data transfer"); + } + } else { + try { + this.evalAsync("remove_user_key()"); + } catch (Exception e) { + getLogger().log(Level.SEVERE, null, e); + } + } + updateRsync(); + } + }//GEN-LAST:event_checkRsyncEnableActionPerformed + + private void buttonSetFolderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetFolderActionPerformed + try { + String path = textRsyncPath.getText().trim(); + setSetting("RSYNC_PATH", path); + /* + String ret = SwingUtils.getString(this, "Enter destination path:", String.valueOf(getSetting("RSYNC_PATH"))); + if ((ret != null) && (!ret.trim().isEmpty())) { + setSetting("RSYNC_PATH", ret.trim()); + } + */ + updateRsync(); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonSetFolderActionPerformed + + private void checkRsyncRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkRsyncRemoveActionPerformed + if (!updatingRsync) { + try { + setSetting("RSYNC_DEL", checkRsyncRemove.isSelected()); + } catch (Exception ex) { + showException(ex); + } + } + }//GEN-LAST:event_checkRsyncRemoveActionPerformed + + private void buttonUndoFolderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUndoFolderActionPerformed + try { + updateRsync(); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonUndoFolderActionPerformed + + private void textRsyncPathKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textRsyncPathKeyReleased + buttonUndoFolder.setEnabled(checkRsyncEnable.isSelected()); + buttonSetFolder.setEnabled(checkRsyncEnable.isSelected()); + }//GEN-LAST:event_textRsyncPathKeyReleased + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton buttonApply; private javax.swing.JButton buttonClear; + private javax.swing.JButton buttonDefaultPath; + private javax.swing.JButton buttonSetFolder; + private javax.swing.JButton buttonSetPath; + private javax.swing.JButton buttonSetSeq; private javax.swing.JButton buttonUndo; - private javax.swing.JLabel jLabel1; + private javax.swing.JButton buttonUndoFolder; + private javax.swing.JButton buttonUndoPath; + private javax.swing.JButton buttonUndoSeq; + private javax.swing.JCheckBox checkRsyncEnable; + private javax.swing.JCheckBox checkRsyncRemove; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel18; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; - private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; - private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel6; private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JPanel panelDataFile; + private javax.swing.JSpinner spinnerSeq; private javax.swing.JTextArea textAuthors; private javax.swing.JTextField textDataPath; - private javax.swing.JTextField textDataRoot; + private javax.swing.JTextField textNamePattern; private javax.swing.JTextField textPGroup; - private javax.swing.JTextField textPrefix; private javax.swing.JTextField textProposal; private javax.swing.JTextField textProposer; + private javax.swing.JTextField textRsyncHost; + private javax.swing.JTextField textRsyncPath; + private javax.swing.JTextField textRsyncUser; private javax.swing.JTextField textSamples; // End of variables declaration//GEN-END:variables } diff --git a/plugins/OTFScanBase.form b/plugins/OTFScanBase.form index 07a34c4..8778bb2 100644 --- a/plugins/OTFScanBase.form +++ b/plugins/OTFScanBase.form @@ -96,14 +96,16 @@ - - - - + + + + + + diff --git a/plugins/OTFScanBase.java b/plugins/OTFScanBase.java index 0984e3a..81bea31 100644 --- a/plugins/OTFScanBase.java +++ b/plugins/OTFScanBase.java @@ -206,13 +206,14 @@ public class OTFScanBase extends Panel { .addComponent(jLabel2) .addComponent(spinnerE2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel3) - .addComponent(spinnerTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel12) .addComponent(radioK1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(radioK3)))) + .addComponent(radioK3)) + .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(spinnerTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) ); jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Scan Control")); @@ -279,7 +280,7 @@ public class OTFScanBase extends Panel { try { abort(); } catch (InterruptedException ex) { - Logger.getLogger(EnergyScan.class.getName()).log(Level.SEVERE, null, ex); + getLogger().log(Level.SEVERE, null, ex); } }//GEN-LAST:event_buttonAbortActionPerformed diff --git a/script/devices/LEEM2000.py b/script/devices/LEEM2000.py new file mode 100644 index 0000000..fd567e7 --- /dev/null +++ b/script/devices/LEEM2000.py @@ -0,0 +1,108 @@ +import ch.psi.pshell.serial.TcpDevice as TcpDevice + + +class LEEM2000(TcpDevice): + def __init__(self, name,host="pc14062.psi.ch", port=5566): + TcpDevice.__init__(self, name, host, port) + self.NUMBER_MNEMONICS = 100 + self._mnemonics = None + self._names = None + self.high_voltage = Channel("X11MA-ES1-PEEM:UMON", alias = "PEEM high voltage", monitored=True) + + def doInitialize(self): + super(LEEM2000, self).doInitialize() + + def doUpdate(self): + try: + hv = self.get_high_voltage() + except: + hv = "" + try: + pl = self.get_preset_label() + except: + pl = "unknown" if microscope.client.isConnected() else "offline" + + value = "%1.3f | %s" % (hv,pl) if hv!="" or pl!="" else None + self.setCache(value, None) + + def send_receive(self, tx, timeout = 1000, retries = 1): + trailer = chr(0) + ret = self.sendReceive(tx+trailer, None,trailer, 0, 1000, 1) + return str(ret[0:-1]).strip() + + def get_value(self, name, timeout = 1000, retries = 1): + cmd = "get " + name + ret = self.send_receive(cmd, timeout, retries) + try: + value = float(ret) + return value + except: + self.getLogger().info("Received invalid value for %s: %s" % (name, ret)) + return None + + def get_mnemonic(self, index, timeout = 1000, retries = 1): + cmd = "mne " + str(index) + return self.send_receive(cmd, timeout, retries) + + def _get_mnemonics(self, timeout = 1000, retries = 1): + ret = [] + for i in range(self.NUMBER_MNEMONICS): + mne = self.get_mnemonic(i, timeout, retries) + if mne not in [None, '', 'disabled', 'invalid']: + ret.append(mne) + return ret + + def get_mnemonics(self, timeout = 1000, retries = 1): + if self._mnemonics is None: + try: + self._mnemonics = self._get_mnemonics(timeout = 1000, retries = 1) + except: + self.getLogger().warning("Error retrieving microscope mnemonics") + return [] + return self._mnemonics + + def get_mnemonic_values(self, timeout = 1000, retries = 1): + ret = {} + for mnemonic in self.get_mnemonics(timeout, retries): + ret[mnemonic] = self.get_value(mnemonic, timeout, retries) + return ret + + def get_name(self, index, timeout = 1000, retries = 1): + cmd = "nam " + str(index) + return self.send_receive(cmd, timeout, retries) + + def _get_names(self, timeout = 1000, retries = 1): + ret = [] + for i in range(self.NUMBER_MNEMONICS): + mne = self.get_name(i, timeout, retries) + if mne not in [None, '', 'disabled', 'invalid']: + ret.append(mne) + return ret + + def get_names(self, timeout = 1000, retries = 1): + if self._names is None: + try: + self._names = self._get_names(timeout = 1000, retries = 1) + except: + self.getLogger().warning("Error retrieving microscope mnemonics") + return [] + return self._names + + def get_values(self, timeout=1000, retries=1): + ret = {} + for name in self.get_names(): + ret[name] = self.get_value(name, timeout, retries) + return ret + + def get_preset_label(self, timeout=1000, retries=1): + cmd = "prl" + return self.send_receive(cmd, timeout, retries) + + def get_high_voltage(self): + return self.high_voltage.get(False) + + +add_device (LEEM2000("microscope"), True) +microscope.setPolling(5000) + + diff --git a/script/devices/diag.py b/script/devices/diag.py index e01ad10..03a691d 100644 --- a/script/devices/diag.py +++ b/script/devices/diag.py @@ -36,14 +36,18 @@ diag_channels = { \ "id2 shift": "X11MA-ID2-SHIFT:READ", \ "keithley 10 IO": "X11Keithley1-read", \ #"ring current": "ARIDI-PCT:CURRENT", \ - "PEEM high voltage": "X11MA-ES1-PEEM:UMON", \ + #"PEEM high voltage": "X11MA-ES1-PEEM:UMON", \ "PEEM leakage current": "X11MA-ES1-PEEM:IMON", \ "Pressure in PEEM": "X11MA-ES1-MAIN:PRESSURE", \ "Pressure in Column": "X11MA-ES1-COLU:PRESSURE", \ - "Sample temperature": "X11MA-ES1-SW:Pt100-T", \ + "Sample temperature": "X11MA-ES1-SW:Pt100-K", \ "Pt100 resistance": "X11MA-ES1-SW:Pt100-R", \ - "high voltage": "X11MA-ES1-SD1:cam1:HighVoltage_RBV", \ } + +eiger_diag_channels = { \ + "high voltage": "X11MA-ES1-SD1:cam1:HighVoltage_RBV", \ +} + diag_devices = { "photon energy": energy_rbk, \ @@ -60,9 +64,22 @@ diag_devices = { "id2 alpha": id2_alpha, \ "id2 harmonic": id2_harmonic, \ "ring current": machine_cur, \ + "PEEM high voltage": microscope.high_voltage, } +def get_microscope_diags(): + try: + ret = microscope.get_values() + except: + return {} + try: + ret["Preset Label"] = microscope.get_preset_label() + except: + pass + return ret + + def get_diags(): ret = {} for k,v in diag_devices.items(): @@ -73,9 +90,23 @@ def get_diags(): for k,v in diag_channels.items(): try: ret[k]=caget(v,'s') + except: + ret[k]="Error: " + str(sys.exc_info()[1]) + if eiger.initialized: + try: + ret["exposure time"] = str(eiger.getExposure()) except: ret[k]="Error: " + str(sys.exc_info()[1]) - ret["exposure time"] = str(eiger.getExposure()) + for k,v in eiger_diag_channels.items(): + try: + ret[k]=caget(v,'s') + except: + ret[k]="Error: " + str(sys.exc_info()[1]) + + if microscope.initialized and microscope.client.isConnected(): + for k,v in get_microscope_diags().items(): + ret["Microscope " + k] = str(v) + return OrderedDict(sorted(ret.items(), key=lambda i: i[0].lower())) def print_diags(): diff --git a/script/local.py b/script/local.py index aba7c4e..7675e3f 100644 --- a/script/local.py +++ b/script/local.py @@ -5,6 +5,8 @@ import ntpath import traceback from rsync import * + +get_context().dataManager.createLogs=False """ OTF_START = "X11MA-OTF:GO" OTF_E1 = "X11MA-OTF:E1" @@ -236,7 +238,7 @@ def otf(start, end, time, delay = 0.0, mode = None, offset = None, alpha = None, #Devices ################################################################################################### -for dev in ["eiger", "id", "chopper", "diag"]: +for dev in ["eiger", "id", "chopper", "LEEM2000", "diag"]: try: run("devices/" + dev) except: @@ -298,7 +300,7 @@ def assert_machine_ok(wait = True): if Ringstatus==5: log ("FB off") - checkRing=1 + #checkRing=1 if Ringstatus==0: log ("Machine down") checkRing=2 @@ -498,13 +500,17 @@ def stop_measurements(): def _check_sync_user_data(path): rsync_user = get_setting("RSYNC_USER"); rsync_path = get_setting("RSYNC_PATH"); + rsync_host = get_setting("RSYNC_HOST"); + rsync_del = str(get_setting("RSYNC_DEL")).lower() == "true" if rsync_user: if not rsync_path: rsync_path = "~/Data1" else: rsync_path = "~/Data1/" + rsync_path + if not rsync_host: + rsync_host = "localhost" if path is not None: - sync_user_data(rsync_user, path, rsync_path) + sync_user_data(rsync_user, path, rsync_path, host=rsync_host, remove_local_folder=rsync_del, remove_local_files=False) time.sleep(5.0) _FORK_SYNC_USER = True @@ -516,12 +522,44 @@ def check_sync_user_data(path, do_fork=_FORK_SYNC_USER): _CURRENT_DATA_PATH = None def on_change_data_path(path): + print "on_change_data_path: " + str(path) global _CURRENT_DATA_PATH if path is None: + print "Close data path" if _CURRENT_DATA_PATH is not None: check_sync_user_data(_CURRENT_DATA_PATH) - else: - _CURRENT_DATA_PATH = path + else: + print "Open data path: " + str(path) + _CURRENT_DATA_PATH = path + fork(write_metadata) + + +################################################################################################### +#Sounds +################################################################################################### +def on_command_started(info): + if not get_context().isLocalMode(): + if info.script and not info.background: + play_sound("start") + +def on_command_finished(info): + if not get_context().isLocalMode(): + if info.script and not info.background: + if (info.isError()): + if not info.isAborted(): + play_sound("error") + else: + play_sound("success") + + +import ch.psi.utils.Audio as Audio +import java.io.File as File + +def play_sound(name): + try: + Audio.playFile(File(get_context().setup.expandPath("{home}/sounds/" + name + ".wav")), False) + except: + log("Error playing sound " + name + ": " + str(sys.exc_info()[1]), False) ################################################################################################### #Settings @@ -543,9 +581,14 @@ def get_outliers_threshold(): except: return 0 - def get_outliers_mask_file(): return get_setting("OUTLIERS_MASK_FILE") - +def write_metadata(): + for name in ["proposer", "proposal", "pgroup", "sample"]: + value = get_setting(name) + set_attribute("/", name, value) + setting = get_setting("authors") + set_attribute("/", "authors", setting.split("|") if setting is not None else [""]) + diff --git a/script/templates/Eiger2Img.py b/script/templates/Eiger2Img.py index 901439a..5dfd925 100644 --- a/script/templates/Eiger2Img.py +++ b/script/templates/Eiger2Img.py @@ -34,19 +34,35 @@ if METHOD == "Two_Energies": start = time.time() threads = [] -path = "{data}/{year}_{month}/{date}" + "/" + "{seq}%03d_" + METHOD -set_exec_pars(path= path, format="txt", layout="table", open=True) -data_path = get_context().setup.expandPath(path) + +#path = "{data}/{year}_{month}/{date}" + "/" + "{seq}%03d_" + METHOD +#set_exec_pars(path= path, format="txt", layout="table", open=True) +#data_path = get_context().setup.expandPath(path) +data_path = "{data}/{year}_{month}/{date}/{date}_{name}" +set_exec_pars(name=METHOD, path = data_path, format="txt", layout="table", open=True) +#data_path = get_exec_pars().path + #get_context().incrementFileSequentialNumber() +run_index = get_context().getDaySequentialNumber() +max_index=0 + def get_image_file_name(cycle=-1, frame_index=0, short_name=False): + global max_index root = "" if short_name else (data_path + "/") + #prefix = get_context().setup.expandPath("i{seq}%03d" + "_" + ("%d" % frame_index)) + abs_index=run_index + frame_index + max_index= max(max_index, frame_index) + #prefix = get_context().setup.expandPath("i{date}%02d_{seq}%03d") + prefix = get_context().setup.expandPath("i{date}%02d_" + ("%03d" % (abs_index,))) + if cycle < 0: - ret = root + "i"+"{seq}%03d" + "_" + ("%d" % frame_index) + ".tif" + ret = root + prefix + ".tif" else: - ret= root + ("%d/" % frame_index) + "i"+"{seq}%03d" + "_" + str(cycle) + ("_%d" % frame_index) + ".tif" - ret = get_context().setup.expandPath(ret) - return ret + ret= root + prefix + "/i{date}%02d"+ ("_%03d#%03d" % (abs_index,cycle)) + ".tif" + return get_context().setup.expandPath(ret) + + """ @@ -56,8 +72,6 @@ def getLEEM(): objective=getObjective() LEEMtemp=getLEEMtemp() """ -set_exec_pars(path= path, format="txt", layout="table", open=True) -data_path = get_context().setup.expandPath(path) @@ -190,7 +204,7 @@ try: ret = grab_frames(image, AVERAGE[i], roi=None, wait_next=True) frames.append(average_frames(ret) if AVERAGE[i] > 1 else ret[0]) imageinfo("I") - save_image_file(frames[i], cycle, i) + save_image_file(frames[i], cycle, i) if METHOD == "Take_Image": break @@ -247,6 +261,8 @@ try: av=op_const(integration, "divide", float(MEASUREMENTS), in_place=True) save_image_file(av, -1, i) finally: + for i in range(max_index): + get_context().incrementDaySequentialNumber() if not DRY_RUN and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true": close_vg10() restore_eiger() diff --git a/script/templates/EigerAbsSpec.py b/script/templates/EigerAbsSpec.py index 3e03688..a362f68 100644 --- a/script/templates/EigerAbsSpec.py +++ b/script/templates/EigerAbsSpec.py @@ -25,7 +25,8 @@ eiger.grabMode=eiger.GrabMode.Single time.sleep(0.3) set_exposure_time(EXPOSURE) -set_exec_pars(path="{data}/{year}_{month}/{date}/{seq}%03d_AbsortionSpectrum", format="csv", layout="table") +#set_exec_pars(path="{data}/{year}_{month}/{date}/{seq}%03d_AbsortionSpectrum", format="csv", layout="table") +set_exec_pars(name="AbsortionSpectrum", format="csv", layout="table") tag= "AbsortionSpectrum_{seq}%03d_{count}%02d" rois = create_roi_devices(ROI) @@ -51,7 +52,7 @@ set_device_alias(sync_energy, "Energy") #Set display name sensors = rois + [machine_cur] if WITH_I0: - sensors = rois + [keithley_1a] + sensors = sensors + [keithley_1a] diff --git a/script/test/TestTcp.py b/script/test/TestTcp.py new file mode 100644 index 0000000..e779688 --- /dev/null +++ b/script/test/TestTcp.py @@ -0,0 +1,25 @@ +import ch.psi.pshell.serial.TcpDevice as TcpDevice + +#trailer = chr(0) +#cmd = "get Transfer Lens" + +trailer = [0] +#cmd = "get Transfer Lens" + +cmd = "get Objective" +cmd = map(ord,cmd) +print cmd + +mic = TcpDevice("mic","pc14062.psi.ch",5565) +mic.initialize() + +try: + cmd = cmd if trailer is None else (cmd + trailer) + print "TX-> ", cmd + ret= mic.sendReceive(cmd, None,trailer, 0, 2000, 1) +finally: + mic.close() + + + +print "RX-> ", ret \ No newline at end of file diff --git a/script/test/rsync.py b/script/test/rsync.py new file mode 100644 index 0000000..31befb8 --- /dev/null +++ b/script/test/rsync.py @@ -0,0 +1,140 @@ +#################################################################################################### +# Utilities for synchronizing folders with rsync +# On RH7 (not SL6) +# Change permission of the account, otherwise SSH keys are not accepted: +# ~/.ssh from drwxr-S--- to drwx---- +# ~ : from drwxrws--- to drwxr-s--- +#################################################################################################### + +import sys +import os +import os.path +import shutil + +from startup import exec_cmd, log + +RSYNC_GENERATE_USER_KEY = True + +def rsync(src, dest, key): + #cmd = 'rsync -e "ssh -i ' + key + ' -o LogLevel=quiet" --chmod=ug=rwx --verbose --modify-window=1 --times --recursive ' + src + ' ' + dest + #ret = exec_cmd(cmd) + cmd = 'rsync -e "ssh -i ' + key + '" --chmod=ug=rwx --verbose --modify-window=1 --times --recursive ' + src + ' ' + dest + ret = exec_cmd(cmd, False) + lines = ret.split("\n") + lines = filter(lambda x: x != "", lines) + if len(lines)<3: + print "Invalid return from rsync:\n", ret + raise Exception ("Invalid format") + #files = lines[1:-2] + files = [] + head,tail=os.path.split(src) + for l in lines: + f = os.path.join(head,l) + if os.path.exists(f): + files.append(f) + try: + stats = lines[-2].replace(",", "").replace(".", "") + stats = [int(s) for s in stats.split() if s.isdigit()] + bytes_sent, bytes_received = stats[0], stats[1] + except: + print "Invalid statistics from rsync:\n", ret + bytes_sent, bytes_received = None, None + + return files, bytes_sent, bytes_received + +def sync_user_data(user, src, dest, host= "localhost", remove_local_folder=False, remove_local_files=False, do_log=True, do_print=True): + try: + if do_log: + log("Start synchronizing %s to %s:%s" % (src, user, dest), False ) + key = os.path.expanduser("~/.ssh/" + ("ke" if RSYNC_GENERATE_USER_KEY else "id_rsa")) + if not os.path.isfile(key): + raise Exception ("Invalid key file") + dest = "'" + dest.replace(" ", "\ ") + "'" + dest = user + "@" + host + ":" + dest + files, bytes_sent, bytes_received = rsync(src,dest,key) + msg = "Transferred " + str(bytes_sent) + " bytes to " + user + ": " + for f in files: + msg = msg + "\n" + f + if do_log: + log(msg, False) + if do_print: + print msg + if remove_local_folder: + if do_log: + log("Removing folder: " + src) + shutil.rmtree(src) + elif remove_local_files: + for f in files: + if not os.path.samefile(f, src): + if os.path.isfile(f): + if do_log: + log("Removing file: " + f) + os.remove(f) + elif os.path.isdir(f): + if do_log: + log("Removing folder: " + f) + shutil.rmtree(f) + + except: + msg = "Error transferring user data to " + user + ": " + str(sys.exc_info()[1]) + if do_log: + log(msg, False) + if do_print: + print >> sys.stderr, msg + return msg + +def remove_user_key(do_print=True): + cmd = "rm ~/.ssh/ke;" + cmd = cmd + "rm ~/.ssh/ke.pub" + if do_print: + print exec_cmd(cmd, False) + +def reset_user_key(do_print=True): + remove_user_key(do_print) + cmd = "ssh-keygen -N '' -f ~/.ssh/ke -t rsa;" + if do_print: + print exec_cmd(cmd) + +def authorize_user(user, aux_file = os.path.expanduser("~/.rsync.tmp"), fix_permissions=True, do_print=True): + if (os.path.isfile(aux_file)): + os.remove(aux_file) + with open(aux_file, "w") as fh: + fh.write("Cannot access file: " + aux_file) + os.chmod(aux_file, 0o777) + + success_msg = 'Success transfering authorization key for: ' + user + cmd = 'echo Authorizing: ' + user + ";" + cmd = cmd + 'echo Invalid user or password > ' + aux_file + ";" + cmd = cmd + "export PK_SUCCESS=FAILURE;" + if RSYNC_GENERATE_USER_KEY: + reset_user_key(do_print) + cmd = cmd + "export PK=`cat ~/.ssh/ke.pub`;" + else: + cmd = cmd + "export PK=`cat ~/.ssh/id_rsa.pub`;" + cmd = cmd + 'su - ' + user + ' bash -c "' + cmd = cmd + 'echo $PK >> .ssh/authorized_keys;' + #cmd = cmd + 'sort .ssh/authorized_keys | uniq > .ssh/authorized_keys.uniq;' + #cmd = cmd + 'mv .ssh/authorized_keys.uniq .ssh/authorized_keys;' + if fix_permissions: + cmd = cmd + 'chmod g-w ~' + ";" + cmd = cmd + 'echo ' + success_msg + ";" + cmd = cmd + 'echo ' + success_msg + " > " + aux_file + ";" + cmd = cmd + '"' + #xterm_options = '-hold -T "Authentication" -into 44040199' #Get Winfow ID with 'wmctrl -lp' + xterm_options = '-T "Authentication" -fa monaco -fs 14 -bg black -fg green -geometry 80x15+400+100' + try: + ret = exec_cmd("xterm " + xterm_options + " -e '" + cmd + "'") + with open (aux_file, "r") as myfile: + ret=myfile.read() + #;if [ "$depth" -eq "1" ]; then echo ' + success_msg + '; fi') + if not success_msg in ret: + raise Exception (ret) + except: + if RSYNC_GENERATE_USER_KEY: + remove_user_key(do_print) + raise Exception ("Error authenticating user: " + str(sys.exc_info()[1])) + finally: + if (os.path.isfile(aux_file)): + os.remove(aux_file) + return ret + diff --git a/script/test/test_file_name b/script/test/test_file_name new file mode 100644 index 0000000..26b0ad7 --- /dev/null +++ b/script/test/test_file_name @@ -0,0 +1,16 @@ +set_exec_pars(open=True) + +cycle=0 +frame_index=0 +short_name=False + +root = "" if short_name else (get_exec_pars().path + "/") +prefix = get_context().setup.expandPath("i{date}%02d_{dseq}%03d") +print prefix +if cycle < 0: + ret = root + prefix + ".tif" +else: + ret= root + prefix + "/i{seq}%03d"+ "_" + str(cycle) + ("_%d" % frame_index) + ".tif" + +print ret + \ No newline at end of file