Included TimeResolved scan

This commit is contained in:
gac-ISS
2021-08-04 10:24:42 +02:00
parent de5ac790eb
commit 424071d9ff
7 changed files with 715 additions and 51 deletions

View File

@@ -1 +1,2 @@
TimeResolved.java=enabled
EnergyScan.java=enabled

View File

@@ -1,2 +1,2 @@
#Wed Aug 04 08:34:55 CEST 2021
FileSequentialNumber=14
#Wed Aug 04 10:23:44 CEST 2021
FileSequentialNumber=30

222
plugins/TimeResolved.form Normal file
View File

@@ -0,0 +1,222 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JEditorPane" name="jEditorPane1">
</Component>
</SubComponents>
</Container>
</NonVisualComponents>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel2" alignment="1" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="buttonStart" linkSize="3" min="-2" pref="150" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="33" max="-2" attributes="0"/>
<Component id="buttonAbort" linkSize="3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="buttonResetId" linkSize="4" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="buttonScienta" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="textFileId" linkSize="4" min="-2" pref="67" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jPanel2" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="7" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textFileId" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonScienta" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonResetId" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonStart" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonAbort" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonStart">
<Properties>
<Property name="text" type="java.lang.String" value="Start"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonStartActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonAbort">
<Properties>
<Property name="text" type="java.lang.String" value="Abort"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonAbortActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonScienta">
<Properties>
<Property name="text" type="java.lang.String" value="Scienta Panel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonScientaActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JPanel" name="jPanel2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Parameters"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel3" linkSize="7" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerScans" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" linkSize="7" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="textName" max="32767" attributes="0"/>
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<Component id="buttonOpen" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="buttonSave" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="14" pref="14" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="textName" alignment="3" max="32767" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonOpen" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonSave" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerScans" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="166" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="Scans:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerScans">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="10" maximum="1000000" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Name:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textName">
</Component>
<Component class="javax.swing.JButton" name="buttonOpen">
<Properties>
<Property name="text" type="java.lang.String" value="Open"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonOpenActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonSave">
<Properties>
<Property name="text" type="java.lang.String" value="Save"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonSaveActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="File ID:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textFileId">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonResetId">
<Properties>
<Property name="text" type="java.lang.String" value="Reset"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonResetIdActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

388
plugins/TimeResolved.java Normal file
View File

