LCOV - code coverage report
Current view: top level - src - mfed.cxx (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 69 0
Test Date: 2025-11-11 10:26:08 Functions: 0.0 % 18 0

            Line data    Source code
       1              : /********************************************************************\
       2              : 
       3              :   Name:         mfed.c
       4              :   Created by:   Stefan Ritt
       5              : 
       6              :   Contents:     Dummy routines to simplify syntax for mfe based
       7              :                 frontends.
       8              : 
       9              :                 Users must #defien MFED before #include "mfe.h"
      10              :                 and link against mfed.cxx
      11              : 
      12              : \********************************************************************/
      13              : 
      14              : #include <cstdio>
      15              : #include <cstring>
      16              : #include <history.h>
      17              : #include "midas.h"
      18              : #include "mfe.h"
      19              : #include "odbxx.h"
      20              : 
      21              : /*-- Globals -------------------------------------------------------*/
      22              : 
      23              : /* frontend_loop is called periodically if this variable is TRUE    */
      24              : BOOL frontend_call_loop = TRUE;
      25              : 
      26              : /* a frontend status page is displayed with this frequency in ms    */
      27              : INT display_period = 0;
      28              : 
      29              : /* maximum event size produced by this frontend */
      30              : INT max_event_size = 1024 * 1024;
      31              : 
      32              : /* maximum event size for fragmented events (EQ_FRAGMENTED) */
      33              : INT max_event_size_frag = 5 * 1024 * 1024;
      34              : 
      35              : /* buffer size to hold events */
      36              : INT event_buffer_size = 2 * 1024 * 1024;
      37              : 
      38              : /*------------------------------------------------------------------*/
      39              : 
      40            0 : void set_max_event_size(int size)
      41              : {
      42            0 :    max_event_size = size;
      43            0 :    event_buffer_size = 2 * size;
      44            0 : }
      45              : 
      46            0 : void set_event_buffer_size(int size)
      47              : {
      48            0 :    event_buffer_size = size;
      49            0 : }
      50              : 
      51              : /*------------------------------------------------------------------*/
      52              : 
      53              : INT (*p_poll_event)(INT,INT,BOOL) = NULL;
      54              : 
      55            0 : void install_poll_event(INT (*f)(INT,INT,BOOL))
      56              : {
      57            0 :    p_poll_event = f;
      58            0 : }
      59              : 
      60            0 : INT poll_event(__attribute__((unused)) INT source, __attribute__((unused)) INT count, __attribute__((unused))BOOL test)
      61              : {
      62            0 :    if (p_poll_event)
      63            0 :       return p_poll_event(source, count, test);
      64            0 :    return 1;
      65              : }
      66              : 
      67            0 : INT interrupt_configure(__attribute__((unused)) INT cmd, __attribute__((unused)) INT source, __attribute__((unused)) PTYPE adr)
      68              : {
      69            0 :    return 1;
      70              : }
      71              : 
      72              : /*------------------------------------------------------------------*/
      73              : 
      74            0 : INT set_write_cache_size(std::string buffer, int size)
      75              : {
      76            0 :    if (size < MIN_WRITE_CACHE_SIZE && size != 0) {
      77            0 :       cm_msg(MERROR, "set_cache_size", "Requested write cache size %d too small, minimum is %d", size, MIN_WRITE_CACHE_SIZE);
      78            0 :       return 0;
      79              :    }
      80              : 
      81            0 :    gWriteCacheSize = size;
      82            0 :    for (int i=0 ; i<equipment[i].name[0] ; i++)
      83            0 :       if (std::string(equipment[i].info.buffer) == buffer) {
      84            0 :          bm_set_cache_size(equipment[i].buffer_handle, 0, size);
      85            0 :          return 1;
      86              :       }
      87              : 
      88            0 :    return 0;
      89              : }
      90              : 
      91              : /*------------------------------------------------------------------*/
      92              : 
      93              : INT (*p_frontend_exit)() = NULL;
      94              : 
      95            0 : void install_frontend_exit(INT (*f)())
      96              : {
      97            0 :    p_frontend_exit = f;
      98            0 : }
      99              : 
     100            0 : INT frontend_exit()
     101              : {
     102            0 :    if (p_frontend_exit)
     103            0 :       return p_frontend_exit();
     104            0 :    return CM_SUCCESS;
     105              : }
     106              : 
     107              : /*------------------------------------------------------------------*/
     108              : 
     109              : INT (*p_begin_of_run)() = NULL;
     110              : 
     111            0 : void install_begin_of_run(INT (*f)())
     112              : {
     113            0 :    p_begin_of_run = f;
     114            0 : }
     115              : 
     116            0 : INT begin_of_run(__attribute__((unused)) INT rn, __attribute__((unused)) char *error)
     117              : {
     118            0 :    if (p_begin_of_run)
     119            0 :       return p_begin_of_run();
     120            0 :    return CM_SUCCESS;
     121              : }
     122              : 
     123              : /*------------------------------------------------------------------*/
     124              : 
     125              : INT (*p_end_of_run)() = NULL;
     126              : 
     127            0 : void install_end_of_run(INT (*f)())
     128              : {
     129            0 :    p_end_of_run = f;
     130            0 : }
     131              : 
     132            0 : INT end_of_run(__attribute__((unused)) INT rn, __attribute__((unused)) char *error)
     133              : {
     134            0 :    if (p_end_of_run)
     135            0 :       return p_end_of_run();
     136            0 :    return CM_SUCCESS;
     137              : }
     138              : 
     139              : /*------------------------------------------------------------------*/
     140              : 
     141              : INT (*p_pause_run)() = NULL;
     142              : 
     143            0 : void install_pause_run(INT (*f)())
     144              : {
     145            0 :    p_pause_run = f;
     146            0 : }
     147              : 
     148            0 : INT pause_run(__attribute__((unused)) INT rn, __attribute__((unused)) char *error)
     149              : {
     150            0 :    if (p_pause_run)
     151            0 :       return p_pause_run();
     152            0 :    return CM_SUCCESS;
     153              : }
     154              : 
     155              : /*------------------------------------------------------------------*/
     156              : 
     157              : INT (*p_resume_run)() = NULL;
     158              : 
     159            0 : void install_resume_run(INT (*f)())
     160              : {
     161            0 :    p_resume_run = f;
     162            0 : }
     163              : 
     164            0 : INT resume_run(__attribute__((unused)) INT rn, __attribute__((unused)) char *error)
     165              : {
     166            0 :    if (p_resume_run)
     167            0 :       return p_resume_run();
     168            0 :    return CM_SUCCESS;
     169              : }
     170              : 
     171              : /*------------------------------------------------------------------*/
     172              : 
     173              : INT (*p_frontend_loop)() = NULL;
     174              : 
     175            0 : void install_frontend_loop(INT (*f)())
     176              : {
     177            0 :    p_frontend_loop = f;
     178            0 : }
     179              : 
     180              : /*------------------------------------------------------------------*/
     181              : 
     182            0 : INT frontend_loop()
     183              : {
     184            0 :    if (p_frontend_loop)
     185            0 :       return p_frontend_loop();
     186              :    else
     187            0 :       ss_sleep(10); // don't eat all CPU
     188            0 :    return CM_SUCCESS;
     189              : }
        

Generated by: LCOV version 2.0-1