Cleanup commented code and HAVE_TEST_RUN #2
No files matched your search
+33
-42
@@ -53,7 +53,7 @@ set(CMAKE_PREFIX_PATH "$ENV{MIDASSYS}")
|
||||
|
||||
set(SIS1100_DIR "struck_sis1100-310x")
|
||||
|
||||
# Always build the library (even for test mode, we can define HAVE_TEST_RUN)
|
||||
# Always build the library
|
||||
add_library(sis3100scal STATIC
|
||||
${SIS1100_DIR}/sis3100_calls/sis3100_vme_calls.c
|
||||
${SIS1100_DIR}/sis3100_calls/sharc_utils.c
|
||||
@@ -64,12 +64,6 @@ target_include_directories(sis3100scal
|
||||
${SIS1100_DIR}
|
||||
)
|
||||
|
||||
# --- TEST FRONTEND MODE ---
|
||||
if (FRONTEND)
|
||||
target_compile_definitions(sis3100scal PUBLIC HAVE_TEST_RUN)
|
||||
message(STATUS "Building in TEST FRONTEND mode (no hardware required).")
|
||||
endif ()
|
||||
|
||||
# =============================================================================
|
||||
# 5. Scaler Frontend Executable
|
||||
# =============================================================================
|
||||
@@ -77,44 +71,41 @@ endif ()
|
||||
set(_default_scaler_frontend_dir "${CMAKE_CURRENT_LIST_DIR}" CACHE INTERNAL "")
|
||||
function(default_scaler_frontend F_TARGET F_NAME F_EVENT_ID NUM_CHANNELS)
|
||||
|
||||
add_executable(${F_TARGET}
|
||||
${_default_scaler_frontend_dir}/frontend/struck_sis3820_fcfe.cxx
|
||||
${_default_scaler_frontend_dir}/device/struck_sis3820.c
|
||||
${DRIVERS}
|
||||
)
|
||||
add_executable(${F_TARGET}
|
||||
${_default_scaler_frontend_dir}/frontend/struck_sis3820_fcfe.cxx
|
||||
${_default_scaler_frontend_dir}/device/struck_sis3820.c
|
||||
)
|
||||
|
||||
target_compile_definitions(${F_TARGET} PUBLIC FRONTEND_NAME="${F_NAME}")
|
||||
target_compile_definitions(${F_TARGET} PUBLIC N_SCALER=${NUM_CHANNELS})
|
||||
target_compile_definitions(${F_TARGET} PUBLIC F_EVENT_ID=${F_EVENT_ID})
|
||||
target_compile_definitions(${F_TARGET} PUBLIC FRONTEND_NAME="${F_NAME}")
|
||||
target_compile_definitions(${F_TARGET} PUBLIC N_SCALER=${NUM_CHANNELS})
|
||||
target_compile_definitions(${F_TARGET} PUBLIC F_EVENT_ID=${F_EVENT_ID})
|
||||
|
||||
target_include_directories(${F_TARGET}
|
||||
PRIVATE
|
||||
$ENV{MIDASSYS}/include
|
||||
$ENV{MIDASSYS}/drivers/kernel
|
||||
$ENV{MIDASSYS}/drivers/divers
|
||||
${_DEFAULT_SCALER_FRONTEND_DIR}
|
||||
${_DEFAULT_SCALER_FRONTEND_DIR}/mxml
|
||||
${_DEFAULT_SCALER_FRONTEND_DIR}/device
|
||||
${SIS1100_DIR}
|
||||
${SIS1100_DIR}/sis3100_calls
|
||||
)
|
||||
target_include_directories(${F_TARGET}
|
||||
PRIVATE
|
||||
$ENV{MIDASSYS}/include
|
||||
$ENV{MIDASSYS}/drivers/kernel
|
||||
$ENV{MIDASSYS}/drivers/divers
|
||||
${_default_scaler_frontend_dir}/
|
||||
${SIS1100_DIR}
|
||||
${SIS1100_DIR}/sis3100_calls
|
||||
)
|
||||
|
||||
find_package(Midas REQUIRED)
|
||||
target_link_libraries(${F_TARGET}
|
||||
PRIVATE
|
||||
sis3100scal
|
||||
midas::mfe
|
||||
midas::midas
|
||||
midas::mscb
|
||||
z pthread util rt dl m
|
||||
)
|
||||
find_package(Midas REQUIRED)
|
||||
target_link_libraries(${F_TARGET}
|
||||
PRIVATE
|
||||
sis3100scal
|
||||
midas::mfe
|
||||
midas::midas
|
||||
midas::mscb
|
||||
z pthread util rt dl m
|
||||
)
|
||||
|
||||
# =============================================================================
|
||||
# 6. Installation
|
||||
# =============================================================================
|
||||
# =============================================================================
|
||||
# 6. Installation
|
||||
# =============================================================================
|
||||
|
||||
install(
|
||||
TARGETS ${F_TARGET}
|
||||
RUNTIME DESTINATION bin
|
||||
)
|
||||
install(
|
||||
TARGETS ${F_TARGET}
|
||||
RUNTIME DESTINATION bin
|
||||
)
|
||||
endfunction()
|
||||
+9
-76
@@ -38,14 +38,7 @@
|
||||
*/
|
||||
int sis3820_key_reset(int device, u_int32_t sis3820_base)
|
||||
{
|
||||
int status;
|
||||
|
||||
#ifdef HAVE_TEST_RUN
|
||||
status = 0;
|
||||
#else
|
||||
status = vme_A32D32_write(device, sis3820_base+SIS3820_KEY_RESET, SIS3820_KEY_RESET);
|
||||
#endif
|
||||
return status;
|
||||
return vme_A32D32_write(device, sis3820_base+SIS3820_KEY_RESET, SIS3820_KEY_RESET);
|
||||
}
|
||||
|
||||
/*------ sis3820_key_enable -----------------------------------------------------*/
|
||||
@@ -61,14 +54,7 @@ int sis3820_key_reset(int device, u_int32_t sis3820_base)
|
||||
*/
|
||||
int sis3820_key_enable(int device, u_int32_t sis3820_base)
|
||||
{
|
||||
int status;
|
||||
|
||||
#ifdef HAVE_TEST_RUN
|
||||
status = 0;
|
||||
#else
|
||||
status = vme_A32D32_write(device, sis3820_base+SIS3820_KEY_OPERATION_ENABLE, SIS3820_KEY_OPERATION_ENABLE);
|
||||
#endif
|
||||
return status;
|
||||
return vme_A32D32_write(device, sis3820_base+SIS3820_KEY_OPERATION_ENABLE, SIS3820_KEY_OPERATION_ENABLE);
|
||||
}
|
||||
|
||||
/*------- sis3820_key_disable ----------------------------------------------------*/
|
||||
@@ -83,27 +69,13 @@ int sis3820_key_enable(int device, u_int32_t sis3820_base)
|
||||
*/
|
||||
int sis3820_key_disable(int device, u_int32_t sis3820_base)
|
||||
{
|
||||
int status;
|
||||
|
||||
#ifdef HAVE_TEST_RUN
|
||||
status = 0;
|
||||
#else
|
||||
status = vme_A32D32_write(device, sis3820_base+SIS3820_KEY_OPERATION_DISABLE, SIS3820_KEY_OPERATION_DISABLE);
|
||||
#endif
|
||||
return status;
|
||||
return vme_A32D32_write(device, sis3820_base+SIS3820_KEY_OPERATION_DISABLE, SIS3820_KEY_OPERATION_DISABLE);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
int sis3820_operation_mode_read(int device, u_int32_t sis3820_base, u_int32_t* mode)
|
||||
{
|
||||
int status;
|
||||
|
||||
#ifdef HAVE_TEST_RUN
|
||||
status = 0;
|
||||
#else
|
||||
status = vme_A32D32_read(device, sis3820_base+SIS3820_OPERATION_MODE, mode);
|
||||
#endif
|
||||
return status;
|
||||
return vme_A32D32_read(device, sis3820_base+SIS3820_OPERATION_MODE, mode);
|
||||
}
|
||||
|
||||
/*------- sis3820_operation_mode_write -----------------------------------------*/
|
||||
@@ -164,40 +136,19 @@ int sis3820_operation_mode_read(int device, u_int32_t sis3820_base, u_int32_t* m
|
||||
/*------------------------------------------------------------------------------*/
|
||||
int sis3820_operation_mode_write(int device, u_int32_t sis3820_base, u_int32_t mode)
|
||||
{
|
||||
int status;
|
||||
|
||||
#ifdef HAVE_TEST_RUN
|
||||
status = 0;
|
||||
#else
|
||||
status = vme_A32D32_write(device, sis3820_base+SIS3820_OPERATION_MODE, mode);
|
||||
#endif
|
||||
return status;
|
||||
return vme_A32D32_write(device, sis3820_base+SIS3820_OPERATION_MODE, mode);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
int sis3820_modid_read(int device, u_int32_t sis3820_base, u_int32_t* modid)
|
||||
{
|
||||
int status;
|
||||
|
||||
#ifdef HAVE_TEST_RUN
|
||||
status = 0;
|
||||
#else
|
||||
status = vme_A32D32_read(device, sis3820_base+SIS3820_MODID, modid);
|
||||
#endif
|
||||
return status;
|
||||
return vme_A32D32_read(device, sis3820_base+SIS3820_MODID, modid);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
int sis3820_control_read(int device, u_int32_t sis3820_base, u_int32_t* control_status)
|
||||
{
|
||||
int status;
|
||||
|
||||
#ifdef HAVE_TEST_RUN
|
||||
status = 0;
|
||||
#else
|
||||
status = vme_A32D32_read(device, sis3820_base+SIS3820_CONTROL_STATUS, control_status);
|
||||
#endif
|
||||
return status;
|
||||
return vme_A32D32_read(device, sis3820_base+SIS3820_CONTROL_STATUS, control_status);
|
||||
}
|
||||
|
||||
/*------- sis3820_control_write -----------------------------------------*/
|
||||
@@ -228,14 +179,7 @@ int sis3820_control_read(int device, u_int32_t sis3820_base, u_int32_t* control_
|
||||
*------------------------------------------------------------------------------*/
|
||||
int sis3820_control_write(int device, u_int32_t sis3820_base, u_int32_t control_status)
|
||||
{
|
||||
int status;
|
||||
|
||||
#ifdef HAVE_TEST_RUN
|
||||
status = 0;
|
||||
#else
|
||||
status = vme_A32D32_write(device, sis3820_base+SIS3820_CONTROL_STATUS, control_status);
|
||||
#endif
|
||||
return status;
|
||||
return vme_A32D32_write(device, sis3820_base+SIS3820_CONTROL_STATUS, control_status);
|
||||
}
|
||||
|
||||
/*------- sis3820_copy_disable_channel -------------------------------------------*/
|
||||
@@ -252,14 +196,7 @@ int sis3820_control_write(int device, u_int32_t sis3820_base, u_int32_t control_
|
||||
*/
|
||||
int sis3820_copy_disable_channel(int device, u_int32_t sis3820_base, u_int32_t channel_disable)
|
||||
{
|
||||
int status;
|
||||
|
||||
#ifdef HAVE_TEST_RUN
|
||||
status = 0;
|
||||
#else
|
||||
status = vme_A32D32_write(device, sis3820_base+SIS3820_COPY_DISABLE, channel_disable);
|
||||
#endif
|
||||
return status;
|
||||
return vme_A32D32_write(device, sis3820_base+SIS3820_COPY_DISABLE, channel_disable);
|
||||
}
|
||||
|
||||
/*-------- sis3820_scaler_read ----------------------------------------------------*/
|
||||
@@ -283,9 +220,6 @@ int sis3820_scaler_read(int device, u_int32_t sis3820_base, int mode, int nwords
|
||||
int status ;
|
||||
int gotwords;
|
||||
|
||||
#ifdef HAVE_TEST_RUN
|
||||
status = 0;
|
||||
#else
|
||||
status = -2;
|
||||
|
||||
switch (mode)
|
||||
@@ -320,7 +254,6 @@ int sis3820_scaler_read(int device, u_int32_t sis3820_base, int mode, int nwords
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -200,9 +200,6 @@ INT frontend_init()
|
||||
flag_scaler_address_1 = FALSE;}
|
||||
|
||||
/*--- VME initialization ---*/
|
||||
#ifdef HAVE_TEST_RUN
|
||||
hdev = 0;
|
||||
#else
|
||||
cm_msg(MINFO, "frontend_init","LINUX_VERSION = 0x%x",LINUX_VERSION_CODE);
|
||||
cm_yield(0);
|
||||
if (LINUX_VERSION_CODE < 0x20600) // for sis1100 drivers < V2, Linux kernel 2.4
|
||||
@@ -216,7 +213,6 @@ INT frontend_init()
|
||||
cm_yield(0);
|
||||
return FE_ERR_HW;
|
||||
}
|
||||
#endif
|
||||
|
||||
//SIS3820 scaler initialization
|
||||
if (init_sis3820(SIS3820_ADDRESS_0) == FE_ERR_HW)
|
||||
@@ -427,11 +423,6 @@ INT interrupt_configure(INT cmd, INT source, PTYPE adr)
|
||||
* <p> Read out of scaler modules.
|
||||
* </p>
|
||||
*
|
||||
* <p> If HAVE_TEST_RUN is defined scaler entries
|
||||
* of about 100 are thrown. If not defined
|
||||
* use the function <b>sis3820_read_scaler</b>
|
||||
* to read out the VME scaler module.
|
||||
*
|
||||
* <p><b>Return:</b>
|
||||
* - bank size of scaler event
|
||||
*
|
||||
@@ -450,23 +441,6 @@ INT read_scaler_event(char *pevent, INT off)
|
||||
bk_create(pevent, "SCL0", TID_DWORD, (void**)&pdata);
|
||||
|
||||
// read out scaler module /
|
||||
#ifdef HAVE_TEST_RUN
|
||||
int channel = 0;
|
||||
for (i=0; i<N_SCALER ; i++) {
|
||||
|
||||
/*---------------------------------------------------------
|
||||
simulate the case when user bits and channel number are sent
|
||||
in the first 8 bits, scaler data in the remaining 24 bits
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
|
||||
if ( scaler_settings["input_mode_3"] )
|
||||
channel = i << 24;
|
||||
else
|
||||
channel = 0;
|
||||
*pdata++ = (100 + rand()%40-20) | channel;
|
||||
}
|
||||
#else
|
||||
//read 1st scaler
|
||||
if (flag_scaler_address_0) {
|
||||
status = sis3820_scaler_read( hdev, SIS3820_ADDRESS_0, A32BLT32, N_SCALER_MODULE, data);
|
||||
@@ -500,7 +474,6 @@ INT read_scaler_event(char *pevent, INT off)
|
||||
for (i=0; i<N_SCALER_MODULE; i++)
|
||||
*pdata++ = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
bk_close(pevent, pdata);
|
||||
|
||||
@@ -509,11 +482,6 @@ INT read_scaler_event(char *pevent, INT off)
|
||||
return bk_size(pevent);
|
||||
}
|
||||
|
||||
/* -------------- other functions -----------
|
||||
void scaler_mode(u_int32_t module_address )
|
||||
int init_sis3820(u_int32_t module_address)
|
||||
*/
|
||||
|
||||
/*! <p> scaler_mode is called at begin_of_run.
|
||||
* It reads the ODB record <b><i>/Equipment/Scaler/Settings</i></b>
|
||||
* and checks if the variable
|
||||
@@ -758,8 +726,6 @@ INT scaler_sum( char *pevent)
|
||||
double *psrat;
|
||||
INT *pd;
|
||||
INT *psratio;
|
||||
//RATE_BANK *prate;
|
||||
//SRAT_BANK *psrat;
|
||||
double new_lem_events;
|
||||
int norm_time_ch;
|
||||
|
||||
@@ -791,26 +757,9 @@ INT scaler_sum( char *pevent)
|
||||
|
||||
/* --- create rate bank and calculate rates --- */
|
||||
|
||||
//bk_create(pevent, "RATE", TID_STRUCT, (void **)&prate);
|
||||
bk_create(pevent, "RATE", TID_DOUBLE, (void **)&prate);
|
||||
|
||||
//pd = &prate->ip; // copy address of first element of structure to pointer pd
|
||||
// this is useful if the structure contains n elements of same type,
|
||||
// i.e. (double) in our case. If element names should be different
|
||||
// then this offers a simple way to assign values to the elements
|
||||
// without explicitly entering the element name.
|
||||
// This will work with the statement
|
||||
// *(pd+i) = rate[i]; see below
|
||||
//not using a struct anymore.
|
||||
|
||||
for (i=0; i<n; i++) {
|
||||
#ifdef HAVE_TEST_RUN
|
||||
norm = 10.;
|
||||
if (i == scaler_param["channel_norm_time"])
|
||||
rate[i] = 1000;
|
||||
else
|
||||
rate[i] = (int) rint(mask_scaler[i]/norm);
|
||||
#else
|
||||
norm_time_ch=scaler_param["channel_norm_time"];
|
||||
if (mask_scaler[norm_time_ch] > 0) {
|
||||
norm = (double)mask_scaler[norm_time_ch]/(double)scaler_param["rate_norm_time"];
|
||||
@@ -818,41 +767,16 @@ INT scaler_sum( char *pevent)
|
||||
} else {
|
||||
rate[i] = -1;
|
||||
}
|
||||
#endif
|
||||
//prate->rat0[i] = rate[i];
|
||||
//*(pd+i) = rate[i]; // increment pointer address by the size of one double, assign
|
||||
// value of rate[i] to new address,
|
||||
// which is the ith entry of the structure prate
|
||||
prate[i] = rate[i];
|
||||
}
|
||||
bk_close(pevent, prate+n);
|
||||
|
||||
/*
|
||||
//TODO: TDC rate is already in odb. Not clear, why it should be duplicated here.?
|
||||
// get LEM events from VME_STATS key in ODB
|
||||
new_lem_events = 0.;
|
||||
size = sizeof(lem_events);
|
||||
//db_get_value(hDB, 0, "/Equipment/Trigger/VME_Statistics/SlowMuonEvents", &lem_events, &size, TID_DOUBLE, FALSE);
|
||||
db_get_value(hDB, 0, "/Equipment/TDC/Vme_Statistics/Muon Good", &lem_events, &size, TID_DOUBLE, FALSE);
|
||||
new_lem_events = lem_events - last_lem_events;
|
||||
last_lem_events = lem_events;
|
||||
if (new_lem_events < 0.0)
|
||||
new_lem_events = 0.0; // this may happen at BOR
|
||||
norm_time_ch=scaler_param["channel_norm_time"];
|
||||
if (mask_scaler[norm_time_ch] > 0)
|
||||
rate[i] = (int) rint(new_lem_events/norm);
|
||||
else
|
||||
rate[i] = -1;
|
||||
*(pd+i) = rate[i];
|
||||
|
||||
bk_close(pevent, prate+1);*/
|
||||
|
||||
/*----------------------------------------------------------------
|
||||
calculate scaler ratios
|
||||
----------------------------------------------------------------
|
||||
*/
|
||||
/* create calculated bank */
|
||||
//bk_create(pevent, "SRAT", TID_STRUCT, (void **)&psrat);
|
||||
bk_create(pevent, "SRAT", TID_DOUBLE, (void **)&psrat);
|
||||
|
||||
//psratio = &psrat->ip; // copy address of first element of structure to pointer psratio
|
||||
@@ -860,23 +784,13 @@ INT scaler_sum( char *pevent)
|
||||
//---- perform calculations --------------------------------------/
|
||||
int ip_channel=scaler_param["ip_channel"];
|
||||
if (rate[ip_channel] > scaler_param["ip_threshold_current_ua_"]*100) {
|
||||
// psrat->ch1_ip = IpSCALE * (float) prate->rat0[0] / (float) prate->rat0[scaler_analysis_param.ip_channel];
|
||||
// psrat->ch1_ip = IpSCALE * (float) pd[0] / (float) pd[scaler_param.ip_channel];
|
||||
for (i=0; i<n+1; i++)
|
||||
//*(psratio+i) = (int) rint(IpSCALE * (float) pd[i] / (float) pd[ip_channel]);
|
||||
psrat[i] = (int) rint(IpSCALE * (float) rate[i] / (float) rate[ip_channel]);
|
||||
} else {
|
||||
for (i=0; i<n+1; i++){
|
||||
//*(psratio+i) = 0;
|
||||
psrat[i] =0;
|
||||
}
|
||||
}
|
||||
/* computer busy time = 1 - LAM2/Trig2 */
|
||||
/*
|
||||
if ( pscl0[hrates_param.trig2] != 0 )
|
||||
phrti->compbusy = 1. - (float) pscl0[hrates_param.lam2] / (float) pscl0[hrates_param.trig2];
|
||||
else
|
||||
*/
|
||||
bk_close(pevent, psrat+n);
|
||||
|
||||
//fill ring buffer for Ip
|
||||
@@ -909,21 +823,6 @@ INT scaler_sum( char *pevent)
|
||||
bk_close(pevent, pmean_rate+1);
|
||||
|
||||
// display scalers in terminal
|
||||
/*
|
||||
if (runinfo.online_mode == 1)
|
||||
disp_scaler(N_SCALER);*/
|
||||
|
||||
// send the normalized PosM1 Rate to EPICS
|
||||
|
||||
/* LEM alternative of feeding signal back to Hallensignale.
|
||||
char cmd[512];
|
||||
int posM1 = *(psratio+52); // channel 52 is PosM1
|
||||
setenv("EPICS_CA_SERVER_PORT", "5062", 0);
|
||||
setenv("EPICS_CA_ADDR_LIST", "hipa-cagw", 0);
|
||||
setenv("EPICS_CA_AUTO_ADDR_LIST", "NO", 0);
|
||||
snprintf(cmd, sizeof(cmd), "/usr/local/epics/base/bin/RHEL8-x86_64/caput ZMUE4-LEM:POSM1_RATE %d &> /dev/null", posM1);
|
||||
system(cmd);
|
||||
*/
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user