From 63f8406f528976dc8eb2e117af6f3f03f2a75bf1 Mon Sep 17 00:00:00 2001 From: cvs Date: Thu, 7 Sep 2000 10:09:38 +0000 Subject: [PATCH] - fixed a bug in amorstat which resulted in bad scan axis to be sent - added GetSoftVar to scan module. - Made sps moddule give up only after three tries to get command through - Added build script --- amor2t.c | 1 - amorstat.c | 2 +- build | 24 ++++++++++++++ danu.dat | 2 +- doc/programmer/center.tex | 4 +++ doc/programmer/choco.tex | 41 ++++++++++++++++++++---- doc/programmer/event.tex | 1 + doc/programmer/hkl.tex | 1 + doc/programmer/nconman.tex | 8 ++++- doc/programmer/optimise.tex | 2 ++ doc/programmer/scan.tex | 5 +++ doc/programmer/velo.tex | 2 +- doc/programmer/velodorn.tex | 19 +++++++++-- scan.c | 42 ++++++++++++++++++++++++ scan.h | 2 ++ scan.tex | 5 +++ scan.w | 5 +++ sps.c | 64 ++++++++++++++++++++++--------------- 18 files changed, 192 insertions(+), 38 deletions(-) create mode 100755 build diff --git a/amor2t.c b/amor2t.c index 996818cb..bf75c42e 100644 --- a/amor2t.c +++ b/amor2t.c @@ -943,7 +943,6 @@ /* set modified interface functions */ pAOM->pDes->GetInterface = A2TGetInterface; pAOM->pDriv->Halt = A2THalt; - pAOM->pDes->SaveStatus = NULL; pAOM->pDriv->CheckLimits = ANA2TCheck; pAOM->pDriv->SetValue = ANA2TSetValue; pAOM->pDriv->GetValue = ANA2TGetValue; diff --git a/amorstat.c b/amorstat.c index 3e6837d8..5f7b6cb0 100644 --- a/amorstat.c +++ b/amorstat.c @@ -85,7 +85,7 @@ return 0; } iAxis[0] = htonl(iLength); - GetScanVar(pScan,0,fAxis,iLength); + GetSoftScanVar(pScan,0,fAxis,iLength); GetScanVarName(pScan,0,pName,39); sprintf(pBueffel,"arrowaxis_%s",pName); for(i = 0 ; i < iLength; i++) diff --git a/build b/build new file mode 100755 index 00000000..8bfdbefe --- /dev/null +++ b/build @@ -0,0 +1,24 @@ +#!/bin/sh +#--------------------------------------------------------------------------- +# build SICS from Scratch +# +# Mark Koennecke, September 2000 +#-------------------------------------------------------------------------- + +#------- build tecs +cd tecs +make +cd .. + +#----- build hardsup +cd hardsup +make +cd .. + +#----- build difrac +cd difrac +make +cd .. + +#------- finally build SICS +make diff --git a/danu.dat b/danu.dat index d64190fa..bc903d7a 100644 --- a/danu.dat +++ b/danu.dat @@ -1,3 +1,3 @@ - 7288 + 7292 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/doc/programmer/center.tex b/doc/programmer/center.tex index 52d777ef..b1e3ecae 100644 --- a/doc/programmer/center.tex +++ b/doc/programmer/center.tex @@ -31,6 +31,10 @@ $\langle$fitinter {\footnotesize ?}$\rangle\equiv$ \mbox{}\verb@ -2 when right FWHM could not be found@\\ \mbox{}\verb@ 1 on success@\\ \mbox{}\verb@ */@\\ +\mbox{}\verb@ int CalculateFitFromData(pFit self, float fAxis[], long lSum[], @\\ +\mbox{}\verb@ int iLen);@\\ +\mbox{}\verb@ void GetFitResults(pFit self, float *fNewCenter, float *fStdDev,@\\ +\mbox{}\verb@ float *FWHM, float *fMax);@\\ \mbox{}\verb@ int DriveCenter(pFit self, SConnection *pCon, SicsInterp *pSics);@\\ \mbox{}\verb@/*-------------------------------------------------------------------------*/@\\ \mbox{}\verb@ int FitFactory(SConnection *pCon,SicsInterp *pSics, void *pData,@\\ diff --git a/doc/programmer/choco.tex b/doc/programmer/choco.tex index fe5016a4..af1f8bbe 100644 --- a/doc/programmer/choco.tex +++ b/doc/programmer/choco.tex @@ -1,8 +1,9 @@ \subsection{Chopper Controller} -Yet another way to deal with a controller has beenn devised for +Yet another way to deal with a controller has been devised for SICS. This uses the concept of a general controller which can have parameters enquired and set. Furthermore it may have parameters which -may be driven like a motor through a special adapter. This scheme is +may be driven like a motor or environment controller through special +adapters . This scheme is used for the chopper controller for FOCUS. \begin{itemize} \item A driver for a particular controller which allows to set and get @@ -11,6 +12,7 @@ parameters. \item An adapter object which allows to drive special parameters in a general controller. Such adapter objects can be configured for each drivable parameter in a controller. +\item An adapter to an environment controller driver. \end{itemize} The test case for this way of doing things is a controller for running choppers. This is why it gets the name. @@ -85,7 +87,7 @@ fValue. The last is floating point which covers the frequent occurence of numeric values. \item[SetPar2] The same as SetPar but uses test string as input for parameter setting. -\item[GetPar] retrieves the parameter parname formatted as test. The +\item[GetPar] retrieves the parameter parname formatted as text. The value is put into the buffer pBuffer. iBufLen is the maximum number of bytes permissable for pBuffer. \item[CheckPar] When parameters are driven a means is needed to find @@ -180,7 +182,7 @@ $\langle$chocodata {\footnotesize ?}$\rangle\equiv$ It consists just of the standard SICS object descriptor and a pointer to the driver. -\subsubsection{The Drive Adapter} +\subsubsection{The Drive And Environment Adapters} Most of the work of the drive adaptor is hidden in the functions implementing the drivable interface. Thus the interface to the DriveAdapter is fairly simple: @@ -199,6 +201,8 @@ $\langle$adapter {\footnotesize ?}$\rangle\equiv$ \mbox{}\verb@ int CHAdapterAction(SConnection *pCon, SicsInterp *pSics, @\\ \mbox{}\verb@ void *pData,@\\ \mbox{}\verb@ int argc, char *argv[]);@\\ +\mbox{}\verb@@\\ +\mbox{}\verb@ pEVDriver MakeControllerEnvironmentDriver(int argc, char *argv[]);@\\ \mbox{}\verb@ @\\ \mbox{}\verb@@$\diamond$ \end{list} @@ -215,6 +219,8 @@ creating a drive adapter. \item[CHAdapterAction] is the SICS interpreter function for representing the object in SICS. Just a single action is supported: request the value of the parameter. +\item[MakeControllerEnvironmentDriver] creates an environment control +driver for a parameter in a general controller object. \end{description} The data structure for the drive adapter is slightly more interesting: @@ -253,8 +259,30 @@ $\langle$adadata {\footnotesize ?}$\rangle\equiv$ this adapter. \end{description} +This is the data structure for the private part of the environment +controller driver: \begin{flushleft} \small \begin{minipage}{\linewidth} \label{scrap6} +$\langle$evada {\footnotesize ?}$\rangle\equiv$ +\vspace{-1ex} +\begin{list}{}{} \item +\mbox{}\verb@@\\ +\mbox{}\verb@ typedef struct __CHEV {@\\ +\mbox{}\verb@ char *pParName;@\\ +\mbox{}\verb@ pCodri pDriv;@\\ +\mbox{}\verb@ int iLastError;@\\ +\mbox{}\verb@ }CHev, *pCHev;@\\ +\mbox{}\verb@@$\diamond$ +\end{list} +\vspace{-1ex} +\footnotesize\addtolength{\baselineskip}{-1ex} +\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}} +\item Macro referenced in scrap ?. +\end{list} +\end{minipage}\\[4ex] +\end{flushleft} +\begin{flushleft} \small +\begin{minipage}{\linewidth} \label{scrap7} \verb@"codri.h"@ {\footnotesize ? }$\equiv$ \vspace{-1ex} \begin{list}{}{} \item @@ -281,7 +309,7 @@ this adapter. \end{minipage}\\[4ex] \end{flushleft} \begin{flushleft} \small -\begin{minipage}{\linewidth} \label{scrap7} +\begin{minipage}{\linewidth} \label{scrap8} \verb@"choco.h"@ {\footnotesize ? }$\equiv$ \vspace{-1ex} \begin{list}{}{} \item @@ -308,7 +336,7 @@ this adapter. \end{minipage}\\[4ex] \end{flushleft} \begin{flushleft} \small -\begin{minipage}{\linewidth} \label{scrap8} +\begin{minipage}{\linewidth} \label{scrap9} \verb@"chadapter.h"@ {\footnotesize ? }$\equiv$ \vspace{-1ex} \begin{list}{}{} \item @@ -327,6 +355,7 @@ this adapter. \mbox{}\verb@@$\langle$adapter {\footnotesize ?}$\rangle$\verb@@\\ \mbox{}\verb@#ifdef CHADAINTERNAL@\\ \mbox{}\verb@@$\langle$adadata {\footnotesize ?}$\rangle$\verb@@\\ +\mbox{}\verb@@$\langle$evada {\footnotesize ?}$\rangle$\verb@@\\ \mbox{}\verb@#endif@\\ \mbox{}\verb@#endif@\\ \mbox{}\verb@@$\diamond$ diff --git a/doc/programmer/event.tex b/doc/programmer/event.tex index a5ad6d87..97651ecb 100644 --- a/doc/programmer/event.tex +++ b/doc/programmer/event.tex @@ -47,6 +47,7 @@ $\langle$VE {\footnotesize ?}$\rangle\equiv$ \mbox{}\verb@#define REFLECTIONDONE 9@\\ \mbox{}\verb@#define COUNTSTART 10@\\ \mbox{}\verb@#define COUNTEND 11@\\ +\mbox{}\verb@#define FILELOADED 12@\\ \mbox{}\verb@@$\diamond$ \end{list} \vspace{-1ex} diff --git a/doc/programmer/hkl.tex b/doc/programmer/hkl.tex index 764637d1..f34f82d9 100644 --- a/doc/programmer/hkl.tex +++ b/doc/programmer/hkl.tex @@ -18,6 +18,7 @@ $\langle$hkldat {\footnotesize ?}$\rangle\equiv$ \mbox{}\verb@ typedef struct __HKL {@\\ \mbox{}\verb@ pObjectDescriptor pDes;@\\ \mbox{}\verb@ double fUB[9];@\\ +\mbox{}\verb@ MATRIX UBinv;@\\ \mbox{}\verb@ double fLambda;@\\ \mbox{}\verb@ int iManual;@\\ \mbox{}\verb@ double fLastHKL[5];@\\ diff --git a/doc/programmer/nconman.tex b/doc/programmer/nconman.tex index daee2b61..032652ac 100644 --- a/doc/programmer/nconman.tex +++ b/doc/programmer/nconman.tex @@ -133,13 +133,17 @@ $\langle$condat {\footnotesize ?}$\rangle\equiv$ \mbox{}\verb@ int iTelnet;@\\ \mbox{}\verb@ int iOutput; @\\ \mbox{}\verb@ int iFiles;@\\ -\mbox{}\verb@ int (*write)(SConnection *pCon,@\\ +\mbox{}\verb@ int (*write)(struct __SConnection *pCon,@\\ \mbox{}\verb@ char *pMessage, int iCode);@\\ +\mbox{}\verb@ mkChannel *pDataSock;@\\ +\mbox{}\verb@ char *pDataComp;@\\ +\mbox{}\verb@ int iDataPort;@\\ \mbox{}\verb@@\\ \mbox{}\verb@ /* execution context */@\\ \mbox{}\verb@ int eInterrupt;@\\ \mbox{}\verb@ int iUserRights;@\\ \mbox{}\verb@ int inUse;@\\ +\mbox{}\verb@ int iDummy;@\\ \mbox{}\verb@ int iGrab;@\\ \mbox{}\verb@ int iErrCode;@\\ \mbox{}\verb@ SicsInterp *pSics;@\\ @@ -235,12 +239,14 @@ $\langle$conint {\footnotesize ?}$\rangle\equiv$ \mbox{}\verb@ void SCSignalFunction(void *pCon, int iSignal, void *pSigData);@\\ \mbox{}\verb@/* ***************************** I/O ************************************** */@\\ \mbox{}\verb@ int SCAddLogFile(SConnection *self, char *name);@\\ +\mbox{}\verb@ int SCDelLogFile(SConnection *pCon, int iFile);@\\ \mbox{}\verb@ void SCSetOutputClass(SConnection *self, int iClass);@\\ \mbox{}\verb@ int SCWrite(SConnection *self, char *pBuffer, int iOut);@\\ \mbox{}\verb@ int SCRead(SConnection *self, char *pBuffer, int iBufLen); @\\ \mbox{}\verb@ int SCPrompt(SConnection *pCon, char *pPrompt, char *pResult, int iLen);@\\ \mbox{}\verb@ int SCSendOK(SConnection *self);@\\ \mbox{}\verb@ int SCnoSock(SConnection *pCon);@\\ +\mbox{}\verb@ int SCWriteUUencoded(SConnection *pCon, char *pName, void *iData, int iLen);@\\ \mbox{}\verb@/************************* CallBack *********************************** */@\\ \mbox{}\verb@ int SCRegister(SConnection *pCon, SicsInterp *pSics,@\\ \mbox{}\verb@ void *pInter, long lID);@\\ diff --git a/doc/programmer/optimise.tex b/doc/programmer/optimise.tex index bb5f44af..bb79438f 100644 --- a/doc/programmer/optimise.tex +++ b/doc/programmer/optimise.tex @@ -141,6 +141,8 @@ The interface to this object looks like this: \mbox{}\verb@#define SCANABORT -4@\\ \mbox{}\verb@#define SYSERROR -5@\\ \mbox{}\verb@#define DRIVEERROR -6@\\ +\mbox{}\verb@#define VARREDO -7@\\ +\mbox{}\verb@@\\ \mbox{}\verb@@\\ \mbox{}\verb@ void OptimiserClear(pOptimise self);@\\ \mbox{}\verb@ int OptimiserAdd(pOptimise self,@\\ diff --git a/doc/programmer/scan.tex b/doc/programmer/scan.tex index 10c3f82b..48dc0600 100644 --- a/doc/programmer/scan.tex +++ b/doc/programmer/scan.tex @@ -200,6 +200,8 @@ $\langle$scaninter {\footnotesize ?}$\rangle\equiv$ \mbox{}\verb@ @\\ \mbox{}\verb@ int GetScanCounts(pScanData self, long *lData, int iDataLen);@\\ \mbox{}\verb@ int GetScanVar(pScanData self, int iWhich, float *fData, int iDataLen);@\\ +\mbox{}\verb@ int GetSoftScanVar(pScanData self, int iWhich, float *fData, int iDataLen);@\\ +\mbox{}\verb@@\\ \mbox{}\verb@ int GetScanVarName(pScanData self, int iWhich, @\\ \mbox{}\verb@ char *pName, int iLength);@\\ \mbox{}\verb@ int GetScanVarStep(pScanData self, int iWhich, @\\ @@ -262,6 +264,9 @@ standard scans. scan. Max iDatLen entries will be copied into lData. \item[GetScanVar] retrieves the scan positions for the scan variable number i. Max iDatLen entries get copied into fData. +\item[GetSoftScanVar] retrieves the scan positions for the scan variable +number i. The soft positions are retrieved, not the hard position stored + during the scan. \item[GetScanVarName] retrieves the name of scan variable i. \item[GetScanVarStep] gets the step of the scan variable i. \item[GetScanMonitor] allows to retrieve the monitor counts collected diff --git a/doc/programmer/velo.tex b/doc/programmer/velo.tex index 75f91115..9d5e3224 100644 --- a/doc/programmer/velo.tex +++ b/doc/programmer/velo.tex @@ -170,7 +170,7 @@ $\langle$protos2 {\footnotesize ?}$\rangle\equiv$ \vspace{-1ex} \begin{list}{}{} \item \mbox{}\verb@@\\ -\mbox{}\verb@\*@\\ +\mbox{}\verb@/*@\\ \mbox{}\verb@ int VSSetRotation(pVelSel self, SConnection *pCon, float fNew);@\\ \mbox{}\verb@ int VSSetTilt(pVelSel self, SConnection *pCon, float FNewTilt);@\\ \mbox{}\verb@*/@\\ diff --git a/doc/programmer/velodorn.tex b/doc/programmer/velodorn.tex index 8358eb18..a9faee1c 100644 --- a/doc/programmer/velodorn.tex +++ b/doc/programmer/velodorn.tex @@ -38,10 +38,25 @@ certain speed has been reached, the command to set the desired rotation speed can be sent. The necessary mode dependent switching is done in the DornierStat function. - - \begin{flushleft} \small \begin{minipage}{\linewidth} \label{scrap1} +$\langle$dh {\footnotesize ?}$\rangle\equiv$ +\vspace{-1ex} +\begin{list}{}{} \item +\mbox{}\verb@@\\ +\mbox{}\verb@ int GetDornierStatus(void **pData, pDornierStatus pDornier);@\\ +\mbox{}\verb@ int DornierSend(void **pData, char *pCommand, char *pReply, int iLen);@\\ +\mbox{}\verb@@$\diamond$ +\end{list} +\vspace{-1ex} +\footnotesize\addtolength{\baselineskip}{-1ex} +\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}} +\item Macro referenced in scrap ?. +\end{list} +\end{minipage}\\[4ex] +\end{flushleft} +\begin{flushleft} \small +\begin{minipage}{\linewidth} \label{scrap2} \verb@"velodorn.h"@ {\footnotesize ? }$\equiv$ \vspace{-1ex} \begin{list}{}{} \item diff --git a/scan.c b/scan.c index 28ceb624..d11dfd67 100644 --- a/scan.c +++ b/scan.c @@ -1467,6 +1467,48 @@ extern void SNXFormatTime(char *pBuffer, int iLen); return 0; } + /* not reached */ + assert(0); + } +/*--------------------------------------------------------------------------*/ + int GetSoftScanVar(pScanData self, int iWhich, float *fData, int iDataLen) + { + int iEnd, i; + pVarEntry pVar = NULL; + void *pPtr = NULL; + + /* does it exist ?*/ + if( (iWhich < 0) || (iWhich >= self->iScanVar) ) + { + return 0; + } + + /* handle iEnd */ + if(self->iCounts < iDataLen) + { + iEnd = self->iCounts; + } + else + { + iEnd = iDataLen; + } + + DynarGet(self->pScanVar,iWhich,&pPtr); + pVar = (pVarEntry)pPtr; + if(pVar) + { + /* initialise to theoretical values */ + for(i = 0; i < self->iNP; i++) + { + fData[i] = pVar->fStart + i * pVar->fStep; + } + return 1; + } + else + { + return 0; + } + /* not reached */ assert(0); } diff --git a/scan.h b/scan.h index 55903bdf..1892d426 100644 --- a/scan.h +++ b/scan.h @@ -31,6 +31,8 @@ int GetScanCounts(pScanData self, long *lData, int iDataLen); int GetScanVar(pScanData self, int iWhich, float *fData, int iDataLen); + int GetSoftScanVar(pScanData self, int iWhich, float *fData, int iDataLen); + int GetScanVarName(pScanData self, int iWhich, char *pName, int iLength); int GetScanVarStep(pScanData self, int iWhich, diff --git a/scan.tex b/scan.tex index 10c3f82b..48dc0600 100644 --- a/scan.tex +++ b/scan.tex @@ -200,6 +200,8 @@ $\langle$scaninter {\footnotesize ?}$\rangle\equiv$ \mbox{}\verb@ @\\ \mbox{}\verb@ int GetScanCounts(pScanData self, long *lData, int iDataLen);@\\ \mbox{}\verb@ int GetScanVar(pScanData self, int iWhich, float *fData, int iDataLen);@\\ +\mbox{}\verb@ int GetSoftScanVar(pScanData self, int iWhich, float *fData, int iDataLen);@\\ +\mbox{}\verb@@\\ \mbox{}\verb@ int GetScanVarName(pScanData self, int iWhich, @\\ \mbox{}\verb@ char *pName, int iLength);@\\ \mbox{}\verb@ int GetScanVarStep(pScanData self, int iWhich, @\\ @@ -262,6 +264,9 @@ standard scans. scan. Max iDatLen entries will be copied into lData. \item[GetScanVar] retrieves the scan positions for the scan variable number i. Max iDatLen entries get copied into fData. +\item[GetSoftScanVar] retrieves the scan positions for the scan variable +number i. The soft positions are retrieved, not the hard position stored + during the scan. \item[GetScanVarName] retrieves the name of scan variable i. \item[GetScanVarStep] gets the step of the scan variable i. \item[GetScanMonitor] allows to retrieve the monitor counts collected diff --git a/scan.w b/scan.w index 048b78c4..b1534970 100644 --- a/scan.w +++ b/scan.w @@ -183,6 +183,8 @@ functions: int GetScanCounts(pScanData self, long *lData, int iDataLen); int GetScanVar(pScanData self, int iWhich, float *fData, int iDataLen); + int GetSoftScanVar(pScanData self, int iWhich, float *fData, int iDataLen); + int GetScanVarName(pScanData self, int iWhich, char *pName, int iLength); int GetScanVarStep(pScanData self, int iWhich, @@ -237,6 +239,9 @@ standard scans. scan. Max iDatLen entries will be copied into lData. \item[GetScanVar] retrieves the scan positions for the scan variable number i. Max iDatLen entries get copied into fData. +\item[GetSoftScanVar] retrieves the scan positions for the scan variable +number i. The soft positions are retrieved, not the hard position stored + during the scan. \item[GetScanVarName] retrieves the name of scan variable i. \item[GetScanVarStep] gets the step of the scan variable i. \item[GetScanMonitor] allows to retrieve the monitor counts collected diff --git a/sps.c b/sps.c index 4a9c1e4b..b95c4e16 100644 --- a/sps.c +++ b/sps.c @@ -24,6 +24,7 @@ #include "bit.h" #include "sps.i" #include "sps.h" +#include "commandlog.h" /*--------------------- some internal defines ----------------------------*/ #define SPSOFFLINE -10 @@ -69,43 +70,56 @@ int iReplyLen) { int iRet, i; + char pError[132]; assert(self); assert(pCommand); assert(pReply); - /* Send command. If failure try to reconnect and try again. If - still in trouble then, give up - */ - iRet = SerialWriteRead(&self->pData,pCommand,pReply,iReplyLen); - if(iRet != 1) + /* + try at least three times to get the command through before + giving up + */ + for(i = 0; i < 3; i++) { - switch(iRet) - { - case TIMEOUT: + iRet = SerialWriteRead(&self->pData,pCommand,pReply,iReplyLen); + if(iRet != 1) + { + switch(iRet) + { + case TIMEOUT: self->iLastError = COMMTMO; - return 0; + continue; break; - default: + default: self->iLastError = iRet; - return 0; + SerialError(iRet,pError,131); + WriteToCommandLog("SYS: SPS-TROUBLE:",pError); + SerialClose(&self->pData); + iRet = init(self); + if(iRet == 0) + { + return 0; + } + continue; break; + } + } + + /* now we may still have a TMO or OFL message */ + if(strstr(pReply,"?TMO") != NULL) + { + self->iLastError = COMMTMO; + continue; } - } - - /* now we may still have a TMO or OFL message */ - if(strstr(pReply,"?TMO") != NULL) - { - self->iLastError = COMMTMO; - return 0; + if(strstr(pReply,"?OFL") != NULL) + { + self->iLastError = SPSOFFLINE; + return 0; + } + return 1; } - if(strstr(pReply,"?OFL") != NULL) - { - self->iLastError = SPSOFFLINE; - return 0; - } - - return 1; + return 0; } /*--------------------------------------------------------------------------*/ int SPSSetButton(pSPS self, SConnection *pCon, int iByte, int iBit)