- Adapted indenation to new agreed upon system
This commit is contained in:
@ -81,16 +81,18 @@
|
||||
**====================================================================
|
||||
** StrMatch - compare two strings.
|
||||
*/
|
||||
int StrMatch (
|
||||
int StrMatch(
|
||||
/* ========
|
||||
*/ char *str_a,
|
||||
char *str_b,
|
||||
int min_len) {
|
||||
char *str_b, int min_len)
|
||||
{
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------- End of StrMatch.C =======*/
|
||||
|
@ -15,7 +15,7 @@
|
||||
/*
|
||||
** Structures needed by AsynSrv_Utility.
|
||||
*/
|
||||
struct AsynSrv__info {
|
||||
struct AsynSrv__info {
|
||||
int skt; /* The socket number of the connection */
|
||||
char host[20]; /* The name of RS-232-C server */
|
||||
int port; /* The TCP/IP port number of server */
|
||||
@ -34,9 +34,9 @@
|
||||
int n_replies; /* # of last response returned to caller */
|
||||
void (*idleHandler) (int, int); /* MZ. handler called when waiting ..
|
||||
** .. on a response */
|
||||
};
|
||||
};
|
||||
|
||||
struct AsynSrv_HostPortSkt {
|
||||
struct AsynSrv_HostPortSkt {
|
||||
char host[30];
|
||||
int port;
|
||||
int skt;
|
||||
@ -46,6 +46,6 @@
|
||||
int rply_hdr_len;
|
||||
int usage_cnt;
|
||||
int status;
|
||||
};
|
||||
};
|
||||
/*------------------------------------------------ End of AsynSrv_DEF.H --*/
|
||||
#endif /* _asynsrv_def_ */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -69,28 +69,31 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
** Global Variables
|
||||
*/
|
||||
extern int C_gbl_status = 0;
|
||||
extern struct dsc$descriptor_s C_name_desc = {0,
|
||||
extern int C_gbl_status = 0;
|
||||
extern struct dsc$descriptor_s C_name_desc = { 0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0};
|
||||
0
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
** Old-style prototypes of routines which we are
|
||||
** bridging to.
|
||||
*/
|
||||
int log_arr_get ();
|
||||
int log_int_get ();
|
||||
int log_flt_get ();
|
||||
int log_str_get ();
|
||||
int log_arr_get();
|
||||
int log_int_get();
|
||||
int log_flt_get();
|
||||
int log_str_get();
|
||||
|
||||
int str_edit ();
|
||||
int str_edit();
|
||||
|
||||
int tt_port_connect ();
|
||||
int tt_port_disconnect ();
|
||||
int tt_port_io ();
|
||||
int tt_port_config ();
|
||||
int tt_port_connect();
|
||||
int tt_port_disconnect();
|
||||
int tt_port_io();
|
||||
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.
|
||||
@ -110,15 +113,17 @@
|
||||
** C_name_desc - set up as a string descriptor for name. It can
|
||||
** 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_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);
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
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.
|
||||
@ -136,15 +141,17 @@
|
||||
** C_name_desc - set up as a string descriptor for name. It can
|
||||
** 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_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);
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
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.
|
||||
@ -162,15 +169,17 @@
|
||||
** C_name_desc - set up as a string descriptor for name. It can
|
||||
** 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_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);
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
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.
|
||||
@ -190,29 +199,32 @@
|
||||
** C_name_desc - set up as a string descriptor for name. It can
|
||||
** 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_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;
|
||||
|
||||
my_val_desc.dsc$w_length = val_size - 1;
|
||||
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 */
|
||||
|
||||
if (C_gbl_status & 1) { /* If success, strip trailing spaces */
|
||||
while ((strlen (value) > 0) && (value[strlen (value) - 1] == ' ')) {
|
||||
value[strlen (value) - 1] = 0;
|
||||
while ((strlen(value) > 0) && (value[strlen(value) - 1] == ' ')) {
|
||||
value[strlen(value) - 1] = 0;
|
||||
}
|
||||
}
|
||||
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.
|
||||
@ -235,39 +247,44 @@
|
||||
** Global variables:
|
||||
** 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_CLASS_S,
|
||||
0};
|
||||
struct dsc$descriptor_s in_desc = {0,
|
||||
0
|
||||
};
|
||||
struct dsc$descriptor_s in_desc = { 0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0};
|
||||
struct dsc$descriptor_s ctrl_desc = {0,
|
||||
0
|
||||
};
|
||||
struct dsc$descriptor_s ctrl_desc = { 0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0};
|
||||
0
|
||||
};
|
||||
|
||||
out_desc.dsc$w_length = *length - 1;
|
||||
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;
|
||||
|
||||
ctrl_desc.dsc$w_length = strlen (ctrl);
|
||||
ctrl_desc.dsc$w_length = strlen(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 */
|
||||
out[*length] = '\0';
|
||||
}else {
|
||||
} else {
|
||||
out[0] = '\0';
|
||||
}
|
||||
|
||||
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.
|
||||
@ -292,30 +309,33 @@
|
||||
** Global variables:
|
||||
** 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_CLASS_S,
|
||||
0};
|
||||
struct dsc$descriptor_s pwd_desc = {0,
|
||||
0
|
||||
};
|
||||
struct dsc$descriptor_s pwd_desc = { 0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0};
|
||||
lognam_desc.dsc$w_length = strlen (lognam);
|
||||
0
|
||||
};
|
||||
lognam_desc.dsc$w_length = strlen(lognam);
|
||||
lognam_desc.dsc$a_pointer = lognam;
|
||||
|
||||
if (pwd != NULL) {
|
||||
pwd_desc.dsc$w_length = strlen (pwd);
|
||||
pwd_desc.dsc$w_length = strlen(pwd);
|
||||
pwd_desc.dsc$a_pointer = pwd;
|
||||
C_gbl_status = tt_port_connect (
|
||||
hndl, chan, &lognam_desc, &pwd_desc);
|
||||
}else {
|
||||
C_gbl_status = tt_port_connect (hndl, chan, &lognam_desc, NULL);
|
||||
C_gbl_status = tt_port_connect(hndl, chan, &lognam_desc, &pwd_desc);
|
||||
} else {
|
||||
C_gbl_status = tt_port_connect(hndl, chan, &lognam_desc, NULL);
|
||||
}
|
||||
|
||||
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.
|
||||
@ -331,20 +351,18 @@
|
||||
** Global variables:
|
||||
** 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);
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int C_tt_port_io (
|
||||
int C_tt_port_io(
|
||||
/* ============
|
||||
*/ int *hndl,
|
||||
char *rqst,
|
||||
char *term,
|
||||
char *answ,
|
||||
int *answ_len, /* Attention -- Read/Write argument!! */
|
||||
int flush,
|
||||
int tmo) {
|
||||
char *rqst, char *term, 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.
|
||||
** Refer to the DELTAT.OLB description of TT_PORT_IO to clarify any
|
||||
@ -386,18 +404,21 @@
|
||||
** Global variables:
|
||||
** 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_CLASS_S,
|
||||
0};
|
||||
struct dsc$descriptor_s term_desc = {0,
|
||||
0
|
||||
};
|
||||
struct dsc$descriptor_s term_desc = { 0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0};
|
||||
struct dsc$descriptor_s answ_desc = {0,
|
||||
0
|
||||
};
|
||||
struct dsc$descriptor_s answ_desc = { 0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0};
|
||||
0
|
||||
};
|
||||
char *my_rqst = NULL;
|
||||
char *my_term = NULL;
|
||||
char *my_answ = NULL;
|
||||
@ -407,13 +428,15 @@
|
||||
int my_tmo = 2;
|
||||
|
||||
my_tmo = tmo;
|
||||
if (my_tmo < 0) my_tmo = 0;
|
||||
if (my_tmo < 0)
|
||||
my_tmo = 0;
|
||||
my_flush = flush;
|
||||
if (my_flush != 0) my_flush = 1;
|
||||
if (my_flush != 0)
|
||||
my_flush = 1;
|
||||
if (answ != NULL) {
|
||||
if (answ_len == 0) {
|
||||
printf ("C_tt_port_io -- argument error.\n");
|
||||
printf (" %s\n",
|
||||
printf("C_tt_port_io -- argument error.\n");
|
||||
printf(" %s\n",
|
||||
"answ_len must be present if answ is present.");
|
||||
C_gbl_status = FALSE;
|
||||
return FALSE;
|
||||
@ -422,30 +445,32 @@
|
||||
answ_desc.dsc$a_pointer = answ;
|
||||
}
|
||||
if (term != NULL) {
|
||||
term_desc.dsc$w_length = strlen (term);
|
||||
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$w_length = strlen(rqst);
|
||||
rqst_desc.dsc$a_pointer = rqst;
|
||||
}
|
||||
C_gbl_status = tt_port_io (hndl, &rqst_desc, &term_desc,
|
||||
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 + 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 mask) {
|
||||
int mask)
|
||||
{
|
||||
/*
|
||||
** 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
|
||||
@ -465,8 +490,9 @@
|
||||
** Global variables:
|
||||
** 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);
|
||||
}
|
||||
}
|
||||
|
||||
/*=========================================== End of C_INTERFACES.C ========*/
|
||||
|
@ -26,9 +26,9 @@
|
||||
*/
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
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 iRet;
|
||||
char pCommand[80];
|
||||
char pReply[132];
|
||||
@ -37,29 +37,25 @@
|
||||
FILE *fd = NULL;
|
||||
|
||||
/* check translation file first */
|
||||
fd = fopen(pTransFile,"r");
|
||||
if(!fd)
|
||||
{
|
||||
fd = fopen(pTransFile, "r");
|
||||
if (!fd) {
|
||||
return DILLU__FILENOTFOUND;
|
||||
}
|
||||
fgets(pReply, 131,fd);
|
||||
if(strstr(pReply,"DILLUTION") == NULL)
|
||||
{
|
||||
fgets(pReply, 131, fd);
|
||||
if (strstr(pReply, "DILLUTION") == NULL) {
|
||||
fclose(fd);
|
||||
return DILLU__NODILLFILE;
|
||||
}
|
||||
|
||||
pTable = CreateTable(fd);
|
||||
fclose(fd);
|
||||
if(!pTable)
|
||||
{
|
||||
if (!pTable) {
|
||||
return DILLU__ERRORTABLE;
|
||||
}
|
||||
|
||||
/* allocate a new data structure */
|
||||
self = (pDILLU)malloc(sizeof(DILLU));
|
||||
if(self == NULL)
|
||||
{
|
||||
self = (pDILLU) malloc(sizeof(DILLU));
|
||||
if (self == NULL) {
|
||||
return DILLU__BADMALLOC;
|
||||
}
|
||||
|
||||
@ -67,8 +63,7 @@
|
||||
self->pTranstable = pTable;
|
||||
|
||||
iRet = SerialOpen(&self->pData, pHost, iPort, iChannel);
|
||||
if(iRet != 1)
|
||||
{
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
|
||||
@ -76,14 +71,12 @@
|
||||
prevent problems.
|
||||
*/
|
||||
iRet = SerialConfig(&self->pData, 100);
|
||||
if(iRet != 1)
|
||||
{
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
|
||||
self->iReadOnly = iMode;
|
||||
if(!self->iReadOnly)
|
||||
{
|
||||
if (!self->iReadOnly) {
|
||||
/* switch to remote operation */
|
||||
/* iRet = SerialWriteRead(&self->pData,"C1\r\n",pReply,131);
|
||||
if(iRet != 1)
|
||||
@ -93,21 +86,22 @@
|
||||
*/
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void DILLU_Close(pDILLU *pData)
|
||||
{
|
||||
void DILLU_Close(pDILLU * pData)
|
||||
{
|
||||
char pReply[132];
|
||||
int iRet;
|
||||
pDILLU self;
|
||||
|
||||
self = *pData;
|
||||
|
||||
if(!self)
|
||||
if (!self)
|
||||
return;
|
||||
|
||||
/* switch to local operation */
|
||||
iRet = SerialWriteRead(&self->pData,"C0\r\n",pReply,131);
|
||||
iRet = SerialWriteRead(&self->pData, "C0\r\n", pReply, 131);
|
||||
/* ignore errors on this one, the thing may be down */
|
||||
|
||||
/* close connection */
|
||||
@ -116,10 +110,11 @@
|
||||
/* free memory */
|
||||
free(self);
|
||||
*pData = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int DILLU_Config(pDILLU *pData, int iTmo)
|
||||
{
|
||||
int DILLU_Config(pDILLU * pData, int iTmo)
|
||||
{
|
||||
int iRet;
|
||||
char pReply[132];
|
||||
char pCommand[10];
|
||||
@ -128,33 +123,32 @@
|
||||
self = *pData;
|
||||
|
||||
/* first timeout */
|
||||
if(iTmo > 0)
|
||||
{
|
||||
if (iTmo > 0) {
|
||||
iRet = SerialConfig(&self->pData, iTmo);
|
||||
if(iRet < 0)
|
||||
{
|
||||
if (iRet < 0) {
|
||||
return iRet;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int DILLU_Send(pDILLU *pData, char *pCommand, char *pReply, int iLen)
|
||||
{
|
||||
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);
|
||||
if (strchr(pCommand, (int) '\r') == NULL) {
|
||||
strcat(pCommand, "\r\n");
|
||||
}
|
||||
return SerialWriteRead(&self->pData, pCommand, pReply, iLen);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int DILLU_Read(pDILLU *pData, float *fVal)
|
||||
{
|
||||
int DILLU_Read(pDILLU * pData, float *fVal)
|
||||
{
|
||||
char pCommand[10], pReply[132];
|
||||
int iRet;
|
||||
float fRead = -9999.;
|
||||
@ -165,69 +159,62 @@
|
||||
|
||||
|
||||
/* send D command */
|
||||
sprintf(pCommand,"D\r\n");
|
||||
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
|
||||
if(iRet != 1)
|
||||
{
|
||||
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)
|
||||
{
|
||||
iRet = sscanf(pReply, "%f", &fOhm);
|
||||
if (iRet != 1) {
|
||||
return DILLU__BADREAD;
|
||||
}
|
||||
if(fOhm > 9999890.)
|
||||
{
|
||||
if (fOhm > 9999890.) {
|
||||
return DILLU__SILLYANSWER;
|
||||
}
|
||||
|
||||
/* convert to K */
|
||||
iRet = InterpolateVal2(self->pTranstable,fOhm,&fRead);
|
||||
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];
|
||||
int iRet, i,iRange, iExec;
|
||||
int iRet, i, iRange, iExec;
|
||||
const float fPrecision = 0.0001;
|
||||
float fSet, fRead, fOhms, tmax, fTemp;
|
||||
pDILLU self;
|
||||
|
||||
self = *pData;
|
||||
|
||||
if(self->iReadOnly)
|
||||
{
|
||||
if (self->iReadOnly) {
|
||||
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)
|
||||
{
|
||||
/* 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)
|
||||
{
|
||||
iRet = sscanf(pReply, "%f", &fRead);
|
||||
if (iRet != 1) {
|
||||
return DILLU__BADREAD;
|
||||
}
|
||||
if(fRead > 9999890.)
|
||||
{
|
||||
if (fRead > 9999890.) {
|
||||
return DILLU__SILLYANSWER;
|
||||
}
|
||||
|
||||
|
||||
/* convert new set value to ohms */
|
||||
iRet = InterpolateVal1(self->pTranstable,fVal,&fOhms);
|
||||
if(!iRet)
|
||||
{
|
||||
iRet = InterpolateVal1(self->pTranstable, fVal, &fOhms);
|
||||
if (!iRet) {
|
||||
return DILLU__OUTOFRANGE;
|
||||
}
|
||||
|
||||
@ -235,186 +222,160 @@
|
||||
#ifdef debug
|
||||
printf("C1\n");
|
||||
#endif
|
||||
iRet = SerialWriteRead(&self->pData,"C1\r\n",pReply,131);
|
||||
if(iRet != 1)
|
||||
{
|
||||
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");
|
||||
strcpy(pCommand, "G3\r");
|
||||
if (fOhms > 1125) {
|
||||
strcpy(pCommand, "G2\r");
|
||||
}
|
||||
if(fOhms > 4000)
|
||||
strcpy(pCommand,"G1\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)
|
||||
{
|
||||
iRet = SerialWriteRead(&self->pData, "A9\r", pReply, 131);
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
#ifdef debug
|
||||
printf("%s\n",pCommand);
|
||||
printf("%s\n", pCommand);
|
||||
#endif
|
||||
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
|
||||
if(iRet != 1)
|
||||
{
|
||||
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");
|
||||
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)
|
||||
{
|
||||
iRet = SerialWriteRead(&self->pData, "A4\r", pReply, 131);
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
#ifdef debug
|
||||
printf("%s\n",pCommand);
|
||||
printf("%s\n", pCommand);
|
||||
#endif
|
||||
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
|
||||
if(iRet != 1)
|
||||
{
|
||||
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");
|
||||
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)
|
||||
{
|
||||
iRet = SerialWriteRead(&self->pData, "A5\r", pReply, 131);
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
#ifdef debug
|
||||
printf("%s\n",pCommand);
|
||||
printf("%s\n", pCommand);
|
||||
iRet = 1;
|
||||
#endif
|
||||
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
|
||||
if(iRet != 1)
|
||||
{
|
||||
iRet = SerialWriteRead(&self->pData, pCommand, pReply, 131);
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
|
||||
/* proportional gain */
|
||||
if(fOhms > 500.)
|
||||
{
|
||||
strcpy(pCommand,"G3\r");
|
||||
if (fOhms > 500.) {
|
||||
strcpy(pCommand, "G3\r");
|
||||
}
|
||||
if(fOhms > 1000)
|
||||
{
|
||||
strcpy(pCommand,"G2\r");
|
||||
if (fOhms > 1000) {
|
||||
strcpy(pCommand, "G2\r");
|
||||
}
|
||||
if(fOhms > 2000)
|
||||
{
|
||||
strcpy(pCommand,"G1\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)
|
||||
{
|
||||
iRet = SerialWriteRead(&self->pData, "A6\r", pReply, 131);
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
#ifdef debug
|
||||
printf("%s\n",pCommand);
|
||||
printf("%s\n", pCommand);
|
||||
#endif
|
||||
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
|
||||
if(iRet != 1)
|
||||
{
|
||||
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) )
|
||||
{
|
||||
fTemp = fOhms * 10000.;
|
||||
if ((fRead > 1.9) || (fOhms > 1.9)) {
|
||||
iRange = 2;
|
||||
fTemp = fOhms*1000.;
|
||||
fTemp = fOhms * 1000.;
|
||||
}
|
||||
if( (fRead > 19) || (fOhms > 19) )
|
||||
{
|
||||
if ((fRead > 19) || (fOhms > 19)) {
|
||||
iRange = 3;
|
||||
fTemp = fOhms*100.;
|
||||
fTemp = fOhms * 100.;
|
||||
}
|
||||
if( (fRead > 190) || (fOhms > 190) )
|
||||
{
|
||||
if ((fRead > 190) || (fOhms > 190)) {
|
||||
iRange = 4;
|
||||
fTemp = fOhms*10.;
|
||||
fTemp = fOhms * 10.;
|
||||
}
|
||||
if( (fRead > 750) || (fOhms > 750) )
|
||||
{
|
||||
if ((fRead > 750) || (fOhms > 750)) {
|
||||
iRange = 5;
|
||||
fTemp = fOhms;
|
||||
}
|
||||
if( (fRead > 19000) || (fOhms > 19000) )
|
||||
{
|
||||
if ((fRead > 19000) || (fOhms > 19000)) {
|
||||
iRange = 6;
|
||||
fTemp = fOhms/10.;
|
||||
fTemp = fOhms / 10.;
|
||||
}
|
||||
if( (fRead > 190000) || (fOhms > 190000) )
|
||||
{
|
||||
if ((fRead > 190000) || (fOhms > 190000)) {
|
||||
iRange = 7;
|
||||
fTemp = fOhms/100.;
|
||||
fTemp = fOhms / 100.;
|
||||
}
|
||||
|
||||
sprintf(pCommand,"R%1.1d\r",iRange);
|
||||
sprintf(pCommand, "R%1.1d\r", iRange);
|
||||
#ifdef debug
|
||||
printf("%s\n",pCommand);
|
||||
printf("%s\n", pCommand);
|
||||
#endif
|
||||
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
|
||||
if(iRet != 1)
|
||||
{
|
||||
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);
|
||||
printf("Set Val befor hex: %d\n", (int) fTemp);
|
||||
#endif
|
||||
sprintf(pCommand,"G%4.4X\r",(int)fTemp);
|
||||
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)
|
||||
{
|
||||
iRet = SerialWriteRead(&self->pData, "A3\r", pReply, 131);
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
#ifdef debug
|
||||
printf("%s\n",pCommand);
|
||||
printf("%s\n", pCommand);
|
||||
#endif
|
||||
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
|
||||
if(iRet != 1)
|
||||
{
|
||||
iRet = SerialWriteRead(&self->pData, pCommand, pReply, 131);
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
|
||||
@ -424,58 +385,57 @@
|
||||
#ifdef debug
|
||||
printf("C1\n");
|
||||
#endif
|
||||
iRet = SerialWriteRead(&self->pData,"C0\r\n",pReply,131);
|
||||
if(iRet != 1)
|
||||
{
|
||||
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];
|
||||
pDILLU self;
|
||||
|
||||
self = *pData;
|
||||
|
||||
switch(iCode)
|
||||
{
|
||||
switch (iCode) {
|
||||
case DILLU__FILENOTFOUND:
|
||||
strncpy(pError,"Translation Table file not found",iLen);
|
||||
strncpy(pError, "Translation Table file not found", iLen);
|
||||
return;
|
||||
break;
|
||||
case DILLU__NODILLFILE:
|
||||
strncpy(pError,"Translation Table file is not DILLU",iLen);
|
||||
strncpy(pError, "Translation Table file is not DILLU", iLen);
|
||||
return;
|
||||
break;
|
||||
case DILLU__ERRORTABLE:
|
||||
strncpy(pError,"Translation Table could not be created",iLen);
|
||||
strncpy(pError, "Translation Table could not be created", iLen);
|
||||
return;
|
||||
break;
|
||||
case DILLU__BADREAD:
|
||||
strncpy(pError,"Message corrupted",iLen);
|
||||
strncpy(pError, "Message corrupted", iLen);
|
||||
return;
|
||||
break;
|
||||
case DILLU__SILLYANSWER:
|
||||
strncpy(pError,"Message corrupted",iLen);
|
||||
strncpy(pError, "Message corrupted", iLen);
|
||||
return;
|
||||
break;
|
||||
case DILLU__BADMALLOC:
|
||||
strncpy(pError,"Out of memory in Open_DILLU",iLen);
|
||||
strncpy(pError, "Out of memory in Open_DILLU", iLen);
|
||||
return;
|
||||
break;
|
||||
case DILLU__READONLY:
|
||||
strncpy(pError,"DILLU is read-only",iLen);
|
||||
strncpy(pError, "DILLU is read-only", iLen);
|
||||
return;
|
||||
break;
|
||||
case DILLU__OUTOFRANGE:
|
||||
strncpy(pError,"Requested value is out of range",iLen);
|
||||
strncpy(pError, "Requested value is out of range", iLen);
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
SerialError(iCode,pError,iLen);
|
||||
SerialError(iCode, pError, iLen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,16 +30,16 @@
|
||||
#define DILLU__BADMALLOC -717
|
||||
#define DILLU__NODILLUFOUND -711
|
||||
/*------------------------------------------------------------------------*/
|
||||
typedef struct __DILLU {
|
||||
typedef struct __DILLU {
|
||||
void *pData;
|
||||
pSTable pTranstable;
|
||||
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);
|
||||
/***** creates an DILLU datastructure and opens a connection to the ITCL4
|
||||
controller. Input Parameters are:
|
||||
@ -55,14 +55,14 @@
|
||||
|
||||
*/
|
||||
|
||||
void DILLU_Close(pDILLU *pData);
|
||||
void DILLU_Close(pDILLU * pData);
|
||||
/****** close a connection to an DILLU controller and frees its
|
||||
data structure. The only parameter is a pointer to the data
|
||||
structure for this controller. This pointer will be invalid after
|
||||
this call.
|
||||
*/
|
||||
|
||||
int DILLU_Config(pDILLU *pData, int iTmo);
|
||||
int DILLU_Config(pDILLU * pData, int iTmo);
|
||||
/***** configure some aspects of a DILLU temperature controller.
|
||||
The parameter are:
|
||||
- a pointer to the data structure for the controller as
|
||||
@ -72,7 +72,7 @@
|
||||
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.
|
||||
A possible reply is returned in the buffer pReply.
|
||||
Maximum iLen characters are copied to pReply.
|
||||
@ -83,7 +83,7 @@
|
||||
failure.
|
||||
*/
|
||||
|
||||
int DILLU_Read(pDILLU *pData, float *fVal);
|
||||
int DILLU_Read(pDILLU * pData, float *fVal);
|
||||
/******
|
||||
Reads the current temperature at the controller
|
||||
|
||||
@ -91,7 +91,7 @@
|
||||
failure.
|
||||
*/
|
||||
|
||||
int DILLU_Set(pDILLU *pData, float fVal);
|
||||
int DILLU_Set(pDILLU * pData, float fVal);
|
||||
/****** sets a new preset temperature in the DILL temperature
|
||||
controller. Parameters are:
|
||||
- a pointer to a DILLU data structure as returned by Open_DILLU.
|
||||
@ -101,8 +101,6 @@
|
||||
failure.
|
||||
*/
|
||||
|
||||
void DILLU_Error2Text(pDILLU *pData, int iCode, char *pError, int iLen);
|
||||
void DILLU_Error2Text(pDILLU * pData, int iCode, char *pError, int iLen);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -17,23 +17,24 @@
|
||||
|
||||
#define MAX_MOT 12
|
||||
|
||||
enum EL734_Requests {FULL__STATUS,
|
||||
SHORT__STATUS};
|
||||
enum EL734_Requests { FULL__STATUS,
|
||||
SHORT__STATUS
|
||||
};
|
||||
/*
|
||||
** Structure to which the EL734_Open handle points.
|
||||
*/
|
||||
struct EL734info {
|
||||
struct EL734info {
|
||||
struct AsynSrv__info asyn_info; /* Contains skt, host, port & chan */
|
||||
int motor;
|
||||
int ored_msr, fp_cntr, fr_cntr;
|
||||
struct RS__MsgStruct to_host;
|
||||
struct RS__RespStruct from_host;
|
||||
};
|
||||
};
|
||||
/*
|
||||
** Structure holding everything that is known about a VME Motor Controller.
|
||||
** It is also the structure of replies from the Server.
|
||||
*/
|
||||
struct Motor_State {
|
||||
struct Motor_State {
|
||||
int motor; /* Motor number */
|
||||
int exists; /* True if Motor exists */
|
||||
int msr; /* MSR - Motor Status Register */
|
||||
@ -46,7 +47,7 @@ enum EL734_Requests {FULL__STATUS,
|
||||
int dec_pt; /* A - # of decimal places */
|
||||
int enc_factor[2]; /* FD - Encoder 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 loop_mode; /* F - Open loop/Closed loop (0/1) */
|
||||
int slow_hz; /* G - Start/stop frequency (Mot-S/sec) */
|
||||
@ -68,6 +69,6 @@ enum EL734_Requests {FULL__STATUS,
|
||||
int ac_state; /* AC - Air-cushion state (0 = down) */
|
||||
int out; /* SO - State of Output Signal */
|
||||
int in; /* RI - State of Input Signal */
|
||||
};
|
||||
};
|
||||
/*------------------------------------------------ End of EL734_DEF.H --*/
|
||||
#endif /* _el734_def_ */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -24,20 +24,20 @@
|
||||
#define False 0
|
||||
#define True 1
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
float fUpper; /* upper limit */
|
||||
float fLower; /* Lower Limit */
|
||||
int iFix; /* fixed, unfixed flag */
|
||||
float fSoftZero; /* SW-zero point */
|
||||
float fSoftUpper; /* software upper boundary*/
|
||||
float fSoftUpper; /* software upper boundary */
|
||||
float fSoftLower; /* " lower " */
|
||||
int iLowFlag, iUpFlag, iZeroFlag; /*activity flags */
|
||||
void *pData; /* EL734 open struct */
|
||||
} EL734st;
|
||||
} EL734st;
|
||||
|
||||
EXTERN int EL734Action(ClientData pDat, Tcl_Interp *i, int a, char *argv[]);
|
||||
static void EL734Error2Text(char *pBuffer, int errcode);
|
||||
EXTERN int EL734Action(ClientData pDat, Tcl_Interp * i, int a,
|
||||
char *argv[]);
|
||||
static void EL734Error2Text(char *pBuffer, int errcode);
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
Tcl has a high niceness level. It deletes a command properly when
|
||||
@ -46,10 +46,11 @@
|
||||
---------------------------------------------------------------------------*/
|
||||
EXTERN void EL734Murder(ClientData pData)
|
||||
{
|
||||
EL734st *pTa = (EL734st *)pData;
|
||||
EL734st *pTa = (EL734st *) pData;
|
||||
EL734_Close(&(pTa->pData));
|
||||
free(pData);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
EL734 is the main entry point for this stuff. It connects to a motor
|
||||
and, on success, creates a new command with the name of the motor.
|
||||
@ -57,7 +58,7 @@ EXTERN void EL734Murder(ClientData pData)
|
||||
EL734 name host port channel index
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
int EL734(ClientData clientData, Tcl_Interp *interp,
|
||||
int EL734(ClientData clientData, Tcl_Interp * interp,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
int iRet;
|
||||
@ -67,151 +68,137 @@ int EL734(ClientData clientData, Tcl_Interp *interp,
|
||||
char pBueffel[80];
|
||||
|
||||
/* check arguments */
|
||||
if(argc < 6)
|
||||
{
|
||||
if (argc < 6) {
|
||||
Tcl_AppendResult(interp,
|
||||
" Insufficient arguments: EL734 name host port channel index"
|
||||
, (char *) NULL);
|
||||
" Insufficient arguments: EL734 name host port channel index",
|
||||
(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);
|
||||
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);
|
||||
iRet = Tcl_GetInt(interp, argv[4], &iChannel);
|
||||
if (iRet == TCL_ERROR) {
|
||||
Tcl_AppendResult(interp, "Need integer value for channel",
|
||||
(char *) NULL);
|
||||
return iRet;
|
||||
}
|
||||
|
||||
iRet = Tcl_GetInt(interp,argv[5],&iMotor);
|
||||
if(iRet == TCL_ERROR)
|
||||
{
|
||||
Tcl_AppendResult(interp,"Need integer value for motor",
|
||||
(char *)NULL);
|
||||
iRet = Tcl_GetInt(interp, argv[5], &iMotor);
|
||||
if (iRet == TCL_ERROR) {
|
||||
Tcl_AppendResult(interp, "Need integer value for motor",
|
||||
(char *) NULL);
|
||||
return iRet;
|
||||
}
|
||||
|
||||
/* make a new pointer, initialise EL734st */
|
||||
pEL734 = (EL734st *)malloc(sizeof(EL734st));
|
||||
if(pEL734 ==NULL)
|
||||
{
|
||||
Tcl_AppendResult(interp,"No memory in EL734",NULL);
|
||||
pEL734 = (EL734st *) malloc(sizeof(EL734st));
|
||||
if (pEL734 == NULL) {
|
||||
Tcl_AppendResult(interp, "No memory in EL734", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
pEL734->iFix = False;
|
||||
pEL734->fSoftZero = INACTIVE+1;
|
||||
pEL734->fSoftUpper = INACTIVE+1.;
|
||||
pEL734->fSoftLower = -INACTIVE-1.;
|
||||
pEL734->fSoftZero = INACTIVE + 1;
|
||||
pEL734->fSoftUpper = INACTIVE + 1.;
|
||||
pEL734->fSoftLower = -INACTIVE - 1.;
|
||||
pEL734->iZeroFlag = False;
|
||||
pEL734->iLowFlag = False;
|
||||
pEL734->iUpFlag = False;
|
||||
|
||||
/* open the motor, finally */
|
||||
iRet = EL734_Open(&(pEL734->pData), argv[2],iPort,iChannel,iMotor,"STPMC EL734");
|
||||
if(iRet) /* success */
|
||||
{
|
||||
iRet =
|
||||
EL734_Open(&(pEL734->pData), argv[2], iPort, iChannel, iMotor,
|
||||
"STPMC EL734");
|
||||
if (iRet) { /* success */
|
||||
/* figure out motor limits */
|
||||
EL734_GetLimits(&(pEL734->pData),&(pEL734->fLower),
|
||||
EL734_GetLimits(&(pEL734->pData), &(pEL734->fLower),
|
||||
&(pEL734->fUpper));
|
||||
/* handle TCL, create new command: the motor */
|
||||
Tcl_CreateCommand(interp,strdup(argv[1]),EL734Action,
|
||||
(ClientData)pEL734,EL734Murder);
|
||||
Tcl_AppendResult(interp,strdup(argv[1]),(char *)NULL);
|
||||
Tcl_CreateCommand(interp, strdup(argv[1]), EL734Action,
|
||||
(ClientData) pEL734, EL734Murder);
|
||||
Tcl_AppendResult(interp, strdup(argv[1]), (char *) NULL);
|
||||
return TCL_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
EL734_ErrInfo(&pErr,&iPort,&iChannel, &iMotor);
|
||||
EL734Error2Text(pBueffel,iPort);
|
||||
Tcl_AppendResult(interp,pBueffel,(char *) NULL);
|
||||
} else {
|
||||
EL734_ErrInfo(&pErr, &iPort, &iChannel, &iMotor);
|
||||
EL734Error2Text(pBueffel, iPort);
|
||||
Tcl_AppendResult(interp, pBueffel, (char *) NULL);
|
||||
free(pEL734);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
CheckPos checks a position and converts it to a real position.
|
||||
Returns TCL_ERROR on mistake, TCL_OK else
|
||||
---------------------------------------------------------------------------*/
|
||||
static int CheckPos(Tcl_Interp *interp, EL734st *pData,
|
||||
static int CheckPos(Tcl_Interp * interp, EL734st * pData,
|
||||
float fRequested, float *fDrive)
|
||||
{
|
||||
{
|
||||
float fPos;
|
||||
char pBueffel[132];
|
||||
|
||||
/* fixed ? */
|
||||
if(pData->iFix)
|
||||
{
|
||||
Tcl_AppendResult(interp,"Motor fixed",NULL);
|
||||
if (pData->iFix) {
|
||||
Tcl_AppendResult(interp, "Motor fixed", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/* check against SW-boundaries */
|
||||
if(pData->iUpFlag)
|
||||
{
|
||||
if(fRequested > pData->fSoftUpper)
|
||||
{
|
||||
if (pData->iUpFlag) {
|
||||
if (fRequested > pData->fSoftUpper) {
|
||||
sprintf(pBueffel,
|
||||
"Requested position: %f violates SW-boundary %f",
|
||||
fRequested, pData->fSoftUpper);
|
||||
Tcl_AppendResult(interp,pBueffel,(char *) NULL);
|
||||
Tcl_AppendResult(interp, pBueffel, (char *) NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
if(pData->iLowFlag)
|
||||
{
|
||||
if(fRequested < pData->fSoftLower)
|
||||
{
|
||||
if (pData->iLowFlag) {
|
||||
if (fRequested < pData->fSoftLower) {
|
||||
sprintf(pBueffel,
|
||||
"Requested position: %f violates SW-boundary %f",
|
||||
fRequested, pData->fSoftLower);
|
||||
Tcl_AppendResult(interp,pBueffel,(char *) NULL);
|
||||
Tcl_AppendResult(interp, pBueffel, (char *) NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/* correct for zero point */
|
||||
if(pData->iZeroFlag)
|
||||
{
|
||||
if (pData->iZeroFlag) {
|
||||
fPos = fRequested - pData->fSoftZero;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
fPos = fRequested;
|
||||
}
|
||||
|
||||
/* check HW-boundaries */
|
||||
if( (fPos < pData->fLower) || (fPos > pData->fUpper) )
|
||||
{
|
||||
sprintf(pBueffel," %f outside limits %f %f",
|
||||
fPos,pData->fLower, pData->fUpper);
|
||||
Tcl_AppendResult(interp,"Requested position: ",
|
||||
pBueffel,(char *)NULL);
|
||||
if ((fPos < pData->fLower) || (fPos > pData->fUpper)) {
|
||||
sprintf(pBueffel, " %f outside limits %f %f",
|
||||
fPos, pData->fLower, pData->fUpper);
|
||||
Tcl_AppendResult(interp, "Requested position: ",
|
||||
pBueffel, (char *) NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
*fDrive = fPos;
|
||||
return TCL_OK;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
fucking standard library missing functionality!!!!!!!!!!!!!!!!
|
||||
---------------------------------------------------------------------------*/
|
||||
static float absf(float x)
|
||||
{
|
||||
if(x < .0)
|
||||
static float absf(float x)
|
||||
{
|
||||
if (x < .0)
|
||||
return -x;
|
||||
else
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
|
||||
@ -230,10 +217,10 @@ int EL734(ClientData clientData, Tcl_Interp *interp,
|
||||
motor upper val sets a software upper limit
|
||||
motor lower val sets a software lower limit
|
||||
----------------------------------------------------------------------------*/
|
||||
EXTERN int EL734Action(ClientData clientData, Tcl_Interp *interp,
|
||||
EXTERN int EL734Action(ClientData clientData, Tcl_Interp * interp,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
EL734st *pData = (EL734st *)clientData;
|
||||
EL734st *pData = (EL734st *) clientData;
|
||||
char pBueffel[80];
|
||||
char *pErr = NULL;
|
||||
int iRet, iMSR, iOMSR, iFPC, iFRC, iSS;
|
||||
@ -244,50 +231,43 @@ EXTERN int EL734Action(ClientData clientData, Tcl_Interp *interp,
|
||||
|
||||
|
||||
/* check parameters */
|
||||
if(argc < 2)
|
||||
{
|
||||
if (argc < 2) {
|
||||
Tcl_AppendResult(interp,
|
||||
"Usage: motor and either dr, pos, hlim slim run zero up lo",(char *)NULL);
|
||||
"Usage: motor and either dr, pos, hlim slim run zero up lo",
|
||||
(char *) NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if(pData == NULL)
|
||||
{
|
||||
Tcl_AppendResult(interp,
|
||||
"Motor data lost!!!!!!!!",(char *)NULL);
|
||||
if (pData == NULL) {
|
||||
Tcl_AppendResult(interp, "Motor data lost!!!!!!!!", (char *) NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/* check for HW-lim */
|
||||
if(strcmp(argv[1],"hlim") == 0)
|
||||
{
|
||||
sprintf(pBueffel," %f %f",pData->fLower,pData->fUpper);
|
||||
Tcl_AppendResult(interp,pBueffel,(char *)NULL);
|
||||
if (strcmp(argv[1], "hlim") == 0) {
|
||||
sprintf(pBueffel, " %f %f", pData->fLower, pData->fUpper);
|
||||
Tcl_AppendResult(interp, pBueffel, (char *) NULL);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/* check for SW-lim */
|
||||
if(strcmp(argv[1],"slim") == 0)
|
||||
{
|
||||
sprintf(pBueffel," %f %f",pData->fSoftLower,pData->fSoftUpper);
|
||||
Tcl_AppendResult(interp,pBueffel,(char *)NULL);
|
||||
if (strcmp(argv[1], "slim") == 0) {
|
||||
sprintf(pBueffel, " %f %f", pData->fSoftLower, pData->fSoftUpper);
|
||||
Tcl_AppendResult(interp, pBueffel, (char *) NULL);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/* fix & unfix */
|
||||
if(strcmp(argv[1],"fix") == 0)
|
||||
{
|
||||
if (strcmp(argv[1], "fix") == 0) {
|
||||
pData->iFix = True;
|
||||
return TCL_OK;
|
||||
}
|
||||
if(strcmp(argv[1],"unfix") == 0)
|
||||
{
|
||||
if (strcmp(argv[1], "unfix") == 0) {
|
||||
pData->iFix = False;
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/* reset */
|
||||
if(strcmp(argv[1],"reset")== 0)
|
||||
{
|
||||
if (strcmp(argv[1], "reset") == 0) {
|
||||
pData->iFix = False;
|
||||
pData->iLowFlag = False;
|
||||
pData->iUpFlag = False;
|
||||
@ -296,62 +276,46 @@ EXTERN int EL734Action(ClientData clientData, Tcl_Interp *interp,
|
||||
}
|
||||
|
||||
/* check for pos */
|
||||
if(strcmp(argv[1],"pos") == 0)
|
||||
{
|
||||
if (strcmp(argv[1], "pos") == 0) {
|
||||
iRet = EL734_GetStatus(&(pData->pData),
|
||||
&iMSR,
|
||||
&iOMSR,
|
||||
&iFPC,
|
||||
&iFRC,
|
||||
&iSS,
|
||||
&fPos);
|
||||
if(!iRet)
|
||||
{
|
||||
EL734_ErrInfo(&pErr,&iMSR,&iOMSR, &iSS);
|
||||
EL734Error2Text(pBueffel,iMSR);
|
||||
Tcl_AppendResult(interp,pBueffel,(char *) NULL);
|
||||
&iMSR, &iOMSR, &iFPC, &iFRC, &iSS, &fPos);
|
||||
if (!iRet) {
|
||||
EL734_ErrInfo(&pErr, &iMSR, &iOMSR, &iSS);
|
||||
EL734Error2Text(pBueffel, iMSR);
|
||||
Tcl_AppendResult(interp, pBueffel, (char *) NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(pData->iZeroFlag)
|
||||
{
|
||||
} else {
|
||||
if (pData->iZeroFlag) {
|
||||
fPos += pData->fSoftZero;
|
||||
}
|
||||
sprintf(pBueffel," %f",fPos);
|
||||
Tcl_AppendResult(interp,pBueffel,NULL);
|
||||
sprintf(pBueffel, " %f", fPos);
|
||||
Tcl_AppendResult(interp, pBueffel, NULL);
|
||||
return TCL_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/* zero point */
|
||||
if(strcmp(argv[1],"zero") == 0)
|
||||
{
|
||||
if (strcmp(argv[1], "zero") == 0) {
|
||||
/* check for zero already been defined */
|
||||
if(pData->iZeroFlag)
|
||||
{
|
||||
if (pData->iZeroFlag) {
|
||||
Tcl_AppendResult(interp,
|
||||
"Request to set new zero point rejected.",
|
||||
" Use reset before new definition. ",
|
||||
" I'll get confused otherwise ",
|
||||
NULL);
|
||||
" I'll get confused otherwise ", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/* get the new position */
|
||||
if(argc < 3)
|
||||
{
|
||||
Tcl_AppendResult(interp,
|
||||
"Usage: motor zero val",NULL);
|
||||
if (argc < 3) {
|
||||
Tcl_AppendResult(interp, "Usage: motor zero val", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
iRet = Tcl_GetDouble(interp,argv[2],&dPos);
|
||||
iRet = Tcl_GetDouble(interp, argv[2], &dPos);
|
||||
fNpos = dPos;
|
||||
if(iRet == TCL_ERROR)
|
||||
{
|
||||
Tcl_AppendResult(interp,"Need float value for new zeropint",
|
||||
(char *)NULL);
|
||||
if (iRet == TCL_ERROR) {
|
||||
Tcl_AppendResult(interp, "Need float value for new zeropint",
|
||||
(char *) NULL);
|
||||
return iRet;
|
||||
}
|
||||
pData->fSoftZero = -fNpos;
|
||||
@ -360,22 +324,18 @@ EXTERN int EL734Action(ClientData clientData, Tcl_Interp *interp,
|
||||
}
|
||||
|
||||
/* upper SW-limit */
|
||||
if(strcmp(argv[1],"up") == 0)
|
||||
{
|
||||
if (strcmp(argv[1], "up") == 0) {
|
||||
/* get the new position */
|
||||
if(argc < 3)
|
||||
{
|
||||
Tcl_AppendResult(interp,
|
||||
"Usage: motor up val",NULL);
|
||||
if (argc < 3) {
|
||||
Tcl_AppendResult(interp, "Usage: motor up val", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
iRet = Tcl_GetDouble(interp,argv[2],&dPos);
|
||||
iRet = Tcl_GetDouble(interp, argv[2], &dPos);
|
||||
fNpos = dPos;
|
||||
if(iRet == TCL_ERROR)
|
||||
{
|
||||
Tcl_AppendResult(interp,"Need float value for new upper limit",
|
||||
(char *)NULL);
|
||||
if (iRet == TCL_ERROR) {
|
||||
Tcl_AppendResult(interp, "Need float value for new upper limit",
|
||||
(char *) NULL);
|
||||
return iRet;
|
||||
}
|
||||
pData->fSoftUpper = fNpos;
|
||||
@ -384,22 +344,18 @@ EXTERN int EL734Action(ClientData clientData, Tcl_Interp *interp,
|
||||
}
|
||||
|
||||
/* lower SW-limit */
|
||||
if(strcmp(argv[1],"lo") == 0)
|
||||
{
|
||||
if (strcmp(argv[1], "lo") == 0) {
|
||||
/* get the new position */
|
||||
if(argc < 3)
|
||||
{
|
||||
Tcl_AppendResult(interp,
|
||||
"Usage: motor lo val",NULL);
|
||||
if (argc < 3) {
|
||||
Tcl_AppendResult(interp, "Usage: motor lo val", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
iRet = Tcl_GetDouble(interp,argv[2],&dPos);
|
||||
iRet = Tcl_GetDouble(interp, argv[2], &dPos);
|
||||
fNpos = dPos;
|
||||
if(iRet == TCL_ERROR)
|
||||
{
|
||||
Tcl_AppendResult(interp,"Need float value for new lower limit",
|
||||
(char *)NULL);
|
||||
if (iRet == TCL_ERROR) {
|
||||
Tcl_AppendResult(interp, "Need float value for new lower limit",
|
||||
(char *) NULL);
|
||||
return iRet;
|
||||
}
|
||||
pData->fSoftLower = fNpos;
|
||||
@ -410,87 +366,73 @@ EXTERN int EL734Action(ClientData clientData, Tcl_Interp *interp,
|
||||
|
||||
|
||||
/* this is most important: dr for Drive */
|
||||
if(strcmp(argv[1],"dr") == 0)
|
||||
{
|
||||
if (strcmp(argv[1], "dr") == 0) {
|
||||
/* get the new position */
|
||||
if(argc < 3)
|
||||
{
|
||||
Tcl_AppendResult(interp,
|
||||
"Usage: motor dr val",NULL);
|
||||
if (argc < 3) {
|
||||
Tcl_AppendResult(interp, "Usage: motor dr val", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
iRet = Tcl_GetDouble(interp,argv[2],&dPos);
|
||||
iRet = Tcl_GetDouble(interp, argv[2], &dPos);
|
||||
fNpos = dPos;
|
||||
if(iRet == TCL_ERROR)
|
||||
{
|
||||
Tcl_AppendResult(interp,"Need value to drive to",
|
||||
(char *)NULL);
|
||||
if (iRet == TCL_ERROR) {
|
||||
Tcl_AppendResult(interp, "Need value to drive to", (char *) NULL);
|
||||
return iRet;
|
||||
}
|
||||
|
||||
/* check if compatible with limits */
|
||||
if(CheckPos(interp,pData,fNpos,&fPos) == TCL_ERROR)
|
||||
if (CheckPos(interp, pData, fNpos, &fPos) == TCL_ERROR)
|
||||
return TCL_ERROR;
|
||||
|
||||
/* finally move */
|
||||
iRet = EL734_MoveWait(&(pData->pData), fPos, &iOMSR,
|
||||
&iFPC, &iFRC,&fNpos);
|
||||
&iFPC, &iFRC, &fNpos);
|
||||
/* 99.99999999999% of all code is error checking */
|
||||
if(!iRet)
|
||||
{
|
||||
EL734_ErrInfo(&pErr,&iMSR,&iOMSR, &iSS);
|
||||
EL734Error2Text(pBueffel,iMSR);
|
||||
Tcl_AppendResult(interp,pBueffel,(char *) NULL);
|
||||
if (!iRet) {
|
||||
EL734_ErrInfo(&pErr, &iMSR, &iOMSR, &iSS);
|
||||
EL734Error2Text(pBueffel, iMSR);
|
||||
Tcl_AppendResult(interp, pBueffel, (char *) NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/* check if driving has been done */
|
||||
if(absf(fPos-fNpos) > MOTACURRACY)
|
||||
{
|
||||
if (absf(fPos - fNpos) > MOTACURRACY) {
|
||||
Tcl_AppendResult(interp,
|
||||
" Motor error: inacurate driving!",
|
||||
" Probably something serious is wrong ",
|
||||
" Check the fucking hardware ",
|
||||
NULL);
|
||||
" Check the fucking hardware ", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/* this is most important: run for Driving without waiting */
|
||||
if(strcmp(argv[1],"run") == 0)
|
||||
{
|
||||
if (strcmp(argv[1], "run") == 0) {
|
||||
/* get the new position */
|
||||
if(argc < 3)
|
||||
{
|
||||
Tcl_AppendResult(interp,
|
||||
"Usage: motor run val",NULL);
|
||||
if (argc < 3) {
|
||||
Tcl_AppendResult(interp, "Usage: motor run val", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
iRet = Tcl_GetDouble(interp,argv[2],&dPos);
|
||||
iRet = Tcl_GetDouble(interp, argv[2], &dPos);
|
||||
fNpos = dPos;
|
||||
if(iRet == TCL_ERROR)
|
||||
{
|
||||
Tcl_AppendResult(interp,"Need value to run for",
|
||||
(char *)NULL);
|
||||
if (iRet == TCL_ERROR) {
|
||||
Tcl_AppendResult(interp, "Need value to run for", (char *) NULL);
|
||||
return iRet;
|
||||
}
|
||||
|
||||
/* check if compatible with limits */
|
||||
if(CheckPos(interp,pData,fNpos,&fPos) == TCL_ERROR)
|
||||
if (CheckPos(interp, pData, fNpos, &fPos) == TCL_ERROR)
|
||||
return TCL_ERROR;
|
||||
|
||||
/* finally move */
|
||||
iRet = EL734_MoveNoWait (&(pData->pData), fPos);
|
||||
iRet = EL734_MoveNoWait(&(pData->pData), fPos);
|
||||
|
||||
/* 99.99999999999% of all code is error checking */
|
||||
if(!iRet)
|
||||
{
|
||||
EL734_ErrInfo(&pErr,&iMSR,&iOMSR, &iSS);
|
||||
EL734Error2Text(pBueffel,iMSR);
|
||||
Tcl_AppendResult(interp,pBueffel,(char *) NULL);
|
||||
if (!iRet) {
|
||||
EL734_ErrInfo(&pErr, &iMSR, &iOMSR, &iSS);
|
||||
EL734Error2Text(pBueffel, iMSR);
|
||||
Tcl_AppendResult(interp, pBueffel, (char *) NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
return TCL_OK;
|
||||
@ -503,31 +445,28 @@ EXTERN int EL734Action(ClientData clientData, Tcl_Interp *interp,
|
||||
to yield a return value. Usage by normal motor users strictly
|
||||
discouraged.
|
||||
*/
|
||||
if(strcmp(argv[1],"com") == 0)
|
||||
{
|
||||
strcpy(pBueffel,argv[2]);
|
||||
for(i = 3; i < argc; i++)
|
||||
{
|
||||
strcat(pBueffel," ");
|
||||
strcat(pBueffel,argv[i]);
|
||||
if (strcmp(argv[1], "com") == 0) {
|
||||
strcpy(pBueffel, argv[2]);
|
||||
for (i = 3; i < argc; i++) {
|
||||
strcat(pBueffel, " ");
|
||||
strcat(pBueffel, argv[i]);
|
||||
}
|
||||
sprintf(pBueffel,"%s\r",pBueffel);
|
||||
iRet = EL734_SendCmnds(&(pData->pData),pBueffel,NULL);
|
||||
if(!iRet)
|
||||
{
|
||||
EL734_ErrInfo(&pErr,&iMSR,&iOMSR, &iSS);
|
||||
EL734Error2Text(pBueffel,iMSR);
|
||||
Tcl_AppendResult(interp,pBueffel,(char *) NULL);
|
||||
sprintf(pBueffel, "%s\r", pBueffel);
|
||||
iRet = EL734_SendCmnds(&(pData->pData), pBueffel, NULL);
|
||||
if (!iRet) {
|
||||
EL734_ErrInfo(&pErr, &iMSR, &iOMSR, &iSS);
|
||||
EL734Error2Text(pBueffel, iMSR);
|
||||
Tcl_AppendResult(interp, pBueffel, (char *) NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
/* fetch reply */
|
||||
pReply = (struct RS__RplyStruct *)EL734_GetReply(
|
||||
&(pData->pData),NULL);
|
||||
while(pReply != NULL)
|
||||
{
|
||||
Tcl_AppendElement(interp,pReply->rply);
|
||||
pReply = (struct RS__RplyStruct *)EL734_GetReply(
|
||||
&(pData->pData),pReply);
|
||||
pReply =
|
||||
(struct RS__RplyStruct *) EL734_GetReply(&(pData->pData), NULL);
|
||||
while (pReply != NULL) {
|
||||
Tcl_AppendElement(interp, pReply->rply);
|
||||
pReply =
|
||||
(struct RS__RplyStruct *) EL734_GetReply(&(pData->pData),
|
||||
pReply);
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
@ -535,110 +474,110 @@ EXTERN int EL734Action(ClientData clientData, Tcl_Interp *interp,
|
||||
/* if we end here an unknown command has been sent */
|
||||
Tcl_AppendResult(interp,
|
||||
"Usage: motor and either dr, run,zero, pos, hlim"
|
||||
"slim up low reset fix unfix",(char *)NULL);
|
||||
"slim up low reset fix unfix", (char *) NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
EL734Error2Text converts between an EL734 error code to text
|
||||
-----------------------------------------------------------------------------*/
|
||||
void EL734Error2Text(char *pBuffer, int iErr)
|
||||
{
|
||||
switch(iErr)
|
||||
{
|
||||
void EL734Error2Text(char *pBuffer, int iErr)
|
||||
{
|
||||
switch (iErr) {
|
||||
case -28:
|
||||
strcpy(pBuffer,"EL734__BAD_ADR");
|
||||
strcpy(pBuffer, "EL734__BAD_ADR");
|
||||
break;
|
||||
case -8:
|
||||
strcpy(pBuffer,"EL734__BAD_BIND");
|
||||
strcpy(pBuffer, "EL734__BAD_BIND");
|
||||
break;
|
||||
case -30:
|
||||
strcpy(pBuffer,"EL734__BAD_BSY");
|
||||
strcpy(pBuffer, "EL734__BAD_BSY");
|
||||
break;
|
||||
case -3:
|
||||
strcpy(pBuffer,"EL734__BAD_CMD");
|
||||
strcpy(pBuffer, "EL734__BAD_CMD");
|
||||
break;
|
||||
case -9:
|
||||
strcpy(pBuffer,"EL734__BAD_CONNECT");
|
||||
strcpy(pBuffer, "EL734__BAD_CONNECT");
|
||||
break;
|
||||
case -23:
|
||||
strcpy(pBuffer,"EL734__BAD_FLUSH");
|
||||
strcpy(pBuffer, "EL734__BAD_FLUSH");
|
||||
break;
|
||||
case -6:
|
||||
strcpy(pBuffer,"EL734__BAD_HOST");
|
||||
strcpy(pBuffer, "EL734__BAD_HOST");
|
||||
break;
|
||||
case -10:
|
||||
strcpy(pBuffer,"EL734__BAD_ID");
|
||||
strcpy(pBuffer, "EL734__BAD_ID");
|
||||
break;
|
||||
case -5:
|
||||
strcpy(pBuffer,"EL734__BAD_ILLG");
|
||||
strcpy(pBuffer, "EL734__BAD_ILLG");
|
||||
break;
|
||||
case -2:
|
||||
strcpy(pBuffer,"EL734__BAD_LOC");
|
||||
strcpy(pBuffer, "EL734__BAD_LOC");
|
||||
break;
|
||||
case -11:
|
||||
strcpy(pBuffer,"EL734__BAD_MALLOC");
|
||||
strcpy(pBuffer, "EL734__BAD_MALLOC");
|
||||
break;
|
||||
case -21:
|
||||
strcpy(pBuffer,"EL734__BAD_NOT_BCD");
|
||||
strcpy(pBuffer, "EL734__BAD_NOT_BCD");
|
||||
break;
|
||||
case -4:
|
||||
strcpy(pBuffer,"EL734__BAD_OFL");
|
||||
strcpy(pBuffer, "EL734__BAD_OFL");
|
||||
break;
|
||||
case -29:
|
||||
strcpy(pBuffer,"EL734__BAD_PAR");
|
||||
strcpy(pBuffer, "EL734__BAD_PAR");
|
||||
break;
|
||||
|
||||
case -17:
|
||||
strcpy(pBuffer,"EL734__BAD_RECV");
|
||||
strcpy(pBuffer, "EL734__BAD_RECV");
|
||||
break;
|
||||
case -19:
|
||||
strcpy(pBuffer,"EL734__BAD_RECV_NET");
|
||||
strcpy(pBuffer, "EL734__BAD_RECV_NET");
|
||||
break;
|
||||
case -18:
|
||||
strcpy(pBuffer,"EL734__BAD_RECV_PIPE");
|
||||
strcpy(pBuffer, "EL734__BAD_RECV_PIPE");
|
||||
break;
|
||||
case -20:
|
||||
strcpy(pBuffer,"EL734__BAD_RECV_UNKN");
|
||||
strcpy(pBuffer, "EL734__BAD_RECV_UNKN");
|
||||
break;
|
||||
case -22:
|
||||
strcpy(pBuffer,"EL734__BAD_RECVLEN");
|
||||
strcpy(pBuffer, "EL734__BAD_RECVLEN");
|
||||
break;
|
||||
case -24:
|
||||
strcpy(pBuffer,"EL734__BAD_RECV1");
|
||||
strcpy(pBuffer, "EL734__BAD_RECV1");
|
||||
break;
|
||||
case -26:
|
||||
strcpy(pBuffer,"EL734__BAD_RECV1_NET");
|
||||
strcpy(pBuffer, "EL734__BAD_RECV1_NET");
|
||||
break;
|
||||
case -25:
|
||||
strcpy(pBuffer,"EL734__BAD_RECV1_PIPE");
|
||||
strcpy(pBuffer, "EL734__BAD_RECV1_PIPE");
|
||||
break;
|
||||
case -27:
|
||||
strcpy(pBuffer,"EL734__BAD_RNG");
|
||||
strcpy(pBuffer, "EL734__BAD_RNG");
|
||||
break;
|
||||
case -13:
|
||||
strcpy(pBuffer,"EL734__BAD_SEND");
|
||||
strcpy(pBuffer, "EL734__BAD_SEND");
|
||||
break;
|
||||
case -14:
|
||||
strcpy(pBuffer,"EL734__BAD_SEND_PIPE");
|
||||
strcpy(pBuffer, "EL734__BAD_SEND_PIPE");
|
||||
break;
|
||||
case -15:
|
||||
strcpy(pBuffer,"EL734__BAD_SEND_NET");
|
||||
strcpy(pBuffer, "EL734__BAD_SEND_NET");
|
||||
break;
|
||||
case -16:
|
||||
strcpy(pBuffer,"EL734__BAD_SEND_UNKN");
|
||||
strcpy(pBuffer, "EL734__BAD_SEND_UNKN");
|
||||
break;
|
||||
case -12:
|
||||
strcpy(pBuffer,"EL734__BAD_SENDLEN");
|
||||
strcpy(pBuffer, "EL734__BAD_SENDLEN");
|
||||
break;
|
||||
case -7:
|
||||
strcpy(pBuffer,"EL734__BAD_SOCKET");
|
||||
strcpy(pBuffer, "EL734__BAD_SOCKET");
|
||||
break;
|
||||
case -1:
|
||||
strcpy(pBuffer,"EL734__BAD_TMO");
|
||||
strcpy(pBuffer, "EL734__BAD_TMO");
|
||||
break;
|
||||
default:
|
||||
strcpy(pBuffer,"Unknown EL734 error");
|
||||
strcpy(pBuffer, "Unknown EL734 error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,8 @@ enum EL737_States {
|
||||
PTSP = 0x9,
|
||||
PCSP = 0xA,
|
||||
LRTSP = 0xD,
|
||||
LRCSP = 0xE};
|
||||
LRCSP = 0xE
|
||||
};
|
||||
|
||||
enum EL737_Consts {
|
||||
VMECNT__PRESET_COUNT,
|
||||
@ -37,20 +38,21 @@ enum EL737_Consts {
|
||||
|
||||
VMECNT__FULL,
|
||||
VMECNT__SHORT,
|
||||
VMECNT__INCR};
|
||||
VMECNT__INCR
|
||||
};
|
||||
/*
|
||||
** Structure to which the EL737_Open handle points.
|
||||
*/
|
||||
struct EL737info {
|
||||
struct EL737info {
|
||||
struct AsynSrv__info asyn_info; /* Contains skt, host, port & chan */
|
||||
int c5, c6, c7, c8;
|
||||
struct RS__MsgStruct to_host;
|
||||
struct RS__RespStruct from_host;
|
||||
};
|
||||
};
|
||||
/*
|
||||
** Structure holding everything that is known about a VME Neutron Counter.
|
||||
*/
|
||||
struct Counter_State {
|
||||
struct Counter_State {
|
||||
int state; /* RS */
|
||||
char timer[16]; /* RT \ RA */
|
||||
int cntrs[8]; /* RC 1 ... RC 8 / */
|
||||
@ -62,6 +64,6 @@ enum EL737_Consts {
|
||||
char threshes[8][16]; /* DL 1 ... DL 8 */
|
||||
int mon_preset; /* MP */
|
||||
char timer_preset[16]; /* TP */
|
||||
};
|
||||
};
|
||||
/*----------------------------------------------------- End of EL737_DEF.H --*/
|
||||
#endif /* _el737_def_ */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -23,13 +23,13 @@
|
||||
#define True 1
|
||||
#define False 0
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
void *pData; /* EL737 open struct */
|
||||
} EL737st;
|
||||
} EL737st;
|
||||
|
||||
EXTERN int EL737Action(ClientData pDat, Tcl_Interp *i, int a, char *argv[]);
|
||||
static void EL737Error2Text(char *pBuffer, int errcode);
|
||||
EXTERN int EL737Action(ClientData pDat, Tcl_Interp * i, int a,
|
||||
char *argv[]);
|
||||
static void EL737Error2Text(char *pBuffer, int errcode);
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
Tcl has a high niceness level. It deletes a command properly when
|
||||
@ -38,10 +38,11 @@
|
||||
---------------------------------------------------------------------------*/
|
||||
EXTERN void EL737Murder(ClientData pData)
|
||||
{
|
||||
EL737st *pTa = (EL737st *)pData;
|
||||
EL737st *pTa = (EL737st *) pData;
|
||||
EL737_Close(&(pTa->pData));
|
||||
free(pData);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
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.
|
||||
@ -49,7 +50,7 @@ EXTERN void EL737Murder(ClientData pData)
|
||||
EL737 name host port channel
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
int CterEL737(ClientData clientData, Tcl_Interp *interp,
|
||||
int CterEL737(ClientData clientData, Tcl_Interp * interp,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
int iRet;
|
||||
@ -59,58 +60,51 @@ int CterEL737(ClientData clientData, Tcl_Interp *interp,
|
||||
char pBueffel[80];
|
||||
|
||||
/* check arguments */
|
||||
if(argc < 5)
|
||||
{
|
||||
if (argc < 5) {
|
||||
Tcl_AppendResult(interp,
|
||||
" Insufficient arguments: CterEL737 name host port channel"
|
||||
, (char *) NULL);
|
||||
" 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);
|
||||
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);
|
||||
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 */
|
||||
pEL737 = (EL737st *)malloc(sizeof(EL737st));
|
||||
if(pEL737 ==NULL)
|
||||
{
|
||||
Tcl_AppendResult(interp,"No memory in EL734",NULL);
|
||||
pEL737 = (EL737st *) malloc(sizeof(EL737st));
|
||||
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 */
|
||||
{
|
||||
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);
|
||||
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);
|
||||
} 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
|
||||
@ -130,10 +124,10 @@ int CterEL737(ClientData clientData, Tcl_Interp *interp,
|
||||
{ counts monitor time }
|
||||
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[])
|
||||
{
|
||||
EL737st *pData = (EL737st *)clientData;
|
||||
EL737st *pData = (EL737st *) clientData;
|
||||
char pBueffel[132];
|
||||
char pNumBuf[20];
|
||||
char *pErr = NULL;
|
||||
@ -144,257 +138,227 @@ EXTERN int EL737Action(ClientData clientData, Tcl_Interp *interp,
|
||||
double dVal;
|
||||
|
||||
/* obviously we need at least a keyword! */
|
||||
if(argc < 2)
|
||||
{
|
||||
Tcl_AppendResult(interp,"No keyword given",NULL);
|
||||
if (argc < 2) {
|
||||
Tcl_AppendResult(interp, "No keyword given", NULL);
|
||||
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);
|
||||
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);
|
||||
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 ? */
|
||||
if(strcmp(argv[1],"isDone") == 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);
|
||||
if (strcmp(argv[1], "isDone") == 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;
|
||||
}
|
||||
if(iRS == 0) /* done is true */
|
||||
{
|
||||
sprintf(pNumBuf,"%d",True);
|
||||
if (iRS == 0) { /* done is true */
|
||||
sprintf(pNumBuf, "%d", True);
|
||||
} else {
|
||||
sprintf(pNumBuf, "%d", False);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(pNumBuf,"%d",False);
|
||||
}
|
||||
Tcl_AppendResult(interp,pNumBuf,(char *) NULL);
|
||||
Tcl_AppendResult(interp, pNumBuf, (char *) NULL);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/* actual counting neutrons in two different modes */
|
||||
if(strcmp(argv[1],"wait") == 0)
|
||||
{
|
||||
if (strcmp(argv[1], "wait") == 0) {
|
||||
iFlag = 2;
|
||||
}
|
||||
if(strcmp(argv[1],"start") == 0)
|
||||
{
|
||||
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);
|
||||
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)
|
||||
{
|
||||
if (strcmp(argv[2], "timer") == 0) {
|
||||
iMode = 1;
|
||||
}
|
||||
else if (strcmp(argv[2],"monitor") == 0)
|
||||
{
|
||||
} else if (strcmp(argv[2], "monitor") == 0) {
|
||||
iMode = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
Tcl_AppendResult(interp,"Usage: ",argv[0],argv[1],
|
||||
" timer or monitor val",NULL);
|
||||
} 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)
|
||||
{
|
||||
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);
|
||||
if (iMode == 1) {
|
||||
iRet = EL737_StartTime(&(pData->pData), (float) dVal, &iRS);
|
||||
} else {
|
||||
iRet = EL737_StartCnt(&(pData->pData), (int) 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);
|
||||
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 */
|
||||
}
|
||||
|
||||
/* 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);
|
||||
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)
|
||||
{
|
||||
} 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);
|
||||
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],
|
||||
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
|
||||
-----------------------------------------------------------------------------*/
|
||||
void EL737Error2Text(char *pBuffer, int iErr)
|
||||
{
|
||||
switch(iErr)
|
||||
{
|
||||
void EL737Error2Text(char *pBuffer, int iErr)
|
||||
{
|
||||
switch (iErr) {
|
||||
case -28:
|
||||
strcpy(pBuffer,"EL737__BAD_ADR");
|
||||
strcpy(pBuffer, "EL737__BAD_ADR");
|
||||
break;
|
||||
case -8:
|
||||
strcpy(pBuffer,"EL737__BAD_OVFL");
|
||||
strcpy(pBuffer, "EL737__BAD_OVFL");
|
||||
break;
|
||||
case -30:
|
||||
strcpy(pBuffer,"EL737__BAD_BSY");
|
||||
strcpy(pBuffer, "EL737__BAD_BSY");
|
||||
break;
|
||||
case -3:
|
||||
strcpy(pBuffer,"EL737__BAD_SNTX");
|
||||
strcpy(pBuffer, "EL737__BAD_SNTX");
|
||||
break;
|
||||
case -9:
|
||||
strcpy(pBuffer,"EL737__BAD_CONNECT");
|
||||
strcpy(pBuffer, "EL737__BAD_CONNECT");
|
||||
break;
|
||||
case -23:
|
||||
strcpy(pBuffer,"EL737__BAD_FLUSH");
|
||||
strcpy(pBuffer, "EL737__BAD_FLUSH");
|
||||
break;
|
||||
case -6:
|
||||
strcpy(pBuffer,"EL734__BAD_DEV");
|
||||
strcpy(pBuffer, "EL734__BAD_DEV");
|
||||
break;
|
||||
case -10:
|
||||
strcpy(pBuffer,"EL737__BAD_ID");
|
||||
strcpy(pBuffer, "EL737__BAD_ID");
|
||||
break;
|
||||
case -5:
|
||||
strcpy(pBuffer,"EL737__BAD_ILLG");
|
||||
strcpy(pBuffer, "EL737__BAD_ILLG");
|
||||
break;
|
||||
case -2:
|
||||
strcpy(pBuffer,"EL737__BAD_LOC");
|
||||
strcpy(pBuffer, "EL737__BAD_LOC");
|
||||
break;
|
||||
case -11:
|
||||
strcpy(pBuffer,"EL737__BAD_MALLOC");
|
||||
strcpy(pBuffer, "EL737__BAD_MALLOC");
|
||||
break;
|
||||
case -21:
|
||||
strcpy(pBuffer,"EL737__BAD_NOT_BCD");
|
||||
strcpy(pBuffer, "EL737__BAD_NOT_BCD");
|
||||
break;
|
||||
case -4:
|
||||
strcpy(pBuffer,"EL737__BAD_OFL");
|
||||
strcpy(pBuffer, "EL737__BAD_OFL");
|
||||
break;
|
||||
case -29:
|
||||
strcpy(pBuffer,"EL737__BAD_PAR");
|
||||
strcpy(pBuffer, "EL737__BAD_PAR");
|
||||
break;
|
||||
|
||||
case -17:
|
||||
strcpy(pBuffer,"EL737__BAD_RECV");
|
||||
strcpy(pBuffer, "EL737__BAD_RECV");
|
||||
break;
|
||||
case -19:
|
||||
strcpy(pBuffer,"EL737__BAD_RECV_NET");
|
||||
strcpy(pBuffer, "EL737__BAD_RECV_NET");
|
||||
break;
|
||||
case -18:
|
||||
strcpy(pBuffer,"EL737__BAD_RECV_PIPE");
|
||||
strcpy(pBuffer, "EL737__BAD_RECV_PIPE");
|
||||
break;
|
||||
case -20:
|
||||
strcpy(pBuffer,"EL737__BAD_RECV_UNKN");
|
||||
strcpy(pBuffer, "EL737__BAD_RECV_UNKN");
|
||||
break;
|
||||
case -22:
|
||||
strcpy(pBuffer,"EL737__BAD_RECVLEN");
|
||||
strcpy(pBuffer, "EL737__BAD_RECVLEN");
|
||||
break;
|
||||
case -24:
|
||||
strcpy(pBuffer,"EL737__BAD_RECV1");
|
||||
strcpy(pBuffer, "EL737__BAD_RECV1");
|
||||
break;
|
||||
case -26:
|
||||
strcpy(pBuffer,"EL737__BAD_RECV1_NET");
|
||||
strcpy(pBuffer, "EL737__BAD_RECV1_NET");
|
||||
break;
|
||||
case -25:
|
||||
strcpy(pBuffer,"EL737__BAD_RECV1_PIPE");
|
||||
strcpy(pBuffer, "EL737__BAD_RECV1_PIPE");
|
||||
break;
|
||||
case -27:
|
||||
strcpy(pBuffer,"EL737__BAD_RNG");
|
||||
strcpy(pBuffer, "EL737__BAD_RNG");
|
||||
break;
|
||||
case -13:
|
||||
strcpy(pBuffer,"EL737__BAD_SEND");
|
||||
strcpy(pBuffer, "EL737__BAD_SEND");
|
||||
break;
|
||||
case -14:
|
||||
strcpy(pBuffer,"EL737__BAD_SEND_PIPE");
|
||||
strcpy(pBuffer, "EL737__BAD_SEND_PIPE");
|
||||
break;
|
||||
case -15:
|
||||
strcpy(pBuffer,"EL737__BAD_SEND_NET");
|
||||
strcpy(pBuffer, "EL737__BAD_SEND_NET");
|
||||
break;
|
||||
case -16:
|
||||
strcpy(pBuffer,"EL737__BAD_SEND_UNKN");
|
||||
strcpy(pBuffer, "EL737__BAD_SEND_UNKN");
|
||||
break;
|
||||
case -12:
|
||||
strcpy(pBuffer,"EL737__BAD_SENDLEN");
|
||||
strcpy(pBuffer, "EL737__BAD_SENDLEN");
|
||||
break;
|
||||
case -7:
|
||||
strcpy(pBuffer,"EL737__BAD_SOCKET");
|
||||
strcpy(pBuffer, "EL737__BAD_SOCKET");
|
||||
break;
|
||||
case -1:
|
||||
strcpy(pBuffer,"EL737__BAD_TMO");
|
||||
strcpy(pBuffer, "EL737__BAD_TMO");
|
||||
break;
|
||||
default:
|
||||
strcpy(pBuffer,"Unknown EL737 error");
|
||||
strcpy(pBuffer, "Unknown EL737 error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,11 +21,11 @@
|
||||
/*
|
||||
** Structure to which the EL755_Open handle points.
|
||||
*/
|
||||
struct EL755info {
|
||||
struct EL755info {
|
||||
struct AsynSrv__info asyn_info; /* Contains skt, host, port & chan */
|
||||
int index;
|
||||
struct RS__MsgStruct to_host;
|
||||
struct RS__RespStruct from_host;
|
||||
};
|
||||
};
|
||||
/*------------------------------------------------ End of EL755_DEF.H --*/
|
||||
#endif /* _el755_def_ */
|
||||
|
@ -16,11 +16,13 @@
|
||||
** routine if he wishes to log these errors in
|
||||
** some other way.
|
||||
*/
|
||||
void EL755_ErrorLog (
|
||||
void EL755_ErrorLog(
|
||||
/* ==============
|
||||
*/ 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 =======*/
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,103 +3,102 @@
|
||||
|
||||
EL734Error2Text converts between an EL734 error code to text
|
||||
-----------------------------------------------------------------------------*/
|
||||
void EL734Error2Text(char *pBuffer, int iErr)
|
||||
{
|
||||
switch(iErr)
|
||||
{
|
||||
void EL734Error2Text(char *pBuffer, int iErr)
|
||||
{
|
||||
switch (iErr) {
|
||||
case -28:
|
||||
strcpy(pBuffer,"EL734__BAD_ADR");
|
||||
strcpy(pBuffer, "EL734__BAD_ADR");
|
||||
break;
|
||||
case -8:
|
||||
strcpy(pBuffer,"EL734__BAD_BIND");
|
||||
strcpy(pBuffer, "EL734__BAD_BIND");
|
||||
break;
|
||||
case -30:
|
||||
strcpy(pBuffer,"EL734__BAD_BSY");
|
||||
strcpy(pBuffer, "EL734__BAD_BSY");
|
||||
break;
|
||||
case -3:
|
||||
strcpy(pBuffer,"EL734__BAD_CMD");
|
||||
strcpy(pBuffer, "EL734__BAD_CMD");
|
||||
break;
|
||||
case -9:
|
||||
strcpy(pBuffer,"EL734__BAD_CONNECT");
|
||||
strcpy(pBuffer, "EL734__BAD_CONNECT");
|
||||
break;
|
||||
case -23:
|
||||
strcpy(pBuffer,"EL734__BAD_FLUSH");
|
||||
strcpy(pBuffer, "EL734__BAD_FLUSH");
|
||||
break;
|
||||
case -6:
|
||||
strcpy(pBuffer,"EL734__BAD_HOST");
|
||||
strcpy(pBuffer, "EL734__BAD_HOST");
|
||||
break;
|
||||
case -10:
|
||||
strcpy(pBuffer,"EL734__BAD_ID");
|
||||
strcpy(pBuffer, "EL734__BAD_ID");
|
||||
break;
|
||||
case -5:
|
||||
strcpy(pBuffer,"EL734__BAD_ILLG");
|
||||
strcpy(pBuffer, "EL734__BAD_ILLG");
|
||||
break;
|
||||
case -2:
|
||||
strcpy(pBuffer,"EL734__BAD_LOC");
|
||||
strcpy(pBuffer, "EL734__BAD_LOC");
|
||||
break;
|
||||
case -11:
|
||||
strcpy(pBuffer,"EL734__BAD_MALLOC");
|
||||
strcpy(pBuffer, "EL734__BAD_MALLOC");
|
||||
break;
|
||||
case -21:
|
||||
strcpy(pBuffer,"EL734__BAD_NOT_BCD");
|
||||
strcpy(pBuffer, "EL734__BAD_NOT_BCD");
|
||||
break;
|
||||
case -4:
|
||||
strcpy(pBuffer,"EL734__BAD_OFL");
|
||||
strcpy(pBuffer, "EL734__BAD_OFL");
|
||||
break;
|
||||
case -29:
|
||||
strcpy(pBuffer,"EL734__BAD_PAR");
|
||||
strcpy(pBuffer, "EL734__BAD_PAR");
|
||||
break;
|
||||
|
||||
case -17:
|
||||
strcpy(pBuffer,"EL734__BAD_RECV");
|
||||
strcpy(pBuffer, "EL734__BAD_RECV");
|
||||
break;
|
||||
case -19:
|
||||
strcpy(pBuffer,"EL734__BAD_RECV_NET");
|
||||
strcpy(pBuffer, "EL734__BAD_RECV_NET");
|
||||
break;
|
||||
case -18:
|
||||
strcpy(pBuffer,"EL734__BAD_RECV_PIPE");
|
||||
strcpy(pBuffer, "EL734__BAD_RECV_PIPE");
|
||||
break;
|
||||
case -20:
|
||||
strcpy(pBuffer,"EL734__BAD_RECV_UNKN");
|
||||
strcpy(pBuffer, "EL734__BAD_RECV_UNKN");
|
||||
break;
|
||||
case -22:
|
||||
strcpy(pBuffer,"EL734__BAD_RECVLEN");
|
||||
strcpy(pBuffer, "EL734__BAD_RECVLEN");
|
||||
break;
|
||||
case -24:
|
||||
strcpy(pBuffer,"EL734__BAD_RECV1");
|
||||
strcpy(pBuffer, "EL734__BAD_RECV1");
|
||||
break;
|
||||
case -26:
|
||||
strcpy(pBuffer,"EL734__BAD_RECV1_NET");
|
||||
strcpy(pBuffer, "EL734__BAD_RECV1_NET");
|
||||
break;
|
||||
case -25:
|
||||
strcpy(pBuffer,"EL734__BAD_RECV1_PIPE");
|
||||
strcpy(pBuffer, "EL734__BAD_RECV1_PIPE");
|
||||
break;
|
||||
case -27:
|
||||
strcpy(pBuffer,"EL734__BAD_RNG");
|
||||
strcpy(pBuffer, "EL734__BAD_RNG");
|
||||
break;
|
||||
case -13:
|
||||
strcpy(pBuffer,"EL734__BAD_SEND");
|
||||
strcpy(pBuffer, "EL734__BAD_SEND");
|
||||
break;
|
||||
case -14:
|
||||
strcpy(pBuffer,"EL734__BAD_SEND_PIPE");
|
||||
strcpy(pBuffer, "EL734__BAD_SEND_PIPE");
|
||||
break;
|
||||
case -15:
|
||||
strcpy(pBuffer,"EL734__BAD_SEND_NET");
|
||||
strcpy(pBuffer, "EL734__BAD_SEND_NET");
|
||||
break;
|
||||
case -16:
|
||||
strcpy(pBuffer,"EL734__BAD_SEND_UNKN");
|
||||
strcpy(pBuffer, "EL734__BAD_SEND_UNKN");
|
||||
break;
|
||||
case -12:
|
||||
strcpy(pBuffer,"EL734__BAD_SENDLEN");
|
||||
strcpy(pBuffer, "EL734__BAD_SENDLEN");
|
||||
break;
|
||||
case -7:
|
||||
strcpy(pBuffer,"EL734__BAD_SOCKET");
|
||||
strcpy(pBuffer, "EL734__BAD_SOCKET");
|
||||
break;
|
||||
case -1:
|
||||
strcpy(pBuffer,"EL734__BAD_TMO");
|
||||
strcpy(pBuffer, "EL734__BAD_TMO");
|
||||
break;
|
||||
default:
|
||||
strcpy(pBuffer,"Unknown EL734 error");
|
||||
strcpy(pBuffer, "Unknown EL734 error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,21 +89,23 @@
|
||||
/*
|
||||
** FailInet: Some network failure has occurred.
|
||||
*/
|
||||
void FailInet (char *text) {
|
||||
void FailInet(char *text)
|
||||
{
|
||||
/* ========
|
||||
** Output the given text and exit the process.
|
||||
*/
|
||||
int my_errno, my_vaxc_errno;
|
||||
|
||||
GetErrno (&my_errno, &my_vaxc_errno);
|
||||
printf ("### Internet Error ###\n");
|
||||
GetErrno(&my_errno, &my_vaxc_errno);
|
||||
printf("### Internet Error ###\n");
|
||||
#ifdef __VMS
|
||||
printf (" ### errno = %d.\n", my_errno);
|
||||
printf (" ### vaxc$errno = %d.\n", my_vaxc_errno);
|
||||
printf(" ### errno = %d.\n", my_errno);
|
||||
printf(" ### vaxc$errno = %d.\n", my_vaxc_errno);
|
||||
#else
|
||||
printf (" ### errno = %d.\n", my_errno);
|
||||
printf(" ### errno = %d.\n", my_errno);
|
||||
#endif
|
||||
perror (text);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
perror(text);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/*------------------------------------------------- End of FAILINET.C =======*/
|
||||
|
@ -82,7 +82,8 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
** 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 */
|
||||
@ -92,5 +93,6 @@
|
||||
*his_vaxc_errno = 1;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------- End of GETERRNO.C =======*/
|
||||
|
@ -45,16 +45,16 @@
|
||||
#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];
|
||||
char pReply[132];
|
||||
pITC4 self = NULL;
|
||||
|
||||
self = (pITC4)malloc(sizeof(ITC4));
|
||||
if(self == NULL)
|
||||
{
|
||||
self = (pITC4) malloc(sizeof(ITC4));
|
||||
if (self == NULL) {
|
||||
return ITC4__BADMALLOC;
|
||||
}
|
||||
*pData = self;
|
||||
@ -65,8 +65,7 @@
|
||||
self->fMult = 10.;
|
||||
|
||||
iRet = SerialOpen(&self->pData, pHost, iPort, iChannel);
|
||||
if(iRet != 1)
|
||||
{
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
|
||||
@ -74,8 +73,7 @@
|
||||
prevent problems.
|
||||
*/
|
||||
iRet = SerialConfig(&self->pData, 100);
|
||||
if(iRet != 1)
|
||||
{
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
|
||||
@ -86,79 +84,68 @@
|
||||
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)
|
||||
{
|
||||
iRet = SerialWriteRead(&self->pData, "V\r\n", pReply, 131);
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
if(strstr(pReply,"ITC503") != NULL)
|
||||
{
|
||||
if (strstr(pReply, "ITC503") != NULL) {
|
||||
self->i503 = 1;
|
||||
}
|
||||
|
||||
if(!self->iReadOnly)
|
||||
{
|
||||
if (!self->iReadOnly) {
|
||||
/* switch to remote and locked operation */
|
||||
iRet = SerialWriteRead(&self->pData,"C3\r\n",pReply,131);
|
||||
if(iRet != 1)
|
||||
{
|
||||
iRet = SerialWriteRead(&self->pData, "C3\r\n", pReply, 131);
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
if(pReply[0] == '?')
|
||||
{
|
||||
strcpy(self->pAns,pReply);
|
||||
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)
|
||||
{
|
||||
iRet = SerialWriteRead(&self->pData, "A0\r\n", pReply, 131);
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
if(pReply[0] == '?')
|
||||
{
|
||||
strcpy(self->pAns,pReply);
|
||||
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)
|
||||
{
|
||||
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);
|
||||
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)
|
||||
{
|
||||
iRet = SerialWriteRead(&self->pData, "A3\r\n", pReply, 131);
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
if(pReply[0] == '?')
|
||||
{
|
||||
strcpy(self->pAns,pReply);
|
||||
if (pReply[0] == '?') {
|
||||
strcpy(self->pAns, pReply);
|
||||
return ITC4__BADCOM;
|
||||
}
|
||||
/* reset timeout */
|
||||
iRet = SerialConfig(&self->pData, 10);
|
||||
if(iRet != 1)
|
||||
{
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void ITC4_Close(pITC4 *pData)
|
||||
{
|
||||
void ITC4_Close(pITC4 * pData)
|
||||
{
|
||||
char pReply[132];
|
||||
int iRet;
|
||||
pITC4 self;
|
||||
@ -166,7 +153,7 @@
|
||||
self = *pData;
|
||||
|
||||
/* switch to local operation */
|
||||
iRet = SerialWriteRead(&self->pData,"C0\r\n",pReply,131);
|
||||
iRet = SerialWriteRead(&self->pData, "C0\r\n", pReply, 131);
|
||||
/* ignore errors on this one, the thing may be down */
|
||||
|
||||
/* close connection */
|
||||
@ -175,11 +162,12 @@
|
||||
/* free memory */
|
||||
free(self);
|
||||
*pData = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int ITC4_Config(pITC4 *pData, int iTmo, int iRead, int iControl,
|
||||
float fDiv,float fMult)
|
||||
{
|
||||
int ITC4_Config(pITC4 * pData, int iTmo, int iRead, int iControl,
|
||||
float fDiv, float fMult)
|
||||
{
|
||||
int iRet;
|
||||
char pReply[132];
|
||||
char pCommand[10];
|
||||
@ -188,60 +176,50 @@
|
||||
self = *pData;
|
||||
|
||||
/* first timeout */
|
||||
if(iTmo > 0)
|
||||
{
|
||||
if (iTmo > 0) {
|
||||
iRet = SerialConfig(&self->pData, iTmo);
|
||||
if(iRet != 1)
|
||||
{
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read Sensor */
|
||||
if( (iRead > 0) && (iRead < 5) && (self->iRead != iRead) )
|
||||
{
|
||||
if ((iRead > 0) && (iRead < 5) && (self->iRead != iRead)) {
|
||||
self->iRead = iRead;
|
||||
}
|
||||
|
||||
/* Control Sensor */
|
||||
if( (iControl > 0) && (iControl < 5) )
|
||||
{
|
||||
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)
|
||||
{
|
||||
iRet = SerialWriteRead(&self->pData, "A0\r\n", pReply, 131);
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
if(pReply[0] == '?')
|
||||
{
|
||||
strcpy(self->pAns,pReply);
|
||||
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)
|
||||
{
|
||||
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);
|
||||
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)
|
||||
{
|
||||
iRet = SerialWriteRead(&self->pData, "A3\r\n", pReply, 131);
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
if(pReply[0] == '?')
|
||||
{
|
||||
strcpy(self->pAns,pReply);
|
||||
if (pReply[0] == '?') {
|
||||
strcpy(self->pAns, pReply);
|
||||
return ITC4__BADCOM;
|
||||
}
|
||||
}
|
||||
@ -249,24 +227,25 @@
|
||||
self->fMult = fMult;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int ITC4_Send(pITC4 *pData, char *pCommand, char *pReply, int iLen)
|
||||
{
|
||||
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);
|
||||
if (strchr(pCommand, (int) '\r') == NULL) {
|
||||
strcat(pCommand, "\r");
|
||||
}
|
||||
return SerialWriteRead(&self->pData, pCommand, pReply, iLen);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int ITC4_Read(pITC4 *pData, float *fVal)
|
||||
{
|
||||
int ITC4_Read(pITC4 * pData, float *fVal)
|
||||
{
|
||||
char pCommand[10], pReply[132];
|
||||
int iRet;
|
||||
float fRead = -9999999.;
|
||||
@ -276,43 +255,37 @@
|
||||
|
||||
|
||||
/* format and send R command */
|
||||
sprintf(pCommand,"R%1.1d\r\n",self->iRead);
|
||||
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
|
||||
if(iRet != 1)
|
||||
{
|
||||
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);
|
||||
if (pReply[0] == '?') {
|
||||
strcpy(self->pAns, pReply);
|
||||
return ITC4__BADCOM;
|
||||
}
|
||||
|
||||
/* analyse reply */
|
||||
if(pReply[0] != 'R')
|
||||
{
|
||||
strcpy(self->pAns,pReply);
|
||||
if (pReply[0] != 'R') {
|
||||
strcpy(self->pAns, pReply);
|
||||
return ITC4__BADCOM;
|
||||
}
|
||||
|
||||
iRet = sscanf(&pReply[1],"%f",&fRead);
|
||||
if(iRet != 1)
|
||||
{
|
||||
iRet = sscanf(&pReply[1], "%f", &fRead);
|
||||
if (iRet != 1) {
|
||||
return ITC4__BADREAD;
|
||||
}
|
||||
if(self->i503)
|
||||
{
|
||||
if (self->i503) {
|
||||
*fVal = fRead;
|
||||
}
|
||||
else
|
||||
{
|
||||
*fVal = fRead/self->fDiv;
|
||||
} else {
|
||||
*fVal = fRead / self->fDiv;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int ITC4_Set(pITC4 *pData, float fVal)
|
||||
{
|
||||
int ITC4_Set(pITC4 * pData, float fVal)
|
||||
{
|
||||
char pCommand[10], pReply[132];
|
||||
int iRet, i, iRead;
|
||||
const float fPrecision = 0.0001;
|
||||
@ -322,38 +295,31 @@
|
||||
|
||||
self = *pData;
|
||||
|
||||
if(self->iReadOnly)
|
||||
{
|
||||
if (self->iReadOnly) {
|
||||
return ITC4__READONLY;
|
||||
}
|
||||
|
||||
/* format command */
|
||||
if(self->i503)
|
||||
{
|
||||
sprintf(pCommand,"T%-7.3f\r\n",fVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
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++)
|
||||
{
|
||||
for (i = 0; i < 3; i++) {
|
||||
/* send command */
|
||||
iRet = SerialWriteRead(&self->pData,pCommand,pReply,131);
|
||||
if(iRet != 1)
|
||||
{
|
||||
iRet = SerialWriteRead(&self->pData, pCommand, pReply, 131);
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
if(pReply[0] == '?')
|
||||
{
|
||||
strcpy(self->pAns,pReply);
|
||||
if (pReply[0] == '?') {
|
||||
strcpy(self->pAns, pReply);
|
||||
return ITC4__BADCOM;
|
||||
}
|
||||
/* read the set value again */
|
||||
@ -361,61 +327,58 @@
|
||||
self->iRead = 0; /* make a R0 */
|
||||
fDum = self->fDiv;
|
||||
self->fDiv = self->fMult;
|
||||
iRet = ITC4_Read(pData,&fRead);
|
||||
iRet = ITC4_Read(pData, &fRead);
|
||||
self->iRead = iRead;
|
||||
self->fDiv = fDum;
|
||||
if(iRet != 1)
|
||||
{
|
||||
if (iRet != 1) {
|
||||
return iRet;
|
||||
}
|
||||
/* check the value read back */
|
||||
if(self->i503)
|
||||
{
|
||||
if (self->i503) {
|
||||
fDelta = fRead - fVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
fDelta = fRead - fSet;
|
||||
}
|
||||
if(fDelta < 0)
|
||||
if (fDelta < 0)
|
||||
fDelta = -fDelta;
|
||||
if(fDelta < fPrecision)
|
||||
{
|
||||
if (fDelta < fPrecision) {
|
||||
/* Success, go home */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return ITC4__BADSET;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
void ITC4_ErrorTxt(pITC4 *pData,int iCode, char *pError, int iLen)
|
||||
{
|
||||
void ITC4_ErrorTxt(pITC4 * pData, int iCode, char *pError, int iLen)
|
||||
{
|
||||
char pBueffel[512];
|
||||
pITC4 self;
|
||||
|
||||
self = *pData;
|
||||
|
||||
switch(iCode)
|
||||
{
|
||||
switch (iCode) {
|
||||
case ITC4__BADCOM:
|
||||
sprintf(pBueffel,"ITC4: Invalid command or offline, got %s",
|
||||
sprintf(pBueffel, "ITC4: Invalid command or offline, got %s",
|
||||
self->pAns);
|
||||
strncpy(pError,pBueffel,iLen);
|
||||
strncpy(pError, pBueffel, iLen);
|
||||
break;
|
||||
case ITC4__BADPAR:
|
||||
strncpy(pError,"ITC4: Invalid parameter specified",iLen);
|
||||
strncpy(pError, "ITC4: Invalid parameter specified", iLen);
|
||||
break;
|
||||
case ITC4__BADMALLOC:
|
||||
strncpy(pError,"ITC4: Error allocating memory in ITC4",iLen);
|
||||
strncpy(pError, "ITC4: Error allocating memory in ITC4", iLen);
|
||||
break;
|
||||
case ITC4__BADREAD:
|
||||
strncpy(pError,"ITC4: Badly formatted answer",iLen);
|
||||
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);
|
||||
strncpy(pError,
|
||||
"ITC4: Failed three times to write new set value to ITC4",
|
||||
iLen);
|
||||
break;
|
||||
default:
|
||||
SerialError(iCode, pError,iLen);
|
||||
SerialError(iCode, pError, iLen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
/* failed three times to set temperature */
|
||||
#define ITC4__READONLY -531
|
||||
/*------------------------------------------------------------------------*/
|
||||
typedef struct __ITC4 {
|
||||
typedef struct __ITC4 {
|
||||
int iRead;
|
||||
int iControl;
|
||||
void *pData;
|
||||
@ -38,13 +38,14 @@
|
||||
float fDiv;
|
||||
float fMult;
|
||||
int iReadOnly;
|
||||
int i503; /* flag for model 503, understanding float*/
|
||||
} ITC4;
|
||||
int i503; /* flag for model 503, understanding float */
|
||||
} 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
|
||||
controller. Input Parameters are:
|
||||
the hostname
|
||||
@ -57,14 +58,14 @@
|
||||
|
||||
*/
|
||||
|
||||
void ITC4_Close(pITC4 *pData);
|
||||
void ITC4_Close(pITC4 * pData);
|
||||
/****** close a connection to an ITC4controller and frees its
|
||||
data structure. The only parameter is a pointer to the data
|
||||
structure for this controller. This pointer will be invalid after
|
||||
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);
|
||||
/***** configure some aspects of a ITC4temperature controller.
|
||||
The parameter are:
|
||||
@ -81,7 +82,7 @@
|
||||
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.
|
||||
A possible reply is returned in the buffer pReply.
|
||||
Maximum iLen characters are copied to pReply.
|
||||
@ -92,7 +93,7 @@
|
||||
failure.
|
||||
*/
|
||||
|
||||
int ITC4_Read(pITC4 *pData, float *fVal);
|
||||
int ITC4_Read(pITC4 * pData, float *fVal);
|
||||
/******* reads the current actual temperature of the sensor
|
||||
configured by ConfigITC4for reading. The value is returned
|
||||
in fVal. The first parameter is a pointer to a ITCL4
|
||||
@ -102,7 +103,7 @@
|
||||
failure.
|
||||
*/
|
||||
|
||||
int ITC4_Set(pITC4 *pData, float fVal);
|
||||
int ITC4_Set(pITC4 * pData, float fVal);
|
||||
/****** sets a new preset temperature in the ITC4temperature
|
||||
controller. Parameters are:
|
||||
- a pointer to a ITC4data structure as returned by OpenITCL4.
|
||||
@ -112,7 +113,7 @@
|
||||
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
|
||||
into text. Maximum iLen bytes will be copied to the
|
||||
buffer pError;
|
||||
@ -120,5 +121,3 @@
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -154,7 +154,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef FORTIFY
|
||||
#include <fortify.h>
|
||||
#include <fortify.h>
|
||||
#endif
|
||||
|
||||
#include <sinq_prototypes.h>
|
||||
@ -167,7 +167,8 @@
|
||||
**--------------------------------------------------------------------------
|
||||
** 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.
|
||||
@ -182,95 +183,141 @@
|
||||
}
|
||||
|
||||
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;
|
||||
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 += sprintf(pntr, "\\%3.3o", in);
|
||||
} else {
|
||||
*pntr++ = in;
|
||||
}
|
||||
}
|
||||
out_size = (out_size > (pntr - buff)) ? (pntr - buff) : out_size;
|
||||
memcpy (out, buff, out_size);
|
||||
memcpy(out, buff, out_size);
|
||||
return out_size;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
**--------------------------------------------------------------------------
|
||||
** MakeMemPrintable: alternative version of MakePrintable.
|
||||
*/
|
||||
char *MakeMemPrintable (
|
||||
char *MakeMemPrintable(
|
||||
/* ================
|
||||
*/ char *out,
|
||||
int out_size,
|
||||
char *in,
|
||||
int in_len) {
|
||||
int out_size, char *in, int in_len)
|
||||
{
|
||||
|
||||
int i;
|
||||
char *pntr;
|
||||
|
||||
if (out_size <= 0) return out;
|
||||
if (out_size <= 0)
|
||||
return out;
|
||||
|
||||
while ((out_size > 1) && (in_len > 0)) {
|
||||
i = MakeCharPrintable (out, (out_size - 1), *in);
|
||||
out += i; out_size -= i;
|
||||
in++; in_len--;
|
||||
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.
|
||||
*/
|
||||
char *MakePrint (char *chr) {
|
||||
char *MakePrint(char *chr)
|
||||
{
|
||||
/* =========
|
||||
*/
|
||||
int len, i;
|
||||
|
||||
for (i = 0; chr[i] != NIL; i++) chr[i] &= 0x7F;
|
||||
for (i = 0; chr[i] != NIL; i++)
|
||||
chr[i] &= 0x7F;
|
||||
|
||||
len = strlen (chr);
|
||||
if (len <= 0) return chr;
|
||||
len = strlen(chr);
|
||||
if (len <= 0)
|
||||
return chr;
|
||||
|
||||
if (chr[len-1] == '\r') chr[len-1] = NIL;
|
||||
if (chr[len-1] == '\n') chr[len-1] = NIL;
|
||||
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] = '.';
|
||||
if (chr[i] < ' ')
|
||||
chr[i] = '.';
|
||||
if (chr[i] == 0x7F)
|
||||
chr[i] = '.';
|
||||
}
|
||||
|
||||
return chr;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
**--------------------------------------------------------------------------
|
||||
** MakePrintable: improved version of MakePrint.
|
||||
*/
|
||||
char *MakePrintable (
|
||||
char *MakePrintable(
|
||||
/* =============
|
||||
*/ char *out,
|
||||
int out_size,
|
||||
char *in) {
|
||||
int out_size, char *in)
|
||||
{
|
||||
|
||||
int i;
|
||||
char *pntr;
|
||||
|
||||
if (out_size <= 0) return out;
|
||||
if (out_size <= 0)
|
||||
return out;
|
||||
|
||||
while ((out_size > 1) && (*in != NIL)) {
|
||||
i = MakeCharPrintable (out, (out_size - 1), *in);
|
||||
in++; out += i; out_size -= i;
|
||||
i = MakeCharPrintable(out, (out_size - 1), *in);
|
||||
in++;
|
||||
out += i;
|
||||
out_size -= i;
|
||||
}
|
||||
*out = NIL;
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------- End of MakePrint.C =======*/
|
||||
|
@ -76,7 +76,7 @@
|
||||
**
|
||||
** 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_id[4];
|
||||
char c_pcol_lvl[4]; /* Client protocol level */
|
||||
@ -85,19 +85,19 @@
|
||||
char terms[4];
|
||||
char n_cmnds[4];
|
||||
char cmnds[356];
|
||||
};
|
||||
};
|
||||
/*
|
||||
** The "cmnds" buffer in RS__MsgStruct is a concatenated
|
||||
** list of the following structures.
|
||||
*/
|
||||
struct RS__CmndStruct {
|
||||
struct RS__CmndStruct {
|
||||
char cmnd_len[2];
|
||||
char cmnd[1];
|
||||
};
|
||||
struct RS__CmndStruct_V01B {
|
||||
};
|
||||
struct RS__CmndStruct_V01B {
|
||||
char cmnd_len[4];
|
||||
char cmnd[1];
|
||||
};
|
||||
};
|
||||
/*----------------------------------------------------------------------------
|
||||
** Structure of Reply from Server to Client - everything is sent in ASCII
|
||||
** for LabView's benefit.
|
||||
@ -150,7 +150,7 @@
|
||||
**
|
||||
** An example of a reply item might be: "0009\r12.3456\0"
|
||||
**--------------------------------------------------------------------------*/
|
||||
struct RS__RespStruct {
|
||||
struct RS__RespStruct {
|
||||
char msg_size[4];
|
||||
char msg_id[4];
|
||||
char s_pcol_lvl[4]; /* Server protocol level */
|
||||
@ -159,12 +159,12 @@
|
||||
char rplys[496];
|
||||
char sub_status[12];
|
||||
} u;
|
||||
};
|
||||
};
|
||||
/*
|
||||
** The "rplys" buffer in RS__RespStruct is a
|
||||
** concatenated list of the following structures.
|
||||
*/
|
||||
struct RS__RplyStruct {
|
||||
struct RS__RplyStruct {
|
||||
char rply_len[2]; /* 2 ASCII decimal chars!!
|
||||
** The length includes the
|
||||
** terminator, term, and the
|
||||
@ -172,8 +172,8 @@
|
||||
*/
|
||||
char term; /* The terminating character */
|
||||
char rply[1]; /* Zero terminated string */
|
||||
};
|
||||
struct RS__RplyStruct_V01B {
|
||||
};
|
||||
struct RS__RplyStruct_V01B {
|
||||
char rply_len[4]; /* 4 ASCII decimal chars!!
|
||||
** The length includes the
|
||||
** terminator, term, and the
|
||||
@ -181,6 +181,6 @@
|
||||
*/
|
||||
char term; /* The terminating character */
|
||||
char rply[1]; /* Zero terminated string */
|
||||
};
|
||||
};
|
||||
/*------------------------------------------------ End of RS232C_DEF.H --*/
|
||||
#endif /* _rs232c_def_ */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -22,25 +22,25 @@
|
||||
|
||||
#line 30 "velodorn.w"
|
||||
|
||||
int SerialOpen(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 SerialGetTmo(void **pData);
|
||||
int SerialATerm(void **pData, char *pTerm);
|
||||
int SerialAGetTerm(void **pData, char *pTerm, int iTermLen);
|
||||
int SerialSendTerm(void **pData, char *pTerm);
|
||||
int SerialGetSocket(void **pData);
|
||||
int SerialClose(void **pData);
|
||||
int SerialForceClose(void **pData);
|
||||
int SerialOpen(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 SerialGetTmo(void **pData);
|
||||
int SerialATerm(void **pData, char *pTerm);
|
||||
int SerialAGetTerm(void **pData, char *pTerm, int iTermLen);
|
||||
int SerialSendTerm(void **pData, char *pTerm);
|
||||
int SerialGetSocket(void **pData);
|
||||
int SerialClose(void **pData);
|
||||
int SerialForceClose(void **pData);
|
||||
|
||||
int SerialSend(void **pData, char *pCommand);
|
||||
int SerialReceive(void **pData, char *pBuffer, int iBufLen);
|
||||
int SerialReceiveWithTerm(void **pData, char *pBuffer,
|
||||
int iBufLen,char *cTerm);
|
||||
int SerialError(int iError, char *pError, int iErrLen);
|
||||
int SerialWriteRead(void **pData, char *pCommand,
|
||||
int SerialSend(void **pData, char *pCommand);
|
||||
int SerialReceive(void **pData, char *pBuffer, int iBufLen);
|
||||
int SerialReceiveWithTerm(void **pData, char *pBuffer,
|
||||
int iBufLen, char *cTerm);
|
||||
int SerialError(int iError, char *pError, int iErrLen);
|
||||
int SerialWriteRead(void **pData, char *pCommand,
|
||||
char *pBuffer, int iBufLen);
|
||||
int SerialNoReply(void **pData, char *pCommand);
|
||||
int SerialNoReply(void **pData, char *pCommand);
|
||||
|
||||
#line 175 "velodorn.w"
|
||||
|
||||
@ -48,8 +48,8 @@
|
||||
|
||||
#line 116 "velodorn.w"
|
||||
|
||||
typedef int (*SerialSleep)(void *pData, int iTime);
|
||||
void SetSerialSleep(void **pData, SerialSleep pFunc, void *pUserData);
|
||||
typedef int (*SerialSleep) (void *pData, int iTime);
|
||||
void SetSerialSleep(void **pData, SerialSleep pFunc, void *pUserData);
|
||||
|
||||
#line 177 "velodorn.w"
|
||||
|
||||
|
@ -19,656 +19,242 @@
|
||||
#include <el737_def.h>
|
||||
#endif
|
||||
/*---------------------------------------------------------------------*/
|
||||
int AsynSrv_ChanClose (
|
||||
struct AsynSrv__info *asyn_info);
|
||||
int AsynSrv_Close (
|
||||
struct AsynSrv__info *asyn_info,
|
||||
int force_flag);
|
||||
int AsynSrv_Config (
|
||||
struct AsynSrv__info *asyn_info,
|
||||
...);
|
||||
int AsynSrv_ConfigDflt (
|
||||
char *par_id,
|
||||
...);
|
||||
void AsynSrv_ErrInfo (
|
||||
char **entry_txt,
|
||||
int *errcode,
|
||||
int *my_errno,
|
||||
int *vaxc_errno);
|
||||
int AsynSrv_Flush (
|
||||
struct AsynSrv__info *asyn_info);
|
||||
int AsynSrv_GetLenTerm (
|
||||
struct AsynSrv__info *asyn_info,
|
||||
int AsynSrv_ChanClose(struct AsynSrv__info *asyn_info);
|
||||
int AsynSrv_Close(struct AsynSrv__info *asyn_info, int force_flag);
|
||||
int AsynSrv_Config(struct AsynSrv__info *asyn_info, ...);
|
||||
int AsynSrv_ConfigDflt(char *par_id, ...);
|
||||
void AsynSrv_ErrInfo(char **entry_txt,
|
||||
int *errcode, int *my_errno, int *vaxc_errno);
|
||||
int AsynSrv_Flush(struct AsynSrv__info *asyn_info);
|
||||
int AsynSrv_GetLenTerm(struct AsynSrv__info *asyn_info,
|
||||
struct RS__RespStruct *rcve_buff,
|
||||
char *rply,
|
||||
int *len,
|
||||
char *term);
|
||||
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,
|
||||
char *rply, int *len, char *term);
|
||||
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__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 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 (
|
||||
char *name,
|
||||
int arr_size,
|
||||
int *value,
|
||||
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_log_arr_get(char *name, int arr_size, int *value, 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 (
|
||||
char *out,
|
||||
char *in,
|
||||
char *ctrl,
|
||||
int *length);
|
||||
int C_str_edit(char *out, char *in, char *ctrl, int *length);
|
||||
/*---------------------------------------------------------------------*/
|
||||
int C_tt_port_config (
|
||||
int *hndl,
|
||||
int mask);
|
||||
int C_tt_port_connect (
|
||||
int *hndl,
|
||||
int *chan,
|
||||
char *lognam,
|
||||
char *pwd);
|
||||
int C_tt_port_disconnect (
|
||||
int *hndl);
|
||||
int C_tt_port_io (
|
||||
int *hndl,
|
||||
int C_tt_port_config(int *hndl, int mask);
|
||||
int C_tt_port_connect(int *hndl, int *chan, char *lognam, 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);
|
||||
char *answ, int *answ_len, int flush, int tmo);
|
||||
/*---------------------------------------------------------------------*/
|
||||
int EL734_Close (
|
||||
void **handle,
|
||||
int force_flag);
|
||||
int EL734_Config (
|
||||
void **handle,
|
||||
...);
|
||||
char *EL734_EncodeMSR (
|
||||
char *text,
|
||||
int EL734_Close(void **handle, int force_flag);
|
||||
int EL734_Config(void **handle, ...);
|
||||
char *EL734_EncodeMSR(char *text,
|
||||
int text_len,
|
||||
int msr,
|
||||
int ored_msr,
|
||||
int fp_cntr,
|
||||
int fr_cntr);
|
||||
char *EL734_EncodeSS (
|
||||
char *text,
|
||||
int text_len,
|
||||
int ss);
|
||||
void EL734_ErrInfo (
|
||||
char **entry_txt,
|
||||
int *errcode,
|
||||
int *my_errno,
|
||||
int *vaxc_errno);
|
||||
int EL734_GetAirCush (
|
||||
void **handle,
|
||||
int *present,
|
||||
int *state);
|
||||
int EL734_GetEncGearing (
|
||||
void **handle,
|
||||
int *nominator,
|
||||
int *denominator);
|
||||
int EL734_GetId (
|
||||
void **handle,
|
||||
char *id_txt,
|
||||
int id_len);
|
||||
int EL734_GetLimits (
|
||||
void **handle,
|
||||
float *lo,
|
||||
float *hi);
|
||||
int EL734_GetMotorGearing (
|
||||
void **handle,
|
||||
int *nominator,
|
||||
int *denominator);
|
||||
int EL734_GetNullPoint (
|
||||
void **handle,
|
||||
int *null_pt);
|
||||
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);
|
||||
char *EL734_EncodeSS(char *text, int text_len, int ss);
|
||||
void EL734_ErrInfo(char **entry_txt,
|
||||
int *errcode, int *my_errno, int *vaxc_errno);
|
||||
int EL734_GetAirCush(void **handle, int *present, int *state);
|
||||
int EL734_GetEncGearing(void **handle, int *nominator, int *denominator);
|
||||
int EL734_GetId(void **handle, char *id_txt, int id_len);
|
||||
int EL734_GetLimits(void **handle, float *lo, float *hi);
|
||||
int EL734_GetMotorGearing(void **handle, int *nominator, int *denominator);
|
||||
int EL734_GetNullPoint(void **handle, int *null_pt);
|
||||
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,
|
||||
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 *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 *fp_cntr, int *fr_cntr, float *ist_posit);
|
||||
void EL734_ZeroStatus(void **handle);
|
||||
/*---------------------------------------------------------------------*/
|
||||
int EL737_Close (
|
||||
void **handle,
|
||||
int force_flag);
|
||||
int EL737_Config (
|
||||
void **handle,
|
||||
...);
|
||||
int EL737_Continue (
|
||||
void **handle,
|
||||
int *status);
|
||||
int EL737_EnableThresh (
|
||||
void **handle,
|
||||
int indx);
|
||||
void EL737_ErrInfo (
|
||||
char **entry_txt,
|
||||
int *errcode,
|
||||
int *my_errno,
|
||||
int *vaxc_errno);
|
||||
int EL737_GetMonIntegTime (
|
||||
void **handle,
|
||||
int indx,
|
||||
float *mon_integ_time);
|
||||
int EL737_GetRateIntegTime (
|
||||
void **handle,
|
||||
float *rate_integ_time);
|
||||
void *EL737_GetReply (
|
||||
void **handle,
|
||||
void *last_rply);
|
||||
int EL737_GetStatus (
|
||||
void **handle,
|
||||
int EL737_Close(void **handle, int force_flag);
|
||||
int EL737_Config(void **handle, ...);
|
||||
int EL737_Continue(void **handle, int *status);
|
||||
int EL737_EnableThresh(void **handle, int indx);
|
||||
void EL737_ErrInfo(char **entry_txt,
|
||||
int *errcode, int *my_errno, int *vaxc_errno);
|
||||
int EL737_GetMonIntegTime(void **handle, int indx, float *mon_integ_time);
|
||||
int EL737_GetRateIntegTime(void **handle, float *rate_integ_time);
|
||||
void *EL737_GetReply(void **handle, void *last_rply);
|
||||
int EL737_GetStatus(void **handle,
|
||||
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 *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 *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 (
|
||||
void **handle,
|
||||
int force_flag);
|
||||
int EL755_Config (
|
||||
void **handle,
|
||||
...);
|
||||
void EL755_ErrInfo (
|
||||
char **entry_txt,
|
||||
int *errcode,
|
||||
int *my_errno,
|
||||
int *vaxc_errno);
|
||||
int EL755_ErrorLog (
|
||||
char *routine_name,
|
||||
char *text);
|
||||
int EL755_GetConstant (
|
||||
void **handle,
|
||||
float *value);
|
||||
int EL755_GetCurrents (
|
||||
void **handle,
|
||||
float *soll,
|
||||
float *ist);
|
||||
int EL755_GetId (
|
||||
void **handle,
|
||||
char *id_txt,
|
||||
int id_len);
|
||||
int EL755_GetLimit (
|
||||
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 EL755_Close(void **handle, int force_flag);
|
||||
int EL755_Config(void **handle, ...);
|
||||
void EL755_ErrInfo(char **entry_txt,
|
||||
int *errcode, int *my_errno, int *vaxc_errno);
|
||||
int EL755_ErrorLog(char *routine_name, char *text);
|
||||
int EL755_GetConstant(void **handle, float *value);
|
||||
int EL755_GetCurrents(void **handle, float *soll, float *ist);
|
||||
int EL755_GetId(void **handle, char *id_txt, int id_len);
|
||||
int EL755_GetLimit(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 (
|
||||
void **handle,
|
||||
int force_flag);
|
||||
int Fluke_Config (
|
||||
void **handle,
|
||||
...);
|
||||
void Fluke_ErrInfo (
|
||||
char **entry_txt,
|
||||
int *errcode,
|
||||
int *my_errno,
|
||||
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 Fluke_Close(void **handle, int force_flag);
|
||||
int Fluke_Config(void **handle, ...);
|
||||
void Fluke_ErrInfo(char **entry_txt,
|
||||
int *errcode, int *my_errno, 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 (
|
||||
void **handle,
|
||||
int force_flag);
|
||||
int ITC_Config (
|
||||
void **handle,
|
||||
...);
|
||||
int ITC_Dump_RAM (
|
||||
void **handle,
|
||||
int buff_size,
|
||||
char *buff,
|
||||
int *dump_len,
|
||||
int *n_diffs);
|
||||
void ITC_ErrInfo (
|
||||
char **entry_txt,
|
||||
int *errcode,
|
||||
int *my_errno,
|
||||
int *vaxc_errno);
|
||||
int ITC_GetConfig (
|
||||
void **handle,
|
||||
...);
|
||||
int ITC_Load_RAM (
|
||||
void **handle,
|
||||
int load_len,
|
||||
char *buff);
|
||||
int ITC_Load_Table (
|
||||
void **handle,
|
||||
char *buff);
|
||||
int ITC_Open (
|
||||
void **handle,
|
||||
char *host,
|
||||
int port,
|
||||
int chan);
|
||||
int ITC_Read_ITC_Sensor (
|
||||
void **handle,
|
||||
int sensor,
|
||||
float factor,
|
||||
float *value);
|
||||
int ITC_Read_LTC11_Sensor (
|
||||
void **handle,
|
||||
int sensor,
|
||||
float *value);
|
||||
int ITC_Read_LTC11_SetPt (
|
||||
void **handle,
|
||||
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,
|
||||
int ITC_Close(void **handle, int force_flag);
|
||||
int ITC_Config(void **handle, ...);
|
||||
int ITC_Dump_RAM(void **handle,
|
||||
int buff_size, char *buff, int *dump_len, int *n_diffs);
|
||||
void ITC_ErrInfo(char **entry_txt,
|
||||
int *errcode, int *my_errno, int *vaxc_errno);
|
||||
int ITC_GetConfig(void **handle, ...);
|
||||
int ITC_Load_RAM(void **handle, int load_len, char *buff);
|
||||
int ITC_Load_Table(void **handle, char *buff);
|
||||
int ITC_Open(void **handle, char *host, int port, int chan);
|
||||
int ITC_Read_ITC_Sensor(void **handle,
|
||||
int sensor, float factor, float *value);
|
||||
int ITC_Read_LTC11_Sensor(void **handle, int sensor, float *value);
|
||||
int ITC_Read_LTC11_SetPt(void **handle, 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,
|
||||
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);
|
||||
int ITC_SendTillSame (
|
||||
void **handle,
|
||||
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_SendTillSameLen (
|
||||
void **handle,
|
||||
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_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);
|
||||
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 (
|
||||
void **handle,
|
||||
int force_flag);
|
||||
int SPS_Config (
|
||||
void **handle,
|
||||
...);
|
||||
void SPS_ErrInfo (
|
||||
char **entry_txt,
|
||||
int *errcode,
|
||||
int *my_errno,
|
||||
int *vaxc_errno);
|
||||
int SPS_ErrorLog (
|
||||
char *routine_name,
|
||||
char *text);
|
||||
int SPS_GetStatus (
|
||||
void **handle,
|
||||
int SPS_Close(void **handle, int force_flag);
|
||||
int SPS_Config(void **handle, ...);
|
||||
void SPS_ErrInfo(char **entry_txt,
|
||||
int *errcode, int *my_errno, int *vaxc_errno);
|
||||
int SPS_ErrorLog(char *routine_name, char *text);
|
||||
int SPS_GetStatus(void **handle,
|
||||
unsigned char *status_vals,
|
||||
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,
|
||||
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,
|
||||
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);
|
||||
char *cmnd, char *rply, int rply_len);
|
||||
/*---------------------------------------------------------------------*/
|
||||
int VelSel_Close (
|
||||
void **handle,
|
||||
int force_flag);
|
||||
void VelSel_Config (
|
||||
void **handle,
|
||||
int msec_tmo,
|
||||
char *eot_str);
|
||||
void VelSel_ErrInfo (
|
||||
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);
|
||||
int VelSel_Close(void **handle, int force_flag);
|
||||
void VelSel_Config(void **handle, int msec_tmo, char *eot_str);
|
||||
void VelSel_ErrInfo(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 (
|
||||
char *text);
|
||||
void GetErrno (
|
||||
int *his_errno,
|
||||
int *his_vaxc_errno);
|
||||
int MakeCharPrintable (
|
||||
char *out,
|
||||
int out_size,
|
||||
char in);
|
||||
char *MakePrint (
|
||||
char *text);
|
||||
char *MakePrintable (
|
||||
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,
|
||||
...);
|
||||
void FailInet(char *text);
|
||||
void GetErrno(int *his_errno, int *his_vaxc_errno);
|
||||
int MakeCharPrintable(char *out, int out_size, char in);
|
||||
char *MakePrint(char *text);
|
||||
char *MakePrintable(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 --*/
|
||||
#endif /* _sinq_prototypes_loaded_ */
|
||||
|
1217
hardsup/sinqhm.c
1217
hardsup/sinqhm.c
File diff suppressed because it is too large
Load Diff
@ -14,7 +14,7 @@
|
||||
#define SINQHMUTILITY
|
||||
#include "sinqhm_def.h"
|
||||
|
||||
typedef struct __SINQHM *pSINQHM;
|
||||
typedef struct __SINQHM *pSINQHM;
|
||||
/*------------------------------ Error codes -----------------------------*/
|
||||
|
||||
#line 341 "sinqhm.w"
|
||||
@ -46,60 +46,58 @@
|
||||
|
||||
#line 118 "sinqhm.w"
|
||||
|
||||
pSINQHM CreateSINQHM(char *pHMComputer, int iMasterPort);
|
||||
pSINQHM CopySINQHM(pSINQHM self);
|
||||
void DeleteSINQHM(pSINQHM self);
|
||||
void SINQHMSetPar(pSINQHM self, int iRank, int iLength, int iBinWidth);
|
||||
void SINQHMSetPSD(pSINQHM self, int xSize, int xOff, int xFac,
|
||||
pSINQHM CreateSINQHM(char *pHMComputer, int iMasterPort);
|
||||
pSINQHM CopySINQHM(pSINQHM self);
|
||||
void DeleteSINQHM(pSINQHM self);
|
||||
void SINQHMSetPar(pSINQHM self, int iRank, int iLength, int iBinWidth);
|
||||
void SINQHMSetPSD(pSINQHM self, int xSize, int xOff, int xFac,
|
||||
int ySize, int yOff, int yFac);
|
||||
|
||||
#line 142 "sinqhm.w"
|
||||
|
||||
int SINQHMError2Text(int iErr, char *pBuffer, int iBufLen);
|
||||
int SINQHMError2Text(int iErr, char *pBuffer, int iBufLen);
|
||||
|
||||
#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 SINQHMConfigurePSD(pSINQHM self, int iMode,
|
||||
int SINQHMConfigurePSD(pSINQHM self, int iMode,
|
||||
int xSize, int xOff, int xFac,
|
||||
int ySize, int yOff, int yFac,
|
||||
int iBinWidth,
|
||||
float *iEdges, int iEdgeLength);
|
||||
int iBinWidth, float *iEdges, int iEdgeLength);
|
||||
|
||||
int SINQHMDeconfigure(pSINQHM self, int iHarsh);
|
||||
int SINQHMGetStatus(pSINQHM self,int *iMode, int *iDaq,
|
||||
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 SINQHMDebug(pSINQHM self, int iLevel);
|
||||
int SINQHMKill(pSINQHM self);
|
||||
|
||||
|
||||
#line 261 "sinqhm.w"
|
||||
|
||||
int SINQHMOpenDAQ(pSINQHM self);
|
||||
int SINQHMCloseDAQ(pSINQHM self);
|
||||
int SINQHMOpenDAQ(pSINQHM self);
|
||||
int SINQHMCloseDAQ(pSINQHM self);
|
||||
|
||||
int SINQHMStartDAQ(pSINQHM self);
|
||||
int SINQHMStopDAQ(pSINQHM self);
|
||||
int SINQHMInhibitDAQ(pSINQHM self);
|
||||
int SINQHMContinueDAQ(pSINQHM self);
|
||||
int SINQHMStartDAQ(pSINQHM self);
|
||||
int SINQHMStopDAQ(pSINQHM self);
|
||||
int SINQHMInhibitDAQ(pSINQHM self);
|
||||
int SINQHMContinueDAQ(pSINQHM self);
|
||||
|
||||
int SINQHMWrite(pSINQHM self, int iNum, int iStart, int iEnd,
|
||||
void *pData);
|
||||
long SINQHMSize(pSINQHM self, int iNum, int iStart, int iEnd);
|
||||
int SINQHMRead(pSINQHM self, int iNum, int iStart, int iEnd,
|
||||
int SINQHMWrite(pSINQHM self, int iNum, int iStart, int iEnd, void *pData);
|
||||
long SINQHMSize(pSINQHM self, int iNum, int iStart, int iEnd);
|
||||
int SINQHMRead(pSINQHM self, int iNum, int iStart, int iEnd,
|
||||
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 SINQHMZero(pSINQHM self, int iNum, int iStart, int iEnd);
|
||||
int SINQHMZero(pSINQHM self, int iNum, int iStart, int iEnd);
|
||||
|
||||
#line 382 "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);
|
||||
|
||||
#line 383 "sinqhm.w"
|
||||
|
@ -261,7 +261,7 @@
|
||||
**------------------------------------------------------------------------------
|
||||
** Define structure of a TOF histogram data item.
|
||||
*/
|
||||
struct tof_histog {
|
||||
struct tof_histog {
|
||||
int cntr_nmbr; /* Counter number */
|
||||
uint lo_edge; /* Low edge of first bin (20-bit value) */
|
||||
uint hi_edge; /* Top edge of last bin (20-bit value) */
|
||||
@ -279,12 +279,12 @@
|
||||
usint *w_bin_data; /* .. pointer if it's 16-bit bins */
|
||||
uint *l_bin_data; /* .. pointer if it's 32-bit bins */
|
||||
} u;
|
||||
};
|
||||
};
|
||||
|
||||
/* Define a TOF 'edge-info' structure. This structure is created
|
||||
** 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 flag; /* Flag bits defining type of histo */
|
||||
uint bin_span; /* Time spanned by a histogram bin (20-bit
|
||||
@ -294,38 +294,40 @@
|
||||
uint edges[2]; /* Array of edge data (20-bit values). There
|
||||
** are actually (n_bins+1) items in the array
|
||||
** and give the bottom edges of the bin */
|
||||
};
|
||||
};
|
||||
|
||||
/* 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 flag; /* Flag (0/1) for fixed/variable bin size */
|
||||
uint *edges; /* Array of bottom edges (20-bit values) */
|
||||
};
|
||||
};
|
||||
|
||||
/* 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 n_cntrs; /* Number of counters in bank */
|
||||
usint edge_indx; /* Index of edge array */
|
||||
usint bytes_per_bin; /* Number of bytes per bin */
|
||||
};
|
||||
};
|
||||
/*
|
||||
**------------------------------------------------------------------------------
|
||||
** Define command structure.
|
||||
*/
|
||||
struct req_buff_struct { /* For messages to SinqHM */
|
||||
struct req_buff_struct { /* For messages to SinqHM */
|
||||
uint bigend;
|
||||
uint cmnd;
|
||||
union {
|
||||
char filler[56];
|
||||
|
||||
struct {uint max_pkt,
|
||||
strt_mode;} cnct;
|
||||
struct {
|
||||
uint max_pkt, strt_mode;
|
||||
} cnct;
|
||||
|
||||
struct {uint mode;
|
||||
struct {
|
||||
uint mode;
|
||||
union {
|
||||
struct {
|
||||
uint n_buffs;
|
||||
@ -363,48 +365,52 @@
|
||||
} u;
|
||||
} cnfg;
|
||||
|
||||
struct {uint mask;} dbg;
|
||||
struct {
|
||||
uint mask;
|
||||
} dbg;
|
||||
|
||||
struct {uint sub_code;} decnfg;
|
||||
struct {
|
||||
uint sub_code;
|
||||
} decnfg;
|
||||
|
||||
struct {uint sub_cmnd;} daq;
|
||||
struct {
|
||||
uint sub_cmnd;
|
||||
} daq;
|
||||
|
||||
struct {uint sub_code,
|
||||
x_lo,
|
||||
nx,
|
||||
y_lo,
|
||||
ny,
|
||||
xdim,
|
||||
nhist;} project;
|
||||
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, first_bin, n_bins;
|
||||
} read;
|
||||
|
||||
struct {uint hist_no;} select;
|
||||
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, bytes_per_bin;
|
||||
} write;
|
||||
|
||||
struct {uint hist_no,
|
||||
first_bin,
|
||||
n_bins;} zero;
|
||||
struct {
|
||||
uint hist_no, first_bin, n_bins;
|
||||
} zero;
|
||||
} u;
|
||||
};
|
||||
};
|
||||
/*
|
||||
**------------------------------------------------------------------------------
|
||||
** Define status response structure.
|
||||
*/
|
||||
struct rply_buff_struct { /* For messages from SinqHM */
|
||||
struct rply_buff_struct { /* For messages from SinqHM */
|
||||
uint bigend;
|
||||
uint status;
|
||||
uint sub_status;
|
||||
union {
|
||||
char message[52];
|
||||
|
||||
struct {uint port;
|
||||
struct {
|
||||
uint port;
|
||||
uint pkt_size;
|
||||
uint hm_mode;
|
||||
uint n_hists;
|
||||
@ -416,14 +422,18 @@
|
||||
uint lo_cntr;
|
||||
uint lo_bin;
|
||||
uint compress;
|
||||
uint up_time;} cnct;
|
||||
uint up_time;
|
||||
} cnct;
|
||||
|
||||
struct {usint daq_now;
|
||||
struct {
|
||||
usint daq_now;
|
||||
usint daq_was;
|
||||
usint filler_mask;
|
||||
usint server_mask;} daq;
|
||||
usint server_mask;
|
||||
} daq;
|
||||
|
||||
struct {uint n_extra_bytes;
|
||||
struct {
|
||||
uint n_extra_bytes;
|
||||
uint up_time;
|
||||
usint offset_vxWorks_ident;
|
||||
usint offset_vxWorks_date;
|
||||
@ -436,20 +446,26 @@
|
||||
usint offset_sinqhm_filler_ident;
|
||||
usint offset_sinqhm_filler_date;
|
||||
usint offset_sinqhm_routines_ident;
|
||||
usint offset_sinqhm_routines_date;} 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;
|
||||
struct {
|
||||
uint n_bins;
|
||||
uint bytes_per_bin;
|
||||
uint cnts_lo;
|
||||
uint cnts_hi;} read;
|
||||
uint cnts_hi;
|
||||
} project;
|
||||
|
||||
struct {uint cfg_state;
|
||||
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;
|
||||
@ -464,20 +480,22 @@
|
||||
uint both;
|
||||
} dt_or_dts;
|
||||
uint num_bad_events;
|
||||
uint up_time;} status;
|
||||
uint up_time;
|
||||
} status;
|
||||
} u;
|
||||
};
|
||||
};
|
||||
/*
|
||||
**------------------------------------------------------------------------------
|
||||
** 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 {
|
||||
char message[32]; /* Ensure buffer is 32 bytes total */
|
||||
struct {
|
||||
uint cmnd;
|
||||
uint index;
|
||||
usint new_mask;} uu;
|
||||
usint new_mask;
|
||||
} uu;
|
||||
} u;
|
||||
};
|
||||
};
|
||||
/*======================================================= End of SinqHM_def.h */
|
||||
|
@ -163,12 +163,11 @@
|
||||
** strncpy to be sure result is always
|
||||
** null terminated.
|
||||
*/
|
||||
char *StrEdit (
|
||||
char *StrEdit(
|
||||
/* =======
|
||||
*/ char *out,
|
||||
char *in,
|
||||
char *ctrl,
|
||||
int *ln) {
|
||||
char *in, char *ctrl, int *ln)
|
||||
{
|
||||
|
||||
int i, j, k, l, m, len, inxt, out_size;
|
||||
char my_ctrl[80];
|
||||
@ -177,10 +176,15 @@
|
||||
int do_uncomment, do_upcase;
|
||||
|
||||
out_size = *ln;
|
||||
if (out_size < 1) {*ln = 0; return NULL;} /* Can't do anything!! */
|
||||
|
||||
if (strlen (in) <= 0) {
|
||||
*out = NIL; *ln = 0; return out; /* Nothing to do!! */
|
||||
if (out_size < 1) {
|
||||
*ln = 0;
|
||||
return NULL;
|
||||
}
|
||||
/* 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
|
||||
@ -188,38 +192,45 @@
|
||||
** 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;
|
||||
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]);
|
||||
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");
|
||||
tok_nxt = strtok(my_ctrl, ", \t\f\v\n");
|
||||
while (tok_nxt != NULL) {
|
||||
if (strcmp (tok_nxt, "collapse") == 0) {
|
||||
if (strcmp(tok_nxt, "collapse") == 0) {
|
||||
do_collapse = True;
|
||||
}else if (strcmp (tok_nxt, "compress") == 0) {
|
||||
} else if (strcmp(tok_nxt, "compress") == 0) {
|
||||
do_compress = True;
|
||||
}else if (strcmp (tok_nxt, "lowercase") == 0) {
|
||||
} else if (strcmp(tok_nxt, "lowercase") == 0) {
|
||||
do_lowercase = True;
|
||||
}else if (strcmp (tok_nxt, "trim") == 0) {
|
||||
} else if (strcmp(tok_nxt, "trim") == 0) {
|
||||
do_trim = True;
|
||||
}else if (strcmp (tok_nxt, "uncomment") == 0) {
|
||||
} else if (strcmp(tok_nxt, "uncomment") == 0) {
|
||||
do_uncomment = True;
|
||||
}else if (strcmp (tok_nxt, "upcase") == 0) {
|
||||
} else if (strcmp(tok_nxt, "upcase") == 0) {
|
||||
do_upcase = True;
|
||||
}else {
|
||||
*out = NIL; *ln = 0; return NULL; /* Illegal ctrl verb */
|
||||
} else {
|
||||
*out = NIL;
|
||||
*ln = 0;
|
||||
return NULL; /* Illegal ctrl verb */
|
||||
}
|
||||
tok_nxt = strtok (NULL, ", \t\f\v\n");
|
||||
tok_nxt = strtok(NULL, ", \t\f\v\n");
|
||||
}
|
||||
|
||||
len = strlen (in) + 1;
|
||||
my_in = malloc (len); /* Get some working space */
|
||||
len = strlen(in) + 1;
|
||||
my_in = malloc(len); /* Get some working space */
|
||||
if (my_in == NULL) {
|
||||
*out = NIL; *ln = 0; return NULL;
|
||||
*out = NIL;
|
||||
*ln = 0;
|
||||
return NULL;
|
||||
}
|
||||
/*
|
||||
** Copy "in" to the "my_in" working space, processing any '\' escape
|
||||
@ -234,24 +245,67 @@
|
||||
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':
|
||||
case 'a':
|
||||
case 'A':
|
||||
*nxt++ = '\007';
|
||||
in++;
|
||||
i = strspn (in, "0123456789abcdefABCDEF");
|
||||
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;
|
||||
*nxt++ = strtol(in, &in, 16);
|
||||
break;
|
||||
} else {
|
||||
*nxt++ = '\\';
|
||||
break;
|
||||
}
|
||||
case '0':
|
||||
case '1':
|
||||
@ -261,42 +315,49 @@
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
i = strspn (in, "01234567");
|
||||
i = strspn(in, "01234567");
|
||||
if (i > 3) {
|
||||
sscanf (in, "%3o", &j);
|
||||
sscanf(in, "%3o", &j);
|
||||
*nxt++ = j;
|
||||
in += 3;
|
||||
break;
|
||||
}else if (i > 0) {
|
||||
sscanf (in, "%o", &j);
|
||||
} else if (i > 0) {
|
||||
sscanf(in, "%o", &j);
|
||||
*nxt++ = j;
|
||||
in += i;
|
||||
break;
|
||||
}else {
|
||||
} 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 {
|
||||
} 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 */
|
||||
my_out = malloc(len); /* Get some working space */
|
||||
if (my_out == NULL) {
|
||||
free (my_in); *out = NIL; *ln = 0; return NULL;
|
||||
free(my_in);
|
||||
*out = NIL;
|
||||
*ln = 0;
|
||||
return NULL;
|
||||
}
|
||||
*my_out = NIL;
|
||||
|
||||
my_tmp = malloc (len); /* Get some working space */
|
||||
my_tmp = malloc(len); /* Get some working space */
|
||||
if (my_tmp == NULL) {
|
||||
free (my_out); free (my_in);
|
||||
*out = NIL; *ln = 0; return NULL;
|
||||
free(my_out);
|
||||
free(my_in);
|
||||
*out = NIL;
|
||||
*ln = 0;
|
||||
return NULL;
|
||||
}
|
||||
*my_tmp = NIL;
|
||||
*out = NIL;
|
||||
@ -304,12 +365,14 @@
|
||||
** 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++;
|
||||
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);
|
||||
free(my_tmp);
|
||||
free(my_out);
|
||||
free(my_in);
|
||||
*ln = strlen(out);
|
||||
return NULL;
|
||||
}
|
||||
/*
|
||||
@ -319,22 +382,22 @@
|
||||
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 */
|
||||
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; ..
|
||||
} 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]);
|
||||
} else {
|
||||
j = strlen(&my_in[inxt]);
|
||||
}
|
||||
memcpy (my_tmp, &my_in[inxt], j); /* Make copy for us to work on */
|
||||
memcpy(my_tmp, &my_in[inxt], j); /* Make copy for us to work on */
|
||||
my_tmp[j] = NIL;
|
||||
inxt = inxt + j;
|
||||
/*
|
||||
@ -343,10 +406,14 @@
|
||||
*/
|
||||
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 (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;
|
||||
@ -357,59 +424,63 @@
|
||||
}
|
||||
}
|
||||
my_tmp[l] = NIL;
|
||||
}else if (do_compress) {
|
||||
} else if (do_compress) {
|
||||
for (k = 0; my_tmp[k] != NIL; k++) {
|
||||
if (my_tmp[k] == ' ') {
|
||||
l = strspn (&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];
|
||||
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;
|
||||
my_tmp[k + m + 1] = NIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (do_lowercase) {
|
||||
for (k = 0; my_tmp[k] != NIL; k++) my_tmp[k] = _tolower (my_tmp[k]);
|
||||
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]);
|
||||
for (k = 0; my_tmp[k] != NIL; k++)
|
||||
my_tmp[k] = _toupper(my_tmp[k]);
|
||||
}
|
||||
if (do_uncomment) {
|
||||
nxt = strchr (my_tmp, '!');
|
||||
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);
|
||||
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 */
|
||||
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--);
|
||||
} else {
|
||||
for (j = strlen(my_out); my_out[j - 1] == ' '; j--);
|
||||
my_out[j] = NIL;
|
||||
}
|
||||
strcpy (out, &my_out[i]);
|
||||
strcpy(out, &my_out[i]);
|
||||
}
|
||||
free (my_tmp);
|
||||
free (my_out);
|
||||
free (my_in);
|
||||
*ln = strlen (out);
|
||||
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] = '\"';
|
||||
if (out[i] == ~'\"')
|
||||
out[i] = '\"';
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------- End of StrEdit.C -------*/
|
||||
|
@ -89,54 +89,57 @@
|
||||
** strncpy to be sure result is always
|
||||
** null terminated.
|
||||
*/
|
||||
char *StrJoin (
|
||||
char *StrJoin(
|
||||
/* =======
|
||||
*/ char *result,
|
||||
int result_size,
|
||||
char *str_a,
|
||||
char *str_b) {
|
||||
int result_size, char *str_a, char *str_b)
|
||||
{
|
||||
|
||||
int i, size, size_a, size_b;
|
||||
|
||||
size = result_size - 1;
|
||||
|
||||
if (size < 0) return result;
|
||||
if (size < 0)
|
||||
return result;
|
||||
|
||||
if (result == str_a) { /* Are the result and str_a the same? */
|
||||
size_a = strlen (str_a); /* Yes */
|
||||
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 */
|
||||
} else {
|
||||
size = size - strlen(result); /* And append str_b */
|
||||
if (size > 0) {
|
||||
strncat (result, str_b, size);
|
||||
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);
|
||||
} 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 {
|
||||
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];
|
||||
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);
|
||||
memcpy(result, str_a, size_a);
|
||||
}
|
||||
}else { /* Result is neither str_a nor str_b so .. */
|
||||
} 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);
|
||||
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 =======*/
|
||||
|
120
hardsup/table.c
120
hardsup/table.c
@ -12,14 +12,14 @@
|
||||
#include "table.h"
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
typedef struct __SicsTable {
|
||||
typedef struct __SicsTable {
|
||||
float *fVal1;
|
||||
float *fVal2;
|
||||
int iLength;
|
||||
} STable;
|
||||
} STable;
|
||||
/*-------------------------------------------------------------------------*/
|
||||
pSTable CreateTable(FILE *fd)
|
||||
{
|
||||
pSTable CreateTable(FILE * fd)
|
||||
{
|
||||
pSTable pNew = NULL;
|
||||
long lStart, lEnd, lData, i;
|
||||
char *pBuffer = NULL, *pEnd = NULL, *pEndLine, *pPtr;
|
||||
@ -30,147 +30,131 @@
|
||||
|
||||
/* find length of file, create a buffer and read it in */
|
||||
lStart = ftell(fd);
|
||||
fseek(fd,0L,SEEK_END);
|
||||
fseek(fd, 0L, SEEK_END);
|
||||
lEnd = ftell(fd);
|
||||
lData = lEnd - lStart;
|
||||
pBuffer = (char *)malloc(lData*sizeof(char));
|
||||
if(!pBuffer)
|
||||
{
|
||||
pBuffer = (char *) malloc(lData * sizeof(char));
|
||||
if (!pBuffer) {
|
||||
return NULL;
|
||||
}
|
||||
fseek(fd,lStart,SEEK_SET);
|
||||
fread(pBuffer,sizeof(char),lData,fd);
|
||||
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')
|
||||
{
|
||||
for (i = 0, iLength = 0; i < lData; i++) {
|
||||
if (pBuffer[i] == '\n') {
|
||||
iLength++;
|
||||
}
|
||||
}
|
||||
|
||||
/* allocate the table structure */
|
||||
pNew = (pSTable)malloc(sizeof(STable));
|
||||
if(!pNew)
|
||||
{
|
||||
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))
|
||||
{
|
||||
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));
|
||||
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')
|
||||
{
|
||||
while (pEndLine < pEnd) {
|
||||
if (*pEndLine == '\n') {
|
||||
*pEndLine = '\0';
|
||||
iRet = sscanf(pPtr,"%f %f",&fVal1, &fVal2);
|
||||
if(iRet == 2)
|
||||
{
|
||||
iRet = sscanf(pPtr, "%f %f", &fVal1, &fVal2);
|
||||
if (iRet == 2) {
|
||||
pNew->fVal1[i] = fVal1;
|
||||
pNew->fVal2[i] = fVal2;
|
||||
i++;
|
||||
}
|
||||
pEndLine++;
|
||||
pPtr = pEndLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pEndLine++;
|
||||
}
|
||||
}
|
||||
|
||||
free(pBuffer);
|
||||
return pNew;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void DeleteTable(pSTable self)
|
||||
{
|
||||
if(self->fVal1)
|
||||
{
|
||||
void DeleteTable(pSTable self)
|
||||
{
|
||||
if (self->fVal1) {
|
||||
free(self->fVal1);
|
||||
}
|
||||
if(self->fVal2)
|
||||
{
|
||||
if (self->fVal2) {
|
||||
free(self->fVal2);
|
||||
}
|
||||
free(self);
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int InterpolateVal1(pSTable self, float fKey, float *fResult)
|
||||
{
|
||||
int InterpolateVal1(pSTable self, float fKey, float *fResult)
|
||||
{
|
||||
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->fVal1[i] >= fKey)
|
||||
{
|
||||
for (i = 0; i < self->iLength; i++) {
|
||||
if (self->fVal1[i] >= fKey) {
|
||||
i1 = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i1 >= self->iLength)
|
||||
{
|
||||
if (i1 >= self->iLength) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* interpolate */
|
||||
fFrac = (fKey - self->fVal1[i1 -1])
|
||||
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]);
|
||||
*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;
|
||||
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)
|
||||
{
|
||||
for (i = 0; i < self->iLength; i++) {
|
||||
if (self->fVal2[i] <= fKey) {
|
||||
i1 = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i1 >= self->iLength)
|
||||
{
|
||||
if (i1 >= self->iLength) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* interpolate */
|
||||
fFrac = (fKey - self->fVal2[i1 -1])
|
||||
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]);
|
||||
*fResult = self->fVal1[i1 - 1]
|
||||
+ fFrac * (self->fVal1[i1] - self->fVal1[i1 - 1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,23 +11,23 @@
|
||||
-----------------------------------------------------------------------------*/
|
||||
#ifndef SICSTABLE
|
||||
#define SICSTABLE
|
||||
typedef struct __SicsTable *pSTable;
|
||||
typedef struct __SicsTable *pSTable;
|
||||
|
||||
/*------------------------- live & death ----------------------------------*/
|
||||
pSTable CreateTable(FILE *fd);
|
||||
pSTable CreateTable(FILE * fd);
|
||||
/*
|
||||
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.
|
||||
This leaves the caller free to examine a header, if any.
|
||||
*/
|
||||
void DeleteTable(pSTable self);
|
||||
void DeleteTable(pSTable self);
|
||||
/*------------------------- 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
|
||||
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
|
||||
second column.
|
||||
|
@ -9,7 +9,7 @@
|
||||
#define OffsetOf(type, identifier) ((size_t)(&((type*) NULL)->identifier))
|
||||
#endif
|
||||
|
||||
enum VelSel_Errors {VELSEL__BAD_TMO = -1,
|
||||
enum VelSel_Errors { VELSEL__BAD_TMO = -1,
|
||||
VELSEL__BAD_CMD = -3,
|
||||
VELSEL__BAD_OFL = -4,
|
||||
VELSEL__BAD_ILLG = -5,
|
||||
@ -41,11 +41,12 @@ enum VelSel_Errors {VELSEL__BAD_TMO = -1,
|
||||
VELSEL__BAD_STP = -33,
|
||||
VELSEL__NOT_OPEN = -35,
|
||||
VELSEL__BAD_ASYNSRV = -36,
|
||||
VELSEL__BAD_REPLY = -34};
|
||||
VELSEL__BAD_REPLY = -34
|
||||
};
|
||||
/*
|
||||
** Structure to which the VelSel_Open handle points.
|
||||
*/
|
||||
struct VelSel_info {
|
||||
struct VelSel_info {
|
||||
struct AsynSrv__info asyn_info; /* Contains skt, host, port & chan */
|
||||
int tmo;
|
||||
char eot[4];
|
||||
@ -53,6 +54,6 @@ enum VelSel_Errors {VELSEL__BAD_TMO = -1,
|
||||
int n_replies, max_replies;
|
||||
struct RS__MsgStruct to_host;
|
||||
struct RS__RespStruct from_host;
|
||||
};
|
||||
};
|
||||
/*------------------------------------------------ End of VelSel_DEF.H --*/
|
||||
#endif /* _velsel_def_ */
|
||||
|
@ -358,99 +358,106 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
** Global Variables
|
||||
*/
|
||||
static int VelSel_call_depth = 0;
|
||||
static char VelSel_routine[5][64];
|
||||
static int VelSel_errcode = 0;
|
||||
static int VelSel_errno, VelSel_vaxc_errno;
|
||||
static int VelSel_call_depth = 0;
|
||||
static char VelSel_routine[5][64];
|
||||
static int VelSel_errcode = 0;
|
||||
static int VelSel_errno, VelSel_vaxc_errno;
|
||||
/*
|
||||
**---------------------------------------------------------------------------
|
||||
** VelSel_Close: Close a connection to a Velocity Selector.
|
||||
*/
|
||||
int VelSel_Close (
|
||||
int VelSel_Close(
|
||||
/* ===========
|
||||
*/ void **handle,
|
||||
int force_flag) {
|
||||
int force_flag)
|
||||
{
|
||||
|
||||
struct VelSel_info *info_ptr;
|
||||
char buff[4];
|
||||
|
||||
info_ptr = (struct VelSel_info *) *handle;
|
||||
if (info_ptr == NULL) return True;
|
||||
if (info_ptr == NULL)
|
||||
return True;
|
||||
|
||||
if (info_ptr->asyn_info.skt != 0) {
|
||||
if (info_ptr->asyn_info.skt > 0) {
|
||||
AsynSrv_Close (*handle, force_flag);
|
||||
AsynSrv_Close(*handle, force_flag);
|
||||
}
|
||||
}
|
||||
free (*handle);
|
||||
free(*handle);
|
||||
*handle = NULL;
|
||||
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
**---------------------------------------------------------------------------
|
||||
** VelSel_Config: Configure a connection to a Velocity Selector.
|
||||
*/
|
||||
void VelSel_Config (
|
||||
void VelSel_Config(
|
||||
/* ============
|
||||
*/ void **handle,
|
||||
int msec_tmo,
|
||||
char *eot_str) {
|
||||
int msec_tmo, char *eot_str)
|
||||
{
|
||||
|
||||
int i;
|
||||
struct VelSel_info *info_ptr;
|
||||
|
||||
info_ptr = (struct VelSel_info *) *handle;
|
||||
if (info_ptr == NULL) return;
|
||||
if (info_ptr == NULL)
|
||||
return;
|
||||
/*-------------------------
|
||||
** Set up the time-out
|
||||
*/
|
||||
if (msec_tmo < 0) {
|
||||
info_ptr->tmo = -1;
|
||||
}else {
|
||||
info_ptr->tmo = (msec_tmo + 99)/100; /* Convert to deci-secs */
|
||||
if (info_ptr->tmo > 9999) info_ptr->tmo = 9999;
|
||||
} else {
|
||||
info_ptr->tmo = (msec_tmo + 99) / 100; /* Convert to deci-secs */
|
||||
if (info_ptr->tmo > 9999)
|
||||
info_ptr->tmo = 9999;
|
||||
}
|
||||
/*---------------------------------
|
||||
** Set up the end-of-text string
|
||||
*/
|
||||
if (eot_str != NULL) {
|
||||
for (i = 0; i < sizeof (info_ptr->eot); i++) info_ptr->eot[i] = '\0';
|
||||
for (i = 0; i < sizeof(info_ptr->eot); i++)
|
||||
info_ptr->eot[i] = '\0';
|
||||
|
||||
for (i = 0; i < sizeof (info_ptr->eot); i++) {
|
||||
if (eot_str[i] == '\0') break;
|
||||
info_ptr->eot[i+1] = eot_str[i];
|
||||
for (i = 0; i < sizeof(info_ptr->eot); i++) {
|
||||
if (eot_str[i] == '\0')
|
||||
break;
|
||||
info_ptr->eot[i + 1] = eot_str[i];
|
||||
}
|
||||
info_ptr->eot[0] = '0' + i;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** -------------------------------------------------------------------------
|
||||
** VelSel_ErrInfo: Return detailed status from last operation.
|
||||
*/
|
||||
void VelSel_ErrInfo (
|
||||
void VelSel_ErrInfo(
|
||||
/* =============
|
||||
*/ char **entry_txt,
|
||||
int *errcode,
|
||||
int *my_errno,
|
||||
int *vaxc_errno) {
|
||||
int *errcode, int *my_errno, int *vaxc_errno)
|
||||
{
|
||||
|
||||
int i;
|
||||
char buff[80];
|
||||
int asyn_errcode, asyn_errno, asyn_vaxerrno;
|
||||
char* asyn_errtxt;
|
||||
char *asyn_errtxt;
|
||||
|
||||
if (VelSel_call_depth <= 0) {
|
||||
strcpy (VelSel_routine[0], "VelSel_no_error_detected");
|
||||
strcpy(VelSel_routine[0], "VelSel_no_error_detected");
|
||||
*errcode = 0;
|
||||
*my_errno = 0;
|
||||
*vaxc_errno = 0;
|
||||
}else {
|
||||
} else {
|
||||
if (VelSel_call_depth > 1) { /* Concatenate the names */
|
||||
for (i = 1; i < VelSel_call_depth; i++) {
|
||||
strcat (VelSel_routine[0], "/");
|
||||
StrJoin (VelSel_routine[0], sizeof (VelSel_routine),
|
||||
strcat(VelSel_routine[0], "/");
|
||||
StrJoin(VelSel_routine[0], sizeof(VelSel_routine),
|
||||
VelSel_routine[0], VelSel_routine[i]);
|
||||
}
|
||||
}
|
||||
@ -458,60 +465,127 @@
|
||||
*my_errno = VelSel_errno;
|
||||
*vaxc_errno = VelSel_vaxc_errno;
|
||||
switch (VelSel_errcode) {
|
||||
case VELSEL__BAD_TMO: strcpy (buff, "/VELSEL__BAD_TMO"); break;
|
||||
case VELSEL__BAD_CMD: strcpy (buff, "/VELSEL__BAD_CMD"); break;
|
||||
case VELSEL__BAD_OFL: strcpy (buff, "/VELSEL__BAD_OFL"); break;
|
||||
case VELSEL__BAD_ILLG: strcpy (buff, "/VELSEL__BAD_ILLG"); break;
|
||||
case VELSEL__BAD_HOST: strcpy (buff, "/VELSEL__BAD_HOST"); break;
|
||||
case VELSEL__BAD_SOCKET: strcpy (buff, "/VELSEL__BAD_SOCKET"); break;
|
||||
case VELSEL__BAD_BIND: strcpy (buff, "/VELSEL__BAD_BIND"); break;
|
||||
case VELSEL__BAD_CONNECT: strcpy (buff, "/VELSEL__BAD_CONNECT"); break;
|
||||
case VELSEL__BAD_DEV: strcpy (buff, "/VELSEL__BAD_DEV"); break;
|
||||
case VELSEL__BAD_MALLOC: strcpy (buff, "/VELSEL__BAD_MALLOC"); break;
|
||||
case VELSEL__BAD_SENDLEN: strcpy (buff, "/VELSEL__BAD_SENDLEN"); break;
|
||||
case VELSEL__BAD_SEND: strcpy (buff, "/VELSEL__BAD_SEND"); break;
|
||||
case VELSEL__BAD_SEND_PIPE: strcpy (buff, "/VELSEL__BAD_SEND_PIPE"); break;
|
||||
case VELSEL__BAD_SEND_NET: strcpy (buff, "/VELSEL__BAD_SEND_NET"); break;
|
||||
case VELSEL__BAD_SEND_UNKN: strcpy (buff, "/VELSEL__BAD_SEND_UNKN"); break;
|
||||
case VELSEL__BAD_RECV: strcpy (buff, "/VELSEL__BAD_RECV"); break;
|
||||
case VELSEL__BAD_RECV_PIPE: strcpy (buff, "/VELSEL__BAD_RECV_PIPE"); break;
|
||||
case VELSEL__BAD_RECV_NET: strcpy (buff, "/VELSEL__BAD_RECV_NET"); break;
|
||||
case VELSEL__BAD_RECV_UNKN: strcpy (buff, "/VELSEL__BAD_RECV_UNKN"); break;
|
||||
case VELSEL__BAD_NOT_BCD: strcpy (buff, "/VELSEL__BAD_NOT_BCD"); break;
|
||||
case VELSEL__BAD_RECVLEN: strcpy (buff, "/VELSEL__BAD_RECVLEN"); break;
|
||||
case VELSEL__BAD_FLUSH: strcpy (buff, "/VELSEL__BAD_FLUSH"); break;
|
||||
case VELSEL__BAD_RECV1: strcpy (buff, "/VELSEL__BAD_RECV1"); break;
|
||||
case VELSEL__BAD_RECV1_PIPE: strcpy (buff, "/VELSEL__BAD_RECV1_PIPE"); break;
|
||||
case VELSEL__BAD_RECV1_NET: strcpy (buff, "/VELSEL__BAD_RECV1_NET"); break;
|
||||
case VELSEL__BAD_PAR: strcpy (buff, "/VELSEL__BAD_PAR"); break;
|
||||
case VELSEL__BAD_BSY: strcpy (buff, "/VELSEL__BAD_BSY"); break;
|
||||
case VELSEL__BAD_OPEN: strcpy (buff, "/VELSEL__BAD_OPEN"); break;
|
||||
case VELSEL__FORCED_CLOSED: strcpy (buff, "/VELSEL__FORCED_CLOSED"); break;
|
||||
case VELSEL__BAD_STP: strcpy (buff, "/VELSEL__BAD_STP"); break;
|
||||
case VELSEL__BAD_REPLY: strcpy (buff, "/VELSEL__BAD_REPLY"); break;
|
||||
default: sprintf (buff, "/VELSEL__unknown_err_code: %d", VelSel_errcode);
|
||||
case VELSEL__BAD_TMO:
|
||||
strcpy(buff, "/VELSEL__BAD_TMO");
|
||||
break;
|
||||
case VELSEL__BAD_CMD:
|
||||
strcpy(buff, "/VELSEL__BAD_CMD");
|
||||
break;
|
||||
case VELSEL__BAD_OFL:
|
||||
strcpy(buff, "/VELSEL__BAD_OFL");
|
||||
break;
|
||||
case VELSEL__BAD_ILLG:
|
||||
strcpy(buff, "/VELSEL__BAD_ILLG");
|
||||
break;
|
||||
case VELSEL__BAD_HOST:
|
||||
strcpy(buff, "/VELSEL__BAD_HOST");
|
||||
break;
|
||||
case VELSEL__BAD_SOCKET:
|
||||
strcpy(buff, "/VELSEL__BAD_SOCKET");
|
||||
break;
|
||||
case VELSEL__BAD_BIND:
|
||||
strcpy(buff, "/VELSEL__BAD_BIND");
|
||||
break;
|
||||
case VELSEL__BAD_CONNECT:
|
||||
strcpy(buff, "/VELSEL__BAD_CONNECT");
|
||||
break;
|
||||
case VELSEL__BAD_DEV:
|
||||
strcpy(buff, "/VELSEL__BAD_DEV");
|
||||
break;
|
||||
case VELSEL__BAD_MALLOC:
|
||||
strcpy(buff, "/VELSEL__BAD_MALLOC");
|
||||
break;
|
||||
case VELSEL__BAD_SENDLEN:
|
||||
strcpy(buff, "/VELSEL__BAD_SENDLEN");
|
||||
break;
|
||||
case VELSEL__BAD_SEND:
|
||||
strcpy(buff, "/VELSEL__BAD_SEND");
|
||||
break;
|
||||
case VELSEL__BAD_SEND_PIPE:
|
||||
strcpy(buff, "/VELSEL__BAD_SEND_PIPE");
|
||||
break;
|
||||
case VELSEL__BAD_SEND_NET:
|
||||
strcpy(buff, "/VELSEL__BAD_SEND_NET");
|
||||
break;
|
||||
case VELSEL__BAD_SEND_UNKN:
|
||||
strcpy(buff, "/VELSEL__BAD_SEND_UNKN");
|
||||
break;
|
||||
case VELSEL__BAD_RECV:
|
||||
strcpy(buff, "/VELSEL__BAD_RECV");
|
||||
break;
|
||||
case VELSEL__BAD_RECV_PIPE:
|
||||
strcpy(buff, "/VELSEL__BAD_RECV_PIPE");
|
||||
break;
|
||||
case VELSEL__BAD_RECV_NET:
|
||||
strcpy(buff, "/VELSEL__BAD_RECV_NET");
|
||||
break;
|
||||
case VELSEL__BAD_RECV_UNKN:
|
||||
strcpy(buff, "/VELSEL__BAD_RECV_UNKN");
|
||||
break;
|
||||
case VELSEL__BAD_NOT_BCD:
|
||||
strcpy(buff, "/VELSEL__BAD_NOT_BCD");
|
||||
break;
|
||||
case VELSEL__BAD_RECVLEN:
|
||||
strcpy(buff, "/VELSEL__BAD_RECVLEN");
|
||||
break;
|
||||
case VELSEL__BAD_FLUSH:
|
||||
strcpy(buff, "/VELSEL__BAD_FLUSH");
|
||||
break;
|
||||
case VELSEL__BAD_RECV1:
|
||||
strcpy(buff, "/VELSEL__BAD_RECV1");
|
||||
break;
|
||||
case VELSEL__BAD_RECV1_PIPE:
|
||||
strcpy(buff, "/VELSEL__BAD_RECV1_PIPE");
|
||||
break;
|
||||
case VELSEL__BAD_RECV1_NET:
|
||||
strcpy(buff, "/VELSEL__BAD_RECV1_NET");
|
||||
break;
|
||||
case VELSEL__BAD_PAR:
|
||||
strcpy(buff, "/VELSEL__BAD_PAR");
|
||||
break;
|
||||
case VELSEL__BAD_BSY:
|
||||
strcpy(buff, "/VELSEL__BAD_BSY");
|
||||
break;
|
||||
case VELSEL__BAD_OPEN:
|
||||
strcpy(buff, "/VELSEL__BAD_OPEN");
|
||||
break;
|
||||
case VELSEL__FORCED_CLOSED:
|
||||
strcpy(buff, "/VELSEL__FORCED_CLOSED");
|
||||
break;
|
||||
case VELSEL__BAD_STP:
|
||||
strcpy(buff, "/VELSEL__BAD_STP");
|
||||
break;
|
||||
case VELSEL__BAD_REPLY:
|
||||
strcpy(buff, "/VELSEL__BAD_REPLY");
|
||||
break;
|
||||
default:
|
||||
sprintf(buff, "/VELSEL__unknown_err_code: %d", VelSel_errcode);
|
||||
}
|
||||
StrJoin (VelSel_routine[0], sizeof(VelSel_routine), VelSel_routine[0], buff);
|
||||
StrJoin(VelSel_routine[0], sizeof(VelSel_routine), VelSel_routine[0],
|
||||
buff);
|
||||
}
|
||||
AsynSrv_ErrInfo (&asyn_errtxt, &asyn_errcode, &asyn_errno, &asyn_vaxerrno);
|
||||
AsynSrv_ErrInfo(&asyn_errtxt, &asyn_errcode, &asyn_errno,
|
||||
&asyn_vaxerrno);
|
||||
if (asyn_errcode != 0) {
|
||||
strcat (VelSel_routine[0], "/");
|
||||
StrJoin (VelSel_routine[0], sizeof(VelSel_routine),
|
||||
strcat(VelSel_routine[0], "/");
|
||||
StrJoin(VelSel_routine[0], sizeof(VelSel_routine),
|
||||
VelSel_routine[0], asyn_errtxt);
|
||||
}
|
||||
*entry_txt = VelSel_routine[0];
|
||||
VelSel_call_depth = 0;
|
||||
VelSel_errcode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
**---------------------------------------------------------------------------
|
||||
** VelSel_GetReply - Get next reply from a reply buffer.
|
||||
*/
|
||||
void *VelSel_GetReply (
|
||||
/* ==============
|
||||
void *VelSel_GetReply(
|
||||
/* ==============
|
||||
*/ void **handle, /* Pointer to structure containing
|
||||
** message to pull apart */
|
||||
void *last_rply) { /* Starting point */
|
||||
void *last_rply)
|
||||
{ /* Starting point */
|
||||
|
||||
int rply_len;
|
||||
struct RS__RplyStruct *ptr;
|
||||
@ -524,31 +598,34 @@
|
||||
|
||||
if (my_last_rply == NULL) { /* Start with first reply? */
|
||||
/* Yes */
|
||||
if (sscanf (my_info_ptr->from_host.n_rply, "%4d",
|
||||
&my_info_ptr->max_replies) != 1) my_info_ptr->max_replies = 0;
|
||||
if (sscanf(my_info_ptr->from_host.n_rply, "%4d",
|
||||
&my_info_ptr->max_replies) != 1)
|
||||
my_info_ptr->max_replies = 0;
|
||||
if (my_info_ptr->max_replies > 0)
|
||||
ptr = (struct RS__RplyStruct *) my_info_ptr->from_host.u.rplys;
|
||||
my_info_ptr->n_replies = 1;
|
||||
}else {
|
||||
} else {
|
||||
my_info_ptr->n_replies++;
|
||||
if (my_info_ptr->n_replies <= my_info_ptr->max_replies) {
|
||||
if (sscanf (my_last_rply->rply_len, "%2d", &rply_len) == 1) {
|
||||
if (sscanf(my_last_rply->rply_len, "%2d", &rply_len) == 1) {
|
||||
ptr =
|
||||
(struct RS__RplyStruct *) ((char *) my_last_rply + rply_len + 2);
|
||||
(struct RS__RplyStruct *) ((char *) my_last_rply + rply_len +
|
||||
2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (void *) ptr;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
**---------------------------------------------------------------------------
|
||||
** VelSel_GetStatus: Get "???" response from Vel Selector
|
||||
*/
|
||||
int VelSel_GetStatus (
|
||||
int VelSel_GetStatus(
|
||||
/* ===============
|
||||
*/ void **handle,
|
||||
char *status_str,
|
||||
int status_str_len) {
|
||||
char *status_str, int status_str_len)
|
||||
{
|
||||
|
||||
int status;
|
||||
struct VelSel_info *info_ptr;
|
||||
@ -561,7 +638,7 @@
|
||||
** Pre-set the routine name (in case of error)
|
||||
*/
|
||||
if (VelSel_errcode == 0 && VelSel_call_depth < 5) {
|
||||
strcpy (VelSel_routine[VelSel_call_depth], "VelSel_GetStatus");
|
||||
strcpy(VelSel_routine[VelSel_call_depth], "VelSel_GetStatus");
|
||||
VelSel_call_depth++;
|
||||
}
|
||||
/*----------------------------------------------
|
||||
@ -573,8 +650,8 @@
|
||||
return False;
|
||||
}
|
||||
if (info_ptr->asyn_info.skt <= 0) {
|
||||
memset (info_ptr->from_host.msg_size,
|
||||
'0', sizeof (info_ptr->from_host.msg_size));
|
||||
memset(info_ptr->from_host.msg_size,
|
||||
'0', sizeof(info_ptr->from_host.msg_size));
|
||||
if ((VelSel_errcode == 0) && (info_ptr->asyn_info.skt < 0)) {
|
||||
VelSel_errcode = VELSEL__FORCED_CLOSED;
|
||||
}
|
||||
@ -583,28 +660,29 @@
|
||||
/*----------------------------------------------
|
||||
** Send "???" command to Velocity Selector
|
||||
*/
|
||||
status = VelSel_SendCmnds (handle, "???", NULL);
|
||||
status = VelSel_SendCmnds(handle, "???", NULL);
|
||||
if (!status) {
|
||||
/* Error in VelSel_SendCmnds */
|
||||
return False;
|
||||
}else {
|
||||
rply_ptr0 = VelSel_GetReply (handle, NULL);
|
||||
if (rply_ptr0 == NULL) rply_ptr0 = (struct RS__RplyStruct *) "06\rNULL";
|
||||
StrJoin (status_str, status_str_len, rply_ptr0->rply, "");
|
||||
} else {
|
||||
rply_ptr0 = VelSel_GetReply(handle, NULL);
|
||||
if (rply_ptr0 == NULL)
|
||||
rply_ptr0 = (struct RS__RplyStruct *) "06\rNULL";
|
||||
StrJoin(status_str, status_str_len, rply_ptr0->rply, "");
|
||||
}
|
||||
VelSel_call_depth--;
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
**---------------------------------------------------------------------------
|
||||
** VelSel_Open: Open a connection to a Velocity Selector.
|
||||
*/
|
||||
int VelSel_Open (
|
||||
int VelSel_Open(
|
||||
/* ==========
|
||||
*/ void **handle,
|
||||
char *host,
|
||||
int port,
|
||||
int chan) {
|
||||
char *host, int port, int chan)
|
||||
{
|
||||
|
||||
int status;
|
||||
struct VelSel_info *my_handle;
|
||||
@ -618,7 +696,7 @@
|
||||
** routine name (in case of error).
|
||||
*/
|
||||
VelSel_errcode = VelSel_errno = VelSel_vaxc_errno = 0;
|
||||
strcpy (VelSel_routine[0], "VelSel_Open");
|
||||
strcpy(VelSel_routine[0], "VelSel_Open");
|
||||
VelSel_call_depth = 1;
|
||||
/*--------------------------------------------------------
|
||||
** Assume trouble
|
||||
@ -627,7 +705,7 @@
|
||||
/*--------------------------------------------------------
|
||||
** Reserve space for the data we need to store.
|
||||
*/
|
||||
my_handle = (struct VelSel_info *) malloc (sizeof (*my_handle));
|
||||
my_handle = (struct VelSel_info *) malloc(sizeof(*my_handle));
|
||||
if (my_handle == NULL) {
|
||||
VelSel_errcode = VELSEL__BAD_MALLOC; /* malloc failed!! */
|
||||
return False;
|
||||
@ -635,17 +713,17 @@
|
||||
/*--------------------------------------------------------
|
||||
** Set up the connection
|
||||
*/
|
||||
StrJoin (my_handle->asyn_info.host, sizeof (my_handle->asyn_info.host),
|
||||
StrJoin(my_handle->asyn_info.host, sizeof(my_handle->asyn_info.host),
|
||||
host, "");
|
||||
my_handle->asyn_info.port = port;
|
||||
my_handle->asyn_info.chan = chan;
|
||||
status = AsynSrv_Open (&my_handle->asyn_info);
|
||||
status = AsynSrv_Open(&my_handle->asyn_info);
|
||||
if (!status) {
|
||||
VelSel_errcode = VELSEL__BAD_SOCKET;
|
||||
GetErrno (&VelSel_errno, &VelSel_vaxc_errno); /* Save errno info */
|
||||
fprintf (stderr, "\nVelSel_Open/AsynSrv_Open: "
|
||||
GetErrno(&VelSel_errno, &VelSel_vaxc_errno); /* Save errno info */
|
||||
fprintf(stderr, "\nVelSel_Open/AsynSrv_Open: "
|
||||
"Failed to make connection.\n");
|
||||
free (my_handle);
|
||||
free(my_handle);
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -653,7 +731,7 @@
|
||||
** there should be no reason for the REM
|
||||
** command to take very long
|
||||
*/
|
||||
strcpy (my_handle->eot, "1\n\0\0");
|
||||
strcpy(my_handle->eot, "1\n\0\0");
|
||||
my_handle->msg_id = 0;
|
||||
/*
|
||||
** Now ensure the VelSel is on-line. The first "REM" command can
|
||||
@ -662,28 +740,29 @@
|
||||
** command is ignored for this reason (but the VelSel_SendCmnds
|
||||
** status must be OK otherwise it indicates a network problem).
|
||||
*/
|
||||
status = VelSel_SendCmnds ((void *) &my_handle, "REM", NULL);
|
||||
status = VelSel_SendCmnds((void *) &my_handle, "REM", NULL);
|
||||
if (status) {
|
||||
status = VelSel_SendCmnds ((void *) &my_handle, "REM", NULL);
|
||||
status = VelSel_SendCmnds((void *) &my_handle, "REM", NULL);
|
||||
}
|
||||
if (!status) {
|
||||
/* Some error occurred in VelSel_SendCmnds - Errcode will
|
||||
** have been set up there.
|
||||
*/
|
||||
AsynSrv_Close (&my_handle->asyn_info, False);
|
||||
free (my_handle);
|
||||
AsynSrv_Close(&my_handle->asyn_info, False);
|
||||
free(my_handle);
|
||||
return False;
|
||||
}
|
||||
/*
|
||||
** Check the responses carefully.
|
||||
*/
|
||||
rply_ptr0 = VelSel_GetReply ((void *) &my_handle, NULL);
|
||||
rply_ptr0 = VelSel_GetReply((void *) &my_handle, NULL);
|
||||
|
||||
if (rply_ptr0 == NULL) rply_ptr0 = (struct RS__RplyStruct *) "06\rNULL";
|
||||
if (rply_ptr0 == NULL)
|
||||
rply_ptr0 = (struct RS__RplyStruct *) "06\rNULL";
|
||||
if (rply_ptr0->rply[0] == '?') {
|
||||
VelSel_errcode = VELSEL__BAD_DEV; /* Error response - not a VelSel? */
|
||||
AsynSrv_Close (&my_handle->asyn_info, False);
|
||||
free (my_handle);
|
||||
AsynSrv_Close(&my_handle->asyn_info, False);
|
||||
free(my_handle);
|
||||
return False;
|
||||
}
|
||||
/*
|
||||
@ -694,15 +773,17 @@
|
||||
*handle = my_handle;
|
||||
VelSel_call_depth--;
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
**---------------------------------------------------------------------------
|
||||
** VelSel_SendCmnds - Send commands to RS232C server.
|
||||
*/
|
||||
int VelSel_SendCmnds (
|
||||
int VelSel_SendCmnds(
|
||||
/* ================
|
||||
*/ void **handle,
|
||||
...) { /* Now we have list of commands -
|
||||
...)
|
||||
{ /* Now we have list of commands -
|
||||
** char *txt = pntr to cmnd strng
|
||||
** Terminate list with *txt = NULL.
|
||||
*/
|
||||
@ -719,7 +800,7 @@
|
||||
** Pre-set the routine name (in case of error)
|
||||
*/
|
||||
if (VelSel_errcode == 0 && VelSel_call_depth < 5) {
|
||||
strcpy (VelSel_routine[VelSel_call_depth], "VelSel_SendCmnds");
|
||||
strcpy(VelSel_routine[VelSel_call_depth], "VelSel_SendCmnds");
|
||||
VelSel_call_depth++;
|
||||
}
|
||||
/*----------------------------------------------
|
||||
@ -732,8 +813,8 @@
|
||||
return False;
|
||||
}
|
||||
if (info_ptr->asyn_info.skt <= 0) {
|
||||
memset (info_ptr->from_host.msg_size,
|
||||
'0', sizeof (info_ptr->from_host.msg_size));
|
||||
memset(info_ptr->from_host.msg_size,
|
||||
'0', sizeof(info_ptr->from_host.msg_size));
|
||||
if ((VelSel_errcode == 0) && (info_ptr->asyn_info.skt < 0)) {
|
||||
VelSel_errcode = VELSEL__FORCED_CLOSED;
|
||||
}
|
||||
@ -745,177 +826,182 @@
|
||||
info_ptr->n_replies = info_ptr->max_replies = 0;
|
||||
|
||||
info_ptr->msg_id++; /* Set up an incrementing message id */
|
||||
if (info_ptr->msg_id > 9999) info_ptr->msg_id = 1;
|
||||
sprintf (info_ptr->to_host.msg_id, "%04.4d", info_ptr->msg_id);
|
||||
if (info_ptr->msg_id > 9999)
|
||||
info_ptr->msg_id = 1;
|
||||
sprintf(info_ptr->to_host.msg_id, "%04.4d", info_ptr->msg_id);
|
||||
|
||||
memcpy (info_ptr->to_host.c_pcol_lvl, RS__PROTOCOL_ID,
|
||||
sizeof (info_ptr->to_host.c_pcol_lvl));
|
||||
sprintf (info_ptr->to_host.serial_port, "%04.4d", info_ptr->asyn_info.chan);
|
||||
sprintf (info_ptr->to_host.tmo, "%04.4d", info_ptr->tmo);
|
||||
memcpy(info_ptr->to_host.c_pcol_lvl, RS__PROTOCOL_ID,
|
||||
sizeof(info_ptr->to_host.c_pcol_lvl));
|
||||
sprintf(info_ptr->to_host.serial_port, "%04.4d",
|
||||
info_ptr->asyn_info.chan);
|
||||
sprintf(info_ptr->to_host.tmo, "%04.4d", info_ptr->tmo);
|
||||
|
||||
memcpy (info_ptr->to_host.terms, info_ptr->eot,
|
||||
sizeof (info_ptr->to_host.terms));
|
||||
memcpy (info_ptr->to_host.n_cmnds, "0000",
|
||||
sizeof (info_ptr->to_host.n_cmnds));
|
||||
memcpy(info_ptr->to_host.terms, info_ptr->eot,
|
||||
sizeof(info_ptr->to_host.terms));
|
||||
memcpy(info_ptr->to_host.n_cmnds, "0000",
|
||||
sizeof(info_ptr->to_host.n_cmnds));
|
||||
|
||||
va_start (ap, handle); /* Set up var arg machinery */
|
||||
va_start(ap, handle); /* Set up var arg machinery */
|
||||
|
||||
txt_ptr = va_arg (ap, char *); /* Get pntr to next cmnd string */
|
||||
txt_ptr = va_arg(ap, char *); /* Get pntr to next cmnd string */
|
||||
ncmnds = 0;
|
||||
cmnd_lst_ptr = &info_ptr->to_host.cmnds[0];
|
||||
bytes_left = sizeof (info_ptr->to_host) -
|
||||
OffsetOf (struct RS__MsgStruct, cmnds[0]);
|
||||
bytes_left = sizeof(info_ptr->to_host) -
|
||||
OffsetOf(struct RS__MsgStruct, cmnds[0]);
|
||||
|
||||
while (txt_ptr != NULL) {
|
||||
size = 2 + strlen (txt_ptr);
|
||||
size = 2 + strlen(txt_ptr);
|
||||
if (size > bytes_left) {
|
||||
VelSel_errcode = VELSEL__BAD_SENDLEN; /* Too much to send */
|
||||
fprintf (stderr, "\nVelSel_SendCmnds/send: too much to send"
|
||||
fprintf(stderr, "\nVelSel_SendCmnds/send: too much to send"
|
||||
" - request ignored.\n");
|
||||
memset (info_ptr->from_host.msg_size,
|
||||
'0', sizeof (info_ptr->from_host.msg_size));
|
||||
memset(info_ptr->from_host.msg_size,
|
||||
'0', sizeof(info_ptr->from_host.msg_size));
|
||||
return False;
|
||||
}else {
|
||||
strcpy (cmnd_lst_ptr+2, txt_ptr);
|
||||
c_len = strlen (txt_ptr);
|
||||
sprintf (text, "%02.2d", c_len);
|
||||
memcpy (cmnd_lst_ptr, text, 2);
|
||||
} else {
|
||||
strcpy(cmnd_lst_ptr + 2, txt_ptr);
|
||||
c_len = strlen(txt_ptr);
|
||||
sprintf(text, "%02.2d", c_len);
|
||||
memcpy(cmnd_lst_ptr, text, 2);
|
||||
cmnd_lst_ptr = cmnd_lst_ptr + c_len + 2;
|
||||
ncmnds++;
|
||||
bytes_left = bytes_left - size;
|
||||
txt_ptr = va_arg (ap, char *);
|
||||
txt_ptr = va_arg(ap, char *);
|
||||
}
|
||||
}
|
||||
sprintf (text, "%04.4d", ncmnds);
|
||||
memcpy (info_ptr->to_host.n_cmnds,
|
||||
text, sizeof (info_ptr->to_host.n_cmnds));
|
||||
sprintf(text, "%04.4d", ncmnds);
|
||||
memcpy(info_ptr->to_host.n_cmnds,
|
||||
text, sizeof(info_ptr->to_host.n_cmnds));
|
||||
|
||||
size = cmnd_lst_ptr - info_ptr->to_host.msg_id;
|
||||
size = (size + 3) & (~3); /* Round up to multiple of 4 */
|
||||
sprintf (text, "%04.4d", size);
|
||||
memcpy (info_ptr->to_host.msg_size, text, 4);
|
||||
sprintf(text, "%04.4d", size);
|
||||
memcpy(info_ptr->to_host.msg_size, text, 4);
|
||||
|
||||
status = send (info_ptr->asyn_info.skt,
|
||||
(char *) &info_ptr->to_host, size+4, 0);
|
||||
if (status != (size+4)) {
|
||||
GetErrno (&VelSel_errno, &VelSel_vaxc_errno);
|
||||
status = send(info_ptr->asyn_info.skt,
|
||||
(char *) &info_ptr->to_host, size + 4, 0);
|
||||
if (status != (size + 4)) {
|
||||
GetErrno(&VelSel_errno, &VelSel_vaxc_errno);
|
||||
if (status == 0) {
|
||||
VelSel_errcode = VELSEL__BAD_SEND; /* Server exited (probably) */
|
||||
fprintf (stderr, "\nVelSel_SendCmnds/send: probable network problem");
|
||||
}else if (status == -1) {
|
||||
fprintf(stderr, "\nVelSel_SendCmnds/send: probable network problem");
|
||||
} else if (status == -1) {
|
||||
if (VelSel_errno == EPIPE) {
|
||||
VelSel_errcode = VELSEL__BAD_SEND_PIPE; /* Server exited (probably) */
|
||||
fprintf (stderr, "\nVelSel_SendCmnds/send: broken network pipe");
|
||||
}else {
|
||||
fprintf(stderr, "\nVelSel_SendCmnds/send: broken network pipe");
|
||||
} else {
|
||||
VelSel_errcode = VELSEL__BAD_SEND_NET; /* It's some other net problem */
|
||||
perror ("VelSel_SendCmnds/send");
|
||||
perror("VelSel_SendCmnds/send");
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
VelSel_errcode = VELSEL__BAD_SEND_UNKN; /* TCP/IP problems */
|
||||
fprintf (stderr, "\nVelSel_SendCmnds/send: probable TCP/IP problem");
|
||||
fprintf(stderr, "\nVelSel_SendCmnds/send: probable TCP/IP problem");
|
||||
}
|
||||
VelSel_Close (handle, True); /* Force close TCP/IP connection */
|
||||
fprintf (stderr, " - link to server force-closed.\n");
|
||||
VelSel_Close(handle, True); /* Force close TCP/IP connection */
|
||||
fprintf(stderr, " - link to server force-closed.\n");
|
||||
return False;
|
||||
}
|
||||
|
||||
size = sizeof (info_ptr->from_host.msg_size);
|
||||
status = recv (info_ptr->asyn_info.skt,
|
||||
size = sizeof(info_ptr->from_host.msg_size);
|
||||
status = recv(info_ptr->asyn_info.skt,
|
||||
info_ptr->from_host.msg_size, size, 0);
|
||||
if (status != size) {
|
||||
GetErrno (&VelSel_errno, &VelSel_vaxc_errno);
|
||||
GetErrno(&VelSel_errno, &VelSel_vaxc_errno);
|
||||
if (status == 0) {
|
||||
VelSel_errcode = VELSEL__BAD_RECV; /* Server exited (probably) */
|
||||
fprintf (stderr, "\nVelSel_SendCmnds/recv: probable network problem");
|
||||
}else if (status == -1) {
|
||||
fprintf(stderr, "\nVelSel_SendCmnds/recv: probable network problem");
|
||||
} else if (status == -1) {
|
||||
if (VelSel_errno == EPIPE) {
|
||||
VelSel_errcode = VELSEL__BAD_RECV_PIPE; /* Server exited (probably) */
|
||||
fprintf (stderr, "\nVelSel_SendCmnds/recv: broken network pipe");
|
||||
}else {
|
||||
fprintf(stderr, "\nVelSel_SendCmnds/recv: broken network pipe");
|
||||
} else {
|
||||
VelSel_errcode = VELSEL__BAD_RECV_NET; /* It's some other net problem */
|
||||
perror ("VelSel_SendCmnds/recv");
|
||||
perror("VelSel_SendCmnds/recv");
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
VelSel_errcode = VELSEL__BAD_RECV_UNKN; /* TCP/IP problems */
|
||||
fprintf (stderr, "\nVelSel_SendCmnds/recv: probable TCP/IP problem");
|
||||
fprintf(stderr, "\nVelSel_SendCmnds/recv: probable TCP/IP problem");
|
||||
}
|
||||
VelSel_Close (handle, True); /* Force close TCP/IP connection */
|
||||
fprintf (stderr, " - link to server force-closed.\n");
|
||||
VelSel_Close(handle, True); /* Force close TCP/IP connection */
|
||||
fprintf(stderr, " - link to server force-closed.\n");
|
||||
return False;
|
||||
}
|
||||
if (sscanf (info_ptr->from_host.msg_size, "%4d", &bytes_to_come) != 1) {
|
||||
if (sscanf(info_ptr->from_host.msg_size, "%4d", &bytes_to_come) != 1) {
|
||||
VelSel_errcode = VELSEL__BAD_NOT_BCD; /* Header not an ASCII BCD integer */
|
||||
VelSel_Close (handle, True); /* Force close TCP/IP connection */
|
||||
fprintf (stderr, "\nVelSel_SendCmnds/recv: non-BCD byte count"
|
||||
VelSel_Close(handle, True); /* Force close TCP/IP connection */
|
||||
fprintf(stderr, "\nVelSel_SendCmnds/recv: non-BCD byte count"
|
||||
" - link to server force-closed.\n");
|
||||
return False;
|
||||
}
|
||||
max_size = sizeof (info_ptr->from_host) -
|
||||
sizeof (info_ptr->from_host.msg_size);
|
||||
max_size = sizeof(info_ptr->from_host) -
|
||||
sizeof(info_ptr->from_host.msg_size);
|
||||
if (bytes_to_come > max_size) {
|
||||
VelSel_errcode = VELSEL__BAD_RECVLEN;
|
||||
fprintf (stderr, "\nVelSel_SendCmnds/recv: pending message length too big"
|
||||
fprintf(stderr,
|
||||
"\nVelSel_SendCmnds/recv: pending message length too big"
|
||||
" - flushing ...\n");
|
||||
nxt_byte_ptr = &info_ptr->from_host.msg_size[size];
|
||||
while (bytes_to_come > 0) { /* Flush out the incoming message */
|
||||
bytes_left = bytes_to_come;
|
||||
if (bytes_left > max_size) bytes_left = max_size;
|
||||
status = recv (info_ptr->asyn_info.skt, nxt_byte_ptr, bytes_left, 0);
|
||||
if (bytes_left > max_size)
|
||||
bytes_left = max_size;
|
||||
status = recv(info_ptr->asyn_info.skt, nxt_byte_ptr, bytes_left, 0);
|
||||
if (status <= 0) {
|
||||
VelSel_errcode = VELSEL__BAD_FLUSH; /* TCP/IP problem whilst flushing */
|
||||
GetErrno (&VelSel_errno, &VelSel_vaxc_errno);
|
||||
VelSel_Close (handle, True); /* Force close TCP/IP connection */
|
||||
fprintf (stderr, "\nVelSel_SendCmnds/recv: network problem during"
|
||||
GetErrno(&VelSel_errno, &VelSel_vaxc_errno);
|
||||
VelSel_Close(handle, True); /* Force close TCP/IP connection */
|
||||
fprintf(stderr, "\nVelSel_SendCmnds/recv: network problem during"
|
||||
" flush.\nLink to server force-closed.\n");
|
||||
return False;
|
||||
}
|
||||
bytes_to_come = bytes_to_come - status;
|
||||
}
|
||||
fprintf (stderr, "\n flushed OK.\n");
|
||||
memset (info_ptr->from_host.msg_size,
|
||||
'0', sizeof (info_ptr->from_host.msg_size));
|
||||
fprintf(stderr, "\n flushed OK.\n");
|
||||
memset(info_ptr->from_host.msg_size,
|
||||
'0', sizeof(info_ptr->from_host.msg_size));
|
||||
return False;
|
||||
}else {
|
||||
} else {
|
||||
nxt_byte_ptr = &info_ptr->from_host.msg_size[size];
|
||||
bytes_left = bytes_to_come;
|
||||
while (bytes_left > 0) { /* Read the rest of the response */
|
||||
status = recv (info_ptr->asyn_info.skt, nxt_byte_ptr, bytes_left, 0);
|
||||
status = recv(info_ptr->asyn_info.skt, nxt_byte_ptr, bytes_left, 0);
|
||||
if (status <= 0) {
|
||||
GetErrno (&VelSel_errno, &VelSel_vaxc_errno);
|
||||
GetErrno(&VelSel_errno, &VelSel_vaxc_errno);
|
||||
if (status == 0) {
|
||||
VelSel_errcode = VELSEL__BAD_RECV1; /* Server exited (probably) */
|
||||
fprintf (stderr, "\nVelSel_SendCmnds/recv/1: probable network "
|
||||
fprintf(stderr, "\nVelSel_SendCmnds/recv/1: probable network "
|
||||
"problem");
|
||||
}else {
|
||||
} else {
|
||||
if (VelSel_errno == EPIPE) {
|
||||
VelSel_errcode = VELSEL__BAD_RECV1_PIPE; /* Server exited (probably) */
|
||||
fprintf (stderr, "\nVelSel_SendCmnds/recv/1: broken network pipe");
|
||||
}else {
|
||||
fprintf(stderr,
|
||||
"\nVelSel_SendCmnds/recv/1: broken network pipe");
|
||||
} else {
|
||||
VelSel_errcode = VELSEL__BAD_RECV1_NET; /* It's some other net fault */
|
||||
perror ("VelSel_SendCmnds/recv/1");
|
||||
perror("VelSel_SendCmnds/recv/1");
|
||||
}
|
||||
}
|
||||
VelSel_Close (handle, True); /* Force close TCP/IP connection */
|
||||
fprintf (stderr, " - link to server force-closed.\n");
|
||||
VelSel_Close(handle, True); /* Force close TCP/IP connection */
|
||||
fprintf(stderr, " - link to server force-closed.\n");
|
||||
return False;
|
||||
}
|
||||
bytes_left = bytes_left - status;
|
||||
nxt_byte_ptr = nxt_byte_ptr + status;
|
||||
}
|
||||
if ((sscanf (info_ptr->from_host.n_rply, "%4d",
|
||||
if ((sscanf(info_ptr->from_host.n_rply, "%4d",
|
||||
&info_ptr->max_replies) != 1) ||
|
||||
(info_ptr->max_replies < 0)) {
|
||||
VelSel_errcode = VELSEL__BAD_REPLY; /* Reply is bad */
|
||||
if (VelSel_call_depth < 5) { /* Add reply to routine stack */
|
||||
bytes_to_come = bytes_to_come + 4;
|
||||
if (bytes_to_come >= sizeof (VelSel_routine[0]))
|
||||
bytes_to_come = sizeof (VelSel_routine[0]) - 1;
|
||||
for (i=0; i<bytes_to_come; i++) {
|
||||
if (bytes_to_come >= sizeof(VelSel_routine[0]))
|
||||
bytes_to_come = sizeof(VelSel_routine[0]) - 1;
|
||||
for (i = 0; i < bytes_to_come; i++) {
|
||||
if (info_ptr->from_host.msg_size[i] == '\0')
|
||||
info_ptr->from_host.msg_size[i] = '.';
|
||||
}
|
||||
info_ptr->from_host.msg_size[bytes_to_come] = '\0';
|
||||
strcpy (VelSel_routine[VelSel_call_depth],
|
||||
strcpy(VelSel_routine[VelSel_call_depth],
|
||||
info_ptr->from_host.msg_size);
|
||||
VelSel_call_depth++;
|
||||
}
|
||||
@ -924,5 +1010,6 @@
|
||||
}
|
||||
VelSel_call_depth--;
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------- End of VelSel_Utility.C =======*/
|
||||
|
Reference in New Issue
Block a user