Low-Energy Muon (LEM) Experiment  0.5.1
hv_fug_scfe.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "midas.h"
#include "msystem.h"
#include "class/hv.h"
#include "hv_scs3000.h"
#include "bus/null.h"
Include dependency graph for hv_fug_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 FUG_CHS   16
 
#define FUG_READ_TIME   10
 
#define FUG_DEMAND_CHANGED_TIMEOUT   300
 
#define FUG_MC   0
 
#define FUG_TC   1
 
#define FUG_SC   2
 
#define TD_FIRST_CH   0
 
#define TD_LAST_CH   3
 
#define FUG_BEAMLINE_KV61_CH   28
 
#define FUG_BEAMLINE_KV62_CH   29
 

Functions

INT poll_event (INT source[], INT count, BOOL test)
 
INT interrupt_configure (INT cmd, INT source[], PTYPE adr)
 
void hv_fug_check_trip_level (INT, INT, void *)
 
void hv_fug_trip_rate_source_changed (INT hDB, INT hKey, void *dummy)
 
void hv_fug_scfe_monitoring (INT hDB, INT hKey, void *hv)
 
void hv_fug_scfe_gas_inlet (INT hDB, INT hKey, void *dummy)
 
void hv_fug_demand_changed (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 = "FUG"
 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...
 
INT hv_fug_detector_rate
 hotlink variable holding the TD or MCP1 rate More...
 
float * hv_detectors_measured
 hotlink variable holding the measured TD HV's More...
 
HNDLE hv_fug_hDB
 
HNDLE hv_fug_measured_hKey
 
float hv_fug_demand [FUG_CHS]
 
int hv_fug_chamber_flag [FUG_CHS]
 
DWORD hv_fug_demand_changed_timer
 
DWORD hv_fug_check_timestamp
 
int hv_fug_drop_counter [FUG_CHS]
 
int hv_fug_debug = 0
 
INT hv_fug_monitoring_enabled
 hotlink variable holding the monitoring enabled flag More...
 
char hv_fug_trip_rate_source [NAME_LENGTH]
 hotlink variable holding the name of the detector which is to monitor the rate More...
 
INT hv_fug_tripEnabled
 hotlink variable holding the trip enabled flag More...
 
INT hv_fug_tripRate
 hotlink variable holding the TD trip rate More...
 
INT hv_fug_hvAlreadyOff
 HV already switched off. More...
 
float lemvac_in [27]
 holds the lemvac input variables More...
 
const char * hv_fug_monitoring_str
 
DEVICE_DRIVER hv_driver []
 device driver list More...
 
EQUIPMENT equipment []
 equipment structure for the mfe.c More...
 

Macro Definition Documentation

#define FUG_BEAMLINE_KV61_CH   28

Definition at line 59 of file hv_fug_scfe.c.

Referenced by hv_fug_check_trip_level().

#define FUG_BEAMLINE_KV62_CH   29

Definition at line 60 of file hv_fug_scfe.c.

Referenced by hv_fug_check_trip_level().

#define FUG_CHS   16
#define FUG_DEMAND_CHANGED_TIMEOUT   300

Definition at line 52 of file hv_fug_scfe.c.

Referenced by frontend_loop().

#define FUG_MC   0

Definition at line 53 of file hv_fug_scfe.c.

Referenced by frontend_init(), and hv_fug_scfe_gas_inlet().

#define FUG_READ_TIME   10

Definition at line 51 of file hv_fug_scfe.c.

Referenced by frontend_loop().

#define FUG_SC   2

Definition at line 55 of file hv_fug_scfe.c.

Referenced by frontend_init(), and hv_fug_scfe_gas_inlet().

#define FUG_TC   1

Definition at line 54 of file hv_fug_scfe.c.

Referenced by frontend_init(), and hv_fug_scfe_gas_inlet().

#define LEMVAC_GAS_INLET_ON   0x80

Definition at line 45 of file hv_fug_scfe.c.

Referenced by hv_fug_scfe_gas_inlet().

#define LEMVAC_MC_STATUS_WORD_2   15

Definition at line 46 of file hv_fug_scfe.c.

Referenced by hv_fug_scfe_gas_inlet().

#define LEMVAC_SC_STATUS_WORD_2   21

Definition at line 48 of file hv_fug_scfe.c.

Referenced by hv_fug_scfe_gas_inlet().

#define LEMVAC_TC_STATUS_WORD_2   18

Definition at line 47 of file hv_fug_scfe.c.

Referenced by hv_fug_scfe_gas_inlet().

#define TD_FIRST_CH   0

Definition at line 57 of file hv_fug_scfe.c.

Referenced by hv_fug_scfe_monitoring().

#define TD_LAST_CH   3

Definition at line 58 of file hv_fug_scfe.c.

Referenced by hv_fug_scfe_monitoring().

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 853 of file hv_fug_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 863 of file hv_fug_scfe.c.

INT frontend_exit ( )

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

Definition at line 690 of file hv_fug_scfe.c.

References hDB, hKey, hv_detectors_measured, and hv_fug_trip_rate_source.

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 the trigger detector rate. If it is getting too high, depending on the switches, the HV of the transport system is switched off. For further details see the corresponding hotlink dispatcher functions.

Definition at line 495 of file hv_fug_scfe.c.

References FUG_CHS, FUG_MC, FUG_SC, FUG_TC, hDB, hKey, hv_detectors_measured, hv_fug_chamber_flag, hv_fug_check_timestamp, hv_fug_check_trip_level(), hv_fug_demand, hv_fug_demand_changed(), hv_fug_demand_changed_timer, hv_fug_detector_rate, hv_fug_drop_counter, hv_fug_hDB, hv_fug_hvAlreadyOff, hv_fug_measured_hKey, hv_fug_monitoring_enabled, hv_fug_monitoring_str, hv_fug_scfe_gas_inlet(), hv_fug_scfe_monitoring(), hv_fug_trip_rate_source, hv_fug_trip_rate_source_changed(), hv_fug_tripEnabled, hv_fug_tripRate, and lemvac_in.

INT frontend_loop ( )

Called by the mfe in the main loop. Here it is only a dummy.

Definition at line 793 of file hv_fug_scfe.c.

References FUG_CHS, FUG_DEMAND_CHANGED_TIMEOUT, FUG_READ_TIME, hKey, hv_fug_check_timestamp, hv_fug_debug, hv_fug_demand, hv_fug_demand_changed_timer, hv_fug_drop_counter, hv_fug_hDB, and hv_fug_measured_hKey.

void hv_fug_check_trip_level ( INT  hDB,
INT  hKey,
void *  hv 
)

If enabled (hv_fug_tripEnabled flag), this routine checks that the trigger detector rate is not too high (< hv_fug_tripRate). In case the maximum trigger detector rate is exeeded, the transport high voltage will be switched off.

Parameters
hDBmain ODB handle
hKeynot used
hvpointer to the measured TD rate

Definition at line 245 of file hv_fug_scfe.c.

References FUG_BEAMLINE_KV61_CH, FUG_BEAMLINE_KV62_CH, FUG_CHS, hv_fug_detector_rate, hv_fug_trip_rate_source, hv_fug_tripEnabled, and hv_fug_tripRate.

Referenced by frontend_init(), and hv_fug_trip_rate_source_changed().

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

Starts the FUG HV demand changed timer. It is used to suppress demand vs measured checking for a given time.

Parameters
hDBmain ODB handle
hKeyunused handle
dummynot used

Definition at line 481 of file hv_fug_scfe.c.

References hv_fug_demand_changed_timer.

Referenced by frontend_init().

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

This hotlink routine sets the values of the hv demand values of the FUG's in the chambers to zero, if the corresponding 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
hKeyhandle to the lemvac input
dummynot used

Definition at line 407 of file hv_fug_scfe.c.

References FUG_CHS, FUG_MC, FUG_SC, FUG_TC, hv_fug_chamber_flag, LEMVAC_GAS_INLET_ON, lemvac_in, LEMVAC_MC_STATUS_WORD_2, LEMVAC_SC_STATUS_WORD_2, and LEMVAC_TC_STATUS_WORD_2.

Referenced by frontend_init().

void hv_fug_scfe_monitoring ( INT  hDB,
INT  hKey,
void *  hv 
)

If enabled (hv_fug_monitoring_enabled flag), this routine checks whether the trigger high voltage is switched on. If not, it will prevent to set any high voltage to the transport system.

Parameters
hDBmain ODB handle
hKeynot used
hvpointer to the measured TD hv's

Definition at line 341 of file hv_fug_scfe.c.

References hv_fug_hvAlreadyOff, hv_fug_monitoring_enabled, TD_FIRST_CH, and TD_LAST_CH.

Referenced by frontend_init().

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

As a HV trip source, the rates of either MCP1 or the TD can be used. This routine checks which one is the relvant one.

Parameters
hDBhandle to the ODB
hKeyODB key for the HV
dummynot used

Definition at line 159 of file hv_fug_scfe.c.

References hv_fug_check_trip_level(), hv_fug_detector_rate, and hv_fug_trip_rate_source.

Referenced by frontend_init().

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

Definition at line 144 of file hv_fug_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 873 of file hv_fug_scfe.c.

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

Definition at line 143 of file hv_fug_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 883 of file hv_fug_scfe.c.

Variable Documentation

INT display_period = 1000

a frontend status page is displayed with this frequency in ms

Definition at line 32 of file hv_fug_scfe.c.

EQUIPMENT equipment[]
Initial value:
= {
{ "HV",
{72, 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 114 of file hv_fug_scfe.c.

INT event_buffer_size = 10*10000

buffer size to hold events

Definition at line 41 of file hv_fug_scfe.c.

BOOL frontend_call_loop = TRUE

frontend_loop is called periodically if this variable is TRUE

Definition at line 29 of file hv_fug_scfe.c.

char* frontend_file_name = __FILE__

The frontend file name, don't change it.

Definition at line 26 of file hv_fug_scfe.c.

char* frontend_name = "FUG"

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

Definition at line 24 of file hv_fug_scfe.c.

float* hv_detectors_measured

hotlink variable holding the measured TD HV's

Definition at line 66 of file hv_fug_scfe.c.

Referenced by frontend_exit(), frontend_init(), frontend_loop(), and hv_detectors_scfe_td_check().

DEVICE_DRIVER hv_driver[]
Initial value:
= {
{ "hv_spin_rot", hv_scs3000, 4, null, DF_PRIO_DEVICE },
{ "hv_mc_tc", hv_scs3000, 7, null, DF_PRIO_DEVICE },
{ "hv_sc", hv_scs3000, 5, null, DF_PRIO_DEVICE }
}

device driver list

Definition at line 107 of file hv_fug_scfe.c.

int hv_fug_chamber_flag[FUG_CHS]

Definition at line 75 of file hv_fug_scfe.c.

Referenced by frontend_init(), and hv_fug_scfe_gas_inlet().

DWORD hv_fug_check_timestamp

Definition at line 79 of file hv_fug_scfe.c.

Referenced by frontend_init(), and frontend_loop().

int hv_fug_debug = 0

Definition at line 84 of file hv_fug_scfe.c.

Referenced by frontend_loop().

float hv_fug_demand[FUG_CHS]

Definition at line 73 of file hv_fug_scfe.c.

Referenced by frontend_init(), and frontend_loop().

DWORD hv_fug_demand_changed_timer

Definition at line 77 of file hv_fug_scfe.c.

Referenced by frontend_init(), frontend_loop(), and hv_fug_demand_changed().

INT hv_fug_detector_rate

hotlink variable holding the TD or MCP1 rate

Definition at line 63 of file hv_fug_scfe.c.

Referenced by frontend_init(), hv_fug_check_trip_level(), and hv_fug_trip_rate_source_changed().

int hv_fug_drop_counter[FUG_CHS]

Definition at line 81 of file hv_fug_scfe.c.

Referenced by frontend_init(), and frontend_loop().

HNDLE hv_fug_hDB

Definition at line 69 of file hv_fug_scfe.c.

Referenced by frontend_init(), and frontend_loop().

INT hv_fug_hvAlreadyOff

HV already switched off.

Definition at line 91 of file hv_fug_scfe.c.

Referenced by frontend_init(), and hv_fug_scfe_monitoring().

HNDLE hv_fug_measured_hKey

Definition at line 70 of file hv_fug_scfe.c.

Referenced by frontend_init(), and frontend_loop().

INT hv_fug_monitoring_enabled

hotlink variable holding the monitoring enabled flag

Definition at line 87 of file hv_fug_scfe.c.

Referenced by frontend_init(), and hv_fug_scfe_monitoring().

const char* hv_fug_monitoring_str
Initial value:
=
"FUG Monitoring = INT : 0\n\
Trip Rate Source = STRING : [32] TD\n\
Trip Enabled = INT : 1\n\
Trip Level = INT : 1500000\n\
"

Definition at line 97 of file hv_fug_scfe.c.

Referenced by frontend_init().

char hv_fug_trip_rate_source[NAME_LENGTH]

hotlink variable holding the name of the detector which is to monitor the rate

Definition at line 88 of file hv_fug_scfe.c.

Referenced by frontend_exit(), frontend_init(), hv_fug_check_trip_level(), and hv_fug_trip_rate_source_changed().

INT hv_fug_tripEnabled

hotlink variable holding the trip enabled flag

Definition at line 89 of file hv_fug_scfe.c.

Referenced by frontend_init(), and hv_fug_check_trip_level().

INT hv_fug_tripRate

hotlink variable holding the TD trip rate

Definition at line 90 of file hv_fug_scfe.c.

Referenced by frontend_init(), and hv_fug_check_trip_level().

float lemvac_in[27]

holds the lemvac input variables

Definition at line 94 of file hv_fug_scfe.c.

Referenced by frontend_init(), hv_detectors_scfe_gas_inlet(), and hv_fug_scfe_gas_inlet().

INT max_event_size = 10000

maximum event size produced by this frontend

Definition at line 35 of file hv_fug_scfe.c.

INT max_event_size_frag = 5*1024*1024

maximum event size for fragmented events (EQ_FRAGMENTED)

Definition at line 38 of file hv_fug_scfe.c.