Low-Energy Muon (LEM) Experiment
0.5.1
|
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include "midas.h"
#include "msystem.h"
#include "bronkhorst.h"
#include "ets_logout.h"
#include "lemSCWatchdog.h"
Go to the source code of this file.
Data Structures | |
struct | BH_IN_SETTINGS |
struct | BH_OUT_SETTINGS |
struct | BH_INFO |
Macros | |
#define | BH_TIME_OUT 2000 |
timeout in (ms) for the communication between pc and bronkhorst More... | |
#define | BH_RECONNECTION_TIMEOUT 5 |
timeout in (sec) between logout terminal server an reconnection trial More... | |
#define | BH_MAX_READBACK_FAILURE 5 |
maximum number of readback failures before a reconnect will take place More... | |
#define | BH_MAX_RECONNECTION_FAILURE 5 |
maximum number of reconnections before bailing off More... | |
#define | BH_MAX_ERROR 10 |
maximum number of error messages More... | |
#define | BH_DELTA_TIME_ERROR 3600 |
reset error counter after BH_DELTA_TIME_ERROR seconds More... | |
#define | BH_WAIT 500 |
time (ms) to BH_WAIT between commands More... | |
#define | BH_CMD_ERROR -3 |
unvalid command error More... | |
#define | BH_INIT_ERROR -2 |
initialize error tag More... | |
#define | BH_READ_ERROR -1 |
read error tag More... | |
#define | BH_ETS_LOGOUT_SLEEP 10000 |
sleep time (us) between the telnet commands of the ets_logout More... | |
#define | BH_SUCCESS 1 |
#define | BH_IN_SETTINGS_STR "\Detailed Messages = INT : 0\n\ETS_IN_USE = INT : 1\n\SCW_IN_USE = INT : 0\n\Input = STRING[2]:\n\[32] BH Flow measured\n\[32] BH ValvePos Get\n\" |
initializing string for the BH_IN_SETTINGS structure. More... | |
#define | BH_OUT_SETTINGS_STR "\Output = STRING[2] :\n\[32] BH Flow setpoint\n\[32] BH ValvePos Set\n\" |
initializing string for the BH_OUT_SETTINGS structure. More... | |
#define | BH_SCW_STR "\Proc Name = STRING : [32]\n\PID = INT : -1\n\Log Name = STRING : [64]\n\DD Name = STRING : [32] bronkhorst\n\Last Updated = DWORD : 0\n\Timeout = DWORD : 180\n\" |
defines the slowcontrol default watchdog info structure More... | |
Functions | |
int | bh_success (char *str, char *error_msg) |
void | hex2ascii (char *str, int len, char *result) |
int | bh_decode_number (char *rply, int decode_tag, char *err_msg, float *result) |
int | bh_decode_string (char *rply, char *err_msg, char *result) |
INT | bh_get_send_rcv (BH_INFO *info, INT cmd, char *result) |
INT | bh_set_send_rcv (BH_INFO *info, INT cmd, float value) |
INT | bh_get_cmd (char *str, int *decode_tag) |
INT | bh_in_init (HNDLE hKey, void **pinfo, INT channels, INT(*bd)(INT cmd,...)) |
INT | bh_out_init (HNDLE hKey, void **pinfo, INT channels, INT(*bd)(INT cmd,...)) |
INT | bh_exit (BH_INFO *info) |
INT | bh_set (BH_INFO *info, INT channel, float value) |
INT | bh_get (BH_INFO *info, INT channel, float *pvalue) |
INT | bh_in_get_label (BH_INFO *info, INT channel, char *name) |
INT | bh_out_get_label (BH_INFO *info, INT channel, char *name) |
INT | bh_flow_in (INT cmd,...) |
INT | bh_flow_out (INT cmd,...) |
Variables | |
BH_INFO * | info |
global info structure since port (rs232 or terminal server) can only be initialized once. More... | |
#define BH_CMD_ERROR -3 |
#define BH_DELTA_TIME_ERROR 3600 |
reset error counter after BH_DELTA_TIME_ERROR seconds
Definition at line 45 of file bronkhorst.c.
Referenced by bh_get().
#define BH_ETS_LOGOUT_SLEEP 10000 |
sleep time (us) between the telnet commands of the ets_logout
Definition at line 54 of file bronkhorst.c.
Referenced by bh_get().
#define BH_IN_SETTINGS_STR "\Detailed Messages = INT : 0\n\ETS_IN_USE = INT : 1\n\SCW_IN_USE = INT : 0\n\Input = STRING[2]:\n\[32] BH Flow measured\n\[32] BH ValvePos Get\n\" |
initializing string for the BH_IN_SETTINGS structure.
Definition at line 159 of file bronkhorst.c.
Referenced by bh_in_init().
#define BH_INIT_ERROR -2 |
#define BH_MAX_ERROR 10 |
maximum number of error messages
Definition at line 44 of file bronkhorst.c.
Referenced by bh_get(), bh_get_send_rcv(), bh_set(), and bh_set_send_rcv().
#define BH_MAX_READBACK_FAILURE 5 |
maximum number of readback failures before a reconnect will take place
Definition at line 39 of file bronkhorst.c.
Referenced by bh_get().
#define BH_MAX_RECONNECTION_FAILURE 5 |
maximum number of reconnections before bailing off
Definition at line 41 of file bronkhorst.c.
Referenced by bh_get().
#define BH_OUT_SETTINGS_STR "\Output = STRING[2] :\n\[32] BH Flow setpoint\n\[32] BH ValvePos Set\n\" |
initializing string for the BH_OUT_SETTINGS structure.
Definition at line 169 of file bronkhorst.c.
Referenced by bh_out_init().
#define BH_READ_ERROR -1 |
#define BH_RECONNECTION_TIMEOUT 5 |
timeout in (sec) between logout terminal server an reconnection trial
Definition at line 37 of file bronkhorst.c.
Referenced by bh_get().
#define BH_SCW_STR "\Proc Name = STRING : [32]\n\PID = INT : -1\n\Log Name = STRING : [64]\n\DD Name = STRING : [32] bronkhorst\n\Last Updated = DWORD : 0\n\Timeout = DWORD : 180\n\" |
defines the slowcontrol default watchdog info structure
Definition at line 176 of file bronkhorst.c.
Referenced by bh_in_init().
#define BH_SUCCESS 1 |
bronkhorst <-> midas tags. def's starting with BH_ aren't documented here. For a detailed description of them see the bronkhorst manual 'RS232 INTERFACE with FLOW-BUS protocol' Doc. no.: 9.17.027 D
Definition at line 64 of file bronkhorst.c.
Referenced by bh_decode_number(), bh_decode_string(), bh_get(), bh_get_send_rcv(), bh_in_init(), bh_set(), bh_set_send_rcv(), and bh_success().
#define BH_TIME_OUT 2000 |
timeout in (ms) for the communication between pc and bronkhorst
Definition at line 34 of file bronkhorst.c.
Referenced by bh_get_send_rcv(), and bh_set_send_rcv().
#define BH_WAIT 500 |
time (ms) to BH_WAIT between commands
Definition at line 47 of file bronkhorst.c.
int bh_decode_number | ( | char * | rply, |
int | decode_tag, | ||
char * | err_msg, | ||
float * | result | ||
) |
if the return message of the flowcontroller is a number, this routine is used to decode the return string into a number.
Return:
rply | return string from flowcontroller |
decode_tag | BH_CHAR, BH_INTEGER, BH_FLOAT |
err_msg | error message if something went wrong |
result | decoded value |
Definition at line 418 of file bronkhorst.c.
References BH_SUCCESS.
Referenced by bh_get().
int bh_decode_string | ( | char * | rply, |
char * | err_msg, | ||
char * | result | ||
) |
if the return message of the flowcontroller is a string, this routine is used to decode the return string.
Return:
rply | return string from flowcontroller |
err_msg | error message if something went wrong |
result | decoded message |
Definition at line 472 of file bronkhorst.c.
References BH_SUCCESS, and hex2ascii().
Referenced by bh_in_init().
INT bh_exit | ( | BH_INFO * | info | ) |
terminates the bus driver and free's the memory allocated for the info structure BH_INFO.
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure |
Definition at line 864 of file bronkhorst.c.
References BH_INFO::bd, BH_INFO::bd_info, BH_INFO::bh_in_settings, BH_INFO::scw, BH_IN_SETTINGS::scw_in_use, and BH_INFO::startup_error.
Referenced by bh_flow_in().
INT bh_flow_in | ( | INT | cmd, |
... | |||
) |
bronkhorst device driver (DD) for reading. It is handling the communication between the bronkhorst mass flow meter and midas.
Definition at line 1088 of file bronkhorst.c.
References bh_exit(), bh_get(), bh_in_get_label(), bh_in_init(), hKey, and info.
INT bh_flow_out | ( | INT | cmd, |
... | |||
) |
bronkhorst device driver (DD) for setting values. It is handling the communication between the bronkhorst mass flow meter and midas.
Definition at line 1141 of file bronkhorst.c.
References bh_out_get_label(), bh_out_init(), bh_set(), hKey, and info.
INT bh_get | ( | BH_INFO * | info, |
INT | channel, | ||
float * | pvalue | ||
) |
get a value from the bronkhorst mass flow meter.
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure. |
channel | is the channel number |
pvalue | read |
Definition at line 935 of file bronkhorst.c.
References BH_INFO::bd, BH_INFO::bd_connected, BH_INFO::bd_info, BH_CMD_ERROR, bh_decode_number(), BH_DELTA_TIME_ERROR, BH_ETS_LOGOUT_SLEEP, bh_get_cmd(), bh_get_send_rcv(), BH_INFO::bh_in_settings, BH_INIT_ERROR, BH_MAX_ERROR, BH_MAX_READBACK_FAILURE, BH_MAX_RECONNECTION_FAILURE, BH_READ_ERROR, BH_RECONNECTION_TIMEOUT, BH_SUCCESS, BH_IN_SETTINGS::detailed_msg, BH_INFO::errorcount, BH_IN_SETTINGS::ets_in_use, ets_logout(), BH_INFO::first_bd_error, BH_INFO::hkey, BH_INFO::last_reconnect, BH_INFO::last_valid_value, BH_INFO::lasterrtime, BH_IN_SETTINGS::name, BH_INFO::readback_failure, BH_INFO::reconnection_failures, BH_INFO::scw, BH_IN_SETTINGS::scw_in_use, and BH_INFO::startup_error.
Referenced by bh_flow_in().
INT bh_get_cmd | ( | char * | str, |
int * | decode_tag | ||
) |
routine which filters the channel name and generates the command tag
Return: command tag
str | channel name |
decode_tag | decode tag needed for the decode routines bh_set_send_rcv, bh_get_send_rcv |
Definition at line 663 of file bronkhorst.c.
INT bh_get_send_rcv | ( | BH_INFO * | info, |
INT | cmd, | ||
char * | result | ||
) |
routine which is used to read back values from the flowcontroller.
Return:
info | info structure used by BD_PUTS and BD_GETS macros |
cmd | command tag telling which value to read back from the flowcontroller. |
result | return string from the flowcontroller. |
Definition at line 505 of file bronkhorst.c.
References BH_INFO::bh_in_settings, BH_MAX_ERROR, BH_SUCCESS, bh_success(), BH_TIME_OUT, BH_IN_SETTINGS::detailed_msg, and BH_INFO::errorcount.
Referenced by bh_get(), and bh_in_init().
INT bh_in_get_label | ( | BH_INFO * | info, |
INT | channel, | ||
char * | name | ||
) |
at startup, after initialization of the DD, this routine allows to write default names of the in-channels 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 1066 of file bronkhorst.c.
References BH_INFO::bh_in_settings, and BH_IN_SETTINGS::name.
Referenced by bh_flow_in().
INT bh_in_init | ( | HNDLE | hKey, |
void ** | pinfo, | ||
INT | channels, | ||
INT(*)(INT cmd,...) | bd | ||
) |
Initializes the bronkhorst device driver, i.e. generates all the necessary structures in the ODB if necessary, initializes the bus driver and the bronkhorst mass flow meter.
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 700 of file bronkhorst.c.
References BH_INFO::bd, BH_INFO::bd_connected, BH_INFO::bd_info, bh_decode_string(), bh_get_send_rcv(), BH_INFO::bh_in_settings, BH_IN_SETTINGS_STR, BH_SCW_STR, BH_SUCCESS, BH_INFO::errorcount, BH_INFO::first_bd_error, hDB, hKey, BH_INFO::hkey, info, BH_INFO::last_reconnect, BH_INFO::lasterrtime, BH_IN_SETTINGS::name, BH_INFO::num_channels_in, BH_INFO::readback_failure, BH_INFO::reconnection_failures, BH_INFO::scw, BH_IN_SETTINGS::scw_in_use, BH_INFO::startup_error, and BH_INFO::startup_tag.
Referenced by bh_flow_in().
INT bh_out_get_label | ( | BH_INFO * | info, |
INT | channel, | ||
char * | name | ||
) |
at startup, after initialization of the DD, this routine allows to write default names of the out-channels 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 1081 of file bronkhorst.c.
References BH_INFO::bh_out_settings, and BH_OUT_SETTINGS::name.
Referenced by bh_flow_out().
INT bh_out_init | ( | HNDLE | hKey, |
void ** | pinfo, | ||
INT | channels, | ||
INT(*)(INT cmd,...) | bd | ||
) |
Initializes the bronkhorst device driver, i.e. generates all the necessary structures in the ODB if necessary, no initialization of the bus driver etc. is done, since this is part of BH_in_init.
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 824 of file bronkhorst.c.
References BH_INFO::bh_out_settings, BH_OUT_SETTINGS_STR, hDB, info, BH_INFO::num_channels_out, and BH_INFO::startup_error.
Referenced by bh_flow_out().
INT bh_set | ( | BH_INFO * | info, |
INT | channel, | ||
float | value | ||
) |
set a value of the bronkhorst mass flow meter.
Return: FE_SUCCESS
info | is a pointer to the DD specific info structure. |
channel | is the channel number |
value | to be set |
Definition at line 887 of file bronkhorst.c.
References BH_INFO::bd_connected, bh_get_cmd(), BH_INFO::bh_in_settings, BH_MAX_ERROR, BH_INFO::bh_out_settings, bh_set_send_rcv(), BH_SUCCESS, BH_IN_SETTINGS::detailed_msg, BH_INFO::errorcount, BH_INFO::first_bd_error, BH_OUT_SETTINGS::name, BH_INFO::startup_error, and BH_INFO::startup_tag.
Referenced by bh_flow_out().
INT bh_set_send_rcv | ( | BH_INFO * | info, |
INT | cmd, | ||
float | value | ||
) |
routine which is used to set values of the flowcontroller.
Return:
info | info structure used by BD_PUTS and BD_GETS macros |
cmd | command tag telling which value to read back from the flowcontroller. |
value | value to be set |
Definition at line 593 of file bronkhorst.c.
References BH_INFO::bh_in_settings, BH_MAX_ERROR, BH_SUCCESS, bh_success(), BH_TIME_OUT, BH_IN_SETTINGS::detailed_msg, and BH_INFO::errorcount.
Referenced by bh_set().
int bh_success | ( | char * | str, |
char * | error_msg | ||
) |
decodes for any error messages coming from the bronkhorst flow meter.
return error tag:
str | return string from the flowmeter |
error_msg | error message return string (if error), otherwise empty string. |
Definition at line 223 of file bronkhorst.c.
References BH_SUCCESS.
Referenced by bh_get_send_rcv(), and bh_set_send_rcv().
void hex2ascii | ( | char * | str, |
int | len, | ||
char * | result | ||
) |
converts a hex string into a readable ascii string.
str | hex input string |
len | length of 'str' |
result | converted ascii string |
Definition at line 390 of file bronkhorst.c.
Referenced by bh_decode_string().
BH_INFO* info |
global info structure since port (rs232 or terminal server) can only be initialized once.
global info structure, in/out-init routines need the same structure
Definition at line 209 of file bronkhorst.c.