Low-Energy Muon (LEM) Experiment  0.5.1
hv_detectors_scfe.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "midas.h"
#include "class/hv.h"
#include "hv_nhr.h"
#include "hvr400.h"
#include "hv_scs2001_apd.h"
#include "hpx30_107.h"
#include "tcpip_rs232.h"
#include "bus/null.h"
Include dependency graph for hv_detectors_scfe.c:

Go to the source code of this file.

Macros

#define LEMVAC_GAS_INLET_ON   0x80
 
#define LEMVAC_MC_STATUS_WORD_2   15
 
#define LEMVAC_TC_STATUS_WORD_2   18
 
#define LEMVAC_SC_STATUS_WORD_2   21
 
#define TD_FIRST_CH   0
 
#define TD_LAST_CH   3
 
#define MCP1_CH   4
 
#define MCP2_FIRST_CH   6
 
#define MCP2_LAST_CH   7
 
#define POS_MCP1_I   12
 
#define POS_MCP1_O   13
 
#define HV_TD_MAX_COUNT   30
 
#define HV_DETECTOR_CHANNELS   94
 
#define HV_DETECTOR_READ_TIME   10
 

Functions

INT poll_event (INT source[], INT count, BOOL test)
 
INT interrupt_configure (INT cmd, INT source[], PTYPE adr)
 
void hv_detectors_scfe_gas_inlet (INT hDB, INT hKey, void *dummy)
 
void hv_detectors_scfe_td_check (INT hDB, INT hKey, void *dummy)
 
INT frontend_init ()
 
INT frontend_exit ()
 
INT frontend_loop ()
 
INT begin_of_run (INT run_number, char *error)
 
INT end_of_run (INT run_number, char *error)
 
INT pause_run (INT run_number, char *error)
 
INT resume_run (INT run_number, char *error)
 

Variables

char * frontend_name = "HV Detectors"
 The frontend name (client name) as seen by other MIDAS clients. More...
 
char * frontend_file_name = __FILE__
 The frontend file name, don't change it. More...
 
BOOL frontend_call_loop = TRUE
 frontend_loop is called periodically if this variable is TRUE More...
 
INT display_period = 1000
 a frontend status page is displayed with this frequency in ms More...
 
INT max_event_size = 10000
 maximum event size produced by this frontend More...
 
INT max_event_size_frag = 5*1024*1024
 maximum event size for fragmented events (EQ_FRAGMENTED) More...
 
INT event_buffer_size = 10*10000
 buffer size to hold events More...
 
HNDLE hv_detectors_hDB
 
HNDLE hv_detectors_measured_hKey
 
int hv_detectors_drop_counter [HV_DETECTOR_CHANNELS]
 
char hv_detectors_names [HV_DETECTOR_CHANNELS *NAME_LENGTH]
 
float hv_detectors_demand [HV_DETECTOR_CHANNELS]
 
float hv_detectors_measured [HV_DETECTOR_CHANNELS]
 
int hv_td_hv_check_counter
 counter needed in the TD HV check More...
 
INT hv_monitoring_enabled
 Monitoring enabled (hotlinked) More...
 
INT hv_hvAlreadyOff
 HV already switched off. More...
 
float lemvac_in [27]
 holds the status info of lemvac input variables More...
 
DWORD hv_dectector_timestamp
 cyclic timer to check hv's More...
 
DEVICE_DRIVER hv_driver []
 device driver list More...
 
EQUIPMENT equipment []
 equipment structure for the mfe.c More...
 

Macro Definition Documentation

#define HV_DETECTOR_CHANNELS   94

Definition at line 62 of file hv_detectors_scfe.c.

Referenced by frontend_init(), and frontend_loop().

#define HV_DETECTOR_READ_TIME   10

Definition at line 64 of file hv_detectors_scfe.c.

Referenced by frontend_loop().

#define HV_TD_MAX_COUNT   30

Definition at line 60 of file hv_detectors_scfe.c.

Referenced by hv_detectors_scfe_td_check().

#define LEMVAC_GAS_INLET_ON   0x80

Definition at line 48 of file hv_detectors_scfe.c.

Referenced by hv_detectors_scfe_gas_inlet().

#define LEMVAC_MC_STATUS_WORD_2   15

Definition at line 49 of file hv_detectors_scfe.c.

Referenced by hv_detectors_scfe_gas_inlet().

#define LEMVAC_SC_STATUS_WORD_2   21

Definition at line 51 of file hv_detectors_scfe.c.

Referenced by hv_detectors_scfe_gas_inlet().

#define LEMVAC_TC_STATUS_WORD_2   18

Definition at line 50 of file hv_detectors_scfe.c.

Referenced by hv_detectors_scfe_gas_inlet().

#define MCP1_CH   4

Definition at line 54 of file hv_detectors_scfe.c.

Referenced by hv_detectors_scfe_gas_inlet().

#define MCP2_FIRST_CH   6

Definition at line 55 of file hv_detectors_scfe.c.

