diff --git a/counter.c b/counter.c index 1b21f4a7..8358c834 100644 --- a/counter.c +++ b/counter.c @@ -1017,7 +1017,7 @@ /* only manager may use this */ if(!SCMatchRights(pCon,usMugger)) { - return; + return 0; } Arg2Text(argc-2,&argv[2],pError,79); iRet = self->pDriv->Send(self->pDriv,pError,pBueffel,255); diff --git a/danu.dat b/danu.dat index 992f0ca2..c3a656e7 100644 --- a/danu.dat +++ b/danu.dat @@ -1,3 +1,3 @@ - 7634 + 7647 NEVER, EVER modify or delete this file You'll risk eternal damnation and a reincarnation as a cockroach!|n \ No newline at end of file diff --git a/devexec.c b/devexec.c index d9165069..e091e3a4 100644 --- a/devexec.c +++ b/devexec.c @@ -561,7 +561,7 @@ */ if(self->iStop == 1) { - return; + return 0; } else { diff --git a/evcontroller.c b/evcontroller.c index 410e1f0a..91867651 100644 --- a/evcontroller.c +++ b/evcontroller.c @@ -173,6 +173,7 @@ int iRet, iCode, iFix; char pBueffel[256], pError[132]; static int iCount; + static int callCount; self = (pEVControl)pData; assert(self); @@ -228,6 +229,15 @@ { fDelta = - fDelta; } + + /* handle callback */ + callCount++; + if(callCount >= 10) + { + sprintf(pBueffel,"%s = %f", self->pName, fPos); + InvokeCallBack(self->pCall, VALUECHANGE,pBueffel); + callCount = 0; + } /* based on this: logic ! */ if(fDelta <= ObVal(self->pParam, TOLERANCE)) /* done */ @@ -548,6 +558,14 @@ { return 0; } + /* deal with callbacks */ + self->callCount++; + if(self->callCount >= 20) + { + sprintf(pBueffel,"%s = %F", self->pName, fPos); + InvokeCallBack(self->pCall,VALUECHANGE, pBueffel); + self->callCount = 0; + } } else if(iRet == -1) /* pending */ { @@ -643,7 +661,17 @@ pRes->pEnvir->GetMode = EVIGetMode; pRes->pEnvir->IsInTolerance = EVIIsInTolerance; pRes->pEnvir->HandleError = EVIErrHandler; - + + /* callback interface */ + pRes->pCall = CreateCallBackInterface(); + if(!pRes->pCall) + { + free(pRes->pDrivInt); + DeleteDescriptor(pRes->pDes); + free(pRes); + return NULL; + } + /* new parameter space */ pRes->pParam = ObParCreate(7); if(!pRes->pParam) @@ -711,6 +739,10 @@ { free(self->pEnvir); } + if(self->pCall) + { + DeleteCallBackInterface(self->pCall); + } if(self->KillPrivate) { self->KillPrivate(self->pPrivate); @@ -894,6 +926,20 @@ return 1; } +/*-------------------------------------------------------------------------*/ + static int EVCallBack(int iEvent, void *pEventData, void *pUserData) + { + char *pBuf = (char *)pEventData; + SConnection *pCon = (SConnection *)pUserData; + char pBueffel[132]; + + if(iEvent == VALUECHANGE) + { + SCWrite(pCon,pBuf,eValue); + return 1; + } + return 1; + } /*--------------------------------------------------------------------------- The wrapper understands the following syntax: EVControl : print current value @@ -913,6 +959,7 @@ double dVal; float fPos; int iRet; + long lID; self = (pEVControl)pData; assert(self); @@ -943,6 +990,21 @@ SCWrite(pCon,pReply,eValue); return iRet; } + /* install automatic notification */ + else if(strcmp(argv[1],"interest") == 0) + { + lID = RegisterCallback(self->pCall, VALUECHANGE, EVCallBack, + pCon, NULL); + SCRegister(pCon,pSics, self->pCall,lID); + SCSendOK(pCon); + return 1; + } + else if(strcmp(argv[1],"uninterest") == 0) + { + RemoveCallback2(self->pCall,pCon); + SCSendOK(pCon); + return 1; + } else if(strcmp(argv[1],"log") == 0) /* log commands */ { if(argc < 3) diff --git a/evcontroller.h b/evcontroller.h index 9b4a970e..a1e1740b 100644 --- a/evcontroller.h +++ b/evcontroller.h @@ -1,5 +1,5 @@ -#line 208 "evcontroller.w" +#line 211 "evcontroller.w" /*-------------------------------------------------------------------------- E N V I R O N M E N T C O N T R O L L E R @@ -14,7 +14,7 @@ #define SICSEVCONTROL #include "varlog.h" -#line 130 "evcontroller.w" +#line 133 "evcontroller.w" /*--------------------------- live & death --------------------------------*/ typedef struct __EVControl *pEVControl; @@ -44,6 +44,6 @@ -#line 221 "evcontroller.w" +#line 224 "evcontroller.w" #endif diff --git a/evcontroller.i b/evcontroller.i index 7b613d57..2b9bd42b 100644 --- a/evcontroller.i +++ b/evcontroller.i @@ -1,5 +1,5 @@ -#line 225 "evcontroller.w" +#line 228 "evcontroller.w" /*------------------------------------------------------------------------- Environment controller datastructure @@ -23,6 +23,8 @@ pObjectDescriptor pDes; pIDrivable pDrivInt; pEVInterface pEnvir; + pICallBack pCall; + int callCount; pEVDriver pDriv; EVMode eMode; float fTarget; @@ -37,5 +39,5 @@ void (*KillPrivate)(void *pData); } EVControl; -#line 241 "evcontroller.w" +#line 244 "evcontroller.w" diff --git a/evcontroller.tex b/evcontroller.tex index 9330cbe8..f05d1f31 100644 --- a/evcontroller.tex +++ b/evcontroller.tex @@ -36,6 +36,8 @@ $\langle$evdata {\footnotesize ?}$\rangle\equiv$ \mbox{}\verb@ pObjectDescriptor pDes;@\\ \mbox{}\verb@ pIDrivable pDrivInt;@\\ \mbox{}\verb@ pEVInterface pEnvir;@\\ +\mbox{}\verb@ pICallBack pCall;@\\ +\mbox{}\verb@ int callCount;@\\ \mbox{}\verb@ pEVDriver pDriv;@\\ \mbox{}\verb@ EVMode eMode;@\\ \mbox{}\verb@ float fTarget;@\\ @@ -63,7 +65,8 @@ the second field a pointer to an Drivable interface. Each environment controller needs to implement that in order to allow SICS drive the device to a new value. The third field is a pointer to an environment interface. This is needed in order to enable monitoring of the device when it has -reached its target value. The fourth field is a pointer to the driver for +reached its target value. Then there is a pointer to a callback +interface. The fifth field is a pointer to the driver for the actual hardware. Next is the mode the device is in. Of course there must be floating point value which defines the current target value for the device. pName is a pointer to a string representing the name of the diff --git a/evcontroller.w b/evcontroller.w index 5dc412e2..334c3503 100644 --- a/evcontroller.w +++ b/evcontroller.w @@ -31,6 +31,8 @@ used by EVControl: pObjectDescriptor pDes; pIDrivable pDrivInt; pEVInterface pEnvir; + pICallBack pCall; + int callCount; pEVDriver pDriv; EVMode eMode; float fTarget; @@ -51,7 +53,8 @@ the second field a pointer to an Drivable interface. Each environment controller needs to implement that in order to allow SICS drive the device to a new value. The third field is a pointer to an environment interface. This is needed in order to enable monitoring of the device when it has -reached its target value. The fourth field is a pointer to the driver for +reached its target value. Then there is a pointer to a callback +interface. The fifth field is a pointer to the driver for the actual hardware. Next is the mode the device is in. Of course there must be floating point value which defines the current target value for the device. pName is a pointer to a string representing the name of the diff --git a/evdriver.i b/evdriver.i index ea329c84..164ec45e 100644 --- a/evdriver.i +++ b/evdriver.i @@ -1,5 +1,5 @@ -#line 244 "evcontroller.w" +#line 247 "evcontroller.w" /*------------------------------------------------------------------------- Environment device driver datastructure @@ -12,7 +12,7 @@ #define DEVREDO 2 -#line 73 "evcontroller.w" +#line 76 "evcontroller.w" typedef struct __EVDriver { int (*SetValue)(pEVDriver self, float fNew); @@ -28,19 +28,8 @@ void (*KillPrivate)(void *pData); } EVDriver; -#line 255 "evcontroller.w" +#line 258 "evcontroller.w" /*-------------------- life & death of a driver --------------------------*/ pEVDriver CreateEVDriver(int argc, char *argv[]); void DeleteEVDriver(pEVDriver pDriv); - - - - - - - - - - - diff --git a/hkl.c b/hkl.c index 48a24b91..7b049f93 100644 --- a/hkl.c +++ b/hkl.c @@ -1393,7 +1393,7 @@ ente: iRet = GetCurrentPosition(self,pCon,fSet); if(iRet == 0) { - return; + return 0; } angle2HKL(self,(double)fSet[0],(double)fSet[1], (double)fSet[2],(double)fSet[3],fHKL); diff --git a/lin2ang.c b/lin2ang.c index 9c27371a..2badd666 100644 --- a/lin2ang.c +++ b/lin2ang.c @@ -63,7 +63,7 @@ self = (pLin2Ang)pData; if(!self) - return; + return 0; fprintf(fd,"%s.length %f\n",name, self->length); return 1; diff --git a/network.c b/network.c index 0d87407e..3688c10e 100644 --- a/network.c +++ b/network.c @@ -428,7 +428,7 @@ CreateSocketAdress( return 0; } - close(self->sockid); + iRet = close(self->sockid); self->iType = 0; self->sockid = 0; if(iRet < 0) diff --git a/nread.c b/nread.c index dde5671b..4a6b3c97 100644 --- a/nread.c +++ b/nread.c @@ -153,7 +153,7 @@ extern VerifyChannel(mkChannel *self); /* defined in network.c */ assert(self); if(self->lMagic != NRMAGIC) { - return; + return 0; } /* find the entry to remove */ @@ -190,7 +190,7 @@ extern VerifyChannel(mkChannel *self); /* defined in network.c */ if(pNew) { /* create connection object */ - pRes = SCreateConnection(self->pMain->pSics,pNew,iRet); + pRes = SCreateConnection(self->pMain->pSics,pNew,3); if(!pRes) { SICSLogWrite("Failure to allocate new Connection",eInternal); diff --git a/nxamor.c b/nxamor.c index 16ba647f..9f1c5a9d 100644 --- a/nxamor.c +++ b/nxamor.c @@ -72,7 +72,7 @@ iRet = NXDinitfromfile(AMORDICT,&hdict); if(iRet != NX_OK) { - sprintf(pBueffel,"ERROR: cannot open dictionary file %s"); + sprintf(pBueffel,"ERROR: cannot open dictionary file %s",AMORDICT); SCWrite(pCon,pBueffel,eError); return 0; } @@ -193,14 +193,14 @@ iRet = NXopen(file,NXACC_RDWR,&hfil); if(iRet != NX_OK) { - sprintf(pBueffel,"ERROR: cannot open file %s for writing"); + sprintf(pBueffel,"ERROR: cannot open file %s for writing",file); SCWrite(pCon,pBueffel,eError); return 0; } iRet = NXDinitfromfile(AMORDICT,&hdict); if(iRet != NX_OK) { - sprintf(pBueffel,"ERROR: cannot open dictionary file %s"); + sprintf(pBueffel,"ERROR: cannot open dictionary file %s",AMORDICT); SCWrite(pCon,pBueffel,eError); return 0; } @@ -319,14 +319,14 @@ iRet = NXopen(file,NXACC_RDWR,&hfil); if(iRet != NX_OK) { - sprintf(pBueffel,"ERROR: cannot open file %s for writing"); + sprintf(pBueffel,"ERROR: cannot open file %s for writing",file); SCWrite(pCon,pBueffel,eError); return 0; } iRet = NXDinitfromfile(AMORDICT,&hdict); if(iRet != NX_OK) { - sprintf(pBueffel,"ERROR: cannot open dictionary file %s"); + sprintf(pBueffel,"ERROR: cannot open dictionary file %s",AMORDICT); SCWrite(pCon,pBueffel,eError); return 0; } diff --git a/pimotor.c b/pimotor.c index 9018944f..76c951f0 100644 --- a/pimotor.c +++ b/pimotor.c @@ -529,7 +529,7 @@ self = (pC804Driv)pMot->pDriver; assert(self); - sprintf(pCommand,"%1.1dTY\r",self->iMotor,iVal); + sprintf(pCommand,"%1.1dTY\r",self->iMotor); iRet = SerialWriteRead(&self->pSerial,pCommand,pReply,79); if(iRet != 1) { diff --git a/sanscook.c b/sanscook.c index ca9e2158..d4ab4ea2 100644 --- a/sanscook.c +++ b/sanscook.c @@ -344,7 +344,7 @@ if(iRet != 1) { pPriv->iError = BADINPUT; - return; + return 0; } return CookerSetPar(self,parname,fValue); diff --git a/scan.c b/scan.c index 8e463e1c..782df5b8 100644 --- a/scan.c +++ b/scan.c @@ -1,3 +1,4 @@ + /*-------------------------------------------------------------------------- S C A N diff --git a/sicsstat.tcl b/sicsstat.tcl index 66d44538..d4a155c5 100644 --- a/sicsstat.tcl +++ b/sicsstat.tcl @@ -1,3 +1,5 @@ +scaninfo 9,en,2.800000,0.050000 +scaninfo setAccess 0 sicsdatapath /data/koenneck/src/sics/tmp/ sicsdatapath setAccess 1 arx2 4.290000 @@ -24,13 +26,13 @@ etam 0.000000 etam setAccess 2 wav 0.000000 wav setAccess 2 -den 0.100000 +den 0.050000 den setAccess 2 -dql 0.010000 +dql 0.000000 dql setAccess 2 dqk 0.000000 dqk setAccess 2 -dqh 0.010000 +dqh 0.000000 dqh setAccess 2 dkf 0.000000 dkf setAccess 2 @@ -94,11 +96,11 @@ alf2 3.000000 alf2 setAccess 2 alf1 11.000000 alf1 setAccess 2 -local Berty Chimney +local Mordahl Schlawadini local setAccess 2 output a1,a2,a3,a4 output setAccess 2 -lastcommand sc qh 0 0 2 3 dqh 0.01 0.0 0.01 .1 +lastcommand sc qh 2 0 0 3 dqh 0 0 0 .05 ti 2 np 9 lastcommand setAccess 2 user Billy Looser user setAccess 2 @@ -144,21 +146,21 @@ da 3.354000 da setAccess 1 dm 3.354000 dm setAccess 1 -en 3.400000 +en 3.000000 en setAccess 2 -ql 2.040000 +ql 0.000000 ql setAccess 2 qk 0.000000 qk setAccess 2 -qh 0.040000 +qh 2.000000 qh setAccess 2 kf 1.964944 kf setAccess 2 ef 8.000000 ef setAccess 2 -ki 2.345619 +ki 2.304101 ki setAccess 2 -ei 11.400000 +ei 11.000000 ei setAccess 2 bz 1.000000 bz setAccess 2 diff --git a/sinqhmdriv.c b/sinqhmdriv.c index 5afd4aaa..2188baa2 100644 --- a/sinqhmdriv.c +++ b/sinqhmdriv.c @@ -650,7 +650,7 @@ pPtr16 = (SQint16 *)pData; for(i = 0; i < iEnd; i++) { - plData[i] = (HistInt)pPtr[i]; + plData[i] = (HistInt)pPtr16[i]; } break; case 4: diff --git a/tas.h b/tas.h index 1e2a6efc..d94c0125 100644 --- a/tas.h +++ b/tas.h @@ -106,8 +106,9 @@ #define OUT 90 #define LOC 91 #define SWUNIT 92 +#define SINFO 93 -#define MAXPAR 93 +#define MAXPAR 94 #define MAXADD 20 /* --------------------- data structure -------------------------------*/ @@ -123,6 +124,7 @@ typedef struct { int addCount; int iFileNO; int iFast; + char scanVar[80]; }TASdata, *pTASdata; diff --git a/tas.w b/tas.w index 4590f6bd..f4f0b3d0 100644 --- a/tas.w +++ b/tas.w @@ -45,6 +45,7 @@ typedef struct { int addCount; int iFileNO; int iFast; + char scanVar[80]; }TASdata, *pTASdata; @} \begin{description} @@ -64,6 +65,8 @@ variables. This can be 0 for simple variables or 1 for a motor. \item[iFileNO] is the number of the current data file. \item[iFast] is a flag denoting a fast scan. In a fast scan there is no wait for the motors to finish driving. +\item[scanVar] memorizes the first scan variable with a step of greater + zero. \end{description} The constants for the parameters are defined in the header file. @@ -189,8 +192,9 @@ These are mainly the interpreter interface functions: #define OUT 90 #define LOC 91 #define SWUNIT 92 +#define SINFO 93 -#define MAXPAR 93 +#define MAXPAR 94 #define MAXADD 20 /* --------------------- data structure -------------------------------*/ diff --git a/tascom.tcl b/tascom.tcl index 99062d31..74df4bef 100644 --- a/tascom.tcl +++ b/tascom.tcl @@ -33,6 +33,7 @@ if { [info exists tasinit] == 0 } { Publish log User Publish sz User Publish sw User + Publish scaninfo Spy } #-------------------------------------------------------------------------- @@ -980,3 +981,4 @@ proc sw args { clientput [prsw] } } + diff --git a/tasdrive.c b/tasdrive.c index c7b515e0..ec8a4316 100644 --- a/tasdrive.c +++ b/tasdrive.c @@ -257,7 +257,7 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData, { SCSetInterrupt(pCon,eContinue); SCSetError(pCon,OKOK); - sprintf(pBueffel,"Driving %aborted"); + sprintf(pBueffel,"Driving aborted"); SCWrite(pCon,pBueffel,eStatus); } return 0; diff --git a/tasinit.c b/tasinit.c index 78edfa2f..987b6043 100644 --- a/tasinit.c +++ b/tasinit.c @@ -149,6 +149,7 @@ extern char *tasVariableOrder[] = { "output", "local", "swunit", + "scaninfo", NULL}; /*--------------------------------------------------------------------- There is a special feauture in MAD where the count mode is determined diff --git a/tasscan.c b/tasscan.c index cf7a62b2..06c0126d 100644 --- a/tasscan.c +++ b/tasscan.c @@ -466,7 +466,7 @@ static int TASScanPoint(pScanData self, int iPoint) */ m1 = GetMonitor(self->pCounterData,1,self->pCon); m2 = GetMonitor(self->pCounterData,2,self->pCon); - m1 = GetMonitor(self->pCounterData,3,self->pCon); + m3 = GetMonitor(self->pCounterData,3,self->pCon); cnts = GetCounts(self->pCounterData,self->pCon); fVal = GetCountTime(self->pCounterData, self->pCon); sprintf(pWork,"%8d %8d %9.4f %8d %8d ",m1,m2,fVal, cnts, m3); @@ -576,7 +576,7 @@ static int TASScanDrive(pScanData self, int iPoint) status = TASCalc(pTAS,self->pCon,tasMask, tasTargets, tasTargetMask); if(!status) - return; + return 0; TASStart(pTAS,self->pCon, self->pSics,tasTargets,tasTargetMask); /* @@ -974,7 +974,7 @@ static int EnterScanVar(pTASdata pTAS, char *name, float fCenter, { int iPtr; char pIncrement[30], pError[132]; - float fIncrement, fStart; + float fIncrement, fStart, fTemp; /* get increment @@ -996,6 +996,18 @@ static int EnterScanVar(pTASdata pTAS, char *name, float fCenter, */ fStart = fCenter - (pTAS->pScan->iNP/2) * fIncrement; + /* + If step > 0 save it for scaninfo + */ + if(fIncrement < 0) + fTemp = -fIncrement; + else + fTemp = fIncrement; + if(fTemp > .001 && strlen(pTAS->scanVar) < 2) + { + sprintf(pTAS->scanVar,"%s,%f,%f",name,fStart,fIncrement); + } + /* put it in */ @@ -1272,6 +1284,7 @@ int TASScan(SConnection *pCon, SicsInterp *pSics, void *pData, clear out old scan */ ClearScanVar(pTAS->pScan); + pTAS->scanVar[0] = '\0'; /* at this stage all simple variables have been set. Now we get the values @@ -1292,6 +1305,22 @@ int TASScan(SConnection *pCon, SicsInterp *pSics, void *pData, if(!status) return status; + /* + check if there is something to scan + */ + if(pTAS->pScan->iScanVar < 1) + { + SCWrite(pCon,"ERROR: nothing to scan",eError); + return 0; + } + + /* + now there is enough information to set the scaninfo variable which + is needed to help the status display. + */ + sprintf(pWork,"%d,%s",pTAS->pScan->iNP,pTAS->scanVar); + VarSetText(pTAS->tasPar[SINFO],pWork,0); + /* parse the output variable in order to get additional stuff to write */ diff --git a/velodornier.c b/velodornier.c index 7b70c161..92bb64c4 100644 --- a/velodornier.c +++ b/velodornier.c @@ -422,7 +422,7 @@ typedef enum {eStart, eRegel, eHalted} eVeloMode; strcpy(pBueffel,pHelp); sprintf(pHelp,"State: %s\n",sStatus.rm); strcat(pBueffel,pHelp); - sprintf(pHelp,"Current: %f\n",sStatus.pwr); + sprintf(pHelp,"Current: %d\n",sStatus.pwr); strcat(pBueffel,pHelp); sprintf(pHelp,"Rotor T: %d, Housing T: %d\n",sStatus.rot_temp, sStatus.cont_temp);