Closedown

This commit is contained in:
gac-x12sa
2023-01-05 15:06:47 +01:00
parent 79566cb477
commit f6c1a860ae
4 changed files with 62 additions and 10 deletions
+38 -6
View File
@@ -349,18 +349,50 @@ public class Eiger extends Panel {
}
return ret;
});
});
}
} catch (Exception ex){
showException(ex);
}
}
}//GEN-LAST:event_buttonConfigActionPerformed
private void buttonConfigDetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfigDetActionPerformed
// TODO add your handling code here:
try{
if (stddaq!=null){
String title = "Detector Config";
this.evalAsync("detector.get_config()").handle((ret,ex)->{
if (ex!=null){
showException((Exception) ex);
} else {
try{
Map cfg = (Map) ret;
String json = EncoderJson.encode(cfg, true);
ScriptDialog dlg = new ScriptDialog(getWindow(), true, title, json, "json");
dlg.setVisible(true);
if (dlg.getResult()){
json = dlg.getText();
cfg = (Map) EncoderJson.decode(json, Map.class);
setGlobalVar("_detector_config", cfg);
evalAsync("detector.set_config(_detector_config)").handle((r,e)->{
if (e!=null){
showException((Exception) e);
} else {
showMessage(title, "Success updating config");
}
return ret;
});
}
} catch (Exception e){
showException(e);
}
}
return ret;
});
}
} catch (Exception ex){
showException(ex);
}
}//GEN-LAST:event_buttonConfigDetActionPerformed
private void buttonParsDetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonParsDetActionPerformed
+21 -2
View File
@@ -1,8 +1,10 @@
class Detector(DeviceBase):
def __init__(self, name, simulated=False):
DeviceBase.__init__(self, name)
def __init__(self, name, url, simulated=False):
DeviceBase.__init__(self, name)
self.url = url
if simulated:
self.setSimulated()
self.simulated_config={'det_name': 'EIGER', 'dr': 16, 'exptime': 1.0, 'frames': 100, 'period': 0.01, 'speed': 'speedLevel.FULL_SPEED', 'tengiga': True, 'threshold': -1, 'timing': 'timingMode.AUTO_TIMING', 'triggers': 1}
self.simulated_pars = {}
def doInitialize(self):
@@ -29,5 +31,22 @@ class Detector(DeviceBase):
if self.simulated:
self.simulated_pars=pars
def get_config(self):
if self.simulated:
return self.simulated_config
else:
return requests.get(url = "http://127.0.0.1:5000/detector/eiger")
def set_config(self, ):
if type(config) == dict or isinstance(config, java.util.Map) :
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)
def doClose(self):
pass
+2 -1
View File
@@ -67,12 +67,13 @@ class StdDaq(DeviceBase):
def get_config(self):
if self.simulated:
return self.simulated_config
#TODO
def set_config(self, config):
if type(config) == dict or isinstance(config, java.util.Map) :
if self.simulated:
self.simulated_config=config
#TODO
def doClose(self):
pass
+1 -1
View File
@@ -29,5 +29,5 @@ add_device(RegisterMatrixSource("image", stream.devMatrix), True)
stream.devMatrix.modulo = DETECTOR_IMAGE_MODULO
add_device(Detector("detector", True), True)
add_device(Detector("detector", STD_DAQ_ADDRESS, True), True)
add_device(StdDaq("std_daq", STD_DAQ_ADDRESS, True), True)