fix: remove many duplicated methods
CI / lint (push) Successful in 31s
CI / test (3.11) (push) Failing after 40s
CI / test (3.12) (push) Failing after 41s
CI / test (3.13) (push) Failing after 41s
CI / lint (pull_request) Successful in 29s
CI / test (3.11) (pull_request) Failing after 40s
CI / test (3.12) (pull_request) Failing after 41s
CI / test (3.13) (pull_request) Failing after 48s
CI / lint (push) Successful in 31s
CI / test (3.11) (push) Failing after 40s
CI / test (3.12) (push) Failing after 41s
CI / test (3.13) (push) Failing after 41s
CI / lint (pull_request) Successful in 29s
CI / test (3.11) (pull_request) Failing after 40s
CI / test (3.12) (pull_request) Failing after 41s
CI / test (3.13) (pull_request) Failing after 48s
This commit is contained in:
@@ -416,16 +416,6 @@ def get_latest_image_stats():
|
||||
return None
|
||||
|
||||
|
||||
def get_latest_image_stats():
|
||||
"""Get the latest image statistics including radial profile"""
|
||||
global stats_receiver
|
||||
|
||||
if stats_receiver and stats_receiver.latest_stats:
|
||||
with stats_receiver.stats_lock:
|
||||
return stats_receiver.latest_stats.copy()
|
||||
return None
|
||||
|
||||
|
||||
def get_radial_profile():
|
||||
"""Get just the radial profile data"""
|
||||
global stats_receiver
|
||||
@@ -442,31 +432,3 @@ def save_current_radial_profile(filename: str = None):
|
||||
if stats_receiver:
|
||||
return stats_receiver.save_radial_profile_to_file(filename)
|
||||
return None
|
||||
|
||||
|
||||
# # Auto-start when daq.py is imported/run
|
||||
# if __name__ == "__main__":
|
||||
# # If running daq.py directly
|
||||
# start_image_stats_receiver()
|
||||
#
|
||||
# try:
|
||||
# # Your existing daq.py code continues here
|
||||
# print("DAQ system running with image statistics monitoring...")
|
||||
#
|
||||
# # Keep the program running
|
||||
# while True:
|
||||
# time.sleep(1)
|
||||
#
|
||||
# # Optional: Access latest stats in your main code
|
||||
# latest = get_latest_image_stats()
|
||||
# if latest and latest['message_count'] % 10 == 0: # Every 10th message
|
||||
# print(f"Main thread sees: Mean={latest['mean']:.1f}")
|
||||
#
|
||||
# except KeyboardInterrupt:
|
||||
# print("\nShutting down...")
|
||||
# finally:
|
||||
# stop_image_stats_receiver()
|
||||
#
|
||||
# else:
|
||||
# # If daq.py is imported as a module, auto-start the receiver
|
||||
# start_image_stats_receiver()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import grp
|
||||
import ipaddress
|
||||
import logging
|
||||
import os
|
||||
import pwd
|
||||
@@ -9,7 +8,6 @@ from datetime import UTC, datetime, timedelta
|
||||
from typing import List
|
||||
|
||||
import jwt
|
||||
from aarecommon.config.beamline import MXBeamline, mx_beamline
|
||||
from aarecommon.errors.exception_handler import (
|
||||
AuthenticationException,
|
||||
AuthErrorCode,
|
||||
|
||||
+5
-44
@@ -368,7 +368,7 @@ async def sample_geometry(token: str = Depends(oauth2_scheme)) -> SampleGeometry
|
||||
|
||||
|
||||
@app.put("/beamline/omega")
|
||||
async def omega(val: float, token: str = Depends(oauth2_scheme)):
|
||||
async def set_omega_abs(val: float, token: str = Depends(oauth2_scheme)):
|
||||
"""
|
||||
Set the omega angle of the goniometer.
|
||||
|
||||
@@ -386,7 +386,7 @@ async def omega(val: float, token: str = Depends(oauth2_scheme)):
|
||||
|
||||
|
||||
@app.put("/beamline/omega_rel")
|
||||
async def omega(val: float, token: str = Depends(oauth2_scheme)):
|
||||
async def set_omega_rel(val: float, token: str = Depends(oauth2_scheme)):
|
||||
"""
|
||||
Move the omega angle relatively.
|
||||
|
||||
@@ -835,28 +835,6 @@ async def local_contact_set_config(
|
||||
return daq.set_local_contact_config(payload)
|
||||
|
||||
|
||||
@app.get("/local_contact/config")
|
||||
async def local_contact_config(token: str = Depends(oauth2_scheme)) -> LocalContactConfigModel:
|
||||
"""
|
||||
Return Local Contact config values. Staff only.
|
||||
"""
|
||||
data = auth.parse_token(token)
|
||||
auth.check_jwt_staff_only(data)
|
||||
return daq.get_local_contact_config()
|
||||
|
||||
|
||||
@app.put("/local_contact/config")
|
||||
async def local_contact_set_config(
|
||||
payload: LocalContactConfigModel, token: str = Depends(oauth2_scheme)
|
||||
) -> LocalContactConfigModel:
|
||||
"""
|
||||
Update Local Contact config values. Staff only.
|
||||
"""
|
||||
data = auth.parse_token(token)
|
||||
auth.check_jwt_staff_only(data)
|
||||
return daq.set_local_contact_config(payload)
|
||||
|
||||
|
||||
@app.post("/beamline/goto_abr_meas_pos")
|
||||
async def goto_abr_meas_pos(token: str = Depends(oauth2_scheme)):
|
||||
"""
|
||||
@@ -1341,7 +1319,7 @@ async def dewar_exchange(token: str = Depends(oauth2_scheme)):
|
||||
|
||||
|
||||
@app.post("/state/sample_exchange")
|
||||
async def dewar_exchange(token: str = Depends(oauth2_scheme)):
|
||||
async def sample_exchange(token: str = Depends(oauth2_scheme)):
|
||||
"""
|
||||
Transition beamline state to SampleExchange.
|
||||
|
||||
@@ -1432,7 +1410,7 @@ async def data_collection(token: str = Depends(oauth2_scheme)):
|
||||
|
||||
|
||||
@app.post("/state/robot_sample_exchange")
|
||||
async def dewar_exchange(token: str = Depends(oauth2_scheme)):
|
||||
async def robot_sample_exchange(token: str = Depends(oauth2_scheme)):
|
||||
"""
|
||||
Transition beamline state to SampleExchange.
|
||||
|
||||
@@ -1463,7 +1441,7 @@ async def xray_fluorescence(token: str = Depends(oauth2_scheme)):
|
||||
|
||||
|
||||
@app.post("/state/xtal_snapshot")
|
||||
async def beam_location(token: str = Depends(oauth2_scheme)):
|
||||
async def xtal_snapshot(token: str = Depends(oauth2_scheme)):
|
||||
"""
|
||||
Transition beamline state to BeamLocation. Staff only.
|
||||
|
||||
@@ -1474,23 +1452,6 @@ async def beam_location(token: str = Depends(oauth2_scheme)):
|
||||
daq.state = BeamlineStateEnum.XtalSnapshot
|
||||
|
||||
|
||||
@app.post("/state/maintenance")
|
||||
async def maintenance(token: str = Depends(oauth2_scheme)) -> str:
|
||||
"""
|
||||
Transition beamline state to Maintenance. Staff only.
|
||||
|
||||
Args:
|
||||
token: OAuth2 access token.
|
||||
|
||||
Returns:
|
||||
"OK" on success.
|
||||
"""
|
||||
auth.check_jwt_staff(cfg, auth.parse_token(token))
|
||||
cfg.state = BeamlineStateEnum.Maintenance
|
||||
logger.warning("Beamline state set to Maintenance via protected endpoint.")
|
||||
return "OK"
|
||||
|
||||
|
||||
@app.post("/access/take_over_beamline")
|
||||
async def take_over_beamline(
|
||||
payload: RecoveryActionRequest, token: str = Depends(oauth2_scheme)
|
||||
|
||||
@@ -61,7 +61,8 @@ class epicsAD(object):
|
||||
|
||||
try:
|
||||
epics.ca.pend_io()
|
||||
except:
|
||||
except Exception as e:
|
||||
print(f"EPICS error: {e}")
|
||||
pass
|
||||
|
||||
def _init_auto_exp(self, settings: AutoExposureSettings = AutoExposureSettings()):
|
||||
|
||||
@@ -12,6 +12,9 @@ from bec_ipython_client.signals import OperationMode
|
||||
from bec_lib.device import RPCError, ScanRequestError
|
||||
from bec_lib.procedures.helper import FrontendProcedureHelper
|
||||
from bec_lib.service_config import ServiceConfig
|
||||
from pxii_bec.macros.build_devices import save_and_reload, save_current_position
|
||||
from pxii_bec.macros.init_beamline import init_beamline_environment
|
||||
from pxii_bec.macros.pxii_energy import bl_energy, get_current_energy, mono_pitch_scan
|
||||
|
||||
logger = setup_logger("aareDAQ")
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ from aarecommon.models.beamline import MXBeamline
|
||||
from aarecommon.models.models import DAQStatusModel, FluorescenceSpectrumOutputModel
|
||||
from aarecommon.models.raster_grid import RasterGridRequest
|
||||
from aarecommon.models.rotation_scan import RotationScanRequest
|
||||
from jfjoch_client.api.default_api import DefaultApi
|
||||
from jfjoch_client.api_client import ApiClient
|
||||
|
||||
|
||||
class ScanTypeEnum(Enum):
|
||||
@@ -26,8 +28,10 @@ class JFJochWrapper:
|
||||
self._url = get_jfjoch_url(bl)
|
||||
|
||||
if self._url == "simulated":
|
||||
self._client = None
|
||||
self._api = None
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
self._client = MagicMock(spec=ApiClient)
|
||||
self._api = MagicMock(spec=DefaultApi)
|
||||
return
|
||||
|
||||
self._client = jfjoch_client.ApiClient(jfjoch_client.Configuration(host=self._url))
|
||||
|
||||
Reference in New Issue
Block a user