22 #define LV_BIT0 0x0100
23 #define LV_BIT1 0x0200
24 #define LV_BIT2 0x0400
25 #define LV_BIT3 0x0800
26 #define LV_BIT4 0x1000
27 #define LV_BIT5 0x2000
28 #define LV_BIT6 0x4000
29 #define LV_BIT7 0x8000
30 #define LV_BIT8 0x0001
31 #define LV_BIT9 0x0002
32 #define LV_BIT10 0x0004
33 #define LV_BIT11 0x0008
34 #define LV_BIT12 0x0010
35 #define LV_BIT13 0x0020
36 #define LV_BIT14 0x0040
37 #define LV_BIT15 0x0080
40 #define PS64_LIFESIGN 0
46 #define SPS_MAX_BYTES 680
47 #define PS64_TIME_CONST 0
48 #define PS64_TIMEOUT_ERROR 3600
56 #define LAMVAC_INTERN_STR "\
57 Detailed Messages = INT : 0\n\
63 char out_name[NAME_LENGTH];
67 #define PS64_NAMES_STR "\
68 Input Names = STRING[5] : \n\
69 [32] PS64 Life Sign\n\
70 [32] PS64 GP Pirani\n\
72 [32] PS64 Status Word 1\n\
73 [32] PS64 Status Word 2\n\
74 Output Names = STRING : [32] PS64 Cmd\n\
84 INT (*bd)(INT cmd, ...);
127 if (buffer[0] & 0x80)
128 val = (buffer[0] &0x7f) << 8;
130 val = buffer[0] << 8;
132 if (buffer[1] & 0x80)
133 val += (buffer[1] &0x7f) + 128;
150 short val = buffer[0];
168 return pow(10.0, 1.667 * (
double)analog/100.0 - 11.33);
182 return pow(10.0, (
double)analog/100.0 - 5.5);
201 if ((buffer[4] != 65) || (buffer[5] != 66))
257 float delta = ss_time()-info->
time;
263 delta = ss_time()-info->
errTime;
267 cm_msg(MINFO,
"ps64_get_all",
268 "ps64_get_all: No of tcpip open errors = %d, tcpip read errors =%d of %d readings in the last %d secs.",
282 status = info->
bd(CMD_READ, info->
bd_info, &data[0],
sizeof(data), 3000);
284 cm_msg(MDEBUG,
"ps64_get_all",
"ps64_get_all: get data (status=%d)", status);
309 cm_msg(MINFO,
"ps64_get_all",
"ps64_get_all: get.data.status=%d", status);
328 info->
time = ss_time();
346 cm_msg(MDEBUG,
"ps64_write_cmd",
"ps64_write_cmd: write data (status=%d)", status);
378 cm_get_experiment_database(&hDB, NULL);
384 status = db_find_key(hDB, hKey,
"DD/intern", &hkeydd);
385 if (status != DB_SUCCESS) {
388 if ((status != DB_SUCCESS) && (status != DB_OPEN_RECORD)) {
389 cm_msg(MERROR,
"ps64_init",
"ps64_init: Error creating ps64 intern record in ODB, status=%d", status);
394 db_find_key(hDB, hKey,
"DD/intern", &hkeydd);
395 size =
sizeof(gInfo->
intern);
396 status = db_get_record(hDB, hkeydd, &gInfo->
intern, &size, 0);
398 status = db_open_record(hDB, hkeydd, &gInfo->
intern, size, MODE_READ, NULL, NULL);
402 if ((status != DB_SUCCESS) && (status != DB_OPEN_RECORD)) {
403 cm_msg(MERROR,
"ps64_init",
"ps64_init: Error creating ps64 Names record in ODB, status=%d", status);
407 db_find_key(hDB, hKey,
"DD/Names", &hkeydd);
409 db_get_record(hDB, hkeydd, &gInfo->
ps64_names, &size, 0);
413 status = db_find_key(hDB, hKey,
"DD/DB_Buffer", &hkeydd);
414 if (status != DB_SUCCESS) {
416 strcpy(str,
"DB_Buffer = BYTE[680] : \n");
419 status = db_create_record(hDB, hKey,
"DD/DB_Buffer", str);
420 if ((status != DB_SUCCESS) && (status != DB_OPEN_RECORD)) {
421 cm_msg(MERROR,
"ps64_init",
"ps64_init: Error creating ps64 DB_Buffer record in ODB, status=%d", status);
427 db_find_key(hDB, hKey,
"DD/DB_Buffer", &hkeydd);
429 status = db_get_record(hDB, hkeydd, &gInfo->
ps64_buffer, &size, 0);
431 status = db_open_record(hDB, hkeydd, &gInfo->
ps64_buffer, size, MODE_WRITE, NULL, NULL);
437 gInfo->
time = ss_time();
447 cm_msg(MDEBUG,
"ps64_init",
"ps64_init: open tcpip connection (status=%d)", status);
450 if (status != SUCCESS) {
453 cm_msg(MINFO,
"ps64_init",
"ps64_init: open bounced off");
456 return FE_ERR_DRIVER;
460 cm_msg(MINFO,
"ps64_init",
"ps64 initialized ...");
478 INT
ps64_out_init(HNDLE hKey,
void **pinfo, INT channels, INT (*bd)(INT cmd, ...))
556 cm_msg(MDEBUG,
"ps64_get",
"in ps64_get ...");
562 cm_msg(MDEBUG,
"ps64_get",
"in ps64_get and will call ps64_get_all(info)");
576 cm_msg(MDEBUG,
"ps64_start_pump",
"ps64_start_pump: will start pump ...");
585 cm_msg(MDEBUG,
"ps64_stop_pump",
"ps64_stop_pump: will stop pump ...");
608 db_find_key(info->
hDB, 0,
"/Equipment/Ps64Vac/Variables/Output", &hKey);
609 size =
sizeof(float);
611 db_set_data_index(info->
hDB, hKey, &fval, size, 0, TID_FLOAT);
627 va_start(argptr, cmd);
632 hKey = va_arg(argptr, HNDLE);
633 info = va_arg(argptr,
void *);
634 channel = va_arg(argptr, INT);
635 flags = va_arg(argptr, DWORD);
636 bd = va_arg(argptr,
void *);
641 info = va_arg(argptr,
void *);
646 info = va_arg(argptr,
void *);
647 channel = va_arg(argptr, INT);
648 pvalue = va_arg(argptr,
float*);
649 status =
ps64_get(info, channel, pvalue);
653 info = va_arg(argptr,
void *);
654 channel = va_arg(argptr, INT);
655 name = va_arg(argptr,
char *);
678 va_start(argptr, cmd);
683 hKey = va_arg(argptr, HNDLE);
684 info = va_arg(argptr,
void *);
685 channel = va_arg(argptr, INT);
686 flags = va_arg(argptr, DWORD);
687 bd = va_arg(argptr,
void *);
692 info = va_arg(argptr,
void *);
693 channel = va_arg(argptr, INT);
694 value = (float) va_arg(argptr,
double);
695 status =
ps64_set(info, channel, value);
699 info = va_arg(argptr,
void *);
700 channel = va_arg(argptr, INT);
701 name = va_arg(argptr,
char *);
INT detailed_msg
flag indicating if detailed status/error messages are wanted
Stores DD specific internal information.
INT read_counts
total no of tcpip reading attempts
INT ps64_out(INT cmd,...)
INT ps64_set(PS64_INFO *info, INT channel, float value)
DWORD last_success
timer of last read success
INT ps64_out_get_label(PS64_INFO *info, INT channel, char *name)
INT ps64_get(PS64_INFO *info, INT channel, float *pvalue)
INT ps64_in_init(HNDLE hKey, void **pinfo, INT channels, INT(*bd)(INT cmd,...))
void ps64_start_pump(PS64_INFO *info)
Stores the names of the various channels which are than transferred form the DD to the variable names...
void * bd_info
pointer to the BD info structure of the input channels
void ps64_get_all(PS64_INFO *info)
#define SPS_MAX_BYTES
length of the data structure exchanged between SPS and midas
INT read_error
how often there has been a read error
DWORD errTime
timer for error handling concerning tcpip communication
INT tcpip_open_error
how often the attempt to open the tcpip communication failed
HNDLE hKey_in
main device driver handle for input channels
LEMVAC_INFO * gInfo
global info structure, in/out-init routines need the same structure
#define PS64_TIMEOUT_ERROR
after what time (sec.) read errors should be reported
int spsToWord(unsigned char *buffer)
#define PS64_NAMES_STR
Initializing string for the struct PS64_NAMES.
#define PS64_IN_VARS
number of variables in the get list
double ps64_pirani_tpr280(int analog)
void ps64_write_cmd(PS64_INFO *info)
INT ps64_out_init(HNDLE hKey, void **pinfo, INT channels, INT(*bd)(INT cmd,...))
INT startup_error
tag if there has been an error at startup
float ps64_data[PS64_IN_VARS]
stores decoded values from SPS-DB
HNDLE hKey_out
main device driver handle for input channels
short spsToNumber(unsigned char *buffer)
char ps64_buffer[SPS_MAX_BYTES]
SPS-DB byte buffer.
INT ps64_exit(PS64_INFO *info)
HNDLE hKey_DB_Buffer
handle to the raw SPS-DB data
double ps64_pkr251(int analog)
PS64_NAMES ps64_names
stores the internal DD settings
int ps64_diag[6]
SPS diagnostics readback array (<1, <2, <3, <5, >5, failed)sec.
PS64_INTERN intern
stores DD specific internal settings
char out_name[NAME_LENGTH]
#define PS64_TIME_CONST
trigger time constant for read out of the SPS
char in_name[PS64_IN_VARS][NAME_LENGTH]
Names of the input variable names as found in the ODB.
This structure contains private variables for the device driver.
INT ps64_in_get_label(PS64_INFO *info, INT channel, char *name)
INT(* bd)(INT cmd,...)
bus driver entry function for reading
#define LAMVAC_INTERN_STR
Initializing string for the struct PS64_INTERN.
void ps64_stop_pump(PS64_INFO *info)
BOOL ps64_decode_data(PS64_INFO *info, const char *buffer)