- Adapted indenation to new agreed upon system

This commit is contained in:
koennecke
2009-02-13 09:01:24 +00:00
parent eb72d5c486
commit b3ac7dff3f
37 changed files with 11946 additions and 11757 deletions

View File

@ -81,16 +81,18 @@
**==================================================================== **====================================================================
** StrMatch - compare two strings. ** StrMatch - compare two strings.
*/ */
int StrMatch ( int StrMatch(
/* ======== /* ========
*/ char *str_a, */ char *str_a,
char *str_b, char *str_b, int min_len)
int min_len) { {
int i = 0; int i = 0;
while ((tolower(str_a[i]) == tolower(str_b[i])) && (str_a[i] != '\0')) i++; while ((tolower(str_a[i]) == tolower(str_b[i])) && (str_a[i] != '\0'))
i++;
return ((str_a[i] == '\0') && (i >= min_len));
}
return ((str_a[i] == '\0') && (i >= min_len));
}
/*-------------------------------------------------- End of StrMatch.C =======*/ /*-------------------------------------------------- End of StrMatch.C =======*/

View File

@ -12,40 +12,40 @@
#endif #endif
#define AsynSrv_MAX_LINK 8 #define AsynSrv_MAX_LINK 8
/* /*
** Structures needed by AsynSrv_Utility. ** Structures needed by AsynSrv_Utility.
*/ */
struct AsynSrv__info { struct AsynSrv__info {
int skt; /* The socket number of the connection */ int skt; /* The socket number of the connection */
char host[20]; /* The name of RS-232-C server */ char host[20]; /* The name of RS-232-C server */
int port; /* The TCP/IP port number of server */ int port; /* The TCP/IP port number of server */
int chan; /* The RS-232-C channel number on server */ int chan; /* The RS-232-C channel number on server */
int msg_id; int msg_id;
int protocol_code; /* Flag to identify the server's protocol level */ int protocol_code; /* Flag to identify the server's protocol level */
char protocol_id[4]; /* ASCII version of server's protocol level */ char protocol_id[4]; /* ASCII version of server's protocol level */
int cmnd_hdr_len; /* Header length for command strings */ int cmnd_hdr_len; /* Header length for command strings */
char cmnd_fmt[8]; /* "sprintf" format for cmnd header conversion */ char cmnd_fmt[8]; /* "sprintf" format for cmnd header conversion */
int rply_hdr_len; /* Header length for response strings */ int rply_hdr_len; /* Header length for response strings */
char rply_fmt[8]; /* "sscanf" format for rply header conversion */ char rply_fmt[8]; /* "sscanf" format for rply header conversion */
char chan_char[4]; /* ASCII encoded version of chan */ char chan_char[4]; /* ASCII encoded version of chan */
char tmo[4]; /* ASCII encoded time-out (deci-secs) */ char tmo[4]; /* ASCII encoded time-out (deci-secs) */
char eot[4]; /* Expected terminators */ char eot[4]; /* Expected terminators */
int max_replies; /* Binary version of #replies in response */ int max_replies; /* Binary version of #replies in response */
int n_replies; /* # of last response returned to caller */ int n_replies; /* # of last response returned to caller */
void (*idleHandler) (int, int); /* MZ. handler called when waiting .. void (*idleHandler) (int, int); /* MZ. handler called when waiting ..
** .. on a response */ ** .. on a response */
}; };
struct AsynSrv_HostPortSkt { struct AsynSrv_HostPortSkt {
char host[30]; char host[30];
int port; int port;
int skt; int skt;
int protocol_code; int protocol_code;
char protocol_id[4]; char protocol_id[4];
int cmnd_hdr_len; int cmnd_hdr_len;
int rply_hdr_len; int rply_hdr_len;
int usage_cnt; int usage_cnt;
int status; int status;
}; };
/*------------------------------------------------ End of AsynSrv_DEF.H --*/ /*------------------------------------------------ End of AsynSrv_DEF.H --*/
#endif /* _asynsrv_def_ */ #endif /* _asynsrv_def_ */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -69,28 +69,31 @@
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
** Global Variables ** Global Variables
*/ */
extern int C_gbl_status = 0; extern int C_gbl_status = 0;
extern struct dsc$descriptor_s C_name_desc = {0, extern struct dsc$descriptor_s C_name_desc = { 0,
DSC$K_DTYPE_T, DSC$K_DTYPE_T,
DSC$K_CLASS_S, DSC$K_CLASS_S,
0}; 0
};
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
** Old-style prototypes of routines which we are ** Old-style prototypes of routines which we are
** bridging to. ** bridging to.
*/ */
int log_arr_get (); int log_arr_get();
int log_int_get (); int log_int_get();
int log_flt_get (); int log_flt_get();
int log_str_get (); int log_str_get();
int str_edit (); int str_edit();
int tt_port_connect (); int tt_port_connect();
int tt_port_disconnect (); int tt_port_disconnect();
int tt_port_io (); int tt_port_io();
int tt_port_config (); int tt_port_config();
/* --------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------*/
int C_log_arr_get (char *name, int arr_size, int *value, int indx) { int C_log_arr_get(char *name, int arr_size, int *value, int indx)
{
/* ============= /* =============
** **
** This routine is useful for calling LOG_ARR_GET from a C program. ** This routine is useful for calling LOG_ARR_GET from a C program.
@ -110,15 +113,17 @@
** C_name_desc - set up as a string descriptor for name. It can ** C_name_desc - set up as a string descriptor for name. It can
** be used to generate an error message if return status == 0. ** be used to generate an error message if return status == 0.
*/ */
C_name_desc.dsc$w_length = strlen (name); C_name_desc.dsc$w_length = strlen(name);
C_name_desc.dsc$a_pointer = name; C_name_desc.dsc$a_pointer = name;
C_gbl_status = log_arr_get (&C_name_desc, &arr_size, value, &indx); C_gbl_status = log_arr_get(&C_name_desc, &arr_size, value, &indx);
return (C_gbl_status & 1);
}
return (C_gbl_status & 1);
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int C_log_int_get (char *name, long int *value, int indx) { int C_log_int_get(char *name, long int *value, int indx)
{
/* ============= /* =============
** **
** This routine is useful for calling LOG_INT_GET from a C program. ** This routine is useful for calling LOG_INT_GET from a C program.
@ -136,15 +141,17 @@
** C_name_desc - set up as a string descriptor for name. It can ** C_name_desc - set up as a string descriptor for name. It can
** be used to generate an error message if return status == 0. ** be used to generate an error message if return status == 0.
*/ */
C_name_desc.dsc$w_length = strlen (name); C_name_desc.dsc$w_length = strlen(name);
C_name_desc.dsc$a_pointer = name; C_name_desc.dsc$a_pointer = name;
C_gbl_status = log_int_get (&C_name_desc, value, &indx); C_gbl_status = log_int_get(&C_name_desc, value, &indx);
return (C_gbl_status & 1);
}
return (C_gbl_status & 1);
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int C_log_flt_get (char *name, float *value, int indx) { int C_log_flt_get(char *name, float *value, int indx)
{
/* ============= /* =============
** **
** This routine is useful for calling LOG_FLT_GET from a C program. ** This routine is useful for calling LOG_FLT_GET from a C program.
@ -162,15 +169,17 @@
** C_name_desc - set up as a string descriptor for name. It can ** C_name_desc - set up as a string descriptor for name. It can
** be used to generate an error message if return status == 0. ** be used to generate an error message if return status == 0.
*/ */
C_name_desc.dsc$w_length = strlen (name); C_name_desc.dsc$w_length = strlen(name);
C_name_desc.dsc$a_pointer = name; C_name_desc.dsc$a_pointer = name;
C_gbl_status = log_flt_get (&C_name_desc, value, &indx); C_gbl_status = log_flt_get(&C_name_desc, value, &indx);
return (C_gbl_status & 1);
}
return (C_gbl_status & 1);
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int C_log_str_get (char *name, char *value, int val_size, int indx) { int C_log_str_get(char *name, char *value, int val_size, int indx)
{
/* ============= /* =============
** **
** This routine is useful for calling LOG_STR_GET from a C program. ** This routine is useful for calling LOG_STR_GET from a C program.
@ -190,29 +199,32 @@
** C_name_desc - set up as a string descriptor for name. It can ** C_name_desc - set up as a string descriptor for name. It can
** be used to generate an error message if return status == 0. ** be used to generate an error message if return status == 0.
*/ */
struct dsc$descriptor_s my_val_desc = {0, struct dsc$descriptor_s my_val_desc = { 0,
DSC$K_DTYPE_T, DSC$K_DTYPE_T,
DSC$K_CLASS_S, DSC$K_CLASS_S,
0}; 0
};
C_name_desc.dsc$w_length = strlen (name); C_name_desc.dsc$w_length = strlen(name);
C_name_desc.dsc$a_pointer = name; C_name_desc.dsc$a_pointer = name;
my_val_desc.dsc$w_length = val_size - 1; my_val_desc.dsc$w_length = val_size - 1;
my_val_desc.dsc$a_pointer = value; my_val_desc.dsc$a_pointer = value;
C_gbl_status = log_str_get (&C_name_desc, &my_val_desc, &indx); C_gbl_status = log_str_get(&C_name_desc, &my_val_desc, &indx);
value[val_size - 1] = 0; /* Zero-terminate the string */ value[val_size - 1] = 0; /* Zero-terminate the string */
if (C_gbl_status & 1) { /* If success, strip trailing spaces */ if (C_gbl_status & 1) { /* If success, strip trailing spaces */
while ((strlen (value) > 0) && (value[strlen (value) - 1] == ' ')) { while ((strlen(value) > 0) && (value[strlen(value) - 1] == ' ')) {
value[strlen (value) - 1] = 0; value[strlen(value) - 1] = 0;
}
} }
return (C_gbl_status & 1);
} }
return (C_gbl_status & 1);
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int C_str_edit (char *out, char *in, char *ctrl, int *length) { int C_str_edit(char *out, char *in, char *ctrl, int *length)
{
/* ========== /* ==========
** **
** This routine is useful for calling STR_EDIT from a C program. ** This routine is useful for calling STR_EDIT from a C program.
@ -235,39 +247,44 @@
** Global variables: ** Global variables:
** C_gbl_status - set to the VAX/VMS return status of STR_EDIT. ** C_gbl_status - set to the VAX/VMS return status of STR_EDIT.
*/ */
struct dsc$descriptor_s out_desc = {0, struct dsc$descriptor_s out_desc = { 0,
DSC$K_DTYPE_T, DSC$K_DTYPE_T,
DSC$K_CLASS_S, DSC$K_CLASS_S,
0}; 0
struct dsc$descriptor_s in_desc = {0, };
DSC$K_DTYPE_T, struct dsc$descriptor_s in_desc = { 0,
DSC$K_CLASS_S, DSC$K_DTYPE_T,
0}; DSC$K_CLASS_S,
struct dsc$descriptor_s ctrl_desc = {0, 0
DSC$K_DTYPE_T, };
DSC$K_CLASS_S, struct dsc$descriptor_s ctrl_desc = { 0,
0}; DSC$K_DTYPE_T,
DSC$K_CLASS_S,
0
};
out_desc.dsc$w_length = *length - 1; out_desc.dsc$w_length = *length - 1;
out_desc.dsc$a_pointer = out; out_desc.dsc$a_pointer = out;
in_desc.dsc$w_length = strlen (in); in_desc.dsc$w_length = strlen(in);
in_desc.dsc$a_pointer = in; in_desc.dsc$a_pointer = in;
ctrl_desc.dsc$w_length = strlen (ctrl); ctrl_desc.dsc$w_length = strlen(ctrl);
ctrl_desc.dsc$a_pointer = ctrl; ctrl_desc.dsc$a_pointer = ctrl;
C_gbl_status = str_edit (&out_desc, &in_desc, &ctrl_desc, length); C_gbl_status = str_edit(&out_desc, &in_desc, &ctrl_desc, length);
if (*length >= 0) { /* zero-terminate the output string */ if (*length >= 0) { /* zero-terminate the output string */
out[*length] = '\0'; out[*length] = '\0';
}else { } else {
out[0] = '\0'; out[0] = '\0';
}
return (C_gbl_status & 1);
} }
return (C_gbl_status & 1);
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int C_tt_port_connect (int *hndl, int *chan, char *lognam, char *pwd) { int C_tt_port_connect(int *hndl, int *chan, char *lognam, char *pwd)
{
/* ================= /* =================
** **
** This routine is useful for calling TT_PORT_CONNECT from a C program. ** This routine is useful for calling TT_PORT_CONNECT from a C program.
@ -292,30 +309,33 @@
** Global variables: ** Global variables:
** C_gbl_status - set to the VAX/VMS return status of TT_PORT_CONNECT. ** C_gbl_status - set to the VAX/VMS return status of TT_PORT_CONNECT.
*/ */
struct dsc$descriptor_s lognam_desc = {0, struct dsc$descriptor_s lognam_desc = { 0,
DSC$K_DTYPE_T, DSC$K_DTYPE_T,
DSC$K_CLASS_S, DSC$K_CLASS_S,
0}; 0
struct dsc$descriptor_s pwd_desc = {0, };
DSC$K_DTYPE_T, struct dsc$descriptor_s pwd_desc = { 0,
DSC$K_CLASS_S, DSC$K_DTYPE_T,
0}; DSC$K_CLASS_S,
lognam_desc.dsc$w_length = strlen (lognam); 0
lognam_desc.dsc$a_pointer = lognam; };
lognam_desc.dsc$w_length = strlen(lognam);
lognam_desc.dsc$a_pointer = lognam;
if (pwd != NULL) { if (pwd != NULL) {
pwd_desc.dsc$w_length = strlen (pwd); pwd_desc.dsc$w_length = strlen(pwd);
pwd_desc.dsc$a_pointer = pwd; pwd_desc.dsc$a_pointer = pwd;
C_gbl_status = tt_port_connect ( C_gbl_status = tt_port_connect(hndl, chan, &lognam_desc, &pwd_desc);
hndl, chan, &lognam_desc, &pwd_desc); } else {
}else { C_gbl_status = tt_port_connect(hndl, chan, &lognam_desc, NULL);
C_gbl_status = tt_port_connect (hndl, chan, &lognam_desc, NULL);
}
return (C_gbl_status & 1);
} }
return (C_gbl_status & 1);
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int C_tt_port_disconnect (int *hndl) { int C_tt_port_disconnect(int *hndl)
{
/* ==================== /* ====================
** **
** This routine is useful for calling TT_PORT_DISCONNECT from a C program. ** This routine is useful for calling TT_PORT_DISCONNECT from a C program.
@ -331,20 +351,18 @@
** Global variables: ** Global variables:
** C_gbl_status - set to the VAX/VMS return status of TT_PORT_DISCONNECT. ** C_gbl_status - set to the VAX/VMS return status of TT_PORT_DISCONNECT.
*/ */
C_gbl_status = tt_port_disconnect (hndl); C_gbl_status = tt_port_disconnect(hndl);
return (C_gbl_status & 1);
}
return (C_gbl_status & 1);
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int C_tt_port_io ( int C_tt_port_io(
/* ============ /* ============
*/ int *hndl, */ int *hndl,
char *rqst, char *rqst, char *term, char *answ, int *answ_len, /* Attention -- Read/Write argument!! */
char *term, int flush, int tmo)
char *answ, {
int *answ_len, /* Attention -- Read/Write argument!! */
int flush,
int tmo) {
/* /*
** This routine is useful for calling TT_PORT_IO from a C program. ** This routine is useful for calling TT_PORT_IO from a C program.
** Refer to the DELTAT.OLB description of TT_PORT_IO to clarify any ** Refer to the DELTAT.OLB description of TT_PORT_IO to clarify any
@ -386,66 +404,73 @@
** Global variables: ** Global variables:
** C_gbl_status - set to the VAX/VMS return status of TT_PORT_IO. ** C_gbl_status - set to the VAX/VMS return status of TT_PORT_IO.
*/ */
struct dsc$descriptor_s rqst_desc = {0, struct dsc$descriptor_s rqst_desc = { 0,
DSC$K_DTYPE_T, DSC$K_DTYPE_T,
DSC$K_CLASS_S, DSC$K_CLASS_S,
0}; 0
struct dsc$descriptor_s term_desc = {0, };
DSC$K_DTYPE_T, struct dsc$descriptor_s term_desc = { 0,
DSC$K_CLASS_S, DSC$K_DTYPE_T,
0}; DSC$K_CLASS_S,
struct dsc$descriptor_s answ_desc = {0, 0
DSC$K_DTYPE_T, };
DSC$K_CLASS_S, struct dsc$descriptor_s answ_desc = { 0,
0}; DSC$K_DTYPE_T,
char *my_rqst = NULL; DSC$K_CLASS_S,
char *my_term = NULL; 0
char *my_answ = NULL; };
char *my_rqst = NULL;
char *my_term = NULL;
char *my_answ = NULL;
int my_answ_len = 0; int my_answ_len = 0;
int my_flush = 1; int my_flush = 1;
int my_tmo = 2; int my_tmo = 2;
my_tmo = tmo; my_tmo = tmo;
if (my_tmo < 0) my_tmo = 0; if (my_tmo < 0)
my_flush = flush; my_tmo = 0;
if (my_flush != 0) my_flush = 1; my_flush = flush;
if (answ != NULL) { if (my_flush != 0)
if (answ_len == 0) { my_flush = 1;
printf ("C_tt_port_io -- argument error.\n"); if (answ != NULL) {
printf (" %s\n", if (answ_len == 0) {
"answ_len must be present if answ is present."); printf("C_tt_port_io -- argument error.\n");
C_gbl_status = FALSE; printf(" %s\n",
return FALSE; "answ_len must be present if answ is present.");
} C_gbl_status = FALSE;
answ_desc.dsc$w_length = *answ_len - 1; return FALSE;
answ_desc.dsc$a_pointer = answ;
} }
if (term != NULL) { answ_desc.dsc$w_length = *answ_len - 1;
term_desc.dsc$w_length = strlen (term); answ_desc.dsc$a_pointer = answ;
term_desc.dsc$a_pointer = term;
}
if (rqst != NULL) {
rqst_desc.dsc$w_length = strlen (rqst);
rqst_desc.dsc$a_pointer = rqst;
}
C_gbl_status = tt_port_io (hndl, &rqst_desc, &term_desc,
&answ_desc, &my_answ_len, &my_flush, &my_tmo);
if (answ_desc.dsc$w_length > 0) { /* Process any input string */
if (answ_desc.dsc$w_length > my_answ_len) { /* Room for terminator? */
answ[my_answ_len+1] = answ[my_answ_len]; /* Yes, so move it. */
}
answ[my_answ_len] = '\0'; /* Put in null terminator */
*answ_len = my_answ_len; /* Return value to caller */
}
return (C_gbl_status & 1);
} }
if (term != NULL) {
term_desc.dsc$w_length = strlen(term);
term_desc.dsc$a_pointer = term;
}
if (rqst != NULL) {
rqst_desc.dsc$w_length = strlen(rqst);
rqst_desc.dsc$a_pointer = rqst;
}
C_gbl_status = tt_port_io(hndl, &rqst_desc, &term_desc,
&answ_desc, &my_answ_len, &my_flush, &my_tmo);
if (answ_desc.dsc$w_length > 0) { /* Process any input string */
if (answ_desc.dsc$w_length > my_answ_len) { /* Room for terminator? */
answ[my_answ_len + 1] = answ[my_answ_len]; /* Yes, so move it. */
}
answ[my_answ_len] = '\0'; /* Put in null terminator */
*answ_len = my_answ_len; /* Return value to caller */
}
return (C_gbl_status & 1);
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int C_tt_port_config ( int C_tt_port_config(
/* ================ /* ================
*/ int *hndl, */ int *hndl,
int mask) { int mask)
{
/* /*
** This routine is useful for calling TT_PORT_CONFIG from a C program. ** This routine is useful for calling TT_PORT_CONFIG from a C program.
** Refer to the DELTAT.OLB description of TT_PORT_CONFIG to clarify any ** Refer to the DELTAT.OLB description of TT_PORT_CONFIG to clarify any
@ -465,8 +490,9 @@
** Global variables: ** Global variables:
** C_gbl_status - set to the VAX/VMS return status of TT_PORT_CONFIG. ** C_gbl_status - set to the VAX/VMS return status of TT_PORT_CONFIG.
*/ */
C_gbl_status = tt_port_config (hndl, &mask); C_gbl_status = tt_port_config(hndl, &mask);
return (C_gbl_status & 1);
}
return (C_gbl_status & 1);
}
/*=========================================== End of C_INTERFACES.C ========*/ /*=========================================== End of C_INTERFACES.C ========*/

View File

@ -26,456 +26,416 @@
*/ */
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
int DILLU_Open(pDILLU *pData, char *pHost, int iPort, int iChannel, int DILLU_Open(pDILLU * pData, char *pHost, int iPort, int iChannel,
int iMode, char *pTransFile) int iMode, char *pTransFile)
{ {
int iRet; int iRet;
char pCommand[80]; char pCommand[80];
char pReply[132]; char pReply[132];
pDILLU self = NULL; pDILLU self = NULL;
pSTable pTable = NULL; pSTable pTable = NULL;
FILE *fd = NULL; FILE *fd = NULL;
/* check translation file first */
fd = fopen(pTransFile,"r");
if(!fd)
{
return DILLU__FILENOTFOUND;
}
fgets(pReply, 131,fd);
if(strstr(pReply,"DILLUTION") == NULL)
{
fclose(fd);
return DILLU__NODILLFILE;
}
pTable = CreateTable(fd);
fclose(fd);
if(!pTable)
{
return DILLU__ERRORTABLE;
}
/* allocate a new data structure */
self = (pDILLU)malloc(sizeof(DILLU));
if(self == NULL)
{
return DILLU__BADMALLOC;
}
*pData = self;
self->pTranstable = pTable;
iRet = SerialOpen(&self->pData, pHost, iPort, iChannel);
if(iRet != 1)
{
return iRet;
}
/* set an lengthy timeout for the configuration in order to /* check translation file first */
prevent problems. fd = fopen(pTransFile, "r");
*/ if (!fd) {
iRet = SerialConfig(&self->pData, 100); return DILLU__FILENOTFOUND;
if(iRet != 1) }
{ fgets(pReply, 131, fd);
return iRet; if (strstr(pReply, "DILLUTION") == NULL) {
} fclose(fd);
return DILLU__NODILLFILE;
self->iReadOnly = iMode; }
if(!self->iReadOnly)
{ pTable = CreateTable(fd);
/* switch to remote operation */ fclose(fd);
if (!pTable) {
return DILLU__ERRORTABLE;
}
/* allocate a new data structure */
self = (pDILLU) malloc(sizeof(DILLU));
if (self == NULL) {
return DILLU__BADMALLOC;
}
*pData = self;
self->pTranstable = pTable;
iRet = SerialOpen(&self->pData, pHost, iPort, iChannel);
if (iRet != 1) {
return iRet;
}
/* set an lengthy timeout for the configuration in order to
prevent problems.
*/
iRet = SerialConfig(&self->pData, 100);
if (iRet != 1) {
return iRet;
}
self->iReadOnly = iMode;
if (!self->iReadOnly) {
/* switch to remote operation */
/* iRet = SerialWriteRead(&self->pData,"C1\r\n",pReply,131); /* iRet = SerialWriteRead(&self->pData,"C1\r\n",pReply,131);
if(iRet != 1) if(iRet != 1)
{ {
return iRet; return iRet;
} }
*/ */
}
return 1;
}
/* --------------------------------------------------------------------------*/
void DILLU_Close(pDILLU *pData)
{
char pReply[132];
int iRet;
pDILLU self;
self = *pData;
if(!self)
return;
/* switch to local operation */
iRet = SerialWriteRead(&self->pData,"C0\r\n",pReply,131);
/* ignore errors on this one, the thing may be down */
/* close connection */
SerialClose(&self->pData);
/* free memory */
free(self);
*pData = NULL;
}
/* --------------------------------------------------------------------------*/
int DILLU_Config(pDILLU *pData, int iTmo)
{
int iRet;
char pReply[132];
char pCommand[10];
pDILLU self;
self = *pData;
/* first timeout */
if(iTmo > 0)
{
iRet = SerialConfig(&self->pData, iTmo);
if(iRet < 0)
{
return iRet;
}
}
return 1;
}
/* --------------------------------------------------------------------------*/
int DILLU_Send(pDILLU *pData, char *pCommand, char *pReply, int iLen)
{
pDILLU self;
self = *pData;
/* make sure, that there is a \r at the end of the command */
if(strchr(pCommand,(int)'\r') == NULL)
{
strcat(pCommand,"\r\n");
}
return SerialWriteRead(&self->pData,pCommand,pReply,iLen);
}
/* --------------------------------------------------------------------------*/
int DILLU_Read(pDILLU *pData, float *fVal)
{
char pCommand[10], pReply[132];
int iRet;
float fRead = -9999.;
float fOhm;
pDILLU self;
self = *pData;
/* send D command */
sprintf(pCommand,"D\r\n");
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
if(iRet != 1)
{
return iRet;
}
/* read ohms */
iRet = sscanf(pReply,"%f",&fOhm);
if(iRet != 1)
{
return DILLU__BADREAD;
}
if(fOhm > 9999890.)
{
return DILLU__SILLYANSWER;
}
/* convert to K */
iRet = InterpolateVal2(self->pTranstable,fOhm,&fRead);
*fVal = fRead;
return 1;
} }
return 1;
}
/* --------------------------------------------------------------------------*/
void DILLU_Close(pDILLU * pData)
{
char pReply[132];
int iRet;
pDILLU self;
self = *pData;
if (!self)
return;
/* switch to local operation */
iRet = SerialWriteRead(&self->pData, "C0\r\n", pReply, 131);
/* ignore errors on this one, the thing may be down */
/* close connection */
SerialClose(&self->pData);
/* free memory */
free(self);
*pData = NULL;
}
/* --------------------------------------------------------------------------*/
int DILLU_Config(pDILLU * pData, int iTmo)
{
int iRet;
char pReply[132];
char pCommand[10];
pDILLU self;
self = *pData;
/* first timeout */
if (iTmo > 0) {
iRet = SerialConfig(&self->pData, iTmo);
if (iRet < 0) {
return iRet;
}
}
return 1;
}
/* --------------------------------------------------------------------------*/
int DILLU_Send(pDILLU * pData, char *pCommand, char *pReply, int iLen)
{
pDILLU self;
self = *pData;
/* make sure, that there is a \r at the end of the command */
if (strchr(pCommand, (int) '\r') == NULL) {
strcat(pCommand, "\r\n");
}
return SerialWriteRead(&self->pData, pCommand, pReply, iLen);
}
/* --------------------------------------------------------------------------*/
int DILLU_Read(pDILLU * pData, float *fVal)
{
char pCommand[10], pReply[132];
int iRet;
float fRead = -9999.;
float fOhm;
pDILLU self;
self = *pData;
/* send D command */
sprintf(pCommand, "D\r\n");
iRet = SerialWriteRead(&self->pData, pCommand, pReply, 131);
if (iRet != 1) {
return iRet;
}
/* read ohms */
iRet = sscanf(pReply, "%f", &fOhm);
if (iRet != 1) {
return DILLU__BADREAD;
}
if (fOhm > 9999890.) {
return DILLU__SILLYANSWER;
}
/* convert to K */
iRet = InterpolateVal2(self->pTranstable, fOhm, &fRead);
*fVal = fRead;
return 1;
}
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
int DILLU_Set(pDILLU *pData, float fVal) int DILLU_Set(pDILLU * pData, float fVal)
{ {
char pCommand[50], pReply[132]; char pCommand[50], pReply[132];
int iRet, i,iRange, iExec; int iRet, i, iRange, iExec;
const float fPrecision = 0.0001; const float fPrecision = 0.0001;
float fSet, fRead, fOhms, tmax, fTemp; float fSet, fRead, fOhms, tmax, fTemp;
pDILLU self; pDILLU self;
self = *pData; self = *pData;
if(self->iReadOnly) if (self->iReadOnly) {
{ return DILLU__READONLY;
return DILLU__READONLY;
}
/* send D command to read current value*/
sprintf(pCommand,"D\r\n");
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
if(iRet != 1)
{
return iRet;
}
/* read ohms */
iRet = sscanf(pReply,"%f",&fRead);
if(iRet != 1)
{
return DILLU__BADREAD;
}
if(fRead > 9999890.)
{
return DILLU__SILLYANSWER;
}
/* convert new set value to ohms */
iRet = InterpolateVal1(self->pTranstable,fVal,&fOhms);
if(!iRet)
{
return DILLU__OUTOFRANGE;
}
/* set to remote operation */
#ifdef debug
printf("C1\n");
#endif
iRet = SerialWriteRead(&self->pData,"C1\r\n",pReply,131);
if(iRet != 1)
{
return iRet;
}
/* set heater power */
strcpy(pCommand,"G3\r");
if(fOhms > 1125)
{
strcpy(pCommand,"G2\r");
}
if(fOhms > 4000)
strcpy(pCommand,"G1\r");
#ifdef debug
printf("A9\n");
#endif
iRet = SerialWriteRead(&self->pData,"A9\r",pReply,131);
if(iRet != 1)
{
return iRet;
}
#ifdef debug
printf("%s\n",pCommand);
#endif
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
if(iRet != 1)
{
return iRet;
}
/* Integrator time constant */
strcpy(pCommand,"G2\r");
if(fOhms > 200)
strcpy(pCommand,"G1\r");
if(fOhms > 2000)
strcpy(pCommand,"G0\r");
strcpy(pCommand,"G7\r");
if(fOhms > 400.)
{
strcpy(pCommand,"G6\r");
}
#ifdef debug
printf("A4\n");
#endif
iRet = SerialWriteRead(&self->pData,"A4\r",pReply,131);
if(iRet != 1)
{
return iRet;
}
#ifdef debug
printf("%s\n",pCommand);
#endif
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
if(iRet != 1)
{
return iRet;
}
/* derivator time constant */
if(fOhms > 1000.)
{
strcpy(pCommand,"G1\r");
}
else
{
strcpy(pCommand,"G2\r");
}
#ifdef debug
printf("A5\n");
#endif
iRet = SerialWriteRead(&self->pData,"A5\r",pReply,131);
if(iRet != 1)
{
return iRet;
}
#ifdef debug
printf("%s\n",pCommand);
iRet = 1;
#endif
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
if(iRet != 1)
{
return iRet;
}
/* proportional gain */
if(fOhms > 500.)
{
strcpy(pCommand,"G3\r");
}
if(fOhms > 1000)
{
strcpy(pCommand,"G2\r");
}
if(fOhms > 2000)
{
strcpy(pCommand,"G1\r");
}
#ifdef debug
printf("A6\n");
#endif
iRet = SerialWriteRead(&self->pData,"A6\r",pReply,131);
if(iRet != 1)
{
return iRet;
}
#ifdef debug
printf("%s\n",pCommand);
#endif
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
if(iRet != 1)
{
return iRet;
}
/* range calculation a la Elsenhans */
iRange = 1;
fTemp = fOhms*10000.;
if( (fRead > 1.9) || (fOhms > 1.9) )
{
iRange = 2;
fTemp = fOhms*1000.;
}
if( (fRead > 19) || (fOhms > 19) )
{
iRange = 3;
fTemp = fOhms*100.;
}
if( (fRead > 190) || (fOhms > 190) )
{
iRange = 4;
fTemp = fOhms*10.;
}
if( (fRead > 750) || (fOhms > 750) )
{
iRange = 5;
fTemp = fOhms;
}
if( (fRead > 19000) || (fOhms > 19000) )
{
iRange = 6;
fTemp = fOhms/10.;
}
if( (fRead > 190000) || (fOhms > 190000) )
{
iRange = 7;
fTemp = fOhms/100.;
}
sprintf(pCommand,"R%1.1d\r",iRange);
#ifdef debug
printf("%s\n",pCommand);
#endif
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
if(iRet != 1)
{
return iRet;
}
/* finally set temperature */
#ifdef debug
printf("Set Val befor hex: %d\n",(int)fTemp);
#endif
sprintf(pCommand,"G%4.4X\r",(int)fTemp);
#ifdef debug
printf("A3\n");
#endif
iRet = SerialWriteRead(&self->pData,"A3\r",pReply,131);
if(iRet != 1)
{
return iRet;
}
#ifdef debug
printf("%s\n",pCommand);
#endif
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
if(iRet != 1)
{
return iRet;
}
/* unset remote operation, so that users may mess everything up
from the panel
*/
#ifdef debug
printf("C1\n");
#endif
iRet = SerialWriteRead(&self->pData,"C0\r\n",pReply,131);
if(iRet != 1)
{
return iRet;
}
return 1;
} }
/* send D command to read current value */
sprintf(pCommand, "D\r\n");
iRet = SerialWriteRead(&self->pData, pCommand, pReply, 131);
if (iRet != 1) {
return iRet;
}
/* read ohms */
iRet = sscanf(pReply, "%f", &fRead);
if (iRet != 1) {
return DILLU__BADREAD;
}
if (fRead > 9999890.) {
return DILLU__SILLYANSWER;
}
/* convert new set value to ohms */
iRet = InterpolateVal1(self->pTranstable, fVal, &fOhms);
if (!iRet) {
return DILLU__OUTOFRANGE;
}
/* set to remote operation */
#ifdef debug
printf("C1\n");
#endif
iRet = SerialWriteRead(&self->pData, "C1\r\n", pReply, 131);
if (iRet != 1) {
return iRet;
}
/* set heater power */
strcpy(pCommand, "G3\r");
if (fOhms > 1125) {
strcpy(pCommand, "G2\r");
}
if (fOhms > 4000)
strcpy(pCommand, "G1\r");
#ifdef debug
printf("A9\n");
#endif
iRet = SerialWriteRead(&self->pData, "A9\r", pReply, 131);
if (iRet != 1) {
return iRet;
}
#ifdef debug
printf("%s\n", pCommand);
#endif
iRet = SerialWriteRead(&self->pData, pCommand, pReply, 131);
if (iRet != 1) {
return iRet;
}
/* Integrator time constant */
strcpy(pCommand, "G2\r");
if (fOhms > 200)
strcpy(pCommand, "G1\r");
if (fOhms > 2000)
strcpy(pCommand, "G0\r");
strcpy(pCommand, "G7\r");
if (fOhms > 400.) {
strcpy(pCommand, "G6\r");
}
#ifdef debug
printf("A4\n");
#endif
iRet = SerialWriteRead(&self->pData, "A4\r", pReply, 131);
if (iRet != 1) {
return iRet;
}
#ifdef debug
printf("%s\n", pCommand);
#endif
iRet = SerialWriteRead(&self->pData, pCommand, pReply, 131);
if (iRet != 1) {
return iRet;
}
/* derivator time constant */
if (fOhms > 1000.) {
strcpy(pCommand, "G1\r");
} else {
strcpy(pCommand, "G2\r");
}
#ifdef debug
printf("A5\n");
#endif
iRet = SerialWriteRead(&self->pData, "A5\r", pReply, 131);
if (iRet != 1) {
return iRet;
}
#ifdef debug
printf("%s\n", pCommand);
iRet = 1;
#endif
iRet = SerialWriteRead(&self->pData, pCommand, pReply, 131);
if (iRet != 1) {
return iRet;
}
/* proportional gain */
if (fOhms > 500.) {
strcpy(pCommand, "G3\r");
}
if (fOhms > 1000) {
strcpy(pCommand, "G2\r");
}
if (fOhms > 2000) {
strcpy(pCommand, "G1\r");
}
#ifdef debug
printf("A6\n");
#endif
iRet = SerialWriteRead(&self->pData, "A6\r", pReply, 131);
if (iRet != 1) {
return iRet;
}
#ifdef debug
printf("%s\n", pCommand);
#endif
iRet = SerialWriteRead(&self->pData, pCommand, pReply, 131);
if (iRet != 1) {
return iRet;
}
/* range calculation a la Elsenhans */
iRange = 1;
fTemp = fOhms * 10000.;
if ((fRead > 1.9) || (fOhms > 1.9)) {
iRange = 2;
fTemp = fOhms * 1000.;
}
if ((fRead > 19) || (fOhms > 19)) {
iRange = 3;
fTemp = fOhms * 100.;
}
if ((fRead > 190) || (fOhms > 190)) {
iRange = 4;
fTemp = fOhms * 10.;
}
if ((fRead > 750) || (fOhms > 750)) {
iRange = 5;
fTemp = fOhms;
}
if ((fRead > 19000) || (fOhms > 19000)) {
iRange = 6;
fTemp = fOhms / 10.;
}
if ((fRead > 190000) || (fOhms > 190000)) {
iRange = 7;
fTemp = fOhms / 100.;
}
sprintf(pCommand, "R%1.1d\r", iRange);
#ifdef debug
printf("%s\n", pCommand);
#endif
iRet = SerialWriteRead(&self->pData, pCommand, pReply, 131);
if (iRet != 1) {
return iRet;
}
/* finally set temperature */
#ifdef debug
printf("Set Val befor hex: %d\n", (int) fTemp);
#endif
sprintf(pCommand, "G%4.4X\r", (int) fTemp);
#ifdef debug
printf("A3\n");
#endif
iRet = SerialWriteRead(&self->pData, "A3\r", pReply, 131);
if (iRet != 1) {
return iRet;
}
#ifdef debug
printf("%s\n", pCommand);
#endif
iRet = SerialWriteRead(&self->pData, pCommand, pReply, 131);
if (iRet != 1) {
return iRet;
}
/* unset remote operation, so that users may mess everything up
from the panel
*/
#ifdef debug
printf("C1\n");
#endif
iRet = SerialWriteRead(&self->pData, "C0\r\n", pReply, 131);
if (iRet != 1) {
return iRet;
}
return 1;
}
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
void DILLU_Error2Text(pDILLU *pData,int iCode, char *pError, int iLen) void DILLU_Error2Text(pDILLU * pData, int iCode, char *pError, int iLen)
{ {
char pBueffel[512]; char pBueffel[512];
pDILLU self; pDILLU self;
self = *pData; self = *pData;
switch(iCode) switch (iCode) {
{ case DILLU__FILENOTFOUND:
case DILLU__FILENOTFOUND: strncpy(pError, "Translation Table file not found", iLen);
strncpy(pError,"Translation Table file not found",iLen); return;
return; break;
break; case DILLU__NODILLFILE:
case DILLU__NODILLFILE: strncpy(pError, "Translation Table file is not DILLU", iLen);
strncpy(pError,"Translation Table file is not DILLU",iLen); return;
return; break;
break; case DILLU__ERRORTABLE:
case DILLU__ERRORTABLE: strncpy(pError, "Translation Table could not be created", iLen);
strncpy(pError,"Translation Table could not be created",iLen); return;
return; break;
break; case DILLU__BADREAD:
case DILLU__BADREAD: strncpy(pError, "Message corrupted", iLen);
strncpy(pError,"Message corrupted",iLen); return;
return; break;
break; case DILLU__SILLYANSWER:
case DILLU__SILLYANSWER: strncpy(pError, "Message corrupted", iLen);
strncpy(pError,"Message corrupted",iLen); return;
return; break;
break; case DILLU__BADMALLOC:
case DILLU__BADMALLOC: strncpy(pError, "Out of memory in Open_DILLU", iLen);
strncpy(pError,"Out of memory in Open_DILLU",iLen); return;
return; break;
break; case DILLU__READONLY:
case DILLU__READONLY: strncpy(pError, "DILLU is read-only", iLen);
strncpy(pError,"DILLU is read-only",iLen); return;
return; break;
break; case DILLU__OUTOFRANGE:
case DILLU__OUTOFRANGE: strncpy(pError, "Requested value is out of range", iLen);
strncpy(pError,"Requested value is out of range",iLen); return;
return; break;
break; default:
default: SerialError(iCode, pError, iLen);
SerialError(iCode,pError,iLen); break;
break;
}
} }
}

View File

@ -30,17 +30,17 @@
#define DILLU__BADMALLOC -717 #define DILLU__BADMALLOC -717
#define DILLU__NODILLUFOUND -711 #define DILLU__NODILLUFOUND -711
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
typedef struct __DILLU { typedef struct __DILLU {
void *pData; void *pData;
pSTable pTranstable; pSTable pTranstable;
int iReadOnly; int iReadOnly;
} DILLU; } DILLU;
typedef struct __DILLU *pDILLU; typedef struct __DILLU *pDILLU;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
int DILLU_Open(pDILLU *pData,char *pHost, int iPort, int iChannel, int DILLU_Open(pDILLU * pData, char *pHost, int iPort, int iChannel,
int iMode, char *pTransFile); int iMode, char *pTransFile);
/***** creates an DILLU datastructure and opens a connection to the ITCL4 /***** creates an DILLU datastructure and opens a connection to the ITCL4
controller. Input Parameters are: controller. Input Parameters are:
the hostname the hostname
@ -53,16 +53,16 @@
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
void DILLU_Close(pDILLU *pData); void DILLU_Close(pDILLU * pData);
/****** close a connection to an DILLU controller and frees its /****** close a connection to an DILLU controller and frees its
data structure. The only parameter is a pointer to the data data structure. The only parameter is a pointer to the data
structure for this controller. This pointer will be invalid after structure for this controller. This pointer will be invalid after
this call. this call.
*/ */
int DILLU_Config(pDILLU *pData, int iTmo); int DILLU_Config(pDILLU * pData, int iTmo);
/***** configure some aspects of a DILLU temperature controller. /***** configure some aspects of a DILLU temperature controller.
The parameter are: The parameter are:
- a pointer to the data structure for the controller as - a pointer to the data structure for the controller as
@ -71,8 +71,8 @@
The function returns 1 on success, a negative error code on The function returns 1 on success, a negative error code on
failure. failure.
*/ */
int DILLU_Send(pDILLU *pData, char *pCommand, char *pReply, int iLen); int DILLU_Send(pDILLU * pData, char *pCommand, char *pReply, int iLen);
/******* send a the command in pCommand to the DILLU controller. /******* send a the command in pCommand to the DILLU controller.
A possible reply is returned in the buffer pReply. A possible reply is returned in the buffer pReply.
Maximum iLen characters are copied to pReply. Maximum iLen characters are copied to pReply.
@ -82,8 +82,8 @@
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
int DILLU_Read(pDILLU *pData, float *fVal); int DILLU_Read(pDILLU * pData, float *fVal);
/****** /******
Reads the current temperature at the controller Reads the current temperature at the controller
@ -91,7 +91,7 @@
failure. failure.
*/ */
int DILLU_Set(pDILLU *pData, float fVal); int DILLU_Set(pDILLU * pData, float fVal);
/****** sets a new preset temperature in the DILL temperature /****** sets a new preset temperature in the DILL temperature
controller. Parameters are: controller. Parameters are:
- a pointer to a DILLU data structure as returned by Open_DILLU. - a pointer to a DILLU data structure as returned by Open_DILLU.
@ -101,8 +101,6 @@
failure. failure.
*/ */
void DILLU_Error2Text(pDILLU *pData, int iCode, char *pError, int iLen); void DILLU_Error2Text(pDILLU * pData, int iCode, char *pError, int iLen);
#endif #endif

View File

@ -17,57 +17,58 @@
#define MAX_MOT 12 #define MAX_MOT 12
enum EL734_Requests {FULL__STATUS, enum EL734_Requests { FULL__STATUS,
SHORT__STATUS}; SHORT__STATUS
};
/* /*
** Structure to which the EL734_Open handle points. ** Structure to which the EL734_Open handle points.
*/ */
struct EL734info { struct EL734info {
struct AsynSrv__info asyn_info; /* Contains skt, host, port & chan */ struct AsynSrv__info asyn_info; /* Contains skt, host, port & chan */
int motor; int motor;
int ored_msr, fp_cntr, fr_cntr; int ored_msr, fp_cntr, fr_cntr;
struct RS__MsgStruct to_host; struct RS__MsgStruct to_host;
struct RS__RespStruct from_host; struct RS__RespStruct from_host;
}; };
/* /*
** Structure holding everything that is known about a VME Motor Controller. ** Structure holding everything that is known about a VME Motor Controller.
** It is also the structure of replies from the Server. ** It is also the structure of replies from the Server.
*/ */
struct Motor_State { struct Motor_State {
int motor; /* Motor number */ int motor; /* Motor number */
int exists; /* True if Motor exists */ int exists; /* True if Motor exists */
int msr; /* MSR - Motor Status Register */ int msr; /* MSR - Motor Status Register */
int ored_msr; /* Cumulated MSR */ int ored_msr; /* Cumulated MSR */
int fp_cntr; /* Counter for *FP reports */ int fp_cntr; /* Counter for *FP reports */
int fr_cntr; /* Counter for *FR reports */ int fr_cntr; /* Counter for *FR reports */
int ss; /* SS - Status Flags Register */ int ss; /* SS - Status Flags Register */
char pos_real[16]; /* U - Position as read (degrees) */ char pos_real[16]; /* U - Position as read (degrees) */
char name[16]; /* MN */ char name[16]; /* MN */
int dec_pt; /* A - # of decimal places */ int dec_pt; /* A - # of decimal places */
int enc_factor[2]; /* FD - Encoder scaling factors (numer/denom) */ int enc_factor[2]; /* FD - Encoder scaling factors (numer/denom) */
int mot_factor[2]; /* FM - Motor scaling factors (numer/denom) */ int mot_factor[2]; /* FM - Motor scaling factors (numer/denom) */
char inertia_tol[16];/* D - Inertia tol'nce (sec) (Schleppfehler) */ char inertia_tol[16]; /* D - Inertia tol'nce (sec) (Schleppfehler) */
int ramp; /* E - Start/stop ramp (kHz/sec) */ int ramp; /* E - Start/stop ramp (kHz/sec) */
int loop_mode; /* F - Open loop/Closed loop (0/1) */ int loop_mode; /* F - Open loop/Closed loop (0/1) */
int slow_hz; /* G - Start/stop frequency (Mot-S/sec) */ int slow_hz; /* G - Start/stop frequency (Mot-S/sec) */
char lims[2][16]; /* H - Lower/Upper limits */ char lims[2][16]; /* H - Lower/Upper limits */
int fast_hz; /* J - Top speed (Mot-S/sec) */ int fast_hz; /* J - Top speed (Mot-S/sec) */
int ref_mode; /* K - Reference mode */ int ref_mode; /* K - Reference mode */
int backlash; /* L - Backlash par (Mot-S) (Spielausgleich) */ int backlash; /* L - Backlash par (Mot-S) (Spielausgleich) */
int pos_tol; /* M - Position tolerance (Enc-Steps) */ int pos_tol; /* M - Position tolerance (Enc-Steps) */
char ref_param[16]; /* Q - Parameter for "Goto Reference" */ char ref_param[16]; /* Q - Parameter for "Goto Reference" */
int is_sided; /* T - One-sided operation flag (0 = no) */ int is_sided; /* T - One-sided operation flag (0 = no) */
char null_pt[16]; /* V - Null point */ char null_pt[16]; /* V - Null point */
int ac_par; /* W - Air-cushion dependency */ int ac_par; /* W - Air-cushion dependency */
int enc_circ; /* Z - circumference of encoder (Enc-Steps) */ int enc_circ; /* Z - circumference of encoder (Enc-Steps) */
int stat_pos; /* SP - # of positionings */ int stat_pos; /* SP - # of positionings */
int stat_pos_flt; /* ST - # of positioning faults (recovered) */ int stat_pos_flt; /* ST - # of positioning faults (recovered) */
int stat_pos_fail; /* SR - # of positioning fails (abandoned) */ int stat_pos_fail; /* SR - # of positioning fails (abandoned) */
int stat_cush_fail; /* SA - # of air-cushion fails */ int stat_cush_fail; /* SA - # of air-cushion fails */
char set_real[16]; /* P - Position as set (degrees) */ char set_real[16]; /* P - Position as set (degrees) */
int ac_state; /* AC - Air-cushion state (0 = down) */ int ac_state; /* AC - Air-cushion state (0 = down) */
int out; /* SO - State of Output Signal */ int out; /* SO - State of Output Signal */
int in; /* RI - State of Input Signal */ int in; /* RI - State of Input Signal */
}; };
/*------------------------------------------------ End of EL734_DEF.H --*/ /*------------------------------------------------ End of EL734_DEF.H --*/
#endif /* _el734_def_ */ #endif /* _el734_def_ */

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@
#define EL734__BAD_HOST ASYNSRV__BAD_HOST #define EL734__BAD_HOST ASYNSRV__BAD_HOST
#define EL734__BAD_BIND ASYNSRV__BAD_BIND #define EL734__BAD_BIND ASYNSRV__BAD_BIND
#define EL734__BAD_SENDLEN ASYNSRV__BAD_SEND_LEN #define EL734__BAD_SENDLEN ASYNSRV__BAD_SEND_LEN
#define EL734__BAD_SEND ASYNSRV__BAD_SEND #define EL734__BAD_SEND ASYNSRV__BAD_SEND
#define EL734__BAD_SEND_PIPE ASYNSRV__BAD_SEND_PIPE #define EL734__BAD_SEND_PIPE ASYNSRV__BAD_SEND_PIPE
#define EL734__BAD_SEND_UNKN ASYNSRV__BAD_SEND_UNKN #define EL734__BAD_SEND_UNKN ASYNSRV__BAD_SEND_UNKN
@ -26,4 +26,4 @@
#define EL734__BAD_RECV1_NET ASYNSRV__BAD_RECV1_NET #define EL734__BAD_RECV1_NET ASYNSRV__BAD_RECV1_NET
#define EL734__BAD_CONNECT ASYNSRV__BAD_CONNECT #define EL734__BAD_CONNECT ASYNSRV__BAD_CONNECT
#define EL734__BAD_ID EL734__BAD_DEV #define EL734__BAD_ID EL734__BAD_DEV
#endif /* el734fix */ #endif /* el734fix */

File diff suppressed because it is too large Load Diff

View File

@ -18,50 +18,52 @@
#include <el737_errcodes.h> #include <el737_errcodes.h>
#endif #endif
enum EL737_States { enum EL737_States {
UNKNOWN = -2, UNKNOWN = -2,
OFFLINE = -1, OFFLINE = -1,
MS = 0x0, MS = 0x0,
PTS = 0x1, PTS = 0x1,
PCS = 0x2, PCS = 0x2,
LRTS = 0x5, LRTS = 0x5,
LRCS = 0x6, LRCS = 0x6,
PTSP = 0x9, PTSP = 0x9,
PCSP = 0xA, PCSP = 0xA,
LRTSP = 0xD, LRTSP = 0xD,
LRCSP = 0xE}; LRCSP = 0xE
};
enum EL737_Consts { enum EL737_Consts {
VMECNT__PRESET_COUNT, VMECNT__PRESET_COUNT,
VMECNT__PRESET_TIME, VMECNT__PRESET_TIME,
VMECNT__FULL, VMECNT__FULL,
VMECNT__SHORT, VMECNT__SHORT,
VMECNT__INCR}; VMECNT__INCR
};
/* /*
** Structure to which the EL737_Open handle points. ** Structure to which the EL737_Open handle points.
*/ */
struct EL737info { struct EL737info {
struct AsynSrv__info asyn_info; /* Contains skt, host, port & chan */ struct AsynSrv__info asyn_info; /* Contains skt, host, port & chan */
int c5, c6, c7, c8; int c5, c6, c7, c8;
struct RS__MsgStruct to_host; struct RS__MsgStruct to_host;
struct RS__RespStruct from_host; struct RS__RespStruct from_host;
}; };
/* /*
** Structure holding everything that is known about a VME Neutron Counter. ** Structure holding everything that is known about a VME Neutron Counter.
*/ */
struct Counter_State { struct Counter_State {
int state; /* RS */ int state; /* RS */
char timer[16]; /* RT \ RA */ char timer[16]; /* RT \ RA */
int cntrs[8]; /* RC 1 ... RC 8 / */ int cntrs[8]; /* RC 1 ... RC 8 / */
char rates[8][16]; /* RR 1 ... RR 8 */ char rates[8][16]; /* RR 1 ... RR 8 */
char thresh_integ_time[8][16]; /* DI 1 ... DI 8 */ char thresh_integ_time[8][16]; /* DI 1 ... DI 8 */
char rate_integ_time[16]; /* DT */ char rate_integ_time[16]; /* DT */
int analog_indx; /* DA */ int analog_indx; /* DA */
int thresh_indx; /* DR */ int thresh_indx; /* DR */
char threshes[8][16]; /* DL 1 ... DL 8 */ char threshes[8][16]; /* DL 1 ... DL 8 */
int mon_preset; /* MP */ int mon_preset; /* MP */
char timer_preset[16]; /* TP */ char timer_preset[16]; /* TP */
}; };
/*----------------------------------------------------- End of EL737_DEF.H --*/ /*----------------------------------------------------- End of EL737_DEF.H --*/
#endif /* _el737_def_ */ #endif /* _el737_def_ */

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@
#define EL737__BAD_HOST ASYNSRV__BAD_HOST #define EL737__BAD_HOST ASYNSRV__BAD_HOST
#define EL737__BAD_BIND ASYNSRV__BAD_BIND #define EL737__BAD_BIND ASYNSRV__BAD_BIND
#define EL737__BAD_SENDLEN ASYNSRV__BAD_SEND_LEN #define EL737__BAD_SENDLEN ASYNSRV__BAD_SEND_LEN
#define EL737__BAD_SEND ASYNSRV__BAD_SEND #define EL737__BAD_SEND ASYNSRV__BAD_SEND
#define EL737__BAD_SEND_PIPE ASYNSRV__BAD_SEND_PIPE #define EL737__BAD_SEND_PIPE ASYNSRV__BAD_SEND_PIPE
#define EL737__BAD_SEND_UNKN ASYNSRV__BAD_SEND_UNKN #define EL737__BAD_SEND_UNKN ASYNSRV__BAD_SEND_UNKN
@ -25,9 +25,9 @@
#define EL737__BAD_RECV1_PIPE ASYNSRV__BAD_RECV1_PIPE #define EL737__BAD_RECV1_PIPE ASYNSRV__BAD_RECV1_PIPE
#define EL737__BAD_RECV1_NET ASYNSRV__BAD_RECV1_NET #define EL737__BAD_RECV1_NET ASYNSRV__BAD_RECV1_NET
#define EL737__BAD_CONNECT ASYNSRV__BAD_CONNECT #define EL737__BAD_CONNECT ASYNSRV__BAD_CONNECT
#define EL737__BAD_ID -99995 #define EL737__BAD_ID -99995
#define EL737__BAD_SNTX -99991 #define EL737__BAD_SNTX -99991
#define EL737__BAD_REPLY -99992 #define EL737__BAD_REPLY -99992
#define EL737__BAD_ADR -99993 #define EL737__BAD_ADR -99993
#define EL737__BAD_RNG -99994 #define EL737__BAD_RNG -99994
#endif /* el734fix */ #endif /* el734fix */

View File

@ -23,13 +23,13 @@
#define True 1 #define True 1
#define False 0 #define False 0
typedef struct typedef struct {
{ void *pData; /* EL737 open struct */
void *pData; /* EL737 open struct */ } EL737st;
} EL737st;
EXTERN int EL737Action(ClientData pDat, Tcl_Interp *i, int a, char *argv[]); EXTERN int EL737Action(ClientData pDat, Tcl_Interp * i, int a,
static void EL737Error2Text(char *pBuffer, int errcode); char *argv[]);
static void EL737Error2Text(char *pBuffer, int errcode);
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
Tcl has a high niceness level. It deletes a command properly when Tcl has a high niceness level. It deletes a command properly when
@ -38,79 +38,73 @@
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
EXTERN void EL737Murder(ClientData pData) EXTERN void EL737Murder(ClientData pData)
{ {
EL737st *pTa = (EL737st *)pData; EL737st *pTa = (EL737st *) pData;
EL737_Close(&(pTa->pData)); EL737_Close(&(pTa->pData));
free(pData); free(pData);
} }
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
CterEL737 is the main entry point for this stuff. It connects to a counter CterEL737 is the main entry point for this stuff. It connects to a counter
and, on success, creates a new command with the name of the counter. and, on success, creates a new command with the name of the counter.
Syntax: Syntax:
EL737 name host port channel EL737 name host port channel
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
int CterEL737(ClientData clientData, Tcl_Interp *interp, int CterEL737(ClientData clientData, Tcl_Interp * interp,
int argc, char *argv[]) int argc, char *argv[])
{ {
int iRet; int iRet;
EL737st *pEL737 = NULL; EL737st *pEL737 = NULL;
int iPort, iChannel, iMotor; int iPort, iChannel, iMotor;
char *pErr = NULL; char *pErr = NULL;
char pBueffel[80]; char pBueffel[80];
/* check arguments */
if(argc < 5)
{
Tcl_AppendResult(interp,
" Insufficient arguments: CterEL737 name host port channel"
, (char *) NULL);
return TCL_ERROR;
}
/* convert arguments */
iRet = Tcl_GetInt(interp,argv[3],&iPort);
if(iRet == TCL_ERROR)
{
Tcl_AppendResult(interp,"Need integer value for port",
(char *)NULL);
return iRet;
}
iRet = Tcl_GetInt(interp,argv[4],&iChannel);
if(iRet == TCL_ERROR)
{
Tcl_AppendResult(interp,"Need integer value for channel",
(char *)NULL);
return iRet;
}
/* make a new pointer, initialise EL737st */ /* check arguments */
pEL737 = (EL737st *)malloc(sizeof(EL737st)); if (argc < 5) {
if(pEL737 ==NULL) Tcl_AppendResult(interp,
{ " Insufficient arguments: CterEL737 name host port channel",
Tcl_AppendResult(interp,"No memory in EL734",NULL); (char *) NULL);
return TCL_ERROR; return TCL_ERROR;
} }
/* open the rotten Counter, finally */ /* convert arguments */
iRet = EL737_Open(&(pEL737->pData), argv[2],iPort,iChannel); iRet = Tcl_GetInt(interp, argv[3], &iPort);
if(iRet) /* success */ if (iRet == TCL_ERROR) {
{ Tcl_AppendResult(interp, "Need integer value for port", (char *) NULL);
/* handle TCL, create new command: the Counter */ return iRet;
Tcl_CreateCommand(interp,strdup(argv[1]),EL737Action, }
(ClientData)pEL737,EL737Murder);
Tcl_AppendResult(interp,strdup(argv[1]),(char *)NULL); iRet = Tcl_GetInt(interp, argv[4], &iChannel);
return TCL_OK; if (iRet == TCL_ERROR) {
} Tcl_AppendResult(interp, "Need integer value for channel",
else (char *) NULL);
{ return iRet;
EL737_ErrInfo(&pErr,&iPort,&iChannel, &iMotor); }
EL737Error2Text(pBueffel,iPort);
Tcl_AppendResult(interp,pBueffel,(char *) NULL); /* make a new pointer, initialise EL737st */
free(pEL737); pEL737 = (EL737st *) malloc(sizeof(EL737st));
return TCL_ERROR; if (pEL737 == NULL) {
} Tcl_AppendResult(interp, "No memory in EL734", NULL);
return TCL_ERROR;
}
/* open the rotten Counter, finally */
iRet = EL737_Open(&(pEL737->pData), argv[2], iPort, iChannel);
if (iRet) { /* success */
/* handle TCL, create new command: the Counter */
Tcl_CreateCommand(interp, strdup(argv[1]), EL737Action,
(ClientData) pEL737, EL737Murder);
Tcl_AppendResult(interp, strdup(argv[1]), (char *) NULL);
return TCL_OK;
} else {
EL737_ErrInfo(&pErr, &iPort, &iChannel, &iMotor);
EL737Error2Text(pBueffel, iPort);
Tcl_AppendResult(interp, pBueffel, (char *) NULL);
free(pEL737);
return TCL_ERROR;
}
} }
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
EL737 Action is the routine where commands send to the conter will EL737 Action is the routine where commands send to the conter will
@ -130,271 +124,241 @@ int CterEL737(ClientData clientData, Tcl_Interp *interp,
{ counts monitor time } { counts monitor time }
counter Stop forces counter to stop counter Stop forces counter to stop
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
EXTERN int EL737Action(ClientData clientData, Tcl_Interp *interp, EXTERN int EL737Action(ClientData clientData, Tcl_Interp * interp,
int argc, char *argv[]) int argc, char *argv[])
{ {
EL737st *pData = (EL737st *)clientData; EL737st *pData = (EL737st *) clientData;
char pBueffel[132]; char pBueffel[132];
char pNumBuf[20]; char pNumBuf[20];
char *pErr = NULL; char *pErr = NULL;
int iC1, iC2, iC3, iC4, iRS, iRet; int iC1, iC2, iC3, iC4, iRS, iRet;
float fTime; float fTime;
int iFlag = 0; int iFlag = 0;
int iMode; int iMode;
double dVal; double dVal;
/* obviously we need at least a keyword! */ /* obviously we need at least a keyword! */
if(argc < 2) if (argc < 2) {
{ Tcl_AppendResult(interp, "No keyword given", NULL);
Tcl_AppendResult(interp,"No keyword given",NULL); return TCL_ERROR;
return TCL_ERROR; }
}
/* get values out */
if(strcmp(argv[1],"value") == 0)
{
iRet = EL737_GetStatus(&(pData->pData),&iC1, &iC2, &iC3,
&iC4,&fTime,&iRS);
if(!iRet)
{
EL737_ErrInfo(&pErr,&iC1,&iC2, &iC3);
EL737Error2Text(pBueffel,iC1);
Tcl_AppendResult(interp,pBueffel,(char *) NULL);
return TCL_ERROR;
}
sprintf(pNumBuf,"%d",iC2);
Tcl_AppendElement(interp,pNumBuf);
sprintf(pNumBuf,"%d",iC1);
Tcl_AppendElement(interp,pNumBuf);
sprintf(pNumBuf,"%f",fTime);
Tcl_AppendElement(interp,pNumBuf);
return TCL_OK;
}
/* isDone ? */ /* get values out */
if(strcmp(argv[1],"isDone") == 0) if (strcmp(argv[1], "value") == 0) {
{ iRet = EL737_GetStatus(&(pData->pData), &iC1, &iC2, &iC3,
iRet = EL737_GetStatus(&(pData->pData),&iC1, &iC2, &iC3, &iC4, &fTime, &iRS);
&iC4,&fTime,&iRS); if (!iRet) {
if(!iRet) EL737_ErrInfo(&pErr, &iC1, &iC2, &iC3);
{ EL737Error2Text(pBueffel, iC1);
EL737_ErrInfo(&pErr,&iC1,&iC2, &iC3); Tcl_AppendResult(interp, pBueffel, (char *) NULL);
EL737Error2Text(pBueffel,iC1); return TCL_ERROR;
Tcl_AppendResult(interp,pBueffel,(char *) NULL); }
return TCL_ERROR; sprintf(pNumBuf, "%d", iC2);
} Tcl_AppendElement(interp, pNumBuf);
if(iRS == 0) /* done is true */ sprintf(pNumBuf, "%d", iC1);
{ Tcl_AppendElement(interp, pNumBuf);
sprintf(pNumBuf,"%d",True); sprintf(pNumBuf, "%f", fTime);
} Tcl_AppendElement(interp, pNumBuf);
else return TCL_OK;
{ }
sprintf(pNumBuf,"%d",False);
}
Tcl_AppendResult(interp,pNumBuf,(char *) NULL);
return TCL_OK;
}
/* actual counting neutrons in two different modes */
if(strcmp(argv[1],"wait") == 0)
{
iFlag = 2;
}
if(strcmp(argv[1],"start") == 0)
{
iFlag = 1;
}
if(iFlag > 0) /* we need to count */
{
if(argc < 4) /* not enough arguments */
{
Tcl_AppendResult(interp,"Usage: ",argv[0],argv[1],
" timer or monitor val",NULL);
return TCL_ERROR;
}
/* timer or monitor preset ? */
if(strcmp(argv[2],"timer") == 0)
{
iMode = 1;
}
else if (strcmp(argv[2],"monitor") == 0)
{
iMode = 2;
}
else
{
Tcl_AppendResult(interp,"Usage: ",argv[0],argv[1],
" timer or monitor val",NULL);
return TCL_ERROR;
}
/* get the preset value */
iRet = Tcl_GetDouble(interp,argv[3],&dVal);
if(iRet == TCL_ERROR)
{
return TCL_ERROR;
}
/* actual start collecting neutrons */
if(iMode == 1)
{
iRet = EL737_StartTime(&(pData->pData),(float)dVal,
&iRS);
}
else
{
iRet = EL737_StartCnt(&(pData->pData),(int)dVal,
&iRS);
}
if(!iRet)
{
EL737_ErrInfo(&pErr,&iC1,&iC2, &iC3);
EL737Error2Text(pBueffel,iC1);
Tcl_AppendResult(interp,pBueffel,(char *) NULL);
return TCL_ERROR;
}
} /* end of count startup code */
/* if apropriate: wait */
if(iFlag == 2)
{
iRet = EL737_WaitIdle(&(pData->pData),&iC1, &iC2, &iC3,
&iC4,&fTime);
if(!iRet)
{
EL737_ErrInfo(&pErr,&iC1,&iC2, &iC3);
EL737Error2Text(pBueffel,iC1);
Tcl_AppendResult(interp,pBueffel,(char *) NULL);
return TCL_ERROR;
}
return TCL_OK;
}
else if(iFlag == 1)
{
return TCL_OK;
}
/* the stop command */
if(strcmp(argv[1],"stop") == 0)
{
iRet = EL737_Stop(&(pData->pData),&iC1, &iC2, &iC3,
&iC4,&fTime,&iRS);
if(!iRet)
{
EL737_ErrInfo(&pErr,&iC1,&iC2, &iC3);
EL737Error2Text(pBueffel,iC1);
Tcl_AppendResult(interp,pBueffel,(char *) NULL);
return TCL_ERROR;
}
return TCL_OK;
}
Tcl_AppendResult(interp," obscure command: ",argv[1], /* isDone ? */
" not understood by EL737 counter", NULL); if (strcmp(argv[1], "isDone") == 0) {
return TCL_ERROR; iRet = EL737_GetStatus(&(pData->pData), &iC1, &iC2, &iC3,
&iC4, &fTime, &iRS);
if (!iRet) {
EL737_ErrInfo(&pErr, &iC1, &iC2, &iC3);
EL737Error2Text(pBueffel, iC1);
Tcl_AppendResult(interp, pBueffel, (char *) NULL);
return TCL_ERROR;
}
if (iRS == 0) { /* done is true */
sprintf(pNumBuf, "%d", True);
} else {
sprintf(pNumBuf, "%d", False);
}
Tcl_AppendResult(interp, pNumBuf, (char *) NULL);
return TCL_OK;
}
/* actual counting neutrons in two different modes */
if (strcmp(argv[1], "wait") == 0) {
iFlag = 2;
}
if (strcmp(argv[1], "start") == 0) {
iFlag = 1;
}
if (iFlag > 0) { /* we need to count */
if (argc < 4) { /* not enough arguments */
Tcl_AppendResult(interp, "Usage: ", argv[0], argv[1],
" timer or monitor val", NULL);
return TCL_ERROR;
}
/* timer or monitor preset ? */
if (strcmp(argv[2], "timer") == 0) {
iMode = 1;
} else if (strcmp(argv[2], "monitor") == 0) {
iMode = 2;
} else {
Tcl_AppendResult(interp, "Usage: ", argv[0], argv[1],
" timer or monitor val", NULL);
return TCL_ERROR;
}
/* get the preset value */
iRet = Tcl_GetDouble(interp, argv[3], &dVal);
if (iRet == TCL_ERROR) {
return TCL_ERROR;
}
/* actual start collecting neutrons */
if (iMode == 1) {
iRet = EL737_StartTime(&(pData->pData), (float) dVal, &iRS);
} else {
iRet = EL737_StartCnt(&(pData->pData), (int) dVal, &iRS);
}
if (!iRet) {
EL737_ErrInfo(&pErr, &iC1, &iC2, &iC3);
EL737Error2Text(pBueffel, iC1);
Tcl_AppendResult(interp, pBueffel, (char *) NULL);
return TCL_ERROR;
}
}
/* end of count startup code */
/* if apropriate: wait */
if (iFlag == 2) {
iRet = EL737_WaitIdle(&(pData->pData), &iC1, &iC2, &iC3, &iC4, &fTime);
if (!iRet) {
EL737_ErrInfo(&pErr, &iC1, &iC2, &iC3);
EL737Error2Text(pBueffel, iC1);
Tcl_AppendResult(interp, pBueffel, (char *) NULL);
return TCL_ERROR;
}
return TCL_OK;
} else if (iFlag == 1) {
return TCL_OK;
}
/* the stop command */
if (strcmp(argv[1], "stop") == 0) {
iRet = EL737_Stop(&(pData->pData), &iC1, &iC2, &iC3,
&iC4, &fTime, &iRS);
if (!iRet) {
EL737_ErrInfo(&pErr, &iC1, &iC2, &iC3);
EL737Error2Text(pBueffel, iC1);
Tcl_AppendResult(interp, pBueffel, (char *) NULL);
return TCL_ERROR;
}
return TCL_OK;
}
Tcl_AppendResult(interp, " obscure command: ", argv[1],
" not understood by EL737 counter", NULL);
return TCL_ERROR;
} }
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
EL737Error2Text converts between an EL734 error code to text EL737Error2Text converts between an EL734 error code to text
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
void EL737Error2Text(char *pBuffer, int iErr) void EL737Error2Text(char *pBuffer, int iErr)
{ {
switch(iErr) switch (iErr) {
{ case -28:
case -28: strcpy(pBuffer, "EL737__BAD_ADR");
strcpy(pBuffer,"EL737__BAD_ADR"); break;
break; case -8:
case -8: strcpy(pBuffer, "EL737__BAD_OVFL");
strcpy(pBuffer,"EL737__BAD_OVFL"); break;
break; case -30:
case -30: strcpy(pBuffer, "EL737__BAD_BSY");
strcpy(pBuffer,"EL737__BAD_BSY"); break;
break; case -3:
case -3: strcpy(pBuffer, "EL737__BAD_SNTX");
strcpy(pBuffer,"EL737__BAD_SNTX"); break;
break; case -9:
case -9: strcpy(pBuffer, "EL737__BAD_CONNECT");
strcpy(pBuffer,"EL737__BAD_CONNECT"); break;
break; case -23:
case -23: strcpy(pBuffer, "EL737__BAD_FLUSH");
strcpy(pBuffer,"EL737__BAD_FLUSH"); break;
break; case -6:
case -6: strcpy(pBuffer, "EL734__BAD_DEV");
strcpy(pBuffer,"EL734__BAD_DEV"); break;
break; case -10:
case -10: strcpy(pBuffer, "EL737__BAD_ID");
strcpy(pBuffer,"EL737__BAD_ID"); break;
break; case -5:
case -5: strcpy(pBuffer, "EL737__BAD_ILLG");
strcpy(pBuffer,"EL737__BAD_ILLG"); break;
break; case -2:
case -2: strcpy(pBuffer, "EL737__BAD_LOC");
strcpy(pBuffer,"EL737__BAD_LOC"); break;
break; case -11:
case -11: strcpy(pBuffer, "EL737__BAD_MALLOC");
strcpy(pBuffer,"EL737__BAD_MALLOC"); break;
break; case -21:
case -21: strcpy(pBuffer, "EL737__BAD_NOT_BCD");
strcpy(pBuffer,"EL737__BAD_NOT_BCD"); break;
break; case -4:
case -4: strcpy(pBuffer, "EL737__BAD_OFL");
strcpy(pBuffer,"EL737__BAD_OFL"); break;
break; case -29:
case -29: strcpy(pBuffer, "EL737__BAD_PAR");
strcpy(pBuffer,"EL737__BAD_PAR"); break;
break;
case -17:
case -17: strcpy(pBuffer, "EL737__BAD_RECV");
strcpy(pBuffer,"EL737__BAD_RECV"); break;
break; case -19:
case -19: strcpy(pBuffer, "EL737__BAD_RECV_NET");
strcpy(pBuffer,"EL737__BAD_RECV_NET"); break;
break; case -18:
case -18: strcpy(pBuffer, "EL737__BAD_RECV_PIPE");
strcpy(pBuffer,"EL737__BAD_RECV_PIPE"); break;
break; case -20:
case -20: strcpy(pBuffer, "EL737__BAD_RECV_UNKN");
strcpy(pBuffer,"EL737__BAD_RECV_UNKN"); break;
break; case -22:
case -22: strcpy(pBuffer, "EL737__BAD_RECVLEN");
strcpy(pBuffer,"EL737__BAD_RECVLEN"); break;
break; case -24:
case -24: strcpy(pBuffer, "EL737__BAD_RECV1");
strcpy(pBuffer,"EL737__BAD_RECV1"); break;
break; case -26:
case -26: strcpy(pBuffer, "EL737__BAD_RECV1_NET");
strcpy(pBuffer,"EL737__BAD_RECV1_NET"); break;
break; case -25:
case -25: strcpy(pBuffer, "EL737__BAD_RECV1_PIPE");
strcpy(pBuffer,"EL737__BAD_RECV1_PIPE"); break;
break; case -27:
case -27: strcpy(pBuffer, "EL737__BAD_RNG");
strcpy(pBuffer,"EL737__BAD_RNG"); break;
break; case -13:
case -13: strcpy(pBuffer, "EL737__BAD_SEND");
strcpy(pBuffer,"EL737__BAD_SEND"); break;
break; case -14:
case -14: strcpy(pBuffer, "EL737__BAD_SEND_PIPE");
strcpy(pBuffer,"EL737__BAD_SEND_PIPE"); break;
break; case -15:
case -15: strcpy(pBuffer, "EL737__BAD_SEND_NET");
strcpy(pBuffer,"EL737__BAD_SEND_NET"); break;
break; case -16:
case -16: strcpy(pBuffer, "EL737__BAD_SEND_UNKN");
strcpy(pBuffer,"EL737__BAD_SEND_UNKN"); break;
break; case -12:
case -12: strcpy(pBuffer, "EL737__BAD_SENDLEN");
strcpy(pBuffer,"EL737__BAD_SENDLEN"); break;
break; case -7:
case -7: strcpy(pBuffer, "EL737__BAD_SOCKET");
strcpy(pBuffer,"EL737__BAD_SOCKET"); break;
break; case -1:
case -1: strcpy(pBuffer, "EL737__BAD_TMO");
strcpy(pBuffer,"EL737__BAD_TMO"); break;
break; default:
default: strcpy(pBuffer, "Unknown EL737 error");
strcpy(pBuffer,"Unknown EL737 error"); break;
break; }
} }
}

View File

@ -21,11 +21,11 @@
/* /*
** Structure to which the EL755_Open handle points. ** Structure to which the EL755_Open handle points.
*/ */
struct EL755info { struct EL755info {
struct AsynSrv__info asyn_info; /* Contains skt, host, port & chan */ struct AsynSrv__info asyn_info; /* Contains skt, host, port & chan */
int index; int index;
struct RS__MsgStruct to_host; struct RS__MsgStruct to_host;
struct RS__RespStruct from_host; struct RS__RespStruct from_host;
}; };
/*------------------------------------------------ End of EL755_DEF.H --*/ /*------------------------------------------------ End of EL755_DEF.H --*/
#endif /* _el755_def_ */ #endif /* _el755_def_ */

View File

@ -16,11 +16,13 @@
** routine if he wishes to log these errors in ** routine if he wishes to log these errors in
** some other way. ** some other way.
*/ */
void EL755_ErrorLog ( void EL755_ErrorLog(
/* ============== /* ==============
*/ char *routine_name, */ char *routine_name,
char *text) { char *text)
{
fprintf(stderr, "%s: %s\n", routine_name, text);
}
fprintf (stderr, "%s: %s\n", routine_name, text);
}
/*-------------------------------------------- End of EL755_ErrorLog.C =======*/ /*-------------------------------------------- End of EL755_ErrorLog.C =======*/

File diff suppressed because it is too large Load Diff

View File

@ -3,103 +3,102 @@
EL734Error2Text converts between an EL734 error code to text EL734Error2Text converts between an EL734 error code to text
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
void EL734Error2Text(char *pBuffer, int iErr) void EL734Error2Text(char *pBuffer, int iErr)
{ {
switch(iErr) switch (iErr) {
{ case -28:
case -28: strcpy(pBuffer, "EL734__BAD_ADR");
strcpy(pBuffer,"EL734__BAD_ADR"); break;
break; case -8:
case -8: strcpy(pBuffer, "EL734__BAD_BIND");
strcpy(pBuffer,"EL734__BAD_BIND"); break;
break; case -30:
case -30: strcpy(pBuffer, "EL734__BAD_BSY");
strcpy(pBuffer,"EL734__BAD_BSY"); break;
break; case -3:
case -3: strcpy(pBuffer, "EL734__BAD_CMD");
strcpy(pBuffer,"EL734__BAD_CMD"); break;
break; case -9:
case -9: strcpy(pBuffer, "EL734__BAD_CONNECT");
strcpy(pBuffer,"EL734__BAD_CONNECT"); break;
break; case -23:
case -23: strcpy(pBuffer, "EL734__BAD_FLUSH");
strcpy(pBuffer,"EL734__BAD_FLUSH"); break;
break; case -6:
case -6: strcpy(pBuffer, "EL734__BAD_HOST");
strcpy(pBuffer,"EL734__BAD_HOST"); break;
break; case -10:
case -10: strcpy(pBuffer, "EL734__BAD_ID");
strcpy(pBuffer,"EL734__BAD_ID"); break;
break; case -5:
case -5: strcpy(pBuffer, "EL734__BAD_ILLG");
strcpy(pBuffer,"EL734__BAD_ILLG"); break;
break; case -2:
case -2: strcpy(pBuffer, "EL734__BAD_LOC");
strcpy(pBuffer,"EL734__BAD_LOC"); break;
break; case -11:
case -11: strcpy(pBuffer, "EL734__BAD_MALLOC");
strcpy(pBuffer,"EL734__BAD_MALLOC"); break;
break; case -21:
case -21: strcpy(pBuffer, "EL734__BAD_NOT_BCD");
strcpy(pBuffer,"EL734__BAD_NOT_BCD"); break;
break; case -4:
case -4: strcpy(pBuffer, "EL734__BAD_OFL");
strcpy(pBuffer,"EL734__BAD_OFL"); break;
break; case -29:
case -29: strcpy(pBuffer, "EL734__BAD_PAR");
strcpy(pBuffer,"EL734__BAD_PAR"); break;
break;
case -17:
case -17: strcpy(pBuffer, "EL734__BAD_RECV");
strcpy(pBuffer,"EL734__BAD_RECV"); break;
break; case -19:
case -19: strcpy(pBuffer, "EL734__BAD_RECV_NET");
strcpy(pBuffer,"EL734__BAD_RECV_NET"); break;
break; case -18:
case -18: strcpy(pBuffer, "EL734__BAD_RECV_PIPE");
strcpy(pBuffer,"EL734__BAD_RECV_PIPE"); break;
break; case -20:
case -20: strcpy(pBuffer, "EL734__BAD_RECV_UNKN");
strcpy(pBuffer,"EL734__BAD_RECV_UNKN"); break;
break; case -22:
case -22: strcpy(pBuffer, "EL734__BAD_RECVLEN");
strcpy(pBuffer,"EL734__BAD_RECVLEN"); break;
break; case -24:
case -24: strcpy(pBuffer, "EL734__BAD_RECV1");
strcpy(pBuffer,"EL734__BAD_RECV1"); break;
break; case -26:
case -26: strcpy(pBuffer, "EL734__BAD_RECV1_NET");
strcpy(pBuffer,"EL734__BAD_RECV1_NET"); break;
break; case -25:
case -25: strcpy(pBuffer, "EL734__BAD_RECV1_PIPE");
strcpy(pBuffer,"EL734__BAD_RECV1_PIPE"); break;
break; case -27:
case -27: strcpy(pBuffer, "EL734__BAD_RNG");
strcpy(pBuffer,"EL734__BAD_RNG"); break;
break; case -13:
case -13: strcpy(pBuffer, "EL734__BAD_SEND");
strcpy(pBuffer,"EL734__BAD_SEND"); break;
break; case -14:
case -14: strcpy(pBuffer, "EL734__BAD_SEND_PIPE");
strcpy(pBuffer,"EL734__BAD_SEND_PIPE"); break;
break; case -15:
case -15: strcpy(pBuffer, "EL734__BAD_SEND_NET");
strcpy(pBuffer,"EL734__BAD_SEND_NET"); break;
break; case -16:
case -16: strcpy(pBuffer, "EL734__BAD_SEND_UNKN");
strcpy(pBuffer,"EL734__BAD_SEND_UNKN"); break;
break; case -12:
case -12: strcpy(pBuffer, "EL734__BAD_SENDLEN");
strcpy(pBuffer,"EL734__BAD_SENDLEN"); break;
break; case -7:
case -7: strcpy(pBuffer, "EL734__BAD_SOCKET");
strcpy(pBuffer,"EL734__BAD_SOCKET"); break;
break; case -1:
case -1: strcpy(pBuffer, "EL734__BAD_TMO");
strcpy(pBuffer,"EL734__BAD_TMO"); break;
break; default:
default: strcpy(pBuffer, "Unknown EL734 error");
strcpy(pBuffer,"Unknown EL734 error"); break;
break; }
} }
}

View File

@ -89,21 +89,23 @@
/* /*
** FailInet: Some network failure has occurred. ** FailInet: Some network failure has occurred.
*/ */
void FailInet (char *text) { void FailInet(char *text)
{
/* ======== /* ========
** Output the given text and exit the process. ** Output the given text and exit the process.
*/ */
int my_errno, my_vaxc_errno; int my_errno, my_vaxc_errno;
GetErrno (&my_errno, &my_vaxc_errno); GetErrno(&my_errno, &my_vaxc_errno);
printf ("### Internet Error ###\n"); printf("### Internet Error ###\n");
#ifdef __VMS #ifdef __VMS
printf (" ### errno = %d.\n", my_errno); printf(" ### errno = %d.\n", my_errno);
printf (" ### vaxc$errno = %d.\n", my_vaxc_errno); printf(" ### vaxc$errno = %d.\n", my_vaxc_errno);
#else #else
printf (" ### errno = %d.\n", my_errno); printf(" ### errno = %d.\n", my_errno);
#endif #endif
perror (text); perror(text);
exit (EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/*------------------------------------------------- End of FAILINET.C =======*/ /*------------------------------------------------- End of FAILINET.C =======*/

View File

@ -82,15 +82,17 @@
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
** GetErrno: Make copies of errno and vaxc$errno for debug. ** GetErrno: Make copies of errno and vaxc$errno for debug.
*/ */
void GetErrno (int *his_errno, int *his_vaxc_errno) { void GetErrno(int *his_errno, int *his_vaxc_errno)
{
/* ======== /* ========
*/ */
*his_errno = errno; /* Make copy of errno */ *his_errno = errno; /* Make copy of errno */
#ifdef __VMS #ifdef __VMS
*his_vaxc_errno = vaxc$errno; /* Make copy of vaxc$errno */ *his_vaxc_errno = vaxc$errno; /* Make copy of vaxc$errno */
#else #else
*his_vaxc_errno = 1; *his_vaxc_errno = 1;
#endif #endif
return; return;
} }
/*------------------------------------------------- End of GETERRNO.C =======*/ /*------------------------------------------------- End of GETERRNO.C =======*/

View File

@ -45,377 +45,340 @@
#include "itc4util.h" #include "itc4util.h"
/* -------------------------------------------------------------------------*/ /* -------------------------------------------------------------------------*/
int ITC4_Open(pITC4 *pData, char *pHost, int iPort, int iChannel, int iMode) int ITC4_Open(pITC4 * pData, char *pHost, int iPort, int iChannel,
{ int iMode)
int iRet; {
char pCommand[80]; int iRet;
char pReply[132]; char pCommand[80];
pITC4 self = NULL; char pReply[132];
pITC4 self = NULL;
self = (pITC4)malloc(sizeof(ITC4));
if(self == NULL)
{
return ITC4__BADMALLOC;
}
*pData = self;
self->iControl = 1;
self->iRead = 1;
self->iReadOnly = iMode;
self->fDiv = 10.;
self->fMult = 10.;
iRet = SerialOpen(&self->pData, pHost, iPort, iChannel);
if(iRet != 1)
{
return iRet;
}
/* set an lengthy timeout for the configuration in order to self = (pITC4) malloc(sizeof(ITC4));
prevent problems. if (self == NULL) {
*/ return ITC4__BADMALLOC;
iRet = SerialConfig(&self->pData, 100);
if(iRet != 1)
{
return iRet;
}
/* an identification test has been here, but I had to removed as not all
ITC4 controllers at SINQ answer the V command. Some versions of the
controller do not recognize it. Sighhhhhhh. I had to put it in again
in order to check for ITC-503, but I handle the thing by default as
an ITC4 if I do not get a proper response.
*/
self->i503 = 0;
iRet = SerialWriteRead(&self->pData,"V\r\n",pReply,131);
if(iRet != 1)
{
return iRet;
}
if(strstr(pReply,"ITC503") != NULL)
{
self->i503 = 1;
}
if(!self->iReadOnly)
{
/* switch to remote and locked operation */
iRet = SerialWriteRead(&self->pData,"C3\r\n",pReply,131);
if(iRet != 1)
{
return iRet;
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* set the control sensor, for this we need to switch A0 first,
the do it and switch back
*/
iRet = SerialWriteRead(&self->pData,"A0\r\n",pReply,131);
if(iRet != 1)
{
return iRet;
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
sprintf(pCommand,"H%1.1d\r\n",self->iControl);
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
if(iRet != 1)
{
return iRet;
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* controls to automatic */
iRet = SerialWriteRead(&self->pData,"A3\r\n",pReply,131);
if(iRet != 1)
{
return iRet;
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* reset timeout */
iRet = SerialConfig(&self->pData, 10);
if(iRet != 1)
{
return iRet;
}
}
return 1;
}
/*--------------------------------------------------------------------------*/
void ITC4_Close(pITC4 *pData)
{
char pReply[132];
int iRet;
pITC4 self;
self = *pData;
/* switch to local operation */
iRet = SerialWriteRead(&self->pData,"C0\r\n",pReply,131);
/* ignore errors on this one, the thing may be down */
/* close connection */
SerialClose(&self->pData);
/* free memory */
free(self);
*pData = NULL;
}
/*--------------------------------------------------------------------------*/
int ITC4_Config(pITC4 *pData, int iTmo, int iRead, int iControl,
float fDiv,float fMult)
{
int iRet;
char pReply[132];
char pCommand[10];
pITC4 self;
self = *pData;
/* first timeout */
if(iTmo > 0)
{
iRet = SerialConfig(&self->pData, iTmo);
if(iRet != 1)
{
return iRet;
}
}
/* Read Sensor */
if( (iRead > 0) && (iRead < 5) && (self->iRead != iRead) )
{
self->iRead = iRead;
}
/* Control Sensor */
if( (iControl > 0) && (iControl < 5) )
{
/* set the control sensor, for this we need to switch A0 first,
the do it and switch back
*/
iRet = SerialWriteRead(&self->pData,"A0\r\n",pReply,131);
if(iRet != 1)
{
return iRet;
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* set sensor */
sprintf(pCommand,"H%1.1d\r\n",iControl);
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
if(iRet != 1)
{
return iRet;
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* controls to automatic */
iRet = SerialWriteRead(&self->pData,"A3\r\n",pReply,131);
if(iRet != 1)
{
return iRet;
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
}
self->fDiv = fDiv;
self->fMult = fMult;
return 1;
}
/* --------------------------------------------------------------------------*/
int ITC4_Send(pITC4 *pData, char *pCommand, char *pReply, int iLen)
{
pITC4 self;
self = *pData;
/* make sure, that there is a \r at the end of the command */
if(strchr(pCommand,(int)'\r') == NULL)
{
strcat(pCommand,"\r");
}
return SerialWriteRead(&self->pData,pCommand,pReply,iLen);
}
/*--------------------------------------------------------------------------*/
int ITC4_Read(pITC4 *pData, float *fVal)
{
char pCommand[10], pReply[132];
int iRet;
float fRead = -9999999.;
pITC4 self;
self = *pData;
/* format and send R command */
sprintf(pCommand,"R%1.1d\r\n",self->iRead);
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
if(iRet != 1)
{
return iRet;
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* analyse reply */
if(pReply[0] != 'R')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
iRet = sscanf(&pReply[1],"%f",&fRead);
if(iRet != 1)
{
return ITC4__BADREAD;
}
if(self->i503)
{
*fVal = fRead;
}
else
{
*fVal = fRead/self->fDiv;
}
return 1;
} }
/* -------------------------------------------------------------------------*/ *pData = self;
int ITC4_Set(pITC4 *pData, float fVal) self->iControl = 1;
{ self->iRead = 1;
char pCommand[10], pReply[132]; self->iReadOnly = iMode;
int iRet, i, iRead; self->fDiv = 10.;
const float fPrecision = 0.0001; self->fMult = 10.;
float fSet, fDelta, fRead, fDum;
pITC4 self;
int iSet;
self = *pData; iRet = SerialOpen(&self->pData, pHost, iPort, iChannel);
if (iRet != 1) {
return iRet;
}
if(self->iReadOnly) /* set an lengthy timeout for the configuration in order to
{ prevent problems.
return ITC4__READONLY; */
} iRet = SerialConfig(&self->pData, 100);
if (iRet != 1) {
/* format command */ return iRet;
if(self->i503) }
{
sprintf(pCommand,"T%-7.3f\r\n",fVal); /* an identification test has been here, but I had to removed as not all
} ITC4 controllers at SINQ answer the V command. Some versions of the
else controller do not recognize it. Sighhhhhhh. I had to put it in again
{ in order to check for ITC-503, but I handle the thing by default as
fSet = fVal; an ITC4 if I do not get a proper response.
iSet = (int)(fSet*self->fMult); */
sprintf(pCommand,"T%5.5d\r\n",iSet); self->i503 = 0;
} iRet = SerialWriteRead(&self->pData, "V\r\n", pReply, 131);
if (iRet != 1) {
/* try three times: send, read, test, if OK return, else return iRet;
resend. This must be done because the ITC4 tends to loose }
characters if (strstr(pReply, "ITC503") != NULL) {
self->i503 = 1;
}
if (!self->iReadOnly) {
/* switch to remote and locked operation */
iRet = SerialWriteRead(&self->pData, "C3\r\n", pReply, 131);
if (iRet != 1) {
return iRet;
}
if (pReply[0] == '?') {
strcpy(self->pAns, pReply);
return ITC4__BADCOM;
}
/* set the control sensor, for this we need to switch A0 first,
the do it and switch back
*/ */
for(i = 0; i < 3; i++) iRet = SerialWriteRead(&self->pData, "A0\r\n", pReply, 131);
{ if (iRet != 1) {
/* send command */ return iRet;
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131); }
if(iRet != 1) if (pReply[0] == '?') {
{ strcpy(self->pAns, pReply);
return iRet; return ITC4__BADCOM;
} }
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* read the set value again */
iRead = self->iRead;
self->iRead = 0; /* make a R0 */
fDum = self->fDiv;
self->fDiv = self->fMult;
iRet = ITC4_Read(pData,&fRead);
self->iRead = iRead;
self->fDiv = fDum;
if(iRet != 1)
{
return iRet;
}
/* check the value read back */
if(self->i503)
{
fDelta = fRead - fVal;
}
else
{
fDelta = fRead - fSet;
}
if(fDelta < 0)
fDelta = -fDelta;
if(fDelta < fPrecision)
{
/* Success, go home */
return 1;
}
}
return ITC4__BADSET;
}
/* -------------------------------------------------------------------------*/
void ITC4_ErrorTxt(pITC4 *pData,int iCode, char *pError, int iLen)
{
char pBueffel[512];
pITC4 self;
self = *pData; sprintf(pCommand, "H%1.1d\r\n", self->iControl);
iRet = SerialWriteRead(&self->pData, pCommand, pReply, 131);
switch(iCode) if (iRet != 1) {
{ return iRet;
case ITC4__BADCOM: }
sprintf(pBueffel,"ITC4: Invalid command or offline, got %s", if (pReply[0] == '?') {
self->pAns); strcpy(self->pAns, pReply);
strncpy(pError,pBueffel,iLen); return ITC4__BADCOM;
break; }
case ITC4__BADPAR:
strncpy(pError,"ITC4: Invalid parameter specified",iLen); /* controls to automatic */
break; iRet = SerialWriteRead(&self->pData, "A3\r\n", pReply, 131);
case ITC4__BADMALLOC: if (iRet != 1) {
strncpy(pError,"ITC4: Error allocating memory in ITC4",iLen); return iRet;
break; }
case ITC4__BADREAD: if (pReply[0] == '?') {
strncpy(pError,"ITC4: Badly formatted answer",iLen); strcpy(self->pAns, pReply);
break; return ITC4__BADCOM;
case ITC4__BADSET: }
strncpy(pError,"ITC4: Failed three times to write new set value to ITC4",iLen); /* reset timeout */
break; iRet = SerialConfig(&self->pData, 10);
default: if (iRet != 1) {
SerialError(iCode, pError,iLen); return iRet;
break; }
}
} }
return 1;
}
/*--------------------------------------------------------------------------*/
void ITC4_Close(pITC4 * pData)
{
char pReply[132];
int iRet;
pITC4 self;
self = *pData;
/* switch to local operation */
iRet = SerialWriteRead(&self->pData, "C0\r\n", pReply, 131);
/* ignore errors on this one, the thing may be down */
/* close connection */
SerialClose(&self->pData);
/* free memory */
free(self);
*pData = NULL;
}
/*--------------------------------------------------------------------------*/
int ITC4_Config(pITC4 * pData, int iTmo, int iRead, int iControl,
float fDiv, float fMult)
{
int iRet;
char pReply[132];
char pCommand[10];
pITC4 self;
self = *pData;
/* first timeout */
if (iTmo > 0) {
iRet = SerialConfig(&self->pData, iTmo);
if (iRet != 1) {
return iRet;
}
}
/* Read Sensor */
if ((iRead > 0) && (iRead < 5) && (self->iRead != iRead)) {
self->iRead = iRead;
}
/* Control Sensor */
if ((iControl > 0) && (iControl < 5)) {
/* set the control sensor, for this we need to switch A0 first,
the do it and switch back
*/
iRet = SerialWriteRead(&self->pData, "A0\r\n", pReply, 131);
if (iRet != 1) {
return iRet;
}
if (pReply[0] == '?') {
strcpy(self->pAns, pReply);
return ITC4__BADCOM;
}
/* set sensor */
sprintf(pCommand, "H%1.1d\r\n", iControl);
iRet = SerialWriteRead(&self->pData, pCommand, pReply, 131);
if (iRet != 1) {
return iRet;
}
if (pReply[0] == '?') {
strcpy(self->pAns, pReply);
return ITC4__BADCOM;
}
/* controls to automatic */
iRet = SerialWriteRead(&self->pData, "A3\r\n", pReply, 131);
if (iRet != 1) {
return iRet;
}
if (pReply[0] == '?') {
strcpy(self->pAns, pReply);
return ITC4__BADCOM;
}
}
self->fDiv = fDiv;
self->fMult = fMult;
return 1;
}
/* --------------------------------------------------------------------------*/
int ITC4_Send(pITC4 * pData, char *pCommand, char *pReply, int iLen)
{
pITC4 self;
self = *pData;
/* make sure, that there is a \r at the end of the command */
if (strchr(pCommand, (int) '\r') == NULL) {
strcat(pCommand, "\r");
}
return SerialWriteRead(&self->pData, pCommand, pReply, iLen);
}
/*--------------------------------------------------------------------------*/
int ITC4_Read(pITC4 * pData, float *fVal)
{
char pCommand[10], pReply[132];
int iRet;
float fRead = -9999999.;
pITC4 self;
self = *pData;
/* format and send R command */
sprintf(pCommand, "R%1.1d\r\n", self->iRead);
iRet = SerialWriteRead(&self->pData, pCommand, pReply, 131);
if (iRet != 1) {
return iRet;
}
if (pReply[0] == '?') {
strcpy(self->pAns, pReply);
return ITC4__BADCOM;
}
/* analyse reply */
if (pReply[0] != 'R') {
strcpy(self->pAns, pReply);
return ITC4__BADCOM;
}
iRet = sscanf(&pReply[1], "%f", &fRead);
if (iRet != 1) {
return ITC4__BADREAD;
}
if (self->i503) {
*fVal = fRead;
} else {
*fVal = fRead / self->fDiv;
}
return 1;
}
/* -------------------------------------------------------------------------*/
int ITC4_Set(pITC4 * pData, float fVal)
{
char pCommand[10], pReply[132];
int iRet, i, iRead;
const float fPrecision = 0.0001;
float fSet, fDelta, fRead, fDum;
pITC4 self;
int iSet;
self = *pData;
if (self->iReadOnly) {
return ITC4__READONLY;
}
/* format command */
if (self->i503) {
sprintf(pCommand, "T%-7.3f\r\n", fVal);
} else {
fSet = fVal;
iSet = (int) (fSet * self->fMult);
sprintf(pCommand, "T%5.5d\r\n", iSet);
}
/* try three times: send, read, test, if OK return, else
resend. This must be done because the ITC4 tends to loose
characters
*/
for (i = 0; i < 3; i++) {
/* send command */
iRet = SerialWriteRead(&self->pData, pCommand, pReply, 131);
if (iRet != 1) {
return iRet;
}
if (pReply[0] == '?') {
strcpy(self->pAns, pReply);
return ITC4__BADCOM;
}
/* read the set value again */
iRead = self->iRead;
self->iRead = 0; /* make a R0 */
fDum = self->fDiv;
self->fDiv = self->fMult;
iRet = ITC4_Read(pData, &fRead);
self->iRead = iRead;
self->fDiv = fDum;
if (iRet != 1) {
return iRet;
}
/* check the value read back */
if (self->i503) {
fDelta = fRead - fVal;
} else {
fDelta = fRead - fSet;
}
if (fDelta < 0)
fDelta = -fDelta;
if (fDelta < fPrecision) {
/* Success, go home */
return 1;
}
}
return ITC4__BADSET;
}
/* -------------------------------------------------------------------------*/
void ITC4_ErrorTxt(pITC4 * pData, int iCode, char *pError, int iLen)
{
char pBueffel[512];
pITC4 self;
self = *pData;
switch (iCode) {
case ITC4__BADCOM:
sprintf(pBueffel, "ITC4: Invalid command or offline, got %s",
self->pAns);
strncpy(pError, pBueffel, iLen);
break;
case ITC4__BADPAR:
strncpy(pError, "ITC4: Invalid parameter specified", iLen);
break;
case ITC4__BADMALLOC:
strncpy(pError, "ITC4: Error allocating memory in ITC4", iLen);
break;
case ITC4__BADREAD:
strncpy(pError, "ITC4: Badly formatted answer", iLen);
break;
case ITC4__BADSET:
strncpy(pError,
"ITC4: Failed three times to write new set value to ITC4",
iLen);
break;
default:
SerialError(iCode, pError, iLen);
break;
}
}

View File

@ -16,11 +16,11 @@
defined are those defined for serialsinq plus a few additional ones: defined are those defined for serialsinq plus a few additional ones:
*/ */
#define ITC4__BADCOM -501 #define ITC4__BADCOM -501
/* command not recognized */ /* command not recognized */
#define ITC4__BADPAR -502 #define ITC4__BADPAR -502
/* bad parameter to command */ /* bad parameter to command */
#define ITC4__BADMALLOC -503 #define ITC4__BADMALLOC -503
/* error allocating memory */ /* error allocating memory */
#define ITC4__BADREAD -504 #define ITC4__BADREAD -504
/* error analysing command string on Read */ /* error analysing command string on Read */
@ -30,21 +30,22 @@
/* failed three times to set temperature */ /* failed three times to set temperature */
#define ITC4__READONLY -531 #define ITC4__READONLY -531
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
typedef struct __ITC4 { typedef struct __ITC4 {
int iRead; int iRead;
int iControl; int iControl;
void *pData; void *pData;
char pAns[80]; char pAns[80];
float fDiv; float fDiv;
float fMult; float fMult;
int iReadOnly; int iReadOnly;
int i503; /* flag for model 503, understanding float*/ int i503; /* flag for model 503, understanding float */
} ITC4; } ITC4;
typedef struct __ITC4 *pITC4; typedef struct __ITC4 *pITC4;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
int ITC4_Open(pITC4 *pData,char *pHost, int iPort, int iChannel, int iMode); int ITC4_Open(pITC4 * pData, char *pHost, int iPort, int iChannel,
int iMode);
/***** creates an ITC4 datastructure and opens a connection to the ITCL4 /***** creates an ITC4 datastructure and opens a connection to the ITCL4
controller. Input Parameters are: controller. Input Parameters are:
the hostname the hostname
@ -55,17 +56,17 @@
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
void ITC4_Close(pITC4 *pData); void ITC4_Close(pITC4 * pData);
/****** close a connection to an ITC4controller and frees its /****** close a connection to an ITC4controller and frees its
data structure. The only parameter is a pointer to the data data structure. The only parameter is a pointer to the data
structure for this controller. This pointer will be invalid after structure for this controller. This pointer will be invalid after
this call. this call.
*/ */
int ITC4_Config(pITC4 *pData, int iTmo, int iRead, int ITC4_Config(pITC4 * pData, int iTmo, int iRead,
int iControl, float fDiv, float fMult); int iControl, float fDiv, float fMult);
/***** configure some aspects of a ITC4temperature controller. /***** configure some aspects of a ITC4temperature controller.
The parameter are: The parameter are:
- a pointer to the data structure for the controller as - a pointer to the data structure for the controller as
@ -80,8 +81,8 @@
The function returns 1 on success, a negative error code on The function returns 1 on success, a negative error code on
failure. failure.
*/ */
int ITC4_Send(pITC4 *pData, char *pCommand, char *pReply, int iLen); int ITC4_Send(pITC4 * pData, char *pCommand, char *pReply, int iLen);
/******* send a the command in pCommand to the ITC4controller. /******* send a the command in pCommand to the ITC4controller.
A possible reply is returned in the buffer pReply. A possible reply is returned in the buffer pReply.
Maximum iLen characters are copied to pReply. Maximum iLen characters are copied to pReply.
@ -91,8 +92,8 @@
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
int ITC4_Read(pITC4 *pData, float *fVal); int ITC4_Read(pITC4 * pData, float *fVal);
/******* reads the current actual temperature of the sensor /******* reads the current actual temperature of the sensor
configured by ConfigITC4for reading. The value is returned configured by ConfigITC4for reading. The value is returned
in fVal. The first parameter is a pointer to a ITCL4 in fVal. The first parameter is a pointer to a ITCL4
@ -102,7 +103,7 @@
failure. failure.
*/ */
int ITC4_Set(pITC4 *pData, float fVal); int ITC4_Set(pITC4 * pData, float fVal);
/****** sets a new preset temperature in the ITC4temperature /****** sets a new preset temperature in the ITC4temperature
controller. Parameters are: controller. Parameters are:
- a pointer to a ITC4data structure as returned by OpenITCL4. - a pointer to a ITC4data structure as returned by OpenITCL4.
@ -111,14 +112,12 @@
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
void ITC4_ErrorTxt(pITC4 *pData, int iCode, char *pError, int iLen); void ITC4_ErrorTxt(pITC4 * pData, int iCode, char *pError, int iLen);
/******* translates one of the negative error ITC4error codes /******* translates one of the negative error ITC4error codes
into text. Maximum iLen bytes will be copied to the into text. Maximum iLen bytes will be copied to the
buffer pError; buffer pError;
*/ */
#endif #endif

View File

@ -154,7 +154,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#ifdef FORTIFY #ifdef FORTIFY
#include <fortify.h> #include <fortify.h>
#endif #endif
#include <sinq_prototypes.h> #include <sinq_prototypes.h>
@ -167,110 +167,157 @@
**-------------------------------------------------------------------------- **--------------------------------------------------------------------------
** MakeCharPrintable: makes a single character printable. ** MakeCharPrintable: makes a single character printable.
*/ */
int MakeCharPrintable (char *out, int out_size, char in) { int MakeCharPrintable(char *out, int out_size, char in)
{
/* ================= /* =================
** **
** Return value is number of chars put into *out. ** Return value is number of chars put into *out.
*/ */
char buff[8], *pntr; char buff[8], *pntr;
pntr = buff; pntr = buff;
if ((in & 0x80) != 0) { /* Parity bit set? */ if ((in & 0x80) != 0) { /* Parity bit set? */
*pntr++ = '^'; /* Yes. Put a '^' in the buffer .. */ *pntr++ = '^'; /* Yes. Put a '^' in the buffer .. */
in = in & 0x7f; /* .. and remove the parity bit. */ in = in & 0x7f; /* .. and remove the parity bit. */
}
switch (in) {
case '^': *pntr++ = '\\'; *pntr++ = '^'; break;
case '\\': *pntr++ = '\\'; *pntr++ = '\\'; break;
case '\000': *pntr++ = '\\'; *pntr++ = '0'; break;
case '\007': *pntr++ = '\\'; *pntr++ = 'a'; break;
case '\010': *pntr++ = '\\'; *pntr++ = 'b'; break;
case '\011': *pntr++ = '\\'; *pntr++ = 't'; break;
case '\012': *pntr++ = '\\'; *pntr++ = 'n'; break;
case '\013': *pntr++ = '\\'; *pntr++ = 'v'; break;
case '\014': *pntr++ = '\\'; *pntr++ = 'f'; break;
case '\015': *pntr++ = '\\'; *pntr++ = 'r'; break;
default:
if ((in < ' ') || (in > '~')) {
pntr += sprintf (pntr, "\\%3.3o", in);
}else {
*pntr++ = in;
}
}
out_size = (out_size > (pntr - buff)) ? (pntr - buff) : out_size;
memcpy (out, buff, out_size);
return out_size;
} }
switch (in) {
case '^':
*pntr++ = '\\';
*pntr++ = '^';
break;
case '\\':
*pntr++ = '\\';
*pntr++ = '\\';
break;
case '\000':
*pntr++ = '\\';
*pntr++ = '0';
break;
case '\007':
*pntr++ = '\\';
*pntr++ = 'a';
break;
case '\010':
*pntr++ = '\\';
*pntr++ = 'b';
break;
case '\011':
*pntr++ = '\\';
*pntr++ = 't';
break;
case '\012':
*pntr++ = '\\';
*pntr++ = 'n';
break;
case '\013':
*pntr++ = '\\';
*pntr++ = 'v';
break;
case '\014':
*pntr++ = '\\';
*pntr++ = 'f';
break;
case '\015':
*pntr++ = '\\';
*pntr++ = 'r';
break;
default:
if ((in < ' ') || (in > '~')) {
pntr += sprintf(pntr, "\\%3.3o", in);
} else {
*pntr++ = in;
}
}
out_size = (out_size > (pntr - buff)) ? (pntr - buff) : out_size;
memcpy(out, buff, out_size);
return out_size;
}
/* /*
**-------------------------------------------------------------------------- **--------------------------------------------------------------------------
** MakeMemPrintable: alternative version of MakePrintable. ** MakeMemPrintable: alternative version of MakePrintable.
*/ */
char *MakeMemPrintable ( char *MakeMemPrintable(
/* ================ /* ================
*/ char *out, */ char *out,
int out_size, int out_size, char *in, int in_len)
char *in, {
int in_len) {
int i; int i;
char *pntr; char *pntr;
if (out_size <= 0) return out; if (out_size <= 0)
while ((out_size > 1) && (in_len > 0)) {
i = MakeCharPrintable (out, (out_size - 1), *in);
out += i; out_size -= i;
in++; in_len--;
}
*out = NIL;
return out; return out;
while ((out_size > 1) && (in_len > 0)) {
i = MakeCharPrintable(out, (out_size - 1), *in);
out += i;
out_size -= i;
in++;
in_len--;
} }
*out = NIL;
return out;
}
/* /*
**-------------------------------------------------------------------------- **--------------------------------------------------------------------------
** MakePrint: Make all characters in a buffer printable. ** MakePrint: Make all characters in a buffer printable.
*/ */
char *MakePrint (char *chr) { char *MakePrint(char *chr)
{
/* ========= /* =========
*/ */
int len, i; int len, i;
for (i = 0; chr[i] != NIL; i++) chr[i] &= 0x7F;
len = strlen (chr); for (i = 0; chr[i] != NIL; i++)
if (len <= 0) return chr; chr[i] &= 0x7F;
if (chr[len-1] == '\r') chr[len-1] = NIL;
if (chr[len-1] == '\n') chr[len-1] = NIL;
for (i = 0; chr[i] != NIL; i++) {
if (chr[i] < ' ') chr[i] = '.';
if (chr[i] == 0x7F) chr[i] = '.';
}
len = strlen(chr);
if (len <= 0)
return chr; return chr;
if (chr[len - 1] == '\r')
chr[len - 1] = NIL;
if (chr[len - 1] == '\n')
chr[len - 1] = NIL;
for (i = 0; chr[i] != NIL; i++) {
if (chr[i] < ' ')
chr[i] = '.';
if (chr[i] == 0x7F)
chr[i] = '.';
} }
return chr;
}
/* /*
**-------------------------------------------------------------------------- **--------------------------------------------------------------------------
** MakePrintable: improved version of MakePrint. ** MakePrintable: improved version of MakePrint.
*/ */
char *MakePrintable ( char *MakePrintable(
/* ============= /* =============
*/ char *out, */ char *out,
int out_size, int out_size, char *in)
char *in) { {
int i; int i;
char *pntr; char *pntr;
if (out_size <= 0) return out; if (out_size <= 0)
while ((out_size > 1) && (*in != NIL)) {
i = MakeCharPrintable (out, (out_size - 1), *in);
in++; out += i; out_size -= i;
}
*out = NIL;
return out; return out;
while ((out_size > 1) && (*in != NIL)) {
i = MakeCharPrintable(out, (out_size - 1), *in);
in++;
out += i;
out_size -= i;
} }
*out = NIL;
return out;
}
/*-------------------------------------------- End of MakePrint.C =======*/ /*-------------------------------------------- End of MakePrint.C =======*/

View File

@ -9,8 +9,8 @@
#define RS__PROTOCOL_ID "V01A" #define RS__PROTOCOL_ID "V01A"
#define RS__PROTOCOL_ID_V01B "V01B" #define RS__PROTOCOL_ID_V01B "V01B"
#define RS__PROTOCOL_CODE 1 /* Code corresponding to RS__PROTOCOL_ID */ #define RS__PROTOCOL_CODE 1 /* Code corresponding to RS__PROTOCOL_ID */
#define RS__PROTOCOL_CODE_V01B 2 /* Code corresponding to RS__PROTOCOL_ID_0 */ #define RS__PROTOCOL_CODE_V01B 2 /* Code corresponding to RS__PROTOCOL_ID_0 */
#ifndef OffsetOf #ifndef OffsetOf
#define OffsetOf(type, identifier) ((size_t)(&((type*) NULL)->identifier)) #define OffsetOf(type, identifier) ((size_t)(&((type*) NULL)->identifier))
@ -76,28 +76,28 @@
** **
** An example of a command item might be: "0006RMT 1\r" ** An example of a command item might be: "0006RMT 1\r"
**--------------------------------------------------------------------------*/ **--------------------------------------------------------------------------*/
struct RS__MsgStruct { struct RS__MsgStruct {
char msg_size[4]; /* 4 ASCII decimal chars!! */ char msg_size[4]; /* 4 ASCII decimal chars!! */
char msg_id[4]; char msg_id[4];
char c_pcol_lvl[4]; /* Client protocol level */ char c_pcol_lvl[4]; /* Client protocol level */
char serial_port[4]; char serial_port[4];
char tmo[4]; /* Units are 0.1 secs */ char tmo[4]; /* Units are 0.1 secs */
char terms[4]; char terms[4];
char n_cmnds[4]; char n_cmnds[4];
char cmnds[356]; char cmnds[356];
}; };
/* /*
** The "cmnds" buffer in RS__MsgStruct is a concatenated ** The "cmnds" buffer in RS__MsgStruct is a concatenated
** list of the following structures. ** list of the following structures.
*/ */
struct RS__CmndStruct { struct RS__CmndStruct {
char cmnd_len[2]; char cmnd_len[2];
char cmnd[1]; char cmnd[1];
}; };
struct RS__CmndStruct_V01B { struct RS__CmndStruct_V01B {
char cmnd_len[4]; char cmnd_len[4];
char cmnd[1]; char cmnd[1];
}; };
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
** Structure of Reply from Server to Client - everything is sent in ASCII ** Structure of Reply from Server to Client - everything is sent in ASCII
** for LabView's benefit. ** for LabView's benefit.
@ -150,37 +150,37 @@
** **
** An example of a reply item might be: "0009\r12.3456\0" ** An example of a reply item might be: "0009\r12.3456\0"
**--------------------------------------------------------------------------*/ **--------------------------------------------------------------------------*/
struct RS__RespStruct { struct RS__RespStruct {
char msg_size[4]; char msg_size[4];
char msg_id[4]; char msg_id[4];
char s_pcol_lvl[4]; /* Server protocol level */ char s_pcol_lvl[4]; /* Server protocol level */
char n_rply[4]; /* Error if < 0 */ char n_rply[4]; /* Error if < 0 */
union { union {
char rplys[496]; char rplys[496];
char sub_status[12]; char sub_status[12];
} u; } u;
}; };
/* /*
** The "rplys" buffer in RS__RespStruct is a ** The "rplys" buffer in RS__RespStruct is a
** concatenated list of the following structures. ** concatenated list of the following structures.
*/ */
struct RS__RplyStruct { struct RS__RplyStruct {
char rply_len[2]; /* 2 ASCII decimal chars!! char rply_len[2]; /* 2 ASCII decimal chars!!
** The length includes the ** The length includes the
** terminator, term, and the ** terminator, term, and the
** zero terminator of rply. ** zero terminator of rply.
*/ */
char term; /* The terminating character */ char term; /* The terminating character */
char rply[1]; /* Zero terminated string */ char rply[1]; /* Zero terminated string */
}; };
struct RS__RplyStruct_V01B { struct RS__RplyStruct_V01B {
char rply_len[4]; /* 4 ASCII decimal chars!! char rply_len[4]; /* 4 ASCII decimal chars!!
** The length includes the ** The length includes the
** terminator, term, and the ** terminator, term, and the
** zero terminator of rply. ** zero terminator of rply.
*/ */
char term; /* The terminating character */ char term; /* The terminating character */
char rply[1]; /* Zero terminated string */ char rply[1]; /* Zero terminated string */
}; };
/*------------------------------------------------ End of RS232C_DEF.H --*/ /*------------------------------------------------ End of RS232C_DEF.H --*/
#endif /* _rs232c_def_ */ #endif /* _rs232c_def_ */

File diff suppressed because it is too large Load Diff

View File

@ -22,25 +22,25 @@
#line 30 "velodorn.w" #line 30 "velodorn.w"
int SerialOpen(void **pData, char *pHost, int iPort, int iChannel); int SerialOpen(void **pData, char *pHost, int iPort, int iChannel);
int SerialForceOpen(void **pData, char *pHost, int iPort, int iChannel); int SerialForceOpen(void **pData, char *pHost, int iPort, int iChannel);
int SerialConfig(void **pData, int iTmo); int SerialConfig(void **pData, int iTmo);
int SerialGetTmo(void **pData); int SerialGetTmo(void **pData);
int SerialATerm(void **pData, char *pTerm); int SerialATerm(void **pData, char *pTerm);
int SerialAGetTerm(void **pData, char *pTerm, int iTermLen); int SerialAGetTerm(void **pData, char *pTerm, int iTermLen);
int SerialSendTerm(void **pData, char *pTerm); int SerialSendTerm(void **pData, char *pTerm);
int SerialGetSocket(void **pData); int SerialGetSocket(void **pData);
int SerialClose(void **pData); int SerialClose(void **pData);
int SerialForceClose(void **pData); int SerialForceClose(void **pData);
int SerialSend(void **pData, char *pCommand); int SerialSend(void **pData, char *pCommand);
int SerialReceive(void **pData, char *pBuffer, int iBufLen); int SerialReceive(void **pData, char *pBuffer, int iBufLen);
int SerialReceiveWithTerm(void **pData, char *pBuffer, int SerialReceiveWithTerm(void **pData, char *pBuffer,
int iBufLen,char *cTerm); int iBufLen, char *cTerm);
int SerialError(int iError, char *pError, int iErrLen); int SerialError(int iError, char *pError, int iErrLen);
int SerialWriteRead(void **pData, char *pCommand, int SerialWriteRead(void **pData, char *pCommand,
char *pBuffer, int iBufLen); char *pBuffer, int iBufLen);
int SerialNoReply(void **pData, char *pCommand); int SerialNoReply(void **pData, char *pCommand);
#line 175 "velodorn.w" #line 175 "velodorn.w"
@ -48,8 +48,8 @@
#line 116 "velodorn.w" #line 116 "velodorn.w"
typedef int (*SerialSleep)(void *pData, int iTime); typedef int (*SerialSleep) (void *pData, int iTime);
void SetSerialSleep(void **pData, SerialSleep pFunc, void *pUserData); void SetSerialSleep(void **pData, SerialSleep pFunc, void *pUserData);
#line 177 "velodorn.w" #line 177 "velodorn.w"

View File

@ -19,656 +19,242 @@
#include <el737_def.h> #include <el737_def.h>
#endif #endif
/* ---------------------------------------------------------------------*/ /* ---------------------------------------------------------------------*/
int AsynSrv_ChanClose ( int AsynSrv_ChanClose(struct AsynSrv__info *asyn_info);
struct AsynSrv__info *asyn_info); int AsynSrv_Close(struct AsynSrv__info *asyn_info, int force_flag);
int AsynSrv_Close ( int AsynSrv_Config(struct AsynSrv__info *asyn_info, ...);
struct AsynSrv__info *asyn_info, int AsynSrv_ConfigDflt(char *par_id, ...);
int force_flag); void AsynSrv_ErrInfo(char **entry_txt,
int AsynSrv_Config ( int *errcode, int *my_errno, int *vaxc_errno);
struct AsynSrv__info *asyn_info, int AsynSrv_Flush(struct AsynSrv__info *asyn_info);
...); int AsynSrv_GetLenTerm(struct AsynSrv__info *asyn_info,
int AsynSrv_ConfigDflt ( struct RS__RespStruct *rcve_buff,
char *par_id, char *rply, int *len, char *term);
...); char *AsynSrv_GetReply(struct AsynSrv__info *asyn_info,
void AsynSrv_ErrInfo ( struct RS__RespStruct *rcve_buff, char *last_rply);
char **entry_txt, int AsynSrv_Open(struct AsynSrv__info *asyn_info);
int *errcode, int AsynSrv_OpenNew(struct AsynSrv__info *asyn_info);
int *my_errno, int AsynSrv_SendCmnds(struct AsynSrv__info *asyn_info,
int *vaxc_errno); struct RS__MsgStruct *send_buff,
int AsynSrv_Flush ( struct RS__RespStruct *rcve_buff, ...);
struct AsynSrv__info *asyn_info); int AsynSrv_SendCmndsBig(struct AsynSrv__info *asyn_info,
int AsynSrv_GetLenTerm ( struct RS__MsgStruct *send_buff,
struct AsynSrv__info *asyn_info, int send_buff_size,
struct RS__RespStruct *rcve_buff, struct RS__RespStruct *rcve_buff,
char *rply, int rcve_buff_size, ...);
int *len, int AsynSrv_Trace(struct AsynSrv__info *asyn_info, int state);
char *term); int AsynSrv_Trace_Write(struct AsynSrv__info *asyn_info);
char *AsynSrv_GetReply (
struct AsynSrv__info *asyn_info,
struct RS__RespStruct *rcve_buff,
char *last_rply);
int AsynSrv_Open (
struct AsynSrv__info *asyn_info);
int AsynSrv_OpenNew (
struct AsynSrv__info *asyn_info);
int AsynSrv_SendCmnds (
struct AsynSrv__info *asyn_info,
struct RS__MsgStruct *send_buff,
struct RS__RespStruct *rcve_buff,
...);
int AsynSrv_SendCmndsBig (
struct AsynSrv__info *asyn_info,
struct RS__MsgStruct *send_buff,
int send_buff_size,
struct RS__RespStruct *rcve_buff,
int rcve_buff_size,
...);
int AsynSrv_Trace (
struct AsynSrv__info *asyn_info,
int state);
int AsynSrv_Trace_Write (
struct AsynSrv__info *asyn_info);
/* ---------------------------------------------------------------------*/ /* ---------------------------------------------------------------------*/
int C_log_arr_get ( int C_log_arr_get(char *name, int arr_size, int *value, int indx);
char *name, int C_log_flt_get(char *name, float *value, int indx);
int arr_size, int C_log_int_get(char *name, long int *value, int indx);
int *value, int C_log_str_get(char *name, char *value, int val_size, int indx);
int indx);
int C_log_flt_get (
char *name,
float *value,
int indx);
int C_log_int_get (
char *name,
long int *value,
int indx);
int C_log_str_get (
char *name,
char *value,
int val_size,
int indx);
/* ---------------------------------------------------------------------*/ /* ---------------------------------------------------------------------*/
int C_str_edit ( int C_str_edit(char *out, char *in, char *ctrl, int *length);
char *out,
char *in,
char *ctrl,
int *length);
/* ---------------------------------------------------------------------*/ /* ---------------------------------------------------------------------*/
int C_tt_port_config ( int C_tt_port_config(int *hndl, int mask);
int *hndl, int C_tt_port_connect(int *hndl, int *chan, char *lognam, char *pwd);
int mask); int C_tt_port_disconnect(int *hndl);
int C_tt_port_connect ( int C_tt_port_io(int *hndl,
int *hndl, char *rqst,
int *chan, char *term,
char *lognam, char *answ, int *answ_len, int flush, int tmo);
char *pwd);
int C_tt_port_disconnect (
int *hndl);
int C_tt_port_io (
int *hndl,
char *rqst,
char *term,
char *answ,
int *answ_len,
int flush,
int tmo);
/* ---------------------------------------------------------------------*/ /* ---------------------------------------------------------------------*/
int EL734_Close ( int EL734_Close(void **handle, int force_flag);
void **handle, int EL734_Config(void **handle, ...);
int force_flag); char *EL734_EncodeMSR(char *text,
int EL734_Config ( int text_len,
void **handle, int msr, int ored_msr, int fp_cntr, int fr_cntr);
...); char *EL734_EncodeSS(char *text, int text_len, int ss);
char *EL734_EncodeMSR ( void EL734_ErrInfo(char **entry_txt,
char *text, int *errcode, int *my_errno, int *vaxc_errno);
int text_len, int EL734_GetAirCush(void **handle, int *present, int *state);
int msr, int EL734_GetEncGearing(void **handle, int *nominator, int *denominator);
int ored_msr, int EL734_GetId(void **handle, char *id_txt, int id_len);
int fp_cntr, int EL734_GetLimits(void **handle, float *lo, float *hi);
int fr_cntr); int EL734_GetMotorGearing(void **handle, int *nominator, int *denominator);
char *EL734_EncodeSS ( int EL734_GetNullPoint(void **handle, int *null_pt);
char *text, int EL734_GetPosition(void **handle, float *ist_posit);
int text_len, int EL734_GetPrecision(void **handle, int *n_dec);
int ss); int EL734_GetRefMode(void **handle, int *mode);
void EL734_ErrInfo ( int EL734_GetRefParam(void **handle, float *param);
char **entry_txt, int EL734_GetSpeeds(void **handle, int *lo, int *hi, int *ramp);
int *errcode, int EL734_GetStatus(void **handle,
int *my_errno, int *msr,
int *vaxc_errno); int *ored_msr,
int EL734_GetAirCush ( int *fp_cntr, int *fr_cntr, int *ss, float *ist_posit);
void **handle, int EL734_GetZeroPoint(void **handle, float *zero_pt);
int *present, int EL734_MoveNoWait(void **handle, float soll_posit);
int *state); int EL734_MoveWait(void **handle,
int EL734_GetEncGearing ( float soll_posit,
void **handle, int *ored_msr,
int *nominator, int *fp_cntr, int *fr_cntr, float *ist_posit);
int *denominator); int EL734_Open(void **handle,
int EL734_GetId ( char *host, int port, int chan, int motor, char *id);
void **handle, int EL734_PutOffline(void **handle);
char *id_txt, int EL734_PutOnline(void **handle, int echo);
int id_len); int EL734_SendCmnd(void **handle, char *cmnd, char *rply, int rply_size);
int EL734_GetLimits ( int EL734_SetAirCush(void **handle, int state);
void **handle, int EL734_SetErrcode(struct EL734info *info_ptr,
float *lo, char *response, char *cmnd);
float *hi); int EL734_SetHighSpeed(void **handle, int hi);
int EL734_GetMotorGearing ( int EL734_SetLowSpeed(void **handle, int lo);
void **handle, int EL734_SetRamp(void **handle, int ramp);
int *nominator, int EL734_Stop(void **handle);
int *denominator); int EL734_WaitIdle(void **handle,
int EL734_GetNullPoint ( int *ored_msr,
void **handle, int *fp_cntr, int *fr_cntr, float *ist_posit);
int *null_pt); void EL734_ZeroStatus(void **handle);
int EL734_GetPosition (
void **handle,
float *ist_posit);
int EL734_GetPrecision (
void **handle,
int *n_dec);
int EL734_GetRefMode (
void **handle,
int *mode);
int EL734_GetRefParam (
void **handle,
float *param);
int EL734_GetSpeeds (
void **handle,
int *lo,
int *hi,
int *ramp);
int EL734_GetStatus (
void **handle,
int *msr,
int *ored_msr,
int *fp_cntr,
int *fr_cntr,
int *ss,
float *ist_posit);
int EL734_GetZeroPoint (
void **handle,
float *zero_pt);
int EL734_MoveNoWait (
void **handle,
float soll_posit);
int EL734_MoveWait (
void **handle,
float soll_posit,
int *ored_msr,
int *fp_cntr,
int *fr_cntr,
float *ist_posit);
int EL734_Open (
void **handle,
char *host,
int port,
int chan,
int motor,
char *id);
int EL734_PutOffline (
void **handle);
int EL734_PutOnline (
void **handle,
int echo);
int EL734_SendCmnd (
void **handle,
char *cmnd,
char *rply,
int rply_size);
int EL734_SetAirCush (
void **handle,
int state);
int EL734_SetErrcode (
struct EL734info *info_ptr,
char *response,
char *cmnd);
int EL734_SetHighSpeed (
void **handle,
int hi);
int EL734_SetLowSpeed (
void **handle,
int lo);
int EL734_SetRamp (
void **handle,
int ramp);
int EL734_Stop (
void **handle);
int EL734_WaitIdle (
void **handle,
int *ored_msr,
int *fp_cntr,
int *fr_cntr,
float *ist_posit);
void EL734_ZeroStatus (
void **handle);
/* ---------------------------------------------------------------------*/ /* ---------------------------------------------------------------------*/
int EL737_Close ( int EL737_Close(void **handle, int force_flag);
void **handle, int EL737_Config(void **handle, ...);
int force_flag); int EL737_Continue(void **handle, int *status);
int EL737_Config ( int EL737_EnableThresh(void **handle, int indx);
void **handle, void EL737_ErrInfo(char **entry_txt,
...); int *errcode, int *my_errno, int *vaxc_errno);
int EL737_Continue ( int EL737_GetMonIntegTime(void **handle, int indx, float *mon_integ_time);
void **handle, int EL737_GetRateIntegTime(void **handle, float *rate_integ_time);
int *status); void *EL737_GetReply(void **handle, void *last_rply);
int EL737_EnableThresh ( int EL737_GetStatus(void **handle,
void **handle, int *c1,
int indx); int *c2, int *c3, int *c4, float *timer, int *rs);
void EL737_ErrInfo ( int EL737_GetStatusExtra(void **handle,
char **entry_txt, int *c5, int *c6, int *c7, int *c8);
int *errcode, int EL737_GetThresh(void **handle, int *indx, float *val);
int *my_errno, int EL737_Open(void **handle, char *host, int port, int chan);
int *vaxc_errno); int EL737_Pause(void **handle, int *status);
int EL737_GetMonIntegTime ( int EL737_SendCmnd(void **handle, char *cmnd, char *rply, int rply_size);
void **handle, int EL737_SetErrcode(struct EL737info *info_ptr,
int indx, char *response, char *cmnd);
float *mon_integ_time); int EL737_SetThresh(void **handle, int indx, float val);
int EL737_GetRateIntegTime ( int EL737_StartCnt(void **handle, int preset_count, int *status);
void **handle, int EL737_StartTime(void **handle, float preset_time, int *status);
float *rate_integ_time); int EL737_Stop(void **handle,
void *EL737_GetReply ( int *c1,
void **handle, int *c2, int *c3, int *c4, float *timer, int *status);
void *last_rply); int EL737_StopFast(void **handle);
int EL737_GetStatus ( int EL737_WaitIdle(void **handle,
void **handle, int *c1, int *c2, int *c3, int *c4, float *timer);
int *c1,
int *c2,
int *c3,
int *c4,
float *timer,
int *rs);
int EL737_GetStatusExtra (
void **handle,
int *c5,
int *c6,
int *c7,
int *c8);
int EL737_GetThresh (
void **handle,
int *indx,
float *val);
int EL737_Open (
void **handle,
char *host,
int port,
int chan);
int EL737_Pause (
void **handle,
int *status);
int EL737_SendCmnd (
void **handle,
char *cmnd,
char *rply,
int rply_size);
int EL737_SetErrcode (
struct EL737info *info_ptr,
char *response,
char *cmnd);
int EL737_SetThresh (
void **handle,
int indx,
float val);
int EL737_StartCnt (
void **handle,
int preset_count,
int *status);
int EL737_StartTime (
void **handle,
float preset_time,
int *status);
int EL737_Stop (
void **handle,
int *c1,
int *c2,
int *c3,
int *c4,
float *timer,
int *status);
int EL737_StopFast (
void **handle);
int EL737_WaitIdle (
void **handle,
int *c1,
int *c2,
int *c3,
int *c4,
float *timer);
/* ---------------------------------------------------------------------*/ /* ---------------------------------------------------------------------*/
int EL755_Close ( int EL755_Close(void **handle, int force_flag);
void **handle, int EL755_Config(void **handle, ...);
int force_flag); void EL755_ErrInfo(char **entry_txt,
int EL755_Config ( int *errcode, int *my_errno, int *vaxc_errno);
void **handle, int EL755_ErrorLog(char *routine_name, char *text);
...); int EL755_GetConstant(void **handle, float *value);
void EL755_ErrInfo ( int EL755_GetCurrents(void **handle, float *soll, float *ist);
char **entry_txt, int EL755_GetId(void **handle, char *id_txt, int id_len);
int *errcode, int EL755_GetLimit(void **handle, float *value);
int *my_errno, int EL755_GetRamp(void **handle, float *value);
int *vaxc_errno); int EL755_GetTimeConstant(void **handle, float *value);
int EL755_ErrorLog ( int EL755_GetVoltageRange(void **handle, float *value);
char *routine_name, int EL755_Open(void **handle, char *host, int port, int chan, int indx);
char *text); int EL755_PutOffline(void **handle);
int EL755_GetConstant ( int EL755_PutOnline(void **handle, int echo);
void **handle, int EL755_SendTillSameStr(void **handle,
float *value); char *cmnd, char *rply, int rply_len);
int EL755_GetCurrents ( int EL755_SendTillSameVal(void **handle, char *cmnd, float *val);
void **handle, int EL755_SendTillTwoVals(void **handle,
float *soll, char *cmnd, float *val0, float *val1);
float *ist); int EL755_SetConstant(void **handle, float value);
int EL755_GetId ( int EL755_SetCurrent(void **handle, float soll);
void **handle, int EL755_SetLimit(void **handle, float value);
char *id_txt, int EL755_SetRamp(void **handle, float value);
int id_len); int EL755_SetTimeConstant(void **handle, float value);
int EL755_GetLimit ( int EL755_SetVoltageRange(void **handle, float value);
void **handle,
float *value);
int EL755_GetRamp (
void **handle,
float *value);
int EL755_GetTimeConstant (
void **handle,
float *value);
int EL755_GetVoltageRange (
void **handle,
float *value);
int EL755_Open (
void **handle,
char *host,
int port,
int chan,
int indx);
int EL755_PutOffline (
void **handle);
int EL755_PutOnline (
void **handle,
int echo);
int EL755_SendTillSameStr (
void **handle,
char *cmnd,
char *rply,
int rply_len);
int EL755_SendTillSameVal (
void **handle,
char *cmnd,
float *val);
int EL755_SendTillTwoVals (
void **handle,
char *cmnd,
float *val0,
float *val1);
int EL755_SetConstant (
void **handle,
float value);
int EL755_SetCurrent (
void **handle,
float soll);
int EL755_SetLimit (
void **handle,
float value);
int EL755_SetRamp (
void **handle,
float value);
int EL755_SetTimeConstant (
void **handle,
float value);
int EL755_SetVoltageRange (
void **handle,
float value);
/* ---------------------------------------------------------------------*/ /* ---------------------------------------------------------------------*/
int Fluke_Close ( int Fluke_Close(void **handle, int force_flag);
void **handle, int Fluke_Config(void **handle, ...);
int force_flag); void Fluke_ErrInfo(char **entry_txt,
int Fluke_Config ( int *errcode, int *my_errno, int *vaxc_errno);
void **handle, int Fluke_ErrorLog(char *routine_name, char *text);
...); int Fluke_Open(void **handle, char *host, int port, int chan);
void Fluke_ErrInfo ( int Fluke_Read(void **handle, float *ist);
char **entry_txt, int Fluke_SendTillSame(void **handle,
int *errcode, char *cmnd, char *rply, int rply_len);
int *my_errno, int Fluke_SendTillSameVal(void **handle, char *cmnd, float *val);
int *vaxc_errno);
int Fluke_ErrorLog (
char *routine_name,
char *text);
int Fluke_Open (
void **handle,
char *host,
int port,
int chan);
int Fluke_Read (
void **handle,
float *ist);
int Fluke_SendTillSame (
void **handle,
char *cmnd,
char *rply,
int rply_len);
int Fluke_SendTillSameVal (
void **handle,
char *cmnd,
float *val);
/* ---------------------------------------------------------------------*/ /* ---------------------------------------------------------------------*/
int ITC_Close ( int ITC_Close(void **handle, int force_flag);
void **handle, int ITC_Config(void **handle, ...);
int force_flag); int ITC_Dump_RAM(void **handle,
int ITC_Config ( int buff_size, char *buff, int *dump_len, int *n_diffs);
void **handle, void ITC_ErrInfo(char **entry_txt,
...); int *errcode, int *my_errno, int *vaxc_errno);
int ITC_Dump_RAM ( int ITC_GetConfig(void **handle, ...);
void **handle, int ITC_Load_RAM(void **handle, int load_len, char *buff);
int buff_size, int ITC_Load_Table(void **handle, char *buff);
char *buff, int ITC_Open(void **handle, char *host, int port, int chan);
int *dump_len, int ITC_Read_ITC_Sensor(void **handle,
int *n_diffs); int sensor, float factor, float *value);
void ITC_ErrInfo ( int ITC_Read_LTC11_Sensor(void **handle, int sensor, float *value);
char **entry_txt, int ITC_Read_LTC11_SetPt(void **handle, float *value);
int *errcode, int ITC_ReadAuxTemp(void **handle, float *value);
int *my_errno, int ITC_ReadControlTemp(void **handle, float *value);
int *vaxc_errno); int ITC_ReadHeaterOp(void **handle, float *op_level, float *op_percent);
int ITC_GetConfig ( int ITC_ReadId(void **handle, char *id_txt, int id_txt_len, int *id_len);
void **handle, int ITC_ReadPID(void **handle, float *p, float *i, float *d);
...); int ITC_ReadSampleTemp(void **handle, float *s_temp);
int ITC_Load_RAM ( int ITC_ReadSetPoint(void **handle, float *sp_temp);
void **handle, int ITC_ReadStatus(void **handle,
int load_len, char *status_txt,
char *buff); int status_txt_len,
int ITC_Load_Table ( int *status_len, int *auto_state, int *remote_state);
void **handle, int ITC_SendTillAckOk(void **handle,
char *buff); struct RS__MsgStruct *to_host,
int ITC_Open ( struct RS__RespStruct *from_host, char *cmnd);
void **handle, int ITC_SendTillSame(void **handle,
char *host, struct RS__MsgStruct *to_host,
int port, struct RS__RespStruct *from_host,
int chan); char *cmnd, char *rply, int rply_len);
int ITC_Read_ITC_Sensor ( int ITC_SendTillSameLen(void **handle,
void **handle, struct RS__MsgStruct *to_host,
int sensor, struct RS__RespStruct *from_host,
float factor, char *cmnd, char *rply, int rply_len);
float *value); int ITC_SendTillSameLenAckOK(void **handle,
int ITC_Read_LTC11_Sensor ( struct RS__MsgStruct *to_host,
void **handle, struct RS__RespStruct *from_host,
int sensor, char *cmnd, char *rply, int rply_len);
float *value); int ITC_SetControlTemp(void **handle, float s_temp);
int ITC_Read_LTC11_SetPt ( int ITC_SetHeatLevel(void **handle, float heat_percent);
void **handle, int ITC_ErrorLog(char *routine_name, char *text);
float *value);
int ITC_ReadAuxTemp (
void **handle,
float *value);
int ITC_ReadControlTemp (
void **handle,
float *value);
int ITC_ReadHeaterOp (
void **handle,
float *op_level,
float *op_percent);
int ITC_ReadId (
void **handle,
char *id_txt,
int id_txt_len,
int *id_len);
int ITC_ReadPID (
void **handle,
float *p,
float *i,
float *d);
int ITC_ReadSampleTemp (
void **handle,
float *s_temp);
int ITC_ReadSetPoint (
void **handle,
float *sp_temp);
int ITC_ReadStatus (
void **handle,
char *status_txt,
int status_txt_len,
int *status_len,
int *auto_state,
int *remote_state);
int ITC_SendTillAckOk (
void **handle,
struct RS__MsgStruct *to_host,
struct RS__RespStruct *from_host,
char *cmnd);
int ITC_SendTillSame (
void **handle,
struct RS__MsgStruct *to_host,
struct RS__RespStruct *from_host,
char *cmnd,
char *rply,
int rply_len);
int ITC_SendTillSameLen (
void **handle,
struct RS__MsgStruct *to_host,
struct RS__RespStruct *from_host,
char *cmnd,
char *rply,
int rply_len);
int ITC_SendTillSameLenAckOK (
void **handle,
struct RS__MsgStruct *to_host,
struct RS__RespStruct *from_host,
char *cmnd,
char *rply,
int rply_len);
int ITC_SetControlTemp (
void **handle,
float s_temp);
int ITC_SetHeatLevel (
void **handle,
float heat_percent);
int ITC_ErrorLog (
char *routine_name,
char *text);
/* ---------------------------------------------------------------------*/ /* ---------------------------------------------------------------------*/
int SPS_Close ( int SPS_Close(void **handle, int force_flag);
void **handle, int SPS_Config(void **handle, ...);
int force_flag); void SPS_ErrInfo(char **entry_txt,
int SPS_Config ( int *errcode, int *my_errno, int *vaxc_errno);
void **handle, int SPS_ErrorLog(char *routine_name, char *text);
...); int SPS_GetStatus(void **handle,
void SPS_ErrInfo ( unsigned char *status_vals,
char **entry_txt, int n_status_vals, int *adc_vals, int n_adc_vals);
int *errcode, int SPS_Open(void **handle, char *host, int port, int chan);
int *my_errno, int SPS_SendTillSame(void **handle,
int *vaxc_errno); struct RS__MsgStruct *to_host,
int SPS_ErrorLog ( struct RS__RespStruct *from_host,
char *routine_name, char *cmnd, char *rply, int rply_len);
char *text); int SPS_SendTillSameLen(void **handle,
int SPS_GetStatus ( struct RS__MsgStruct *to_host,
void **handle, struct RS__RespStruct *from_host,
unsigned char *status_vals, char *cmnd, char *rply, int rply_len);
int n_status_vals,
int *adc_vals,
int n_adc_vals);
int SPS_Open (
void **handle,
char *host,
int port,
int chan);
int SPS_SendTillSame (
void **handle,
struct RS__MsgStruct *to_host,
struct RS__RespStruct *from_host,
char *cmnd,
char *rply,
int rply_len);
int SPS_SendTillSameLen (
void **handle,
struct RS__MsgStruct *to_host,
struct RS__RespStruct *from_host,
char *cmnd,
char *rply,
int rply_len);
/* ---------------------------------------------------------------------*/ /* ---------------------------------------------------------------------*/
int VelSel_Close ( int VelSel_Close(void **handle, int force_flag);
void **handle, void VelSel_Config(void **handle, int msec_tmo, char *eot_str);
int force_flag); void VelSel_ErrInfo(char **entry_txt,
void VelSel_Config ( int *errcode, int *my_errno, int *vaxc_errno);
void **handle, void *VelSel_GetReply(void **handle, void *last_rply);
int msec_tmo, int VelSel_GetStatus(void **handle, char *status_str, int status_str_len);
char *eot_str); int VelSel_Open(void **handle, char *host, int port, int chan);
void VelSel_ErrInfo ( int VelSel_SendCmnd(void **handle, char *cmnd, char *rply, int rply_size);
char **entry_txt,
int *errcode,
int *my_errno,
int *vaxc_errno);
void *VelSel_GetReply (
void **handle,
void *last_rply);
int VelSel_GetStatus (
void **handle,
char *status_str,
int status_str_len);
int VelSel_Open (
void **handle,
char *host,
int port,
int chan);
int VelSel_SendCmnd (
void **handle,
char *cmnd,
char *rply,
int rply_size);
/* ---------------------------------------------------------------------*/ /* ---------------------------------------------------------------------*/
void FailInet ( void FailInet(char *text);
char *text); void GetErrno(int *his_errno, int *his_vaxc_errno);
void GetErrno ( int MakeCharPrintable(char *out, int out_size, char in);
int *his_errno, char *MakePrint(char *text);
int *his_vaxc_errno); char *MakePrintable(char *out, int out_size, char *in);
int MakeCharPrintable ( void *Map_to_ACS();
char *out, char *StrEdit(char *out, char *in, char *ctrl, int *ln);
int out_size, char *StrJoin(char *result, int result_size, char *str_a, char *str_b);
char in); int StrMatch(char *str_a, char *str_b, int min_len);
char *MakePrint ( int Get_TASMAD_Info(char *file_name, int *nItems, ...);
char *text); int Get_TASMAD_Info_Filename(char *file_name, char *buf, int *bufSize);
char *MakePrintable ( int Update_TASMAD_Info(char *file_name, int *nItems, ...);
char *out,
int out_size,
char *in);
void *Map_to_ACS ();
char *StrEdit (
char *out,
char *in,
char *ctrl,
int *ln);
char *StrJoin (
char *result,
int result_size,
char *str_a,
char *str_b);
int StrMatch (
char *str_a,
char *str_b,
int min_len);
int Get_TASMAD_Info (
char *file_name,
int *nItems,
...);
int Get_TASMAD_Info_Filename (
char *file_name,
char *buf,
int *bufSize);
int Update_TASMAD_Info (
char *file_name,
int *nItems,
...);
/*--------------------------------------------- End of SINQ_PROTOTYPES.H --*/ /*--------------------------------------------- End of SINQ_PROTOTYPES.H --*/
#endif /* _sinq_prototypes_loaded_ */ #endif /* _sinq_prototypes_loaded_ */

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@
#define SINQHMUTILITY #define SINQHMUTILITY
#include "sinqhm_def.h" #include "sinqhm_def.h"
typedef struct __SINQHM *pSINQHM; typedef struct __SINQHM *pSINQHM;
/*------------------------------ Error codes -----------------------------*/ /*------------------------------ Error codes -----------------------------*/
#line 341 "sinqhm.w" #line 341 "sinqhm.w"
@ -46,61 +46,59 @@
#line 118 "sinqhm.w" #line 118 "sinqhm.w"
pSINQHM CreateSINQHM(char *pHMComputer, int iMasterPort); pSINQHM CreateSINQHM(char *pHMComputer, int iMasterPort);
pSINQHM CopySINQHM(pSINQHM self); pSINQHM CopySINQHM(pSINQHM self);
void DeleteSINQHM(pSINQHM self); void DeleteSINQHM(pSINQHM self);
void SINQHMSetPar(pSINQHM self, int iRank, int iLength, int iBinWidth); void SINQHMSetPar(pSINQHM self, int iRank, int iLength, int iBinWidth);
void SINQHMSetPSD(pSINQHM self, int xSize, int xOff, int xFac, void SINQHMSetPSD(pSINQHM self, int xSize, int xOff, int xFac,
int ySize, int yOff, int yFac); int ySize, int yOff, int yFac);
#line 142 "sinqhm.w" #line 142 "sinqhm.w"
int SINQHMError2Text(int iErr, char *pBuffer, int iBufLen); int SINQHMError2Text(int iErr, char *pBuffer, int iBufLen);
#line 155 "sinqhm.w" #line 155 "sinqhm.w"
int SINQHMConfigure(pSINQHM self, int iMode, int iRank, int iLength, int SINQHMConfigure(pSINQHM self, int iMode, int iRank, int iLength,
int iBinWidth, int iLowBin, int iCompress); int iBinWidth, int iLowBin, int iCompress);
int SINQHMConfigurePSD(pSINQHM self, int iMode, int SINQHMConfigurePSD(pSINQHM self, int iMode,
int xSize, int xOff, int xFac, int xSize, int xOff, int xFac,
int ySize, int yOff, int yFac, int ySize, int yOff, int yFac,
int iBinWidth, int iBinWidth, float *iEdges, int iEdgeLength);
float *iEdges, int iEdgeLength);
int SINQHMDeconfigure(pSINQHM self, int iHarsh);
int SINQHMGetStatus(pSINQHM self, int *iMode, int *iDaq,
int *iRank, int *iBinWidth,
int *iLength, int *iClients);
int SINQHMDebug(pSINQHM self, int iLevel);
int SINQHMKill(pSINQHM self);
int SINQHMDeconfigure(pSINQHM self, int iHarsh);
int SINQHMGetStatus(pSINQHM self,int *iMode, int *iDaq,
int *iRank, int *iBinWidth,
int *iLength, int *iClients);
int SINQHMDebug(pSINQHM self, int iLevel);
int SINQHMKill(pSINQHM self);
#line 261 "sinqhm.w" #line 261 "sinqhm.w"
int SINQHMOpenDAQ(pSINQHM self); int SINQHMOpenDAQ(pSINQHM self);
int SINQHMCloseDAQ(pSINQHM self); int SINQHMCloseDAQ(pSINQHM self);
int SINQHMStartDAQ(pSINQHM self); int SINQHMStartDAQ(pSINQHM self);
int SINQHMStopDAQ(pSINQHM self); int SINQHMStopDAQ(pSINQHM self);
int SINQHMInhibitDAQ(pSINQHM self); int SINQHMInhibitDAQ(pSINQHM self);
int SINQHMContinueDAQ(pSINQHM self); int SINQHMContinueDAQ(pSINQHM self);
int SINQHMWrite(pSINQHM self, int iNum, int iStart, int iEnd, int SINQHMWrite(pSINQHM self, int iNum, int iStart, int iEnd, void *pData);
void *pData); long SINQHMSize(pSINQHM self, int iNum, int iStart, int iEnd);
long SINQHMSize(pSINQHM self, int iNum, int iStart, int iEnd); int SINQHMRead(pSINQHM self, int iNum, int iStart, int iEnd,
int SINQHMRead(pSINQHM self, int iNum, int iStart, int iEnd, void *pData, int iDataLen);
void *pData, int iDataLen); int SINQHMProject(pSINQHM self, int code, int xStart, int nx,
int SINQHMProject(pSINQHM self, int code, int xStart, int nx, int yStart, int ny, void *pData, int iDataLen);
int yStart, int ny, void *pData, int iDataLen); int SINQHMZero(pSINQHM self, int iNum, int iStart, int iEnd);
int SINQHMZero(pSINQHM self, int iNum, int iStart, int iEnd);
#line 382 "sinqhm.w" #line 382 "sinqhm.w"
#line 232 "sinqhm.w" #line 232 "sinqhm.w"
int SINQHMDefineBank(pSINQHM self, int iBankNumber, int iStart, int iEnd, int SINQHMDefineBank(pSINQHM self, int iBankNumber, int iStart, int iEnd,
float *iEdges, int iEdgeLength); float *iEdges, int iEdgeLength);
#line 383 "sinqhm.w" #line 383 "sinqhm.w"

View File

@ -19,15 +19,15 @@
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
** Define some defaults. ** Define some defaults.
*/ */
#define PORT_BASE 2400 /* The Internet Port for Server Requests */ #define PORT_BASE 2400 /* The Internet Port for Server Requests */
#define MAX_CLIENTS 8 /* The maximum number of active clients */ #define MAX_CLIENTS 8 /* The maximum number of active clients */
#define MAX_TOF_CNTR 1024 /* The maximum number of individual counters .. #define MAX_TOF_CNTR 1024 /* The maximum number of individual counters ..
** which can be handled in TOF mode */ ** which can be handled in TOF mode */
#define MAX_PSD_CNTR 1048576 /* maximum number of PSD elements */ #define MAX_PSD_CNTR 1048576 /* maximum number of PSD elements */
#define MAX_TOF_NBINS 32768 /* The maximum number of bins in a TOF histog */ #define MAX_TOF_NBINS 32768 /* The maximum number of bins in a TOF histog */
#define MAX_TOF_EDGE 16 /* The maximum number of TOF edge arrays */ #define MAX_TOF_EDGE 16 /* The maximum number of TOF edge arrays */
#define VMIO_BASE_ADDR 0x1900 /* VME address of a (possible) VMIO10 module */ #define VMIO_BASE_ADDR 0x1900 /* VME address of a (possible) VMIO10 module */
#define IDENT_MSGE_LEN 256 /* Length of Ident info for SQHM_IDENT */ #define IDENT_MSGE_LEN 256 /* Length of Ident info for SQHM_IDENT */
#define uchar unsigned char #define uchar unsigned char
#define usint unsigned short int #define usint unsigned short int
@ -71,76 +71,76 @@
#define SQHM_STATUS 0x0a #define SQHM_STATUS 0x0a
#define SQHM_WRITE 0x0b #define SQHM_WRITE 0x0b
#define SQHM_ZERO 0x0c #define SQHM_ZERO 0x0c
/* /*
** Define the various operation modes ** Define the various operation modes
*/ */
#define SQHM__TRANS 0x1000 /* Transparent mode */ #define SQHM__TRANS 0x1000 /* Transparent mode */
#define SQHM__HM_DIG 0x2000 /* Hist mode (with digitised read-out) */ #define SQHM__HM_DIG 0x2000 /* Hist mode (with digitised read-out) */
#define SQHM__TOF 0x3000 /* Time-of-Flight mode */ #define SQHM__TOF 0x3000 /* Time-of-Flight mode */
#define SQHM__HM_PSD 0x4000 /* Hist mode (with Pos-sens-detect read-out) */ #define SQHM__HM_PSD 0x4000 /* Hist mode (with Pos-sens-detect read-out) */
#define SQHM__HRPT 0x5000 /* Hist mode for HRPT */ #define SQHM__HRPT 0x5000 /* Hist mode for HRPT */
/* /*
** Define the various sub-mode bits of the operation modes ** Define the various sub-mode bits of the operation modes
*/ */
#define SQHM__SUB_MODE_MSK 0xff /* Mask for extracting "sub-mode" bits */ #define SQHM__SUB_MODE_MSK 0xff /* Mask for extracting "sub-mode" bits */
#define SQHM__DEBUG 0x01 /* Debug flag - FILLER will suspend itself .. #define SQHM__DEBUG 0x01 /* Debug flag - FILLER will suspend itself ..
** .. after starting to allow debugging */ ** .. after starting to allow debugging */
#define SQHM__UD 0x02 /* Use Up/Down bit information */ #define SQHM__UD 0x02 /* Use Up/Down bit information */
#define SQHM__BO_MSK 0x18 /* Mask for extracting "bin-overflow" bits */ #define SQHM__BO_MSK 0x18 /* Mask for extracting "bin-overflow" bits */
#define SQHM__BO_IGN 0x00 /* Ignore bin-overflows (bin-contents wrap) */ #define SQHM__BO_IGN 0x00 /* Ignore bin-overflows (bin-contents wrap) */
#define SQHM__BO_SMAX 0x08 /* On bin-overflow, stop at maximum */ #define SQHM__BO_SMAX 0x08 /* On bin-overflow, stop at maximum */
#define SQHM__BO_CNT 0x10 /* Keep counts of overflow bins */ #define SQHM__BO_CNT 0x10 /* Keep counts of overflow bins */
#define SQHM__STROBO 0x20 /* Use strobo-bit information */ #define SQHM__STROBO 0x20 /* Use strobo-bit information */
#define SQHM__REFLECT 0x40 /* Reflect histograms */ #define SQHM__REFLECT 0x40 /* Reflect histograms */
#define SQHM__NO_STAT 0x80 /* Suppress status info from "Filler" */ #define SQHM__NO_STAT 0x80 /* Suppress status info from "Filler" */
/* /*
** ---------------------------------------------------------- ** ----------------------------------------------------------
** SQHM_DAQ sub-function codes ** SQHM_DAQ sub-function codes
*/ */
#define DAQ__EXIT 0xffffffff #define DAQ__EXIT 0xffffffff
#define DAQ__CLR 0x01 #define DAQ__CLR 0x01
#define DAQ__GO 0x02 #define DAQ__GO 0x02
#define DAQ__INH 0x03 #define DAQ__INH 0x03
#define DAQ__STOP 0x04 #define DAQ__STOP 0x04
#define DAQ__TST 0x05 #define DAQ__TST 0x05
/* /*
** ---------------------------------------------------------- ** ----------------------------------------------------------
** SQHM_PROJECT sub-codes ** SQHM_PROJECT sub-codes
*/ */
#define PROJECT__ON_Y 0x0001 /* Project onto y-axis */ #define PROJECT__ON_Y 0x0001 /* Project onto y-axis */
#define PROJECT__1_DIM 0x0002 /* Make projection of a 1-dim histogram */ #define PROJECT__1_DIM 0x0002 /* Make projection of a 1-dim histogram */
#define PROJECT__COLL 0x0003 /* collapse PSD on one time channel */ #define PROJECT__COLL 0x0003 /* collapse PSD on one time channel */
#define PROJECT__SAMPLE 0x0004 /* sum a rectangular part of the PSD #define PROJECT__SAMPLE 0x0004 /* sum a rectangular part of the PSD
detector in time detector in time
*/ */
/* /*
** ---------------------------------------------------------- ** ----------------------------------------------------------
** Definition of bits in <flag> of TOF edge-array ** Definition of bits in <flag> of TOF edge-array
*/ */
#define FLAG__VAR_BIN 0x01 /* Bin span of histogram is variable */ #define FLAG__VAR_BIN 0x01 /* Bin span of histogram is variable */
/* /*
** ---------------------------------------------------------- ** ----------------------------------------------------------
** Definition of bits in <flags> of SQHM_STATUS response ** Definition of bits in <flags> of SQHM_STATUS response
*/ */
#define STATUS_FLAGS__PF 0x8000 /* PF - Power Fail */ #define STATUS_FLAGS__PF 0x8000 /* PF - Power Fail */
#define STATUS_FLAGS__SWC 0x4000 /* SWC - Status Word Changed */ #define STATUS_FLAGS__SWC 0x4000 /* SWC - Status Word Changed */
#define STATUS_FLAGS__NRL 0x2000 /* NRL - Neutron Rate Low */ #define STATUS_FLAGS__NRL 0x2000 /* NRL - Neutron Rate Low */
#define STATUS_FLAGS__DAQ 0x1000 /* DAQ on -- set if Hdr Mask Bits are #define STATUS_FLAGS__DAQ 0x1000 /* DAQ on -- set if Hdr Mask Bits are
** correct so that data acq is active */ ** correct so that data acq is active */
#define STATUS_FLAGS__SYNC3 0x0800 /* Ext Synch Bit #3 */ #define STATUS_FLAGS__SYNC3 0x0800 /* Ext Synch Bit #3 */
#define STATUS_FLAGS__SYNC2 0x0400 /* Ext Synch Bit #2 */ #define STATUS_FLAGS__SYNC2 0x0400 /* Ext Synch Bit #2 */
#define STATUS_FLAGS__SYNC1 0x0200 /* Ext Synch Bit #1 */ #define STATUS_FLAGS__SYNC1 0x0200 /* Ext Synch Bit #1 */
#define STATUS_FLAGS__SYNC0 0x0100 /* Ext Synch Bit #0 */ #define STATUS_FLAGS__SYNC0 0x0100 /* Ext Synch Bit #0 */
#define STATUS_FLAGS__UD 0x0080 /* UD - Up/Down */ #define STATUS_FLAGS__UD 0x0080 /* UD - Up/Down */
#define STATUS_FLAGS__GU 0x0040 /* GU - Gummi (i.e. Strobo) */ #define STATUS_FLAGS__GU 0x0040 /* GU - Gummi (i.e. Strobo) */
/* /*
** ---------------------------------------------------------- ** ----------------------------------------------------------
*/ */
#define N_HISTS_MAX 64 /* Maximum number of histograms supported */ #define N_HISTS_MAX 64 /* Maximum number of histograms supported */
#define N_BINS_MAX 0x00ffff /* Maximum histogram bin number permitted */ #define N_BINS_MAX 0x00ffff /* Maximum histogram bin number permitted */
#define N_TOTAL_BYTES 0x400000 /* Maximum total bytes of histogram */ #define N_TOTAL_BYTES 0x400000 /* Maximum total bytes of histogram */
/* /*
**------------------------------------------------------------------------------ **------------------------------------------------------------------------------
** Definitions of Filler states in HRPT mode ** Definitions of Filler states in HRPT mode
@ -151,74 +151,74 @@
**------------------------------------------------------------------------------ **------------------------------------------------------------------------------
** Definitions for the LWL Datagrams ** Definitions for the LWL Datagrams
*/ */
#define LWL_HDR_TYPE_MASK (0x1f000000) /* Mask for extracting main dgrm .. #define LWL_HDR_TYPE_MASK (0x1f000000) /* Mask for extracting main dgrm ..
** .. hdr command-type bits */ ** .. hdr command-type bits */
#define LWL_HDR_PF_MASK (0x80000000) /* Mask for extr Power Fail bit */ #define LWL_HDR_PF_MASK (0x80000000) /* Mask for extr Power Fail bit */
#define LWL_HDR_SWC_MASK (0x40000000) /* Mask for extr Status Word Chng bit */ #define LWL_HDR_SWC_MASK (0x40000000) /* Mask for extr Status Word Chng bit */
#define LWL_HDR_NRL_MASK (0x20000000) /* Mask for extr Neutron Rate Low bit */ #define LWL_HDR_NRL_MASK (0x20000000) /* Mask for extr Neutron Rate Low bit */
#define LWL_HDR_SYNC3_MASK (0x00800000) /* Mask for one of ext synch bits */ #define LWL_HDR_SYNC3_MASK (0x00800000) /* Mask for one of ext synch bits */
#define LWL_HDR_SYNC2_MASK (0x00400000) /* Mask for one of ext synch bits */ #define LWL_HDR_SYNC2_MASK (0x00400000) /* Mask for one of ext synch bits */
#define LWL_HDR_SYNC1_MASK (0x00200000) /* Mask for one of ext synch bits */ #define LWL_HDR_SYNC1_MASK (0x00200000) /* Mask for one of ext synch bits */
#define LWL_HDR_SYNC0_MASK (0x00100000) /* Mask for one of ext synch bits */ #define LWL_HDR_SYNC0_MASK (0x00100000) /* Mask for one of ext synch bits */
#define LWL_HDR_UD_MASK LWL_HDR_SYNC1_MASK /* Mask for Up/Down bit */ #define LWL_HDR_UD_MASK LWL_HDR_SYNC1_MASK /* Mask for Up/Down bit */
#define LWL_HDR_GU_MASK LWL_HDR_SYNC0_MASK /* Mask for GU bit */ #define LWL_HDR_GU_MASK LWL_HDR_SYNC0_MASK /* Mask for GU bit */
#define LWL_HDR_BA_MASK (0x00f00000) /* Mask for TSI Binning Addr */ #define LWL_HDR_BA_MASK (0x00f00000) /* Mask for TSI Binning Addr */
#define LWL_HDR_TS_MASK (0x000fffff) /* Mask for TSI Time Stamp */ #define LWL_HDR_TS_MASK (0x000fffff) /* Mask for TSI Time Stamp */
#define LWL_FIFO_EMPTY (0x1e000000) /* FIFO Empty */ #define LWL_FIFO_EMPTY (0x1e000000) /* FIFO Empty */
#define LWL_TSI_TR (0x1f000000) /* Time-Status-Info Transp-Mode */ #define LWL_TSI_TR (0x1f000000) /* Time-Status-Info Transp-Mode */
#define LWL_TSI_HM_NC (0x1f000000) /* Time-Status-Info Hist-Mode+No-Coinc */ #define LWL_TSI_HM_NC (0x1f000000) /* Time-Status-Info Hist-Mode+No-Coinc */
#define LWL_TSI_HM_C (0x0e000000) /* Time-Status-Info Hist-Mode+Coinc */ #define LWL_TSI_HM_C (0x0e000000) /* Time-Status-Info Hist-Mode+Coinc */
#define LWL_TSI_TOF (0x1f000000) /* Time-Status-Info TOF-Mode */ #define LWL_TSI_TOF (0x1f000000) /* Time-Status-Info TOF-Mode */
#define LWL_TSI_SM_NC (0x1f000000) /* Time-Status-Info Strobo-Mode+No-Coin */ #define LWL_TSI_SM_NC (0x1f000000) /* Time-Status-Info Strobo-Mode+No-Coin */
#define LWL_TSI_SM_C (0x0e000000) /* Time-Status-Info Strobo-Mode+Coinc */ #define LWL_TSI_SM_C (0x0e000000) /* Time-Status-Info Strobo-Mode+Coinc */
#define LWL_TSI_DT_MSK (0x000fffff) /* Mask for Dead-Time in TSI */ #define LWL_TSI_DT_MSK (0x000fffff) /* Mask for Dead-Time in TSI */
#define LWL_TSI_DTS_MSK (0x000fffff) /* Mask for Delay-Time-to-Start in TSI */ #define LWL_TSI_DTS_MSK (0x000fffff) /* Mask for Delay-Time-to-Start in TSI */
#define LWL_TR_C1 (0x00000001) /* Transp. Mode Chan 1 */ #define LWL_TR_C1 (0x00000001) /* Transp. Mode Chan 1 */
#define LWL_TR_C2 (0x00000002) /* Transp. Mode Chan 2 */ #define LWL_TR_C2 (0x00000002) /* Transp. Mode Chan 2 */
#define LWL_TR_C3 (0x00000003) /* Transp. Mode Chan 3 */ #define LWL_TR_C3 (0x00000003) /* Transp. Mode Chan 3 */
#define LWL_TR_C4 (0x00000004) /* Transp. Mode Chan 4 */ #define LWL_TR_C4 (0x00000004) /* Transp. Mode Chan 4 */
#define LWL_TR_C5 (0x00000005) /* Transp. Mode Chan 5 */ #define LWL_TR_C5 (0x00000005) /* Transp. Mode Chan 5 */
#define LWL_TR_C6 (0x00000006) /* Transp. Mode Chan 6 */ #define LWL_TR_C6 (0x00000006) /* Transp. Mode Chan 6 */
#define LWL_TR_C7 (0x00000007) /* Transp. Mode Chan 7 */ #define LWL_TR_C7 (0x00000007) /* Transp. Mode Chan 7 */
#define LWL_TR_C8 (0x00000008) /* Transp. Mode Chan 8 */ #define LWL_TR_C8 (0x00000008) /* Transp. Mode Chan 8 */
#define LWL_TR_C9 (0x00000009) /* Transp. Mode Chan 9 */ #define LWL_TR_C9 (0x00000009) /* Transp. Mode Chan 9 */
#define LWL_HM_NC (0x10000000) /* Hist-Mode/No-Coinc 0 chan dgrm hdr */ #define LWL_HM_NC (0x10000000) /* Hist-Mode/No-Coinc 0 chan dgrm hdr */
#define LWL_HM_NC_C1 (0x11000000) /* Hist-Mode/No-Coinc 1 chan dgrm hdr */ #define LWL_HM_NC_C1 (0x11000000) /* Hist-Mode/No-Coinc 1 chan dgrm hdr */
#define LWL_HM_NC_C2 (0x12000000) /* Hist-Mode/No-Coinc 2 chan dgrm hdr */ #define LWL_HM_NC_C2 (0x12000000) /* Hist-Mode/No-Coinc 2 chan dgrm hdr */
#define LWL_HM_NC_C3 (0x13000000) /* Hist-Mode/No-Coinc 3 chan dgrm hdr */ #define LWL_HM_NC_C3 (0x13000000) /* Hist-Mode/No-Coinc 3 chan dgrm hdr */
#define LWL_HM_NC_C4 (0x14000000) /* Hist-Mode/No-Coinc 4 chan dgrm hdr */ #define LWL_HM_NC_C4 (0x14000000) /* Hist-Mode/No-Coinc 4 chan dgrm hdr */
#define LWL_HM_NC_C5 (0x15000000) /* Hist-Mode/No-Coinc 5 chan dgrm hdr */ #define LWL_HM_NC_C5 (0x15000000) /* Hist-Mode/No-Coinc 5 chan dgrm hdr */
#define LWL_HM_NC_C6 (0x16000000) /* Hist-Mode/No-Coinc 6 chan dgrm hdr */ #define LWL_HM_NC_C6 (0x16000000) /* Hist-Mode/No-Coinc 6 chan dgrm hdr */
#define LWL_HM_NC_C7 (0x17000000) /* Hist-Mode/No-Coinc 7 chan dgrm hdr */ #define LWL_HM_NC_C7 (0x17000000) /* Hist-Mode/No-Coinc 7 chan dgrm hdr */
#define LWL_HM_NC_C8 (0x18000000) /* Hist-Mode/No-Coinc 8 chan dgrm hdr */ #define LWL_HM_NC_C8 (0x18000000) /* Hist-Mode/No-Coinc 8 chan dgrm hdr */
#define LWL_HM_NC_C9 (0x19000000) /* Hist-Mode/No-Coinc 9 chan dgrm hdr */ #define LWL_HM_NC_C9 (0x19000000) /* Hist-Mode/No-Coinc 9 chan dgrm hdr */
#define LWL_HM_CO (0x10000000) /* Hist-Mode+Coinc 0 chan dgrm hdr */ #define LWL_HM_CO (0x10000000) /* Hist-Mode+Coinc 0 chan dgrm hdr */
#define LWL_HM_CO_C2 (0x12000000) /* Hist-Mode+Coinc 2 chan dgrm hdr */ #define LWL_HM_CO_C2 (0x12000000) /* Hist-Mode+Coinc 2 chan dgrm hdr */
#define LWL_HM_CO_C3 (0x13000000) /* Hist-Mode+Coinc 3 chan dgrm hdr */ #define LWL_HM_CO_C3 (0x13000000) /* Hist-Mode+Coinc 3 chan dgrm hdr */
#define LWL_HM_CO_C4 (0x14000000) /* Hist-Mode+Coinc 4 chan dgrm hdr */ #define LWL_HM_CO_C4 (0x14000000) /* Hist-Mode+Coinc 4 chan dgrm hdr */
#define LWL_HM_CO_C5 (0x15000000) /* Hist-Mode+Coinc 5 chan dgrm hdr */ #define LWL_HM_CO_C5 (0x15000000) /* Hist-Mode+Coinc 5 chan dgrm hdr */
#define LWL_HM_CO_C6 (0x16000000) /* Hist-Mode+Coinc 6 chan dgrm hdr */ #define LWL_HM_CO_C6 (0x16000000) /* Hist-Mode+Coinc 6 chan dgrm hdr */
#define LWL_HM_CO_C7 (0x17000000) /* Hist-Mode+Coinc 7 chan dgrm hdr */ #define LWL_HM_CO_C7 (0x17000000) /* Hist-Mode+Coinc 7 chan dgrm hdr */
#define LWL_HM_CO_C8 (0x18000000) /* Hist-Mode+Coinc 8 chan dgrm hdr */ #define LWL_HM_CO_C8 (0x18000000) /* Hist-Mode+Coinc 8 chan dgrm hdr */
#define LWL_HM_CO_C9 (0x19000000) /* Hist-Mode+Coinc 9 chan dgrm hdr */ #define LWL_HM_CO_C9 (0x19000000) /* Hist-Mode+Coinc 9 chan dgrm hdr */
#define LWL_TOF_C1 (0x01000000) /* TOF-Mode 1 chan dgrm hdr */ #define LWL_TOF_C1 (0x01000000) /* TOF-Mode 1 chan dgrm hdr */
#define LWL_TOF_C2 (0x02000000) /* TOF-Mode 2 chan dgrm hdr */ #define LWL_TOF_C2 (0x02000000) /* TOF-Mode 2 chan dgrm hdr */
#define LWL_TOF_C3 (0x03000000) /* TOF-Mode 3 chan dgrm hdr */ #define LWL_TOF_C3 (0x03000000) /* TOF-Mode 3 chan dgrm hdr */
#define LWL_TOF_C4 (0x04000000) /* TOF-Mode 4 chan dgrm hdr */ #define LWL_TOF_C4 (0x04000000) /* TOF-Mode 4 chan dgrm hdr */
#define LWL_TOF_C5 (0x05000000) /* TOF-Mode 5 chan dgrm hdr */ #define LWL_TOF_C5 (0x05000000) /* TOF-Mode 5 chan dgrm hdr */
#define LWL_TOF_C6 (0x06000000) /* TOF-Mode 6 chan dgrm hdr */ #define LWL_TOF_C6 (0x06000000) /* TOF-Mode 6 chan dgrm hdr */
#define LWL_TOF_C7 (0x07000000) /* TOF-Mode 7 chan dgrm hdr */ #define LWL_TOF_C7 (0x07000000) /* TOF-Mode 7 chan dgrm hdr */
#define LWL_TOF_C8 (0x08000000) /* TOF-Mode 8 chan dgrm hdr */ #define LWL_TOF_C8 (0x08000000) /* TOF-Mode 8 chan dgrm hdr */
#define LWL_TOF_C9 (0x09000000) /* TOF-Mode 9 chan dgrm hdr */ #define LWL_TOF_C9 (0x09000000) /* TOF-Mode 9 chan dgrm hdr */
#define LWL_PSD_TSI 0x0E000000 /* PSD-Mode TSI datagram */ #define LWL_PSD_TSI 0x0E000000 /* PSD-Mode TSI datagram */
#define LWL_PSD_DATA 0x12000000 /* PSD-mode data datagram */ #define LWL_PSD_DATA 0x12000000 /* PSD-mode data datagram */
#define LWL_PSD_PWF 0x20000000 /* PSD-mode Power Fail bit */ #define LWL_PSD_PWF 0x20000000 /* PSD-mode Power Fail bit */
#define LWL_PSD_TIME 0x000fffff /* PSD-mode time stamp extraction #define LWL_PSD_TIME 0x000fffff /* PSD-mode time stamp extraction
mask */ mask */
@ -226,258 +226,276 @@
#define LWL_PSD_XORF 0x2000 /* mask for TDC-XORF bit */ #define LWL_PSD_XORF 0x2000 /* mask for TDC-XORF bit */
#define LWL_PSD_CONF 0x0100 /* mask for TDC-CONF flag */ #define LWL_PSD_CONF 0x0100 /* mask for TDC-CONF flag */
#define LWL_SM_NC (0x10000000) /* Strobo-Mode/No-Coinc 0 chan dgrm hdr */ #define LWL_SM_NC (0x10000000) /* Strobo-Mode/No-Coinc 0 chan dgrm hdr */
#define LWL_SM_NC_C1 (0x11000000) /* Strobo-Mode/No-Coinc 1 chan dgrm hdr */ #define LWL_SM_NC_C1 (0x11000000) /* Strobo-Mode/No-Coinc 1 chan dgrm hdr */
#define LWL_SM_NC_C2 (0x12000000) /* Strobo-Mode/No-Coinc 2 chan dgrm hdr */ #define LWL_SM_NC_C2 (0x12000000) /* Strobo-Mode/No-Coinc 2 chan dgrm hdr */
#define LWL_SM_NC_C3 (0x13000000) /* Strobo-Mode/No-Coinc 3 chan dgrm hdr */ #define LWL_SM_NC_C3 (0x13000000) /* Strobo-Mode/No-Coinc 3 chan dgrm hdr */
#define LWL_SM_NC_C4 (0x14000000) /* Strobo-Mode/No-Coinc 4 chan dgrm hdr */ #define LWL_SM_NC_C4 (0x14000000) /* Strobo-Mode/No-Coinc 4 chan dgrm hdr */
#define LWL_SM_NC_C5 (0x15000000) /* Strobo-Mode/No-Coinc 5 chan dgrm hdr */ #define LWL_SM_NC_C5 (0x15000000) /* Strobo-Mode/No-Coinc 5 chan dgrm hdr */
#define LWL_SM_NC_C6 (0x16000000) /* Strobo-Mode/No-Coinc 6 chan dgrm hdr */ #define LWL_SM_NC_C6 (0x16000000) /* Strobo-Mode/No-Coinc 6 chan dgrm hdr */
#define LWL_SM_NC_C7 (0x17000000) /* Strobo-Mode/No-Coinc 7 chan dgrm hdr */ #define LWL_SM_NC_C7 (0x17000000) /* Strobo-Mode/No-Coinc 7 chan dgrm hdr */
#define LWL_SM_NC_C8 (0x18000000) /* Strobo-Mode/No-Coinc 8 chan dgrm hdr */ #define LWL_SM_NC_C8 (0x18000000) /* Strobo-Mode/No-Coinc 8 chan dgrm hdr */
#define LWL_SM_NC_C9 (0x19000000) /* Strobo-Mode/No-Coinc 9 chan dgrm hdr */ #define LWL_SM_NC_C9 (0x19000000) /* Strobo-Mode/No-Coinc 9 chan dgrm hdr */
#define LWL_SM_CO (0x10000000) /* Strobo-Mode + Coinc 0 chan dgrm hdr */ #define LWL_SM_CO (0x10000000) /* Strobo-Mode + Coinc 0 chan dgrm hdr */
#define LWL_SM_CO_C1 (0x11000000) /* Strobo-Mode + Coinc 1 chan dgrm hdr */ #define LWL_SM_CO_C1 (0x11000000) /* Strobo-Mode + Coinc 1 chan dgrm hdr */
#define LWL_SM_CO_C2 (0x12000000) /* Strobo-Mode + Coinc 2 chan dgrm hdr */ #define LWL_SM_CO_C2 (0x12000000) /* Strobo-Mode + Coinc 2 chan dgrm hdr */
#define LWL_SM_CO_C3 (0x13000000) /* Strobo-Mode + Coinc 3 chan dgrm hdr */ #define LWL_SM_CO_C3 (0x13000000) /* Strobo-Mode + Coinc 3 chan dgrm hdr */
#define LWL_SM_CO_C4 (0x14000000) /* Strobo-Mode + Coinc 4 chan dgrm hdr */ #define LWL_SM_CO_C4 (0x14000000) /* Strobo-Mode + Coinc 4 chan dgrm hdr */
#define LWL_SM_CO_C5 (0x15000000) /* Strobo-Mode + Coinc 5 chan dgrm hdr */ #define LWL_SM_CO_C5 (0x15000000) /* Strobo-Mode + Coinc 5 chan dgrm hdr */
#define LWL_SM_CO_C6 (0x16000000) /* Strobo-Mode + Coinc 6 chan dgrm hdr */ #define LWL_SM_CO_C6 (0x16000000) /* Strobo-Mode + Coinc 6 chan dgrm hdr */
#define LWL_SM_CO_C7 (0x17000000) /* Strobo-Mode + Coinc 7 chan dgrm hdr */ #define LWL_SM_CO_C7 (0x17000000) /* Strobo-Mode + Coinc 7 chan dgrm hdr */
#define LWL_SM_CO_C8 (0x18000000) /* Strobo-Mode + Coinc 8 chan dgrm hdr */ #define LWL_SM_CO_C8 (0x18000000) /* Strobo-Mode + Coinc 8 chan dgrm hdr */
#define LWL_SM_CO_C9 (0x19000000) /* Strobo-Mode + Coinc 9 chan dgrm hdr */ #define LWL_SM_CO_C9 (0x19000000) /* Strobo-Mode + Coinc 9 chan dgrm hdr */
#define LWL_TSI_MODE_MASK (0x000e) /* Mask for mode in Time Status Info */ #define LWL_TSI_MODE_MASK (0x000e) /* Mask for mode in Time Status Info */
#define LWL_TSI_MODE_TR (0x0000) /* TSI Transparent-Mode */ #define LWL_TSI_MODE_TR (0x0000) /* TSI Transparent-Mode */
#define LWL_TSI_MODE_HM (0x0002) /* TSI Hist-Mode */ #define LWL_TSI_MODE_HM (0x0002) /* TSI Hist-Mode */
#define LWL_TSI_MODE_TOF (0x0004) /* TSI TOF-Mode */ #define LWL_TSI_MODE_TOF (0x0004) /* TSI TOF-Mode */
#define LWL_TSI_MODE_SM1 (0x0006) /* TSI Strobo-Mode 1 - time-stamp coded */ #define LWL_TSI_MODE_SM1 (0x0006) /* TSI Strobo-Mode 1 - time-stamp coded */
#define LWL_TSI_MODE_TR_UD (0x0008) /* TSI Transparent-Mode Up-Down */ #define LWL_TSI_MODE_TR_UD (0x0008) /* TSI Transparent-Mode Up-Down */
#define LWL_TSI_MODE_HM_UD (0x000a) /* TSI Hist-Mode Up-Down */ #define LWL_TSI_MODE_HM_UD (0x000a) /* TSI Hist-Mode Up-Down */
#define LWL_TSI_MODE_TOF_UD (0x000c) /* TSI TOF-Mode Up-Down */ #define LWL_TSI_MODE_TOF_UD (0x000c) /* TSI TOF-Mode Up-Down */
#define LWL_TSI_MODE_SM2 (0x000e) /* TSI Strobo-Mode 2 - h/w coded */ #define LWL_TSI_MODE_SM2 (0x000e) /* TSI Strobo-Mode 2 - h/w coded */
/* /*
**------------------------------------------------------------------------------ **------------------------------------------------------------------------------
** Define structure of a TOF histogram data item. ** Define structure of a TOF histogram data item.
*/ */
struct tof_histog { struct tof_histog {
int cntr_nmbr; /* Counter number */ int cntr_nmbr; /* Counter number */
uint lo_edge; /* Low edge of first bin (20-bit value) */ uint lo_edge; /* Low edge of first bin (20-bit value) */
uint hi_edge; /* Top edge of last bin (20-bit value) */ uint hi_edge; /* Top edge of last bin (20-bit value) */
usint flag; /* Bit mask giving info on histog -- may be usint flag; /* Bit mask giving info on histog -- may be
** used to help optimise the code */ ** used to help optimise the code */
usint bytes_per_bin; /* Number of bytes in each histogram bin */ usint bytes_per_bin; /* Number of bytes in each histogram bin */
uint n_bins; /* Number of bins in histogram */ uint n_bins; /* Number of bins in histogram */
uint cnt_early_up; /* Count of early events (pol'n up) */ uint cnt_early_up; /* Count of early events (pol'n up) */
uint cnt_late_up; /* Count of late events (pol'n up) */ uint cnt_late_up; /* Count of late events (pol'n up) */
uint cnt_early_down; /* Count of early events (pol'n down) */ uint cnt_early_down; /* Count of early events (pol'n down) */
uint cnt_late_down; /* Count of late events (pol'n down) */ uint cnt_late_down; /* Count of late events (pol'n down) */
uint *bin_edge; /* Pointer to array of bin edges */ uint *bin_edge; /* Pointer to array of bin edges */
union { /* Pointer to histogram array */ union { /* Pointer to histogram array */
uchar *b_bin_data; /* .. pointer if it's 8-bit bins */ uchar *b_bin_data; /* .. pointer if it's 8-bit bins */
usint *w_bin_data; /* .. pointer if it's 16-bit bins */ usint *w_bin_data; /* .. pointer if it's 16-bit bins */
uint *l_bin_data; /* .. pointer if it's 32-bit bins */ uint *l_bin_data; /* .. pointer if it's 32-bit bins */
} u; } u;
}; };
/* Define a TOF 'edge-info' structure. This structure is created /* Define a TOF 'edge-info' structure. This structure is created
** as a result of a TOF 'edge-array' in a SQHM__TOF config cmnd. ** as a result of a TOF 'edge-array' in a SQHM__TOF config cmnd.
*/ */
struct tof_edge_info { struct tof_edge_info {
uint n_bins; /* Number of bins in histogram */ uint n_bins; /* Number of bins in histogram */
uint flag; /* Flag bits defining type of histo */ uint flag; /* Flag bits defining type of histo */
uint bin_span; /* Time spanned by a histogram bin (20-bit uint bin_span; /* Time spanned by a histogram bin (20-bit
** value) if bin width is constant. Otherwise ** value) if bin width is constant. Otherwise
** it is zero. */ ** it is zero. */
uint hi_edge; /* Top edge of last bin (20-bit value) */ uint hi_edge; /* Top edge of last bin (20-bit value) */
uint edges[2]; /* Array of edge data (20-bit values). There uint edges[2]; /* Array of edge data (20-bit values). There
** are actually (n_bins+1) items in the array ** are actually (n_bins+1) items in the array
** and give the bottom edges of the bin */ ** and give the bottom edges of the bin */
}; };
/* Define structure of a TOF 'edge-array' in SQHM__TOF config cmnd /* Define structure of a TOF 'edge-array' in SQHM__TOF config cmnd
*/ */
struct tof_edge_arr { struct tof_edge_arr {
uint n_bins; /* Number of bins in histogram */ uint n_bins; /* Number of bins in histogram */
uint flag; /* Flag (0/1) for fixed/variable bin size */ uint flag; /* Flag (0/1) for fixed/variable bin size */
uint *edges; /* Array of bottom edges (20-bit values) */ uint *edges; /* Array of bottom edges (20-bit values) */
}; };
/* Define structure of a TOF 'bank' in SQHM__TOF config command /* Define structure of a TOF 'bank' in SQHM__TOF config command
*/ */
struct tof_bank { struct tof_bank {
usint first; /* Number of first counter in bank */ usint first; /* Number of first counter in bank */
usint n_cntrs; /* Number of counters in bank */ usint n_cntrs; /* Number of counters in bank */
usint edge_indx; /* Index of edge array */ usint edge_indx; /* Index of edge array */
usint bytes_per_bin; /* Number of bytes per bin */ usint bytes_per_bin; /* Number of bytes per bin */
}; };
/* /*
**------------------------------------------------------------------------------ **------------------------------------------------------------------------------
** Define command structure. ** Define command structure.
*/ */
struct req_buff_struct { /* For messages to SinqHM */ struct req_buff_struct { /* For messages to SinqHM */
uint bigend; uint bigend;
uint cmnd; uint cmnd;
union {
char filler[56];
struct {
uint max_pkt, strt_mode;
} cnct;
struct {
uint mode;
union { union {
char filler[56]; struct {
uint n_buffs;
struct {uint max_pkt, uint n_bytes;
strt_mode;} cnct; } trans;
struct {
struct {uint mode; uint n_hists;
union { uint lo_bin;
struct { uint num_bins;
uint n_buffs; uint bytes_per_bin;
uint n_bytes; uint compress;
} trans; } hm_dig;
struct { struct {
uint n_hists; uint n_extra_bytes;
uint lo_bin; usint n_edges;
uint num_bins; usint n_banks;
uint bytes_per_bin; uint preset_delay;
uint compress; struct tof_edge_arr edge_0;
} hm_dig; struct tof_bank bank_0;
struct { } tof;
uint n_extra_bytes; struct {
usint n_edges; uint n_extra_bytes;
usint n_banks; usint n_edges;
uint preset_delay; usint n_banks;
struct tof_edge_arr edge_0; uint preset_delay;
struct tof_bank bank_0; usint xFactor;
} tof; usint yFactor;
struct { usint xOffset;
uint n_extra_bytes; usint yOffset;
usint n_edges; usint xSize;
usint n_banks; usint ySize;
uint preset_delay; struct tof_edge_arr edge_0;
usint xFactor; struct tof_bank bank_0;
usint yFactor; } psd;
usint xOffset;
usint yOffset;
usint xSize;
usint ySize;
struct tof_edge_arr edge_0;
struct tof_bank bank_0;
} psd;
} u;
} cnfg;
struct {uint mask;} dbg;
struct {uint sub_code;} decnfg;
struct {uint sub_cmnd;} daq;
struct {uint sub_code,
x_lo,
nx,
y_lo,
ny,
xdim,
nhist;} project;
struct {uint hist_no,
first_bin,
n_bins;} read;
struct {uint hist_no;} select;
struct {uint hist_no,
first_bin,
n_bins,
bytes_per_bin;} write;
struct {uint hist_no,
first_bin,
n_bins;} zero;
} u; } u;
}; } cnfg;
struct {
uint mask;
} dbg;
struct {
uint sub_code;
} decnfg;
struct {
uint sub_cmnd;
} daq;
struct {
uint sub_code, x_lo, nx, y_lo, ny, xdim, nhist;
} project;
struct {
uint hist_no, first_bin, n_bins;
} read;
struct {
uint hist_no;
} select;
struct {
uint hist_no, first_bin, n_bins, bytes_per_bin;
} write;
struct {
uint hist_no, first_bin, n_bins;
} zero;
} u;
};
/* /*
**------------------------------------------------------------------------------ **------------------------------------------------------------------------------
** Define status response structure. ** Define status response structure.
*/ */
struct rply_buff_struct { /* For messages from SinqHM */ struct rply_buff_struct { /* For messages from SinqHM */
uint bigend; uint bigend;
uint status; uint status;
uint sub_status; uint sub_status;
union {
char message[52];
struct {
uint port;
uint pkt_size;
uint hm_mode;
uint n_hists;
uint num_bins;
uint bytes_per_bin;
uint curr_hist;
uint max_block;
uint total_bytes;
uint lo_cntr;
uint lo_bin;
uint compress;
uint up_time;
} cnct;
struct {
usint daq_now;
usint daq_was;
usint filler_mask;
usint server_mask;
} daq;
struct {
uint n_extra_bytes;
uint up_time;
usint offset_vxWorks_ident;
usint offset_vxWorks_date;
usint offset_instr;
usint offset_def_ident;
usint offset_sinqhm_main_ident;
usint offset_sinqhm_main_date;
usint offset_sinqhm_server_ident;
usint offset_sinqhm_server_date;
usint offset_sinqhm_filler_ident;
usint offset_sinqhm_filler_date;
usint offset_sinqhm_routines_ident;
usint offset_sinqhm_routines_date;
} ident;
struct {
uint n_bins;
uint bytes_per_bin;
uint cnts_lo;
uint cnts_hi;
} project;
struct {
uint first_bin;
uint n_bins;
uint bytes_per_bin;
uint cnts_lo;
uint cnts_hi;
} read;
struct {
uint cfg_state;
usint n_hists, curr_hist;
uint num_bins;
uint max_n_hists;
uint max_num_bins;
uchar max_srvrs, act_srvrs, bytes_per_bin, compress;
usint daq_now, filler_mask;
uint max_block;
usint tsi_status, flags;
union { union {
char message[52]; uint dead_time;
uint dts;
struct {uint port; uint both;
uint pkt_size; } dt_or_dts;
uint hm_mode; uint num_bad_events;
uint n_hists; uint up_time;
uint num_bins; } status;
uint bytes_per_bin; } u;
uint curr_hist; };
uint max_block;
uint total_bytes;
uint lo_cntr;
uint lo_bin;
uint compress;
uint up_time;} cnct;
struct {usint daq_now;
usint daq_was;
usint filler_mask;
usint server_mask;} daq;
struct {uint n_extra_bytes;
uint up_time;
usint offset_vxWorks_ident;
usint offset_vxWorks_date;
usint offset_instr;
usint offset_def_ident;
usint offset_sinqhm_main_ident;
usint offset_sinqhm_main_date;
usint offset_sinqhm_server_ident;
usint offset_sinqhm_server_date;
usint offset_sinqhm_filler_ident;
usint offset_sinqhm_filler_date;
usint offset_sinqhm_routines_ident;
usint offset_sinqhm_routines_date;} ident;
struct {uint n_bins;
uint bytes_per_bin;
uint cnts_lo;
uint cnts_hi;} project;
struct {uint first_bin;
uint n_bins;
uint bytes_per_bin;
uint cnts_lo;
uint cnts_hi;} read;
struct {uint cfg_state;
usint n_hists, curr_hist;
uint num_bins;
uint max_n_hists;
uint max_num_bins;
uchar max_srvrs, act_srvrs, bytes_per_bin, compress;
usint daq_now, filler_mask;
uint max_block;
usint tsi_status, flags;
union {
uint dead_time;
uint dts;
uint both;
} dt_or_dts;
uint num_bad_events;
uint up_time;} status;
} u;
};
/* /*
**------------------------------------------------------------------------------ **------------------------------------------------------------------------------
** Define structure of message to SinqHM-filler. ** Define structure of message to SinqHM-filler.
*/ */
struct msg_to_filler_struct { /* For messages to SinqHM-filler */ struct msg_to_filler_struct { /* For messages to SinqHM-filler */
union { union {
char message[32]; /* Ensure buffer is 32 bytes total */ char message[32]; /* Ensure buffer is 32 bytes total */
struct { struct {
uint cmnd; uint cmnd;
uint index; uint index;
usint new_mask;} uu; usint new_mask;
} u; } uu;
}; } u;
};
/*======================================================= End of SinqHM_def.h */ /*======================================================= End of SinqHM_def.h */

View File

@ -163,253 +163,324 @@
** strncpy to be sure result is always ** strncpy to be sure result is always
** null terminated. ** null terminated.
*/ */
char *StrEdit ( char *StrEdit(
/* ======= /* =======
*/ char *out, */ char *out,
char *in, char *in, char *ctrl, int *ln)
char *ctrl, {
int *ln) {
int i, j, k, l, m, len, inxt, out_size; int i, j, k, l, m, len, inxt, out_size;
char my_ctrl[80]; char my_ctrl[80];
char *tok_nxt, *my_in, *my_out, *my_tmp, *nxt; char *tok_nxt, *my_in, *my_out, *my_tmp, *nxt;
int do_collapse, do_compress, do_lowercase, do_trim; int do_collapse, do_compress, do_lowercase, do_trim;
int do_uncomment, do_upcase; int do_uncomment, do_upcase;
out_size = *ln; out_size = *ln;
if (out_size < 1) {*ln = 0; return NULL;} /* Can't do anything!! */ if (out_size < 1) {
*ln = 0;
if (strlen (in) <= 0) { return NULL;
*out = NIL; *ln = 0; return out; /* Nothing to do!! */
}
/*
** Scan ctrl looking to see what has to be done. Do this by first
** taking a copy of it (in case it is declared "const" in the calling
** routine, convert to lowercase and split into tokens at any space,
** tab or comma.
*/
len = strlen (ctrl);
if (len >= sizeof (my_ctrl)) {
*out = NIL; *ln = 0; return NULL;
}
for (i = 0; i <= len; i++) my_ctrl[i] = tolower (ctrl[i]);
do_collapse = do_compress = do_lowercase = do_trim = do_uncomment =
do_upcase = False;
tok_nxt = strtok (my_ctrl, ", \t\f\v\n");
while (tok_nxt != NULL) {
if (strcmp (tok_nxt, "collapse") == 0) {
do_collapse = True;
}else if (strcmp (tok_nxt, "compress") == 0) {
do_compress = True;
}else if (strcmp (tok_nxt, "lowercase") == 0) {
do_lowercase = True;
}else if (strcmp (tok_nxt, "trim") == 0) {
do_trim = True;
}else if (strcmp (tok_nxt, "uncomment") == 0) {
do_uncomment = True;
}else if (strcmp (tok_nxt, "upcase") == 0) {
do_upcase = True;
}else {
*out = NIL; *ln = 0; return NULL; /* Illegal ctrl verb */
}
tok_nxt = strtok (NULL, ", \t\f\v\n");
}
len = strlen (in) + 1;
my_in = malloc (len); /* Get some working space */
if (my_in == NULL) {
*out = NIL; *ln = 0; return NULL;
}
/*
** Copy "in" to the "my_in" working space, processing any '\' escape
** sequences as we go. Note that, since "my_in" is big enough to hold
** "in" and the escape sequence processing can only shorten the length
** of "in", there's no need to check for an overflow of "my_in". Any
** non-escaped double quotes are converted to something special so
** that they can be recognised at the editing stage.
*/
nxt = my_in;
while (*in != '\0') {
if (*in == '\\') { /* Look for escape sequence */
in++;
switch (*in) {
case 'a': case 'A': *nxt++ = '\007'; in++; break;
case 'b': case 'B': *nxt++ = '\010'; in++; break;
case 'f': case 'F': *nxt++ = '\014'; in++; break;
case 'n': case 'N': *nxt++ = '\012'; in++; break;
case 'r': case 'R': *nxt++ = '\015'; in++; break;
case 't': case 'T': *nxt++ = '\011'; in++; break;
case 'v': case 'V': *nxt++ = '\013'; in++; break;
case '\\': *nxt++ = '\\'; in++; break;
case '\'': *nxt++ = '\''; in++; break;
case '\"': *nxt++ = '\"'; in++; break;
case '\?': *nxt++ = '\?'; in++; break;
case 'x': case 'X':
in++;
i = strspn (in, "0123456789abcdefABCDEF");
if (i > 0) {
*nxt++ = strtol (in, &in, 16); break;
}else {
*nxt++ = '\\'; break;
}
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
i = strspn (in, "01234567");
if (i > 3) {
sscanf (in, "%3o", &j);
*nxt++ = j;
in += 3;
break;
}else if (i > 0) {
sscanf (in, "%o", &j);
*nxt++ = j;
in += i;
break;
}else {
*nxt++ = '\\';
break;
}
default:
*nxt++ = '\\'; /* Invalid esc sequ - just copy it */
}
}else if (*in == '\"') { /* Look for non-escaped double quotes */
*nxt++ = QUOTE; *in++; /* Make it something unlikely */
}else {
*nxt++ = *in++;
}
}
*nxt = '\0';
my_out = malloc (len); /* Get some working space */
if (my_out == NULL) {
free (my_in); *out = NIL; *ln = 0; return NULL;
}
*my_out = NIL;
my_tmp = malloc (len); /* Get some working space */
if (my_tmp == NULL) {
free (my_out); free (my_in);
*out = NIL; *ln = 0; return NULL;
}
*my_tmp = NIL;
*out = NIL;
/*
** Ensure "in" has an even number of non-escaped quotes. Return if not.
*/
i = 0;
for (j = 0; my_in[j] != NIL; j++) if (my_in[j] == QUOTE) i++;
if ((i & 1) == 1) {
free (my_tmp);
free (my_out);
free (my_in);
*ln = strlen (out);
return NULL;
}
/*
** Scan through "in", substring by substring, to
** handle quotation marks correctly.
*/
inxt = 0;
while (my_in[inxt] != NIL) {
if (my_in[inxt] == QUOTE) { /* Is there a quoted string next? */
nxt = strchr (&my_in[inxt+1], QUOTE); /* Yes, find matching quote. */
j = nxt - &my_in[inxt+1];
memcpy (my_tmp, &my_in[inxt+1], j); /* Make copy of it */
my_tmp[j] = NIL;
inxt = inxt + j + 2;
}else {
nxt = strchr (&my_in[inxt], QUOTE); /* Not a quoted string; ..
** .. find next non-escaped ..
** .. quote.
*/
if (nxt != NULL) {
j = nxt - my_in - inxt;
}else {
j = strlen (&my_in[inxt]);
}
memcpy (my_tmp, &my_in[inxt], j); /* Make copy for us to work on */
my_tmp[j] = NIL;
inxt = inxt + j;
/*
** For collapse and compress, start by turning all white space
** chars to spaces.
*/
if (do_collapse || do_compress) {
for (k = 0; my_tmp[k] != NIL; k++) {
if (my_tmp[k] == '\t') my_tmp[k] = ' ';
if (my_tmp[k] == '\f') my_tmp[k] = ' ';
if (my_tmp[k] == '\v') my_tmp[k] = ' ';
if (my_tmp[k] == '\n') my_tmp[k] = ' ';
}
if (do_collapse) {
l = 0;
for (k = 0; my_tmp[k] != NIL; k++) {
if (my_tmp[k] != ' ') {
my_tmp[l] = my_tmp[k];
l++;
}
}
my_tmp[l] = NIL;
}else if (do_compress) {
for (k = 0; my_tmp[k] != NIL; k++) {
if (my_tmp[k] == ' ') {
l = strspn (&my_tmp[k], " ");
if (l > 1) {
for (m = 0; my_tmp[k+l+m] != NIL; m++) {
my_tmp[k+m+1] = my_tmp[k+l+m];
}
my_tmp[k+m+1] = NIL;
}
}
}
}
}
if (do_lowercase) {
for (k = 0; my_tmp[k] != NIL; k++) my_tmp[k] = _tolower (my_tmp[k]);
}
if (do_upcase) {
for (k = 0; my_tmp[k] != NIL; k++) my_tmp[k] = _toupper (my_tmp[k]);
}
if (do_uncomment) {
nxt = strchr (my_tmp, '!');
if (nxt != NULL) {
*nxt = NIL; /* Truncate the string at the "!" */
my_in[inxt] = NIL; /* Stop processing loop too */
}
}
}
StrJoin (out, out_size, my_out, my_tmp);
strcpy (my_out, out);
}
if (do_trim) {
i = strspn (my_out, " ");
if (i == strlen (my_out)) { /* If all spaces, result is a null string */
*out = NIL;
}else {
for (j = strlen (my_out); my_out[j-1] == ' '; j--);
my_out[j] = NIL;
}
strcpy (out, &my_out[i]);
}
free (my_tmp);
free (my_out);
free (my_in);
*ln = strlen (out);
/*
** Undo any encoded escape characters.
*/
for (i = 0; out[i] != NIL; i++) {
if (out[i] == ~'\"') out[i] = '\"';
}
return out;
} }
/* Can't do anything!! */
if (strlen(in) <= 0) {
*out = NIL;
*ln = 0;
return out; /* Nothing to do!! */
}
/*
** Scan ctrl looking to see what has to be done. Do this by first
** taking a copy of it (in case it is declared "const" in the calling
** routine, convert to lowercase and split into tokens at any space,
** tab or comma.
*/
len = strlen(ctrl);
if (len >= sizeof(my_ctrl)) {
*out = NIL;
*ln = 0;
return NULL;
}
for (i = 0; i <= len; i++)
my_ctrl[i] = tolower(ctrl[i]);
do_collapse = do_compress = do_lowercase = do_trim = do_uncomment =
do_upcase = False;
tok_nxt = strtok(my_ctrl, ", \t\f\v\n");
while (tok_nxt != NULL) {
if (strcmp(tok_nxt, "collapse") == 0) {
do_collapse = True;
} else if (strcmp(tok_nxt, "compress") == 0) {
do_compress = True;
} else if (strcmp(tok_nxt, "lowercase") == 0) {
do_lowercase = True;
} else if (strcmp(tok_nxt, "trim") == 0) {
do_trim = True;
} else if (strcmp(tok_nxt, "uncomment") == 0) {
do_uncomment = True;
} else if (strcmp(tok_nxt, "upcase") == 0) {
do_upcase = True;
} else {
*out = NIL;
*ln = 0;
return NULL; /* Illegal ctrl verb */
}
tok_nxt = strtok(NULL, ", \t\f\v\n");
}
len = strlen(in) + 1;
my_in = malloc(len); /* Get some working space */
if (my_in == NULL) {
*out = NIL;
*ln = 0;
return NULL;
}
/*
** Copy "in" to the "my_in" working space, processing any '\' escape
** sequences as we go. Note that, since "my_in" is big enough to hold
** "in" and the escape sequence processing can only shorten the length
** of "in", there's no need to check for an overflow of "my_in". Any
** non-escaped double quotes are converted to something special so
** that they can be recognised at the editing stage.
*/
nxt = my_in;
while (*in != '\0') {
if (*in == '\\') { /* Look for escape sequence */
in++;
switch (*in) {
case 'a':
case 'A':
*nxt++ = '\007';
in++;
break;
case 'b':
case 'B':
*nxt++ = '\010';
in++;
break;
case 'f':
case 'F':
*nxt++ = '\014';
in++;
break;
case 'n':
case 'N':
*nxt++ = '\012';
in++;
break;
case 'r':
case 'R':
*nxt++ = '\015';
in++;
break;
case 't':
case 'T':
*nxt++ = '\011';
in++;
break;
case 'v':
case 'V':
*nxt++ = '\013';
in++;
break;
case '\\':
*nxt++ = '\\';
in++;
break;
case '\'':
*nxt++ = '\'';
in++;
break;
case '\"':
*nxt++ = '\"';
in++;
break;
case '\?':
*nxt++ = '\?';
in++;
break;
case 'x':
case 'X':
in++;
i = strspn(in, "0123456789abcdefABCDEF");
if (i > 0) {
*nxt++ = strtol(in, &in, 16);
break;
} else {
*nxt++ = '\\';
break;
}
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
i = strspn(in, "01234567");
if (i > 3) {
sscanf(in, "%3o", &j);
*nxt++ = j;
in += 3;
break;
} else if (i > 0) {
sscanf(in, "%o", &j);
*nxt++ = j;
in += i;
break;
} else {
*nxt++ = '\\';
break;
}
default:
*nxt++ = '\\'; /* Invalid esc sequ - just copy it */
}
} else if (*in == '\"') { /* Look for non-escaped double quotes */
*nxt++ = QUOTE;
*in++; /* Make it something unlikely */
} else {
*nxt++ = *in++;
}
}
*nxt = '\0';
my_out = malloc(len); /* Get some working space */
if (my_out == NULL) {
free(my_in);
*out = NIL;
*ln = 0;
return NULL;
}
*my_out = NIL;
my_tmp = malloc(len); /* Get some working space */
if (my_tmp == NULL) {
free(my_out);
free(my_in);
*out = NIL;
*ln = 0;
return NULL;
}
*my_tmp = NIL;
*out = NIL;
/*
** Ensure "in" has an even number of non-escaped quotes. Return if not.
*/
i = 0;
for (j = 0; my_in[j] != NIL; j++)
if (my_in[j] == QUOTE)
i++;
if ((i & 1) == 1) {
free(my_tmp);
free(my_out);
free(my_in);
*ln = strlen(out);
return NULL;
}
/*
** Scan through "in", substring by substring, to
** handle quotation marks correctly.
*/
inxt = 0;
while (my_in[inxt] != NIL) {
if (my_in[inxt] == QUOTE) { /* Is there a quoted string next? */
nxt = strchr(&my_in[inxt + 1], QUOTE); /* Yes, find matching quote. */
j = nxt - &my_in[inxt + 1];
memcpy(my_tmp, &my_in[inxt + 1], j); /* Make copy of it */
my_tmp[j] = NIL;
inxt = inxt + j + 2;
} else {
nxt = strchr(&my_in[inxt], QUOTE); /* Not a quoted string; ..
** .. find next non-escaped ..
** .. quote.
*/
if (nxt != NULL) {
j = nxt - my_in - inxt;
} else {
j = strlen(&my_in[inxt]);
}
memcpy(my_tmp, &my_in[inxt], j); /* Make copy for us to work on */
my_tmp[j] = NIL;
inxt = inxt + j;
/*
** For collapse and compress, start by turning all white space
** chars to spaces.
*/
if (do_collapse || do_compress) {
for (k = 0; my_tmp[k] != NIL; k++) {
if (my_tmp[k] == '\t')
my_tmp[k] = ' ';
if (my_tmp[k] == '\f')
my_tmp[k] = ' ';
if (my_tmp[k] == '\v')
my_tmp[k] = ' ';
if (my_tmp[k] == '\n')
my_tmp[k] = ' ';
}
if (do_collapse) {
l = 0;
for (k = 0; my_tmp[k] != NIL; k++) {
if (my_tmp[k] != ' ') {
my_tmp[l] = my_tmp[k];
l++;
}
}
my_tmp[l] = NIL;
} else if (do_compress) {
for (k = 0; my_tmp[k] != NIL; k++) {
if (my_tmp[k] == ' ') {
l = strspn(&my_tmp[k], " ");
if (l > 1) {
for (m = 0; my_tmp[k + l + m] != NIL; m++) {
my_tmp[k + m + 1] = my_tmp[k + l + m];
}
my_tmp[k + m + 1] = NIL;
}
}
}
}
}
if (do_lowercase) {
for (k = 0; my_tmp[k] != NIL; k++)
my_tmp[k] = _tolower(my_tmp[k]);
}
if (do_upcase) {
for (k = 0; my_tmp[k] != NIL; k++)
my_tmp[k] = _toupper(my_tmp[k]);
}
if (do_uncomment) {
nxt = strchr(my_tmp, '!');
if (nxt != NULL) {
*nxt = NIL; /* Truncate the string at the "!" */
my_in[inxt] = NIL; /* Stop processing loop too */
}
}
}
StrJoin(out, out_size, my_out, my_tmp);
strcpy(my_out, out);
}
if (do_trim) {
i = strspn(my_out, " ");
if (i == strlen(my_out)) { /* If all spaces, result is a null string */
*out = NIL;
} else {
for (j = strlen(my_out); my_out[j - 1] == ' '; j--);
my_out[j] = NIL;
}
strcpy(out, &my_out[i]);
}
free(my_tmp);
free(my_out);
free(my_in);
*ln = strlen(out);
/*
** Undo any encoded escape characters.
*/
for (i = 0; out[i] != NIL; i++) {
if (out[i] == ~'\"')
out[i] = '\"';
}
return out;
}
/*-------------------------------------------------- End of StrEdit.C -------*/ /*-------------------------------------------------- End of StrEdit.C -------*/

View File

@ -89,54 +89,57 @@
** strncpy to be sure result is always ** strncpy to be sure result is always
** null terminated. ** null terminated.
*/ */
char *StrJoin ( char *StrJoin(
/* ======= /* =======
*/ char *result, */ char *result,
int result_size, int result_size, char *str_a, char *str_b)
char *str_a, {
char *str_b) {
int i, size, size_a, size_b; int i, size, size_a, size_b;
size = result_size - 1; size = result_size - 1;
if (size < 0) return result; if (size < 0)
if (result == str_a) { /* Are the result and str_a the same? */
size_a = strlen (str_a); /* Yes */
if (size_a > size) { /* Check sizes anyway. */
result[size] = NIL; /* Truncate str_a. No room for str_b! */
}else {
size = size - strlen (result); /* And append str_b */
if (size > 0) {
strncat (result, str_b, size);
}
}
}else if (result == str_b) { /* Are the result and str_b the same? */
size_a = strlen (str_a); /* Yes, this is a bit complicated! */
size_b = strlen (str_b);
if (size_a >= size) { /* If str_a completely fills result, .. */
result[0] = NIL; /* .. then just copy in str_a */
strncat (result, str_a, size);
}else {
/*
** Otherwise, str_b must first be moved to
** make room for str_a and then str_a must
** be put at the front of the result.
*/
if ((size_a + size_b) > size) size_b = size - size_a;
result[size_a+size_b] = NIL;
for (i = (size_b-1); i >= 0; i--) {
result[size_a+i] = str_b[i];
}
memcpy (result, str_a, size_a);
}
}else { /* Result is neither str_a nor str_b so .. */
result[0] = NIL; /* .. str_a needs to be copied */
strncat (result, str_a, size);
size = size - strlen (result); /* And str_a appended */
if (size > 0) strncat (result, str_b, size);
}
return result; return result;
if (result == str_a) { /* Are the result and str_a the same? */
size_a = strlen(str_a); /* Yes */
if (size_a > size) { /* Check sizes anyway. */
result[size] = NIL; /* Truncate str_a. No room for str_b! */
} else {
size = size - strlen(result); /* And append str_b */
if (size > 0) {
strncat(result, str_b, size);
}
}
} else if (result == str_b) { /* Are the result and str_b the same? */
size_a = strlen(str_a); /* Yes, this is a bit complicated! */
size_b = strlen(str_b);
if (size_a >= size) { /* If str_a completely fills result, .. */
result[0] = NIL; /* .. then just copy in str_a */
strncat(result, str_a, size);
} else {
/*
** Otherwise, str_b must first be moved to
** make room for str_a and then str_a must
** be put at the front of the result.
*/
if ((size_a + size_b) > size)
size_b = size - size_a;
result[size_a + size_b] = NIL;
for (i = (size_b - 1); i >= 0; i--) {
result[size_a + i] = str_b[i];
}
memcpy(result, str_a, size_a);
}
} else { /* Result is neither str_a nor str_b so .. */
result[0] = NIL; /* .. str_a needs to be copied */
strncat(result, str_a, size);
size = size - strlen(result); /* And str_a appended */
if (size > 0)
strncat(result, str_b, size);
} }
return result;
}
/*-------------------------------------------------- End of STRJOIN.C =======*/ /*-------------------------------------------------- End of STRJOIN.C =======*/

View File

@ -12,165 +12,149 @@
#include "table.h" #include "table.h"
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
typedef struct __SicsTable { typedef struct __SicsTable {
float *fVal1; float *fVal1;
float *fVal2; float *fVal2;
int iLength; int iLength;
} STable; } STable;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
pSTable CreateTable(FILE *fd) pSTable CreateTable(FILE * fd)
{ {
pSTable pNew = NULL; pSTable pNew = NULL;
long lStart, lEnd, lData, i; long lStart, lEnd, lData, i;
char *pBuffer = NULL, *pEnd = NULL, *pEndLine, *pPtr; char *pBuffer = NULL, *pEnd = NULL, *pEndLine, *pPtr;
int iLength, iRet; int iLength, iRet;
float fVal1, fVal2; float fVal1, fVal2;
assert(fd); assert(fd);
/* find length of file, create a buffer and read it in */ /* find length of file, create a buffer and read it in */
lStart = ftell(fd); lStart = ftell(fd);
fseek(fd,0L,SEEK_END); fseek(fd, 0L, SEEK_END);
lEnd = ftell(fd); lEnd = ftell(fd);
lData = lEnd - lStart; lData = lEnd - lStart;
pBuffer = (char *)malloc(lData*sizeof(char)); pBuffer = (char *) malloc(lData * sizeof(char));
if(!pBuffer) if (!pBuffer) {
{ return NULL;
return NULL;
}
fseek(fd,lStart,SEEK_SET);
fread(pBuffer,sizeof(char),lData,fd);
/* find number of lines */
for(i = 0, iLength = 0; i < lData; i++)
{
if(pBuffer[i] == '\n')
{
iLength++;
}
}
/* allocate the table structure */
pNew = (pSTable)malloc(sizeof(STable));
if(!pNew)
{
free(pBuffer);
return NULL;
}
pNew->iLength = iLength;
pNew->fVal1 = (float *)malloc(sizeof(float)*iLength);
pNew->fVal2 = (float *)malloc(sizeof(float)*iLength);
if( (!pNew->fVal1) || (!pNew->fVal2))
{
free(pBuffer);
free(pNew);
return NULL;
}
memset(pNew->fVal1,0,iLength*sizeof(float));
memset(pNew->fVal2,0,iLength*sizeof(float));
/* dodge through the file reading pairs until end */
pPtr = pBuffer;
pEnd = pBuffer + lData;
pEndLine = pBuffer;
i = 0;
while(pEndLine < pEnd)
{
if(*pEndLine == '\n')
{
*pEndLine = '\0';
iRet = sscanf(pPtr,"%f %f",&fVal1, &fVal2);
if(iRet == 2)
{
pNew->fVal1[i] = fVal1;
pNew->fVal2[i] = fVal2;
i++;
}
pEndLine++;
pPtr = pEndLine;
}
else
{
pEndLine++;
}
}
free(pBuffer);
return pNew;
} }
/*--------------------------------------------------------------------------*/ fseek(fd, lStart, SEEK_SET);
void DeleteTable(pSTable self) fread(pBuffer, sizeof(char), lData, fd);
{
if(self->fVal1) /* find number of lines */
{ for (i = 0, iLength = 0; i < lData; i++) {
free(self->fVal1); if (pBuffer[i] == '\n') {
} iLength++;
if(self->fVal2) }
{ }
free(self->fVal2);
} /* allocate the table structure */
free(self); pNew = (pSTable) malloc(sizeof(STable));
} if (!pNew) {
/*--------------------------------------------------------------------------*/ free(pBuffer);
int InterpolateVal1(pSTable self, float fKey, float *fResult) return NULL;
{ }
float fFrac; pNew->iLength = iLength;
int i1,i; pNew->fVal1 = (float *) malloc(sizeof(float) * iLength);
pNew->fVal2 = (float *) malloc(sizeof(float) * iLength);
assert(self); if ((!pNew->fVal1) || (!pNew->fVal2)) {
assert(self->fVal1); free(pBuffer);
assert(self->fVal2); free(pNew);
return NULL;
/* search the entry point */ }
for(i = 0; i < self->iLength; i++) memset(pNew->fVal1, 0, iLength * sizeof(float));
{ memset(pNew->fVal2, 0, iLength * sizeof(float));
if(self->fVal1[i] >= fKey)
{ /* dodge through the file reading pairs until end */
i1 = i; pPtr = pBuffer;
break; pEnd = pBuffer + lData;
} pEndLine = pBuffer;
} i = 0;
if(i1 >= self->iLength) while (pEndLine < pEnd) {
{ if (*pEndLine == '\n') {
return 0; *pEndLine = '\0';
} iRet = sscanf(pPtr, "%f %f", &fVal1, &fVal2);
if (iRet == 2) {
pNew->fVal1[i] = fVal1;
pNew->fVal2[i] = fVal2;
i++;
}
pEndLine++;
pPtr = pEndLine;
} else {
pEndLine++;
}
}
free(pBuffer);
return pNew;
}
/*--------------------------------------------------------------------------*/
void DeleteTable(pSTable self)
{
if (self->fVal1) {
free(self->fVal1);
}
if (self->fVal2) {
free(self->fVal2);
}
free(self);
}
/*--------------------------------------------------------------------------*/
int InterpolateVal1(pSTable self, float fKey, float *fResult)
{
float fFrac;
int i1, i;
assert(self);
assert(self->fVal1);
assert(self->fVal2);
/* search the entry point */
for (i = 0; i < self->iLength; i++) {
if (self->fVal1[i] >= fKey) {
i1 = i;
break;
}
}
if (i1 >= self->iLength) {
return 0;
}
/* interpolate */
fFrac = (fKey - self->fVal1[i1 - 1])
/ (self->fVal1[i1] - self->fVal1[i1 - 1]);
*fResult = self->fVal2[i1 - 1]
+ fFrac * (self->fVal2[i1] - self->fVal2[i1 - 1]);
return 1;
}
/* interpolate */
fFrac = (fKey - self->fVal1[i1 -1])
/ (self->fVal1[i1] - self->fVal1[i1 - 1]);
*fResult = self->fVal2[i1-1]
+ fFrac*(self->fVal2[i1] - self->fVal2[i1 -1]);
return 1;
}
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int InterpolateVal2(pSTable self, float fKey, float *fResult) int InterpolateVal2(pSTable self, float fKey, float *fResult)
{ {
float fFrac; float fFrac;
int i1,i; int i1, i;
assert(self);
assert(self->fVal1);
assert(self->fVal2);
/* search the entry point */
for(i = 0; i < self->iLength; i++)
{
if(self->fVal2[i] <= fKey)
{
i1 = i;
break;
}
}
if(i1 >= self->iLength)
{
return 0;
}
/* interpolate */ assert(self);
fFrac = (fKey - self->fVal2[i1 -1]) assert(self->fVal1);
/ (self->fVal2[i1] - self->fVal2[i1 - 1]); assert(self->fVal2);
*fResult = self->fVal1[i1-1]
+ fFrac*(self->fVal1[i1] - self->fVal1[i1 -1]); /* search the entry point */
return 1; for (i = 0; i < self->iLength; i++) {
} if (self->fVal2[i] <= fKey) {
i1 = i;
break;
}
}
if (i1 >= self->iLength) {
return 0;
}
/* interpolate */
fFrac = (fKey - self->fVal2[i1 - 1])
/ (self->fVal2[i1] - self->fVal2[i1 - 1]);
*fResult = self->fVal1[i1 - 1]
+ fFrac * (self->fVal1[i1] - self->fVal1[i1 - 1]);
return 1;
}

View File

@ -8,28 +8,28 @@
copyright: see copyright.h copyright: see copyright.h
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
#ifndef SICSTABLE #ifndef SICSTABLE
#define SICSTABLE #define SICSTABLE
typedef struct __SicsTable *pSTable; typedef struct __SicsTable *pSTable;
/*------------------------- live & death ----------------------------------*/ /*------------------------- live & death ----------------------------------*/
pSTable CreateTable(FILE *fd); pSTable CreateTable(FILE * fd);
/* /*
creates a new table from a given file. The file is meant to have creates a new table from a given file. The file is meant to have
been positioned to the first entry for the table in the file. been positioned to the first entry for the table in the file.
This leaves the caller free to examine a header, if any. This leaves the caller free to examine a header, if any.
*/ */
void DeleteTable(pSTable self); void DeleteTable(pSTable self);
/*------------------------- Interpolation --------------------------------*/ /*------------------------- Interpolation --------------------------------*/
int InterpolateVal1(pSTable pTable, float fKey, float *fResult); int InterpolateVal1(pSTable pTable, float fKey, float *fResult);
/* /*
Returns a result from the second column for a key from the Returns a result from the second column for a key from the
first column. first column.
*/ */
int InterpolateVal2(pSTable pTable, float fKey, float *fResult); int InterpolateVal2(pSTable pTable, float fKey, float *fResult);
/* /*
Returns a result from the first column for a key from the Returns a result from the first column for a key from the
second column. second column.
*/ */
#endif #endif

View File

@ -9,50 +9,51 @@
#define OffsetOf(type, identifier) ((size_t)(&((type*) NULL)->identifier)) #define OffsetOf(type, identifier) ((size_t)(&((type*) NULL)->identifier))
#endif #endif
enum VelSel_Errors {VELSEL__BAD_TMO = -1, enum VelSel_Errors { VELSEL__BAD_TMO = -1,
VELSEL__BAD_CMD = -3, VELSEL__BAD_CMD = -3,
VELSEL__BAD_OFL = -4, VELSEL__BAD_OFL = -4,
VELSEL__BAD_ILLG = -5, VELSEL__BAD_ILLG = -5,
VELSEL__BAD_HOST = -6, VELSEL__BAD_HOST = -6,
VELSEL__BAD_SOCKET = -7, VELSEL__BAD_SOCKET = -7,
VELSEL__BAD_BIND = -8, VELSEL__BAD_BIND = -8,
VELSEL__BAD_CONNECT = -9, VELSEL__BAD_CONNECT = -9,
VELSEL__BAD_DEV = -10, VELSEL__BAD_DEV = -10,
VELSEL__BAD_MALLOC = -11, VELSEL__BAD_MALLOC = -11,
VELSEL__BAD_SENDLEN = -12, VELSEL__BAD_SENDLEN = -12,
VELSEL__BAD_SEND = -13, VELSEL__BAD_SEND = -13,
VELSEL__BAD_SEND_PIPE = -14, VELSEL__BAD_SEND_PIPE = -14,
VELSEL__BAD_SEND_NET = -15, VELSEL__BAD_SEND_NET = -15,
VELSEL__BAD_SEND_UNKN = -16, VELSEL__BAD_SEND_UNKN = -16,
VELSEL__BAD_RECV = -17, VELSEL__BAD_RECV = -17,
VELSEL__BAD_RECV_PIPE = -18, VELSEL__BAD_RECV_PIPE = -18,
VELSEL__BAD_RECV_NET = -19, VELSEL__BAD_RECV_NET = -19,
VELSEL__BAD_RECV_UNKN = -20, VELSEL__BAD_RECV_UNKN = -20,
VELSEL__BAD_NOT_BCD = -21, VELSEL__BAD_NOT_BCD = -21,
VELSEL__BAD_RECVLEN = -22, VELSEL__BAD_RECVLEN = -22,
VELSEL__BAD_FLUSH = -23, VELSEL__BAD_FLUSH = -23,
VELSEL__BAD_RECV1 = -24, VELSEL__BAD_RECV1 = -24,
VELSEL__BAD_RECV1_PIPE = -25, VELSEL__BAD_RECV1_PIPE = -25,
VELSEL__BAD_RECV1_NET = -26, VELSEL__BAD_RECV1_NET = -26,
VELSEL__BAD_PAR = -29, VELSEL__BAD_PAR = -29,
VELSEL__BAD_BSY = -30, VELSEL__BAD_BSY = -30,
VELSEL__BAD_OPEN = -31, VELSEL__BAD_OPEN = -31,
VELSEL__FORCED_CLOSED = -32, VELSEL__FORCED_CLOSED = -32,
VELSEL__BAD_STP = -33, VELSEL__BAD_STP = -33,
VELSEL__NOT_OPEN = -35, VELSEL__NOT_OPEN = -35,
VELSEL__BAD_ASYNSRV = -36, VELSEL__BAD_ASYNSRV = -36,
VELSEL__BAD_REPLY = -34}; VELSEL__BAD_REPLY = -34
};
/* /*
** Structure to which the VelSel_Open handle points. ** Structure to which the VelSel_Open handle points.
*/ */
struct VelSel_info { struct VelSel_info {
struct AsynSrv__info asyn_info; /* Contains skt, host, port & chan */ struct AsynSrv__info asyn_info; /* Contains skt, host, port & chan */
int tmo; int tmo;
char eot[4]; char eot[4];
int msg_id; int msg_id;
int n_replies, max_replies; int n_replies, max_replies;
struct RS__MsgStruct to_host; struct RS__MsgStruct to_host;
struct RS__RespStruct from_host; struct RS__RespStruct from_host;
}; };
/*------------------------------------------------ End of VelSel_DEF.H --*/ /*------------------------------------------------ End of VelSel_DEF.H --*/
#endif /* _velsel_def_ */ #endif /* _velsel_def_ */

File diff suppressed because it is too large Load Diff