diff --git a/Makefile b/Makefile index cb46a86a..8ee274a4 100644 --- a/Makefile +++ b/Makefile @@ -16,12 +16,12 @@ FORTIFYOBJ = fortify.o strdup.o #========================================================================== # assign if the National Instrument GPIB driver is available -NI= -DHAVENI -NIOBJ= nigpib.o -NILIB=-lgpibenet -#NI= -#NIOBJ= -#NILIB= +#NI= -DHAVENI +#NIOBJ= nigpib.o +#NILIB=-lgpibenet +NI= +NIOBJ= +NILIB= #----- comment or uncomment if a difrac version is required # Do not forget to remove or add comments to ofac.c as well if changes @@ -72,18 +72,18 @@ VELOOBJ = velo.o velosim.o velodorn.o velodornier.o #----- comment or uncomment the following according to operating system #------------- for Digital Unix -#BINTARGET = bin -#HDFROOT=/data/lnslib -#CC=cc -#EXTRA= +BINTARGET = bin +HDFROOT=/data/lnslib +CC=cc +EXTRA= #CFLAGS = -I$(HDFROOT)/include -Ihardsup -DHDF4 -DHDF5 -I. -std1 \ # -g -warnprotos -c -#CFLAGS = -I$(HDFROOT)/include -DFORTIFY -DHDF4 -DHDF5 -Ihardsup -g \ -# -std1 -warnprotos -c -#LIBS = -L$(HDFROOT)/lib -Lhardsup -lhlib -Lmatrix -lmatrix -Ltecs \ -# -ltecsl -ltcl8.0 -lfor $(HDFROOT)/lib/libhdf5.a \ -# $(HDFROOT)/lib/libmfhdf.a $(HDFROOT)/lib/libdf.a \ -# $(HDFROOT)/lib/libjpeg.a -lz -lm -ll -lc +CFLAGS = -I$(HDFROOT)/include -DFORTIFY -DHDF4 -DHDF5 -Ihardsup -g \ + -std1 -warnprotos -c +LIBS = -L$(HDFROOT)/lib -Lhardsup -lhlib -Lmatrix -lmatrix -Ltecs \ + -ltecsl -ltcl8.0 -lfor $(HDFROOT)/lib/libhdf5.a \ + $(HDFROOT)/lib/libmfhdf.a $(HDFROOT)/lib/libdf.a \ + $(HDFROOT)/lib/libjpeg.a -lz -lm -ll -lc #------- for cygnus #HDFROOT=../HDF411 @@ -94,16 +94,16 @@ VELOOBJ = velo.o velosim.o velodorn.o velodornier.o # -lmfhdf -ldf -ljpeg -lz -lm #---------- for linux -BINTARGET=../../bin -HDFROOT=$(SINQDIR)/linux -CC=gcc +#BINTARGET=../../bin +#HDFROOT=$(SINQDIR)/linux +#CC=gcc #CFLAGS = -I$(HDFROOT)/include -DHDF4 -DHDF5 $(NI) -Ihardsup \ # -fwritable-strings -DCYGNUS -DNONINTF -g -c -CFLAGS = -I$(HDFROOT)/include -DFORTIFY -DHDF4 -DHDF5 $(NI) -Ihardsup \ - -fwritable-strings -DCYGNUS -DNONINTF -g -c -LIBS= -L$(HDFROOT)/lib -Lhardsup -Ltecs -ltecsl -Lmatrix -lmatrix -lhlib \ - $(NILIB) -ltcl -lhdf5 -lmfhdf -ldf -ljpeg -lz -lm -lg2c -ldl -EXTRA=nintf.o +#CFLAGS = -I$(HDFROOT)/include -DFORTIFY -DHDF4 -DHDF5 $(NI) -Ihardsup \ +# -fwritable-strings -DCYGNUS -DNONINTF -g -c +#LIBS= -L$(HDFROOT)/lib -Lhardsup -Ltecs -ltecsl -Lmatrix -lmatrix -lhlib \ +# $(NILIB) -ltcl -lhdf5 -lmfhdf -ldf -ljpeg -lz -lm -lg2c -ldl +#EXTRA=nintf.o #--------------------------------- .c.o: diff --git a/SCinter.c b/SCinter.c index 9d464003..9308bd3f 100644 --- a/SCinter.c +++ b/SCinter.c @@ -222,15 +222,8 @@ extern char *SkipSpace(char *pPtr); } else { - if(!pCon->iDummy) - { - printf("Executing -> %s <- from dummy socket\n", pText); - } - else - { - sprintf(pBueffel,"Executing -> %s <- from sicscron",pText); - SICSLogWrite(pBueffel,eCommand); - } + printf("Executing -> %s <- from dummy socket\n", pText); + SICSLogWrite(pBueffel,eCommand); } /* convert to argc, argv */ diff --git a/conman.c b/conman.c index a2a542b0..0d27705b 100644 --- a/conman.c +++ b/conman.c @@ -130,7 +130,6 @@ extern pServer pServ; pRes->pSics = pSics; pRes->eInterrupt = eContinue; pRes->lMagic = CONMAGIC; - pRes->iDummy = 0; pRes->iLogin = 0; pRes->conStart = time(NULL); pRes->write = SCNormalWrite; @@ -216,7 +215,6 @@ extern pServer pServ; pRes->pSics = pSics; pRes->lMagic = CONMAGIC; pRes->eInterrupt = eContinue; - pRes->iDummy = 0; pRes->iLogin = 0; pRes->conStart = time(NULL); pRes->write = SCNormalWrite; @@ -546,6 +544,24 @@ extern pServer pServ; } return self->write(self,pBuffer,iOut); } +/*-------------------------------------------------------------------------*/ +writeFunc SCGetWriteFunc(SConnection *self) +{ + if(!VerifyConnection(self)) + { + return 0; + } + return self->write; +} +/*-------------------------------------------------------------------------*/ +void SCSetWriteFunc(SConnection *self, writeFunc x) +{ + if(!VerifyConnection(self)) + { + return; + } + self->write = x; +} /*--------------------------------------------------------------------------*/ static int SCNormalWrite(SConnection *self, char *buffer, int iOut) { @@ -658,6 +674,95 @@ extern pServer pServ; } return 1; } +/*--------------------------------------------------------------------------*/ + int SCOnlySockWrite(SConnection *self, char *buffer, int iOut) + { + int i, iPtr, iRet; + char pBueffel[80]; + + if(!VerifyConnection(self)) + { + return 0; + } + + /* log it for any case */ + if(self->pSock) + { + iRet = self->pSock->sockid; + } + else + { + iRet = 0; + } + sprintf(pBueffel,"Next line intended for socket: %d",iRet); + SICSLogWrite(pBueffel,eInternal); + SICSLogWrite(buffer,iOut); + + /* put it into the interpreter if present */ + if(SCinMacro(self)) + { + InterpWrite(self->pSics,buffer); + } + else /* not in interpreter, normal logic */ + { + /* is this really to be printed ? */ + if(iOut < self->iOutput) + return 0; + + /* the socket */ + if(self->pSock) + { + if(self->iTelnet) + { + iRet = TelnetWrite(self->pSock,buffer); + } + else + { + iRet = NETWrite(self->pSock,buffer,strlen(buffer)); + if(!HasNL(buffer)) + { + iRet = NETWrite(self->pSock,"\n",sizeof("\n")); + } + } + if(!iRet) + { + SCnoSock(self); + WriteToCommandLog("SYS> ","Send broken to connection"); + } + } + else + { + printf("%s \n",buffer); + } + } + return 1; + } +/*--------------------------------------------------------------------------*/ + int SCNotWrite(SConnection *self, char *buffer, int iOut) + { + int i, iPtr, iRet; + char pBueffel[80]; + + if(!VerifyConnection(self)) + { + return 0; + } + + /* log it for any case */ + if(self->pSock) + { + iRet = self->pSock->sockid; + } + else + { + iRet = 0; + } + sprintf(pBueffel,"Next line intended for socket: %d",iRet); + SICSLogWrite(pBueffel,eInternal); + SICSLogWrite(buffer,iOut); + + return 1; + } /*-------------------------------------------------------------------------- This version writes only to configured log files but not to sockets. Used for automatic file execution for the WWW interface @@ -1176,33 +1281,13 @@ extern pServer pServ; return self->eInterrupt; } -/*--------------------------------------------------------------------------*/ - void SCSetError(SConnection *self, int eCode) - { - if(!VerifyConnection(self)) - { - return; - } - - self->iErrCode = eCode; - } -/*---------------------------------------------------------------------------*/ - int SCGetError(SConnection *self) - { - if(!VerifyConnection(self)) - { - return 0; - } - - return self->iErrCode; - } /* --------------------------------------------------------------------------*/ int SCInvoke(SConnection *self, SicsInterp *pInter, char *pCommand) { int iRet; long lLen; const char *pResult = NULL; - char *pBuffer = NULL; + char *pBuffer = NULL, *pFile = NULL; char pBueffel[80]; int i, iSpace; @@ -1238,8 +1323,20 @@ extern pServer pServ; /* invoke */ self->inUse++; self->eInterrupt = eContinue; - self->iErrCode = OKOK; + self->parameterChange = 0; iRet = InterpExecute(pInter,self,pCommand); + if(self->parameterChange == 1) + { + /* + automatically save changed parameters + */ + pFile = IFindOption(pSICSOptions,"statusfile"); + if(pFile != NULL) + { + WriteSicsStatus(pInter,pFile,0); + self->parameterChange = 0; + } + } self->inUse--; return iRet; } @@ -1701,3 +1798,12 @@ extern pServer pServ; self->iGrab = 1; } } +/*-----------------------------------------------------------------------*/ +void SCparChange(SConnection *self) +{ + if(!VerifyConnection(self)) + { + return; + } + self->parameterChange = 1; +} diff --git a/conman.h b/conman.h index faaa74fd..93011394 100644 --- a/conman.h +++ b/conman.h @@ -22,6 +22,9 @@ #define MAXLOGFILES 10 +typedef int (*writeFunc)(struct __SConnection *pCon, + char *pMessage, int iCode); + typedef struct __SConnection { /* object basics */ pObjectDescriptor pDes; @@ -35,8 +38,7 @@ int iTelnet; int iOutput; int iFiles; - int (*write)(struct __SConnection *pCon, - char *pMessage, int iCode); + writeFunc write; mkChannel *pDataSock; char *pDataComp; int iDataPort; @@ -45,10 +47,11 @@ int eInterrupt; int iUserRights; int inUse; - int iDummy; int iGrab; - int iErrCode; SicsInterp *pSics; + + /* flag for parameter change */ + int parameterChange; /* a FIFO */ pCosta pStack; @@ -88,19 +91,22 @@ int SCnoSock(SConnection *pCon); int SCWriteUUencoded(SConnection *pCon, char *pName, void *iData, int iLen); int SCWriteZipped(SConnection *pCon, char *pName, void *pData, int iDataLen); + writeFunc SCGetWriteFunc(SConnection *pCon); + void SCSetWriteFunc(SConnection *pCon, writeFunc x); + int SCOnlySockWrite(SConnection *self, char *buffer, int iOut); + int SCNotWrite(SConnection *self, char *buffer, int iOut); /************************* CallBack *********************************** */ int SCRegister(SConnection *pCon, SicsInterp *pSics, void *pInter, long lID); int SCUnregister(SConnection *pCon, void *pInter); -/******************************* Error **************************************/ +/******************************* Interrupt *********************************/ void SCSetInterrupt(SConnection *self, int eCode); int SCGetInterrupt(SConnection *self); - void SCSetError(SConnection *pCon, int iCode); - int SCGetError(SConnection *pCon); /****************************** Macro ***************************************/ int SCinMacro(SConnection *pCon); int SCsetMacro(SConnection *pCon, int iMode); - +/************************** parameters changed ? **************************/ + void SCparChange(SConnection *pCon); /* *************************** Info *************************************** */ int SCGetRights(SConnection *self); int SCSetRights(SConnection *pCon, int iNew); diff --git a/counter.c b/counter.c index 7dcac5ff..72e0e849 100644 --- a/counter.c +++ b/counter.c @@ -230,7 +230,6 @@ { SCWrite(pCon,"ERROR: Cannot fix counter problem, aborting",eError); SCSetInterrupt(pCon,eAbortBatch); - SCSetError(pCon,eCt); return eCt; } else @@ -795,6 +794,7 @@ if(isAuthorised(pCon,usUser)) { iRet2 = SetCounterPreset(self,PaRes.Arg[0].fVal); + SCparChange(pCon); if(iRet2) SCSendOK(pCon); return iRet2; @@ -823,12 +823,14 @@ if(strcmp(PaRes.Arg[0].text,"timer") == 0) { SetCounterMode(self,eTimer); + SCparChange(pCon); SCSendOK(pCon); return 1; } else if(strcmp(PaRes.Arg[0].text,"monitor") == 0) { SetCounterMode(self,ePreset); + SCparChange(pCon); SCSendOK(pCon); return 1; } @@ -869,6 +871,7 @@ return 0; } self->iExponent = PaRes.Arg[0].iVal; + SCparChange(pCon); SCSendOK(pCon); return 1; case 8: /* GetExponent */ @@ -960,6 +963,7 @@ } else { + SCparChange(pCon); SCSendOK(pCon); return 1; } @@ -982,12 +986,14 @@ if(strcmp(PaRes.Arg[0].text,"timer") == 0) { SetCounterMode(self,eTimer); + SCparChange(pCon); SCSendOK(pCon); return 1; } else if(strcmp(PaRes.Arg[0].text,"monitor") == 0) { SetCounterMode(self,ePreset); + SCparChange(pCon); SCSendOK(pCon); return 1; } @@ -1025,6 +1031,7 @@ iRet2 = SetCounterPreset(self,PaRes.Arg[0].fVal); if(iRet2) SCSendOK(pCon); + SCparChange(pCon); return iRet2; } else @@ -1069,6 +1076,7 @@ PaRes.Arg[1].iVal, PaRes.Arg[2].fVal); if(iRet == 1) { + SCparChange(pCon); SCSendOK(pCon); return 1; } diff --git a/devexec.c b/devexec.c index d0becf37..954f87b3 100644 --- a/devexec.c +++ b/devexec.c @@ -196,7 +196,6 @@ if(!pNew) { SCWrite(pCon,"ERROR: memory exhausted in Device Executor ",eError); - SCSetError(pCon,NOMEMORY); return 0; } @@ -240,7 +239,6 @@ { sprintf(pBueffel,"ERROR: cannot start device %s",name); SCWrite(pCon,pBueffel,eError); - SCSetError(self->pOwner,iRet); DeleteDevEntry(pNew); if(LLDcheck(self->iList) >= LIST_EMPTY) { @@ -398,7 +396,6 @@ self->iStatus = DEVDONE; break; case HWFault: /* real HW error: burning, no net etc.. */ - SCSetError(self->pOwner,iRet); DeleteDevEntry(pDev); LLDnodeDelete(self->iList); self->iStatus = DEVERROR; @@ -442,7 +439,6 @@ self->iStatus = DEVBUSY; break; case HWPosFault: /* cannot get somewhere... */ - SCSetError(self->pOwner,eCode); DeleteDevEntry(pDev); LLDnodeDelete(self->iList); self->iStatus = DEVERROR; diff --git a/doc/manager/hwini.htm b/doc/manager/hwini.htm index 08010e30..ac53ad8e 100644 --- a/doc/manager/hwini.htm +++ b/doc/manager/hwini.htm @@ -63,6 +63,77 @@ number of the motor in the EL734DC motor controller.
+GPIB is yet another bus system. Up to 30 devices can share the bus and +transfer data on it. SICS likest to speak to GPIB devices through the +National Instrument ENET-100 TCP/IP bridge. In order for this to work +the National Instruments driver software must have been installed on +the computer running SICS. SICS has to be compiled with the define +HAVENI defined and the proper paths to the header file and library +configured. The an GPIB controller can be installed into SICS with the +command: +
+MakeGPIB name drivertype ++Name is the name under which the GPIB controller is addressable within +SICS afterwards. drivertype is the driver to use for the GPIB +device. Supported values are: +
+ECB controllers are at the heart of the Risoe data aquisition +system. These are essentially Z80 processors wired to the GPIB +bus. Functions can be invoked in this processor by sending a function +code followed by the contents of 4 8 bit registers. As a result the +contents of the registers after the function call are returned. A ECB +can be made knwon to SICS through the initialisation command: +
+MakeECB name gpib-controller gbib-controller-number gpib-address ++The parameters: +