This commit is contained in:
root
2017-11-02 08:53:26 +01:00
parent ccb0d3ff80
commit fa5cd8e408
7 changed files with 272 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
import ch.psi.pshell.imaging.ImageBuffer as ImageBuffer
import java.math.BigInteger as BigInteger
import org.python.core.PyLong as PyLong
import json
if get_exec_pars().source == CommandSource.ui:
camera_name = "SLG-LCAM-C041"
shared = True
logbook = "SwissFEL commissioning data"
comment = "Test"
else:
camera_name = args[0]
shared = args[1].lower() == "true"
logbook = args[2]
comment = args[3]
set_exec_pars(name="camera_snapshot")
path = "/image"
snapshotFile = None
if shared:
cam_server.start(camera_name + "_sp1", shared)
else:
cam_server.start(camera_name)
cam_server.waitNext(10000)
stream_value = cam_server.stream.take()
save_dataset(path, cam_server.data.matrix)
for id in stream_value.identifiers:
val = stream_value.getValue(id)
if id == "image":
pass
elif id == "processing_parameters":
val = json.loads(val)
for key in val.keys():
set_attribute(path, key, "" if val[key] is None else val[key] )
elif isinstance(val, PyArray):
save_dataset("/"+id, val)
elif isinstance(val, PyLong):
save_dataset("/"+id, int(val))
else:
set_attribute(path, id, val)
set_exec_pars(open = False)
#Enforce the same timestamp to data & image files.
snapshot_file = get_exec_pars().path+ ".png";
ImageBuffer.saveImage(cam_server.output, snapshot_file, "png");
msg = "Camera: " + camera_name
msg += "\nShared: " + str(shared)
msg += "\nData file: " + str(get_exec_pars().path)
msg += "\nComment: " + str(comment)
elog("Camera Snapshot", msg, [snapshot_file,], logbook=logbook)

View File

@@ -0,0 +1,10 @@
def save_snapshot(camera_name = "SLG-LCAM-C041", shared = True, logbook = "SwissFEL commissioning data", comment = ""):
import requests
base = "http://sf-daq-mgmt:8090/"
url = base + "run/Tools/save_snapshot(%s,%s,%s,%s)" % (camera_name, str(shared), logbook, "'" + str(comment) + "'")
r = requests.get(url)
if r.status_code != 200:
raise Exception(r.text)
save_snapshot()