28 #define XTC_ETS_LOGOUT_SLEEP 10000
31 #define XTC_MAX_READBACK_FAILURE 5
34 #define XTC_INIT_ERROR -2
35 #define XTC_READ_ERROR -1
39 #define XTC_CHANNELS 2
49 #define XTC_SETTINGS_STR "\
50 Detailed Messages = INT : 0\n\
51 ETS_IN_USE = INT : 1\n\
52 Name_1 = STRING : [32] XTC_Thickness\n\
53 Name_2 = STRING : [32] XTC_Rate\n\
60 INT (*bd)(INT cmd, ...);
74 #define TIME_OUT_XTC 2000
78 #define DELTA_TIME_ERROR 3600
97 INT
xtc_init(HNDLE
hKey,
void **pinfo, INT channels, INT (*bd)(INT cmd, ...))
100 char cmd[8], ack[2], str[32];
104 cm_get_experiment_database(&hDB, NULL);
112 if ((status != DB_SUCCESS) && (status != DB_OPEN_RECORD)) {
113 cm_msg(MERROR,
"xtc_init",
"xtc_init: Error creating DD record in ODB, status=%d", status);
119 db_find_key(hDB, hKey,
"DD", &hkeydd);
135 cm_msg(MERROR,
"xtc_init",
"Error, number of XTC channels %d exceeds maximum of allowed channels", info->
num_channels);
146 if (status != SUCCESS) {
152 sprintf(ack,
"%c",
ACK);
153 sprintf(cmd,
"D%s", ack);
162 cm_msg(MINFO,
"xtc_init",
"XTC startup error.");
165 cm_msg(MINFO,
"xtc_init",
"XTC driver initialized.");
222 char str[128], substr[128], ack[2], cmd[128];
224 DWORD nowtime, difftime;
242 cm_msg(MERROR,
"xtc_get",
"too many reconnection failures, bailing out :-(");
248 sprintf(ack,
"%c",
ACK);
249 sprintf(cmd,
"D%s", ack);
260 cm_msg(MERROR,
"xtc_get",
"XTC: command error.");
272 cm_msg(MINFO,
"xtc_get",
"xtc: try to disconnect and reconnect the bus driver");
283 cm_msg(MINFO,
"xtc_get",
"xtc: reconnection trial ...");
285 if (status != FE_SUCCESS) {
287 cm_msg(MINFO,
"xtc_get",
"xtc: reconnection attempted failed");
295 cm_msg(MINFO,
"xtc_get",
"xtc: successfully reconnected");
303 sscanf(str,
"%s %f", substr, pvalue);
306 sscanf(str,
"%f ", pvalue);
349 float value, *pvalue;
352 va_start(argptr, cmd);
357 hKey = va_arg(argptr, HNDLE);
358 info = va_arg(argptr,
void *);
359 channel = va_arg(argptr, INT);
360 flags = va_arg(argptr, DWORD);
361 bd = va_arg(argptr,
void *);
362 status =
xtc_init(hKey, info, channel, bd);
366 info = va_arg(argptr,
void *);
371 info = va_arg(argptr,
void *);
372 channel = va_arg(argptr, INT);
373 value = (float) va_arg(argptr,
double);
374 status =
xtc_set(info, channel, value);
378 info = va_arg(argptr,
void *);
379 channel = va_arg(argptr, INT);
380 pvalue = va_arg(argptr,
float *);
381 status =
xtc_get(info, channel, pvalue);
385 info = va_arg(argptr,
void *);
386 channel = va_arg(argptr, INT);
387 name = va_arg(argptr,
char*);
INT startup_error
startup error flag
#define XTC_CHANNELS
number of channels of the xtc
#define TIME_OUT_XTC
time out in msecs for bus driver -> device communication
#define DELTA_TIME_ERROR
reset error counter after DELTA_TIME_ERROR seconds
void * bd_info
private info of bus driver
HNDLE hkey
ODB key for bus driver info.
#define MAX_ERROR
maximum number of error messages
XTC_SETTINGS xtc_settings
private settings of the XTC device driver
int bd_connected
flag showing if bus driver is connected
int ets_logout(void *info, int wait, int detailed_msg)
This structure contains private variables for the device driver.
#define XTC_MAX_READBACK_FAILURE
maximum number of readback failures before a reconnect will take place
INT errorcount
number of error encountered
#define XTC_READ_ERROR
error tag if there was communication problem
Stores all the parameters the device driver needs.
#define ACK
acknowledgment tag for device communication
DWORD lasterrtime
last error time stamp
INT num_channels
number of channels of the XTC
INT xtc_init(HNDLE hKey, void **pinfo, INT channels, INT(*bd)(INT cmd,...))
float last_value
stores the last valid value
char name[XTC_CHANNELS][32]
string array holding the default names for the different channels
int reconnection_failures
how often reconnection failed
INT readback_failure
counts the number of readback failures
DWORD last_reconnect
timer for bus driver reconnect error handling
INT ets_in_use
flag indicating if the rs232 terminal server is in use
INT xtc_get_label(XTC_INFO *info, INT channel, char *name)
#define XTC_ETS_LOGOUT_SLEEP
sleep time (us) between the telnet commands of the ets_logout
INT xtc_set(XTC_INFO *info, INT channel, float value)
#define XTC_INIT_ERROR
error tag if there was an error during initializing the DD
INT(* bd)(INT cmd,...)
bus driver entry function
INT xtc_get(XTC_INFO *info, INT channel, float *pvalue)
INT detailed_msg
flag indicating if detailed status/error messages are wanted
INT xtc_exit(XTC_INFO *info)
#define XTC_SETTINGS_STR
Initializing string for the struct XTC_SETTINGS_STR.