Low-Energy Muon (LEM) Experiment
0.5.1
|
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include "midas.h"
#include "bruker.h"
#include "ets_logout.h"
Go to the source code of this file.
Data Structures | |
struct | BRUKER_SETTINGS |
Stores all the parameters the device driver needs. More... | |
struct | BRUKER_INFO |
This structure contains private variables for the device driver. More... | |
Macros | |
#define | BRUKER_INIT_ERROR -2 |
tag: initializing error More... | |
#define | BRUKER_READ_ERROR -1 |
tag: read error More... | |
#define | BRUKER_MAX_READ 5 |
maximal number for reading retries More... | |
#define | BRUKER_TIME_OUT 2000 |
timeout in (ms) for the communication between pc and bruker More... | |
#define | BRUKER_MAX_READBACK_FAILURE 5 |
maximum number of readback failures before a reconnect will take place More... | |
#define | BRUKER_RECONNECTION_TIMEOUT 5 |
timeout in (sec) between logout terminal server an reconnection trial More... | |
#define | BRUKER_ETS_LOGOUT_SLEEP 10000 |
sleep time (us) between the telnet commands of the ets_logout More... | |
#define | BRUKER_ERR_WATER 0x001 |
tag: cooling water for the bruker is missing (see Bruker "Description of B-EC 1", p. 5) More... | |
#define | BRUKER_ERR_PHASE 0x002 |
tag: on off the line phases might be missing (see Bruker "Description of B-EC 1", p. 5) More... | |
#define | BRUKER_ERR_TEMP 0x004 |
tag: internal overheating protection for the bruker (see Bruker "Description of B-EC 1", p. 5) More... | |
#define | BRUKER_ERR_EXT1 0x008 |
tag: monitoring tag of the water guard of the magnet hooked up to the bruker More... | |
#define | BRUKER_ERR_DOOR 0x010 |
tag: door at the back of the bruker is open More... | |
#define | BRUKER_ERR_GND 0x020 |
tag: ground relay has tripped due to a ground voltage exeeding about 10 volt (see Bruker "Description of B-EC 1", p. 5) More... | |
#define | BRUKER_ERR_EXT2 0x040 |
tag: unused More... | |
#define | BRUKER_ERR_CURR 0x100 |
tag: overcurrent protection More... | |
#define | BRUKER_STATUS_REMOTE 0x010000 |
tag: bruker on remote More... | |
#define | BRUKER_STATUS_EXTREF 0x040000 |
tag: ?? More... | |
#define | BRUKER_STATUS_CYCLE 0x080000 |
tag: ?? More... | |
#define | BRUKER_STATUS_POLNORM 0x200000 |
tag: ?? More... | |
#define | BRUKER_STATUS_DCPWRON 0x400000 |
tag: ?? More... | |
#define | BRUKER_MAX_ERROR 10 |
maximum number of error messages More... | |
#define | BRUKER_DELTA_TIME_ERROR 1800 |
reset error counter after BRUKER_DELTA_TIME_ERROR seconds More... | |
#define | BRUKER_IN_CHS 5 |
number of input channels More... | |
#define | BRUKER_OUT_CHS 2 |
number of output channels More... | |
#define | BRUKER_SETTINGS_STR "\Detailed Messages = INT : 0\n\ETS_IN_USE = INT : 1\n\Input Names = STRING[5] :\n\[32] Polarity, 1=pos, 2=neg, 3=switch\n\[32] Status\n\[32] Demand Current (Readback)\n\[32] Output Current\n\[32] Output Voltage\n\Output Names = STRING[2] :\n\[32] Power On=1/Off=0\n\[32] Demand Current\n\" |
Initializing string for the struct BRUKER_SETTINGS. More... | |
Functions | |
INT | bruker_send_rcv (BRUKER_INFO *info, char *cmd, char *str, int size) |
INT | bruker_decode_status (BRUKER_INFO *info, char *str) |
INT | bruker_in_init (HNDLE hKey, void **pinfo, INT channels, INT(*bd)(INT cmd,...)) |
INT | bruker_out_init (HNDLE hKey, void **pinfo, INT channels, INT(*bd)(INT cmd,...)) |
INT | bruker_exit (BRUKER_INFO *info) |
INT | bruker_set (BRUKER_INFO *info, INT channel, float value) |
INT | bruker_get_label_in (BRUKER_INFO *info, INT channel, char *name) |
INT | bruker_get_label_out (BRUKER_INFO *info, INT channel, char *name) |
INT | bruker_get (BRUKER_INFO *info, INT channel, float *pvalue) |
INT | bruker_in (INT cmd,...) |
INT | bruker_out (INT cmd,...) |
Variables | |
BRUKER_INFO * | info |
global info structure, in/out-init routines need the same structure More... | |
#define BRUKER_DELTA_TIME_ERROR 1800 |
reset error counter after BRUKER_DELTA_TIME_ERROR seconds
Definition at line 75 of file bruker.c.
Referenced by bruker_get().
#define BRUKER_ERR_CURR 0x100 |
tag: overcurrent protection
Definition at line 57 of file bruker.c.
Referenced by bruker_decode_status().
#define BRUKER_ERR_DOOR 0x010 |
tag: door at the back of the bruker is open
Definition at line 51 of file bruker.c.
Referenced by bruker_decode_status().
#define BRUKER_ERR_EXT1 0x008 |
tag: monitoring tag of the water guard of the magnet hooked up to the bruker
Definition at line 49 of file bruker.c.
Referenced by bruker_decode_status().
#define BRUKER_ERR_EXT2 0x040 |
#define BRUKER_ERR_GND 0x020 |
tag: ground relay has tripped due to a ground voltage exeeding about 10 volt (see Bruker "Description of B-EC 1", p. 5)
Definition at line 53 of file bruker.c.
Referenced by bruker_decode_status().
#define BRUKER_ERR_PHASE 0x002 |
tag: on off the line phases might be missing (see Bruker "Description of B-EC 1", p. 5)
Definition at line 45 of file bruker.c.
Referenced by bruker_decode_status().
#define BRUKER_ERR_TEMP 0x004 |
tag: internal overheating protection for the bruker (see Bruker "Description of B-EC 1", p. 5)
Definition at line 47 of file bruker.c.
Referenced by bruker_decode_status().
#define BRUKER_ERR_WATER 0x001 |
tag: cooling water for the bruker is missing (see Bruker "Description of B-EC 1", p. 5)
Definition at line 43 of file bruker.c.
Referenced by bruker_decode_status().
#define BRUKER_ETS_LOGOUT_SLEEP 10000 |
sleep time (us) between the telnet commands of the ets_logout
Definition at line 39 of file bruker.c.
Referenced by bruker_get().
#define BRUKER_INIT_ERROR -2 |
#define BRUKER_MAX_ERROR 10 |
maximum number of error messages
Definition at line 73 of file bruker.c.
Referenced by bruker_decode_status(), and bruker_get().
#define BRUKER_MAX_READ 5 |
maximal number for reading retries
Definition at line 27 of file bruker.c.
Referenced by bruker_send_rcv().
#define BRUKER_MAX_READBACK_FAILURE 5 |
maximum number of readback failures before a reconnect will take place
Definition at line 33 of file bruker.c.
Referenced by bruker_get().
#define BRUKER_READ_ERROR -1 |
#define BRUKER_RECONNECTION_TIMEOUT 5 |
timeout in (sec) between logout terminal server an reconnection trial
Definition at line 36 of file bruker.c.
Referenced by bruker_get().
#define BRUKER_SETTINGS_STR "\Detailed Messages = INT : 0\n\ETS_IN_USE = INT : 1\n\Input Names = STRING[5] :\n\[32] Polarity, 1=pos, 2=neg, 3=switch\n\[32] Status\n\[32] Demand Current (Readback)\n\[32] Output Current\n\[32] Output Voltage\n\Output Names = STRING[2] :\n\[32] Power On=1/Off=0\n\[32] Demand Current\n\" |
Initializing string for the struct BRUKER_SETTINGS.
Definition at line 92 of file bruker.c.
Referenced by bruker_in_init().
#define BRUKER_STATUS_DCPWRON 0x400000 |
#define BRUKER_STATUS_REMOTE 0x010000 |
#define BRUKER_TIME_OUT 2000 |
timeout in (ms) for the communication between pc and bruker
Definition at line 30 of file bruker.c.
Referenced by bruker_send_rcv().
INT bruker_decode_status | ( | BRUKER_INFO * | info, |
char * | str | ||
) |
Decodes the bruker status messages, and filters error messages if present.
Return:
info | is a pointer to the DD specific info structure. |
str | string to be decoded |
Definition at line 178 of file bruker.c.
References BRUKER_ERR_CURR, BRUKER_ERR_DOOR, BRUKER_ERR_EXT1, BRUKER_ERR_EXT2, BRUKER_ERR_GND, BRUKER_ERR_PHASE, BRUKER_ERR_TEMP, BRUKER_ERR_WATER, BRUKER_MAX_ERROR, BRUKER_INFO::bruker_remote, BRUKER_STATUS_DCPWRON, BRUKER_STATUS_REMOTE, and BRUKER_INFO::errcount.
Referenced by bruker_get(), and bruker_in_init().
INT bruker_exit | ( | BRUKER_INFO * | info | ) |
Quits the bus driver and free's the memory allocated for the info structure
BRUKER_INFO
.
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure |
Definition at line 471 of file bruker.c.
References BRUKER_INFO::bd, and BRUKER_INFO::bd_info.
Referenced by bruker_in().
INT bruker_get | ( | BRUKER_INFO * | info, |
INT | channel, | ||
float * | pvalue | ||
) |
Reads a value back from the bruker power supply
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure |
channel | to be read back |
pvalue | pointer to the ODB value |
Definition at line 609 of file bruker.c.
References BRUKER_INFO::bd, BRUKER_INFO::bd_connected, BRUKER_INFO::bd_info, bruker_decode_status(), BRUKER_DELTA_TIME_ERROR, BRUKER_DEMAND_CURRENT, BRUKER_DEMAND_CURRENT_READBACK, BRUKER_ETS_LOGOUT_SLEEP, BRUKER_INIT_ERROR, BRUKER_MAX_ERROR, BRUKER_MAX_READBACK_FAILURE, BRUKER_OUTPUT_CURRENT, BRUKER_OUTPUT_VOLTAGE, BRUKER_INFO::bruker_pol_switching, BRUKER_INFO::bruker_polarity, BRUKER_POLARITY_READBACK, BRUKER_READ_ERROR, BRUKER_RECONNECTION_TIMEOUT, bruker_send_rcv(), bruker_set(), BRUKER_INFO::bruker_settings, BRUKER_STATUS, BRUKER_INFO::bruker_target_demand, BRUKER_INFO::check_setpoint, BRUKER_INFO::check_setpoint_timer, BRUKER_SETTINGS::detailed_msg, BRUKER_INFO::errcount, BRUKER_SETTINGS::ets_in_use, ets_logout(), BRUKER_INFO::first_bd_error, BRUKER_INFO::hkey, BRUKER_INFO::last_reconnect, BRUKER_INFO::lasterrtime, BRUKER_INFO::readback_failure, BRUKER_INFO::reconnection_failures, and BRUKER_INFO::startup_error.
Referenced by bruker_in().
INT bruker_get_label_in | ( | BRUKER_INFO * | info, |
INT | channel, | ||
char * | name | ||
) |
At startup, after initialization of the DD, this routine allows to write default names into the ODB.
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure |
channel | of the name to be set |
name | pointer to the ODB name |
Definition at line 576 of file bruker.c.
References BRUKER_INFO::bruker_settings, and BRUKER_SETTINGS::names_in.
Referenced by bruker_in().
INT bruker_get_label_out | ( | BRUKER_INFO * | info, |
INT | channel, | ||
char * | name | ||
) |
At startup, after initialization of the DD, this routine allows to write default names into the ODB.
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure |
channel | of the name to be set |
name | pointer to the ODB name |
Definition at line 593 of file bruker.c.
References BRUKER_INFO::bruker_settings, and BRUKER_SETTINGS::names_out.
Referenced by bruker_out().
INT bruker_in | ( | INT | cmd, |
... | |||
) |
bruker magnet power supply device driver (DD) input part. It is handling the communication between the bruker magnet power supply and midas. The bruker is used as a current source for the electromagnet in our setup.
Definition at line 822 of file bruker.c.
References bruker_exit(), bruker_get(), bruker_get_label_in(), bruker_in_init(), hKey, and info.
INT bruker_in_init | ( | HNDLE | hKey, |
void ** | pinfo, | ||
INT | channels, | ||
INT(*)(INT cmd,...) | bd | ||
) |
Initializes the bruker device driver, i.e. generates all the necessary structures in the ODB if necessary, initializes the bus driver and the bruker.
Return: FE_SUCCESS
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 327 of file bruker.c.
References BRUKER_INFO::bd, BRUKER_INFO::bd_connected, BRUKER_INFO::bd_info, bruker_decode_status(), BRUKER_INFO::bruker_polarity, BRUKER_INFO::bruker_remote, bruker_send_rcv(), BRUKER_INFO::bruker_settings, BRUKER_SETTINGS_STR, BRUKER_INFO::check_setpoint, BRUKER_SETTINGS::detailed_msg, BRUKER_INFO::errcount, BRUKER_INFO::first_bd_error, hDB, hKey, BRUKER_INFO::hkey, info, BRUKER_INFO::last_reconnect, BRUKER_INFO::lasterrtime, BRUKER_INFO::readback_failure, BRUKER_INFO::reconnection_failures, and BRUKER_INFO::startup_error.
Referenced by bruker_in().
INT bruker_out | ( | INT | cmd, |
... | |||
) |
bruker magnet power supply device driver (DD) output part. It is handling the communication between the bruker magnet power supply and midas. The bruker is used as a current source for the electromagnet in our setup.
Definition at line 874 of file bruker.c.
References bruker_get_label_out(), bruker_out_init(), bruker_set(), hKey, and info.
INT bruker_out_init | ( | HNDLE | hKey, |
void ** | pinfo, | ||
INT | channels, | ||
INT(*)(INT cmd,...) | bd | ||
) |
The out init routine is just needed to keep some pointers.
Return: FE_SUCCESS
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 455 of file bruker.c.
References info.
Referenced by bruker_out().
INT bruker_send_rcv | ( | BRUKER_INFO * | info, |
char * | cmd, | ||
char * | str, | ||
int | size | ||
) |
send<->recieve command
Return: number of bytes read.
cmd | command string |
str | reply string |
Definition at line 139 of file bruker.c.
References BRUKER_MAX_READ, and BRUKER_TIME_OUT.
Referenced by bruker_get(), bruker_in_init(), and bruker_set().
INT bruker_set | ( | BRUKER_INFO * | info, |
INT | channel, | ||
float | value | ||
) |
Sends a new value to the bruker power supply
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure |
channel | for which channel is this command |
value | to be set. |
Definition at line 491 of file bruker.c.
References BRUKER_INFO::bd_connected, BRUKER_DEMAND_CURRENT, BRUKER_INFO::bruker_pol_switching, BRUKER_INFO::bruker_polarity, BRUKER_POWER, bruker_send_rcv(), BRUKER_INFO::bruker_settings, BRUKER_INFO::bruker_target_demand, BRUKER_INFO::check_setpoint, BRUKER_SETTINGS::detailed_msg, BRUKER_INFO::first_bd_error, and BRUKER_INFO::startup_error.
Referenced by bruker_get(), and bruker_out().
BRUKER_INFO* info |