58 lines
1.7 KiB
Python
58 lines
1.7 KiB
Python
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_sp"
|
|
shared = False
|
|
#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)
|
|
|
|
#Enforce the same timestamp to data & image files.
|
|
set_exec_pars(open = False)
|
|
data_file = get_exec_pars().path
|
|
snapshot_file = data_file+ ".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)
|
|
|
|
set_return([data_file, snapshot_file]) |