- Changes to SLS magnet controller
- Added nxscript putsicsdata to nxscript - Fixed bad minitors in nxamor.c
This commit is contained in:
4
nxamor.c
4
nxamor.c
@ -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);
|
||||
}
|
||||
}
|
||||
|
89
slsmagnet.c
89
slsmagnet.c
@ -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;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@ -799,20 +854,13 @@ static void slsdspCodeToText(int code, char *text, int textlen){
|
||||
pMe = (pSLSDriv )self->pPrivate;
|
||||
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);
|
||||
pMe->pSock = NULL;
|
||||
@ -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,7 +888,15 @@ static void slsdspCodeToText(int code, char *text, int textlen){
|
||||
return DEVFAULT;
|
||||
break;
|
||||
case BADECHO:
|
||||
case TIMEOUT:
|
||||
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:
|
||||
SLSClose(self);
|
||||
|
Reference in New Issue
Block a user