- Changes to SLS magnet controller

- Added nxscript putsicsdata to nxscript
- Fixed bad minitors in nxamor.c
This commit is contained in:
koennecke
2005-10-20 12:41:28 +00:00
parent 93f5af6930
commit 797cd1146d
3 changed files with 75 additions and 18 deletions

BIN
libpsi.a

Binary file not shown.

View File

@ -540,9 +540,9 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim,
/* the assignment of monitors has to be checked once
the Schlumpf is done
*/
lVal = GetMonitor((pCounter)pCom->pData,2, pCon);
lVal = GetMonitor((pCounter)pCom->pData,1, pCon);
NXDputalias(hfil,hdict,"cnmon1",&lVal);
lVal = GetMonitor((pCounter)pCom->pData,3, pCon);
lVal = GetMonitor((pCounter)pCom->pData,4, pCon);
NXDputalias(hfil,hdict,"cnmon2",&lVal);
}
}

View File

@ -54,6 +54,8 @@
#define DSPWRITE 0x80
#define DSPREAD 0x0
#define ABS(x) (x < 0 ? -(x) : (x))
/*-----------------------------------------------------------------------*/
typedef struct {
mkChannel *pSock;
@ -119,11 +121,12 @@ static double DSPfloat2double( ULONG input )
static int communicateSLS(mkChannel *pSock, char msg[6], char reply[6])
{
long lVal = 0;
int iRet, i;
int iRet, i, address;
if(!pSock)
return NOTCONNECTED;
address = (int)msg[1];
iRet = NETWrite(pSock,msg,6);
if(iRet < 0)
{
@ -149,6 +152,9 @@ static int communicateSLS(mkChannel *pSock, char msg[6], char reply[6])
}
}
}
if((int)reply[1] != address){
return BADECHO;
}
return TIMEOUT;
}
/*---------------------------------------------------------------------------*/
@ -164,6 +170,8 @@ static int communicateSLS(mkChannel *pSock, char msg[6], char reply[6])
pMe = (pSLSDriv)self->pPrivate;
assert(pMe);
memset(msg,0,6*sizeof(char));
memset(reply,0,6*sizeof(char));
msg[0] = DSPREAD; /* read request */
/* old address of mag current
msg[1] = 0x92;
@ -173,7 +181,7 @@ static int communicateSLS(mkChannel *pSock, char msg[6], char reply[6])
if(iRet < 0)
{
pMe->iError = iRet;
return iRet;
return 0;
}
memcpy(&ival,reply+2,4);
dval = DSPfloat2double(ival);
@ -188,7 +196,7 @@ static int communicateSLS(mkChannel *pSock, char msg[6], char reply[6])
if(iRet < 0)
{
pMe->iError = iRet;
return iRet;
return 0;
}
err = (int)reply[5];
if(err != 0){
@ -210,6 +218,9 @@ static int communicateSLS(mkChannel *pSock, char msg[6], char reply[6])
pMe = (pSLSDriv )self->pPrivate;
assert(pMe);
memset(msg,0,6*sizeof(char));
memset(reply,0,6*sizeof(char));
/*
* test high limit
*/
@ -240,7 +251,7 @@ static int communicateSLS(mkChannel *pSock, char msg[6], char reply[6])
return iRet;
}
memcpy(&ival,reply+2,4);
min = DSPfloat2double(ival);
min = -ABS(DSPfloat2double(ival));
if(fVal < min){
pMe->iError = BADLOWLIM;
return 0;
@ -735,7 +746,51 @@ static void slsdspCodeToText(int code, char *text, int textlen){
/*-------------------------------------------------------------------------*/
static int SLSSend(pEVDriver self, char *pCommand, char *pReply, int iLen)
{
strncpy(pReply,"PSI-DSP understands only binary, send disabled",iLen);
pSLSDriv pMe = NULL;
int iRet, ival;
char msg[6], reply[6];
msg[0] = DSPWRITE;
msg[1] = 0x3c;
if(strcmp(pCommand,"off") == 0){
/*
* ival = 0: ausschalten
*/
ival = 0;
memcpy(msg+2, &ival,4);
iRet = communicateSLS(pMe->pSock,msg,reply);
if(iRet <= 0)
{
pMe->iError = iRet;
SLSError(self,&ival,pReply,iLen);
return 0;
} else {
strncpy(pReply,"Done",iLen);
return 1;
}
} else if(strcmp(pCommand,"on") == 0){
/*
* ival = 1: einschalten
*/
ival = 1;
memcpy(msg+2, &ival,4);
iRet = communicateSLS(pMe->pSock,msg,reply);
if(iRet <= 0)
{
pMe->iError = iRet;
SLSError(self,&ival,pReply,iLen);
return 0;
} else {
strncpy(pReply,"Done",iLen);
return 1;
}
} else {
strncpy(pReply,"SLSMagnet only understands on or off on send",
iLen);
return 0;
}
return 0;
}
/*--------------------------------------------------------------------------*/
@ -800,18 +855,11 @@ static void slsdspCodeToText(int code, char *text, int textlen){
assert(pMe);
/*
* switch the thing off
*/
msg[0] = DSPWRITE;
msg[1] = 0x3c;
/*
* ival = 0: ausschalten
*/
ival = 0;
memcpy(msg+2, &ival,4);
iRet = communicateSLS(pMe->pSock,msg,reply);
/*
* we are on our way out: ignore errors
*/
NETClosePort(pMe->pSock);
@ -822,7 +870,8 @@ static void slsdspCodeToText(int code, char *text, int textlen){
static int SLSFix(pEVDriver self, int iError)
{
pSLSDriv pMe = NULL;
int iRet;
int iRet, i;
char buffer[80];
assert(self);
pMe = (pSLSDriv )self->pPrivate;
@ -839,6 +888,14 @@ static void slsdspCodeToText(int code, char *text, int textlen){
return DEVFAULT;
break;
case BADECHO:
for(i = 0; i < 10; i++){
iRet = NETAvailable(pMe->pSock,0);
if(iRet == 1){
NETRead(pMe->pSock, buffer,70,-10);
}
}
return DEVREDO;
break;
case TIMEOUT:
return DEVREDO;
default: