mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-01 23:52:22 +02:00
cleanup and organization for eiger on xbl-daq-28
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/home/dbe/miniconda3/bin:$PATH:/home/hax_l/sf_daq_buffer/slsDetectorPackage/build/bin/
|
||||
source /home/dbe/miniconda3/etc/profile.d/conda.sh
|
||||
conda deactivate
|
||||
conda activate sf-daq
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z ${SLS_DET_PACKAGE_PATH} ]; then SLS_DET_PACKAGE_PATH="/home/hax_l/software/sf_daq_buffer/slsDetectorPackage/build/bin/"; fi
|
||||
|
||||
${SLS_DET_PACKAGE_PATH}sls_detector_put triggers 1
|
||||
${SLS_DET_PACKAGE_PATH}sls_detector_put timing trigger
|
||||
${SLS_DET_PACKAGE_PATH}sls_detector_put exptime 0.000005
|
||||
${SLS_DET_PACKAGE_PATH}sls_detector_put frames 1
|
||||
${SLS_DET_PACKAGE_PATH}sls_detector_put dr 16
|
||||
${SLS_DET_PACKAGE_PATH}sls_detector_put start
|
||||
|
||||
echo "Acquisition started..."
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# default port 2050 and 2052
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
PORT=2050
|
||||
PORT_SLAVE=2052
|
||||
elif [ $# -eq 1 ]
|
||||
then
|
||||
PORT=$1
|
||||
PORT_SLAVE=$(( $1 + 2 ))
|
||||
else
|
||||
echo "Usage : $0 <port>"
|
||||
echo " tcp port : optional, default 2050"
|
||||
exit
|
||||
fi
|
||||
|
||||
SLS_DET_PACKAGE_PATH='/home/hax_l/software/sf_daq_buffer/slsDetectorPackage/build/bin/'
|
||||
|
||||
|
||||
echo "Starting the master eiger virtual detector at port ${PORT}..."
|
||||
|
||||
if [ -f "${SLS_DET_PACKAGE_PATH}eigerDetectorServerMaster_virtual" ]; then
|
||||
${SLS_DET_PACKAGE_PATH}eigerDetectorServerMaster_virtual -p ${PORT} &
|
||||
else
|
||||
echo "Eiger master was not found at ${SLS_DET_PACKAGE_PATH}."
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "Starting the slave bottom eiger virtual detector at port ${PORT_SLAVE}..."
|
||||
|
||||
if [ -f "${SLS_DET_PACKAGE_PATH}eigerDetectorServerSlaveBottom_virtual" ]; then
|
||||
${SLS_DET_PACKAGE_PATH}eigerDetectorServerSlaveBottom_virtual -p ${PORT} &
|
||||
else
|
||||
echo "Eiger slave bottom was not found at ${SLS_DET_PACKAGE_PATH}."
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import socket
|
||||
import numpy as np
|
||||
import sys
|
||||
|
||||
frame_header_dt = np.dtype(
|
||||
[
|
||||
@@ -19,19 +20,20 @@ frame_header_dt = np.dtype(
|
||||
]
|
||||
)
|
||||
|
||||
#ip = "10.30.40.211"
|
||||
ip = sys.argv[1]
|
||||
|
||||
ip = "10.30.20.6"
|
||||
ports = list(range(50200, 50204, 1))
|
||||
ports = list(range(50000, 50004, 1))
|
||||
sockets = [socket.socket(socket.AF_INET, socket.SOCK_DGRAM) for i in range(len(ports))]
|
||||
|
||||
for s, p in zip(sockets, ports):
|
||||
print("IP:Port: ", ip, p)
|
||||
s.bind((ip, p))
|
||||
print(ip,p)
|
||||
s.bind((ip,p))
|
||||
|
||||
while True:
|
||||
for s in sockets:
|
||||
data, address = s.recvfrom(4096)
|
||||
h = np.frombuffer(data, count=1, dtype=frame_header_dt)[0]
|
||||
print(
|
||||
f'pkt:{h["Packet Number"]}, frame: {h["Frame Number"]}, row: {h["Row"]}, column: {h["Column"]}'
|
||||
)
|
||||
f'[{h["Timestamp"]}] frame: {h["Frame Number"]}, pkt:{h["Packet Number"]}, explength:{h["SubFrame Number/ExpLength"]}, module id: {h["Module Id"]} ,row: {h["Row"]}, column: {h["Column"]}'
|
||||
)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python
|
||||
from datetime import datetime
|
||||
from slsdet import Eiger
|
||||
n_test = 10
|
||||
n_frames = 1000
|
||||
d = Eiger()
|
||||
#d.nextframenumber = 1
|
||||
#d.frames = n_frames
|
||||
#d.period = 0.001
|
||||
#d.exptime = 0.0005
|
||||
|
||||
for i in range(0,n_test):
|
||||
d.acquire()
|
||||
next_fn = d.nextframenumber
|
||||
print(datetime.now(), ' ', next_fn)
|
||||
#if not isinstance(next_fn, int):
|
||||
# raise ValueError(f'Frame numbers differ: {next_fn}')
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"size": "medium",
|
||||
"price": 15.67,
|
||||
"toppings": ["mushrooms", "pepperoni", "basil"],
|
||||
"extra_cheese": false,
|
||||
"delivery": true,
|
||||
"client": {
|
||||
"name": "Jane Doe",
|
||||
"phone": null,
|
||||
"email": "janedoe@email.com"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
import json
|
||||
import sys
|
||||
|
||||
config_file = '/home/dbe/sls/hosts/xbl-daq-28/cSAXS.EG01V01.json'
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print("error... bit depth argument missing")
|
||||
|
||||
bit_d = sys.argv[1]
|
||||
|
||||
with open(config_file) as f:
|
||||
content = json.load(f)
|
||||
|
||||
content['bit_depth'] = int(bit_d)
|
||||
#f.truncate(0)
|
||||
#json.dump(content, f, indent='\t', separators=(',', ': '))
|
||||
|
||||
with open(config_file, 'w') as f:
|
||||
f.seek(0)
|
||||
json.dump(content, f, indent='\t')
|
||||
|
||||
#os.chdir('/home/dbe/sls/hosts/xbl-daq-28/')
|
||||
#rc = os.system(f'git pull && git add {config_file} && git commit -m "[LOG] config test change push" && git push')
|
||||
#print('result value: ', rc)
|
||||
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
import socket
|
||||
import numpy as np
|
||||
import sys
|
||||
|
||||
frame_header_dt = np.dtype(
|
||||
[
|
||||
("Frame Number", "u8"),
|
||||
("SubFrame Number/ExpLength", "u4"),
|
||||
("Packet Number", "u4"),
|
||||
("Bunch ID", "u8"),
|
||||
("Timestamp", "u8"),
|
||||
("Module Id", "u2"),
|
||||
("Row", "u2"),
|
||||
("Column", "u2"),
|
||||
("Reserved", "u2"),
|
||||
("Debug", "u4"),
|
||||
("Round Robin Number", "u2"),
|
||||
("Detector Type", "u1"),
|
||||
("Header Version", "u1"),
|
||||
]
|
||||
)
|
||||
|
||||
#ip = "10.30.40.211"
|
||||
ip = sys.argv[1]
|
||||
|
||||
ports = list(range(50000, 50004, 1))
|
||||
sockets = [socket.socket(socket.AF_INET, socket.SOCK_DGRAM) for i in range(len(ports))]
|
||||
|
||||
for s, p in zip(sockets, ports):
|
||||
print(ip,p)
|
||||
s.bind((ip,p))
|
||||
|
||||
while True:
|
||||
for s in sockets:
|
||||
data, address = s.recvfrom(4096)
|
||||
h = np.frombuffer(data, count=1, dtype=frame_header_dt)[0]
|
||||
print(
|
||||
f'[{h["Timestamp"]}] frame: {h["Frame Number"]}, pkt:{h["Packet Number"]}, explength:{h["SubFrame Number/ExpLength"]}, module id: {h["Module Id"]} ,row: {h["Row"]}, column: {h["Column"]}'
|
||||
)
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
from slsdet import Eiger
|
||||
n_test = 1000
|
||||
n_frames = 1000
|
||||
d = Eiger()
|
||||
d.nextframenumber = 1
|
||||
d.frames = n_frames
|
||||
d.period = 0.001
|
||||
d.exptime = 0.0005
|
||||
|
||||
for i in range(0,n_test):
|
||||
d.acquire()
|
||||
next_fn = d.nextframenumber
|
||||
print(next_fn)
|
||||
if not isinstance(next_fn, int):
|
||||
raise ValueError(f'Frame numbers differ: {next_fn}')
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"detector_name": "cSAXS.EG01V01",
|
||||
"detector_type": "eiger",
|
||||
"n_modules": 4,
|
||||
"image_height": 514,
|
||||
"image_width": 1030,
|
||||
"start_udp_port": 50000
|
||||
}
|
||||
@@ -6,42 +6,51 @@ import getopt
|
||||
import requests
|
||||
import time
|
||||
import json
|
||||
from urllib.parse import urljoin
|
||||
|
||||
URL = "http://127.0.0.1:5000"
|
||||
SYNC = "/write_sync"
|
||||
ASYNC = "/write_async"
|
||||
DET = "/detector/eiger"
|
||||
|
||||
headers = {'Content-type':'application/json'}
|
||||
|
||||
def prepare_det(dr):
|
||||
print("Stoping the detector...")
|
||||
stop_data = {'cmd': "STOP"}
|
||||
r = requests.post(url=urljoin(URL,DET), headers=headers, json=stop_data)
|
||||
time.sleep(0.1)
|
||||
print("Configuring the detector...")
|
||||
data_config = {"det_name":"eiger","config":{"frames":5000, "triggers":1, "exptime":0.0005, "period": 0.001, "timing":"auto", "tengiga":1, "dr":dr}}
|
||||
r = requests.post(url=urljoin(URL,DET), headers=headers, json=data_config)
|
||||
time.sleep(1)
|
||||
print("Starting the detector...")
|
||||
start_data = {'cmd':"START"}
|
||||
r = requests.post(url = urljoin(URL,DET), headers=headers, json=start_data)
|
||||
|
||||
|
||||
|
||||
|
||||
def main(argv):
|
||||
|
||||
# writer agent endpoint
|
||||
URL = "http://127.0.0.1:5000"
|
||||
# details of request
|
||||
n_images = 10
|
||||
n_acquisitions = 10
|
||||
headers = {'Content-type': 'application/json'}
|
||||
n_images = 5
|
||||
n_acquisitions = 5
|
||||
|
||||
for dr in [8, 16, 32]:
|
||||
prepare_det(dr)
|
||||
for j in [SYNC, ASYNC]:
|
||||
print(f'Performing { j } aquisitions (bit depth { dr })...')
|
||||
time.sleep(1.5)
|
||||
for i in range(0,n_acquisitions):
|
||||
output_file ='/home/dbe/git/sf_daq_buffer/eiger/xbl-daq-28/output_folder%s_%s_req%s_dr%s.h5' % (j, datetime.now().strftime("%H%M%S"), i, dr)
|
||||
data = {'sources':'BEC.EG01V01', 'n_images':n_images, 'output_file':output_file}
|
||||
r = requests.post(url = urljoin(URL,SYNC), json=data, headers=headers)
|
||||
print("RESPONSE FROM REQUEST: ", r.text)
|
||||
|
||||
|
||||
|
||||
|
||||
print("Configuring the detector...")
|
||||
data_config = {"det_name":"eiger","config":{"frames":36000,"dr":16, "triggers":1, "exptime":0.0005, "period": 0.001, "timing":"auto", "tengiga":1}}
|
||||
r = requests.post(url="http://127.0.0.1:5000/detector/eiger", headers=headers, json=data_config)
|
||||
time.sleep(0.5)
|
||||
|
||||
|
||||
print("Starting the detector...")
|
||||
start_data = {'cmd':"START"}
|
||||
r = requests.post(url = "http://127.0.0.1:5000/detector/eiger", headers=headers, json=start_data)
|
||||
time.sleep(0.5)
|
||||
|
||||
print("Performing sync aquisitions...")
|
||||
for i in range(0,n_acquisitions):
|
||||
output_file ='/home/dbe/git/sf_daq_buffer/eiger/xbl-daq-28/output_folder/eiger_sync_%s_%s.h5' % (datetime.now().strftime("%H%M%S"), i)
|
||||
#output_file='/tmp/output.h5'
|
||||
data = {'sources':'BEC.EG01V01', 'n_images':n_images, 'output_file':output_file}
|
||||
print("REQUEST: ", i)
|
||||
print("DATA: ", data)
|
||||
|
||||
r = requests.post(url = "http://127.0.0.1:5000/write_async", json=data, headers=headers)
|
||||
print("RESPONSE FROM REQUEST: ", r.text)
|
||||
time.sleep(0.2)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
||||
|
||||
Reference in New Issue
Block a user