Referenced by hv_detectors_scfe_gas_inlet().

#define MCP2_LAST_CH   7

Definition at line 56 of file hv_detectors_scfe.c.

Referenced by hv_detectors_scfe_gas_inlet().

#define POS_MCP1_I   12

Definition at line 57 of file hv_detectors_scfe.c.

Referenced by frontend_loop().

#define POS_MCP1_O   13

Definition at line 58 of file hv_detectors_scfe.c.

Referenced by frontend_loop().

#define TD_FIRST_CH   0

Definition at line 52 of file hv_detectors_scfe.c.

Referenced by hv_detectors_scfe_gas_inlet(), and hv_detectors_scfe_td_check().

#define TD_LAST_CH   3

Definition at line 53 of file hv_detectors_scfe.c.

Referenced by hv_detectors_scfe_gas_inlet().

Function Documentation

INT begin_of_run ( INT  run_number,
char *  error 
)

Called by the mfe at the begin of the run. Here it is only a dummy.

Definition at line 452 of file hv_detectors_scfe.c.

INT end_of_run ( INT  run_number,
char *  error 
)

Called by the mfe at the end of the run. Here it is only a dummy.

Definition at line 462 of file hv_detectors_scfe.c.

INT frontend_exit ( )

Called by the mfe at exiting stage. Unlinks all the established hotlinks.

Definition at line 338 of file hv_detectors_scfe.c.

References hDB, and hKey.

INT frontend_init ( )

Called by the master frontend (mfe) at initializing stage. It hotlinks various variables which are needed for safety reasons. It monitors for example if the gas inlet is activated, and if yes, shuts down the high voltage of the corresponding chamber. For further details see the corresponding hotlink dispatcher functions.

Definition at line 250 of file hv_detectors_scfe.c.

References hDB, hKey, hv_dectector_timestamp, HV_DETECTOR_CHANNELS, hv_detectors_demand, hv_detectors_drop_counter, hv_detectors_hDB, hv_detectors_measured, hv_detectors_measured_hKey, hv_detectors_names, hv_detectors_scfe_gas_inlet(), hv_detectors_scfe_td_check(), hv_hvAlreadyOff, hv_monitoring_enabled, hv_td_hv_check_counter, and lemvac_in.

INT frontend_loop ( )

Called by the mfe in the main loop, if the frontend_call_loop flag is set to TRUE.

It cyclically reads the measured detector HV's and checks that they are not too strongly are deviating from the demand ones.

Definition at line 384 of file hv_detectors_scfe.c.

References hKey, hv_dectector_timestamp, HV_DETECTOR_CHANNELS, HV_DETECTOR_READ_TIME, hv_detectors_demand, hv_detectors_drop_counter, hv_detectors_hDB, hv_detectors_measured, hv_detectors_measured_hKey, hv_detectors_names, offset, POS_MCP1_I, and POS_MCP1_O.

void hv_detectors_scfe_gas_inlet ( INT  hDB,
INT  hKey,
void *  dummy 
)

This hotlink routine sets the values of the hv demand values of the various chamber to zero, if the gas inlet flag of the vacuum control unit (lemvac) is set.

The purpose is the following: the vacuum control unit is switching the hv power supplies power off if the gas inlet is activated. Hence, if the demand values wouldn't be set to zero, after powering the hv power supplies again, the hv would just ramp back to there set values. This could lead to hv problems and therefore these demand values are set to zero.

Parameters
hDBmain ODB handle
hKeyunused handle
dummynot used

Definition at line 151 of file hv_detectors_scfe.c.

References LEMVAC_GAS_INLET_ON, lemvac_in, LEMVAC_MC_STATUS_WORD_2, LEMVAC_SC_STATUS_WORD_2, LEMVAC_TC_STATUS_WORD_2, MCP1_CH, MCP2_FIRST_CH, MCP2_LAST_CH, TD_FIRST_CH, and TD_LAST_CH.

Referenced by frontend_init().

void hv_detectors_scfe_td_check ( INT  hDB,
INT  hKey,
void *  dummy 
)
Parameters
hDBmain ODB handle
hKeyhandle to the DB50 sc_status
dummynot used

Definition at line 217 of file hv_detectors_scfe.c.

References hv_detectors_measured, hv_td_hv_check_counter, HV_TD_MAX_COUNT, and TD_FIRST_CH.

Referenced by frontend_init().

INT interrupt_configure ( INT  cmd,
INT  source[],
PTYPE  adr 
)

Definition at line 132 of file hv_detectors_scfe.c.

INT pause_run ( INT  run_number,
char *  error 
)

Called by the mfe when the run is paused. Here it is only a dummy.

Definition at line 472 of file hv_detectors_scfe.c.

INT poll_event ( INT  source[],
INT  count,
BOOL  test 
)

Definition at line 131 of file hv_detectors_scfe.c.

INT resume_run ( INT  run_number,
char *  error 
)

Called by the mfe when the run is resumed. Here it is only a dummy.

Definition at line 482 of file hv_detectors_scfe.c.

