Factorize proc_sr

This commit is contained in:
root
2025-12-08 10:27:24 +01:00
parent 49f8c8120c
commit 4d1556bcd5
13 changed files with 175 additions and 34 deletions

View File

@@ -1,13 +1,13 @@
{
"camera_calibration": {
"reference_marker": [
339,
339,
2077,
2077
354,
354,
1200,
1200
],
"reference_marker_width": 2140.0,
"reference_marker_height": 2140.0,
"reference_marker_width": 1040.0,
"reference_marker_height": 1040.0,
"angle_horizontal": 0.0,
"angle_vertical": 0.0
},
@@ -16,7 +16,11 @@
"rotate": 0,
"roi": null,
"image_background": null,
"source_type": "epics",
"source_type": "bsread",
"debug": true,
"check_timestamp": false,
"enforce_pid": false,
"enforce_timestamp": false,
"prefix": "X01DD-FE-CAM1",
"name": "X01DD-FE-CAM1",
"source": "X01DD-FE-CAM1",

View File

@@ -8,6 +8,7 @@
"pipeline_type": "processing",
"camera_name": "ARS05-RCAM-0060",
"function": "proc_sr1",
"instName": "SR1",
"reload": true,
"abort_on_error": false,
"name": "ARS05-RCAM-0060_proc2"

View File

@@ -8,8 +8,9 @@
"pipeline_type": "processing",
"camera_name": "ARS05-RCAM-0060",
"name": "ARS05-RCAM-0060_sp",
"function": "epics_handler.py",
"disable_epics": false,
"max_output_rate": 10.1,
"throw_epics_errors": true
"max_frame_rate": 10.1,
"_function": "epics_handler.py",
"_disable_epics": false,
"_max_output_rate": 10.1,
"_throw_epics_errors": true
}

View File

@@ -8,6 +8,7 @@
"pipeline_type": "processing",
"camera_name": "ARS05-RCAM-0140",
"function": "proc_sr2",
"instName": "SR2",
"reload": true,
"abort_on_error": false,
"name": "ARS05-RCAM-0140_proc2",

View File

@@ -8,8 +8,9 @@
"pipeline_type": "processing",
"camera_name": "ARS05-RCAM-0140",
"name": "ARS05-RCAM-0140_sp",
"function": "epics_handler.py",
"disable_epics": false,
"max_output_rate": 10.1,
"throw_epics_errors": true
"max_frame_rate": 10.1,
"_function": "epics_handler.py",
"_disable_epics": false,
"_max_output_rate": 10.1,
"_throw_epics_errors": true
}

View File

@@ -8,6 +8,7 @@
"pipeline_type": "processing",
"camera_name": "ARS05-RCAM-0230",
"function": "proc_sr3",
"instName": "SR3",
"reload": true,
"abort_on_error": false,
"name": "ARS05-RCAM-0230_proc2",

View File

@@ -8,8 +8,9 @@
"pipeline_type": "processing",
"camera_name": "ARS05-RCAM-0230",
"name": "ARS05-RCAM-0230_sp",
"function": "epics_handler.py",
"disable_epics": false,
"max_output_rate": 10.1,
"throw_epics_errors": true
"max_frame_rate": 10.1,
"_function": "epics_handler.py",
"_disable_epics": false,
"_max_output_rate": 10.1,
"_throw_epics_errors": true
}

View File

@@ -8,6 +8,7 @@
"pipeline_type": "processing",
"camera_name": "ARS05-RCAM-0310",
"function": "proc_sr4",
"instName": "SR4",
"reload": true,
"abort_on_error": false,
"name": "ARS05-RCAM-0310_proc2",

View File

@@ -8,8 +8,9 @@
"pipeline_type": "processing",
"camera_name": "ARS05-RCAM-0310",
"name": "ARS05-RCAM-0310_sp",
"function": "epics_handler.py",
"disable_epics": false,
"max_output_rate": 10.1,
"throw_epics_errors": true
"max_frame_rate": 10.1,
"_function": "epics_handler.py",
"_disable_epics": false,
"_max_output_rate": 10.1,
"_throw_epics_errors": true
}

View File

@@ -11,12 +11,12 @@
"pipeline_type": "processing",
"camera_name": "X01DD-FE-CAM1",
"name": "X01DD-FE-CAM1_sp",
"max_frame_rate": 100.1,
"reload": true,
"function": "epics_handler.py",
"disable_epics": false,
"max_output_rate": 10.1,
"single_optics": true,
"PSF": 3.4,
"throw_epics_errors": true
"throw_epics_errors": true,
"no_client_timeout": 0,
"_processing_threads": 1,
"max_output_rate": 10.1
}

View File

@@ -4,7 +4,7 @@
"image_threshold": null,
"image_region_of_interest": null,
"image_good_region": {
"threshold": 0.4,
"threshold": 0.30000000000000004,
"gfscale": 3.0
},
"image_slices": null,
@@ -12,8 +12,6 @@
"camera_name": "X08DB-FE-CAM1",
"name": "X08DB-FE-CAM1_sp",
"function": "epics_handler.py",
"disable_epics": false,
"max_frame_rate": 100.1,
"max_output_rate": 10.1,
"single_optics": true,
"PSF": 3.4,

