This commit is contained in:
2021-09-30 16:45:20 +02:00
8 changed files with 238 additions and 68 deletions
+24 -1
View File
@@ -12,6 +12,7 @@ BUILD_PATH='/home/hax_l/sf_daq_buffer/build/'
UDP_RECV='std_udp_recv'
UDP_SYNC='std_udp_sync'
EIGER_ASSEMBLER='eiger_assembler'
STD_STREAM_SEND='std_stream_send'
STD_DET_WRITER='std_det_writer'
# default config file
@@ -22,6 +23,7 @@ HELP_FLAG=0
# CONFIGURATION
BIT_DEPTH=16
N_MPI_EXEC=3
STREAM_NAME='streamvis'
while getopts h:c:b:m: flag
do
case "${flag}" in
@@ -29,15 +31,17 @@ do
c ) CONFIG_FILE=${OPTARG};;
b ) BIT_DEPTH=${OPTARG};;
m ) N_MPIT_EXEC=${OPTARG};;
s ) STREAMVIS=${OPTARG};;
esac
done
# prints help and exits
if (( ${HELP_FLAG} == 1 )); then
echo "Usage : $0 -h <help_flag> -c <config_file> -b <bit_depth>"
echo "Usage : $0 -h <help_flag> -c <config_file> -b <bit_depth> -s <stream_name>"
echo " help_flag : show this help and exits."
echo " config_file : detector configuration file."
echo " bit_depth : detector bit depth."
echo " stream name : live stream name."
exit
fi
@@ -127,6 +131,25 @@ else
exit
fi
# Start the stream
echo "Starting the ${STD_STREAM_SEND}..."
if [ -f "${BUILD_PATH}${STD_STREAM_SEND}" ]; then
if [ -f "${CONFIG_FILE}" ]; then
if [ ${BIT_DEPTH} -ne 0 ]; then
${BUILD_PATH}${STD_STREAM_SEND} ${CONFIG_FILE} ${BIT_DEPTH} ${STREAM_NAME} &
else
echo "Error: ${BIT_DEPTH} can't be zero..."
exit
fi
else
echo "Something went wrong while starting the ${STD_STREAM_SEND}..."
exit
fi
else
echo "Error: ${STD_STREAM_SEND} wasn't found..."
exit
fi
# Start the eiger writer
echo "Starting the ${STD_DET_WRITER}..."
export PATH="/usr/lib64/mpich-3.2/bin:${PATH}";
+49
View File
@@ -0,0 +1,49 @@
from _ctypes import Structure
from ctypes import c_uint64, c_uint16
import zmq
image_metadata_dtype_mapping = {
1: 'uint8',
2: 'uint16',
4: 'uint32',
8: 'uint64',
12: 'float16',
14: 'float32',
18: 'float64'
}
class ImageMetadata(Structure):
_pack_ = 1
_fields_ = [
("version", c_uint64),
("id", c_uint64),
("height", c_uint64),
("width", c_uint64),
("dtype", c_uint16),
("encoding", c_uint16),
("source_id", c_uint16),
("status", c_uint16),
("user_1", c_uint64),
("user_2", c_uint64),]
def as_dict(self):
return dict((f, getattr(self, f)) for f, _ in self._fields_)
flags=0
zmq_context = zmq.Context(io_threads=4)
poller = zmq.Poller()
backend_socket = zmq_context.socket(zmq.SUB)
backend_socket.setsockopt_string(zmq.SUBSCRIBE, "")
backend_socket.connect("ipc:///tmp/std-daq-cSAXS.EG01V01-image_stream")
poller.register(backend_socket, zmq.POLLIN)
while True:
events = dict(poller.poll(2000))
if backend_socket in events:
metadata = ImageMetadata.from_buffer_copy(backend_socket.recv(flags))
image = backend_socket.recv(flags, copy=False, track=False)
print(f"Recv img id: {metadata.id}")
else:
print("nothing")