25 #define TWICKENHAM_ETS_LOGOUT_SLEEP 10000
29 #define TWICKENHAM_READ_ERROR -1
31 #define TWICKENHAM_DEBUG FALSE
34 #define TIME_OUT_TWICKENHAM 2000
38 #define TWICKENHAM_MAX_READBACK_FAILURE 5
44 char name[NAME_LENGTH];
48 #define TWICKENHAM_SETTINGS_STR "\
49 Detailed Messages = INT : 0\n\
50 ETS_IN_USE = INT : 1\n\
51 Name = STRING : [32] HDI_Level\n\
58 INT (*bd)(INT cmd, ...);
93 cm_get_experiment_database(&hDB, NULL);
101 if ((status != DB_SUCCESS) && (status != DB_OPEN_RECORD)) {
102 cm_msg(MERROR,
"twickenham_init",
"twickenham_init: Error creating DD record in ODB, status=%d", status);
108 db_find_key(hDB, hKey,
"DD", &hkeydd);
127 if (status != SUCCESS)
132 printf(
"\n initialize Twickenham.");
136 cm_msg(MINFO,
"twicken_init",
"status = %d, str = %s, device = %s",
141 cm_msg(MERROR,
"twickenham_init",
142 "Error getting device status from Twickenham, %s",
194 str[strlen(str)-2] =
'\0';
195 if ( strstr(str,
"-") )
198 sscanf(str+strlen(str)-6,
"%f", pvalue);
208 cm_msg(MERROR,
"twickenham_get",
"too many reconnection failures, bailing out :-(");
218 cm_msg(MINFO,
"twickenham_get",
"twickenham: try to disconnect and reconnect the bus driver");
232 cm_msg(MINFO,
"twickenham_get",
"twickenham: reconnection trial ...");
234 if (status != FE_SUCCESS) {
236 cm_msg(MINFO,
"twickenham_get",
"twickenham: reconnection attempted failed");
244 cm_msg(MINFO,
"twickenham_get",
"twickenham: successfully reconnected");
251 cm_msg(MINFO,
"tw_get",
"status = %d, str = %s, %f", status, str, *pvalue);
285 va_start(argptr, cmd);
291 hKey = va_arg(argptr, HNDLE);
292 info = va_arg(argptr,
void *);
293 channel = va_arg(argptr, INT);
294 flags = va_arg(argptr, DWORD);
295 bd = va_arg(argptr,
void *);
300 info = va_arg(argptr,
void *);
308 info = va_arg(argptr,
void *);
309 channel = va_arg(argptr, INT);
310 pvalue = va_arg(argptr,
float*);
315 info = va_arg(argptr,
void *);
316 channel = va_arg(argptr, INT);
317 name = va_arg(argptr,
char*);
void * bd_info
private info of bus driver
int bd_connected
flag showing if bus driver is connected
TWICKENHAM_SETTINGS twickenham_settings
ODB hot-link data for the DD.
This structure contains private variables for the device driver.
stores internal informations within the DD.
DWORD last_reconnect
timer for bus driver reconnect error handling
INT twickenham_get(TWICKENHAM_INFO *info, INT channel, float *pvalue)
int reconnection_failures
how often reconnection failed
#define TIME_OUT_TWICKENHAM
be displayed at execution time
INT twickenham_exit(TWICKENHAM_INFO *info)
INT twickenham_get_label(TWICKENHAM_INFO *info, INT channel, char *name)
int ets_logout(void *info, int wait, int detailed_msg)
float last_value
stores the last valid value
#define TWICKENHAM_READ_ERROR
read error tag
#define TWICKENHAM_SETTINGS_STR
initializing string for TWICKENHAM_SETTINGS
#define TWICKENHAM_MAX_READBACK_FAILURE
maximum number of readback failures before a reconnect will take place
HNDLE hkey
ODB key for bus driver info.
INT errorcount
error counter; for reducing number of error messages
INT readback_failure
counts the number of readback failures
INT twickenham(INT cmd,...)
INT detailed_msg
flag indicating if detailed status/error messages are wanted
INT ets_in_use
flag indicating if the rs232 terminal server is in use
char name[NAME_LENGTH]
name of the device used for system messages
DWORD lasterrtime
timer error handling; for reducing number of error messages
#define TWICKENHAM_ETS_LOGOUT_SLEEP
sleep time (us) between the telnet commands of the ets_logout
INT(* bd)(INT cmd,...)
bus driver entry function
INT num_channels
number of channels of the DD
INT twickenham_init(HNDLE hKey, void **pinfo, INT channels, INT(*bd)(INT cmd,...))