View File

@@ -1,4 +1,8 @@
{
"#ARS05-RCAM-0060_sp": "ARS05-RCAM-0060_sp",
"#ARS05-RCAM-0140_sp": "ARS05-RCAM-0140_sp",
"#ARS05-RCAM-0230_sp": "ARS05-RCAM-0230_sp",
"#ARS05-RCAM-0310_sp": "ARS05-RCAM-0310_sp",
"#simulation_sp1": "simulation_sp",
"ABODI-SM-1S1_sp": "ABODI-SM-1S1_sp",
"ABODI-SM-1S2_sp": "ABODI-SM-1S2_sp",
@@ -13,13 +17,9 @@
"ALIDI-SM-E_sp": "ALIDI-SM-E_sp",
"ARS01-DSCR-0750_sp": "ARS01-DSCR-0750_sp",
"ARS05-RCAM-0060_proc2": "ARS05-RCAM-0060_proc2",
"ARS05-RCAM-0060_sp": "ARS05-RCAM-0060_sp",
"ARS05-RCAM-0140_proc2": "ARS05-RCAM-0140_proc2",
"ARS05-RCAM-0140_sp": "ARS05-RCAM-0140_sp",
"ARS05-RCAM-0230_proc2": "ARS05-RCAM-0230_proc2",
"ARS05-RCAM-0230_sp": "ARS05-RCAM-0230_sp",
"ARS05-RCAM-0310_proc2": "ARS05-RCAM-0310_proc2",
"ARS05-RCAM-0310_sp": "ARS05-RCAM-0310_sp",
"X01DD-ES-CAM1_for": "X01DD-ES-CAM1_for",
"X01DD-FE-CAM1_sp": "X01DD-FE-CAM1_sp",
"X01DD-SC-CAM1_sp": "X01DD-SC-CAM1_sp",

View File

@@ -0,0 +1,131 @@
#########################################################################
# The interface to integrate into the pipeline server
# The following files are needed to be added to the library:
# - CamDataProcess.py
# - Config_Param.py
# - LocalPV.py
# - RecordTemplate.py
# - RemotePV.py
# - Service_Log.py
# - Service_RFStation.py
# - Service_Screen.py
# - elog.py
#
# Created by Zheqiao Geng on 29.05.2024
#########################################################################
import os
import time
from cam_server.pipeline.data_processing import functions, processor
from cam_server import utils
from logging import getLogger
from CamDataProcess import *
from Service_RFStation import *
from Config_Param import *
from Service_Log import *
# ===============================================================
# global variables
# ===============================================================
_logger = getLogger(__name__)
initialized = False
srvRFs = None
srvLog = None
camPrc = None
# ===============================================================
# init function
# ===============================================================
def initialize(moduleName, instName):
global srvRFs, srvLog, camPrc
# get the RF station info
if instName == 'TS':
cav_label = ts_cav_label
cpl_label = ts_cpl_label
elif instName == 'SR1':
cav_label = sr1_cav_label
cpl_label = sr1_cpl_label
elif instName == 'SR2':
cav_label = sr2_cav_label
cpl_label = sr2_cpl_label
elif instName == 'SR3':
cav_label = sr3_cav_label
cpl_label = sr3_cpl_label
elif instName == 'SR4':
cav_label = sr4_cav_label
cpl_label = sr4_cpl_label
else:
cav_label = ''
cpl_label = ''
# define the services
srvRFs = Service_RFStation(loc=instName,
cav_label=cav_label,
cpl_label=cpl_label)
srvLog = Service_Log(moduleName, loc=instName)
# define the jobs
camPrc = CamDataProcess(moduleName,
instName,
srv_scr=None,
srv_rfs=srvRFs,
srv_log=srvLog,
f_path=file_path)
# connect to all PVs
RemotePV.connect()
time.sleep(2.0)
# start the threads
camPrc.start()
_logger.info('EPICS_CA_ADDR_LIST = ' + str(os.environ.get('EPICS_CA_ADDR_LIST')))
_logger.info('Data Path: ' + camPrc.f_path)
_logger.info("Initialized")
# ===============================================================
# implement the image processing function (replacing the thread
# function "DataRecvProcFunc" in "CamDataProcess.py")
# ===============================================================
def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, bsdata=None):
# declare the global variables
global camPrc, initialized
try:
# initialization
if not initialized:
moduleName = parameters["camera_name"]
instName = parameters["instName"]
initialize(moduleName, instName)
initialized = True
# basic process of the image
data = {'timestamp': utils.timestamp_as_float(timestamp),
'width': len(image[0]),
'height': len(image),
'image': image,
'arc_found': 0}
# calculate the properties for arc detection
x_profile, y_profile = functions.get_x_y_profile(image)
min_value, max_value = functions.get_min_max(image)
intensity = x_profile.sum()
data['intensity'] = intensity
data['min_value'] = min_value
data['max_value'] = max_value
data['x_profile'] = x_profile
data['y_profile'] = y_profile
# store to the circular buffer
camPrc.receiveImage(data)
return data
except Exception as e:
_logger.warning(str(e))
return None