This commit is contained in:
gac-x09la
2022-02-07 09:49:39 +01:00
parent 34661df5b9
commit f6b0954e8f
15 changed files with 290 additions and 52 deletions
+3 -3
View File
@@ -1,8 +1,8 @@
#Fri Aug 27 09:00:46 CEST 2021
#Thu Jan 20 17:13:38 CET 2022
ch.psi.jcae.ContextFactory.addressList=
ch.psi.jcae.ContextFactory.serverPort=
ch.psi.jcae.ContextFactory.maxArrayBytes=20000000
ch.psi.jcae.ContextFactory.maxSendArrayBytes=10000000
ch.psi.jcae.ContextFactory.maxArrayBytes=40000000
ch.psi.jcae.ContextFactory.maxSendArrayBytes=20000000
ch.psi.jcae.ChannelFactory.retries=2
ch.psi.jcae.ChannelFactory.timeout=1500
ch.psi.jcae.impl.DefaultChannelService.retries=1
-2
View File
@@ -1,4 +1,2 @@
NewJPanel.java=disabled
Test.java=disabled
SIStem.java=enabled
EnergyScan.java=disabled
+3 -3
View File
@@ -1,4 +1,4 @@
#Wed Jan 19 10:05:40 CET 2022
LastRunDate=220119
#Thu Jan 27 11:28:54 CET 2022
LastRunDate=220127
DaySequentialNumber=1
FileSequentialNumber=97
FileSequentialNumber=180
+17
View File
@@ -24,6 +24,10 @@
<Component id="buttonScienta" linkSize="10" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="buttonData" linkSize="10" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="32767" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="textTime" min="-2" pref="120" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonStart" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
@@ -67,6 +71,8 @@
<Component id="buttonStart" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonAbort" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonData" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textTime" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -1379,5 +1385,16 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonDataActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Acquisition Time:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textTime">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
</SubComponents>
</Form>
+133 -16
View File
@@ -15,8 +15,12 @@ import ch.psi.pshell.plot.MatrixPlotSeries;
import ch.psi.pshell.plot.Plot;
import ch.psi.pshell.swing.DataPanel;
import ch.psi.pshell.swing.DevicePanel;
import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.PanelProcessor;
import ch.psi.pshell.ui.Preferences;
import ch.psi.pshell.ui.Processor;
import ch.psi.pshell.ui.QueueProcessor;
import ch.psi.pshell.ui.View;
import ch.psi.utils.Arr;
import ch.psi.utils.Convert;
import ch.psi.utils.IO;
@@ -77,7 +81,29 @@ public class SIStem extends PanelProcessor {
final JComboBox[] deviceCombos;
String[] additionalPositioners ;
boolean intialized;
static{
QueueProcessor.DEFAULT_INFO_COLUMN = "Time";
View view = App.getInstance().getMainFrame();
if (view!=null){
List<QueueProcessor> queues =view.getQueues();
for (QueueProcessor qp : queues){
String filename = qp.getFileName();
if ((filename!=null)&&(!filename.isBlank())&&!qp.hasChanged()){
System.out.println("Reload: " + filename);
try {
view.getDocumentsTab().remove(qp.getPanel());
view.openProcessor(QueueProcessor.class, filename);
} catch (Exception ex) {
Logger.getLogger(SIStem.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace();
}
}
}
}
}
public SIStem() {
initComponents();
modelInactive = (DefaultTableModel) tableInactive.getModel();
@@ -184,6 +210,7 @@ public class SIStem extends PanelProcessor {
detectorPlot.getAxis(Plot.AxisId.X).setLabel("X-Scale (energy)");
detectorPlot.getAxis(Plot.AxisId.Y).setLabel("Y-Scale (distance or angle)");
clear();
startTimer(2000, 100);
}
void addDevice(ProcessVariable dev, DefaultTableModel model, int row, Object[] data) {
@@ -223,8 +250,10 @@ public class SIStem extends PanelProcessor {
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
if ((runCount == 0)&&(getFileName()==null)) {
clear();
if (runCount == 0) {
if (getFileName()==null){
clear();
}
}
if (!intialized) {
@@ -283,6 +312,13 @@ public class SIStem extends PanelProcessor {
public void onExecutedFile(String fileName, Object result) {
}
@Override
public void onTimer() {
if (getState().isInitialized()){
updateTime();
}
}
//Callback to perform update - in event thread
@Override
protected void doUpdate() {
@@ -504,6 +540,8 @@ public class SIStem extends PanelProcessor {
}
} finally{
updateControls();
updatingTime=false;
updateTime();
}
}
@@ -553,6 +591,7 @@ public class SIStem extends PanelProcessor {
getLogger().log(Level.WARNING, null, ex);
}
}
textTime.setText("");
}
@Override
@@ -601,22 +640,29 @@ public class SIStem extends PanelProcessor {
if (currentFile == null) {
return;
}
Processor p = getView().getRunningProcessor(true);
HashMap args = new HashMap();
args.put("NAME", getScanName());
this.runAsync("templates/SIStem", args).handle((ret, ex) -> {
if (ex != null) {
}
try {
} catch (Exception e) {
Logger.getLogger(SIStem.class.getName()).log(Level.SEVERE, null, e);
}
args.put("NAME", getScanName());
this.runAsync("templates/SIStem", args).handle((ret, ex) -> {
if (ex != null) {
if ((p==null)||!(p instanceof QueueProcessor)){
if (getView().getPreferences().getScriptPopupDialog() != Preferences.ScriptPopupDialog.None) {
if (!getContext().isAborted()) {
showException((Exception)ex);
}
}
}
}
return ret;
});
}
@Override
public Object getResult() {
return getContext().getLastScriptResult();
}
String getScanName() {
String scan = null;
if (currentFile != null) {
@@ -945,6 +991,56 @@ public class SIStem extends PanelProcessor {
void onPlotHide() {
detectorPlot.clear();
}
volatile boolean updatingTime;
void updateTime(){
if (!updatingTime){
String cmd="calc_acquisition_time(";
int samples = 1;
for (int i = 0; i < modelScanned.getRowCount(); i++) {
Integer points = (Integer) modelScanned.getValueAt(i, 3);
samples*=points;
}
cmd+="samples="+Math.max(samples,1) + ", ";
if (!((String)comboAcquisition.getSelectedItem()).isBlank()){
cmd+="mode='"+String.valueOf(comboAcquisition.getSelectedItem()) + "', ";
}
if (!textLowEnergy.getText().isBlank()){
cmd+="enl="+(String)textLowEnergy.getText() + ", ";
}
if (!textHighEnergy.getText().isBlank()){
cmd+="enh="+(String)textHighEnergy.getText() + ", ";
}
if (!textStepEnergy.getText().isBlank()){
cmd+="ens="+(String)textStepEnergy.getText() + ", ";
}
if (!textLowThetaY.getText().isBlank()){
cmd+="tyl="+(String)textLowThetaY.getText() + ", ";
}
if (!textHighThetaY.getText().isBlank()){
cmd+="tyh="+(String)textHighThetaY.getText() + ", ";
}
if (!textStepThetaY.getText().isBlank()){
cmd+="tys="+(String)textStepThetaY.getText() + ", ";
}
cmd+=")";
updatingTime=true;
try {
this.evalAsync(cmd, true).handle((ret, ex) -> {
String text = ((ex != null) || (ret==null)) ? "" : String.valueOf(ret);
SwingUtilities.invokeLater(()->{
textTime.setText(text);
});
updatingTime=false;
return ret;
});
} catch (Context.ContextStateException ex) {
Logger.getLogger(SIStem.class.getName()).log(Level.WARNING, null, ex);
updatingTime=false;
}
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
@@ -1053,6 +1149,8 @@ public class SIStem extends PanelProcessor {
buttonSave = new javax.swing.JButton();
buttonClear = new javax.swing.JButton();
buttonData = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
textTime = new javax.swing.JTextField();
buttonScienta.setText("Scienta Panel");
buttonScienta.addActionListener(new java.awt.event.ActionListener() {
@@ -1919,6 +2017,11 @@ public class SIStem extends PanelProcessor {
}
});
jLabel2.setText("Acquisition Time:");
textTime.setEditable(false);
textTime.setHorizontalAlignment(javax.swing.JTextField.CENTER);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -1931,6 +2034,10 @@ public class SIStem extends PanelProcessor {
.addComponent(buttonScienta)
.addGap(18, 18, 18)
.addComponent(buttonData)
.addGap(18, 18, Short.MAX_VALUE)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textTime, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonStart)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
@@ -1974,7 +2081,9 @@ public class SIStem extends PanelProcessor {
.addComponent(buttonScienta)
.addComponent(buttonStart)
.addComponent(buttonAbort)
.addComponent(buttonData))
.addComponent(buttonData)
.addComponent(jLabel2)
.addComponent(textTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
@@ -2060,7 +2169,13 @@ public class SIStem extends PanelProcessor {
getView().getDocumentsTab().setSelectedComponent(tq);
}
if (currentFile != null) {
tq.addNewFile(currentFile.getPath());
if (tq.getTableInfoCol()!=null){
tq.addNewFile(currentFile.getPath(), "", textTime.getText());
} else {
String args = (textTime.getText().isBlank()) ? "": "\"Time\":"+textTime.getText();
tq.addNewFile(currentFile.getPath(), args);
}
}
} catch (Exception ex) {
showException(ex);
@@ -2196,6 +2311,7 @@ public class SIStem extends PanelProcessor {
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;
@@ -2252,6 +2368,7 @@ public class SIStem extends PanelProcessor {
private javax.swing.JTextArea textSnapshots;
private javax.swing.JTextField textStepEnergy;
private javax.swing.JTextField textStepThetaY;
private javax.swing.JTextField textTime;
private javax.swing.JTextField textXChannelMax;
private javax.swing.JTextField textXChannelMin;
private javax.swing.JTextField textYChannelMax;
+49 -2
View File
@@ -2,6 +2,7 @@
# Deployment specific global definitions - executed after startup.py
###################################################################################################
def get_additional_positioners():
ret = []
try:
@@ -299,8 +300,15 @@ def trigger_scienta():
"""
Trigger new acquisition
"""
scienta.start()
scienta.waitNewImage(-1)
#scienta.start()
#scienta.waitNewImage(-1)
if scienta.isSimulated():
time.sleep(0.1)
else:
image_id = scienta.currentImageCount
scienta.start()
scienta.waitReady(-1)
scienta.waitNewImage(3000, image_id)
def dummy_trigger_scienta():
@@ -355,3 +363,42 @@ def fit(ydata, xdata = None):
p.addMarker(max_x, None, "Max="+str(round(max_x,2)), Color.GRAY)
print "Invalid gaussian fit: " + str(mean)
return (None, None, None)
def calc_acquisition_time(samples=1,exp=None, iter=None, images=None, mode=None, enl=None, enh=None, ens=None, tyl=None, tyh=None, tys=None, as_string=True):
if exp is None: exp = scienta.getExposure()
if iter is None: iter = scienta.getIterations()
if images is None: images = scienta.getNumImages()
if mode is None: mode = str(scienta.getAcquisitionMode())
if enl is None: enl = scienta.getLowEnergy().take()
if enh is None: enh = scienta.getHighEnergy().take()
if ens is None: ens = scienta.getEnergyStepSize().take()
if tyl is None: tyl = scienta.getLowThetaY().take()
if tyh is None: tyh = scienta.getHighThetaY().take()
if tys is None: tys = scienta.getThetaYStepSize().take()
pass_energy=float(scienta.getPassEnergy())
time_s = float(exp)*iter*images
if mode in ("Swept_Energy", "Swept_Energy_ThetaY"):
time_s = time_s * ((abs(enh - enl)+(pass_energy*0.08)) / ens + 3.0)
if mode in ("Swept_ThetaY", "Swept_Energy_ThetaY"):
time_s = time_s * (abs(tyh - tyl) / tys + 3.0)
time_s = time_s * samples
time_s = time_s + 1
if not as_string:
return time_s
#return time.strftime("%H:%M:%S" , time.gmtime(time_s))
dec= math.modf(time_s)[0]
hours = time_s // (60*60)
time_s %= (60*60)
minutes = time_s // 60
time_s %= 60
#if (hours==minutes==0) and (time_s<10) :
if (hours==minutes==time_s==0):
ret= "%0.3f" % (time_s)
else:
ret= "%02i:%02i:%02i" % (hours, minutes, time_s)
return ret
+1 -1
View File
@@ -1 +1 @@
[ [ [ true, "/sls/X09LA/data/X09LA/pshell/home/parameters/Test1.ens", "", "Resume", "" ], [ true, "templates/EnergyScan.py", "\"FILE\":\"\", \"REGIONS\":[[523.0,527.0,2.0],[527.0,535.0,4.0],[535.0,558.0,2.0]], \"NAME\":\"tst\"", "Resume", "" ] ] ]
[ [ [ true, "scans/test/nick.json", "\"Time\":2.500", "Resume", "Failure" ], [ false, "scans/test/nick2d.json", "", "Resume", "Disabled" ], [ true, "scans/test/nick.json", "", "Resume", "Success" ], [ true, "scans/test/nick.json", "", "Resume", "Failure" ], [ true, "scans/test/nick.json", "\"Time\":2.500", "Resume", "Success" ], [ true, "scans/test/scan2.json", "", "Resume", "Failure" ], [ true, "scans/test/scan2.json", "\"Time\":5.000", "Resume", "Success" ], [ true, "scans/test/scan2.json", "\"Time\":5.000", "Resume", "Failure" ] ] ]
+1
View File
@@ -0,0 +1 @@
[ [ ] ]
+1
View File
@@ -0,0 +1 @@
[ [ [ true, "scans/test/nick2d.json", "", "Resume", "Failure", "00:00:12" ], [ true, "scans/test/nick2d.json", "", "Resume", "Failure", "00:00:12" ], [ true, "scans/test/test.json", "", "Resume", "Failure", "00:00:01" ] ] ]
+1
View File
@@ -0,0 +1 @@
[ [ [ true, "scans/test/test.json", "", "Resume", "", "00:00:01" ], [ true, "scans/test/test.json", "", "Resume", "", "00:00:01" ] ] ]
+29
View File
@@ -0,0 +1,29 @@
{
"PASSES" : 1,
"STOP" : [ 1.0 ],
"DIAGS" : [ "phi", "theta", "tilt", "x", "y", "z" ],
"PRE_ACTIONS" : {
"scienta.passEnergyDev" : "10",
"scienta.acquisitionModeDev" : "Fixed",
"scienta.energyModeDev" : "Kinetic",
"scienta.lensModeDev" : "A30L_01",
"scienta.detectorModeDev" : "ADC",
"scienta.lowEnergy" : 33.0,
"scienta.centerEnergy" : 34.5,
"scienta.highEnergy" : 35.0,
"scienta.energyStepSize" : 0.005,
"scienta.centerThetaX" : 0.0,
"scienta.slices" : 601,
"scienta.channels" : 801
},
"COMPRESSION" : true,
"SENSORS" : [ "scienta.dataMatrix", "current" ],
"ZIGZAG" : false,
"SETTLING_TIME" : 0.0,
"MONITORS" : [ "current" ],
"START" : [ 0.0 ],
"RANGE" : [ 900, 100, 750, 150 ],
"POSITIONERS" : [ "x" ],
"STEPS" : [ 9 ],
"SNAPS" : [ "acmi", "cff", "energy", "exit_slit", "fe_horiz_width", "fe_vert_width", "helium_valve", "master", "pgm_cff", "photon_energy", "tcmp", "temp_boot1", "temp_boot2", "temp_cryopump", "temp_cryostat", "temp_headmech", "temp_sample1", "temp_sample2", "temp_shield" ]
}
+29
View File
@@ -0,0 +1,29 @@
{
"PASSES" : 1,
"STOP" : [ 1.0, 1.0 ],
"DIAGS" : [ "phi", "theta", "tilt", "x", "y", "z" ],
"PRE_ACTIONS" : {
"scienta.passEnergyDev" : "10",
"scienta.acquisitionModeDev" : "Fixed",
"scienta.energyModeDev" : "Kinetic",
"scienta.lensModeDev" : "A30L_01",
"scienta.detectorModeDev" : "ADC",
"scienta.lowEnergy" : 33.0,
"scienta.centerEnergy" : 34.5,
"scienta.highEnergy" : 35.0,
"scienta.energyStepSize" : 0.005,
"scienta.centerThetaX" : 0.0,
"scienta.slices" : 601,
"scienta.channels" : 801
},
"COMPRESSION" : true,
"SENSORS" : [ "scienta.dataMatrix", "current" ],
"ZIGZAG" : false,
"SETTLING_TIME" : 0.0,
"MONITORS" : [ "current" ],
"START" : [ 0.0, 0.0 ],
"RANGE" : [ 900, 100, 750, 150 ],
"POSITIONERS" : [ "x", "y" ],
"STEPS" : [ 4, 4 ],
"SNAPS" : [ "acmi", "cff", "energy", "exit_slit", "fe_horiz_width", "fe_vert_width", "helium_valve", "master", "pgm_cff", "photon_energy", "tcmp", "temp_boot1", "temp_boot2", "temp_cryopump", "temp_cryostat", "temp_headmech", "temp_sample1", "temp_sample2", "temp_shield" ]
}
+8 -17
View File
@@ -1,25 +1,16 @@
{
"PASSES" : 1,
"STOP" : [ 1.0 ],
"STOP" : [ ],
"DIAGS" : [ "phi", "theta", "tilt", "x", "y", "z" ],
"PRE_ACTIONS" : {
"scienta.passEnergyDev" : "20",
"scienta.acquisitionModeDev" : "Fixed",
"scienta.energyModeDev" : "Kinetic",
"scienta.lensModeDev" : "Transmission",
"scienta.detectorModeDev" : "ADC",
"scienta.slices" : 512,
"scienta.channels" : 512,
"y" : 0.1
},
"PRE_ACTIONS" : { },
"COMPRESSION" : true,
"SENSORS" : [ "scienta.dataMatrix", "keithley11" ],
"ZIGZAG" : true,
"SENSORS" : [ "scienta.dataMatrix" ],
"ZIGZAG" : false,
"SETTLING_TIME" : 0.0,
"MONITORS" : [ "current" ],
"START" : [ 0.0 ],
"START" : [ ],
"RANGE" : [ null, null, null, null ],
"POSITIONERS" : [ "x" ],
"STEPS" : [ 9 ],
"SNAPS" : [ "acmi", "energy", "exit_slit", "fe_horiz_width", "fe_vert_width", "helium_valve", "master", "tcmp", "temp_boot1", "temp_boot2", "temp_cryopump", "temp_cryostat", "temp_headmech", "temp_sample1", "temp_sample2", "temp_shield" ]
"POSITIONERS" : [ ],
"STEPS" : [ ],
"SNAPS" : [ "acmi", "cff", "energy", "exit_slit", "fe_horiz_width", "fe_vert_width", "helium_valve", "master", "pgm_cff", "photon_energy", "tcmp", "temp_boot1", "temp_boot2", "temp_cryopump", "temp_cryostat", "temp_headmech", "temp_sample1", "temp_sample2", "temp_shield" ]
}
+1 -3
View File
@@ -2,9 +2,7 @@
"PASSES" : 1,
"STOP" : [ ],
"DIAGS" : [ "phi", "theta", "tilt", "x", "y", "z" ],
"PRE_ACTIONS" : {
"scienta.lensModeDev" : "A14_08"
},
"PRE_ACTIONS" : { },
"COMPRESSION" : true,
"SENSORS" : [ "scienta.dataMatrix" ],
"ZIGZAG" : false,
+14 -5
View File
@@ -1,5 +1,6 @@
from collections import OrderedDict
time.sleep(2.0)
1/0
#Debugging
if get_exec_pars().args is None:
PRE_ACTIONS = {z:0.1}
@@ -77,11 +78,19 @@ if COMPRESSION:
def before_read(pos, scan):
trigger_scienta()
def after_read(rec, scan):
#handle_diagnostics(rec)
pass
data_3d = (scienta.dataMatrix in sensors) and (str(scienta.getAcquisitionMode())=="Swept_Energy_ThetaY")
def after_read(rec, scan):
global data_3d
#handle_diagnostics(rec)
#data_3d = (scienta.dataMatrix in sensors) and (scienta.arraySize2.read()>1)
if data_3d:
try:
path = get_exec_pars().scanPath + ("/3d_images/%04d" % rec.index)
data = scienta.takeStack()
save_dataset(path, data)
except:
log(sys.exc_info()[1])
try:
if len(positioners)==0:
ret= tscan (sensors, 1,0, passes=passes, \