diff --git a/.gitea/workflows/action.yaml b/.gitea/workflows/action.yaml index cd615e3..6e8990b 100644 --- a/.gitea/workflows/action.yaml +++ b/.gitea/workflows/action.yaml @@ -8,11 +8,11 @@ jobs: - name: checkout repo uses: actions/checkout@v4 - name: formatting - run: clang-format --style=file --Werror --dry-run device/* frontends/* + run: clang-format --style=file --Werror --dry-run device/* frontend/* Lint: runs-on: linepics steps: - name: checkout repo uses: actions/checkout@v4 - name: cppcheck - run: cppcheck --std=c++17 --addon=cert --addon=misc --error-exitcode=1 device/ frontends/ + run: cppcheck --std=c++17 --addon=cert --addon=misc --error-exitcode=1 device/ frontend/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 79fbb3a..185833b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,27 +70,36 @@ target_link_libraries( if(${BUILD_FRONTEND}) + set(STRAYFIELD_FRONTEND_NAME Ext_stray_field_status CACHE STRING "Overridable frontend name") + add_executable( - strayfield_fe + Ext_stray_field_status_scfe frontend/strayfield_scfe.cxx ) + add_compile_definitions(Ext_stray_field_status_scfe PRIVATE FRONTEND_NAME="${STRAYFIELD_FRONTEND_NAME}") set_property( TARGET - strayfield_fe + Ext_stray_field_status_scfe PROPERTY CXX_STANDARD 11 ) target_include_directories( - strayfield_fe + Ext_stray_field_status_scfe PRIVATE $ENV{MIDASSYS}/drivers ) target_link_libraries( - strayfield_fe + Ext_stray_field_status_scfe strayfield ) + install( + TARGETS + Ext_stray_field_status_scfe + RUNTIME DESTINATION bin + ) + endif() diff --git a/frontend/strayfield_scfe.cxx b/frontend/strayfield_scfe.cxx index ffd2b2a..c034cf4 100644 --- a/frontend/strayfield_scfe.cxx +++ b/frontend/strayfield_scfe.cxx @@ -1,51 +1,45 @@ -/*******************************************************************\ +/********************************************************************\ - Name: strayfield_scfe.cxx - Created by: Edward Wall - Contents: Slow Control Frontend for Strayfield Cobra and Comet Magnets + Name: Ext_stray_field_status_scfe.c + Created by: Hubertus Luetkens -\********************************************************************/ + Contents: Midas frontend to read stray field status in the Experimental + hall (Cobra, Comet,...) from Multicasts + \********************************************************************/ + +#include #include "midas.h" -#include "mfe.h" - -#include "bus/tcpip.h" +#include "bus/null.h" #include "class/multi.h" - #include "device/strayfield.h" -/******************************************************************************* - * Global Variables Required by mfe.h - ******************************************************************************/ +/*-- Globals -------------------------------------------------------*/ -//! The frontend name (client name) as seen by other MIDAS clients -const char *frontend_name = "Strayfield"; +/* The frontend name (client name) as seen by other MIDAS clients + * This is a preprocessor macro with a default values that can be overriden + * with cmake*/ +const char *frontend_name = FRONTEND_NAME; -//! The frontend file name, don't change it +/* The frontend file name, don't change it */ const char *frontend_file_name = __FILE__; -//! frontend_loop is called periodically if this variable is TRUE +/* frontend_loop is called periodically if this variable is TRUE */ BOOL frontend_call_loop = FALSE; -//! a frontend status page is displayed with this frequency in ms +/* a frontend status page is displayed with this frequency in ms */ INT display_period = 1000; -//! maximum event size produced by this frontend +/* maximum event size produced by this frontend */ INT max_event_size = 10000; -//! maximum event size for fragmented events (EQ_FRAGMENTED) +/* maximum event size for fragmented events (EQ_FRAGMENTED) */ INT max_event_size_frag = 5 * 1024 * 1024; -//! buffer size to hold events +/* buffer size to hold events */ INT event_buffer_size = 10 * 10000; -/******************************************************************************* - * Equipment List Required by mfe.h - ******************************************************************************/ - -DEVICE_DRIVER strayfield_driver[] = { - // { name, *dd, channels, *bd, flags } - {"strayfield_inp", strayfield_in, 4, tcpip, DF_INPUT}}; +extern BOOL should_exit; /*! * equipment_common_overwrite: @@ -58,68 +52,98 @@ DEVICE_DRIVER strayfield_driver[] = { */ BOOL equipment_common_overwrite = FALSE; -/******************************************************************************* - * Equipment Structure Required by mfe.h - ******************************************************************************/ +/*-- Equipment list ------------------------------------------------*/ + +/* device driver list */ + +DEVICE_DRIVER strayfield_driver[] = { + {"stray_field", strayfield_in, 4, null, DF_INPUT}, + //{ "null", nulldev, 1, NULL, DF_OUTPUT}, /* not necessary ?? + //*/ + {""}}; EQUIPMENT equipment[] = { + { - "Strayfield_Magnet", /* equipment name */ - { - 94, /* Event ID associated with equipm. */ - 0, /* Trigger mask */ - "SYSTEM", /* Event buffer to send events into */ - EQ_SLOW, /* equipment type */ - 0, /* Event source (LAM/IRQ) */ - "FIXED", /* Data format to produce */ - TRUE, /* Enable flag */ - RO_RUNNING | - RO_TRANSITIONS, /* Combination of Read-On flags RO_xxx */ - 10000, /* Readout interval/Polling time in ms */ - 0, /* Stop run when limit is reached */ - 0, /* Number of events in super event */ - 1, /* log history every event */ - "", /* Host on which FE is running */ - "", /* Frontend name */ - "" /* Source file used for user FE */ - }, + FRONTEND_NAME, /* equipment name */ + {94, 0, /* event ID, trigger mask */ + "SYSTEM", /* event buffer */ + EQ_SLOW, /* equipment type */ + 0, /* event source */ + "FIXED", /* format */ + TRUE, /* enabled */ + RO_RUNNING | RO_TRANSITIONS, /* read when running and on transitions */ + 10000, /* read every 10 sec */ + 0, /* stop run after this event limit */ + 0, /* number of sub events */ + 1, /* log history every event */ + "", "", ""}, cd_multi_read, /* readout routine */ cd_multi, /* class driver main routine */ strayfield_driver, /* device driver list */ NULL, /* init string */ }, + {""}}; -/******************************************************************************* - * Routines Required by mfe.h - * - * Can be overwritten to modify the default frontend behaviour. - ******************************************************************************/ +/*-- Dummy routines ------------------------------------------------*/ -INT poll_event(INT source, INT count, BOOL test) { return CM_SUCCESS; }; +INT poll_event(INT source, INT count, BOOL test) { return 1; } +INT interrupt_configure(INT cmd, INT source, PTYPE adr) { return 1; } -INT interrupt_configure(INT cmd, INT source, POINTER_T adr) { - return CM_SUCCESS; -}; +/*-- Frontend Init -------------------------------------------------*/ INT frontend_init() { +#ifdef LEM_USED + // not necessary for bulk as mfe.c is compiled with NO_RUN_TRANSITION flag // de-register run-transition notifications cm_deregister_transition(TR_START); cm_deregister_transition(TR_STOP); cm_deregister_transition(TR_PAUSE); cm_deregister_transition(TR_RESUME); +#endif + +#ifdef FORTIFY + Fortify_CheckAllMemory(); +#endif return CM_SUCCESS; } +/*-- Frontend Exit -------------------------------------------------*/ + +INT frontend_exit() { + +#ifdef FORTIFY + Fortify_CheckAllMemory(); + Fortify_OutputStatistics(); +#endif + + return CM_SUCCESS; +} + +/*-- Frontend Loop -------------------------------------------------*/ + +#ifdef FORTIFY +static DWORD last_time_fortify = 0; +#endif + INT frontend_loop() { return CM_SUCCESS; } -INT frontend_exit() { return CM_SUCCESS; } +/*-- Begin of Run --------------------------------------------------*/ INT begin_of_run(INT run_number, char *error) { return CM_SUCCESS; } +/*-- End of Run ----------------------------------------------------*/ + +INT end_of_run(INT run_number, char *error) { return CM_SUCCESS; } + +/*-- Pause Run -----------------------------------------------------*/ + INT pause_run(INT run_number, char *error) { return CM_SUCCESS; } +/*-- Resuem Run ----------------------------------------------------*/ + INT resume_run(INT run_number, char *error) { return CM_SUCCESS; } -INT end_of_run(INT run_number, char *error) { return CM_SUCCESS; } +/*------------------------------------------------------------------*/