21 #define SCS400_INIT_ERROR -2
22 #define SCS400_READ_ERROR -1
24 #define SCS400_MAX_ERROR 5
26 #define SCS400_DELTA_TIME_ERROR 600
28 #define SCS400_DEBUG FALSE
30 #define SCS400_MSCB_DEBUG FALSE
35 #define SCS400_NOVARS 57
36 #define SCS400_TEMP_CHS 8
38 #define SCS400_POS_DEMAND 0
40 #define SCS400_POS_TEMP 1
42 #define SCS400_POS_CPROP 2
44 #define SCS400_POS_CINT 3
46 #define SCS400_POS_PINT 4
48 #define SCS400_POS_POWER 5
50 #define SCS400_POS_OFFSET 6
52 #define SCS400_POS_PERIOD 7
60 char port[NAME_LENGTH];
70 char period[NAME_LENGTH];
74 #define SCS400_SETTINGS_STR "\
75 Detailed Messages = INT : 0\n\
76 Read Period (sec) = INT : 1\n\
77 MSCB Port = STRING : [32] usb0\n\
78 Group Addr = INT : 1\n\
79 Node Addr = INT : 10\n\
80 Demand Temp Name = STRING[8] : \n\
89 Temp Name = STRING[8] : \n\
98 Gain P (PID) Name = STRING[8] : \n\
107 Rate I (PID) Name = STRING[8] : \n\
116 PInt (PID) Name = STRING[8] : \n\
125 Power Name = STRING[8] : \n\
134 Offset Name = STRING[8] : \n\
143 Period Name = STRING : [32] Period\n\
157 char input_buffer[32];
188 MSCB_INFO_VAR var_info;
194 cm_get_experiment_database(&hDB, NULL);
198 if ((status != DB_SUCCESS) && (status != DB_OPEN_RECORD)) {
199 cm_msg(MERROR,
"scs400_in_init",
"scs400_in_init: Error creating SCS Settings record in ODB, status=%d", status);
204 db_find_key(hDB, hKey,
"DD", &hkeydd);
206 db_get_record(hDB, hkeydd, &info->
settings, &size, 0);
216 if (info->
fd == -1) {
217 cm_msg(MINFO,
"scs400_init",
"scs400_init: Couldn't initialize MSCB port %s", info->
settings.
port);
225 if (status != MSCB_SUCCESS) {
226 cm_msg(MINFO,
"scs400_init",
"scs400_init: Couldn't get node info");
232 cm_msg(MINFO,
"scs400_init",
"scs400_init: No of vars should be %d, found %d",
SCS400_NOVARS, node_info.n_variables);
240 if (status != MSCB_SUCCESS) {
241 cm_msg(MINFO,
"scs400_init",
"scs400_init: Couldn't get demand variable info");
250 if (status != MSCB_SUCCESS) {
251 cm_msg(MINFO,
"scs400_init",
"scs400_init: Couldn't get temp. variable info");
260 if (status != MSCB_SUCCESS) {
261 cm_msg(MINFO,
"scs400_init",
"scs400_init: Couldn't get gain P (PID) variable info");
270 if (status != MSCB_SUCCESS) {
271 cm_msg(MINFO,
"scs400_init",
"scs400_init: Couldn't get reset I (PID) variable info");
280 if (status != MSCB_SUCCESS) {
281 cm_msg(MINFO,
"scs400_init",
"scs400_init: Couldn't get PInt (PID) variable info");
290 if (status != MSCB_SUCCESS) {
291 cm_msg(MINFO,
"scs400_init",
"scs400_init: Couldn't get power variable info");
300 if (status != MSCB_SUCCESS) {
301 cm_msg(MINFO,
"scs400_init",
"scs400_init: Couldn't get offset variable info");
308 cm_msg(MINFO,
"scs400_init",
"scs400_init: initialized");
331 cm_get_experiment_database(&hDB, NULL);
369 DWORD nowtime, difftime;
386 svalue = (short) value;
388 (
unsigned char) channel, (
void *)&svalue, info->
pwr_width);
404 svalue = (short) value;
411 svalue = (short) value;
417 if (status != MSCB_SUCCESS) {
420 cm_msg(MERROR,
"scs400_set",
"scs400_set: MSCB error encountered: %d", status);
493 buff[3-i] = data[index+i];
495 result = *((
float*) &buff);
513 DWORD nowtime, difftime;
541 if (status == MSCB_SUCCESS) {
543 size =
sizeof(float);
561 if (status == MSCB_SUCCESS) {
563 size =
sizeof(float);
581 if (status == MSCB_SUCCESS) {
583 size =
sizeof(float);
614 va_start(argptr, cmd);
619 hKey = va_arg(argptr, HNDLE);
620 info = va_arg(argptr,
void *);
621 channel = va_arg(argptr, INT);
622 flags = va_arg(argptr, DWORD);
627 info = va_arg(argptr,
void *);
632 info = va_arg(argptr,
void *);
633 channel = va_arg(argptr, INT);
634 pvalue = va_arg(argptr,
float*);
639 info = va_arg(argptr,
void *);
640 channel = va_arg(argptr, INT);
641 name = va_arg(argptr,
char *);
665 va_start(argptr, cmd);
670 hKey = va_arg(argptr, HNDLE);
671 info = va_arg(argptr,
void *);
672 channel = va_arg(argptr, INT);
673 flags = va_arg(argptr, DWORD);
678 info = va_arg(argptr,
void *);
679 channel = va_arg(argptr, INT);
680 value = (float) va_arg(argptr,
double);
685 info = va_arg(argptr,
void *);
686 channel = va_arg(argptr, INT);
687 name = va_arg(argptr,
char *);
unsigned char temp_width
width of the temp values
#define SCS400_POS_POWER
position of power
char temp[SCS400_TEMP_CHS][NAME_LENGTH]
Name of the temperatures.
#define SCS400_POS_CPROP
position of gain for PID
INT scs400_in_init(HNDLE hKey, void **pinfo, INT channels)
INT scs400_out_init(HNDLE hKey, void **pinfo, INT channels)
#define SCS400_POS_PINT
position of PInt from PID
#define SCS400_DELTA_TIME_ERROR
reset error counter after DELTA_TIME_ERROR seconds
#define SCS400_MAX_ERROR
maximum number of error messages
char input_buffer[32]
raw data input buffer
#define SCS400_MSCB_DEBUG
MSCB debug flag.
#define SCS400_POS_CINT
position of reset for PID
INT scs400_get(SCS400_INFO *info, INT channel, float *pvalue)
char period[NAME_LENGTH]
Name of period.
Stores all the parameters the device driver needs.
INT scs400_out(INT cmd,...)
float present_value[3 *SCS400_TEMP_CHS]
present data value
#define SCS400_POS_TEMP
position of measured temperature
INT fd
MSCB file desciptor.
char demand[SCS400_TEMP_CHS][NAME_LENGTH]
Name of the demand temperature.
INT node_addr
node address within the MSCB
unsigned char pint_width
width of the pint values
unsigned char cint_width
width of the cint values
unsigned char offset_width
width of the offset values
#define SCS400_NOVARS
number of variables of the thermo element MSCB card
unsigned char pwr_width
width of the power values
float previous_value[3 *SCS400_TEMP_CHS]
previous data value
SCS400_SETTINGS settings
stores the internal DD settings
static INT rate[N_SCALER]
#define SCS400_SETTINGS_STR
Initializing string for the struct SCS400_SETTINGS.
#define SCS400_TEMP_CHS
number of temperature channels
float scs400_mscb_to_float(char *data, int index)
#define SCS400_POS_PERIOD
position of period
char offset[SCS400_TEMP_CHS][NAME_LENGTH]
Name of the temperature offsets.
char power[SCS400_TEMP_CHS][NAME_LENGTH]
Name of the power cycle.
DWORD lasterrtime
last error time stamp
INT scs400_exit(SCS400_INFO *info)
INT scs400_in(INT cmd,...)
unsigned char demand_width
width of the demand values
INT startup_error
initializer error tag, if set, scs400_get and scs400_set won't do anything
DWORD read_timer
timer used to decide when to read data
#define SCS400_POS_OFFSET
position of offset
INT scs400_get_out_label(SCS400_INFO *info, INT channel, char *name)
#define SCS400_POS_DEMAND
position of demand temperature
INT detailed_msg
flag indicating if detailed status/error messages are wanted
INT errcount
error counter in order not to flood the message queue
INT group_addr
group address within the MSCB
#define SCS400_INIT_ERROR
tag: initializing error
INT read_timeout
how often data shall be taken in (sec)
char pint[SCS400_TEMP_CHS][NAME_LENGTH]
Name of PInt (PID)
This structure contains private variables for the device driver.
char gain[SCS400_TEMP_CHS][NAME_LENGTH]
Name of the gain P (PID)
unsigned char cprop_width
width of the cprop values
char port[NAME_LENGTH]
MSCB port, e.g. /dev/parport0.
char rate[SCS400_TEMP_CHS][NAME_LENGTH]
Name of the reset I (PID)
INT scs400_set(SCS400_INFO *info, INT channel, float value)
INT scs400_get_in_label(SCS400_INFO *info, INT channel, char *name)