Closedown

This commit is contained in:
gac-x12sa
2023-01-06 09:23:34 +01:00
parent 12d61a6ceb
commit 152ebac918
3 changed files with 121 additions and 50 deletions

View File

@@ -72,6 +72,7 @@
<Component id="buttonStartDet" alignment="0" max="32767" attributes="0"/>
<Component id="buttonStopDet" alignment="0" max="32767" attributes="0"/>
<Component id="buttonParsDet" alignment="0" max="32767" attributes="0"/>
<Component id="buttonApplyConfigDet" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -87,6 +88,8 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonStopDet" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="32767" attributes="0"/>
<Component id="buttonApplyConfigDet" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="32767" attributes="0"/>
<Component id="buttonConfigDet" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonParsDet" min="-2" max="-2" attributes="0"/>
@@ -140,6 +143,14 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonParsDetActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonApplyConfigDet">
<Properties>
<Property name="text" type="java.lang.String" value="Apply Config"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonApplyConfigDetActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel2">
@@ -192,32 +203,34 @@
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buttonConfig" max="32767" attributes="0"/>
<Component id="deviceStatePanel1" alignment="0" max="32767" attributes="0"/>
<Group type="103" alignment="1" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="spinnerImages" linkSize="4" alignment="1" pref="109" max="32767" attributes="0"/>
<Component id="textFile" linkSize="4" alignment="1" pref="109" max="32767" attributes="0"/>
</Group>
</Group>
<Component id="buttonStart" alignment="1" max="32767" attributes="0"/>
</Group>
<Component id="buttonStart" alignment="1" max="32767" attributes="0"/>
<Component id="buttonStop" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="deviceValuePanel1" linkSize="4" pref="109" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="spinnerImages" linkSize="4" alignment="1" pref="109" max="32767" attributes="0"/>
<Component id="textFile" linkSize="4" alignment="1" pref="109" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="deviceValuePanel1" linkSize="4" pref="109" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
<Component id="buttonStop" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>

View File

@@ -98,6 +98,7 @@ public class Eiger extends Panel {
buttonConfigDet = new javax.swing.JButton();
deviceStatePanel2 = new ch.psi.pshell.swing.DeviceStatePanel();
buttonParsDet = new javax.swing.JButton();
buttonApplyConfigDet = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
renderer = new ch.psi.pshell.imaging.Renderer();
jPanel3 = new javax.swing.JPanel();
@@ -145,6 +146,13 @@ public class Eiger extends Panel {
}
});
buttonApplyConfigDet.setText("Apply Config");
buttonApplyConfigDet.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonApplyConfigDetActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
@@ -160,7 +168,8 @@ public class Eiger extends Panel {
.addComponent(buttonConfigDet, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonStartDet, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonStopDet, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonParsDet, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(buttonParsDet, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonApplyConfigDet, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())))
);
jPanel1Layout.setVerticalGroup(
@@ -171,6 +180,8 @@ public class Eiger extends Panel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonStopDet)
.addGap(18, 18, Short.MAX_VALUE)
.addComponent(buttonApplyConfigDet)
.addGap(18, 18, Short.MAX_VALUE)
.addComponent(buttonConfigDet)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonParsDet)
@@ -243,25 +254,26 @@ public class Eiger extends Panel {
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(buttonConfig, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(deviceStatePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(6, 6, 6))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(spinnerImages, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
.addComponent(textFile, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)))
.addComponent(buttonStart, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(buttonStart, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonStop, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(deviceValuePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE))
.addComponent(buttonStop, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(6, 6, 6))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(spinnerImages, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
.addComponent(textFile, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(deviceValuePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)))))
.addContainerGap())
);
@@ -441,7 +453,12 @@ public class Eiger extends Panel {
if (stddaq!=null){
int images = (Integer)spinnerImages.getValue();
String file = textFile.getText();
evalAsync("std_daq.start(" + images + ", '" + file + "')");
evalAsync("std_daq.start(" + images + ", '" + file + "')").handle((r,e)->{
if (e!=null){
showException((Exception) e);
}
return r;
});
}
} catch (Exception ex){
showException(ex);
@@ -451,7 +468,12 @@ public class Eiger extends Panel {
private void buttonStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStopActionPerformed
try{
if (stddaq!=null){
evalAsync("std_daq.abort()");
evalAsync("std_daq.abort()").handle((r,e)->{
if (e!=null){
showException((Exception) e);
}
return r;
});
}
} catch (Exception ex){
showException(ex);
@@ -461,7 +483,12 @@ public class Eiger extends Panel {
private void buttonStartDetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartDetActionPerformed
try{
if (stddaq!=null){
evalAsync("detector.start()");
evalAsync("detector.start()").handle((r,e)->{
if (e!=null){
showException((Exception) e);
}
return r;
});
}
} catch (Exception ex){
showException(ex);
@@ -471,14 +498,35 @@ public class Eiger extends Panel {
private void buttonStopDetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStopDetActionPerformed
try{
if (stddaq!=null){
evalAsync("detector.stop()");
evalAsync("detector.stop()").handle((r,e)->{
if (e!=null){
showException((Exception) e);
}
return r;
});
}
} catch (Exception ex){
showException(ex);
}
}//GEN-LAST:event_buttonStopDetActionPerformed
private void buttonApplyConfigDetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonApplyConfigDetActionPerformed
try{
if (stddaq!=null){
evalAsync("detector.apply_config()").handle((r,e)->{
if (e!=null){
showException((Exception) e);
}
return r;
});
}
} catch (Exception ex){
showException(ex);
}
}//GEN-LAST:event_buttonApplyConfigDetActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonApplyConfigDet;
private javax.swing.JButton buttonConfig;
private javax.swing.JButton buttonConfigDet;
private javax.swing.JButton buttonParsDet;

View File

@@ -9,19 +9,28 @@ class Detector(DeviceBase):
def doInitialize(self):
pass
def send_cmd(self, cmd):
print "Send detector command: ", cmd
if not self.simulated:
data = {"det_name":"eiger","cmd":cmd}
headers = {'Content-type': 'application/json'}
r = requests.post(url = self.url + "/detector/eiger", json=data, headers=headers)
def start(self):
self.state.assertIs(State.Ready)
if not self.simulated:
pass
self.send_cmd("START")
self.setState(State.Busy)
def stop(self):
self.state.assertIs(State.Busy)
if not self.simulated:
pass
self.send_cmd("STOP")
self.setState(State.Ready)
def apply_config(self):
self.state.assertIs(State.Ready)
self.send_cmd("SET_CONFIG")
def get_pars(self):
if self.simulated:
return self.simulated_pars
@@ -40,12 +49,13 @@ class Detector(DeviceBase):
def set_config(self, config):
if type(config) == dict or isinstance(config, java.util.Map) :
print "Send detector config: ", config
if self.simulated:
self.simulated_config=config
else:
data = {"det_name":"eiger","config":config}
headers = {'Content-type': 'application/json'}
r = requests.post(url = self.url + "/detector", json=data, headers=headers)
r = requests.post(url = self.url + "/detector/eiger", json=data, headers=headers)
def doClose(self):