class Detector(DeviceBase): 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): 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) self.send_cmd("START") self.setState(State.Busy) def stop(self): self.state.assertIs(State.Busy) 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 def set_pars(self, pars): if type(pars) == dict or isinstance(pars, java.util.Map) : 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, 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/eiger", json=data, headers=headers) def doClose(self): pass