Low-Energy Muon (LEM) Experiment  0.5.1
scs400.c
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------
2 
3  Name: scs400.c
4  Created by: Andreas Suter 2005/04/22
5 
6  Contents: MIDAS device driver for the MSCB thermo element card.
7 
8 ----------------------------------------------------------------------------*/
9 
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <stdarg.h>
13 #include <string.h>
14 #include "midas.h"
15 #include "mscb.h"
16 #include "scs400.h"
17 
18 
19 // --------- to handle error messages ------------------------------
20 
21 #define SCS400_INIT_ERROR -2
22 #define SCS400_READ_ERROR -1
23 
24 #define SCS400_MAX_ERROR 5
26 #define SCS400_DELTA_TIME_ERROR 600
28 #define SCS400_DEBUG FALSE
30 #define SCS400_MSCB_DEBUG FALSE
32 
33 // ----------- SCS400 related infos ---------------------------------
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
54 
55 
57 typedef struct {
60  char port[NAME_LENGTH];
61  INT group_addr;
62  INT node_addr;
63  char demand[SCS400_TEMP_CHS][NAME_LENGTH];
64  char temp[SCS400_TEMP_CHS][NAME_LENGTH];
65  char gain[SCS400_TEMP_CHS][NAME_LENGTH];
66  char rate[SCS400_TEMP_CHS][NAME_LENGTH];
67  char pint[SCS400_TEMP_CHS][NAME_LENGTH];
68  char power[SCS400_TEMP_CHS][NAME_LENGTH];
69  char offset[SCS400_TEMP_CHS][NAME_LENGTH];
70  char period[NAME_LENGTH];
72 
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\
81 [32] Demand0\n\
82 [32] Demand1\n\
83 [32] Demand2\n\
84 [32] Demand3\n\
85 [32] Demand4\n\
86 [32] Demand5\n\
87 [32] Demand6\n\
88 [32] Demand7\n\
89 Temp Name = STRING[8] : \n\
90 [32] Temp0\n\
91 [32] Temp1\n\
92 [32] Temp2\n\
93 [32] Temp3\n\
94 [32] Temp4\n\
95 [32] Temp5\n\
96 [32] Temp6\n\
97 [32] Temp7\n\
98 Gain P (PID) Name = STRING[8] : \n\
99 [32] CProp0\n\
100 [32] CProp1\n\
101 [32] CProp2\n\
102 [32] CProp3\n\
103 [32] CProp4\n\
104 [32] CProp5\n\
105 [32] CProp6\n\
106 [32] CProp7\n\
107 Rate I (PID) Name = STRING[8] : \n\
108 [32] CInt0\n\
109 [32] CInt1\n\
110 [32] CInt2\n\
111 [32] CInt3\n\
112 [32] CInt4\n\
113 [32] CInt5\n\
114 [32] CInt6\n\
115 [32] CInt7\n\
116 PInt (PID) Name = STRING[8] : \n\
117 [32] PInt0\n\
118 [32] PInt1\n\
119 [32] PInt2\n\
120 [32] PInt3\n\
121 [32] PInt4\n\
122 [32] PInt5\n\
123 [32] PInt6\n\
124 [32] PInt7\n\
125 Power Name = STRING[8] : \n\
126 [32] Pwr0\n\
127 [32] Pwr1\n\
128 [32] Pwr2\n\
129 [32] Pwr3\n\
130 [32] Pwr4\n\
131 [32] Pwr5\n\
132 [32] Pwr6\n\
133 [32] Pwr7\n\
134 Offset Name = STRING[8] : \n\
135 [32] Offset0\n\
136 [32] Offset1\n\
137 [32] Offset2\n\
138 [32] Offset3\n\
139 [32] Offset4\n\
140 [32] Offset5\n\
141 [32] Offset6\n\
142 [32] Offset7\n\
143 Period Name = STRING : [32] Period\n\
144 "
145 
147 typedef struct {
149  INT fd;
150  unsigned char demand_width;
151  unsigned char temp_width;
152  unsigned char cprop_width;
153  unsigned char cint_width;
154  unsigned char pint_width;
155  unsigned char pwr_width;
156  unsigned char offset_width;
157  char input_buffer[32];
158  float present_value[3*SCS400_TEMP_CHS];
159  float previous_value[3*SCS400_TEMP_CHS];
160  INT errcount;
162  DWORD lasterrtime;
163  DWORD read_timer;
164 } SCS400_INFO;
165 
167 
168 //---- device driver routines --------------------------------------
183 INT scs400_in_init(HNDLE hKey, void **pinfo, INT channels)
184 {
185 INT status, size;
186 HNDLE hDB, hkeydd;
187 MSCB_INFO node_info;
188 MSCB_INFO_VAR var_info;
189 
190  // allocate info structure
191  info = calloc(1, sizeof(SCS400_INFO));
192  *pinfo = info;
193 
194  cm_get_experiment_database(&hDB, NULL);
195 
196  // create SCS400 settings record
197  status = db_create_record(hDB, hKey, "DD", SCS400_SETTINGS_STR);
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);
200  cm_yield(0);
201  return FE_ERR_ODB;
202  }
203 
204  db_find_key(hDB, hKey, "DD", &hkeydd);
205  size = sizeof(info->settings);
206  db_get_record(hDB, hkeydd, &info->settings, &size, 0);
207 
208  // initialize driver
209  info->errcount = 0;
210  info->startup_error = 0;
211  info->lasterrtime = ss_time();
212  info->read_timer = 0;
213 
214  // initialize MSCB
215  info->fd = mscb_init(info->settings.port, sizeof(info->settings.port), NULL, SCS400_MSCB_DEBUG);
216  if (info->fd == -1) {
217  cm_msg(MINFO, "scs400_init", "scs400_init: Couldn't initialize MSCB port %s", info->settings.port);
218  cm_yield(0);
219  info->startup_error = 1;
220  return FE_SUCCESS;
221  }
222 
223  // check if it is really a scs400
224  status=mscb_info(info->fd, info->settings.node_addr, &node_info);
225  if (status != MSCB_SUCCESS) {
226  cm_msg(MINFO, "scs400_init", "scs400_init: Couldn't get node info");
227  cm_yield(0);
228  info->startup_error = 1;
229  return FE_SUCCESS;
230  }
231  if (node_info.n_variables != SCS400_NOVARS) {
232  cm_msg(MINFO, "scs400_init", "scs400_init: No of vars should be %d, found %d", SCS400_NOVARS, node_info.n_variables);
233  cm_yield(0);
234  info->startup_error = 1;
235  return FE_SUCCESS;
236  }
237 
238  // get variable width of demand
239  status=mscb_info_variable(info->fd, info->settings.node_addr, SCS400_POS_DEMAND*SCS400_TEMP_CHS, &var_info);
240  if (status != MSCB_SUCCESS) {
241  cm_msg(MINFO, "scs400_init", "scs400_init: Couldn't get demand variable info");
242  cm_yield(0);
243  info->startup_error = 1;
244  return FE_SUCCESS;
245  }
246  info->demand_width = var_info.width;
247 
248  // get variable width of temp
249  status=mscb_info_variable(info->fd, info->settings.node_addr, SCS400_POS_TEMP*SCS400_TEMP_CHS, &var_info);
250  if (status != MSCB_SUCCESS) {
251  cm_msg(MINFO, "scs400_init", "scs400_init: Couldn't get temp. variable info");
252  cm_yield(0);
253  info->startup_error = 1;
254  return FE_SUCCESS;
255  }
256  info->temp_width = var_info.width;
257 
258  // get variable width of CProp
259  status=mscb_info_variable(info->fd, info->settings.node_addr, SCS400_POS_CPROP*SCS400_TEMP_CHS, &var_info);
260  if (status != MSCB_SUCCESS) {
261  cm_msg(MINFO, "scs400_init", "scs400_init: Couldn't get gain P (PID) variable info");
262  cm_yield(0);
263  info->startup_error = 1;
264  return FE_SUCCESS;
265  }
266  info->cprop_width = var_info.width;
267 
268  // get variable width of CInt
269  status=mscb_info_variable(info->fd, info->settings.node_addr, SCS400_POS_CINT*SCS400_TEMP_CHS, &var_info);
270  if (status != MSCB_SUCCESS) {
271  cm_msg(MINFO, "scs400_init", "scs400_init: Couldn't get reset I (PID) variable info");
272  cm_yield(0);
273  info->startup_error = 1;
274  return FE_SUCCESS;
275  }
276  info->cint_width = var_info.width;
277 
278  // get variable width of PInt
279  status=mscb_info_variable(info->fd, info->settings.node_addr, SCS400_POS_PINT*SCS400_TEMP_CHS, &var_info);
280  if (status != MSCB_SUCCESS) {
281  cm_msg(MINFO, "scs400_init", "scs400_init: Couldn't get PInt (PID) variable info");
282  cm_yield(0);
283  info->startup_error = 1;
284  return FE_SUCCESS;
285  }
286  info->pint_width = var_info.width;
287 
288  // get variable width of pwr
289  status=mscb_info_variable(info->fd, info->settings.node_addr, SCS400_POS_POWER*SCS400_TEMP_CHS, &var_info);
290  if (status != MSCB_SUCCESS) {
291  cm_msg(MINFO, "scs400_init", "scs400_init: Couldn't get power variable info");
292  cm_yield(0);
293  info->startup_error = 1;
294  return FE_SUCCESS;
295  }
296  info->pwr_width = var_info.width;
297 
298  // get variable width of offset
299  status=mscb_info_variable(info->fd, info->settings.node_addr, SCS400_POS_OFFSET*SCS400_TEMP_CHS, &var_info);
300  if (status != MSCB_SUCCESS) {
301  cm_msg(MINFO, "scs400_init", "scs400_init: Couldn't get offset variable info");
302  cm_yield(0);
303  info->startup_error = 1;
304  return FE_SUCCESS;
305  }
306  info->offset_width = var_info.width;
307 
308  cm_msg(MINFO, "scs400_init", "scs400_init: initialized");
309  cm_yield(0);
310 
311  return FE_SUCCESS;
312 }
313 
314 /*----------------------------------------------------------------------------*/
327 INT scs400_out_init(HNDLE hKey, void **pinfo, INT channels)
328 {
329 HNDLE hDB;
330 
331  cm_get_experiment_database(&hDB, NULL);
332 
333  *pinfo = info;
334 
335  return FE_SUCCESS;
336 }
337 
338 /*----------------------------------------------------------------------------*/
347 {
348  // call EXIT function of MSCB driver, usually closes device
349  mscb_exit(info->fd);
350 
351  free(info);
352  return FE_SUCCESS;
353 }
354 
355 /*----------------------------------------------------------------------------*/
365 INT scs400_set(SCS400_INFO *info, INT channel, float value)
366 {
367  INT status;
368  short svalue;
369  DWORD nowtime, difftime;
370 
371  if (info->startup_error) {
372  ss_sleep(10); // to keep CPU load low when Run active
373  return FE_SUCCESS;
374  }
375 
376  // error timeout facility
377  nowtime = ss_time();
378  difftime = nowtime - info->lasterrtime;
379  if ( difftime > SCS400_DELTA_TIME_ERROR ) {
380  info->errcount = 0;
381  info->lasterrtime = ss_time();
382  }
383 
384  // write demand temperature
385  if (channel < SCS400_TEMP_CHS) { // demand
386  svalue = (short) value;
387  status = mscb_write(info->fd, info->settings.node_addr,
388  (unsigned char) channel, (void *)&svalue, info->pwr_width);
389  }
390  // write CProp (Gain P of PID)
391  if ((channel >= SCS400_TEMP_CHS) && (channel < 2*SCS400_TEMP_CHS)) {
392  status = mscb_write(info->fd, info->settings.node_addr,
393  (unsigned char) (channel-SCS400_TEMP_CHS+SCS400_POS_CPROP*SCS400_TEMP_CHS),
394  (void *)&value, info->pwr_width);
395  }
396  // write CInt (Reset I of PID)
397  if ((channel >= 2*SCS400_TEMP_CHS) && (channel < 3*SCS400_TEMP_CHS)) {
398  status = mscb_write(info->fd, info->settings.node_addr,
399  (unsigned char) (channel-2*SCS400_TEMP_CHS+SCS400_POS_CINT*SCS400_TEMP_CHS),
400  (void *)&value, info->pwr_width);
401  }
402  // write offset
403  if ((channel >= 3*SCS400_TEMP_CHS) && (channel < 4*SCS400_TEMP_CHS)) {
404  svalue = (short) value;
405  status = mscb_write(info->fd, info->settings.node_addr,
406  (unsigned char) (channel-3*SCS400_TEMP_CHS+SCS400_POS_OFFSET*SCS400_TEMP_CHS),
407  (void *)&svalue, info->pwr_width);
408  }
409  // write period
410  if (channel >= 4*SCS400_TEMP_CHS) {
411  svalue = (short) value;
412  status = mscb_write(info->fd, info->settings.node_addr,
413  (unsigned char) (channel-4*SCS400_TEMP_CHS+SCS400_POS_PERIOD*SCS400_TEMP_CHS),
414  (void *)&svalue, info->pwr_width);
415  }
416 
417  if (status != MSCB_SUCCESS) {
418  if (info->errcount < SCS400_MAX_ERROR) {
419  if (info->settings.detailed_msg)
420  cm_msg(MERROR, "scs400_set", "scs400_set: MSCB error encountered: %d", status);
421  info->errcount++;
422  }
423  return FE_SUCCESS;
424  }
425 
426  return FE_SUCCESS;
427 }
428 
429 /*----------------------------------------------------------------------------*/
440 INT scs400_get_in_label(SCS400_INFO *info, INT channel, char *name)
441 {
442  if (channel < SCS400_TEMP_CHS) // temp
443  strcpy(name, info->settings.temp[channel]);
444  if ((channel >= SCS400_TEMP_CHS) && (channel < 2*SCS400_TEMP_CHS)) // pint
445  strcpy(name, info->settings.pint[channel-SCS400_TEMP_CHS]);
446  if ((channel >= 2*SCS400_TEMP_CHS) && (channel < 3*SCS400_TEMP_CHS)) // power
447  strcpy(name, info->settings.power[channel-2*SCS400_TEMP_CHS]);
448 
449  return FE_SUCCESS;
450 }
451 
452 /*----------------------------------------------------------------------------*/
463 INT scs400_get_out_label(SCS400_INFO *info, INT channel, char *name)
464 {
465  if (channel < SCS400_TEMP_CHS) // demand
466  strcpy(name, info->settings.demand[channel]);
467  if ((channel >= SCS400_TEMP_CHS) && (channel < 2*SCS400_TEMP_CHS)) // cprop
468  strcpy(name, info->settings.gain[channel-SCS400_TEMP_CHS]);
469  if ((channel >= 2*SCS400_TEMP_CHS) && (channel < 3*SCS400_TEMP_CHS)) // cint
470  strcpy(name, info->settings.rate[channel-2*SCS400_TEMP_CHS]);
471  if ((channel >= 3*SCS400_TEMP_CHS) && (channel < 4*SCS400_TEMP_CHS)) // offset
472  strcpy(name, info->settings.offset[channel-3*SCS400_TEMP_CHS]);
473  if (channel >= 4*SCS400_TEMP_CHS) // period
474  strcpy(name, info->settings.period);
475 
476  return FE_SUCCESS;
477 }
478 
479 /*-----------------------------------------------------------------------------*/
486 float scs400_mscb_to_float(char *data, int index)
487 {
488  int i;
489  char buff[4];
490  float result;
491 
492  for (i=0; i<4; i++)
493  buff[3-i] = data[index+i];
494 
495  result = *((float*) &buff);
496 
497  return result;
498 }
499 
500 /*-----------------------------------------------------------------------------*/
510 INT scs400_get(SCS400_INFO *info, INT channel, float *pvalue)
511 {
512  INT status, size;
513  DWORD nowtime, difftime;
514  int i, j;
515 
516  // check if there was a startup error
517  if (info->startup_error) {
518  *pvalue = (float) SCS400_INIT_ERROR;
519  ss_sleep(10); // to keep CPU load low when Run active
520  return FE_SUCCESS;
521  }
522 
523  // error timeout facility
524  nowtime = ss_time();
525  difftime = nowtime - info->lasterrtime;
526  if ( difftime > SCS400_DELTA_TIME_ERROR ) {
527  info->errcount = 0;
528  info->lasterrtime = ss_time();
529  }
530 
531  // check if time to read data
532  if (nowtime - info->read_timer >= info->settings.read_timeout) {
533  // restart timer
534  info->read_timer = ss_time();
535 
536  // read temperature values
537  size = sizeof(info->input_buffer);
538  status = mscb_read_range(info->fd, info->settings.node_addr,
539  SCS400_POS_TEMP*SCS400_TEMP_CHS, (SCS400_POS_TEMP+1)*SCS400_TEMP_CHS-1,
540  &info->input_buffer, &size);
541  if (status == MSCB_SUCCESS) { // got data
542  // fill temperature values
543  size = sizeof(float);
544  for (i=0; i<SCS400_TEMP_CHS; i++) {
545  info->present_value[i] = scs400_mscb_to_float(info->input_buffer, size*i);
546  }
547  // copy new values to the previous ones
548  for (j=0; j<SCS400_TEMP_CHS; j++)
549  info->previous_value[j] = info->present_value[j];
550  } else { // error getting data
551  // copy previous values to the present ones
552  for (j=0; j<SCS400_TEMP_CHS; j++)
553  info->present_value[j] = info->previous_value[j];
554  }
555 
556  // read PInt values
557  size = sizeof(info->input_buffer);
558  status = mscb_read_range(info->fd, info->settings.node_addr,
559  SCS400_POS_PINT*SCS400_TEMP_CHS, (SCS400_POS_PINT+1)*SCS400_TEMP_CHS-1,
560  &info->input_buffer, &size);
561  if (status == MSCB_SUCCESS) { // got data
562  // fill PInt values
563  size = sizeof(float);
564  for (i=0; i<SCS400_TEMP_CHS; i++) {
565  info->present_value[SCS400_TEMP_CHS+i] = scs400_mscb_to_float(info->input_buffer, size*i);
566  }
567  // copy new values to the previous ones
568  for (j=0; j<SCS400_TEMP_CHS; j++)
569  info->previous_value[SCS400_TEMP_CHS+j] = info->present_value[SCS400_TEMP_CHS+j];
570  } else { // error getting data
571  // copy previous values to the present ones
572  for (j=0; j<SCS400_TEMP_CHS; j++)
573  info->present_value[SCS400_TEMP_CHS+j] = info->previous_value[SCS400_TEMP_CHS+j];
574  }
575 
576  // read power values
577  size = sizeof(info->input_buffer);
578  status = mscb_read_range(info->fd, info->settings.node_addr,
579  SCS400_POS_POWER*SCS400_TEMP_CHS, (SCS400_POS_POWER+1)*SCS400_TEMP_CHS-1,
580  &info->input_buffer, &size);
581  if (status == MSCB_SUCCESS) { // got data
582  // fill power values
583  size = sizeof(float);
584  for (i=0; i<SCS400_TEMP_CHS; i++) {
585  info->present_value[2*SCS400_TEMP_CHS+i] = scs400_mscb_to_float(info->input_buffer, size*i);
586  }
587  // copy new values to the previous ones
588  for (j=0; j<SCS400_TEMP_CHS; j++)
589  info->previous_value[2*SCS400_TEMP_CHS+j] = info->present_value[2*SCS400_TEMP_CHS+j];
590  } else { // error getting data
591  // copy previous values to the present ones
592  for (j=0; j<SCS400_TEMP_CHS; j++)
593  info->present_value[2*SCS400_TEMP_CHS+j] = info->previous_value[2*SCS400_TEMP_CHS+j];
594  }
595  }
596 
597  ss_sleep(10); // to keep CPU load low when Run active
598  *pvalue = info->present_value[channel];
599 
600  return FE_SUCCESS;
601 }
602 
603 /*---- device driver entry point -----------------------------------*/
604 INT scs400_in(INT cmd, ...)
605 {
606 va_list argptr;
607 HNDLE hKey;
608 INT channel, status;
609 float *pvalue;
610 void *info;
611 char *name;
612 DWORD flags;
613 
614  va_start(argptr, cmd);
615  status = FE_SUCCESS;
616 
617  switch (cmd) {
618  case CMD_INIT:
619  hKey = va_arg(argptr, HNDLE);
620  info = va_arg(argptr, void *);
621  channel = va_arg(argptr, INT);
622  flags = va_arg(argptr, DWORD);
623  status = scs400_in_init(hKey, info, channel);
624  break;
625 
626  case CMD_EXIT:
627  info = va_arg(argptr, void *);
628  status = scs400_exit(info);
629  break;
630 
631  case CMD_GET:
632  info = va_arg(argptr, void *);
633  channel = va_arg(argptr, INT);
634  pvalue = va_arg(argptr, float*);
635  status = scs400_get(info, channel, pvalue);
636  break;
637 
638  case CMD_GET_LABEL:
639  info = va_arg(argptr, void *);
640  channel = va_arg(argptr, INT);
641  name = va_arg(argptr, char *);
642  status = scs400_get_in_label(info, channel, name);
643  break;
644 
645  default:
646  break;
647  }
648 
649  va_end(argptr);
650 
651  return status;
652 }
653 /*------------------------------------------------------------------*/
654 
655 INT scs400_out(INT cmd, ...)
656 {
657 va_list argptr;
658 HNDLE hKey;
659 INT channel, status;
660 float value;
661 void *info;
662 char *name;
663 DWORD flags;
664 
665  va_start(argptr, cmd);
666  status = FE_SUCCESS;
667 
668  switch (cmd) {
669  case CMD_INIT:
670  hKey = va_arg(argptr, HNDLE);
671  info = va_arg(argptr, void *);
672  channel = va_arg(argptr, INT);
673  flags = va_arg(argptr, DWORD);
674  status = scs400_out_init(hKey, info, channel);
675  break;
676 
677  case CMD_SET:
678  info = va_arg(argptr, void *);
679  channel = va_arg(argptr, INT);
680  value = (float) va_arg(argptr, double);
681  status = scs400_set(info, channel, value);
682  break;
683 
684  case CMD_GET_LABEL:
685  info = va_arg(argptr, void *);
686  channel = va_arg(argptr, INT);
687  name = va_arg(argptr, char *);
688  status = scs400_get_out_label(info, channel, name);
689  break;
690 
691  default:
692  break;
693  }
694 
695  va_end(argptr);
696 
697  return status;
698 }
699 /*------------------------------------------------------------------*/
unsigned char temp_width
width of the temp values
Definition: scs400.c:151
#define SCS400_POS_POWER
position of power
Definition: scs400.c:49
char temp[SCS400_TEMP_CHS][NAME_LENGTH]
Name of the temperatures.
Definition: scs400.c:64
#define SCS400_POS_CPROP
position of gain for PID
Definition: scs400.c:43
INFO info
Definition: vme_fe.c:206
INT scs400_in_init(HNDLE hKey, void **pinfo, INT channels)
Definition: scs400.c:183
INT scs400_out_init(HNDLE hKey, void **pinfo, INT channels)
Definition: scs400.c:327
#define SCS400_POS_PINT
position of PInt from PID
Definition: scs400.c:47
#define SCS400_DELTA_TIME_ERROR
reset error counter after DELTA_TIME_ERROR seconds
Definition: scs400.c:27
#define SCS400_MAX_ERROR
maximum number of error messages
Definition: scs400.c:25
char input_buffer[32]
raw data input buffer
Definition: scs400.c:157
#define SCS400_MSCB_DEBUG
MSCB debug flag.
Definition: scs400.c:31
#define SCS400_POS_CINT
position of reset for PID
Definition: scs400.c:45
INT scs400_get(SCS400_INFO *info, INT channel, float *pvalue)
Definition: scs400.c:510
char period[NAME_LENGTH]
Name of period.
Definition: scs400.c:70
Stores all the parameters the device driver needs.
Definition: scs400.c:57
INT scs400_out(INT cmd,...)
Definition: scs400.c:655
float present_value[3 *SCS400_TEMP_CHS]
present data value
Definition: scs400.c:158
#define SCS400_POS_TEMP
position of measured temperature
Definition: scs400.c:41
INT fd
MSCB file desciptor.
Definition: scs400.c:149
char demand[SCS400_TEMP_CHS][NAME_LENGTH]
Name of the demand temperature.
Definition: scs400.c:63
INT node_addr
node address within the MSCB
Definition: scs400.c:62
unsigned char pint_width
width of the pint values
Definition: scs400.c:154
HNDLE hKey
Definition: write_summary.c:97
unsigned char cint_width
width of the cint values
Definition: scs400.c:153
unsigned char offset_width
width of the offset values
Definition: scs400.c:156
#define SCS400_NOVARS
number of variables of the thermo element MSCB card
Definition: scs400.c:35
unsigned char pwr_width
width of the power values
Definition: scs400.c:155
float previous_value[3 *SCS400_TEMP_CHS]
previous data value
Definition: scs400.c:159
SCS400_SETTINGS settings
stores the internal DD settings
Definition: scs400.c:148
static INT rate[N_SCALER]
#define SCS400_SETTINGS_STR
Initializing string for the struct SCS400_SETTINGS.
Definition: scs400.c:74
HNDLE hDB
Definition: write_summary.c:97
#define SCS400_TEMP_CHS
number of temperature channels
Definition: scs400.c:37
float scs400_mscb_to_float(char *data, int index)
Definition: scs400.c:486
#define SCS400_POS_PERIOD
position of period
Definition: scs400.c:53
char offset[SCS400_TEMP_CHS][NAME_LENGTH]
Name of the temperature offsets.
Definition: scs400.c:69
char power[SCS400_TEMP_CHS][NAME_LENGTH]
Name of the power cycle.
Definition: scs400.c:68
DWORD lasterrtime
last error time stamp
Definition: scs400.c:162
INT scs400_exit(SCS400_INFO *info)
Definition: scs400.c:346
INT scs400_in(INT cmd,...)
Definition: scs400.c:604
unsigned char demand_width
width of the demand values
Definition: scs400.c:150
static INT offset
Definition: sc_ana_module.c:89
INT startup_error
initializer error tag, if set, scs400_get and scs400_set won&#39;t do anything
Definition: scs400.c:161
DWORD read_timer
timer used to decide when to read data
Definition: scs400.c:163
#define SCS400_POS_OFFSET
position of offset
Definition: scs400.c:51
INT scs400_get_out_label(SCS400_INFO *info, INT channel, char *name)
Definition: scs400.c:463
#define SCS400_POS_DEMAND
position of demand temperature
Definition: scs400.c:39
INT detailed_msg
flag indicating if detailed status/error messages are wanted
Definition: scs400.c:58
INT errcount
error counter in order not to flood the message queue
Definition: scs400.c:160
INT group_addr
group address within the MSCB
Definition: scs400.c:61
#define SCS400_INIT_ERROR
tag: initializing error
Definition: scs400.c:21
INT read_timeout
how often data shall be taken in (sec)
Definition: scs400.c:59
char pint[SCS400_TEMP_CHS][NAME_LENGTH]
Name of PInt (PID)
Definition: scs400.c:67
This structure contains private variables for the device driver.
Definition: scs400.c:147
char gain[SCS400_TEMP_CHS][NAME_LENGTH]
Name of the gain P (PID)
Definition: scs400.c:65
unsigned char cprop_width
width of the cprop values
Definition: scs400.c:152
char port[NAME_LENGTH]
MSCB port, e.g. /dev/parport0.
Definition: scs400.c:60
char rate[SCS400_TEMP_CHS][NAME_LENGTH]
Name of the reset I (PID)
Definition: scs400.c:66
INT scs400_set(SCS400_INFO *info, INT channel, float value)
Definition: scs400.c:365
INT scs400_get_in_label(SCS400_INFO *info, INT channel, char *name)
Definition: scs400.c:440