Files
x12sa-eiger/script/devices/StdDaq.py
gac-x12sa f4daee6c25 Closedown
2023-01-05 14:36:23 +01:00

70 lines
2.3 KiB
Python

class StdDaq(DeviceBase):
def __init__(self, name, url, simulated=False):
DeviceBase.__init__(self, name)
self.url=url
self.req_id = None
if simulated:
self.setSimulated()
self.simulated_id=1
self.simulated_config = {
"detector_name": "eg",
"detector_type": "eiger",
"n_modules": 2,
"bit_depth": 32,
"image_pixel_height": 514,
"image_pixel_width": 1030,
"start_udp_port": 50000
}
def doInitialize(self):
pass
def start(self, n_images, output_file):
self.state.assertIs(State.Ready)
if not self.simulated:
data = {"sources":"eiger", "n_images":10, "output_file":"/tmp/test.h5"}
headers = {'Content-type': 'application/json'}
r = requests.post(url = self.url + "/write_async", json=data, headers=headers)
self.req_id = int(str(r.json()["request_id"]))
else:
self.req_id = self.simulated_id
self.simulated_id=self.simulated_id+1
self.setCache(self.req_id, None)
self.setState(State.Busy)
fork (self.monitor)
def stop(self):
self.state.assertIs(State.Busy)
if not self.simulated:
data = {"request_id":self.req_id}
headers = {'Content-type': 'application/json'}
r = requests.post(url = self.url + "/write_kill", json=data, headers=headers)
self.setCache(None, None)
self.setState(State.Ready)
def monitor(self):
count=0
print "Enter"
while getState==State.Busy:
time.sleep(1.0)
count=count+1
if count==3:
self.setCache(None, None)
self.setState(State.Ready)
def get_config(self):
if self.simulated:
return self.simulated_config
def set_config(self, config):
if type(config) == dict or isinstance(config, java.util.Map) :
if self.simulated:
self.simulated_config=config
def doClose(self):
pass