Low-Energy Muon (LEM) Experiment
0.5.1
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdarg.h>
#include "midas.h"
#include "msystem.h"
#include "hv_fug.h"
#include "ets_logout.h"
#include "lemSCWatchdog.h"
Go to the source code of this file.
Data Structures | |
struct | HV_FUG_SETTINGS |
stores internal informations within the DD. More... | |
struct | HV_FUG_INFO |
struct | HV_FUG_FP |
Macros | |
#define | FP_1000 0x0001 |
RS 232 Network-Module. More... | |
#define | FP_1001 0x0002 |
RS 485 module, not used for NEMU. More... | |
#define | FP_AI_110 0x0101 |
16-bit-Analog-Input More... | |
#define | FP_AO_200 0x0102 |
12-bit-Analog-Output (Current), not used anymore for NEMU More... | |
#define | FP_DI_330 0x0103 |
not used for NEMU More... | |
#define | FP_DO_400 0x0104 |
not used for NEMU More... | |
#define | FP_DI_301 0x0105 |
not used for NEMU More... | |
#define | FP_DO_401 0x0106 |
not used for NEMU More... | |
#define | FP_TC_120 0x0107 |
not used for NEMU More... | |
#define | FP_RLY_420 0x0108 |
relay module More... | |
#define | FP_DI_300 0x0109 |
not used for NEMU More... | |
#define | FP_AI_100 0x010A |
not used for NEMU More... | |
#define | FP_RTD_122 0x010B |
not used for NEMU More... | |
#define | FP_AI_111 0x010C |
not used for NEMU More... | |
#define | FP_AO_210 0x010F |
12-bit-Analog-Output (Voltage) More... | |
#define | FP_IO_NUM_CH 8 |
channels per moduleMore... | |
#define | FP_AI_110_RANGE 0x04 |
0 - 10.4 V More... | |
#define | FP_AI_110_FILTER 0x00 |
60 Hz More... | |
#define | FP_AO_210_RANGE 0x04 |
0 - 10.2 V More... | |
#define | FP_RLY_SETTING 0x10 |
default reply More... | |
#define | FP_IO_RESOL 65536 |
resolution of the i/o commands 2^16 More... | |
#define | FP_AO_NORM 0.9804 |
Max FUG prog / Max AO. More... | |
#define | FP_AI_NORM 1.04 |
Max AI / Max FUG prog. More... | |
#define | FP_ERR_PUCLR_EXP 0x00 |
#define | HV_FUG_TIME_OUT 3000 |
time out for read rs232 communication in (ms). More... | |
#define | HV_FUG_MAX_ERROR 5 |
maximum number of error messages More... | |
#define | HV_FUG_DELTA_TIME_ERROR 3600 |
reset error counter after HV_FUG_DELTA_TIME_ERROR seconds More... | |
#define | HV_FUG_MAX_READBACK_FAILURE 5 |
maximum number of readback failures before a reconnect will take place More... | |
#define | HV_FUG_RECONNECTION_TIMEOUT 10 |
timeout in (sec) for before trying to reconnect again (after a communication breakdown) More... | |
#define | HV_FUG_READ_ERROR -99 |
return value in case a read back error occured More... | |
#define | HV_FUG_ETS_LOGOUT_SLEEP 10000 |
sleep time (us) between the telnet commands of the ets_logout More... | |
#define | HV_FUG_SETTINGS_INTERNAL_STR "\Detailed Messages = INT : 0\n\ETS_IN_USE = INT : 1\n\SCW_IN_USE = INT : 1\n\" |
#define | HV_FUG_SETTINGS_ODB_OFFSET_STR "\ODB Channel Offset = INT : 0\n\" |
#define | HV_FUG_SETTINGS_NO_STR "\No of FP-IO Modules = INT : 9\n\" |
#define | HV_FUG_SETTINGS_MODULE_STR "\Modules = STRING : [128] 0:FP-1000; 1:FP-AO-210; 2:FP-AI-110; 3:FP-AI-110; 4:FP-AO-210; 5:FP-AI-110; 6:FP-AO-210; 7:FP-AI-110; 8:FP-RLY-420;\n\" |
#define | HV_FUG_SETTINGS_OUT_STR "\FUG fp mapping output = STRING[12] : \n\[64] Moderator 04 0x0004 04 0x0008 N 00 0x0000 \n\[64] Mod_Guard 04 0x0010 04 0x0020 N 00 0x0000 \n\[64] Mod_Grid 01 0x0001 01 0x0002 N 00 0x0000 \n\[64] Lense_1 01 0x0004 01 0x0008 N 00 0x0000 \n\[64] Mirror 04 0x0001 04 0x0002 N 00 0x0000 \n\[64] Lense_2 01 0x0040 01 0x0080 N 00 0x0000 \n\[64] Lense_3 01 0x0010 01 0x0020 N 00 0x0000 \n\[64] RA-L 06 0x0010 06 0x0020 Y 08 0x0008 \n\[64] RA-R 06 0x0004 06 0x0008 Y 08 0x0004 \n\[64] RA-T 06 0x0001 06 0x0002 Y 08 0x0002 \n\[64] RA-B 04 0x0040 04 0x0080 Y 08 0x0001 \n\[64] Sample 06 0x0040 06 0x0080 Y 08 0x0010 \n\" |
#define | HV_FUG_SETTINGS_IN_STR "\FUG fp mapping input = STRING[12] : \n\[64] Moderator 03 0x0004 03 0x0008 N 00 0x0000 \n\[64] Mod_Guard 03 0x0010 03 0x0020 N 00 0x0000 \n\[64] Mod_Grid 02 0x0001 02 0x0002 N 00 0x0000 \n\[64] Lense_1 02 0x0004 02 0x0008 N 00 0x0000 \n\[64] Mirror 03 0x0001 03 0x0002 N 00 0x0000 \n\[64] Lense_2 02 0x0040 02 0x0080 N 00 0x0000 \n\[64] Lense_3 02 0x0010 02 0x0020 N 00 0x0000 \n\[64] RA-L 07 0x0010 07 0x0020 Y 05 0x0008 \n\[64] RA-R 07 0x0004 07 0x0008 Y 05 0x0004 \n\[64] RA-T 07 0x0001 07 0x0002 Y 05 0x0002 \n\[64] RA-B 03 0x0040 03 0x0080 Y 05 0x0001 \n\[64] Sample 07 0x0040 07 0x0080 Y 05 0x0010 \n\" |
#define | HV_FUG_SETTINGS_PROPERTIES_STR "\Properties = STRING[12] : \n\[64] Moderator @35.0kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] Mod_Guard @20.0kV #0.6mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] Mod_Grid @12.5kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] Lense_1 @12.5kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] Mirror @35.0kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] Lense_2 @35.0kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] Lense_3 @35.0kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] RA-L @35.0kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] RA-R @35.0kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] RA-T @20.0kV #0.6mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] RA-B @20.0kV #0.6mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] Sample @12.5kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\" |
#define | HV_FUG_SCW_STR "\Proc Name = STRING : [32]\n\PID = INT : -1\n\Log Name = STRING : [64]\n\DD Name = STRING : [32] FUG\n\Last Updated = DWORD : 0\n\Timeout = DWORD : 180\n\" |
defines the slowcontrol default watchdog info structure More... | |
Functions | |
INT | hv_fug_get (HV_FUG_INFO *info, INT channel, float *pvalue) |
INT | fp_error_msg (HV_FUG_INFO *info, char *where, char *error) |
void | mid_str (char *start, char *stop, char *line, char *result) |
void | sub_str (int start, int stop, char *line, char *result, int size_line, int size_result) |
char * | filter_sub_str (char *str, char *start, char *stop, char *result) |
int | chksumchk (char *line, char *chksum) |
int | chk_attrib_in (HV_FUG_INFO *info, int module, char *line) |
int | chk_attrib_out (HV_FUG_INFO *info, int module, char *line) |
int | chk_attrib_rly (HV_FUG_INFO *info, int module, char *line) |
void | err_bad_channels (char *line, int module, HV_FUG_INFO *info) |
static INT | hv_fug_update_db_settings (HNDLE hDB, HV_FUG_INFO *info, INT channels) |
static INT | fp_power_up_clear (HNDLE hDB, HV_FUG_INFO *info) |
static INT | fp_check_modules (HNDLE hDB, HV_FUG_INFO *info) |
static INT | fp_check_attrib_settings (HNDLE hDB, HV_FUG_INFO *info) |
static INT | fp_write_defaults (HNDLE hDB, HV_FUG_INFO *info) |
INT | hv_fug_init (HNDLE hKey, void **pinfo, INT channels, INT(*bd)(INT cmd,...)) |
INT | hv_fug_exit (HV_FUG_INFO *info) |
INT | hv_fug_set (HV_FUG_INFO *info, INT channel, float value) |
INT | hv_fug_get_label (INT channel, char *name) |
INT | hv_fug_get_current (HV_FUG_INFO *info, INT channel, float *pvalue) |
INT | hv_fug_set_current_limit (HV_FUG_INFO *info, INT channel, float limit) |
INT | hv_fug (INT cmd,...) |
Variables | |
static HV_FUG_FP | hv_fug_fp_set [12] |
#define FP_AI_110_FILTER 0x00 |
#define FP_AI_110_RANGE 0x04 |
#define FP_AI_NORM 1.04 |
Max AI / Max FUG prog.
Definition at line 158 of file hv_fug.c.
Referenced by hv_fug_get(), and hv_fug_get_current().
#define FP_AO_200 0x0102 |
#define FP_AO_210_RANGE 0x04 |
#define FP_AO_NORM 0.9804 |
Max FUG prog / Max AO.
Definition at line 157 of file hv_fug.c.
Referenced by fp_write_defaults(), hv_fug_set(), and hv_fug_set_current_limit().
#define FP_ERR_PUCLR_EXP 0x00 |
defines starting with FP_ERR_* are error codes of the field point modules. For details see the field point module documentation of National Instruments.
Definition at line 166 of file hv_fug.c.
Referenced by fp_error_msg().
#define FP_IO_NUM_CH 8 |
Definition at line 151 of file hv_fug.c.
Referenced by chk_attrib_in(), chk_attrib_out(), chk_attrib_rly(), and fp_check_attrib_settings().
#define FP_IO_RESOL 65536 |
resolution of the i/o commands 2^16
Definition at line 156 of file hv_fug.c.
Referenced by fp_write_defaults(), hv_fug_get(), hv_fug_get_current(), hv_fug_set(), and hv_fug_set_current_limit().
#define FP_RLY_SETTING 0x10 |
#define HV_FUG_DELTA_TIME_ERROR 3600 |
reset error counter after HV_FUG_DELTA_TIME_ERROR seconds
Definition at line 194 of file hv_fug.c.
Referenced by hv_fug_get(), and hv_fug_get_current().
#define HV_FUG_ETS_LOGOUT_SLEEP 10000 |
sleep time (us) between the telnet commands of the ets_logout
Definition at line 204 of file hv_fug.c.
Referenced by hv_fug_get().
#define HV_FUG_MAX_ERROR 5 |
maximum number of error messages
Definition at line 193 of file hv_fug.c.
Referenced by chk_attrib_in(), chk_attrib_out(), chk_attrib_rly(), err_bad_channels(), fp_check_modules(), fp_error_msg(), fp_power_up_clear(), fp_write_defaults(), hv_fug_get(), hv_fug_get_current(), and hv_fug_set().
#define HV_FUG_MAX_READBACK_FAILURE 5 |
maximum number of readback failures before a reconnect will take place
Definition at line 197 of file hv_fug.c.
Referenced by hv_fug_get().
#define HV_FUG_READ_ERROR -99 |
return value in case a read back error occured
Definition at line 201 of file hv_fug.c.
Referenced by hv_fug_get().
#define HV_FUG_RECONNECTION_TIMEOUT 10 |
timeout in (sec) for before trying to reconnect again (after a communication breakdown)
Definition at line 199 of file hv_fug.c.
Referenced by hv_fug_get().
#define HV_FUG_SCW_STR "\Proc Name = STRING : [32]\n\PID = INT : -1\n\Log Name = STRING : [64]\n\DD Name = STRING : [32] FUG\n\Last Updated = DWORD : 0\n\Timeout = DWORD : 180\n\" |
defines the slowcontrol default watchdog info structure
Definition at line 403 of file hv_fug.c.
Referenced by hv_fug_init().
#define HV_FUG_SETTINGS_IN_STR "\FUG fp mapping input = STRING[12] : \n\[64] Moderator 03 0x0004 03 0x0008 N 00 0x0000 \n\[64] Mod_Guard 03 0x0010 03 0x0020 N 00 0x0000 \n\[64] Mod_Grid 02 0x0001 02 0x0002 N 00 0x0000 \n\[64] Lense_1 02 0x0004 02 0x0008 N 00 0x0000 \n\[64] Mirror 03 0x0001 03 0x0002 N 00 0x0000 \n\[64] Lense_2 02 0x0040 02 0x0080 N 00 0x0000 \n\[64] Lense_3 02 0x0010 02 0x0020 N 00 0x0000 \n\[64] RA-L 07 0x0010 07 0x0020 Y 05 0x0008 \n\[64] RA-R 07 0x0004 07 0x0008 Y 05 0x0004 \n\[64] RA-T 07 0x0001 07 0x0002 Y 05 0x0002 \n\[64] RA-B 03 0x0040 03 0x0080 Y 05 0x0001 \n\[64] Sample 07 0x0040 07 0x0080 Y 05 0x0010 \n\" |
Initializing sub-string for HV_FUG_SETTINGS. default mapping field point<->FUG of the input channels
Definition at line 350 of file hv_fug.c.
Referenced by hv_fug_init().
#define HV_FUG_SETTINGS_INTERNAL_STR "\Detailed Messages = INT : 0\n\ETS_IN_USE = INT : 1\n\SCW_IN_USE = INT : 1\n\" |
Initializing sub-string for HV_FUG_SETTINGS. Internal flags.
Definition at line 225 of file hv_fug.c.
Referenced by hv_fug_init().
#define HV_FUG_SETTINGS_MODULE_STR "\Modules = STRING : [128] 0:FP-1000; 1:FP-AO-210; 2:FP-AI-110; 3:FP-AI-110; 4:FP-AO-210; 5:FP-AI-110; 6:FP-AO-210; 7:FP-AI-110; 8:FP-RLY-420;\n\" |
Initializing sub-string for HV_FUG_SETTINGS. default device settings, field point and channel addresses
Definition at line 251 of file hv_fug.c.
Referenced by hv_fug_init().
#define HV_FUG_SETTINGS_NO_STR "\No of FP-IO Modules = INT : 9\n\" |
Initializing sub-string for HV_FUG_SETTINGS. default: how many FP-IO modules do exist, in which bank, and what type
Definition at line 243 of file hv_fug.c.
Referenced by hv_fug_init().
#define HV_FUG_SETTINGS_ODB_OFFSET_STR "\ODB Channel Offset = INT : 0\n\" |
Initializing sub-string for HV_FUG_SETTINGS. default: channel offset within ODB
Definition at line 235 of file hv_fug.c.
Referenced by hv_fug_init().
#define HV_FUG_SETTINGS_OUT_STR "\FUG fp mapping output = STRING[12] : \n\[64] Moderator 04 0x0004 04 0x0008 N 00 0x0000 \n\[64] Mod_Guard 04 0x0010 04 0x0020 N 00 0x0000 \n\[64] Mod_Grid 01 0x0001 01 0x0002 N 00 0x0000 \n\[64] Lense_1 01 0x0004 01 0x0008 N 00 0x0000 \n\[64] Mirror 04 0x0001 04 0x0002 N 00 0x0000 \n\[64] Lense_2 01 0x0040 01 0x0080 N 00 0x0000 \n\[64] Lense_3 01 0x0010 01 0x0020 N 00 0x0000 \n\[64] RA-L 06 0x0010 06 0x0020 Y 08 0x0008 \n\[64] RA-R 06 0x0004 06 0x0008 Y 08 0x0004 \n\[64] RA-T 06 0x0001 06 0x0002 Y 08 0x0002 \n\[64] RA-B 04 0x0040 04 0x0080 Y 08 0x0001 \n\[64] Sample 06 0x0040 06 0x0080 Y 08 0x0010 \n\" |
Initializing sub-string for HV_FUG_SETTINGS. default mapping field point<->FUG of the output channels
Definition at line 295 of file hv_fug.c.
Referenced by hv_fug_init().
#define HV_FUG_SETTINGS_PROPERTIES_STR "\Properties = STRING[12] : \n\[64] Moderator @35.0kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] Mod_Guard @20.0kV #0.6mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] Mod_Grid @12.5kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] Lense_1 @12.5kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] Mirror @35.0kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] Lense_2 @35.0kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] Lense_3 @35.0kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] RA-L @35.0kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] RA-R @35.0kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] RA-T @20.0kV #0.6mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] RA-B @20.0kV #0.6mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\[64] Sample @12.5kV #1.0mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA \n\" |
Initializing sub-string for HV_FUG_SETTINGS. default: Description of the individual FUG HV devices
Definition at line 386 of file hv_fug.c.
Referenced by hv_fug_init().
#define HV_FUG_TIME_OUT 3000 |
time out for read rs232 communication in (ms).
Definition at line 190 of file hv_fug.c.
Referenced by fp_check_attrib_settings(), fp_check_modules(), fp_power_up_clear(), fp_write_defaults(), hv_fug_get(), hv_fug_get_current(), hv_fug_set(), and hv_fug_set_current_limit().
int chk_attrib_in | ( | HV_FUG_INFO * | info, |
int | module, | ||
char * | line | ||
) |
checks if the attribute and range settings of an input field point module is correct.
Return:
info | is a pointer to the DD specific info structure |
module | FP input module number |
line | responds string from the field point interface |
Definition at line 684 of file hv_fug.c.
References HV_FUG_INFO::errorcount, FP_AI_110_FILTER, FP_AI_110_RANGE, FP_IO_NUM_CH, and HV_FUG_MAX_ERROR.
Referenced by fp_check_attrib_settings().
int chk_attrib_out | ( | HV_FUG_INFO * | info, |
int | module, | ||
char * | line | ||
) |
checks if the attribute and range settings of an output field point module is correct.
Return:
info | is a pointer to the DD specific info structure |
module | FP output module number |
line | responds string from the field point interface |
Definition at line 726 of file hv_fug.c.
References HV_FUG_INFO::errorcount, FP_AO_210_RANGE, FP_IO_NUM_CH, and HV_FUG_MAX_ERROR.
Referenced by fp_check_attrib_settings().
int chk_attrib_rly | ( | HV_FUG_INFO * | info, |
int | module, | ||
char * | line | ||
) |
checks if the attribute and range settings of an relay field point module is correct.
Return:
info | is a pointer to the DD specific info structure |
module | FP input module number |
line | responds string from the field point interface |
Definition at line 759 of file hv_fug.c.
References HV_FUG_INFO::errorcount, FP_IO_NUM_CH, FP_RLY_SETTING, and HV_FUG_MAX_ERROR.
Referenced by fp_check_attrib_settings().
int chksumchk | ( | char * | line, |
char * | chksum | ||
) |
checks the if the checksum of 'line' corresponds to 'chksum'
Return:
line | input string which needs to be checked if it corresponds to chksum |
chksum | as a string |
Definition at line 654 of file hv_fug.c.
Referenced by fp_check_attrib_settings(), hv_fug_get(), hv_fug_get_current(), and hv_fug_set().
void err_bad_channels | ( | char * | line, |
int | module, | ||
HV_FUG_INFO * | info | ||
) |
generates from a coded input an error message when a channel went bad, and sends a message to the ODB message system.
line | responds string from the field point interface |
module | FP module number |
info | is a pointer to the DD specific info structure |
Definition at line 788 of file hv_fug.c.
References HV_FUG_INFO::errorcount, HV_FUG_MAX_ERROR, and HV_FUG_INFO::num_channels.
Referenced by fp_write_defaults().
char* filter_sub_str | ( | char * | str, |
char * | start, | ||
char * | stop, | ||
char * | result | ||
) |
|
static |
checks all the settings of the field point moduels.
gets ALL the attributes and ranges of ALL the channels per input module at once. see FieldPoint Programmer Reference Manual, p.5-14
0xFF = 11111111, i.e. for every channel (8 for the FP-AI-110) there is a character (bit) set = 1. for each channel 'bit' set there is an attribute mask and a range mask. The attribute mask is 4 byte (e.g. 0x0001) and the range mask 1 byte (e.g. 1).
return structure: A0004...000420 with the meaning for each channel 4 characters, the first two are the attributes 0x00=60Hz, the second two are the range 0x04=0-10.4V. The very last two characters of the string are the checksum. (for checksum see subroutine chksumchk above and Manual P.1-3)
Return:
hDB | handle onto the ODB |
info | is a pointer to the DD specific info structure |
Definition at line 1084 of file hv_fug.c.
References chk_attrib_in(), chk_attrib_out(), chk_attrib_rly(), chksumchk(), HV_FUG_SETTINGS::detailed_msg, fp_error_msg(), FP_IO_NUM_CH, HV_FUG_TIME_OUT, HV_FUG_INFO::hv_settings, HV_FUG_SETTINGS::no_fp_modules, and sub_str().
Referenced by hv_fug_init().
|
static |
checks if the number of field point modules is correct and further, if the modules are correctely connected and of the right type.
Return:
hDB | handle onto the ODB |
info | is a pointer to the DD specific info structure |
Definition at line 984 of file hv_fug.c.
References HV_FUG_INFO::errorcount, fp_error_msg(), HV_FUG_SETTINGS::fp_io_modules, HV_FUG_MAX_ERROR, HV_FUG_TIME_OUT, HV_FUG_INFO::hv_settings, mid_str(), and HV_FUG_SETTINGS::no_fp_modules.
Referenced by hv_fug_init().
INT fp_error_msg | ( | HV_FUG_INFO * | info, |
char * | where, | ||
char * | error | ||
) |
This routine decodes an error message obtained form the field point modules. It sends a message to the midas message system if an error occured.
Return: FE_ERR_HW
info | is a pointer to the DD specific info structure |
where | string holding the name of the routine which got the field point error message |
error | coded error message form the field point module |
Definition at line 484 of file hv_fug.c.
References HV_FUG_SETTINGS::detailed_msg, HV_FUG_INFO::errorcount, FP_ERR_PUCLR_EXP, HV_FUG_MAX_ERROR, and HV_FUG_INFO::hv_settings.
Referenced by fp_check_attrib_settings(), fp_check_modules(), fp_write_defaults(), hv_fug_get(), hv_fug_get_current(), hv_fug_set(), and hv_fug_set_current_limit().
|
static |
sends a 'power up clear' command to the field point modules, and checks the responds. For 'power up clear' see 'FieldPoint Programmer Reference Manual' p.4-2.
Return:
hDB | handle onto the ODB |
info | is a pointer to the DD specific info structure |
Definition at line 950 of file hv_fug.c.
References HV_FUG_INFO::errorcount, HV_FUG_MAX_ERROR, HV_FUG_TIME_OUT, HV_FUG_INFO::hv_settings, and HV_FUG_SETTINGS::no_fp_modules.
Referenced by hv_fug_init().
|
static |
sends default values (current limits, ...) to the field point modules.
Return:
hDB | handle onto the ODB |
info | is a pointer to the DD specific info structure |
Definition at line 1173 of file hv_fug.c.
References HV_FUG_FP::channel_cdc_out, err_bad_channels(), HV_FUG_INFO::errorcount, FP_AO_NORM, fp_error_msg(), FP_IO_RESOL, HV_FUG_MAX_ERROR, HV_FUG_TIME_OUT, HV_FUG_INFO::hv_settings, HV_FUG_FP::module_cdc_out, HV_FUG_SETTINGS::no_fp_modules, HV_FUG_INFO::num_channels, and sub_str().
Referenced by hv_fug_init().
INT hv_fug | ( | INT | cmd, |
... | |||
) |
The FUG high voltage devices are used for the muon transport system in the low energy muon experiment (LEM) at PSI. Since the high voltage devices themselfs only have analog input controls, analog input/output cards of National Instruments (FP-AI-110 / FP-AO-210) are used to connect to the digital world. To control them via a computer a special interface card (FP1000) and bus is used (again National Instrument stuff).
The hard wiring looks like this:
|- FP-RLY-420,bus address 8 (set polarity of FUG HCL devices 8-12) |- FP-AI-110, bus address 5 (read polarity of FUG HCL devices 8-12) |- FP-AI-110, bus address 7 (Grid_1, Sample_G1, Sample_G2, Sample) |- FP-AI-110, bus address 3 (Lense_3, RA-L, RA-R, Guard) |- FP-AI-110, bus address 2 (Moderator, Lense_1, Mirror, Lense_2) PC <-- Lantronix/RS232 --> FP1000 -| |- FP-AO-210, bus address 6 (Grid_1, Sample_G1, Sample_G2, Sample) |- FP-AO-210, bus address 4 (Lense_3, RA-L, RA-R, Guard) |- FP-AO-210, bus address 1 (Moderator, Lense_1, Mirror, Lense_2)
i.e. we use
for 12 FUG high voltage devices. Each FUG HV device needs 2 input and 2 output channels (in/out voltage/current).
The new HCL devices (we will use four of them for Grid_1, Sample_G1, Sample_G2, Sample) have the option to change the polarity remotely. This is done by using the relay module FP-RLY-420. The polarity of these devices is monitored by an additional FP-AI-110: +polarity gives ~15V, i.e. overrange at the FP-AI-110 (10.4V max. measurable voltage) -polarity gives ~0V.
For a detailed description of the command language of the field point bus of National Instruments see: Field Point – FP-1000/FP-1001 Programmer Reference Manual.
The ODB equipment definition of the different FUG HV devices is organized as follows: key : /Equipment/HV/Settings/Devices/FUG/DD
With the following entries:
Moderator @ 20.0kV #0.6mA up0.1kV/s down0.0kV/s $0.00kV !0.001mA ^ ^ ^ ^ ^ ^ ^ name max hv | upramp downramp default hv | max current default current limit
RS232: 9600 baud, 8 data bits, 1 stop bit, no parity bit, no hardware protocol, no software protocol, termination: \ r (CR)
Definition at line 1790 of file hv_fug.c.
References hKey, hv_fug_exit(), hv_fug_get(), hv_fug_get_current(), hv_fug_get_label(), hv_fug_init(), hv_fug_set(), hv_fug_set_current_limit(), and info.
INT hv_fug_exit | ( | HV_FUG_INFO * | info | ) |
terminates the bus driver and free's the memory allocated for the info structure HV_FUG_INFO.
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure |
Definition at line 1415 of file hv_fug.c.
References HV_FUG_INFO::bd, HV_FUG_INFO::bd_connected, HV_FUG_INFO::bd_info, HV_FUG_INFO::hv_settings, HV_FUG_INFO::scw, HV_FUG_SETTINGS::scw_in_use, and HV_FUG_INFO::startup_error.
Referenced by hv_fug().
INT hv_fug_get | ( | HV_FUG_INFO * | info, |
INT | channel, | ||
float * | pvalue | ||
) |
gets the HV measured value of an FUG.
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure |
channel | to be set |
pvalue | pointer onto HV measured in (kV) |
Definition at line 1539 of file hv_fug.c.
References HV_FUG_INFO::bd, HV_FUG_INFO::bd_connected, HV_FUG_INFO::bd_info, chksumchk(), HV_FUG_SETTINGS::detailed_msg, HV_FUG_INFO::errorcount, HV_FUG_SETTINGS::ets_in_use, ets_logout(), HV_FUG_INFO::first_bd_error, FP_AI_NORM, fp_error_msg(), FP_IO_RESOL, HV_FUG_INFO::hkey, HV_FUG_DELTA_TIME_ERROR, HV_FUG_ETS_LOGOUT_SLEEP, HV_FUG_MAX_ERROR, HV_FUG_MAX_READBACK_FAILURE, HV_FUG_READ_ERROR, HV_FUG_RECONNECTION_TIMEOUT, HV_FUG_TIME_OUT, HV_FUG_INFO::hv_settings, HV_FUG_INFO::last_reconnect, HV_FUG_INFO::last_valid_hv, HV_FUG_INFO::lasterrtime, HV_FUG_FP::max_volt, HV_FUG_INFO::readback_failure, HV_FUG_INFO::reconnection_failures, HV_FUG_INFO::scw, HV_FUG_SETTINGS::scw_in_use, HV_FUG_INFO::startup_error, and sub_str().
Referenced by hv_fug().
INT hv_fug_get_current | ( | HV_FUG_INFO * | info, |
INT | channel, | ||
float * | pvalue | ||
) |
gets the current measured value of an FUG.
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure |
channel | to be set |
pvalue | pointer onto current measured in (mA) |
Definition at line 1694 of file hv_fug.c.
References HV_FUG_INFO::bd_connected, chksumchk(), HV_FUG_INFO::errorcount, FP_AI_NORM, fp_error_msg(), FP_IO_RESOL, HV_FUG_DELTA_TIME_ERROR, HV_FUG_MAX_ERROR, HV_FUG_TIME_OUT, HV_FUG_INFO::last_valid_current, HV_FUG_INFO::lasterrtime, HV_FUG_FP::max_curr, HV_FUG_INFO::startup_error, and sub_str().
Referenced by hv_fug().
INT hv_fug_get_label | ( | INT | channel, |
char * | name | ||
) |
INT hv_fug_init | ( | HNDLE | hKey, |
void ** | pinfo, | ||
INT | channels, | ||
INT(*)(INT cmd,...) | bd | ||
) |
Initializes the fug device drivers via the field point modules, i.e. generates all the necessary structures in the ODB if necessary, initializes the bus driver and the FUG's.
Return:
hKey | is the device driver handle given from the class driver |
pinfo | is needed to store the internal info structure |
channels | is the number of channels of the device (from the class driver) |
bd | is a pointer to the bus driver |
Definition at line 1271 of file hv_fug.c.
References HV_FUG_INFO::bd, HV_FUG_INFO::bd_connected, HV_FUG_INFO::bd_info, HV_FUG_INFO::errorcount, HV_FUG_INFO::first_bd_error, fp_check_attrib_settings(), fp_check_modules(), fp_power_up_clear(), fp_write_defaults(), hDB, HV_FUG_INFO::hDB, HV_FUG_INFO::hDDkey, hKey, HV_FUG_INFO::hkey, HV_FUG_SCW_STR, HV_FUG_SETTINGS_IN_STR, HV_FUG_SETTINGS_INTERNAL_STR, HV_FUG_SETTINGS_MODULE_STR, HV_FUG_SETTINGS_NO_STR, HV_FUG_SETTINGS_ODB_OFFSET_STR, HV_FUG_SETTINGS_OUT_STR, HV_FUG_SETTINGS_PROPERTIES_STR, hv_fug_update_db_settings(), HV_FUG_INFO::hv_settings, info, HV_FUG_INFO::last_reconnect, HV_FUG_INFO::lasterrtime, HV_FUG_INFO::num_channels, HV_FUG_INFO::readback_failure, HV_FUG_INFO::reconnection_failures, HV_FUG_INFO::scw, HV_FUG_SETTINGS::scw_in_use, and HV_FUG_INFO::startup_error.
Referenced by hv_fug().
INT hv_fug_set | ( | HV_FUG_INFO * | info, |
INT | channel, | ||
float | value | ||
) |
sets the HV demand value of an FUG.
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure |
channel | to be set |
value | HV demand in (kV) |
Definition at line 1443 of file hv_fug.c.
References HV_FUG_INFO::bd_connected, chksumchk(), HV_FUG_INFO::errorcount, HV_FUG_INFO::first_bd_error, FP_AO_NORM, fp_error_msg(), FP_IO_RESOL, HV_FUG_MAX_ERROR, HV_FUG_TIME_OUT, HV_FUG_FP::max_volt, HV_FUG_INFO::startup_error, and sub_str().
Referenced by hv_fug().
INT hv_fug_set_current_limit | ( | HV_FUG_INFO * | info, |
INT | channel, | ||
float | limit | ||
) |
sets the current limit values of an FUG.
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure |
channel | to be set |
limit | current limit value in (mA) |
Definition at line 1758 of file hv_fug.c.
References HV_FUG_INFO::bd_connected, FP_AO_NORM, fp_error_msg(), FP_IO_RESOL, HV_FUG_TIME_OUT, and HV_FUG_INFO::startup_error.
Referenced by hv_fug().
|
static |
updates necessary ODB settings, like high voltage -, current limits, ... , at startup.
Return:
hDB | handle onto the ODB |
info | is a pointer to the DD specific info structure |
channels | number of FUG devices |
Definition at line 828 of file hv_fug.c.
References HV_FUG_FP::channel_cdc_in, HV_FUG_FP::channel_cdc_out, HV_FUG_FP::channel_relais_in, HV_FUG_FP::channel_relais_out, HV_FUG_FP::channel_vdc_in, HV_FUG_FP::channel_vdc_out, HV_FUG_SETTINGS::fug_properties, HV_FUG_INFO::hv_settings, HV_FUG_FP::hv_switchable, HV_FUG_FP::init_curr, HV_FUG_FP::init_volt, HV_FUG_SETTINGS::map_fp_fug_input, HV_FUG_SETTINGS::map_fp_fug_output, HV_FUG_FP::max_curr, HV_FUG_FP::max_volt, HV_FUG_FP::module_cdc_in, HV_FUG_FP::module_cdc_out, HV_FUG_FP::module_relais_in, HV_FUG_FP::module_relais_out, HV_FUG_FP::module_vdc_in, HV_FUG_FP::module_vdc_out, HV_FUG_FP::name, HV_FUG_SETTINGS::odb_offset, HV_FUG_FP::ramping_speed_down, and HV_FUG_FP::ramping_speed_up.
Referenced by hv_fug_init().
void mid_str | ( | char * | start, |
char * | stop, | ||
char * | line, | ||
char * | result | ||
) |
copies a substring from 'line' starting at 'start' and ending at 'stop' to 'result'.
start | start pattern |
stop | stop pattern |
line | input string |
result | return sub-string |
Definition at line 582 of file hv_fug.c.
Referenced by fp_check_modules().
void sub_str | ( | int | start, |
int | stop, | ||
char * | line, | ||
char * | result, | ||
int | size_line, | ||
int | size_result | ||
) |
copies a substring from 'line' starting at 'start' and ending at 'stop' to 'result'.
start | start-position |
stop | stop-position |
line | input string |
result | return sub-string |
size_line | size of line |
size_result | size of result |
Definition at line 604 of file hv_fug.c.
Referenced by fp_check_attrib_settings(), fp_write_defaults(), hv_fug_get(), hv_fug_get_current(), and hv_fug_set().