Variable Documentation

INT display_period = 1000

a frontend status page is displayed with this frequency in ms

Definition at line 35 of file hv_detectors_scfe.c.

EQUIPMENT equipment[]
Initial value:
= {
{ "HV Detectors",
{73, 0,
"SYSTEM",
EQ_SLOW,
0,
"FIXED",
TRUE,
RO_RUNNING |
RO_TRANSITIONS,
30000,
0,
0,
1,
"", "", "",},
cd_hv_read,
cd_hv,
NULL,
},
{ "" }
}
DEVICE_DRIVER hv_driver[]
device driver list
Definition: hv_fug_scfe.c:107

equipment structure for the mfe.c

Definition at line 102 of file hv_detectors_scfe.c.

INT event_buffer_size = 10*10000

buffer size to hold events

Definition at line 44 of file hv_detectors_scfe.c.

BOOL frontend_call_loop = TRUE

frontend_loop is called periodically if this variable is TRUE

Definition at line 32 of file hv_detectors_scfe.c.

char* frontend_file_name = __FILE__

The frontend file name, don't change it.

Definition at line 29 of file hv_detectors_scfe.c.

char* frontend_name = "HV Detectors"

The frontend name (client name) as seen by other MIDAS clients.

Definition at line 27 of file hv_detectors_scfe.c.

DWORD hv_dectector_timestamp

cyclic timer to check hv's

Definition at line 82 of file hv_detectors_scfe.c.

Referenced by frontend_init(), and frontend_loop().

float hv_detectors_demand[HV_DETECTOR_CHANNELS]

Definition at line 71 of file hv_detectors_scfe.c.

Referenced by frontend_init(), and frontend_loop().

int hv_detectors_drop_counter[HV_DETECTOR_CHANNELS]

Definition at line 69 of file hv_detectors_scfe.c.

Referenced by frontend_init(), and frontend_loop().

HNDLE hv_detectors_hDB

Definition at line 66 of file hv_detectors_scfe.c.

Referenced by frontend_init(), and frontend_loop().

float hv_detectors_measured[HV_DETECTOR_CHANNELS]

Definition at line 72 of file hv_detectors_scfe.c.

HNDLE hv_detectors_measured_hKey

Definition at line 67 of file hv_detectors_scfe.c.

Referenced by frontend_init(), and frontend_loop().

char hv_detectors_names[HV_DETECTOR_CHANNELS *NAME_LENGTH]

Definition at line 70 of file hv_detectors_scfe.c.

Referenced by frontend_init(), and frontend_loop().

DEVICE_DRIVER hv_driver[]
Initial value:
= {
{ "TD", hv_nhr, 4, null, DF_PRIO_DEVICE | DF_HW_RAMP | DF_REPORT_STATUS | DF_REPORT_TEMP },
{ "MCP", hv_nhr, 4, null, DF_PRIO_DEVICE | DF_HW_RAMP | DF_REPORT_STATUS | DF_REPORT_TEMP },
{ "PHVR400_1", hvr400, 4, null, DF_PRIO_DEVICE | DF_HW_RAMP },
{ "PHVR400_2", hvr400, 4, null, DF_PRIO_DEVICE | DF_HW_RAMP },
{ "PHVR400_3", hvr400, 4, null, DF_PRIO_DEVICE | DF_HW_RAMP },
{ "NHVR400_1", hvr400, 4, null, DF_PRIO_DEVICE | DF_HW_RAMP },
{ "NHVR400_2", hvr400, 4, null, DF_PRIO_DEVICE | DF_HW_RAMP },
{ "HPP30_107", hpx30_107, 1, tcpip_rs232, DF_PRIO_DEVICE },
{ "HPN30_107", hpx30_107, 1, tcpip_rs232, DF_PRIO_DEVICE },
{ "HV_APD", hv_scs2001_apd, 64, null, DF_PRIO_DEVICE | DF_HW_RAMP },
{ "" }
}
INT hvr400(INT cmd,...)
Definition: hvr400.c:670

device driver list

Definition at line 87 of file hv_detectors_scfe.c.

INT hv_hvAlreadyOff

HV already switched off.

Definition at line 77 of file hv_detectors_scfe.c.

Referenced by frontend_init().

INT hv_monitoring_enabled

Monitoring enabled (hotlinked)

Definition at line 76 of file hv_detectors_scfe.c.

Referenced by frontend_init().

int hv_td_hv_check_counter

counter needed in the TD HV check

Definition at line 73 of file hv_detectors_scfe.c.

Referenced by frontend_init(), and hv_detectors_scfe_td_check().

float lemvac_in[27]

holds the status info of lemvac input variables

Definition at line 80 of file hv_detectors_scfe.c.

INT max_event_size = 10000

maximum event size produced by this frontend

Definition at line 38 of file hv_detectors_scfe.c.

INT max_event_size_frag = 5*1024*1024

maximum event size for fragmented events (EQ_FRAGMENTED)

Definition at line 41 of file hv_detectors_scfe.c.