@@ -0,0 +1,388 @@
import ch.psi.pshell.core.JsonSerializer;
import ch.psi.pshell.ui.PanelProcessor;
import ch.psi.utils.IO;
import ch.psi.utils.State;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;
/**
*
*/
public class TimeResolved extends PanelProcessor {
File currentFile;
public static final String FILE_EXTENSION = "tmr";
public TimeResolved() {
initComponents();
}
@Override
public String getType() {
return "Time Resolved";
}
@Override
public boolean createMenuNew() {
return true;
}
@Override
public boolean createFilePanel() {
return true;
}
@Override
public String getDescription() {
return "Time Resolved scan definition file (*." + FILE_EXTENSION + ")";
}
@Override
public String[] getExtensions() {
return new String[]{FILE_EXTENSION};
}
@Override
public String getHomePath() {
return "{home}/parameters";
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
}
@Override
public void onStateChange(State state, State former) {
buttonStart.setEnabled(state == State.Ready);
buttonAbort.setEnabled(state.isProcessing());
buttonScienta.setEnabled(state.isInitialized());
updateSeq();
}
void updateSeq() {
try {
textFileId.setText(String.valueOf(getContext().getFileSequentialNumber()));
} catch (Exception ex) {
textFileId.setText("");
}
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
//Callback to perform update - in event thread
@Override
protected void doUpdate() {
}
String getScanName() {
String name = textName.getText().trim();
return name.isEmpty() ? null : name;
}
@Override
public void execute() throws Exception {
String lastOutput = getContext().getDataManager().getLastOutput();
HashMap args = new HashMap();
args.put("FILE", null);
args.put("NAME", getScanName());
args.put("SCANS", spinnerScans.getValue());
this.runAsync("templates/TimeResolved", args).handle((ret, ex) -> {
if (ex != null) {
}
return ret;
});
}
@Override
public void saveAs(String fileName) throws IOException {
currentFile = new File(fileName);
ArrayList data = new ArrayList();
data.add(textName.getText());
data.add(spinnerScans.getValue());
String json = JsonSerializer.encode(data, true);
Files.write(currentFile.toPath(), json.getBytes());
}
@Override
public void open(String fileName) throws IOException {
if (fileName==null){
currentFile = null;
textName.setText("");
spinnerScans.setValue(0);
} else {
Path path = Paths.get(fileName);
String json = new String(Files.readAllBytes(path));
currentFile = path.toFile();
Object[] vector = (Object[]) JsonSerializer.decode(json, Object[].class);
textName.setText(String.valueOf(vector[0]));
spinnerScans.setValue(vector[1]);
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane2 = new javax.swing.JScrollPane();
jEditorPane1 = new javax.swing.JEditorPane();
buttonStart = new javax.swing.JButton();
buttonAbort = new javax.swing.JButton();
buttonScienta = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
spinnerScans = new javax.swing.JSpinner();
jLabel1 = new javax.swing.JLabel();
textName = new javax.swing.JTextField();
buttonOpen = new javax.swing.JButton();
buttonSave = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
textFileId = new javax.swing.JTextField();
buttonResetId = new javax.swing.JButton();
jScrollPane2.setViewportView(jEditorPane1);
buttonStart.setText("Start");
buttonStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonStartActionPerformed(evt);
}
});
buttonAbort.setText("Abort");
buttonAbort.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonAbortActionPerformed(evt);
}
});
buttonScienta.setText("Scienta Panel");
buttonScienta.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonScientaActionPerformed(evt);
}
});
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameters"));
jLabel3.setText("Scans:");
spinnerScans.setModel(new javax.swing.SpinnerNumberModel(10, 1, 1000000, 1));
jLabel1.setText("Name:");
buttonOpen.setText("Open");
buttonOpen.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonOpenActionPerformed(evt);
}
});
buttonSave.setText("Save");
buttonSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonSaveActionPerformed(evt);
}
});
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)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerScans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textName)
.addGap(18, 18, 18)
.addComponent(buttonOpen)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonSave)))
.addGap(14, 14, 14))
);
jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel3});
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(textName)
.addComponent(jLabel1)
.addComponent(buttonOpen)
.addComponent(buttonSave))
.addGap(11, 11, 11)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(spinnerScans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(166, Short.MAX_VALUE))
);
jLabel2.setText("File ID:");
textFileId.setEditable(false);
textFileId.setHorizontalAlignment(javax.swing.JTextField.CENTER);
buttonResetId.setText("Reset");
buttonResetId.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonResetIdActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(buttonStart, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(33, 33, 33)
.addComponent(buttonAbort)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(buttonResetId))
.addGroup(layout.createSequentialGroup()
.addComponent(buttonScienta)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textFileId, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())))
);
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonAbort, buttonStart});
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonResetId, textFileId});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(7, 7, 7)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(textFileId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonScienta))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonResetId)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonStart)
.addComponent(buttonAbort))
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
try {
execute();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonStartActionPerformed
private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed
try {
abort();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonAbortActionPerformed
private void buttonScientaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonScientaActionPerformed
try {
this.showDevicePanel("scienta");
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonScientaActionPerformed
private void buttonResetIdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonResetIdActionPerformed
try {
this.getContext().setFileSequentialNumber(0);
updateSeq();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonResetIdActionPerformed
private void buttonOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOpenActionPerformed
try {
open();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonOpenActionPerformed
private void buttonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSaveActionPerformed
try {
JFileChooser chooser = new JFileChooser(getContext().getSetup().expandPath(getHomePath()));
FileNameExtensionFilter filter = new FileNameExtensionFilter(getDescription(), getExtensions());
chooser.setFileFilter(filter);
try {
if (currentFile != null) {
chooser.setSelectedFile(currentFile);
} else if (getScanName() != null) {
File file = Paths.get(chooser.getCurrentDirectory().getAbsolutePath(), getScanName()).toFile();
chooser.setSelectedFile(file);
}
} catch (Exception ex) {
this.showException(ex);
}
int rVal = chooser.showSaveDialog(this);
if (rVal == JFileChooser.APPROVE_OPTION) {
String fileName = chooser.getSelectedFile().getAbsolutePath();
if (IO.getExtension(chooser.getSelectedFile().getAbsolutePath()).isEmpty()) {
fileName += "." + FILE_EXTENSION;
}
saveAs(fileName);
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonSaveActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
private javax.swing.JButton buttonOpen;
private javax.swing.JButton buttonResetId;
private javax.swing.JButton buttonSave;
private javax.swing.JButton buttonScienta;
private javax.swing.JButton buttonStart;
private javax.swing.JEditorPane jEditorPane1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JSpinner spinnerScans;
private javax.swing.JTextField textFileId;
private javax.swing.JTextField textName;
// End of variables declaration//GEN-END:variables
}

View File

@@ -81,3 +81,23 @@ def after_readout(rec):
def trigger_scienta():
"""
Trigger new acquisition
"""
scienta.start()
scienta.waitNewImage(-1)
def dummy_trigger_scienta():
"""
Trigger detector to update the array sizes and calibration
"""
iterations = scienta.getIterations()
scienta.setIterations(1)
try:
trigger_scienta()
finally:
scienta.setIterations(iterations)

View File

@@ -1,48 +1,41 @@
if get_exec_pars().debug:
print "Setting debug parameters"
REGIONS = [[523.0, 527.0, 2.0], [527.0, 535.0, 4.0], [535.0, 558.0, 2.0]]
NAME = None
FILE = None
if FILE:
FILE = get_context().setup.expandPath("{home}/parameters/" + FILE)
import json
with open(FILE) as json_file:
cfg = json.load(json_file)
NAME , REGIONS= cfg[0][0][0], cfg[1]
print "FILE: ", FILE
print "NAME: ", NAME
print "REGIONS: ", REGIONS
IOC_AUTO_SAVE = False
DUMMY_TRIGGER = True #Trigger detector to update the array sizes and calibration
set_device_alias(scienta.getSpectrum(), "spectrum")
set_device_alias(scienta.getDataMatrix(), "image")
set_device_alias(scienta.stats[0], "sum")
sensors=[i0, scienta.stats[0], scienta.getSpectrum()] #), scienta.getDataMatrix()]
def trigger(position, scan):
scienta.start()
scienta.waitNewImage(-1)
if DUMMY_TRIGGER:
iterations = scienta.getIterations()
scienta.setIterations(1)
try:
trigger(None, None)
finally:
scienta.setIterations(iterations)
if IOC_AUTO_SAVE:
capture.write(1)
try:
rscan(energy, sensors, REGIONS, latency = 0.0, before_read=trigger, after_read=after_readout, name = NAME)
finally:
if IOC_AUTO_SAVE:
capture.write(0)
scienta.zeroSupplies()
if get_exec_pars().debug:
print "Setting debug parameters"
REGIONS = [[523.0, 527.0, 2.0], [527.0, 535.0, 4.0], [535.0, 558.0, 2.0]]
NAME = None
FILE = None
if FILE:
FILE = get_context().setup.expandPath("{home}/parameters/" + FILE)
import json
with open(FILE) as json_file:
cfg = json.load(json_file)
NAME , REGIONS= cfg[0][0][0], cfg[1]
print "FILE: ", FILE
print "NAME: ", NAME
print "REGIONS: ", REGIONS
IOC_AUTO_SAVE = False
DUMMY_TRIGGER = True
set_device_alias(scienta.getSpectrum(), "spectrum")
set_device_alias(scienta.getDataMatrix(), "image")
set_device_alias(scienta.stats[0], "sum")
sensors=[i0, scienta.stats[0], scienta.getSpectrum()] #), scienta.getDataMatrix()]
def before_read(position, scan):
trigger_scienta()
if DUMMY_TRIGGER:
dummy_trigger_scienta()
if IOC_AUTO_SAVE:
capture.write(1)
try:
rscan(energy, sensors, REGIONS, latency = 0.0, before_read=before_read, after_read=after_readout, name = NAME)
finally:
if IOC_AUTO_SAVE:
capture.write(0)
scienta.zeroSupplies()

View File

@@ -1,8 +1,48 @@
if get_exec_pars().debug:
print "Setting debug parameters"
SCANS = 10
NAME = None
FILE = None
if FILE:
FILE = get_context().setup.expandPath("{home}/parameters/" + FILE)
import json
with open(FILE) as json_file:
cfg = json.load(json_file)
NAME , SCANS= cfg[0], cfg[1]
print "FILE: ", FILE
print "SCANS: ", SCANS
"""
scienta.getState().assertReady()
current_spectrum=scienta.getSpectrum().take()
scienta.start()
try:
scienta.getSpectrum().waitValueNot(current_spectrum, -1)
mscan(scienta.getSpectrum(), scienta.getSpectrum(), scienta.getIterations(), -1, take_initial=True)
except:
scienta.stop()
scienta.zeroSupplies()
"""
set_device_alias(scienta.getSpectrum(), "spectrum")
sensors=[i0, scienta.getSpectrum()]
def before_read(position, scan):
trigger_scienta()
mscan(scienta.getSpectrum(), scienta.getSpectrum(), scienta.getIterations() -1)
dummy_trigger_scienta()
try:
tscan(sensors, SCANS, 0.001, before_read=before_read, after_read=after_readout, name = NAME)
finally:
scienta.zeroSupplies()