24 #define W6100_ETS_LOGOUT_SLEEP 10000
27 #define W6100_MAX_READBACK_FAILURE 5
30 #define W6100_TIME_OUT 1000
33 #define W6100_SET_PRESSURE 1
37 #define W6100_CTRL_MODE 5
38 #define W6100_NEEDLE_VALVE_POS 6
39 #define W6100_UPPER_OUTPUT_LIMIT 7
43 #define W6100_MAX_ERROR 3
44 #define W6100_DELTA_TIME_ERROR 600
46 #define W6100_READ_ERROR -1
47 #define W6100_INIT_ERROR -2
48 #define W6100_OUT_OF_RANGE -3
50 #define W6100_IN_CHANNELS 7
51 #define W6100_OUT_CHANNELS 8
59 char odb_output[2*NAME_LENGTH];
69 #define W6100_IN_SETTINGS_STR "\
71 Detailed Messages = INT : 0\n\
72 ETS_IN_USE = INT : 1\n\
73 ODB Offset = INT : 0\n\
74 ODB Output Path = STRING : [64] /Equipment/ModCryo/Variables/Output\n\
75 Input = STRING[7] : \n\
76 [64] W6100 Pressure (mbar)\n\
77 [64] W6100 Set Point Pressure (mbar, readback)\n\
78 [64] W6100 Needle Valve (0=Open, 100=Close)\n\
79 [64] W6100 PID-Gain (P, readback)\n\
80 [64] W6100 PID-Reset (I, readback)\n\
81 [64] W6100 PID-Rate (D, readback)\n\
82 [64] W6100 Controller State\n\
86 #define W6100_OUT_SETTINGS_STR "\
87 Output = STRING[8] : \n\
89 [64] W6100 Set Point Pressure (mbar)\n\
90 [64] W6100 PID-Gain (P)\n\
91 [64] W6100 PID-Reset (I)\n\
92 [64] W6100 PID-Rate (D)\n\
93 [64] W6100 Ctrl-Mode\n\
94 [64] W6100 Needle Valve Pos.\n\
95 [64] W6100 Upper Output Limit\n\
114 INT (*bd)(INT cmd, ...);
143 cm_msg(MERROR, who, msg);
165 float sign=0.0f, power=0.0f, value;
167 if (strlen(code)!=10) {
212 strncpy(str, &code[3], 4);
213 sscanf(str,
"%f", &value);
215 return sign*power*value;
238 char str[16], rcv[16];
244 if (!strstr(rcv,
"L1")) {
245 sprintf(msg,
"%s: 'West 6100' does not respond properly.", who);
249 if (strstr(rcv,
"N")) {
250 sprintf(msg,
"%s: '%s' negative acknowledgement, i.e. controller doesn't accept command", who, cmd);
256 sprintf(str,
"L1%sI*", activate_cmd);
259 if (!strstr(rcv,
"L1")) {
260 sprintf(msg,
"%s: 'West 6100' does not respond properly (2nd send, execution '%s').",
285 char str[16], msg[128];
292 if (!strstr(str,
"L1")){
300 sprintf(msg,
"%s: 'West 6100' does not respond properly.", who);
305 if (strstr(str,
"N")) {
306 sprintf(msg,
"%s: '%s' negative acknowledgement, i.e. controller doesn't accept command", who, cmd);
330 if ((value > info->
param.
high_limit) || (value < info->param.low_limit)) {
331 cm_msg(MERROR,
"W6100_set",
"set point %f, not within limits (low=%f, high=%f).",
337 sprintf(str,
"L1S#%04d1*", (
int)(10.f*value));
353 if ((value<0.f) || (value>999.9f)) {
354 cm_msg(MERROR,
"W6100_set",
"demanded gain (P) out of range [0.0, 999.9]");
358 sprintf(str,
"L1P#%04d1*", (
int)(10.0*value));
372 char cmd[4], str[16];
383 if ((sec<0.f) || (sec>0.59)) {
384 cm_msg(MERROR,
"W6100_set",
"value for '%s' out of range [0.0,99.59].", cmd);
390 if ((sec<0.f) || (sec>0.59)) {
391 cm_msg(MERROR,
"W6100_set",
"value for '%s' out of range [0.0,99.59].", cmd);
400 if ((min<0.f) || (min>99)) {
401 cm_msg(MERROR,
"W6100_set",
"value for '%s' out of range [0.00,99.59].", cmd);
406 sprintf(str,
"L1%s#%04d2*", cmd, (
int)(100.f*value));
423 if ((value < 0.f) || (value > 100.f)) {
424 cm_msg(MERROR,
"W6100_set",
"value for the needle valve position is out of range [0,100].");
429 sprintf(str,
"L1W#%04d0*", (
int)value);
447 sscanf(str,
"L1L%dA*", &status);
450 strcpy(str,
"L1Z#00040*");
456 strcpy(str,
"L1Z#00010*");
478 cm_get_experiment_database(&hDB, NULL);
482 cm_msg(MINFO,
"w6100_forced_update",
"w6100_forced_update: couldn't get variable output handle. Forced update needs to be preformed manually!");
487 cm_msg(MINFO,
"w6100_forced_update",
"w6100_forced_update: performing forced update...");
490 size =
sizeof(value);
495 size =
sizeof(value);
500 size =
sizeof(value);
505 size =
sizeof(value);
525 sscanf(str,
"L1L%dA*", &status);
528 strcpy(str,
"L1Z#00040*");
535 strcpy(str,
"L1Z#00020*");
557 sscanf(str,
"L1L%dA*", &status);
560 strcpy(str,
"L1Z#00020*");
566 strcpy(str,
"L1Z#00030*");
580 int status, ctrl, self_tune;
599 cm_msg(MERROR,
"W6100_set",
"allowed values are 0=manual, 1=auto i.e. PID, 2=self-tuning.");
605 sscanf(str,
"L1L%dA*", &status);
618 if (ctrl && self_tune)
641 INT status, i, ctrl, self_tune;
645 cm_get_experiment_database(&hDB, NULL);
653 if ((status != DB_SUCCESS) && (status != DB_OPEN_RECORD)) {
654 cm_msg(MERROR,
"w6100_in_init",
"w6100_in_init: Error creating DD record in ODB, status=%d", status);
660 db_find_key(hDB, hKey,
"DD", &hkeydd);
665 cm_msg(MINFO,
"w6100_in_init",
"West 6100 disabled from within the DD ...");
684 cm_msg(MERROR,
"w6100_in_init",
"Error, max. number of W6100 input channels is 3, not %d.", info->
num_channels_in);
694 status = info->
bd(CMD_INIT, hKey, &info->
bd_info);
695 if (status != FE_SUCCESS) {
696 cm_msg(MERROR,
"W6100_in_init",
"Couldn't init bus driver of 'West 6100'");
712 cm_msg(MERROR,
"W6100_in_init",
"Error getting device query from 'West 6100'");
717 if (strstr(str,
"L1?A*")) {
718 cm_msg(MINFO,
"W6100_in_init",
"'West 6100' is alive and ready.");
721 cm_msg(MINFO,
"W6100_in_init",
"'West 6100' is not responding properly -> %s", str);
738 sscanf(str,
"L1L%dA*", &status);
751 if (ctrl && self_tune)
757 cm_msg(MINFO,
"west6100_in_init",
"west6100_in_init: west 6100 initialized.");
777 INT
w6100_out_init(HNDLE hKey,
void **pinfo, INT channels, INT (*bd)(INT cmd, ...))
782 cm_get_experiment_database(&hDB, NULL);
788 if ((status != DB_SUCCESS) && (status != DB_OPEN_RECORD)) {
789 cm_msg(MERROR,
"w6100_out_init",
"w6100_out_init: Error creating DD record in ODB, status=%d", status);
794 db_find_key(hDB, hKey,
"DD", &hkeydd);
801 cm_msg(MERROR,
"w6100_out_init",
"Error, allowed number of W6100 output channels is 8, not %d.", info->
num_channels_out);
850 info->
remote = (int) value;
857 cm_msg(MINFO,
"W6100_set",
858 "set values not possible at the moment, since the bus driver is not available!");
885 sprintf(str,
"L1B#%04d0*", (
int)value);
907 char str[128], cmd[128];
909 DWORD nowtime, difftime;
936 cm_msg(MINFO,
"W6100_get",
"West 6100: reconnection trial ...");
938 if (status != FE_SUCCESS) {
941 cm_msg(MINFO,
"W6100_get",
"West 6100: reconnection attempted failed");
948 cm_msg(MINFO,
"W6100_get",
"West 6100: successfully reconnected");
985 if (strstr(str,
"<??>")) {
991 sscanf(str,
"L1L%fA*", pvalue);
999 cm_msg(MERROR,
"W6100_get",
"'West 6100' does not respond.");
1011 cm_msg(MINFO,
"W6100_get",
"West 6100: try to disconnect and reconnect the bus driver");
1062 INT channel, status;
1068 va_start(argptr, cmd);
1069 status = FE_SUCCESS;
1073 hKey = va_arg(argptr, HNDLE);
1074 info = va_arg(argptr,
void *);
1075 channel = va_arg(argptr, INT);
1076 flags = va_arg(argptr, DWORD);
1077 bd = va_arg(argptr,
void *);
1082 info = va_arg(argptr,
void *);
1087 info = va_arg(argptr,
void *);
1088 channel = va_arg(argptr, INT);
1089 pvalue = va_arg(argptr,
float*);
1090 status =
w6100_get(info, channel, pvalue);
1094 info = va_arg(argptr,
void *);
1095 channel = va_arg(argptr, INT);
1096 name = va_arg(argptr,
char *);
1112 INT channel, status;
1118 va_start(argptr, cmd);
1119 status = FE_SUCCESS;
1123 hKey = va_arg(argptr, HNDLE);
1124 info = va_arg(argptr,
void *);
1125 channel = va_arg(argptr, INT);
1126 flags = va_arg(argptr, DWORD);
1127 bd = va_arg(argptr,
void *);
1132 info = va_arg(argptr,
void *);
1133 channel = va_arg(argptr, INT);
1134 value = (float) va_arg(argptr,
double);
1135 status =
w6100_set(info, channel, value);
1139 info = va_arg(argptr,
void *);
1140 channel = va_arg(argptr, INT);
1141 name = va_arg(argptr,
char *);
void w6100_set_manual(W6100_INFO *info)
char odb_output[2 *NAME_LENGTH]
odb output variable path. Needed by the forced update routine
INT w6100_get(W6100_INFO *info, INT channel, float *pvalue)
#define W6100_OUT_CHANNELS
number of output channels
#define W6100_READ_ERROR
read error tag
W6100_param param
stores internal parameter of the controller
void w6100_set_gain(W6100_INFO *info, float value)
#define W6100_IN_SETTINGS_STR
initializing string for W6100_IN_SETTINGS
INT w6100_set(W6100_INFO *info, INT channel, float value)
INT w6100_in_init(HNDLE hKey, void **pinfo, INT channels, INT(*bd)(INT cmd,...))
#define W6100_IN_CHANNELS
number of input channels
INT w6100_exit(W6100_INFO *info)
INT w6100_in_get_label(W6100_INFO *info, INT channel, char *name)
INT w6100_in(INT cmd,...)
INT num_channels_out
number of out-channels
int ets_logout(void *info, int wait, int detailed_msg)
INT detailed_msg
flag indicating if detailed status/error messages are wanted
char name[W6100_IN_CHANNELS][64]
name of the in-channels
void w6100_set_pressure(W6100_INFO *info, float value)
void w6100_set_ctrl(W6100_INFO *info, float value)
void * bd_info
private info of bus driver
int first_bd_error
flag showing if the bus driver error message is already given
void w6100_set_reset_or_rate(W6100_INFO *info, float value, int tag)
INT readback_failure
counts the number of readback failures
#define W6100_DELTA_TIME_ERROR
reset error counter after W6100_DELTA_TIME_ERROR seconds
int w6100_set_cmd(W6100_INFO *info, char *who, char *cmd, char *activate_cmd)
#define W6100_INIT_ERROR
initialize error tag
void w6100_set_auto(W6100_INFO *info)
void w6100_error(W6100_INFO *info, char *who, char *msg)
float low_limit
low limit of the 'West 6100' set point
int ctrl
'West 6100' controller state (0=Manual, 1=Auto, i.e. PID controlled, 2=Self-Tuning) ...
INT ets_in_use
flag indicating if the rs232 terminal server is in use
W6100_IN_SETTINGS w6100_in_settings
ODB hot-link data for the DD.
INT odb_offset
odb offset for the output variables. Needed by the forced update routine
HNDLE hkey
holds the ODB key to the DD
#define W6100_MAX_ERROR
maximum number of error messages
#define W6100_TIME_OUT
time out in msecs for read (rs232)
#define W6100_SET_PRESSURE
#define W6100_OUT_OF_RANGE
read back pressure out of range tag
float w6100_decode_data(char *code)
This structure contains private variables for the device driver.
void w6100_set_self_tuning(W6100_INFO *info)
int w6100_get_value(W6100_INFO *info, char *who, char *cmd, char *rcv)
char name[W6100_OUT_CHANNELS][64]
name of the out-channels
void w6100_set_needle_valve_pos(W6100_INFO *info, float value)
W6100_OUT_SETTINGS w6100_out_settings
ODB hot-link data for the DD.
INT enabled
flag showing if the device is enabled
INT errorcount
error counter
int bd_connected
flag showing if bus driver is connected
stores internal informations within the DD.
INT w6100_out_init(HNDLE hKey, void **pinfo, INT channels, INT(*bd)(INT cmd,...))
stores internal informations within the DD.
float high_limit
high limit of the 'West 6100' set point
stores internal settings of the running 'West 6100' controller
INT(* bd)(INT cmd,...)
bus driver entry function
#define W6100_ETS_LOGOUT_SLEEP
sleep time (us) between the telnet commands of the ets_logout
#define W6100_MAX_READBACK_FAILURE
maximum number of readback failures before a reconnect will take place
INT w6100_out_get_label(W6100_INFO *info, INT channel, char *name)
DWORD last_reconnect
timer for bus driver reconnect error handling
void w6100_forced_update(W6100_INFO *info)
INT w6100_out(INT cmd,...)
#define W6100_OUT_SETTINGS_STR
initializing string for W6100_OUT_SETTINGS
INT startup_error
startup error tag
float needle_valve_pos
actual needle valve position
INT num_channels_in
number of in-channels
DWORD lasterrtime
timer for error handling
INT remote
remote tag, 1=remote, 0=local