- made fixes to hkl

- Introduced a help system
- introduced a module for handling automatic updates of files during
  long measurements
- Added a circular buffer and handling facilities to varlog
- Upgraded documentation


SKIPPED:
	psi/faverage.h
	psi/nxamor.tex
	psi/pimotor.h
	psi/pimotor.tex
This commit is contained in:
cvs
2003-12-10 13:50:44 +00:00
parent 7a5f0193ab
commit bc02cb79e7
80 changed files with 2680 additions and 664 deletions

234
SCinter.c
View File

@ -6,6 +6,9 @@
Mark Koennecke, November 1996
Made ListObjects moe intelligent: list objects according to interface etc.
Mark Koennecke, December 2003
Copyright:
Labor fuer Neutronenstreuung
@ -422,11 +425,9 @@ extern char *SkipSpace(char *pPtr);
free(self);
}
/*--------------------------------------------------------------------------*/
int ListObjects(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[])
{
/*------------------------------------------------------------------------*/
static void printAll(SicsInterp *pSics, SConnection *pCon)
{
CommandList *pCurrent;
char pBueffel[256];
int iNum = 0;
@ -465,6 +466,228 @@ extern char *SkipSpace(char *pPtr);
strcat(pBueffel,"\r\n");
SCWrite(pCon,pBueffel,eStatus);
}
}
/*-----------------------------------------------------------------------
printInterface prints only those objects which implement an interface
as specified bi the id given
-------------------------------------------------------------------------*/
static void printInterface(SicsInterp *pSics, SConnection *pCon, int id)
{
CommandList *pCurrent;
char pBueffel[256];
int iNum = 0;
pObjectDescriptor pObj = NULL;
assert(pSics);
assert(pCon);
pBueffel[0] = '\0';
pCurrent = pSics->pCList;
while(pCurrent)
{
pObj = FindDescriptor(pCurrent->pData);
if(pObj != NULL)
{
if(pObj->GetInterface(pObj,id) != NULL)
{
if(iNum == 0)
{
strcpy(pBueffel,pCurrent->pName);
iNum++;
}
else if(iNum < 4)
{
strcat(pBueffel," ");
strcat(pBueffel,pCurrent->pName);
iNum++;
}
else
{
strcat(pBueffel," ");
strcat(pBueffel,pCurrent->pName);
strcat(pBueffel,"\r\n");
SCWrite(pCon,pBueffel,eStatus);
iNum = 0;
}
}
}
pCurrent = pCurrent->pNext;
}
/* write final entries */
strcat(pBueffel,"\r\n");
SCWrite(pCon,pBueffel,eStatus);
}
/*-----------------------------------------------------------------------
printMatch prints only those objects which match the wildcard string given
-------------------------------------------------------------------------*/
extern int match(const char *mask, const char *name); /* from wwildcard.c */
static void printMatch(SicsInterp *pSics, SConnection *pCon, char *mask)
{
CommandList *pCurrent;
char pBueffel[256];
int iNum = 0;
pObjectDescriptor pObj = NULL;
assert(pSics);
assert(pCon);
pBueffel[0] = '\0';
pCurrent = pSics->pCList;
while(pCurrent)
{
pObj = FindDescriptor(pCurrent->pData);
if(pObj != NULL)
{
if(!match(mask,pObj->name))
{
if(iNum == 0)
{
strcpy(pBueffel,pCurrent->pName);
iNum++;
}
else if(iNum < 4)
{
strcat(pBueffel," ");
strcat(pBueffel,pCurrent->pName);
iNum++;
}
else
{
strcat(pBueffel," ");
strcat(pBueffel,pCurrent->pName);
strcat(pBueffel,"\r\n");
SCWrite(pCon,pBueffel,eStatus);
iNum = 0;
}
}
}
pCurrent = pCurrent->pNext;
}
/* write final entries */
strcat(pBueffel,"\r\n");
SCWrite(pCon,pBueffel,eStatus);
}
/*-----------------------------------------------------------------------
printType prints only those objects which match the type given
-------------------------------------------------------------------------*/
static void printType(SicsInterp *pSics, SConnection *pCon, char *type)
{
CommandList *pCurrent;
char pBueffel[256];
int iNum = 0;
assert(pSics);
assert(pCon);
pBueffel[0] = '\0';
pCurrent = pSics->pCList;
while(pCurrent)
{
if(pCurrent->pData != NULL)
{
if(iHasType(pCurrent->pData,type))
{
if(iNum == 0)
{
strcpy(pBueffel,pCurrent->pName);
iNum++;
}
else if(iNum < 4)
{
strcat(pBueffel," ");
strcat(pBueffel,pCurrent->pName);
iNum++;
}
else
{
strcat(pBueffel," ");
strcat(pBueffel,pCurrent->pName);
strcat(pBueffel,"\r\n");
SCWrite(pCon,pBueffel,eStatus);
iNum = 0;
}
}
}
pCurrent = pCurrent->pNext;
}
/* write final entries */
strcat(pBueffel,"\r\n");
SCWrite(pCon,pBueffel,eStatus);
}
/*--------------------------------------------------------------------------*/
int ListObjects(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[])
{
if(argc < 2)
{
printAll(pSics,pCon);
return 1;
}
strtolower(argv[1]);
/*
stand alone subcommands
*/
if(strstr(argv[1],"var") != NULL)
{
printType(pSics,pCon,"SicsVariable");
return 1;
}
if(strstr(argv[1],"mot") != NULL)
{
printType(pSics,pCon,"Motor");
return 1;
}
/*
subcommand with three args
*/
if(argc < 3)
{
SCWrite(pCon,"ERROR: missing parameter to command or bad subcommand",
eError);
return 0;
}
/*
interface
*/
if(strcmp(argv[1],"inter") == 0)
{
strtolower(argv[2]);
if(strstr(argv[2],"driv") != NULL)
{
printInterface(pSics,pCon,DRIVEID);
return 1;
}
if(strstr(argv[2],"coun") != NULL)
{
printInterface(pSics,pCon,COUNTID);
return 1;
}
if(strstr(argv[2],"env") != NULL)
{
printInterface(pSics,pCon,ENVIRINTERFACE);
return 1;
}
SCWrite(pCon,"ERROR: interface description nor recognized",eError);
return 0;
}
/*
match
*/
if(strcmp(argv[1],"match") == 0)
{
printMatch(pSics,pCon,argv[2]);
return 1;
}
return 1;
}
/*---------------------------------------------------------------------------*/
@ -567,3 +790,4 @@ void *FindDrivable(SicsInterp *pSics, char *name){
return NULL;
}

View File

@ -105,7 +105,7 @@ the error can be ignored or was fully resolved.
\item[pParList] is text string containing a comma separated list of
all parameters understood by this driver.
\item[pPrivate] Is a pointer to a driver specific specific data
structure. This data structure will not be messed with by upper level code.
structure. This data structure shall not be messed with by upper level code.
\end{description}
\subsubsection{The Controller Object}

View File

@ -654,7 +654,7 @@ void SCSetWriteFunc(SConnection *self, writeFunc x)
iRet = NETWrite(self->pSock,buffer,strlen(buffer));
if(!HasNL(buffer))
{
iRet = NETWrite(self->pSock,"\n",sizeof("\n"));
iRet = NETWrite(self->pSock,"\n",strlen("\n"));
}
}
if(!iRet)

View File

@ -22,9 +22,6 @@
#define MAXLOGFILES 10
typedef int (*writeFunc)(struct __SConnection *pCon,
char *pMessage, int iCode);
typedef struct __SConnection {
/* object basics */
pObjectDescriptor pDes;
@ -38,7 +35,8 @@ typedef int (*writeFunc)(struct __SConnection *pCon,
int iTelnet;
int iOutput;
int iFiles;
writeFunc write;
int (*write)(struct __SConnection *pCon,
char *pMessage, int iCode);
mkChannel *pDataSock;
char *pDataComp;
int iDataPort;
@ -47,12 +45,11 @@ typedef int (*writeFunc)(struct __SConnection *pCon,
int eInterrupt;
int iUserRights;
int inUse;
int iDummy;
int iGrab;
int iErrCode;
SicsInterp *pSics;
/* flag for parameter change */
int parameterChange;
/* a FIFO */
pCosta pStack;
@ -61,12 +58,6 @@ typedef int (*writeFunc)(struct __SConnection *pCon,
/* Tasking Stuff */
int iEnd;
/* for keeping track of the login
process on a non telnet connection.
Should only be used in SCTaskFunction
*/
int iLogin;
time_t conStart;
}SConnection;
#include "nserver.h"
@ -90,32 +81,26 @@ typedef int (*writeFunc)(struct __SConnection *pCon,
int SCSendOK(SConnection *self);
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);
/******************************* Interrupt *********************************/
/******************************* Error **************************************/
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);
int SCMatchRights(SConnection *pCon, int iCode);
int SCGetOutClass(SConnection *self);
int SCGetGrab(SConnection *pCon);
/********************* simulation mode ************************************/
void SCSetSimMode(SConnection *pCon, int value);
int SCinSimMode(SConnection *pCon);
/* **************************** Invocation ******************************** */
int SCInvoke(SConnection *self,SicsInterp *pInter,char *pCommand);

View File

@ -104,6 +104,7 @@
{
self->isUpToDate = 0;
self->tStart = time(&tX);
InvokeCallBack(self->pCall,COUNTSTART,pCon);
return iRet;
}
else
@ -231,6 +232,7 @@
{
SCWrite(pCon,"ERROR: Cannot fix counter problem, aborting",eError);
SCSetInterrupt(pCon,eAbortBatch);
InvokeCallBack(self->pCall,COUNTEND,NULL);
return eCt;
}
else
@ -238,6 +240,10 @@
return HWBusy;
}
}
/*
handle count parameters and notify listeners on progress
*/
sMon.fCurrent = fControl;
sMon.fPreset = self->pDriv->fPreset;
sMon.pName = self->name;
@ -251,6 +257,14 @@
self->iCallbackCounter++;
}
self->pDriv->fLastCurrent = fControl;
/*
notification on finish
*/
if(eCt == HWIdle)
{
InvokeCallBack(self->pCall,COUNTEND,NULL);
}
return eCt;
}
/*------------------------------------------------------------------------*/

34
doc/manager/helpman.htm Normal file
View File

@ -0,0 +1,34 @@
<HTML>
<HEAD>
<TITLE>The SICS Online Help System</TITLE>
</HEAD>
<BODY>
<H1>The SICS Online Help System</H1>
<P>
SICS has a simple built in help system. Help text is stored in simple
ASCII text files which are printed to the client on demand. The help
system can search for help files in several directories. Typically one
would want one directory with general SICS help files and another one
with instrument specific help files. If help is invoked without any
options, a default help file is printed. This file is supposed to
contain a directory of available help topics together with a brief
description. The normal usage is: help topicname . The help system
will then search for a file named topicname.txt in its help
directories.
</P>
<p>
A SICS manager will need to configure this help system. A new
directory can be added to the list of directories to search with the
command:
<pre>
help configure adddir dirname
</pre>
The default help file can be specified with:
<pre>
help configure defaultfile filename
</pre>
Each of these command given without a parameter print the current
settings.
</P>
</BODY>
</HTML>

View File

@ -19,6 +19,7 @@ Go to:
<li> A discussion of SICS <a href = var.htm> variables</a>.
<li> Advice about <a href=hwini.htm> hardware </a> configuration.
<li> A description of <a href = command.htm> command </a> initialisation.
<li> Managing the SICS <a href="helpman.htm"> help </a> system.
</ul>
</p>
<!latex-on>

View File

@ -46,6 +46,7 @@ which is described elsewhere.
%html var.htm 1
%html hwini.htm 1
%html command.htm 1
%html helpman.htm 2
%html special.htm 1
%html serial.htm 2
%html status.htm 2
@ -54,6 +55,8 @@ which is described elsewhere.
%html alias.htm 2
%html cron.htm 2
%html rs232.htm 2
%html nxscript.htm 2
%html nxupdate.htm 2
%html ../user/trouble.htm 1
%html move.htm 1
\end{document}

71
doc/manager/nxupdate.htm Normal file
View File

@ -0,0 +1,71 @@
<HTML>
<HEAD>
<TITLE>Automatic Updating of NeXus Files</TITLE>
</HEAD>
<BODY>
<H1>Automatic Updating of NeXus Files</H1>
<P>
Some instruments perform measurements for quite long counting
times. In such cases it is advisable to save the data measured so far
to file in order to protect against hardware or software failures. To
this purpose an automatic file upgrade manager is provided. On
installation the automatic update object is connected wth a counting
device through the the callback interface. This makes sure that the
update manager is automatically notified when counting starts or
finishes.
</P>
<h2>Prerequisites for Using the Automatic Update Manager</h2>
<p>
In order to use automatic updating, three programs must be
provided. Each of these programs can be a script which uses the
nxscript facility. It can also be a SICS command.
<dl>
<dt>startScript
<dd>This program is supposed to write the static part of the file. It
is called once when the file is created.
<dt>updateScript
<dd>This program is supposed to create and update the variable data
elements in the NeXus file. This is called frequently.
<dt>linkScript
<dd>This program is supposed to create the links within the NeXus
file. This is called once after startcript and updateScript have been
run.
</dl>
</p>
<h2>Installing Automatic Update</h2>
<p>
An automatic update object is installed into SICS with:
<pre>
updatefactory name countername
</pre>
name is a placeholder for the name under which SICS knows the
automatic update object. name is available as a SICS command later on.
countername is a placeholder for a counter
object (counter or HM) which triggers automatic updating of NeXus
files. This object has to support both the countable and callback
interfaces of SICS. Suitable SICS objects include counter and
histogram memory objects.
</p>
<h2>Configuring Automatic Update</h2>
<p>
The SICS command created with updatefactory (see above) supports a few
parameters which allow for the configuration of the whole
process. Parameters follow the normal SICS syntax. Futhermore there is
a subcommand list, which lists all configuration
parameters. Supported parameters are:
<dl>
<dt>startScript
<dd>The program supposed to write the static part of the file.
<dt>updateScript
<dd>The program supposed to create and update the variable data
elements in the NeXus file.
<dt>linkScript
<dd>This program supposed to create the links within the NeXus
file.
<dt>updateintervall
<dd>The time intervall in seconds between updates. The defualt is
1200, eg. 20 minutes.
</dl>
</p>
</BODY>
</HTML>

View File

@ -15,6 +15,8 @@ This section describes a few commands which need not be known to SICS users.
<li> <a href="cron.htm">Reoccuring tasks</a>.
<li> Direct access to <a href="rs232.htm">RS232 controllers</a> through
the terminal server.
<li>Scripting the content of<a href="nxscript.htm"> NeXus</a> files.
<li>Automatic <a href="nxupdate.htm">update</a> of files during long counting operations.
</uL>
<!latex-on>
</P>

View File

@ -10,7 +10,7 @@ This object implements this complex movement as a virtual motor.
The following formulas are used for the necessary calculations:
\begin{eqnarray}
delta height & = & h_{s} - R \sin \alpha \\
delta height & = & h_{s} - \sin \alpha \\
delta x & = & |x_{c} - x_{s}| - R \cos \alpha \\
omega & = & -2 MOM + 2 SOM \\
\end{eqnarray}
@ -18,7 +18,7 @@ with
\begin{eqnarray}
h_{s} & = & \tan(2MOM)|x_{c} - x_{s}| \\
R & = & \sqrt{hs^{2} - |x_{c} - x_{s}|^{2}} \\
\alpha & = & 180 -90 - \beta - 2SOM \\
\alpha & = & ATT - 2SOM \\
\beta & = & 180 - 90 - 2MOM \\
MOM & = & polarizer \omega \\
SOM & = & sample \omega \\
@ -141,6 +141,34 @@ $\langle$amorinterface {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@@\\
\mbox{}\verb@ Mark Koennecke, September 1999@\\
\mbox{}\verb@----------------------------------------------------------------------------*/@\\
\mbox{}\verb@@\\
\mbox{}\verb@/* distance detector sample */@\\
\mbox{}\verb@#define PARDS 0@\\
\mbox{}\verb@/* constant height of sample: height = PARDH + MOTSOZ + MOTSTZ */@\\
\mbox{}\verb@#define PARDH 1@\\
\mbox{}\verb@/* distance diaphragm 4 - sample */@\\
\mbox{}\verb@#define PARDD4 2@\\
\mbox{}\verb@/* distance to diaphragm 5 */@\\
\mbox{}\verb@#define PARDD5 3@\\
\mbox{}\verb@/* interrupt to issue when a motor fails on this */@\\
\mbox{}\verb@#define PARINT 4@\\
\mbox{}\verb@/* base height of counter station */@\\
\mbox{}\verb@#define PARDDH 5@\\
\mbox{}\verb@/* height of D4 */@\\
\mbox{}\verb@#define PARD4H 6@\\
\mbox{}\verb@/* height of D5 */@\\
\mbox{}\verb@#define PARD5H 7@\\
\mbox{}\verb@/* base height of analyzer */@\\
\mbox{}\verb@#define PARANA 8@\\
\mbox{}\verb@/* distance of analyzer from sample */@\\
\mbox{}\verb@#define PARADIS 9@\\
\mbox{}\verb@/* flag analyzer calculation on/off */@\\
\mbox{}\verb@#define ANAFLAG 10@\\
\mbox{}\verb@/* constant for second detector */@\\
\mbox{}\verb@#define PARDDD 11@\\
\mbox{}\verb@/* constant part of AOM */@\\
\mbox{}\verb@#define PARAOM 12@\\
\mbox{}\verb@@\\
\mbox{}\verb@@$\langle$putput {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@@$\langle$amoredata {\footnotesize ?}$\rangle$\verb@@\\

View File

@ -105,7 +105,7 @@ the error can be ignored or was fully resolved.
\item[pParList] is text string containing a comma separated list of
all parameters understood by this driver.
\item[pPrivate] Is a pointer to a driver specific specific data
structure. This data structure will not be messed with by upper level code.
structure. This data structure shall not be messed with by upper level code.
\end{description}
\subsubsection{The Controller Object}

View File

@ -212,6 +212,29 @@ take care of invoking the apropriate commands on all registered counting
devices.
\subsubsection{Locking the Device Executor}
In some instances user code may wish to lock the device executor. An
example is a long running data saving operation. In order to do this
two functions are provided:
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap4}
$\langle$devlock {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@ void LockDeviceExecutor(pExeList self);@\\
\mbox{}\verb@ void UnlockDeviceExecutor(pExeList self);@\\
\mbox{}\verb@@\\
\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}
\subsubsection{The Rest}
The rest of the interface includes initialisation and deletion routines
and some access routines. With the devexec being such an important system
@ -219,7 +242,7 @@ component a function {\bf GetExecutor} is provided which retrieves a pointer
to the global SICS device executor.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap4}
\begin{minipage}{\linewidth} \label{scrap5}
\verb@"devexec.h"@ {\footnotesize ? }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
@ -308,7 +331,8 @@ to the global SICS device executor.
\mbox{}\verb@ connection with non blocking operation such as motors started@\\
\mbox{}\verb@ with run.@\\
\mbox{}\verb@ */@\\
\mbox{}\verb@ @\\
\mbox{}\verb@/*--------------------------- Locking ---------------------------------*/@\\
\mbox{}\verb@ @$\langle$devlock {\footnotesize ?}$\rangle$\verb@ @\\
\mbox{}\verb@/* -------------------------- Executor management -------------------------*/@\\
\mbox{}\verb@ @\\
\mbox{}\verb@ pExeList GetExecutor(void);@\\

View File

@ -36,10 +36,16 @@ $\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;@\\
\mbox{}\verb@ time_t start;@\\
\mbox{}\verb@ time_t lastt;@\\
\mbox{}\verb@ char *pName;@\\
\mbox{}\verb@ char *driverName;@\\
\mbox{}\verb@ char *errorScript;@\\
\mbox{}\verb@ ObPar *pParam;@\\
\mbox{}\verb@ int iLog;@\\
\mbox{}\verb@ pVarLog pLog;@\\
@ -63,11 +69,17 @@ 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
controller. Then there is a
device. start and lastt are used to control the settling time.
pName is a pointer to a string representing the name of the
controller. driverName is the name of the driver used by this
device. errorScript is the name of a script command to run when the
controller goes out of tolerance.
Then there is a
parameter array. iLog is a boolean which says if data should be logged
for this controller or not. pLog is the a pointer to a Varlog structure
holding the logging information. Then there is a switch, iWarned, which is
@ -91,6 +103,8 @@ $\langle$evdriv {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ typedef struct __EVDriver {@\\
\mbox{}\verb@ int (*SetValue)(pEVDriver self, float fNew);@\\
\mbox{}\verb@ int (*GetValue)(pEVDriver self, float *fPos);@\\
\mbox{}\verb@ int (*GetValues)(pEVDriver self, float *fTarget,@\\
\mbox{}\verb@ float *fPos, float *fDelta);@\\
\mbox{}\verb@ int (*Send)(pEVDriver self, char *pCommand,@\\
\mbox{}\verb@ char *pReplyBuffer, int iReplBufLen); @\\
\mbox{}\verb@ int (*GetError)(pEVDriver self, int *iCode,@\\
@ -287,6 +301,8 @@ See the documentation for commands understood.
\mbox{}\verb@#define UPLIMIT 4@\\
\mbox{}\verb@#define LOWLIMIT 5@\\
\mbox{}\verb@#define SAFEVALUE 6@\\
\mbox{}\verb@#define MAXWAIT 7@\\
\mbox{}\verb@#define SETTLE 8@\\
\mbox{}\verb@@\\
\mbox{}\verb@@$\langle$evdata {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@@$\diamond$

View File

@ -17,7 +17,9 @@ $\langle$Modes {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ eHNormal,@\\
\mbox{}\verb@ eHTOF,@\\
\mbox{}\verb@ eHStrobo,@\\
\mbox{}\verb@ eHRPT@\\
\mbox{}\verb@ eHRPT,@\\
\mbox{}\verb@ ePSD,@\\
\mbox{}\verb@ eSANSTOF@\\
\mbox{}\verb@ } HistMode;@\\
\mbox{}\verb@@$\diamond$
\end{list}
@ -29,6 +31,7 @@ $\langle$Modes {\footnotesize ?}$\rangle\equiv$
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
These modes are specific to the SINQ histogram memory.
A histogram memory can be operated in transparent mode. It has not yet been
defined what this means but it is sort of storing raw data from the detector
without any summing or processing. Normal mode is better defined, this is
@ -99,6 +102,11 @@ command. Then on initialisation first the logical histogram memory
evaluates the general options and then the driver in its Config
function evaluates the driver specific options.
The histogram memory supports several dimensions, a time binning
option and optional buffering of histogram memory data read from the
actual HM. All this data management stuff is handled in a separate
class, HMdata. See the documentation for HMdata for more details.
\subsubsection{The Histogram memory driver}
Adhering to the Sics paradigm of dividing any device into a logical device
@ -113,16 +121,7 @@ $\langle$HistType {\footnotesize ?}$\rangle\equiv$
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@ typedef struct __HistDriver {@\\
\mbox{}\verb@ /* configuration data */@\\
\mbox{}\verb@ HistMode eHistMode;@\\
\mbox{}\verb@ OverFlowMode eFlow;@\\
\mbox{}\verb@ int iRank;@\\
\mbox{}\verb@ int iDims[MAXDIM];@\\
\mbox{}\verb@ int nDim;@\\
\mbox{}\verb@ int iLength;@\\
\mbox{}\verb@ int iBinWidth;@\\
\mbox{}\verb@ float fTime[MAXCHAN];@\\
\mbox{}\verb@ int iTimeChan;@\\
\mbox{}\verb@ pHMdata data;@\\
\mbox{}\verb@ /* counting operations data */@\\
\mbox{}\verb@ CounterMode eCount;@\\
\mbox{}\verb@ float fCountPreset;@\\
@ -183,15 +182,6 @@ $\langle$HistType {\footnotesize ?}$\rangle\equiv$
\end{minipage}\\[4ex]
\end{flushleft}
Quite a lot, but a histogram memory is quite a complex piece of equipment.
The configuration information is in the elements EhistMode, eOverFlowMode,
iRank, iDims and iBinWidth fields. iDim and nDim desribe the logical
dimensions of the histogram memory. These may be different from the
dimensions used for data transfer. For instance the SANS detector is
handled internally as 1600+ numbers where it really is a filed o
128*128.
Additionally there is an array of
floating point values which denote the time binning for time-o-flight
operation or the stroboscopic binning axis in stroboscopic mode.
The fields fPreset and CounterMode hold the counting parameter data.
@ -324,11 +314,6 @@ $\langle$HistST {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ pICountable pCountInt;@\\
\mbox{}\verb@ pICallBack pCall;@\\
\mbox{}\verb@ pStringDict pOption;@\\
\mbox{}\verb@ HistInt *iLocalData;@\\
\mbox{}\verb@ int iLocalLength;@\\
\mbox{}\verb@ int iLocalUpdate;@\\
\mbox{}\verb@ time_t tLocal;@\\
\mbox{}\verb@ int iUpdateIntervall;@\\
\mbox{}\verb@ } HistMem;@\\
\mbox{}\verb@@$\diamond$
\end{list}
@ -451,6 +436,7 @@ $\langle$Protos {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ float GetHistCountTime(pHistMem self,SConnection *pCon);@\\
\mbox{}\verb@ int HistDoCount(pHistMem self, SConnection *pCon);@\\
\mbox{}\verb@ int HistBlockCount(pHistMem self, SConnection *pCon);@\\
\mbox{}\verb@ void HistDirty(pHistMem self); @\\
\mbox{}\verb@@\\
\mbox{}\verb@@$\diamond$
\end{list}
@ -488,6 +474,9 @@ $\langle$Protos {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ int GetHistogram(pHistMem self, SConnection *pCon,@\\
\mbox{}\verb@ int i,int iStart, int iEnd, HistInt *lData, int iDataLen);@\\
\mbox{}\verb@ HistInt *GetHistogramPointer(pHistMem self,SConnection *pCon);@\\
\mbox{}\verb@ int GetHistogramDirect(pHistMem self, SConnection *pCon,@\\
\mbox{}\verb@ int i, int iStart, int iEnd, @\\
\mbox{}\verb@ HistInt *lData, int iDataLen);@\\
\mbox{}\verb@ int PresetHistogram(pHistMem self, SConnection *pCon, HistInt lVal);@\\
\mbox{}\verb@@$\diamond$
\end{list}
@ -514,6 +503,11 @@ initialises the HM from the lData provided. GetHistogram reads an histogram
into lData but maximum iDataLen items. PresetHistogram presets the HM to the
value lVal. Can be used to clear the HM.
GetHistogram and GetHistogramPointer try to buffer the data when
possible and configured. The configuration happens through the
definition of an update intervall. GetHistogramDirect never buffers
but goes for the histogram memory directly.
The histogram memory object buffers the histograms for a adjustable
period of time. GetHistogramPointer retrieves a pointer to the local
histogram buffer. It also makes sure, that the histogram has been
@ -620,7 +614,7 @@ following.
\mbox{}\verb@----------------------------------------------------------------------------*/@\\
\mbox{}\verb@#ifndef SICSHISTDRIV@\\
\mbox{}\verb@#define SICSHISTDRIV@\\
\mbox{}\verb@#define MAXCHAN 4096@\\
\mbox{}\verb@#include "hmdata.h"@\\
\mbox{}\verb@@\\
\mbox{}\verb@@$\langle$HistType {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@@$\langle$HistDrivProt {\footnotesize ?}$\rangle$\verb@@\\

View File

@ -24,6 +24,7 @@ $\langle$hkldat {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ double fLastHKL[5];@\\
\mbox{}\verb@ int iNOR;@\\
\mbox{}\verb@ int iQuad;@\\
\mbox{}\verb@ int iHM;@\\
\mbox{}\verb@ pMotor pTheta;@\\
\mbox{}\verb@ pMotor pOmega;@\\
\mbox{}\verb@ pMotor pChi;@\\
@ -51,6 +52,8 @@ The fields are more or less self explaining:
or is updated automatically from a wavelength variable.
\item[fLastHKL] the HKL of the last reflection calculated.
\item[iNor] a flag for normal beam calculation mode.
\item[iHM] a flag for histogram memory mode. In this mode two theta
limits are checked alos for detector 2 and 3.
\item[pTheta] The two theta motor. All motor are needed for boundary
checking.
\item[pOmega] The omega axis motor.

View File

@ -60,6 +60,7 @@ $\langle$obdes {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ /*---------------------------------------------------------------------------*/@\\
\mbox{}\verb@ pObjectDescriptor CreateDescriptor(char *name);@\\
\mbox{}\verb@ void DeleteDescriptor(pObjectDescriptor self);@\\
\mbox{}\verb@ pObjectDescriptor FindDescriptor(void *pData);@\\
\mbox{}\verb@ @\\
\mbox{}\verb@/*============================================================================@\\
\mbox{}\verb@ Objects which do not carry data need a dummy descriptor. Otherwise@\\
@ -207,6 +208,8 @@ $\langle$count {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ typedef struct {@\\
\mbox{}\verb@ int ID;@\\
\mbox{}\verb@ int (*Halt)(void *self);@\\
\mbox{}\verb@ void (*SetCountParameters)(void *self, float fPreset,@\\
\mbox{}\verb@ CounterMode eMode);\@\\
\mbox{}\verb@ int (*StartCount)(void *self, SConnection *pCon);@\\
\mbox{}\verb@ int (*CheckCountStatus)(void *self, SConnection *pCon);@\\
\mbox{}\verb@ int (*Pause)(void *self, SConnection *pCon);@\\
@ -313,6 +316,11 @@ $\langle$cifunc {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ void *pUserData, KillFuncIT pKill);@\\
\mbox{}\verb@ int RemoveCallback(pICallBack pInterface, long iID);@\\
\mbox{}\verb@ int RemoveCallback2(pICallBack pInterface, void *pUserData);@\\
\mbox{}\verb@@\\
\mbox{}\verb@ int CallbackScript(SConnection *pCon, SicsInterp *pSics, void *pData,@\\
\mbox{}\verb@ int argc, char *argv[]); @\\
\mbox{}\verb@@\\
\mbox{}\verb@ pICallBack GetCallbackInterface(void *pData); @\\
\mbox{}\verb@@$\diamond$
\end{list}
\vspace{-1ex}
@ -360,8 +368,16 @@ RegisterCallBack.
search key for deletion is the pointer to user data. All callbacks related
to this user data in the interface specified will be removed.
{\bf CallbackScript} allows to connect callbacks to scripts. Please
note, that those scripts will have a dummy connection to clients only
and will not be able to write to clients. All output occurring in
these scripts will be directed to stdout though, in order to support
debugging.
All these functions are implemented in the file callback.c.
\subsubsection{The Environment Interface}
This interface is used by the environment monitor in order to monitor
the status of a environment controller. The interface looks like this:

View File

@ -18,6 +18,7 @@ $\langle$servdat {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ pEnvMon pMonitor;@\\
\mbox{}\verb@ mkChannel *pServerPort;@\\
\mbox{}\verb@ pNetRead pReader;@\\
\mbox{}\verb@ int simMode;@\\
\mbox{}\verb@ } SicsServer;@\\
\mbox{}\verb@@$\diamond$
\end{list}
@ -40,6 +41,8 @@ This module monitors sample environment controllers.
the SICS server is listening for connections.
\item[pReader] points to a data structure which defines the network
communication object.
\item[simMode] a flag which is true when the SICS server is a simulation
server.
\end{description}

View File

@ -60,6 +60,8 @@ time-of-flight mode.
\mbox{}\verb@----------------------------------------------------------------------*/@\\
\mbox{}\verb@#ifndef NXAMOR@\\
\mbox{}\verb@#define NXAMOR@\\
\mbox{}\verb@#include <scan.h>@\\
\mbox{}\verb@#include <HistMem.h>@\\
\mbox{}\verb@@$\langle$namor {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@#endif@\\
\mbox{}\verb@@$\diamond$

View File

@ -194,7 +194,7 @@ NexUs API which holds the dictionary information within a NeXus file.
One additional data type is needed for this API:
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap1}
$\langle$tata {\footnotesize 4a}$\rangle\equiv$
$\langle$tata {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
@ -213,7 +213,7 @@ NXdict will be used as a handle for the dictionary currently in use.
\subsubsection{Dictionary Maintainance Function}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap2}
$\langle$dicman {\footnotesize 4b}$\rangle\equiv$
$\langle$dicman {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
@ -264,7 +264,7 @@ $\langle$dicman {\footnotesize 4b}$\rangle\equiv$
\subsubsection{Data Handling functions}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap3}
$\langle$dicdata {\footnotesize 5}$\rangle\equiv$
$\langle$dicdata {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
@ -347,7 +347,7 @@ The NXDICT data handling functions go in pairs. The version ending in
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap4}
$\langle$dicutil {\footnotesize 6}$\rangle\equiv$
$\langle$dicutil {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
@ -411,7 +411,7 @@ the current approach poses a serious performance problem.
Thus, the NXdict data structure looks like this:
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap5}
$\langle$dicdat {\footnotesize 7}$\rangle\equiv$
$\langle$dicdat {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
@ -1155,7 +1155,7 @@ $\langle$deftok {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ {"-type",DTYPE},@\\
\mbox{}\verb@ {"-rank",DRANK},@\\
\mbox{}\verb@ {"-attr",DATTR},@\\
\mbox{}\verb@ {NULL,0} };@\\
\mbox{}\verb@ {"",0} };@\\
\mbox{}\verb@@\\
\mbox{}\verb@/*-----------------------------------------------------------------------*/@\\
\mbox{}\verb@ static void NXDIDefToken(ParDat *sStat)@\\
@ -1543,7 +1543,7 @@ $\langle$nxpasds {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ iRank = atoi(pParse->pToken);@\\
\mbox{}\verb@ break;@\\
\mbox{}\verb@ case DDIM:@\\
\mbox{}\verb@ iRet = NXDIParseDim(pParse, iDim);@\\
\mbox{}\verb@ iRet = NXDIParseDim (pParse, (int *) iDim);@\\
\mbox{}\verb@ if(iRet == NX_ERROR)@\\
\mbox{}\verb@ {@\\
\mbox{}\verb@ LLDdelete(iList);@\\
@ -1599,7 +1599,7 @@ $\langle$nxpasds {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ /* we need to create it, if we may */@\\
\mbox{}\verb@ if(pParse->iMayCreate)@\\
\mbox{}\verb@ {@\\
\mbox{}\verb@ iRet = NXmakedata(hfil,pName,iType, iRank,iDim);@\\
\mbox{}\verb@ iRet = NXmakedata (hfil, pName, iType, iRank, (int *) iDim);@\\
\mbox{}\verb@ if(iRet != NX_OK)@\\
\mbox{}\verb@ { @\\
\mbox{}\verb@ /* a comment on this one has already been written! */@\\
@ -1669,7 +1669,7 @@ $\langle$parsetype {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ {"DFNT_UINT16",DFNT_UINT16},@\\
\mbox{}\verb@ {"DFNT_INT32",DFNT_INT32},@\\
\mbox{}\verb@ {"DFNT_UINT32",DFNT_UINT32},@\\
\mbox{}\verb@ {NULL,-122} };@\\
\mbox{}\verb@ {"",0} };@\\
\mbox{}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@@\\
@ -2737,15 +2737,15 @@ $\langle$free {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@#include "napi.h" /* make sure, napi is included */@\\
\mbox{}\verb@@\\
\mbox{}\verb@/*-------------------- NXDict data types & defines ----------------------*/@\\
\mbox{}\verb@@$\langle$tata {\footnotesize 4a}$\rangle$\verb@@\\
\mbox{}\verb@@$\langle$tata {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@#define NXquiet 0@\\
\mbox{}\verb@#define NXalot 1@\\
\mbox{}\verb@/*-------------------- Dictionary Maintainance ----------------------------*/@\\
\mbox{}\verb@@$\langle$dicman {\footnotesize 4b}$\rangle$\verb@@\\
\mbox{}\verb@@$\langle$dicman {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@/*----------------- Dictionary added data transfer -----------------------*/ @\\
\mbox{}\verb@@$\langle$dicdata {\footnotesize 5}$\rangle$\verb@@\\
\mbox{}\verb@@$\langle$dicdata {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@/*-------------------- Utility Functions --------------------------------*/@\\
\mbox{}\verb@@$\langle$dicutil {\footnotesize 6}$\rangle$\verb@@\\
\mbox{}\verb@@$\langle$dicutil {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@#endif@\\
\mbox{}\verb@@$\diamond$
\end{list}
@ -2804,7 +2804,7 @@ $\langle$free {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ dictionaries.@\\
\mbox{}\verb@*/@\\
\mbox{}\verb@/*-------------------------------------------------------------------------*/@\\
\mbox{}\verb@@$\langle$dicdat {\footnotesize 7}$\rangle$\verb@@\\
\mbox{}\verb@@$\langle$dicdat {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@/*-------------------------------------------------------------------------*/@\\
\mbox{}\verb@ static char *NXDIReadFile(FILE *fd)@\\
\mbox{}\verb@ {@\\

View File

@ -50,6 +50,7 @@ $\langle$pimoti {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@----------------------------------------------------------------------------*/@\\
\mbox{}\verb@#ifndef PIMOTOR@\\
\mbox{}\verb@#define PIMOTOR@\\
\mbox{}\verb@#include <motor.h>@\\
\mbox{}\verb@@$\langle$pimoti {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@#endif@\\
\mbox{}\verb@@\\

View File

@ -87,6 +87,7 @@ There are two sections: Building the SICS applications and building the Java
The first step is to untar the sics.tar file. As a result a directory sics
with several subdirectories will be created. These subdirectories are:
\begin{description}
\item[psi]PSI specific commands and code.
\item[hardsup] contains David Madens and other hardware drivers.
\item[motor] contains the unix version of David Madens el734\_test program.
\item[doc/programmer]holds programming documentation for SICS.
@ -95,7 +96,9 @@ The first step is to untar the sics.tar file. As a result a directory sics
\item[bin] Holds the final binary files.
\item[tcl] Some Tcl helper code.
\item[doc/manager]The SICS managers documentation.
\item[difrac] The DIFRAC four circle diffraction subsystem.
\item[difrac] The DIFRAC four circle diffraction subsystem. This is
not used anymore.
\item[matrix] A matrix manipulation package.
\end{description}
For most programs makefiles are provided.
Makefiles may need a little editing to correct the location of libraries.
@ -134,6 +137,8 @@ Again the first step is the untaring of tha java.tar file. This creates a
\item[spread] Another layout manager package.
\item[topsi] The topsi and general scan status display.
\item[amor] The AMOR user interface program.
\item[tas] The Triple Axis user interface program.
\item[trics] The TRICS user interface program.
\end{description}
Furthermore there are some Java source file in the main directory together
with some htm files and makefiles. For each of the Java clients a makefile
@ -149,11 +154,11 @@ Furthermore there are some Java source file in the main directory together
\item[Jar-File] make -f make.powder jar
\end{description}
\section{Kernel Objects and Modules}
This section describes the modules defining the SICS kernel.
\include{task}
\include{nserver}
\include{site}
\include{ini}
\include{passwd}
\include{network}
@ -171,6 +176,9 @@ This section describes the modules defining the SICS kernel.
\include{interrupt}
\include{ofac}
\include{servlog}
\include{help}
\include{Busy}
\include{hmcontrol}
\subsection{The commandlog}
This is yet another logging facility of SICS. The idea is that all I/O
going to connections with user or manager level rights is logged.
@ -187,6 +195,7 @@ writing to it. The rest is implemented as file statics in commandlog.c.
This section describes the SICS objects implementing commands and objects
common to all SICS instruments.
\include{scan}
\include{userscan}
\include{center}
\include{danu}
\include{drive}
@ -202,6 +211,13 @@ common to all SICS instruments.
\include{token}
\include{udpquieck}
\include{xytable}
\include{lin2ang}
\include{lomax}
\include{nxscript}
\include{nxupdate}
\include{sicsdata}
\include{simsync}
\include{anticollider}
\section{SICS Hardware Objects}
This section deals with objects and modules representing instrument
@ -228,24 +244,31 @@ right as utility functions. However, the preferred and supported way of
accessing SICS hardware objects is through the interface functions.
\include{velo}
\include{velodorn}
\include{evcontroller}
\include{itc4}
\include{bruker}
\include{tclev}
\include{evdrivers}
\include{motor}
\include{pimotor}
\include{counter}
\include{hmdata}
\include{histogram}
\include{sinqhmdriv}
\include{histsim}
\include{choco}
\include{switchedmotor}
\include{tcldriveable}
\include{rs232controller}
\include{gpib}
\section{PSI Specific Hardware}
\include{velodorn}
\include{itc4}
\include{bruker}
\include{pimotor}
\include{sinqhmdriv}
\include{serial}
\include{serialwait}
\include{sps}
\include{frame}
\include{ecb}
\section{Powder Diffraction Specific Objects}
\include{dmc}
@ -275,6 +298,9 @@ The files nxsans.h and nxsans.c implement the NeXus writing functions for SANS.
\include{tricsnex}
\include{difrac}
\section{Triple Axis Specific Code}
\include{tas}
\section{Helper Objects}
This section describes helper objects which implement useful data
structures or utilities.

View File

@ -66,6 +66,7 @@ $\langle$scandata {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ SConnection *pCon;@\\
\mbox{}\verb@ char pRecover[1024];@\\
\mbox{}\verb@ char pHeaderFile[1024];@\\
\mbox{}\verb@ int (*PrepareScan)(pScanData self);@\\
\mbox{}\verb@ int (*WriteHeader)(pScanData self);@\\
\mbox{}\verb@ int (*WriteScanPoints)@\\
\mbox{}\verb@ (pScanData self, @\\
@ -78,6 +79,7 @@ $\langle$scandata {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ (pScanData self,@\\
\mbox{}\verb@ int iP);@\\
\mbox{}\verb@ long lPos;@\\
\mbox{}\verb@ int posSoft;@\\
\mbox{}\verb@ void *pCounterData;@\\
\mbox{}\verb@ char pCounterName[512];@\\
\mbox{}\verb@ int iChannel;@\\
@ -140,6 +142,9 @@ line is permitted.
finding data.
\item[pCon] The connection object to use for error reporting during scan
execution.
\item[PrepareScan] checks limits of scan variables and memorizes
important scan information. Sometimes this is not wanted, that is why
it is parametrized here.
\item[WriteHeader] is a pointer to a function which writes the header part
of the scan file. Replace this function if another data format is needed.
\item[WriteScanPoints] is a pointer to a function which will be called after
@ -154,22 +159,24 @@ This function together with ScanDrive and the data writing functions allow for
\item[CollectScanData] reads all the scan data into the scan's data
structures after any scan point. Overload this if a different storage
scheme is required especiallay for polarising scans.
\item[posSoft] is a flag which is true if scan variable are stored with
soft position, i.e. with zeropoints applied.
\item[pCounterData] is a pointer to a counter structure. This defines the
counter to use and is initialized at creation of the scan data structure.
\item[pCountername] is the name of the counter used.
\item[iChannel] is the channel to use for counting. 0 is the main counter,
everything baove one of the monitors.
everything above one of the monitors.
\item[pCount, iCounts] is a dynamic array containing iCounts sets of
counting infomation. For each scan point this array holds the counts
measured. iCounts is also the current scan position.
\item[iWindow] the width of the window used for peak integration. See
integrate.w,c for more details.
\item[pCommand] It turned out that a way is needed to define user defined
speciality scans. This is implemented by setting the channel number to -10
and then have the scan command execute a Tcl script for each scan point.
This Tcl script has to return a Tcl list containing the values to enter for
counter and monitor for the scan point. pCommand now is the name of the
Tcl procedure to invoke.
speciality scans, especially for those magnetic polarized guys. The way
it is done is that scan has to be configured user. In this mode, ScanCount
will call a script which does everything necessary at the scan point,
including adding data to the data file. pCommand now holds the name of
the script to invoke.
\item[pSpecial] Usually NULL. A entry which allows customized scans to keep
some additional data in the scan data structure.
\end{description}
@ -206,6 +213,7 @@ $\langle$scaninter {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ char *pName, int iLength);@\\
\mbox{}\verb@ int GetScanVarStep(pScanData self, int iWhich, @\\
\mbox{}\verb@ float *fStep);@\\
\mbox{}\verb@ int isScanVarSoft(pScanData self);@\\
\mbox{}\verb@ int GetScanMonitor(pScanData self, int iWhich, @\\
\mbox{}\verb@ long *lData, int iDataLen);@\\
\mbox{}\verb@ int GetScanNP(pScanData self);@\\
@ -221,7 +229,23 @@ $\langle$scaninter {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ /*@\\
\mbox{}\verb@ resets the configurable scan functions to their default values.@\\
\mbox{}\verb@ */@\\
\mbox{}\verb@@\\
\mbox{}\verb@ int NonCheckPrepare(pScanData self);@\\
\mbox{}\verb@ /*@\\
\mbox{}\verb@ a function for the PrepareScan field in the scan data structure@\\
\mbox{}\verb@ which does not check the boundaries of the scan as the default@\\
\mbox{}\verb@ PrepareScan does.@\\
\mbox{}\verb@ */@\\
\mbox{}\verb@ int AppendScanLine(pScanData self, char *line);@\\
\mbox{}\verb@ /*@\\
\mbox{}\verb@ AppendScanLine appends a line to the scan data file. When finished@\\
\mbox{}\verb@ it updates the position pointer in the file to point behind the@\\
\mbox{}\verb@ added line. @\\
\mbox{}\verb@ */@\\
\mbox{}\verb@ int StoreScanCounts(pScanData self, char *data);@\\
\mbox{}\verb@ /*@\\
\mbox{}\verb@ parses the numbers in data and stores them as the count and@\\
\mbox{}\verb@ monitor data for the current scan point.@\\
\mbox{}\verb@ */ @\\
\mbox{}\verb@/*------------------------ Interpreter Interface --------------------------*/@\\
\mbox{}\verb@ int ScanFactory(SConnection *pCon, SicsInterp *pSics, void *pData,@\\
\mbox{}\verb@ int argc, char *argv[]);@\\
@ -279,6 +303,17 @@ summed counts and the variance. See the section on integrate for more
details.
\item[ResetScanFunctions] reinstalls the default functions for scan
processing into the ScanData structure.
\item[NonCheckPrepare] Before a scan is started, various data
structures in the scan object are initialized. Thereby the scan
boundaries are checked against the motor limits. For some scans this
is not feasible. This version omits this check and must be entered as
the PrepareScan function field in the scan data structure by code
using the scan module.
\item[AppendScanLine] appends a line to the scan file. This is useful
for user configured scans, for instance in polarisation mode.
\item[StoreScanCounts] parses the data given in data and stores the
numbers as count values as the count data for the current scan point.
Another feature for supporting user configurable scans.
\item[SimScan] creates a simulated gaussian peak with the given
parameters. Used for debugging several things.
\item[ScanFactory] is the SICS interpreter object creation function

View File

@ -30,6 +30,10 @@ $\langle$SQType {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ pSINQHM pMaster;@\\
\mbox{}\verb@ int iLastHMError;@\\
\mbox{}\verb@ int iLastCTError;@\\
\mbox{}\verb@ HistMode eHistMode;@\\
\mbox{}\verb@ int iBinWidth;@\\
\mbox{}\verb@ OverFlowMode eFlow;@\\
\mbox{}\verb@ int extraDetector;@\\
\mbox{}\verb@ } SinqHMDriv;@\\
\mbox{}\verb@@$\diamond$
\end{list}
@ -59,7 +63,10 @@ The driver implements all the functions specified in the driver interface.
Please note that these contain functions for the deletion of driver private
data structures which will be automatically called form DeleteHistDriver.
Therefore the only function to define is CreateSINQDriver which sets things
up.
up. Another function is isSINQHMDriv which tests if the driver given as an
argument actually is a SINQHM driver. This is currently only used in
amorstat.c which has to circumvent normal SICS mechanisms for performance
reasons.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap2}
@ -68,6 +75,7 @@ $\langle$Protos {\footnotesize ?}$\rangle\equiv$
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@ pHistDriver CreateSINQDriver(pStringDict pOption);@\\
\mbox{}\verb@ int isSINQHMDriv(pHistDriver test);@\\
\mbox{}\verb@@$\diamond$
\end{list}
\vspace{-1ex}
@ -94,7 +102,7 @@ $\langle$Protos {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@----------------------------------------------------------------------------*/@\\
\mbox{}\verb@#ifndef SINQHMDRIVER@\\
\mbox{}\verb@#define SINQHMDRIVER@\\
\mbox{}\verb@@\\
\mbox{}\verb@#include "hardsup/sinqhm.h"@\\
\mbox{}\verb@@$\langle$SQType {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@/*-------------------------------------------------------------------------*/@\\
\mbox{}\verb@@$\langle$Protos {\footnotesize ?}$\rangle$\verb@@\\

View File

@ -1,129 +1,143 @@
\chapter{Site Adaptions}\label{site}
Any new site adapting SICS will have different hardware and thus
require different drivers. Moreover additional commands may need to be
added in order to support special hardware, instrument specific
computations or status displays and local usage patterns. In order to
separate such site specific code from the SICS kernel, the site data
structure was conceived. Any new site is supposed to create a library
which provides site specific code and the site data structure which
allows SICS to locate the code. A site data structure can be retrieved
using:
\begin{verbatim}
pSite getSite(void);
\end{verbatim}
The site data structure is meant to be a singleton. It is a site's
programmers task to provide an implementation of getSite which returns
a nice site structure.
\subsubsection{Site Abstraction Layer}
With ANSTO using SICS as well it became necessary to separate the
general parts of SICS from the installation specific components. Each
installation will have a separate set of drivers and, to some
extent, instrument specific commands. Such code has to be in a
separate library. Access to this library is through an interface which
consists of a structure containing pointers to functions which allow
for the creation of site specific drivers and commands. Moreover, the
site specific library has to implement a function, getSite, which
returns the appropriate data structure for the site for which SICS is
being compiled. This data structure looks like this:
The site data structure is a structure which holds pointers to
functions. A user has to implement suitable functions along the
signatures given and assign them to this data structure.
\begin{verbatim}
typedef struct {
void (*AddSiteCommands)(SicsInterp *pSics);
void (*RemoveSiteCommands)(SicsInterp *pSics);
pMotor (*CreateMotor)(SConnection *pCon,
int argc, char *argv[]);
pCounterDriver (*CreateCounterDriver)(
SConnection *pCon,
int argc,
char *argv[]);
HistDriver *(*CreateHistogramMemoryDriver)(
char *name, pStringDict pOption);
pVelSelDriv (*CreateVelocitySelector)(char *name,
char *array, Tcl_Interp *pTcl);
pCodri (*CreateControllerDriver)(SConnection *pCon,
int argc,
char *argv[]);
pEVControl (*InstallEnvironmentController)(
SicsInterp *pSics,
SConnection *pCon,
int argc,
char *argv[]);
int (*ConfigureScan)(pScanData self,
char *option);
void (*KillSite)(void *pData);
}Site, *pSite;
\end{verbatim}
The members of this data structure:
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap1}
$\langle$sitedata {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@ typedef struct {@\\
\mbox{}\verb@ void (*AddSiteCommands)(SicsInterp *pSics);@\\
\mbox{}\verb@ void (*RemoveSiteCommands)(SicsInterp *pSics);@\\
\mbox{}\verb@ pMotor (*CreateMotor)(SConnection *pCon,@\\
\mbox{}\verb@ int argc, char *argv[]);@\\
\mbox{}\verb@ pCounterDriver (*CreateCounterDriver)(@\\
\mbox{}\verb@ SConnection *pCon,@\\
\mbox{}\verb@ int argc, @\\
\mbox{}\verb@ char *argv[]);@\\
\mbox{}\verb@ HistDriver *(*CreateHistogramMemoryDriver)(@\\
\mbox{}\verb@ char *name, pStringDict pOption);@\\
\mbox{}\verb@ pVelSelDriv (*CreateVelocitySelector)(char *name, @\\
\mbox{}\verb@ char *array, Tcl_Interp *pTcl);@\\
\mbox{}\verb@ pCodri (*CreateControllerDriver)(SConnection *pCon,@\\
\mbox{}\verb@ int argc,@\\
\mbox{}\verb@ char *argv[]);@\\
\mbox{}\verb@ pEVControl (*InstallEnvironmentController)(@\\
\mbox{}\verb@ SicsInterp *pSics,@\\
\mbox{}\verb@ SConnection *pCon,@\\
\mbox{}\verb@ int argc,@\\
\mbox{}\verb@ char *argv[]);@\\
\mbox{}\verb@ int (*ConfigureScan)(pScanData self,@\\
\mbox{}\verb@ char *option);@\\
\mbox{}\verb@ void (*KillSite)(void *pData);@\\
\mbox{}\verb@}Site, *pSite;@\\
\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{description}
\item[AddSiteCommand] adds site specific commands coded in C to the
SICS interpreter pSics.
\item[RemoveSiteCommands] removes object creation commands after SICS
has processed the instrument initialization file. See \ref{factory}
for details on the scheme.
\item[CreateMotor] creates a motor object. \verb+argv[0]+ contains the
motors name, \verb+argv[1]+ the identifier for the motor driver and
the rest of argv, argc holds further driver initialisation
parameters. Any errors in processing the arguments can be reported to
pCon. If CreateMotor can create a suitable motor object, a pointer to
it is returned, if not NULL must be returned.
\item[CreateCounterDriver] creates a driver for a counter. argc, argv
is the full array of arguments given to the MakeCounter factory
function. Of interest are: \verb+argv[1]+ the counter name,
\verb+argv[2]+, the driver identifier and the rest of the
initialization arguments. On success a pointer to
new driver is returned, on failure NULL.
\item[AddSiteCommands] adds site specific object creation and
instrument specific commands to the SICS interpreter, pSics.
\item[RemoveSiteCommands] will be called to remove surplus object
creation commands after the SICS interpreter has processed the
initialization files. Please note, that SICS does not support the
removal of objects at runtime in general. This is due to the fact that
any possible object may be used by or linked to others and and it
would be a bookeeping nightmare to keep track of all those relations.
\item[CreateMotor] creates a motor using the arguments in argc and
argv. It returns a pointer to the new motor structure on success or
NULL in case of a failure. This function has to return a complete
motor in order to allow for special configurations of the motor to
take place in its initialization.
\item[CreateCounterDriver] returns a driver for a new counter box
driver if the parameters are valid or NULL if not. Driver arguments
are in the argc, argv pair.
\item[CreateHistogramMemoryDriver] creates a driver for a histogram
memory. The driver is identified through name, the options database is
in pOptions. Histogram memory initialization follows the following
pattern:
\begin{itemize}
\item At first the raw driver is created. This code has to initializie
defaults in the options data base.
\item Then, with calls to {\em hmname configure opt val} the options
database is populated with the histogram memories configuration
options. The options database is pOptions a dictionary of name value
pairs.
\item In the last step, with {\bf hmname init} the options are parsed
and the driver is supposed to connect to the histogram memory. See
Configure in the histogram memory driver.
\end{itemize}
On success a pointer to
new driver is returned, on failure NULL.
\item[CreateVelolcitySelector] creates a driver for a velocity selector. The
driver is identified by nname, array is the name of a Tcl array in
pTcl holding initialization parameters for name.
\item[CreateControllerDriver] generates a driver for a SICS general controller
object. \verb+argv[0]+ is the driver identifier, the rest of argc,
\verb+argv[]+ are further initialization parameters. Any errors in
parsing argc, argv can be reported to pCon. On success a pointer to
new driver is returned, on failure NULL.
\item[InstallEnvironmentController] installs a sample environment
controller into pSics. \verb+argv[3]+ is the driver identifier,
\verb+argv[2]+ is the SICS name of the environment device command, the
rest are initialization parameters. This function must also install
the command into pSics with AddCommand. This is because for many PSI
environment devices special interpreter wrapper functions are
provided. Any errors encountered while processing the arguments has to
be reported to pCon. On success a pointer to the environment
controller is returned, on failure NULL.
\item[ConfigureScan] configures the SICS general scan object self according
to the value of option. Returns 1 on success and 0 on failure. SICS
general scan object is a data structure holding function pointers for
various steps in the scan. These functions can be overloaded in order
to provide for special scans. See the documentation in scan.tex,
scan.h and scan.c for more details.
memory. The driver type is specified through name.
Driver options are in pOptions.
\item[CreateVelocitySelector] create a driver for a velocity selector.
The parameter name is the name of the driver, array is the name of a
Tcl array holding configuration parameters for the driver and pTcl is
the Tcl interpreter in which array lives.
\item[CreateControllerDriver] creates a driver for the general
controller module within SICS. argc and argv hold the parameters,
starting with the name of the driver to create.
\item[InstallEnvironmentController] installs a a sample
environment device such as a temperature controller or magnet
controller etc. into the interpreter pSics. pCon is a connection
object to which errors can be
reported, argc and argv are the controller parameters starting with
the driver name. This method does not get away with creating a driver
but must install the command into SICS because some environment
devices overload the standard Wrapper function with special ones. The
newly created object is still returned for further processing. In the
case of failure NULL is returned. Errors will have been printed to
pCon.
\item[ConfigureScan] allows for modules which configure the scan
object. option is the option to xxscan configure to process, the scan
object to configure is passed in in self. This returns 1 on success
and 0 on failures or options which are not recognized.
\item[KillSite] is a function to remove the site data structure when
SICS is done with it. pData must point to the site data structure.
KillSite's purpose is to free all memory associated with
the site data structure. This is mostly a cleanup thing, to keep the
fortify logs clear off inconsequential and confusing data.
\end{description}
All the simulation drivers for the hardware are part of the SICS
kernel and need not be initialized from these functions. SICS also
handles sample environment devices built in Tcl or on the general
controller object.
The site data structure suffers a little from inconsistencies
introduced through varying concepts for initializing SICS objects implemented
in various stage of the development of SICS. If you need to bypass the schemes
introduced here, consider implementing an own factory command and
install it through AddSiteCommand, RemoveSiteCommand.
Good luck!
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap2}
\verb@"site.h"@ {\footnotesize ? }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
\mbox{}\verb@/*-----------------------------------------------------------------------@\\
\mbox{}\verb@ S i t e A b s t r a c t i o n L a y e r@\\
\mbox{}\verb@@\\
\mbox{}\verb@With ANSTO using SICS as well it became necessary to separate the@\\
\mbox{}\verb@general parts of SICS from the installation specific components. Each@\\
\mbox{}\verb@installation will have a separate set of drivers and, to some@\\
\mbox{}\verb@extent, instrument specific commands. Such code has to be in a@\\
\mbox{}\verb@separate library. Access to this library is through an interface which@\\
\mbox{}\verb@consists of a structure containing pointers to functions which allow@\\
\mbox{}\verb@for the creation of site specific drivers and commands. Moreover, the@\\
\mbox{}\verb@site specific library has to implement a function, getSite, which@\\
\mbox{}\verb@returns the appropriate data structure for the site for which SICS is@\\
\mbox{}\verb@being compiled. @\\
\mbox{}\verb@------------------------------------------------------------------------*/@\\
\mbox{}\verb@#ifndef SICSSITE@\\
\mbox{}\verb@#define SICSSITE@\\
\mbox{}\verb@#include <sics.h>@\\
\mbox{}\verb@#include <motor.h>@\\
\mbox{}\verb@#include <countdriv.h>@\\
\mbox{}\verb@#include <HistDriv.i>@\\
\mbox{}\verb@#include <stringdict.h>@\\
\mbox{}\verb@#include <velo.h>@\\
\mbox{}\verb@#include <tcl.h>@\\
\mbox{}\verb@#include <codri.h>@\\
\mbox{}\verb@#include <evcontroller.h>@\\
\mbox{}\verb@#include <scan.h>@\\
\mbox{}\verb@@$\langle$sitedata {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@/*-------------------------------------------------------------------*/@\\
\mbox{}\verb@pSite getSite(void);@\\
\mbox{}\verb@#endif@\\
\mbox{}\verb@@$\diamond$
\end{list}
\vspace{-2ex}
\end{minipage}\\[4ex]
\end{flushleft}

View File

@ -46,6 +46,7 @@ $\langle$dh {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@@\\
\mbox{}\verb@ int GetDornierStatus(void **pData, pDornierStatus pDornier);@\\
\mbox{}\verb@ int DornierSend(void **pData, char *pCommand, char *pReply, int iLen);@\\
\mbox{}\verb@ int DecodeNewDornierStatus(char *pText, pDornierStatus pDornier);@\\
\mbox{}\verb@@$\diamond$
\end{list}
\vspace{-1ex}
@ -69,6 +70,8 @@ $\langle$dh {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@@\\
\mbox{}\verb@ Mark Koennecke, Juli 1997@\\
\mbox{}\verb@@\\
\mbox{}\verb@ updated to support new format fo status messages, Mark Koennecke, July 2003@\\
\mbox{}\verb@@\\
\mbox{}\verb@ copyright: see implementation file.@\\
\mbox{}\verb@------------------------------------------------------------------------------*/@\\
\mbox{}\verb@#ifndef VELODORN@\\

View File

@ -36,7 +36,19 @@ system for instance file names are case sensitive and that had to be
preserved. Commands defined in the scripting language are lower case by
convention.
</p>
<p>
Most SICS objects also hold the parameters required for their proper
operation. The general syntax for handling such parameters is:
<pre>
objectname parametername
</pre>
prints the current value of the parameter
</p>
<pre>
objectname parametername newvalue
</pre>
sets the parameter value to newvalue if you are properly authorized.
</p>
<h3>Authorisation</h3>
<p>
A client server system is potentially open to unauthorised hackers

View File

@ -21,9 +21,6 @@ manually from the command line through the following commands:
is minutes.
<DT>storefocus intervall newval
<DD>Sets the update intervall to newval minutes.
<DT>killfile
<DD>This command will overwrite the last data file written and thus
effectively erase it. Therefore this command requires manager privilege.
</DL>
FOCUS has three detector banks which may not all be active at all
times. Thus a way is needed to tell SICS about the configuration of

View File

@ -75,15 +75,10 @@ for its number type.
</UL>
<DT> Rank
<DD> Rank defines the number of histograms in memory.
<DT> Length
<DD> gives the length of an individual histogram.
<DT> BinWidth
<DD> determines the size of a single bin in histogram memory in bytes.
<DT>dim0, dim1, dim2, ... dimn
<DD>define the logical dimensions of the histogram. Must be set if the
the sum command (see below) is to be used. This is a clutch necessary to
cope with the different notions of dimensions in the SINQ histogram memory
and physics.
<DD>define the logical dimensions of the histogram.
</DL>
</p>
<p>
@ -126,6 +121,8 @@ will be generated starting from start with a stepwidth of step (example: HM genb
configured with this command. The time bin iNum is set to the value value.
<DT>HM clearbin
<DD>Deletes the currently active time binning information.
<dt>HM notimebin
<dd>returns the number of currently configured timebins.
</DL>
</p>
@ -150,6 +147,10 @@ transfer the configuration from the host computer to the actual HM.
<DD> starts counting using the currently active values for CountMode and
preset. This command does not block, i.e. in order to inhibit further
commands from the console, you have to give Success afterwards.
<DT>HM countblock
<DD> starts counting using the currently active values for CountMode and
preset. This command does block, i.e. you can give new commands only when
the counting operation finishes.
<DT>HM initval <i>val</i>
<DD> initialises the whole histogram memory to the value val. Ususally 0 in
order to clear the HM.
@ -164,3 +165,5 @@ allow to retrieve a subset of a histogram between iStart and iEnd.
</p>
</body>
</html>

View File

@ -53,6 +53,17 @@ Optionally a psi value and a hamilton position can be specified.
the motors to drive to that position. This command will wait for the
diffractometer to arrive at the setting angles requested.
Optionally a psi value and a hamilton position can be specified.
<dt>hkl hm
<dd>Retrieves the value of the histogram memory flag.
<dt>hkl hm val
<dd>Sets the histogram memory flag to val. This is a special for
TRICS. TRICS has three detectors at 0, 45, 90 degree offset to two
theta. If this flag is greater 0, hkl checks if the reflection to be
calculated is on any of the three detectors and calculates two theta
accordingly.
<dt>hkl fromangles two-theta om chi phi
<dd>Calculates hkl from the angles given on the command line using the
current UB matrix and wavelength.
</DL>
</p>

View File

@ -3,10 +3,14 @@
<TITLE>Hklscan</TITLE>
</HEAD>
<BODY>
<H1>Hklscan</H1>
<H1>Hklscan and Hklscan2d</H1>
<P>
Hklscan is a command which allows to scan in reciprocal space expressed as
Miller indizes on a four circle diffractometer. Prerequisite for this is
Miller indizes on a four circle diffractometer. Hklscan operates with
a single detector. Hklscan2d does the same as hklscan but for the
position sensitive detectors, saving data into NeXus files. Hklscan
and Hklscan2d share the same syntax.
Prerequisite for this is
the existence of a scan object and the hkl-object for doing crystallographic
calculations. Make sure the properties of the hkl object (UB, wavelength, NB)
have some reasonable relation to reality, otherwise the diffractometer may
@ -25,10 +29,15 @@ Hklscan is a command which allows to scan in reciprocal space expressed as
<dd>executes the HKL scan. NP is the number of points to do, mode is the
counting mode and can be either timer or monitor and preset is the preset
value for the counter at each step.
<dt>hklscan2d sim NP mode preset
<dd>This command only for hklscan2d. It tries to calculate all points
in the hkl scan and complains if it cannot reached or stays
silent. Use this to test if your hklscan2d can be performed.
</dl>
Data is written automatically into a slightly modified TOPSI data format
file. The status display with topsistatus or scanstatus might be slightly
erratic as it uses two theta as x-axis.
file for hklscan. The status display with topsistatus or scanstatus
might be slightly erratic as it uses two theta as x-axis. Hklscan2d
writes data into NeXus files.
</P>
</BODY>
</HTML>

59
doc/user/lowmax.htm Normal file
View File

@ -0,0 +1,59 @@
<HTML>
<HEAD>
<TITLE>The Local Maximum Search Module</TITLE>
</HEAD>
<BODY>
<h1>The Local Maximum Search Module</h1>
<p>
This module allows to search for local maxima in two-dimensional
datasets stored within a SICS histogram memory. All commands
act upon the current content of the histogram memory. The following
commands are understood:
<dl>
<dt>lowmax stat hm
<dd>calculates the average and the maximum count in the frame
currently held in histogram memory hm.
<dt>lowmax search hm
<dd>searches the frame held in histogram memory hm for local
maxima. Local maxima are returned as sets of three numbers which are
the x and y coordinates and the intensity. Each set of numbers is
separated from the next one by the @ symbol.
<dt>lowmax cog hm x y
<dd>calculates the center ogf gravity for the pixel at coordinates x
and y in histogram memory hm. Four numbers are returned: the new x and
y coordinates, the intensity of the peak and the number of points
contributing to the peak.
<dt>lowmax steepness val
<dd>accesses the steepness parameter for the peak search. With a
parameter val sets a new value, without print the current value.
<dt>lowmax window val
<dd>accesses the window parameter for the peak search. With a
parameter val sets a new value, without print the current value.
<dt>lowmax threshold val
<dd>accesses the thresholds parameter for the peak search. With a
parameter val sets a new value, without print the current value.
<dt>lowmax cogwindow val
<dd>accesses the cogwindow parameter for the peak search. With a
parameter val sets a new value, without print the current value.
<dt>lowmax cogcontour val
<dd>accesses the cogcontour parameter for the peak search. With a
parameter val sets a new value, without print the current value.
</dl>
The local maximum search can be tuned through the parameters: The
window parameter sets the size of the quadratic area for which a
candidate pixel must be the local maximum. Threshold sets a minimum
count rate for a local maximum. Steepness sets a minimum difference to
the borders of the window used for the local maximum search which must
be fulfilled.
</p>
<p>
The center of gravity calculation can be tuned mainly through the
cogcontour parameter which determines at which percentage of the
maximum value of the peak the center of gravity calculation
stops. Cogwindow is the size of the area in which a center of gravity
is calculated. Can be set rather generously.
</p>
</BODY>
</HTML>

View File

@ -7,14 +7,25 @@
<p>
SICS has a built in macro facility. This macro facility is aimed at instrument managers and users alike. Instrument managers may provide customised measurement procedures in this language, users may write batch files in this language. The macro language is John Ousterhout's Tool Command Language (TCL). Tcl has control constructs, variables of its own, loop constructs, associative arrays and procedures. Tcl is well documented by several books and online tutorials, therefore no details on Tcl will be given here. All SICS commands are available in the macro language. Some potentially harmful Tcl commands have been deleted from the standard Tcl interpreter. These are: exec, source, puts, vwait, exit,gets and socket. A macro or batch file can be executed with the command:</p>
<p>
<b> fileeval <i>name</i> </b> tries to open the file name and executes the script in this file. </p>
<b> fileeval <i>name</i> </b> tries to open the file name and
executes the script in this file.
</p>
<p>
<b>batchrun <i>name</i></b> prepends to name a directory name
configured in the variable batchroot and then executes that
batchfile. The usage scenerio is that you have a directory where you
keep batch files. Then the variable batcroot is set to contain the path
to that directory. Batchrun then allows to start scripts in that
directory without specifying the full path.
Then there are some special commands which can be used within macro-sripts:
<p>
<b> ClientPut sometext1 ... </b> writes everything after ClientPut to
the client which started the script. This is needed as SICS supresses
the output from intermediate commands in scripts. Except error
messages and warnings. With clientput this scheme can be circumvented
and data be printed from within scripts.</p>
<b> ClientPut sometext1 ... </b>Usally SICS suppresses any messages
from SICS during the processing of batch files. This is in order not
to confuse users with the output of intermediate results during
the processing of batch files. Error messages and warnings, however,
come through always. Clientput now allows to send messages to the
user on purpose from within scripts.
</p>
<p>
<b> SICSType object </b> allows to query the type of the object specified by object. Possible return values are<ul>
<li> <b> DRIV </b> if the object is a SICS drivable object such as a motor

View File

@ -47,8 +47,83 @@ or equal to zero for the motor being movable.
<li> <b> Precision </b> denotes the precision to expect from the motor in positioning. Can usually only be set by managers.
<li> <b> AccessCode </b> specifies the level of user privilege necessary to operate the motor. Some motors are for adjustment only and can be harmful to move once the adjustment has been done. Others must be moved for the experiment. Values are 0 - 3 for internal, manager, user and spy. This parameter can only be changed by managers.
<li> <b> Sign </b> reverses the operating sense of the motor.
For cases where electricians and not physicists have defined the operating sense of the motor. Usually a parameter not to be changed by ordinary users.
For cases where electricians and not physicists have defined the
operating sense of the motor. Usually a parameter not to be changed
by ordinary users.
<li><b> failafter </b>This is the number of consecutive failures of
positioning operations this motor allows before it thinks that
something is really broken and aborts the experiment.
<li><b> maxretry </b>When a motor finishes driving, SICS checks if the
desired position was reached. If the position read back from the motor
is not within precision to the desired value, the motor is
restarted. This is done at max maxretry times. After maxretry retries,
the motor throws an error.
<li></b> ignorefault </b>If this is bigger then 0, positioning faults
from the motor will be ignored.
</ul>
<p>
<h2>Motor Error Handling Concepts</h2>
<p>
As mechanical components motors are prone to errors. SICS knows about
two different classes of motor errors:
<dl>
<dt>HWFault
<dd>This is when there is a problem communicating with the motor, a
limit is violated etc. SICS assumes that such errors are so grave that
no fix is possible. If such a HWFault is detected a configurable
interrupt (see parameter InterruptMode) is set which can be used by
upper level code to act upon the problem.
<dt>HWPosFault
<dd>This is a positioning failure, i.e. The motor did not reach the
desired position. Such a positioning problem can come from two
sources:
<ul>
<li>The positioning problem is reported by the motor driver. SICS then
assumes that the driver has done something to solve the problem and
promotes this problem to a HWFault.
<li>The motor driver reported no error and SICS figures out by itself,
that the desired position has not been reached. SICS thinks that this
is the case if the difference between the desired position and the
position read from the motor controller is greater then the parameter
precision. If SICS detects such a problem it tries to reposition the
motor. This is done for the number of times specified through the
parameter maxretries. If the position has not been reached after
maxretries repositionings, a HWFault is assumed.
</ul>
</dl>
In any case lots of warnings and infos are printed.
</p>
<p>
If SICS tries to drive an axis which is for some reason broken to
often hardware damage may occur (and HAS occurred!). Now, SICS has no
means to detect if the mispositioning of a motor is due to a concrete
block in the path of the instrument or any other reason. What SICS can
do though is to count how often a motor mispositions in
sequence. This means SICS counts mispositionings if it cannot drive a
motor, if the motor is driven succesfully, the count is cleared. If
the count of mispositionings becomes higher then the parameter
failafter, SICS thinks that there is something really, really wrong
and aborts the measurement and prints an error message containing the
string: MOTOR ALARM.
</p>
<p>
There are some common pitfalls with this scheme:
<dl>
<dt>You want upper level code to be signalled when your critical motor
fails.
<dd>Solution: set the parameter interruptmode to something useful and
check for the interrupt in upper level code.
<dt>SICS falsly reports mispositionings.
<dd>Solution: increase the precision parameter.
<dt>You know that a motor is broken, you cannot fix it, but you want
to measure anyway.
<dd>Solution: increase the precision parameter, if SICS finds the
positioning problem, increase maxretries, increase the failafter
parameter. In the worst case set the ignorefault parameter to greater
0, this will prevent all motor alarms.
</dl>
</p>
</body>
</html>

View File

@ -21,9 +21,6 @@ manually from the command line through the following commands:
is minutes. Default is 20 minutes.
<DT>storedata intervall <i>newval</i>
<DD>Sets the update intervall to newval minutes.
<DT>killfile
<DD>This command will overwrite the last data file written and thus
effectively erase it. Therefore this command requires manager privilege.
</DL>
</P>
</BODY>

View File

@ -225,15 +225,17 @@ can be achieved by using the drive command.
and <b>log frequency</b> (both below)
</DL>
<h3>Logging </h3>
The values of any sample environement device can be logged. There are two
The values of any sample environement device can be logged. There are three
features:
<ul>
<li>Logging to a file wih a configurable time intervall between log
file entries.
<li>Sums are kept internally which allow the calculation of the mean
value and the standard deviation at all times.
<li>A circular buffer holding 1000 timestamps plus values is
automatically updated.
</ul>
The last system is automatically switched on after the first drive or
The last two systems are automatically switched on after the first drive or
run command on the environment device completed.
This system is run through the following commands.
<DL>
@ -245,7 +247,7 @@ standard deviation.
values and prints them.
<DT>name log frequency val
<DD> With a parameter sets, without a parameter requests the logging intervall
for the log file.
for the log file and the circular buffer.
This parameter specifies the time intervall in seconds
between log records. The default is 300 seconds.
<DT>name log file filename
@ -255,12 +257,22 @@ Logging will happen any 5 minutes initially. The logging frequency
of the form date time value. The name of the file must be specified relative
to the SICS server.
<DT>name log flush
<DD>DigitalUnix buffers output heavily. With this command an update of
<DD>Unix buffers output heavily. With this command an update of
the file can be enforced.
<DT>name log status
<DD>Queries if logging to file is currently happening or not.
<DT>name log close
<DD> Stops logging data to the file.
<dt>name log tosicsdata dataname
<dd>copies the content of the circular buffer to a sicsdata
buffer. This is used by graphical clients to display the content of
the circular buffer.
<dt>name log dump
<dd>Prints the content of the circular log buffer to screen.
<dt>name log dumptofile filename
<dd>Prints the content of the circular log buffer into the file
specified as filename. Note, this file is on the computer where the
SICS server resides.
</DL>
</P>
@ -509,7 +521,7 @@ At SANS there is a Eurotherm temperature controller for the sample heater.
with the following command. The eurotherm needs to be connected with a
nullmodem adapter.
<BLOCKQUOTE>
evfactory new name euro Mac-PC Mac-port Mac-channel
evfactory new name euro computer port channel
</BLOCKQUOTE>
</p>
<p>
@ -663,19 +675,19 @@ device. The LTC-11 behaves like a normal SICS environment control device
plus a few additional commands. An LTC-11 can be configured into SICS with
the following command:
<BLOCKQUOTE>
evfactory new name ltc11 Mac-PC Mac-port Mac-channel
evfactory new name ltc11 computer port channel
</BLOCKQUOTE>
</p>
<p>
name is a placeholder for the name of the device within SICS. A good
suggestion is temperature.
ltc11 is the keyword for selecting the LTC-11 driver. Mac-PC is the name of
the Macintosh PC to which the controller has been connected, Mac-Port is the
port number at which the Macintosh-PC's serial port server listens.
Mac-channel is the RS-232 channel to which the controller has been
ltc11 is the keyword for selecting the LTC-11 driver. Computer is the name of
the computer running David Maden's SerPortServer program, port is the
port number at which the SerPortServer program listens.
Channel is the RS-232 channel to which the controller has been
connected. For example (at DMC):
<pre>
evfactory new temperature ltc11 lnsp18.psi.ch 4000 6
evfactory new temperature ltc11 localhost 4000 6
</pre>
</p>
<p>

View File

@ -24,19 +24,20 @@ these SICS client programs. SICS Clients and the SICServer communicate
with each other through the TCP/IP network.
</p>
<p>
Currently these SICS clients are available:
Currently the following SICS clients are available:
<uL>
<li> A command line control client for sending commands to the SICS
server and displaying its repsonses.
<li> A status display for the powder diffractometers DMC and HRPT.
<li> A status display for TOPSI.
<li> A status display for SANS.
<li> A status display for SANS and SANS2.
<li> A status display for FOCUS.
<li> A AMOR control and status program.
<li> A triple axis control and status program.
<li> A SICS variable watcher. This application graphically logs the
change of a SICS variable over time. Useful for monitoring for
instance temperature controllers.
<li>A graphical client for TRICS.
</ul>
</p>
<p>
@ -71,12 +72,26 @@ following commands at the command prompt:
<DD> for the triple axis status display and control application.
<DT>varwatch &
<DD> for the variable watcher.
<dt>trics-&
<dd>for the starting the TRICS graphical client.
</dl>
On a PC you may find icons for starting the different programs on the
desktop.
Each of these clients has usage instructions online which can be displayed
through the help/about menu entry.
</p>
<p>
Another option to start SICS clients is the Java Webstart mechanism
which is available for most platforms. Java webstart requires both
Java and Java webstart to be installed on the computer running the
client. Then clients can be started directly from a WWW-page. The
advantage is that clients are automatically updated in this system as
soon as new version have been copied to the WWW-site. Installation
instructions for Java webstart and links to start all SICS clients
though this mechanism can be found at:
<a href="http://lns00.psi.ch/sics/wstart"> the SICS webstart</a>
page. This service is only accessible within the PSI network.
</p>
<h2>Connecting</h2>
<p>
After startup any SICS client is not connected to a SICS server and thus not
@ -101,11 +116,11 @@ the SICS server log in as the instrument user at the instrument computer and
invoke the appropriate command to start the server. These are:
<dl>
<DT>DMC
<DD>Computer = lnsa05,User = DMC
<DD>Computer = lnsa05, User = DMC
<DT>TOPSI
<DD>Computer = lnsa07,User = TOPSI
<DD>Computer = topsi, User = TOPSI
<DT>SANS
<DD>Computer = lnsa10,User = SANS
<DD>Computer = sans, User = SANS
<DT>TRICS
<DD>Computer = lnsa18, User = TRICS
<DT>HRPT
@ -115,7 +130,7 @@ invoke the appropriate command to start the server. These are:
<DT>AMOR
<DD>Computer = lnsa14, User = AMOR
<DT>TASP
<DD>Computer = lnsa12, User = TASP
<DD>Computer = tasp, User = TASP
<DT>POLDI
<DD>Computer = poldi, User = POLDI
</dl>

View File

@ -11,7 +11,27 @@
<p>
<b> resetserver </b> resets the server after an interrupt.</p>
<p>
<b> dir </b> a single word command which lists all objects available in the SICS system in its current configuration.</p>
<b> dir </b> a command which lists objects available in the SICS
system. Dir without any options prints a list of all objects. The
list can be restricted with:
<dl>
<dt>dir var
<dd>prints all SICS primitive variables
<dt>dir mot
<dd>prints a list of all motors
<dt>dir inter driv
<dd> prints a list of all drivable objects. This is more then motors
and includes virtual motors such as environment devices and wavelength
as well.
<dt>dir inter count
<dd>Shows everything which can be counted upon.
<dt>dir inter env
<dd>Shows all currently configured environment devices.
<dt>dir match wildcard
<dd>lists all objects which match the wildcard string given in
wildcard.
</dl>
</p>
<p>
<b> status </b> A single word command which makes SICS print its current
status. Possible return values can be:
@ -45,5 +65,12 @@ above and restores SICS to the state it was in when the status was saved with
backup. If no file argument is given the system default file gets
read.
</p>
<p>
<b>killfile</b> decrements the data number used for SICS file writing
and thus consequently overwrites the last datafile. This is useful
when useless data files have been created during tests. As this is
critical command in normal user operations, this command requires
managers privilege.
</p>
</body>
</html>

View File

@ -72,9 +72,9 @@
e.g. ALF1-ALF4 (carry out command given on variables between ALF1 and
ALF4 in storage order; see section V)
e.g. DM,ALF1-ALF4,SS,DA (a combination of the above) Variables separated
by commas need not be typed in their order of storage in THE Program.
by commas need not be typed in their order of storage in the program.
Note : that for this type of syntax (type a) the only acceptable
Note : that for this type of syntax (type A) the only acceptable
variable separators are ' ' (i.e. a space), ',' and '-' (' ' and ','
are equivalent).
@ -87,7 +87,7 @@
variables in storage [QK, QL] take the values 0 and 2 )
e.g. QH=1,0,2.0,AS=3.24,CC=90 (a combination of the above)
In commands involving this construction type (B) THE Program echoes
In commands involving this construction type (B) the program echoes
the variable names and values it has understood.
Possible separators are ',' and ' ' ('space')
@ -159,7 +159,7 @@
<pre>
CO(UNT) : Counts for a given preset TIme or MoNitor.
This is a command of type b syntax. If the command is issued alone,
This is a command of type B syntax. If the command is issued alone,
the preset used will be that most recently set. However, the preset
may also be specified on the same line as the COUNT command.
(For use of COnt in a P.A. file, see SCan and PA).
@ -223,11 +223,11 @@
new position and the appropriate variable is altered in the memory.
A DRIVE command will fail (non destructively) if:
l a motor or power supply is protected or fixed
l a software or hard limit is exceeded; the soft limits may be changed
- a motor or power supply is protected or fixed
- a software or hard limit is exceeded; the soft limits may be changed
if necessary using the SET command provided the value desired is
within the allowed range.
l there is ambiguity among the driven variables.
- there is ambiguity among the driven variables.
e.g. DR KI=2.662,A2=40&lt;CR&gt;
sets two different targets for A2 and fails.
@ -332,7 +332,7 @@
(within a certain tolerance) to the positions.
Clear exceptions are for a power supply which has
been turned disabled, the abort of a DRive via
^C^C and, for instance, the incident wavevector
Interrupt and, for instance, the incident wavevector
after a drive of A1 or A2.
</pre>
<h3><a name="LOG">LOG</a></h3>
@ -379,7 +379,7 @@
non-zero.(This is because it no longer behaves as a flipper.)
Note that the ON and OFF commands are the only ones which can be used
to change F1 and F2. Both ON and OFF are of type Asyntax.
to change F1 and F2. Both ON and OFF are of type A syntax.
</pre>
@ -398,8 +398,9 @@
be printed for every point in every scan until disabled.
Typing OU with NO following variables will stop the output of ALL
variables apart from scanned ones.
Type A syntax. A variable that has to be output because it is scanned a
nd has also been selected with the OUT command will only be output once.
Type A syntax. A variable that has to be output because it is scanned
and has also been selected with the OUT command will only be output
once.
e.g. OU A3,A4&lt;CR&gt;
A3 &amp; A4 will be printed in addition to the scan variables.
@ -546,23 +547,9 @@
2) data files :
All of this data is also output to a disk file. This file is called
either TEMP##.SCN or SV####.SCN where # represents a digit between 0
and 9. Both types of data files are used sequentially and thus
periodically overwritten but obviously the TEMP##.SCN files disappear
sooner.
A scan initiated from the terminal will be stored in a TEMP file
(unless the appropriate SWITCH is on ) while scans input from .JOB files
are always saved permanently. The TEMP files are lost ( but see SAVE).
For more details on data files see section VI below.
All SV####.SCN files are copied to the mainframe computer automatically
and transfered to the SPECTRA database for Backup and archiving. They
can be accessed by the SPECTRA program or by the 3-axis programs (PKFIT
or FILING).
Programs for manipulating data files are described in another manual
(PKFIT, FILING, LOOK, LIST, LHEAD etc.)
All tas####.dat files are copied to the mainframe computer
automatically.
3) Scan output :
@ -602,7 +589,7 @@
As with the DRIVE command, scans in Q-E space are carried out at fixed
KI (FX=1) or fixed KF (FX=2). During a scan with Kf fixed (i.e.FX=2)
THE Program will automatically check and adjust A5 and A6; for Ki
the program will automatically check and adjust A5 and A6; for Ki
fixed (FX=1) however, MAD Program will not adjust at check and adjust
at every point A1 and A2 because these variables are not likely to
move in a Ki-fix scan.
@ -847,7 +834,7 @@ however, corresponds to a transmission minimum for Ki neutrons.
by SET.
The following list gives the variable identifiers and definitions,
where the order is as the variables are stored in THE Program.
where the order is as the variables are stored in the program.
P.A Variables : Variables marked with an asterisk are not recognized

View File

@ -345,6 +345,7 @@ H H L
%html histogram.htm 2
%html nextrics.htm 2
%html peaksearch.htm 2
%html lowmax.htm 2
%html trscan.htm 2
%html psddata.htm 1

View File

@ -11,6 +11,7 @@ TRICS with a PSD requires the following special features.
histogram memory</a>.
<li><a href="nextrics.htm">NeXus</a> data handling for TRICS.
<li>A <a href="peaksearch.htm">peak search</a> command.
<li>A <a href="lowmax.htm">local maximum search</a> command.
<li>A TRICS specific <a href="trscan.htm">count and scan</a> command.
</ul>
</p>

View File

@ -41,7 +41,11 @@ This means the log file has been started at August, 8, 2001 at 00:01:01.
There is a new log file daily. Load appropriate files into the editor and
look what really happened.
</p>
<p>
Another good ideas is to use the unix command grep on assorted log
files. A grep for the strings ERROR or WARNING will more ofteh then
not give an indication for the nature of the problem.
</p>
<p>
The log files show you all commands given and all the responses of the system.
Additionally there are hourly time stamps in the file which allow to narrow
@ -63,12 +67,8 @@ The log files show you all commands given and all the responses of the system.
<dt>EL737__BAD_BSY
<dd>A counting operation was aborted while the beam was off. Unfortunately,
the counter box does not respond to commands in this state and ignores the
stop command sent to it during the abort operation. This can be resolved by
the command:
<pre>
counter stop
</pre>
when the beam is on again.
stop command sent to it during the abort operation. This can be
safely ignored, SICS fixes this condition.
</dl>
</p>
<h2>Starting SICS</h2>

104
doc/user/userrefman Normal file
View File

@ -0,0 +1,104 @@
\documentclass[12pt,a4paper]{report}
%%\usepackage[dvips]{graphics}
%%\usepackage{epsf}
\setlength{\textheight}{24cm}
\setlength{\textwidth}{16cm}
\setlength{\headheight}{0cm}
\setlength{\headsep}{0cm}
\setlength{\topmargin}{0cm}
\setlength{\oddsidemargin}{0cm}
\setlength{\evensidemargin}{0cm}
\setlength{\hoffset}{0cm}
\setlength{\marginparwidth}{0cm}
\begin{document}
%html -d hr " "
%html -s report
\begin{center}
\begin{huge}
SICS Master User Manual\\
\end{huge}
\today\\
Dr. Mark K\"onnecke \\
Labor f\"ur Neutronenstreuung\\
Paul Scherrer Institut\\
CH--5232 Villigen--PSI\\
Switzerland\\
\end{center}
\clearpage
\clearpage
\tableofcontents
\clearpage
\chapter{Introduction}
This is the master user manual for SICS. It gives an overview over all
command implemented, independent of a specific instrument. This is to
be used as the source for more instrument specific user manuals and
gives an overview of the commands available within SICS. Please note,
that many instruments have special commands realized as scripts in the
SICS built in scripting language. Only the most common of such
commands are listed here.
\chapter{System Commands and Concepts}
%html sicsinvoc.htm 2
%html basic.htm 2
%html logging.htm 2
%html logbook.htm 3
%html commandlog.htm 3
%html batch.htm 2
%html macro.htm 3
%html buffer.htm 3
%html token.htm 2
%html system.htm 2
%html config.htm 2
%html madsim.htm 2
%html trouble.htm 2
\chapter{Hardware Related Commands}
%html drive.htm 1
%html motor.htm 2
%html chopper.htm 2
%html counter.htm 2
%html count.htm 2
%html histogram.htm 2
%html samenv.htm 2
%html ctrl.htm 2
%html velocity.htm 2
%html velolambda.htm 2
\chapter{Common User Commands}
%html topscan.htm 2
%html hkl.htm 2
%html optimise.htm 2
%html xytable.htm 2
%html lowmax.htm 2
\chapter{PSI Specific Commands}
\section{Commands specific to the TOF--diffractometer FOCUS}
%html focussps.htm 3
%html fowrite.htm 3
\section{Reflectometer AMOR specific Commands}
%html amor2t.htm 3
%html amorstore.htm 3
%html amortof.htm 3
\section{TRICS Specific Commands}
%html hklscan.htm 3
%html trscan.htm 3
%html mesure.htm 3
%html nextrics.htm 3
%html peaksearch.htm 3
\section{Fourier Diffractometer POLDI Specific Commands}
%html poldiscan.htm 2
%html poldiwrite.htm 3
\section{Triple Axis Spectrometer Specific Commands}
%html tasmad.html 3
%html tasvariables.html 3
%html tascommands.html 3
\end{document}

View File

@ -6,6 +6,14 @@
Mark Koennecke, Juli 1997
Implemented calling site specific initialisation routines.
Mark Koennecke, July 2003
Implemented scripted out of tolerance handling and retrieval of
driver name.
Mark Koennecke, December 2003
Copyright:
Labor fuer Neutronenstreuung
@ -331,35 +339,45 @@
return iRes;
}
/*---------------------------- Error Handlers --------------------------------*/
static void ErrWrite(char *txt)
{
pExeList pExe;
SConnection *pCon = NULL;
pExe = GetExecutor();
pCon = GetExeOwner(pExe);
if(pCon)
{
SCWrite(pCon,txt,eWarning);
}
else
{
ServerWriteGlobal(txt,eWarning);
}
}
/*-----------------------------------------------------------------------*/
static void ErrReport(pEVControl self)
{
float fPos, fDelta;
char pBueffel[256];
self->pDriv->GetValues(self->pDriv,&self->fTarget,&fPos,&fDelta);
sprintf(pBueffel,"WARNING: %s is out of range by %g",self->pName,fDelta);
ErrWrite(pBueffel);
self->iWarned = 1;
}
/*-------------------------------------------------------------------------*/
static int ErrLazy(void *pData)
{
pEVControl self = NULL;
pExeList pExe;
SConnection *pCon = NULL;
float fPos, fDelta;
char pBueffel[256];
self = (pEVControl)pData;
assert(self);
self->pDriv->GetValues(self->pDriv,&self->fTarget,&fPos,&fDelta);
sprintf(pBueffel,"WARNING: %s is out of range by %g",self->pName,fDelta);
pExe = GetExecutor();
pCon = GetExeOwner(pExe);
if(!self->iWarned)
{
if(pCon)
{
SCWrite(pCon,pBueffel,eWarning);
}
else
{
ServerWriteGlobal(pBueffel,eWarning);
}
}
self->iWarned = 1;
ErrReport(self);
return 1;
}
/*--------------------------------------------------------------------------*/
@ -367,33 +385,14 @@
{
pEVControl self = NULL;
pExeList pExe;
SConnection *pCon = NULL;
float fPos, fDelta;
char pBueffel[256];
int iRet;
self = (pEVControl)pData;
assert(self);
self->pDriv->GetValues(self->pDriv,&self->fTarget,&fPos,&fDelta);
sprintf(pBueffel,"WARNING: %s is out of range by %g",self->pName,fDelta);
ErrReport(self);
pExe = GetExecutor();
pCon = GetExeOwner(pExe);
if(!self->iWarned)
{
if(pCon)
{
SCWrite(pCon,pBueffel,eWarning);
}
else
{
ServerWriteGlobal(pBueffel,eWarning);
}
}
self->iWarned = 1;
if(IsCounting(pExe))
{
SCWrite(GetExeOwner(pExe),"Pausing till OK",eError);
@ -414,36 +413,57 @@
}
return 1;
}
/*---------------------------------------------------------------------------*/
static int ErrInterrupt(void *pData)
/*--------------------------------------------------------------------------*/
static int ErrScript(void *pData)
{
pEVControl self = NULL;
pExeList pExe;
SConnection *pCon = NULL;
float fPos,fDelta;
char pBueffel[256];
int iRet;
Tcl_Interp *pTcl = NULL;
pExeList pExe;
char pBueffel[256];
self = (pEVControl)pData;
assert(self);
/* report problem */
self->pDriv->GetValues(self->pDriv,&self->fTarget,&fPos,&fDelta);
sprintf(pBueffel,"WARNING: %s is out of range by %g",self->pName,fDelta);
ErrReport(self);
pExe = GetExecutor();
pCon = GetExeOwner(pExe);
if(!self->iWarned)
if(self->errorScript != NULL)
{
if(pCon)
pTcl = InterpGetTcl(pServ->pSics);
iRet = Tcl_Eval(pTcl,self->errorScript);
if(iRet != TCL_OK)
{
SCWrite(pCon,pBueffel,eWarning);
snprintf(pBueffel,255,
"ERROR: %s while processing errorscript for %s",
pTcl->result,self->pName);
ErrWrite(pBueffel);
}
/*
assume that everything is fine again after the script
returns
*/
self->eMode = EVMonitor;
}
else
{
ServerWriteGlobal(pBueffel,eWarning);
snprintf(pBueffel,255,
"ERROR: script error handling requested for %s, but no script given",
self->pName);
ErrWrite(pBueffel);
}
return 1;
}
self->iWarned = 1;
/*---------------------------------------------------------------------------*/
static int ErrInterrupt(void *pData)
{
pEVControl self = NULL;
self = (pEVControl)pData;
assert(self);
ErrReport(self);
/* interrupt */
SetInterrupt((int)ObVal(self->pParam,INTERRUPT));
@ -453,31 +473,13 @@
static int ErrRun(void *pData)
{
pEVControl self = NULL;
pExeList pExe;
SConnection *pCon = NULL;
float fPos, fDelta;
char pBueffel[256];
int iRet;
self = (pEVControl)pData;
assert(self);
/* report problem */
self->pDriv->GetValues(self->pDriv,&self->fTarget,&fPos,&fDelta);
sprintf(pBueffel,"WARNING: %s is out of range by %g",self->pName,fDelta);
pExe = GetExecutor();
pCon = GetExeOwner(pExe);
if(pCon)
{
SCWrite(pCon,pBueffel,eWarning);
SCWrite(pCon,"Driving to a safe place",eWarning);
}
else
{
ServerWriteGlobal(pBueffel,eWarning);
ServerWriteGlobal("Driving to a safe place",eWarning);
}
ErrReport(self);
ErrWrite("Running to safe value");
self->pDriv->SetValue(self->pDriv, ObVal(self->pParam,SAFEVALUE));
self->eMode = EVIdle;
return 1;
@ -511,6 +513,10 @@
iStatus = ErrRun(pData);
return iStatus;
break;
case 4: /* invoke a script */
iStatus = ErrScript(pData);
return iStatus;
break;
default:
return 0;
@ -807,6 +813,14 @@
{
VarlogDelete(self->pLog);
}
if(self->driverName != NULL)
{
free(self->driverName);
}
if(self->errorScript != NULL)
{
free(self->errorScript);
}
free(self);
}
/*--------------------------------------------------------------------------*/
@ -935,43 +949,55 @@
assert(self);
assert(pCon);
sprintf(pBueffel,"Parameter listing for %s",self->pName);
snprintf(pBueffel,255,"Parameter listing for %s",self->pName);
SCWrite(pCon,pBueffel,eValue);
sprintf(pBueffel,"%s.%s = %g ",self->pName, "tolerance",
snprintf(pBueffel,255,"%s.%s = %g ",self->pName, "tolerance",
ObVal(self->pParam,TOLERANCE));
SCWrite(pCon,pBueffel, eValue);
sprintf(pBueffel,"%s.%s = %g",self->pName, "access",
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "access",
ObVal(self->pParam,ACCESS));
SCWrite(pCon,pBueffel, eValue);
sprintf(pBueffel,"%s.%s = %g",self->pName, "ErrorHandler",
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "ErrorHandler",
ObVal(self->pParam,ERRORHANDLER));
SCWrite(pCon,pBueffel, eValue);
sprintf(pBueffel,"%s.%s = %g",self->pName, "interrupt",
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "interrupt",
ObVal(self->pParam,INTERRUPT));
SCWrite(pCon,pBueffel, eValue);
sprintf(pBueffel,"%s.%s = %g",self->pName, "UpperLimit",
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "UpperLimit",
ObVal(self->pParam,UPLIMIT));
SCWrite(pCon,pBueffel, eValue);
sprintf(pBueffel,"%s.%s = %g",self->pName, "LowerLimit",
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "LowerLimit",
ObVal(self->pParam,LOWLIMIT));
SCWrite(pCon,pBueffel, eValue);
sprintf(pBueffel,"%s.%s = %g",self->pName, "SafeValue",
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "SafeValue",
ObVal(self->pParam,SAFEVALUE));
SCWrite(pCon,pBueffel, eValue);
sprintf(pBueffel,"%s.%s = %g",self->pName, "MaxWait",
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "MaxWait",
ObVal(self->pParam,MAXWAIT));
SCWrite(pCon,pBueffel, eValue);
sprintf(pBueffel,"%s.%s = %g",self->pName, "Settle",
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "Settle",
ObVal(self->pParam,SETTLE));
SCWrite(pCon,pBueffel, eValue);
EVCGetPos(self,pCon,&fPos);
sprintf(pBueffel,"%s.%s = %g",self->pName, "CurrentValue",
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "CurrentValue",
fPos);
SCWrite(pCon,pBueffel, eValue);
sprintf(pBueffel,"%s.%s = %g",self->pName, "TargetValue",
snprintf(pBueffel,255,"%s.%s = %g",self->pName, "TargetValue",
self->fTarget);
SCWrite(pCon,pBueffel, eValue);
snprintf(pBueffel,255,"%s.driver = %s",self->pName, self->driverName);
SCWrite(pCon,pBueffel, eValue);
if(self->errorScript != NULL)
{
snprintf(pBueffel,255,"%s.errorScript = %s", self->pName,
self->errorScript);
}
else
{
snprintf(pBueffel,255,"%s.errorScript = UNDEFINED", self->pName);
}
SCWrite(pCon,pBueffel, eValue);
return 1;
}
@ -1109,6 +1135,35 @@
}
else /* parameter request */
{
/*
catch case of errorScript
*/
strtolower(argv[1]);
if(strcmp(argv[1],"errorscript") == 0)
{
if(self->errorScript != NULL)
{
snprintf(pBueffel,255,"%s.errorScript = %s",self->pName,
self->errorScript);
}
else
{
snprintf(pBueffel,255,"%s.errorScript = UNDEFINED",
self->pName);
}
SCWrite(pCon,pBueffel,eValue);
return 1;
}
/*
catch case for drivername
*/
if(strcmp(argv[1],"driver") == 0)
{
snprintf(pBueffel,255,"%s.driver = %s", self->pName,
self->driverName);
SCWrite(pCon,pBueffel,eValue);
return 1;
}
iRet = EVCGetPar(self,argv[1],&fPos);
if(!iRet)
{
@ -1127,6 +1182,21 @@
}
else /* try to set parameter */
{
/*
first catch case of errorScript
*/
strtolower(argv[1]);
if(strcmp(argv[1],"errorscript") == 0)
{
Arg2Text(argc-2,&argv[2],pBueffel,255);
if(self->errorScript != NULL)
{
free(self->errorScript);
}
self->errorScript = strdup(pBueffel);
SCSendOK(pCon);
return 1;
}
iRet = Tcl_GetDouble(pSics->pTcl,argv[2],&dVal);
if(iRet != TCL_OK)
{
@ -1347,6 +1417,7 @@ static pEVControl InstallCommonControllers(SicsInterp *pSics,
}
}
EVRegisterController(FindEMON(pSics),argv[2],pNew, pCon);
pNew->driverName = strdup(argv[3]);
SCSendOK(pCon);
return 1;
}

View File

@ -1,5 +1,5 @@
#line 211 "evcontroller.w"
#line 222 "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 133 "evcontroller.w"
#line 144 "evcontroller.w"
/*--------------------------- live & death --------------------------------*/
typedef struct __EVControl *pEVControl;
@ -44,6 +44,6 @@
#line 224 "evcontroller.w"
#line 235 "evcontroller.w"
#endif

View File

@ -1,5 +1,5 @@
#line 228 "evcontroller.w"
#line 239 "evcontroller.w"
/*-------------------------------------------------------------------------
Environment controller datastructure
@ -18,6 +18,7 @@
#define MAXWAIT 7
#define SETTLE 8
#line 29 "evcontroller.w"
typedef struct __EVControl {
@ -32,6 +33,8 @@
time_t start;
time_t lastt;
char *pName;
char *driverName;
char *errorScript;
ObPar *pParam;
int iLog;
pVarLog pLog;
@ -42,5 +45,5 @@
void (*KillPrivate)(void *pData);
} EVControl;
#line 244 "evcontroller.w"
#line 257 "evcontroller.w"

View File

@ -41,7 +41,11 @@ $\langle$evdata {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ pEVDriver pDriv;@\\
\mbox{}\verb@ EVMode eMode;@\\
\mbox{}\verb@ float fTarget;@\\
\mbox{}\verb@ time_t start;@\\
\mbox{}\verb@ time_t lastt;@\\
\mbox{}\verb@ char *pName;@\\
\mbox{}\verb@ char *driverName;@\\
\mbox{}\verb@ char *errorScript;@\\
\mbox{}\verb@ ObPar *pParam;@\\
\mbox{}\verb@ int iLog;@\\
\mbox{}\verb@ pVarLog pLog;@\\
@ -69,8 +73,13 @@ 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
controller. Then there is a
device. start and lastt are used to control the settling time.
pName is a pointer to a string representing the name of the
controller. driverName is the name of the driver used by this
device. errorScript is the name of a script command to run when the
controller goes out of tolerance.
Then there is a
parameter array. iLog is a boolean which says if data should be logged
for this controller or not. pLog is the a pointer to a Varlog structure
holding the logging information. Then there is a switch, iWarned, which is
@ -94,6 +103,8 @@ $\langle$evdriv {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ typedef struct __EVDriver {@\\
\mbox{}\verb@ int (*SetValue)(pEVDriver self, float fNew);@\\
\mbox{}\verb@ int (*GetValue)(pEVDriver self, float *fPos);@\\
\mbox{}\verb@ int (*GetValues)(pEVDriver self, float *fTarget,@\\
\mbox{}\verb@ float *fPos, float *fDelta);@\\
\mbox{}\verb@ int (*Send)(pEVDriver self, char *pCommand,@\\
\mbox{}\verb@ char *pReplyBuffer, int iReplBufLen); @\\
\mbox{}\verb@ int (*GetError)(pEVDriver self, int *iCode,@\\
@ -290,6 +301,8 @@ See the documentation for commands understood.
\mbox{}\verb@#define UPLIMIT 4@\\
\mbox{}\verb@#define LOWLIMIT 5@\\
\mbox{}\verb@#define SAFEVALUE 6@\\
\mbox{}\verb@#define MAXWAIT 7@\\
\mbox{}\verb@#define SETTLE 8@\\
\mbox{}\verb@@\\
\mbox{}\verb@@$\langle$evdata {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@@$\diamond$

View File

@ -36,7 +36,11 @@ used by EVControl:
pEVDriver pDriv;
EVMode eMode;
float fTarget;
time_t start;
time_t lastt;
char *pName;
char *driverName;
char *errorScript;
ObPar *pParam;
int iLog;
pVarLog pLog;
@ -57,8 +61,13 @@ 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
controller. Then there is a
device. start and lastt are used to control the settling time.
pName is a pointer to a string representing the name of the
controller. driverName is the name of the driver used by this
device. errorScript is the name of a script command to run when the
controller goes out of tolerance.
Then there is a
parameter array. iLog is a boolean which says if data should be logged
for this controller or not. pLog is the a pointer to a Varlog structure
holding the logging information. Then there is a switch, iWarned, which is
@ -77,6 +86,8 @@ used:
typedef struct __EVDriver {
int (*SetValue)(pEVDriver self, float fNew);
int (*GetValue)(pEVDriver self, float *fPos);
int (*GetValues)(pEVDriver self, float *fTarget,
float *fPos, float *fDelta);
int (*Send)(pEVDriver self, char *pCommand,
char *pReplyBuffer, int iReplBufLen);
int (*GetError)(pEVDriver self, int *iCode,
@ -240,6 +251,8 @@ See the documentation for commands understood.
#define UPLIMIT 4
#define LOWLIMIT 5
#define SAFEVALUE 6
#define MAXWAIT 7
#define SETTLE 8
@<evdata@>
@}

View File

@ -1,5 +1,5 @@
#line 247 "evcontroller.w"
#line 260 "evcontroller.w"
/*-------------------------------------------------------------------------
Environment device driver datastructure
@ -12,7 +12,7 @@
#define DEVREDO 2
#line 76 "evcontroller.w"
#line 85 "evcontroller.w"
typedef struct __EVDriver {
int (*SetValue)(pEVDriver self, float fNew);
@ -30,7 +30,7 @@
void (*KillPrivate)(void *pData);
} EVDriver;
#line 258 "evcontroller.w"
#line 271 "evcontroller.w"
/*-------------------- life & death of a driver --------------------------*/
pEVDriver CreateEVDriver(int argc, char *argv[]);

View File

@ -37,7 +37,6 @@
#define COUNTSTART 10
#define COUNTEND 11
#define FILELOADED 12
#define MOTEND 13
#line 92 "event.w"

152
help.c Normal file
View File

@ -0,0 +1,152 @@
/*-----------------------------------------------------------------------
Implementation file for the SICS help system.
copyright: see file COPYRIGHT
Mark Koennecke, December 2003
-----------------------------------------------------------------------*/
#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include "fortify.h"
#include "sics.h"
#include "help.h"
extern char *stptok(const char *s, char *tok, size_t toklen, char *brk);
/*----------------------------------------------------------------------*/
#define PATHSEP ":"
#define DIRSEP "/"
static char *helpDirs = NULL;
static char *defaultFile="master.txt";
/*----------------------------------------------------------------------*/
void KillHelp(void *pData){
if(helpDirs != NULL){
free(helpDirs);
helpDirs = NULL;
}
if(defaultFile != NULL){
free(defaultFile);
defaultFile = NULL;
}
}
/*-----------------------------------------------------------------------*/
static FILE *findHelpFile(char *name){
FILE *fd = NULL;
char pBueffel[256];
char dir[132];
char *pPtr;
if(helpDirs == NULL){
return NULL;
}
pPtr = helpDirs;
while( (pPtr = stptok(pPtr,dir,131,PATHSEP)) != NULL){
strcpy(pBueffel,dir);
strcat(pBueffel,DIRSEP);
strncat(pBueffel,name,(254-strlen(pBueffel)));
fd = fopen(pBueffel,"r");
if(fd != NULL){
return fd;
}
}
/*
this means: not found!
*/
return NULL;
}
/*----------------------------------------------------------------------*/
static void printHelpFile(SConnection *pCon, FILE *fd){
char line[132];
while(fgets(line,131,fd) != NULL){
SCWrite(pCon,line,eValue);
}
}
/*----------------------------------------------------------------------*/
static void configureHelp(SConnection *pCon,
char *option, char *parameter){
char *pPtr = NULL;
int length;
strtolower(option);
if(strcmp(option,"adddir") == 0){
if(parameter == NULL){
SCWrite(pCon,helpDirs,eValue);
return;
} else {
pPtr = helpDirs;
if(pPtr != NULL){
length = strlen(pPtr) + strlen(PATHSEP) + strlen(parameter) + 2;
helpDirs = (char *)malloc(length*sizeof(char));
memset(helpDirs,0,length*sizeof(char));
strcpy(helpDirs,pPtr);
strcat(helpDirs,PATHSEP);
strcat(helpDirs,parameter);
free(pPtr);
} else {
helpDirs=strdup(parameter);
}
}
} else if(strcmp(option,"defaultfile") == 0){
if(parameter == NULL){
SCWrite(pCon,defaultFile,eValue);
return;
} else {
if(defaultFile != NULL){
free(defaultFile);
}
defaultFile = strdup(parameter);
}
} else {
SCWrite(pCon,"Unknown option to configure",eWarning);
SCWrite(pCon,"Known options: defaultfile, adddir",eWarning);
}
}
/*-----------------------------------------------------------------------*/
int SicsHelp(SConnection *pCon,SicsInterp *pSics, void *pData,
int argc, char *argv[]){
char helpFile[256];
FILE *fd = NULL;
strncpy(helpFile,defaultFile,255);
if(argc > 1){
strtolower(argv[1]);
/*
check for configure
*/
if(strcmp(argv[1],"configure") == 0){
if(argc < 3){
SCWrite(pCon,"ERROR: need an option to configure",eError);
return 0;
}
if(argc > 3){
configureHelp(pCon,argv[2],argv[3]);
} else {
configureHelp(pCon,argv[2],NULL);
}
SCSendOK(pCon);
return 1;
}
/*
the parameter is a help file name
*/
strncpy(helpFile,argv[1],255);
strncat(helpFile,".txt",255);
}
/*
print the helpFile
*/
fd = findHelpFile(helpFile);
if(fd == NULL){
SCWrite(pCon,"ERROR: failed to locate helpFile:",eError);
SCWrite(pCon,helpFile,eError);
return 0;
}
printHelpFile(pCon,fd);
fclose(fd);
}

17
help.h Normal file
View File

@ -0,0 +1,17 @@
/*-----------------------------------------------------------------------
Header file for the SICS help system.
copyright: see file COPYRIGHT
Mark Koennecke, December 2003
-----------------------------------------------------------------------*/
#ifndef SICSHELP
#define SICSHELP
int SicsHelp(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]);
void KillHelp(void *pData);
#endif

37
help.w Normal file
View File

@ -0,0 +1,37 @@
\subsection{The SICS Help System}
SICS has a very simple help system. It is based on plain text files
containing the help texts. There is a default help file which is
printed when help is called without arguments. Other help files are
printed by the command: help name. The name of the text file is then
name.txt. This file is earched in a configurable small set of
directories. This allows to separate general SICS help files and
instrument specific help files.
This system is implemented as a module defined in help.c. The
interface is simply the interpreter function implementing the help
command. There is also a function for removing the data associated
with help.
@o help.h @{
/*-----------------------------------------------------------------------
Header file for the SICS help system.
copyright: see file COPYRIGHT
Mark Koennecke, December 2003
-----------------------------------------------------------------------*/
#ifndef SICSHELP
#define SICSHELP
int SicsHelp(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]);
void KillHelp(void *pData);
#endif
@}

View File

@ -911,7 +911,6 @@ void HistDirty(pHistMem self)
return 0;
}
/*----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
static int HMCountInterest(int iEvent, void *pEvent, void *pUser)
{
SConnection *pCon = NULL;

44
hkl.c
View File

@ -18,6 +18,10 @@
three detectors.
Mark Koennecke, May 2002
Added handling of the chi ==0 or chi == 180 degree case to tryTweakOmega
Mark Koennecke, December 2003
-----------------------------------------------------------------------------*/
#include <math.h>
#include <ctype.h>
@ -35,6 +39,11 @@
the space we leave in omega in order to allow for a scan to be done
*/
#define SCANBORDER 3.
/*
the tolerance in chi we give before we allow to fix omega with phi
*/
#define CHITOLERANCE 3.
#define ABS(x) (x < 0 ? -(x) : (x))
/*-------------------------------------------------------------------------*/
static int HKLSave(void *pData, char *name, FILE *fd)
{
@ -466,9 +475,22 @@ static int checkNormalBeam(double om, double *gamma, double nu,
}
return 0;
}
/*--------------------------------------------------------------------*/
static int chiVertical(double chi){
if(ABS(chi - .0) < CHITOLERANCE){
return 1;
}
if(ABS(chi - 180.0) < CHITOLERANCE){
return 1;
}
return 0;
}
/*-----------------------------------------------------------------------
tryOmegaTweak tries to calculate a psi angle in order to put an
offending omega back into range.
This routine also handles the special case when chi ~ 0 or chi ~ 180.
Then it is possible to fix a omega problem by turing in phi.
-----------------------------------------------------------------------*/
static int tryOmegaTweak(pHKL self, MATRIX z1, double *stt, double *om,
double *chi, double *phi){
@ -506,6 +528,22 @@ static int tryOmegaTweak(pHKL self, MATRIX z1, double *stt, double *om,
omOffset = *om - omTarget;
omOffset = -omOffset;
/*
check for the special case of chi == 0 or chi == 180
*/
if(chiVertical(*chi)){
dumstt = *stt;
offom = omTarget;
offchi = *chi;
offphi = *phi - omOffset;
if(checkBisecting(self,&dumstt,offom,offchi,offphi)){
*om = offom;
*chi = offchi;
*phi = offphi;
return 1;
}
}
/*
calculate angles with omega offset
*/
@ -622,8 +660,6 @@ static int calculateBisecting(MATRIX z1, pHKL self, SConnection *pCon,
return 0;
}
/*----------------------------------------------------------------------*/
#define ABS(x) (x < 0 ? -(x) : (x))
/*-----------------------------------------------------------------------*/
static int calculateNormalBeam(MATRIX z1, pHKL self, SConnection *pCon,
float fSet[4], double myPsi, int iRetry)
@ -1508,14 +1544,14 @@ ente:
}
else
{
sprintf(pBueffel," theta = %f, omega = %f, chi = %f, phi = %f",
sprintf(pBueffel," 2-theta = %f, omega = %f, chi = %f, phi = %f",
fSet[0], fSet[1], fSet[2],fSet[3]);
SCWrite(pCon,pBueffel,eValue);
}
if(!iRet)
{
SCWrite(pCon,
"WARNING: Settings violate motor limits or cannot be calculated",
"WARNING: Cannot drive to the hkl of your desire",
eWarning);
return 0;
}

View File

@ -31,7 +31,6 @@ the maximum number of slaves
int nSlaves;
float fPreset;
CounterMode eMode;
pICallBack pCall;
} HMcontrol, *pHMcontrol;

View File

@ -19,10 +19,10 @@ SOBJ = network.o ifile.o conman.o SCinter.o splitter.o passwd.o \
histmem.o histdriv.o histsim.o interface.o callback.o \
event.o emon.o evcontroller.o evdriver.o simev.o perfmon.o \
danu.o nxdict.o varlog.o stptok.o nread.o \
scan.o fitcenter.o telnet.o token.o \
scan.o fitcenter.o telnet.o token.o wwildcard.o\
tclev.o hkl.o integrate.o optimise.o dynstring.o nxutil.o \
mesure.o uubuffer.o commandlog.o udpquieck.o \
rmtrail.o \
rmtrail.o help.o nxupdate.o\
simchop.o choco.o chadapter.o trim.o scaldate.o \
hklscan.o xytable.o \
circular.o maximize.o sicscron.o \

49
napi5.c
View File

@ -121,7 +121,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
unsigned int vers_major, vers_minor, vers_release, am1 ;
hid_t fapl;
int mdc_nelmts;
int rdcc_nelmts;
unsigned long rdcc_nelmts;
size_t rdcc_nbytes;
double rdcc_w0;
@ -343,7 +343,26 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
pFile=NXI5assert(*fid);
iRet=0;
/*
printf("HDF5 object count before close: %d\n",
H5Fget_obj_count(pFile->iFID,H5F_OBJ_ALL));
*/
iRet = H5Fclose(pFile->iFID);
/*
Please leave this here, it helps debugging HDF5 resource leakages
printf("HDF5 object count after close: %d\n",
H5Fget_obj_count(H5F_OBJ_ALL,H5F_OBJ_ALL));
printf("HDF5 dataset count after close: %d\n",
H5Fget_obj_count(H5F_OBJ_ALL,H5F_OBJ_DATASET));
printf("HDF5 group count after close: %d\n",
H5Fget_obj_count(H5F_OBJ_ALL,H5F_OBJ_GROUP));
printf("HDF5 datatype count after close: %d\n",
H5Fget_obj_count(H5F_OBJ_ALL,H5F_OBJ_DATATYPE));
printf("HDF5 attribute count after close: %d\n",
H5Fget_obj_count(H5F_OBJ_ALL,H5F_OBJ_ATTR));
*/
if (iRet < 0) {
NXIReportError (NXpData, "ERROR: HDF cannot close HDF file");
}
@ -368,16 +387,17 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
pNexusFile5 pFile;
hid_t iRet;
hid_t attr1,aid1, aid2;
char pBuffer[1024];
char pBuffer[1024] = "";
pFile = NXI5assert (fid);
/* create and configure the group */
if (pFile->iCurrentG==0)
{
iRet = H5Gcreate(pFile->iFID,(const char*)name, 0);
snprintf(pBuffer,1023,"/%s",name);
} else
{
sprintf(pBuffer,"/%s/%s",pFile->name_ref,name);
snprintf(pBuffer,1023,"/%s/%s",pFile->name_ref,name);
iRet = H5Gcreate(pFile->iFID,(const char*)pBuffer, 0);
}
if (iRet < 0) {
@ -385,7 +405,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
return NX_ERROR;
}
pFile->iVID = iRet;
strcpy(pFile->name_ref,pBuffer);
strncpy(pFile->name_ref,pBuffer,1023);
aid2 = H5Screate(H5S_SCALAR);
aid1 = H5Tcopy(H5T_C_S1);
H5Tset_size(aid1, strlen(nxclass));
@ -840,10 +860,9 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
NXstatus CALLING_STYLE NX5putdata (NXhandle fid, void *data)
{
pNexusFile5 pFile;
NXname pBuffer;
hid_t iRet;
char pError[512];
char pError[512] = "";
pFile = NXI5assert (fid);
@ -851,7 +870,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
iRet = H5Dwrite (pFile->iCurrentD, pFile->iCurrentT, H5S_ALL, H5S_ALL,
H5P_DEFAULT, data);
if (iRet < 0) {
sprintf (pError, "ERROR: failure to write data to %s", pBuffer);
snprintf (pError,511, "ERROR: failure to write data");
NXIReportError (NXpData, pError);
return NX_ERROR;
}
@ -1328,6 +1347,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
*datatype=iPtype;
strcpy(nxclass, "SDS");
H5Tclose(atype);
H5Tclose(type);
H5Dclose(grp);
}
return NX_OK;
@ -1355,7 +1375,7 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
NXstatus CALLING_STYLE NX5getdata (NXhandle fid, void *data)
{
pNexusFile5 pFile;
int iStart[H5S_MAX_RANK];
int iStart[H5S_MAX_RANK], status;
hid_t data_id, memtype_id, size_id, sign_id;
int dims;
@ -1418,7 +1438,18 @@ NXstatus CALLING_STYLE NX5closegroup (NXhandle fid);
}
/* actually read */
H5Dread (pFile->iCurrentD, memtype_id, H5S_ALL, H5S_ALL,H5P_DEFAULT, data);
status = H5Dread (pFile->iCurrentD, memtype_id,
H5S_ALL, H5S_ALL,H5P_DEFAULT, data);
if(data_id == H5T_STRING)
{
H5Tclose(memtype_id);
}
if(status < 0)
{
NXIReportError (NXpData, "ERROR: failed to transfer dataset");
return NX_ERROR;
}
return NX_OK;
}

View File

@ -32,7 +32,6 @@
mkChannel *pServerPort;
pNetRead pReader;
int simMode;
SConnection *dummyCon;
} SicsServer;

385
nxdict.c
View File

@ -1,4 +1,6 @@
#line 2264 "nxdict.w"
/*---------------------------------------------------------------------------
Nexus Dictionary API implementation file.
@ -18,24 +20,14 @@
August, 1997
Version: 1.0
Version 1.1
Updated to use the combined HDF4 HDF5 API. New keyword -chunk which
defines the chunk buffer size for a SDS.
Mark Koennecke, August 2001
-----------------------------------------------------------------------------*/
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <time.h>
#include <mfhdf.h>
#include "fortify.h"
#include "lld.h"
#include "napi.h"
#include "stringdict.h"
@ -49,13 +41,14 @@
extern void *NXpData;
extern void (*NXIReportError)(void *pData, char *pBuffer);
/*--------------------------------------------------------------------------*/
/* #define DEFDEBUG 1 */
#define DEFDEBUG 1
/* define DEFDEBUG when you wish to print your definition strings before
action. This can help a lot to resolve mysteries when working with
dictionaries.
*/
/*-------------------------------------------------------------------------*/
#line 362 "nxdict.w"
typedef struct __NXdict
{
@ -65,6 +58,7 @@
/*------------------ verbosity level -------------------------------------*/
static int iVerbosity = 0 ;
#line 2311 "nxdict.w"
/*-------------------------------------------------------------------------*/
static char *NXDIReadFile(FILE *fd)
@ -106,6 +100,7 @@
}
/*--------------------------------------------------------------------------*/
#line 490 "nxdict.w"
#define FWORD 1
#define FHASH 2
@ -178,9 +173,11 @@
}
#line 2351 "nxdict.w"
/*------------------------------------------------------------------------*/
#line 566 "nxdict.w"
#define AMODE 0
#define DMODE 1
@ -269,6 +266,7 @@
}
}
#line 2353 "nxdict.w"
/*--------------------------------------------------------------------------*/
NXstatus NXDinitfromfile(char *filename, NXdict *pData)
@ -279,6 +277,7 @@
char pError[512];
#line 383 "nxdict.w"
/* allocate a new NXdict structure */
if(iVerbosity == NXalot)
@ -303,6 +302,10 @@
}
#line 2362 "nxdict.w"
#line 410 "nxdict.w"
/* is there a file name argument */
if(filename == NULL)
@ -315,6 +318,10 @@
return NX_OK;
}
#line 2363 "nxdict.w"
#line 424 "nxdict.w"
fd = fopen(filename,"rb");
if(!fd)
@ -327,6 +334,12 @@
}
#line 2364 "nxdict.w"
#line 444 "nxdict.w"
/* read the file contents */
if(iVerbosity == NXalot)
{
@ -350,6 +363,8 @@
}
NXDIParse(pBuffer, pNew->pDictionary);
#line 2365 "nxdict.w"
if(iVerbosity == NXalot)
{
@ -361,6 +376,8 @@
}
/*--------------------------------------------------------------------------*/
#line 660 "nxdict.w"
NXdict NXDIAssert(NXdict handle)
{
NXdict self = NULL;
@ -370,9 +387,12 @@
return self;
}
#line 2376 "nxdict.w"
/*-------------------------------------------------------------------------*/
#line 671 "nxdict.w"
NXstatus NXDclose(NXdict handle, char *filename)
{
NXdict self;
@ -421,8 +441,12 @@
return NX_OK;
}
#line 2378 "nxdict.w"
/*------------------------------------------------------------------------*/
#line 724 "nxdict.w"
NXstatus NXDadd(NXdict handle, char *alias, char *pDef)
{
NXdict self;
@ -467,7 +491,14 @@
}
return NX_OK;
}
#line 2380 "nxdict.w"
/*-----------------------------------------------------------------------*/
#line 776 "nxdict.w"
#define NORMAL 1
#define ALIAS 2
pDynString NXDItextreplace(NXdict handle, char *pDefString)
@ -564,12 +595,23 @@
return NX_OK;
}
#line 2382 "nxdict.w"
/*------------------- The Defintion String Parser -----------------------*/
/*------- Data structures */
#line 886 "nxdict.w"
typedef struct {
char pText[20];
int iCode;
} TokDat;
#line 2385 "nxdict.w"
#line 896 "nxdict.w"
#define TERMSDS 100
#define TERMVG 200
#define TERMLINK 300
@ -583,15 +625,32 @@
int iTerminal;
} ParDat;
#line 2386 "nxdict.w"
#line 1101 "nxdict.w"
static void DummyError(void *pData, char *pError)
{
return;
}
#line 2387 "nxdict.w"
#line 1215 "nxdict.w"
typedef struct {
char name[256];
char value[256];
}AttItem;
#line 2388 "nxdict.w"
/*------------------------------------------------------------------------*/
#line 918 "nxdict.w"
/*---------------- Token name defines ---------------------------*/
#define DSLASH 0
#define DKOMMA 1
@ -606,14 +665,10 @@
#define DCLOSE 11
#define DATTR 12
#define DEND 13
#define DLZW 14
#define DHUF 15
#define DRLE 16
#define CHUNK 17
/*----------------- Keywords ----------------------------------------*/
static TokDat TokenList[12] = {
static TokDat TokenList[8] = {
{"SDS",DSDS},
{"NXLINK",DLINK},
{"NXVGROUP",DGROUP},
@ -621,11 +676,7 @@
{"-type",DTYPE},
{"-rank",DRANK},
{"-attr",DATTR},
{"-chunk",CHUNK},
{"-LZW",DLZW},
{"-HUF",DHUF},
{"-RLE",DRLE},
{NULL,0} };
{"",0} };
/*-----------------------------------------------------------------------*/
static void NXDIDefToken(ParDat *sStat)
@ -693,7 +744,7 @@
sStat->pToken[i] = '\0';
/*--------- try to find word in Tokenlist */
for(i = 0; i < 10; i++)
for(i = 0; i < 7; i++)
{
if(strcmp(sStat->pToken,TokenList[i].pText) == 0)
{
@ -708,8 +759,12 @@
}
#line 2390 "nxdict.w"
/*------------------------------------------------------------------------*/
#line 1114 "nxdict.w"
int NXDIParsePath(NXhandle hfil, ParDat *pParse)
{
int iRet, iToken;
@ -800,8 +855,12 @@
return NX_ERROR;
}
#line 2392 "nxdict.w"
/*------------------------------------------------------------------------*/
#line 1481 "nxdict.w"
static int NXDIParseAttr(ParDat *pParse, int iList)
{
char pError[256];
@ -860,7 +919,12 @@
return NX_OK;
}
#line 2394 "nxdict.w"
/*------------------------------------------------------------------------*/
#line 1428 "nxdict.w"
static int NXDIParseDim(ParDat *pParse, int *iDim)
{
char pError[256];
@ -908,7 +972,13 @@
}
return NX_OK;
}
#line 2396 "nxdict.w"
/*------------------------------------------------------------------------*/
#line 1379 "nxdict.w"
static TokDat tDatType[] = {
{"DFNT_FLOAT32",DFNT_FLOAT32},
{"DFNT_FLOAT64",DFNT_FLOAT64},
@ -918,8 +988,7 @@
{"DFNT_UINT16",DFNT_UINT16},
{"DFNT_INT32",DFNT_INT32},
{"DFNT_UINT32",DFNT_UINT32},
{"DFNT_CHAR",DFNT_CHAR},
{NULL,-122} };
{"",0} };
@ -954,15 +1023,19 @@
return NX_ERROR;
}
#line 2398 "nxdict.w"
/*-------------------------------------------------------------------------*/
#line 1223 "nxdict.w"
static int NXDIParseSDS(NXhandle hfil, ParDat *pParse)
{
int iType = DFNT_FLOAT32;
int iRank = 1;
int iCompress = NX_COMP_NONE;
int32 iDim[MAX_VAR_DIMS], iChunk[MAX_VAR_DIMS];
int iList, iChunkDefined = 0 ;
int iRet, iStat, i;
int32 iDim[MAX_VAR_DIMS];
int iList;
int iRet, iStat;
char pError[256];
char pName[MAX_NC_NAME];
void (*ErrFunc)(void *pData, char *pErr);
@ -1006,17 +1079,8 @@
}
iRank = atoi(pParse->pToken);
break;
case CHUNK: /* chunk size for compression */
iRet = NXDIParseDim(pParse, iChunk);
if(iRet == NX_ERROR)
{
LLDdelete(iList);
return iRet;
}
iChunkDefined = 1;
break;
case DDIM:
iRet = NXDIParseDim(pParse, iDim);
iRet = NXDIParseDim (pParse, (int *) iDim);
if(iRet == NX_ERROR)
{
LLDdelete(iList);
@ -1039,15 +1103,6 @@
return iRet;
}
break;
case DLZW:
iCompress = NX_COMP_LZW;
break;
case DRLE:
iCompress = NX_COMP_RLE;
break;
case DHUF:
iCompress = NX_COMP_HUF;
break;
case DEND:
break;
default:
@ -1061,18 +1116,7 @@
NXDIDefToken(pParse);
}
/* whew! got all information for doing the SDS
However, if the chunk sizes for compression have not
been set, default them to the dimensions of the data set
*/
if(iChunkDefined == 0)
{
for(i = 0; i < iRank; i++)
{
iChunk[i] = iDim[i];
}
}
/* whew! got all information for doing the SDS */
/* first install dummy error handler, try open it, then
deinstall again and create if allowed
*/
@ -1092,8 +1136,7 @@
/* we need to create it, if we may */
if(pParse->iMayCreate)
{
iRet = NXcompmakedata(hfil,pName,iType, iRank,iDim,
iCompress,iChunk);
iRet = NXmakedata (hfil, pName, iType, iRank, (int *) iDim);
if(iRet != NX_OK)
{
/* a comment on this one has already been written! */
@ -1107,7 +1150,6 @@
LLDdelete(iList);
return iRet;
}
/* put attributes in */
iRet = LLDnodePtr2First(iList);
while(iRet != 0)
@ -1137,7 +1179,13 @@
}
return NX_OK;
}
#line 2400 "nxdict.w"
/*------------------------------------------------------------------------*/
#line 1544 "nxdict.w"
static int NXDIParseLink(NXhandle hfil, NXdict pDict,ParDat *pParse)
{
char pError[256];
@ -1166,8 +1214,14 @@
return NXDopenalias(hfil, pDict, pParse->pToken);
}
#line 2402 "nxdict.w"
/*------------------------------------------------------------------------*/
int NXDIDefParse(NXhandle hFil, NXdict pDict, ParDat *pParse)
#line 1034 "nxdict.w"
static int NXDIDefParse(NXhandle hFil, NXdict pDict, ParDat *pParse)
{
int iRet;
char pError[256];
@ -1217,8 +1271,14 @@
}
return NX_OK;
}
#line 2404 "nxdict.w"
/*----------------------------------------------------------------------*/
NXstatus NXDIUnwind(NXhandle hFil, int iDepth)
#line 1576 "nxdict.w"
static NXstatus NXDIUnwind(NXhandle hFil, int iDepth)
{
int i, iRet;
@ -1232,7 +1292,13 @@
}
return NX_OK;
}
#line 2406 "nxdict.w"
/*-------------------- The Data Transfer Functions ----------------------*/
#line 1597 "nxdict.w"
NXstatus NXDopendef(NXhandle hfil, NXdict dict, char *pDef)
{
NXdict pDict;
@ -1266,18 +1332,24 @@
/* do not rewind on links */
return iRet;
}
#line 2408 "nxdict.w"
/*------------------------------------------------------------------------*/
#line 1637 "nxdict.w"
NXstatus NXDopenalias(NXhandle hfil, NXdict dict, char *pAlias)
{
NXdict pDict;
int iRet;
char pDefinition[2048];
char pDefinition[1024];
pDynString pReplaced = NULL;
pDict = NXDIAssert(dict);
/* get Definition String */
iRet = NXDget(pDict,pAlias,pDefinition,2047);
iRet = NXDget(pDict,pAlias,pDefinition,1023);
if(iRet != NX_OK)
{
sprintf(pDefinition,"ERROR: alias %s not recognized",pAlias);
@ -1297,7 +1369,13 @@
DeleteDynString(pReplaced);
return iRet;
}
#line 2410 "nxdict.w"
/*------------------------------------------------------------------------*/
#line 1674 "nxdict.w"
NXstatus NXDputdef(NXhandle hFil, NXdict dict, char *pDef, void *pData)
{
NXdict pDict;
@ -1344,18 +1422,24 @@
}
return iStat;
}
#line 2412 "nxdict.w"
/*------------------------------------------------------------------------*/
#line 1725 "nxdict.w"
NXstatus NXDputalias(NXhandle hFil, NXdict dict, char *pAlias, void *pData)
{
NXdict pDict;
int iRet;
char pDefinition[2048];
char pDefinition[1024];
pDynString pReplaced = NULL;
pDict = NXDIAssert(dict);
/* get Definition String */
iRet = NXDget(pDict,pAlias,pDefinition,2047);
iRet = NXDget(pDict,pAlias,pDefinition,1023);
if(iRet != NX_OK)
{
sprintf(pDefinition,"ERROR: alias %s not recognized",pAlias);
@ -1375,7 +1459,13 @@
DeleteDynString(pReplaced);
return iRet;
}
#line 2414 "nxdict.w"
/*------------------------------------------------------------------------*/
#line 1760 "nxdict.w"
NXstatus NXDgetdef(NXhandle hFil, NXdict dict, char *pDef, void *pData)
{
NXdict pDict;
@ -1424,18 +1514,23 @@
return iStat;
}
#line 2416 "nxdict.w"
/*------------------------------------------------------------------------*/
#line 1812 "nxdict.w"
NXstatus NXDgetalias(NXhandle hFil, NXdict dict, char *pAlias, void *pData)
{
NXdict pDict;
int iRet;
char pDefinition[2048];
char pDefinition[1024];
pDynString pReplaced = NULL;
pDict = NXDIAssert(dict);
/* get Definition String */
iRet = NXDget(pDict,pAlias,pDefinition,2047);
iRet = NXDget(pDict,pAlias,pDefinition,1023);
if(iRet != NX_OK)
{
sprintf(pDefinition,"ERROR: alias %s not recognized",pAlias);
@ -1455,92 +1550,13 @@
DeleteDynString(pReplaced);
return iRet;
}
/*------------------------------------------------------------------------*/
NXstatus NXDinfodef(NXhandle hFil, NXdict dict, char *pDef, int *rank,
int dimension[], int *iType)
{
NXdict pDict;
ParDat pParse;
int iRet, i, iStat;
pDict = NXDIAssert(dict);
/* parse and act on definition string */
pParse.iMayCreate = 0;
pParse.pPtr = pDef;
pParse.iDepth = 0;
#ifdef DEFDEBUG
printf("Getting: %s\n",pDef);
#endif
iRet = NXDIDefParse(hFil,pDict,&pParse);
if(iRet == NX_ERROR)
{
/* unwind and throw up */
NXDIUnwind(hFil,pParse.iDepth);
return NX_ERROR;
}
/* only SDS can be written */
if(pParse.iTerminal != TERMSDS)
{
NXIReportError(NXpData,
"ERROR: can only write to an SDS!");
iStat = NX_ERROR;
}
else
{
/* the SDS should be open by now, read it */
iStat = NXgetinfo(hFil, rank,dimension, iType);
iRet = NXclosedata(hFil);
}
/* rewind the hierarchy */
iRet = NXDIUnwind(hFil,pParse.iDepth);
if(iRet != NX_OK)
{
return NX_ERROR;
}
return iStat;
}
#line 2418 "nxdict.w"
/*------------------------------------------------------------------------*/
NXstatus NXDinfoalias(NXhandle hFil, NXdict dict, char *pAlias, int *rank,
int dimension[], int *iType)
{
NXdict pDict;
int iRet;
char pDefinition[2048];
pDynString pReplaced = NULL;
#line 1849 "nxdict.w"
pDict = NXDIAssert(dict);
/* get Definition String */
iRet = NXDget(pDict,pAlias,pDefinition,2047);
if(iRet != NX_OK)
{
sprintf(pDefinition,"ERROR: alias %s not recognized",pAlias);
NXIReportError(NXpData,pDefinition);
return NX_ERROR;
}
/* do text replacement */
pReplaced = NXDItextreplace(dict,pDefinition);
if(!pReplaced)
{
return NX_ERROR;
}
/* call NXDgetdef */
iRet = NXDinfodef(hFil,dict,GetCharArray(pReplaced),rank,dimension,iType);
DeleteDynString(pReplaced);
return iRet;
}
/*------------------------------------------------------------------------*/
NXstatus NXDdeflink(NXhandle hFil, NXdict dict,
char *pTarget, char *pVictim)
{
@ -1629,7 +1645,7 @@
NXstatus NXDaliaslink(NXhandle hFil, NXdict dict,
char *pTarget, char *pVictim)
{
char pTargetDef[2048], pVictimDef[2048];
char pTargetDef[1024], pVictimDef[1024];
int iRet;
NXdict pDict;
pDynString pRep1 = NULL, pRep2 = NULL;
@ -1637,7 +1653,7 @@
pDict = NXDIAssert(dict);
/* get Target Definition String */
iRet = NXDget(pDict,pTarget,pTargetDef,2047);
iRet = NXDget(pDict,pTarget,pTargetDef,1023);
if(iRet != NX_OK)
{
sprintf(pTargetDef,"ERROR: alias %s not recognized",pTarget);
@ -1646,7 +1662,7 @@
}
/* get Victim definition string */
iRet = NXDget(pDict,pVictim,pVictimDef,2047);
iRet = NXDget(pDict,pVictim,pVictimDef,1023);
if(iRet != NX_OK)
{
sprintf(pTargetDef,"ERROR: alias %s not recognized",pTarget);
@ -1672,6 +1688,14 @@
DeleteDynString(pRep2);
return iRet;
}
#line 2420 "nxdict.w"
/*-----------------------------------------------------------------------*/
#line 1986 "nxdict.w"
/*-------------------------------------------------------------------------*/
static void SNXFormatTime(char *pBuffer, int iBufLen)
{
@ -1682,7 +1706,7 @@
iDate = time(NULL);
psTime = localtime(&iDate);
memset(pBuffer,0,iBufLen);
strftime(pBuffer,iBufLen,"%Y-%m-%d %H:%M:%S",psTime);
strftime(pBuffer,iBufLen,"%Y-%d-%m %H:%M:%S",psTime);
}
/*--------------------------------------------------------------------------*/
NXstatus NXUwriteglobals(NXhandle pFile,
@ -1697,28 +1721,26 @@
char pBueffel[512];
int iStat;
/* store global attributes, now done by NXopen
/* store global attributes */
iStat = NXputattr(pFile,"file_name",filename,
strlen(filename)+1,NX_CHAR);
strlen(filename)+1,DFNT_INT8);
if(iStat == NX_ERROR)
{
return NX_ERROR;
}
*/
/* write creation time, now done by NXopen
/* write creation time */
SNXFormatTime(pBueffel,512);
iStat = NXputattr(pFile,"file_time",pBueffel,
strlen(pBueffel)+1,NX_CHAR);
strlen(pBueffel)+1,DFNT_INT8);
if(iStat == NX_ERROR)
{
return NX_ERROR;
}
*/
/* instrument name */
iStat = NXputattr(pFile,"instrument",instrument,
strlen(instrument)+1,NX_CHAR);
strlen(instrument)+1,DFNT_INT8);
if(iStat == NX_ERROR)
{
return iStat;
@ -1726,7 +1748,7 @@
/* owner */
iStat = NXputattr(pFile,"owner",owner,
strlen(owner)+1,NX_CHAR);
strlen(owner)+1,DFNT_INT8);
if(iStat == NX_ERROR)
{
return iStat;
@ -1734,7 +1756,7 @@
/* Adress */
iStat = NXputattr(pFile,"owner_adress",adress,
strlen(adress)+1,NX_CHAR);
strlen(adress)+1,DFNT_INT8);
if(iStat == NX_ERROR)
{
return iStat;
@ -1742,7 +1764,7 @@
/* phone */
iStat = NXputattr(pFile,"owner_telephone_number",phone,
strlen(phone)+1,NX_CHAR);
strlen(phone)+1,DFNT_INT8);
if(iStat == NX_ERROR)
{
return iStat;
@ -1750,7 +1772,7 @@
/* fax */
iStat = NXputattr(pFile,"owner_fax_number",fax,
strlen(fax)+1,NX_CHAR);
strlen(fax)+1,DFNT_INT8);
if(iStat == NX_ERROR)
{
return iStat;
@ -1758,14 +1780,20 @@
/* email */
iStat = NXputattr(pFile,"owner_email",email,
strlen(email)+1,NX_CHAR);
strlen(email)+1,DFNT_INT8);
if(iStat == NX_ERROR)
{
return iStat;
}
return NX_OK;
}
#line 2422 "nxdict.w"
/*-----------------------------------------------------------------------*/
#line 2082 "nxdict.w"
NXstatus NXUentergroup(NXhandle hFil, char *name, char *class)
{
void (*ErrFunc)(void *pData, char *pErr);
@ -1800,7 +1828,13 @@
}
return NX_OK;
}
#line 2424 "nxdict.w"
/*-----------------------------------------------------------------------*/
#line 2119 "nxdict.w"
NXstatus NXUenterdata(NXhandle hFil, char *label, int datatype,
int rank, int dim[], char *pUnits)
{
@ -1843,7 +1877,13 @@
}
return NX_OK;
}
#line 2426 "nxdict.w"
/*-----------------------------------------------------------------------*/
#line 2165 "nxdict.w"
NXstatus NXUallocSDS(NXhandle hFil, void **pData)
{
int iDIM[MAX_VAR_DIMS];
@ -1873,8 +1913,6 @@
lLength *= sizeof(float64);
break;
case DFNT_INT8:
case DFNT_CHAR:
case DFNT_UCHAR8:
lLength *= sizeof(int8);
break;
case DFNT_UINT8:
@ -1905,10 +1943,15 @@
NXIReportError(NXpData,"ERROR: memory exhausted in NXUallocSDS");
return NX_ERROR;
}
memset(*pData,0,lLength);
return NX_OK;
}
#line 2428 "nxdict.w"
/*----------------------------------------------------------------------*/
#line 2229 "nxdict.w"
NXstatus NXUfreeSDS(void **pData)
{
free(*pData);
@ -1916,3 +1959,5 @@
return NX_OK;
}
#line 2430 "nxdict.w"

View File

@ -49,12 +49,6 @@
char *alias, void *pData);
NXstatus NXDgetdef(NXhandle file, NXdict dict, char *pDefString, void *pData);
NXstatus NXDinfoalias(NXhandle hFil, NXdict dict, char *pAlias, int *rank,
int dimension[], int *iType);
NXstatus NXDinfodef(NXhandle hFil, NXdict dict, char *pDef, int *rank,
int dimension[], int *iType);
NXstatus NXDaliaslink(NXhandle file, NXdict dict,
char *pAlias1, char *pAlias2);
NXstatus NXDdeflink(NXhandle file, NXdict dict,

View File

@ -194,7 +194,7 @@ NexUs API which holds the dictionary information within a NeXus file.
One additional data type is needed for this API:
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap1}
$\langle$tata {\footnotesize 4a}$\rangle\equiv$
$\langle$tata {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
@ -213,7 +213,7 @@ NXdict will be used as a handle for the dictionary currently in use.
\subsubsection{Dictionary Maintainance Function}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap2}
$\langle$dicman {\footnotesize 4b}$\rangle\equiv$
$\langle$dicman {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
@ -264,7 +264,7 @@ $\langle$dicman {\footnotesize 4b}$\rangle\equiv$
\subsubsection{Data Handling functions}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap3}
$\langle$dicdata {\footnotesize 5}$\rangle\equiv$
$\langle$dicdata {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
@ -347,7 +347,7 @@ The NXDICT data handling functions go in pairs. The version ending in
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap4}
$\langle$dicutil {\footnotesize 6}$\rangle\equiv$
$\langle$dicutil {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
@ -411,7 +411,7 @@ the current approach poses a serious performance problem.
Thus, the NXdict data structure looks like this:
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap5}
$\langle$dicdat {\footnotesize 7}$\rangle\equiv$
$\langle$dicdat {\footnotesize ?}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@\\
@ -1155,7 +1155,7 @@ $\langle$deftok {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ {"-type",DTYPE},@\\
\mbox{}\verb@ {"-rank",DRANK},@\\
\mbox{}\verb@ {"-attr",DATTR},@\\
\mbox{}\verb@ {NULL,0} };@\\
\mbox{}\verb@ {"",0} };@\\
\mbox{}\verb@@\\
\mbox{}\verb@/*-----------------------------------------------------------------------*/@\\
\mbox{}\verb@ static void NXDIDefToken(ParDat *sStat)@\\
@ -1543,7 +1543,7 @@ $\langle$nxpasds {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ iRank = atoi(pParse->pToken);@\\
\mbox{}\verb@ break;@\\
\mbox{}\verb@ case DDIM:@\\
\mbox{}\verb@ iRet = NXDIParseDim(pParse, iDim);@\\
\mbox{}\verb@ iRet = NXDIParseDim (pParse, (int *) iDim);@\\
\mbox{}\verb@ if(iRet == NX_ERROR)@\\
\mbox{}\verb@ {@\\
\mbox{}\verb@ LLDdelete(iList);@\\
@ -1599,7 +1599,7 @@ $\langle$nxpasds {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ /* we need to create it, if we may */@\\
\mbox{}\verb@ if(pParse->iMayCreate)@\\
\mbox{}\verb@ {@\\
\mbox{}\verb@ iRet = NXmakedata(hfil,pName,iType, iRank,iDim);@\\
\mbox{}\verb@ iRet = NXmakedata (hfil, pName, iType, iRank, (int *) iDim);@\\
\mbox{}\verb@ if(iRet != NX_OK)@\\
\mbox{}\verb@ { @\\
\mbox{}\verb@ /* a comment on this one has already been written! */@\\
@ -1669,7 +1669,7 @@ $\langle$parsetype {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ {"DFNT_UINT16",DFNT_UINT16},@\\
\mbox{}\verb@ {"DFNT_INT32",DFNT_INT32},@\\
\mbox{}\verb@ {"DFNT_UINT32",DFNT_UINT32},@\\
\mbox{}\verb@ {NULL,-122} };@\\
\mbox{}\verb@ {"",0} };@\\
\mbox{}\verb@@\\
\mbox{}\verb@@\\
\mbox{}\verb@@\\
@ -2737,15 +2737,15 @@ $\langle$free {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@#include "napi.h" /* make sure, napi is included */@\\
\mbox{}\verb@@\\
\mbox{}\verb@/*-------------------- NXDict data types & defines ----------------------*/@\\
\mbox{}\verb@@$\langle$tata {\footnotesize 4a}$\rangle$\verb@@\\
\mbox{}\verb@@$\langle$tata {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@#define NXquiet 0@\\
\mbox{}\verb@#define NXalot 1@\\
\mbox{}\verb@/*-------------------- Dictionary Maintainance ----------------------------*/@\\
\mbox{}\verb@@$\langle$dicman {\footnotesize 4b}$\rangle$\verb@@\\
\mbox{}\verb@@$\langle$dicman {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@/*----------------- Dictionary added data transfer -----------------------*/ @\\
\mbox{}\verb@@$\langle$dicdata {\footnotesize 5}$\rangle$\verb@@\\
\mbox{}\verb@@$\langle$dicdata {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@/*-------------------- Utility Functions --------------------------------*/@\\
\mbox{}\verb@@$\langle$dicutil {\footnotesize 6}$\rangle$\verb@@\\
\mbox{}\verb@@$\langle$dicutil {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@#endif@\\
\mbox{}\verb@@$\diamond$
\end{list}
@ -2804,7 +2804,7 @@ $\langle$free {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ dictionaries.@\\
\mbox{}\verb@*/@\\
\mbox{}\verb@/*-------------------------------------------------------------------------*/@\\
\mbox{}\verb@@$\langle$dicdat {\footnotesize 7}$\rangle$\verb@@\\
\mbox{}\verb@@$\langle$dicdat {\footnotesize ?}$\rangle$\verb@@\\
\mbox{}\verb@/*-------------------------------------------------------------------------*/@\\
\mbox{}\verb@ static char *NXDIReadFile(FILE *fd)@\\
\mbox{}\verb@ {@\\

View File

@ -234,6 +234,34 @@ static void putCounter(SConnection *pCon, SicsInterp *pSics, pNXScript self,
return;
}
/*----------------------------------------------------------------------*/
static void updateHMDim(NXScript *self, pHistMem mem){
int iDim[MAXDIM];
int i, rank, timeLength, status;
char dummy[40], value[20];
const float *timeBin;
/*
update the dimension variables in the dictionary
*/
GetHistDim(mem,iDim,&rank);
for(i = 0; i < rank; i++){
sprintf(dummy,"dim%1.1d", i);
sprintf(value,"%d",iDim[i]);
status = NXDupdate(self->dictHandle,dummy,value);
if(status == 0) {
NXDadd(self->dictHandle,dummy,value);
}
}
timeBin = GetHistTimeBin(mem,&timeLength);
if(timeLength > 2){
sprintf(dummy,"%d",timeLength);
status = NXDupdate(self->dictHandle,"timedim",dummy);
if(status == 0) {
NXDadd(self->dictHandle,"timedim",dummy);
}
}
}
/*----------------------------------------------------------------------
The sequence of things is important in here: The code for updating
the dimensions variables also applies the time binning to the length.
@ -244,11 +272,9 @@ static void putHistogramMemory(SConnection *pCon, SicsInterp *pSics,
pNXScript self,
int argc, char *argv[]){
pHistMem mem = NULL;
int status, start, length, iDim[MAXDIM], rank, i, subset = 0;
int status, start, length, i, subset = 0;
HistInt *iData = NULL;
char buffer[256], dummy[40], value[20];
const float *timeBin;
int timeLength;
char buffer[256];
if(argc < 4){
SCWrite(pCon,"ERROR: insufficient number of arguments to puthm",
@ -272,26 +298,7 @@ static void putHistogramMemory(SConnection *pCon, SicsInterp *pSics,
start = 0;
length = GetHistLength(mem);
/*
update the dimension variables in the dictionary
*/
GetHistDim(mem,iDim,&rank);
for(i = 0; i < rank; i++){
sprintf(dummy,"dim%1.1d", i);
sprintf(value,"%d",iDim[i]);
status = NXDupdate(self->dictHandle,dummy,value);
if(status == 0) {
NXDadd(self->dictHandle,dummy,value);
}
}
timeBin = GetHistTimeBin(mem,&timeLength);
if(timeLength > 2){
sprintf(dummy,"%d",timeLength);
status = NXDupdate(self->dictHandle,"timedim",dummy);
if(status == 0) {
NXDadd(self->dictHandle,"timedim",dummy);
}
}
updateHMDim(self,mem);
/*
check for further arguments specifying a subset
@ -314,6 +321,105 @@ static void putHistogramMemory(SConnection *pCon, SicsInterp *pSics,
}
}
/*
read HM
*/
if(subset){
iData = (HistInt *)malloc(length*sizeof(HistInt));
if(!iData){
SCWrite(pCon,"ERROR: out of memory for reading histogram memory",
eError);
return;
}
memset(iData,0,length*sizeof(HistInt));
status = GetHistogramDirect(mem,pCon,0,start,start+length,iData,
length*sizeof(HistInt));
}else{
/*
status = GetHistogram(mem,pCon,0,start,length,iData,
length*sizeof(HistInt));
*/
iData = GetHistogramPointer(mem,pCon);
if(iData == NULL){
status = 0;
} else {
status = 1;
}
}
if(!status){
SCWrite(pCon,"ERROR: failed to read histogram memory",eError);
if(subset){
free(iData);
}
return;
}
/*
finally: write
*/
status = NXDputalias(self->fileHandle, self->dictHandle,argv[2],iData);
if(status != NX_OK){
sprintf(buffer,"ERROR: failed to write histogram memory data");
SCWrite(pCon,buffer,eError);
}
if(subset){
free(iData);
}
SCSendOK(pCon);
return;
}
/*---------------------------------------------------------------------
defunct as of december 2003
*/
static void putHistogramMemoryChunked(SConnection *pCon, SicsInterp *pSics,
pNXScript self,
int argc, char *argv[]){
pHistMem mem = NULL;
int status, start, length, i, noChunks, chunkDim[MAXDIM], rank;
HistInt *iData = NULL;
char buffer[256];
int subset;
if(argc < 5){
SCWrite(pCon,"ERROR: insufficient number of arguments to puthmchunked",
eError);
return;
}
/*
find Histogram Memory
*/
mem = (pHistMem)FindCommandData(pSics,argv[3],"HistMem");
if(!mem){
sprintf(buffer,"ERROR: HistMem %s not found!", argv[3]);
SCWrite(pCon,buffer,eError);
return;
}
/*
default: everything
*/
start = 0;
length = GetHistLength(mem);
updateHMDim(self,mem);
/*
check for an argument defining the number of chunks
*/
status = Tcl_GetInt(InterpGetTcl(pSics),argv[4],&noChunks);
if(status != TCL_OK){
sprintf(buffer,"ERROR: failed to convert %s to integer",
argv[4]);
SCWrite(pCon,buffer,eError);
return;
}
/*
read HM
*/

289
nxupdate.c Normal file
View File

@ -0,0 +1,289 @@
/*-----------------------------------------------------------------------
Automatic update of NeXus files a scheduled time intervalls.
For more information see nxudpate.tex.
copyright: see file COPYRIGHT
Mark Koennecke, December 2003
----------------------------------------------------------------------*/
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
#include "fortify.h"
#include "sics.h"
#include "splitter.h"
#include "nxupdate.h"
#include "nxupdate.i"
/*-------------------------------------------------------------------*/
static int UpdateTask(void *pData){
pNXupdate self = NULL;
self = (pNXupdate)pData;
if(self == NULL){
return 0;
}
/*
update when intervall reached or when end
*/
if(time(NULL) >= self->nextUpdate || self->iEnd == 1){
if(self->updateScript != NULL){
InterpExecute(pServ->pSics,self->pCon,self->updateScript);
}
self->nextUpdate = time(NULL) + self->updateIntervall;
}
if(self->iEnd == 1){
self->pCon = NULL;
return 0;
} else {
return 1;
}
}
/*--------------------------------------------------------------------*/
static int CountCallback(int iEvent, void *pEventData, void *pUser){
pNXupdate self = NULL;
SConnection *pCon = NULL;
self = (pNXupdate)pUser;
pCon = (SConnection *)pEventData;
if(iEvent == COUNTSTART){
assert(pCon);
assert(self);
/*
start file
*/
if(self->startScript != NULL){
InterpExecute(pServ->pSics,pCon,self->startScript);
}
if(self->updateScript != NULL){
InterpExecute(pServ->pSics,pCon,self->updateScript);
}
if(self->linkScript != NULL){
InterpExecute(pServ->pSics,pCon,self->linkScript);
}
/*
register update function
*/
self->nextUpdate = time(NULL) + self->updateIntervall;
self->iEnd = 0;
self->pCon = pCon;
TaskRegister(pServ->pTasker,UpdateTask,NULL,NULL,self,1);
return 1;
} else if(iEvent == COUNTEND){
self->iEnd = 1;
assert(self);
return 1;
}
return 1;
}
/*----------------------------------------------------------------------*/
void KillUpdate(void *pData){
pNXupdate self = NULL;
self = (pNXupdate)pData;
if(self == NULL){
return;
}
if(self->startScript != NULL){
free(self->startScript);
self->startScript = NULL;
}
if(self->updateScript != NULL){
free(self->updateScript);
self->updateScript = NULL;
}
if(self->linkScript != NULL){
free(self->linkScript);
self->linkScript = NULL;
}
free(self);
}
/*-------------------------------------------------------------------*/
static void printUpdateList(SConnection *pCon, pNXupdate self, char *name){
char pBueffel[256];
snprintf(pBueffel,255,"%s.startScript = %s",name, self->startScript);
SCWrite(pCon,pBueffel,eValue);
snprintf(pBueffel,255,"%s.updateScript = %s",name, self->updateScript);
SCWrite(pCon,pBueffel,eValue);
snprintf(pBueffel,255,"%s.linkScript = %s",name, self->linkScript);
SCWrite(pCon,pBueffel,eValue);
snprintf(pBueffel,255,"%s.updateIntervall = %d",name,
self->updateIntervall);
SCWrite(pCon,pBueffel,eValue);
}
/*--------------------------------------------------------------------*/
static int printUpdateParameters(SConnection *pCon, pNXupdate self,
char *name, char *param){
char pBueffel[256];
if(strcmp(param,"list") == 0){
printUpdateList(pCon,self, name);
return 1;
} else if(strcmp(param,"startscript") == 0){
snprintf(pBueffel,255,"%s.startScript = %s",name, self->startScript);
SCWrite(pCon,pBueffel,eValue);
return 1;
} else if(strcmp(param,"updatescript")== 0){
snprintf(pBueffel,255,"%s.updateScript = %s",name, self->updateScript);
SCWrite(pCon,pBueffel,eValue);
return 1;
} else if(strcmp(param,"linkscript") == 0){
snprintf(pBueffel,255,"%s.linkScript = %s",name, self->linkScript);
SCWrite(pCon,pBueffel,eValue);
return 1;
} else if(strcmp(param,"updateintervall") == 0){
snprintf(pBueffel,255,"%s.updateIntervall = %d",name,
self->updateIntervall);
SCWrite(pCon,pBueffel,eValue);
return 1;
} else {
snprintf(pBueffel,255,"ERROR: parameter %s not known", param);
SCWrite(pCon,pBueffel,eValue);
return 0;
}
}
/*---------------------------------------------------------------------*/
static int configureUpdate(SConnection *pCon, pNXupdate self,
char *param, char *value){
char pBueffel[256];
int newUpdate;
if(strcmp(param,"startscript") == 0){
if(self->startScript != NULL){
free(self->startScript);
}
self->startScript = strdup(value);
SCSendOK(pCon);
return 1;
} else if(strcmp(param,"updatescript")== 0){
if(self->updateScript != NULL){
free(self->updateScript);
}
self->updateScript = strdup(value);
SCSendOK(pCon);
return 1;
} else if(strcmp(param,"linkscript") == 0){
if(self->linkScript != NULL){
free(self->linkScript);
}
self->linkScript = strdup(value);
SCSendOK(pCon);
return 1;
} else if(strcmp(param,"updateintervall") == 0){
if(Tcl_GetInt(InterpGetTcl(pServ->pSics),value,&newUpdate) != TCL_OK){
snprintf(pBueffel,255,
"ERROR: %s not an int, cannot set updateIntervall", value);
SCWrite(pCon,pBueffel,eError);
return 0;
}
self->updateIntervall = newUpdate;
SCSendOK(pCon);
return 1;
} else {
snprintf(pBueffel,255,"ERROR: parameter %s not known", param);
SCWrite(pCon,pBueffel,eValue);
return 0;
}
}
/*----------------------------------------------------------------------*/
int UpdateAction(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]){
pNXupdate self = NULL;
char pBueffel[132];
self = (pNXupdate)pData;
assert(self);
if(argc < 2){
snprintf(pBueffel,131,"ERROR: need argument to %s", argv[0]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
if(argc < 3){
strtolower(argv[1]);
return printUpdateParameters(pCon,self,argv[0], argv[1]);
} else {
Arg2Text(argc-2,&argv[2],pBueffel,131);
return configureUpdate(pCon,self,argv[1],pBueffel);
}
/*
not reached
*/
assert(0);
return 0;
}
/*----------------------------------------------------------------------*/
int UpdateFactory(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]){
pICountable pCount = NULL;
pICallBack pCall = NULL;
void *pPtr = NULL;
char pBueffel[256];
pNXupdate self = NULL;
CommandList *pCom = NULL;
if(argc < 3){
SCWrite(pCon,"ERROR: insuffcient number of argument to UpdateFactory",
eError);
return 0;
}
/*
argv[1] = name
argv[2] = counter with which to register for automatic notifications
*/
pCom = FindCommand(pSics,argv[2]);
if(pCom){
pPtr = pCom->pData;
}
if(!pPtr){
snprintf(pBueffel,255,"ERROR: cannot find %s to register to", argv[2]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
pCount = GetCountableInterface(pPtr);
pCall = GetCallbackInterface(pPtr);
if(!pCount || !pCall){
snprintf(pBueffel,255,"ERROR: %s is not a usable counter",argv[2]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
/*
allocate memory and initialize
*/
self = (pNXupdate)malloc(sizeof(NXupdate));
if(self == NULL){
SCWrite(pCon,"ERROR: out of memory in UpdateFactory",eError);
return 0;
}
memset(self,0,sizeof(NXupdate));
self->pDes = CreateDescriptor("AutoUpdate");
if(self->pDes == NULL){
SCWrite(pCon,"ERROR: out of memory in UpdateFactory",eError);
return 0;
}
self->startScript = strdup("UNDEFINED");
self->updateScript = strdup("UNDEFINED");
self->linkScript = strdup("UNDEFINED");
self->updateIntervall = 1200; /* 20 min */
/*
register callbacks
*/
RegisterCallback(pCall,COUNTSTART,CountCallback,
self,NULL);
RegisterCallback(pCall,COUNTEND,CountCallback,
self,NULL);
AddCommand(pSics,argv[1],UpdateAction,KillUpdate,self);
return 1;
}

20
nxupdate.h Normal file
View File

@ -0,0 +1,20 @@
/*-----------------------------------------------------------------------
Automatic update of NeXus files a scheduled time intervalls.
For more information see nxudpate.tex.
copyright: see file COPYRIGHT
Mark Koennecke, December 2003
----------------------------------------------------------------------*/
#ifndef NXUPDATE
#define NXUPDATE
int UpdateAction(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]);
int UpdateFactory(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]);
void KillUpdate(void *pData);
#endif

94
nxupdate.w Normal file
View File

@ -0,0 +1,94 @@
\subsection{NeXus File Update}
When performing long term measurements it is advisable to save the
current state of the measurement at regular time intervalls in order
to protect against loss of data caused by computer or software
failures. This is a general object which takes care of it. This is
meant to work closely with the nxscript module for scripting the
content of NeXus files but is not restricted to it. In general, the
user has to specify the names of three scripts or SICS commands which
implement the following functionality:
\begin{description}
\item[startScript] This script is supposed to write all constant data
and is called once when counting starts.
\item[updateScript] is called whenever an update is called for. This
script is supposed to create and update those datasets which vary in
the course of the measurement.
\item[linkScript] This script is called once when the measurement
starts after startScript and updateScript. Then the NeXus file is
complete enough to create all the links required. This has to be done
by this script.
\end{description}
The NeXus file is automatically updated when counting finishes.
The data structure for holding the information required by this
object:
@d nxupdate @{
typedef struct __NXUPDATE {
pObjectDescriptor pDes;
char *startScript;
char *updateScript;
char *linkScript;
int updateIntervall;
time_t nextUpdate;
int iEnd;
SConnection *pCon;
}NXupdate, *pNXupdate;
@}
The fields:
\begin{description}
\item[pDes] The standard object descriptor.
\item[startScript] The name of the program to call for starting a
file.
\item[updateScript] The name of the program to use for updating a
file.
\item[linkScript] The name of the program to use for creating links in
the NeXus file.
\item[updateIntervall] The time in seconds between updates.
\item[nextUpdate] The time value for the next scheduled update.
\item[iEnd] A flag which becomes 1 when counting ends and makes the
UpdateTask to stop.
\item[pCon] The connection for which we are updating.
\end{description}
This object has no public C interface. There is only ainterpreter
function which allows to configure the object and a factory function
for creating an object of this type.
@o nxupdate.h @{
/*-----------------------------------------------------------------------
Automatic update of NeXus files a scheduled time intervalls.
For more information see nxudpate.tex.
copyright: see file COPYRIGHT
Mark Koennecke, December 2003
----------------------------------------------------------------------*/
#ifndef NXUPDATE
#define NXUPDATE
int UpdateAction(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]);
int UpdateFactory(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]);
void KillUpdate(void *pData);
#endif
@}
@o nxupdate.i @{
/*-----------------------------------------------------------------------
Automatic update of NeXus files a scheduled time intervalls.
For more information see nxudpate.tex.
Internal, automatically generated file, do not modify. Modify in
nxudpate.w
copyright: see file COPYRIGHT
Mark Koennecke, December 2003
----------------------------------------------------------------------*/
@<nxupdate@>
@}

5
ofac.c
View File

@ -101,7 +101,9 @@
#include "tclintimpl.h"
#include "tcldrivable.h"
#include "sicsdata.h"
#include "help.h"
#include "site.h"
#include "nxupdate.h"
/*----------------------- Server options creation -------------------------*/
static int IFServerOption(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[])
@ -223,6 +225,7 @@
AddCommand(pInter,"sicscron",MakeCron,NULL,NULL);
AddCommand(pInter,"sicsdatafactory",SICSDataFactory,NULL,NULL);
AddCommand(pInter,"scriptcallback",CallbackScript,NULL,NULL);
AddCommand(pInter,"help",SicsHelp,KillHelp,NULL);
/* commands to do with the executor. Only StopExe carries the
DeleteFunction in order to avoid double deletion. All the
@ -272,6 +275,7 @@
AddCommand(pInter,"MakeTclInt",MakeTclInt,NULL,NULL);
AddCommand(pInter,"TclReplaceDrivable",TclReplaceDrivable,NULL,NULL);
AddCommand(pInter,"DrivableInvoke", TclDrivableInvoke,NULL,NULL);
AddCommand(pInter,"UpdateFactory",UpdateFactory,NULL,NULL);
/*
install site specific commands
@ -326,6 +330,7 @@
RemoveCommand(pSics,"MakeGPIB");
RemoveCommand(pSics,"MakeNXScript");
RemoveCommand(pSics,"MakeTclInt");
RemoveCommand(pSics,"UpdateFactory");
/*
remove site specific installation commands

View File

@ -12,7 +12,7 @@
#ifndef SERIALSICSWAIT
#define SERIALSICSWAIT
#include "sics.h"
#include "psi/hardsup/serialsinq.h"
#include "hardsup/serialsinq.h"
int SerialSicsExecute(void **pData, char *pCommand, char *pReply,
int iBufLen);

View File

@ -18,8 +18,6 @@
#include "HistMem.h"
#include "sicsdata.h"
#define INTTYPE 0
#define FLOATTYPE 1
/*--------------------------------------------------------------------*/
static void KillSICSData(void *pData){
pSICSData self = NULL;
@ -110,6 +108,10 @@ static void assignType(pSICSData self, int start, int end, int type){
self->dataType[i] = type;
}
}
/*-----------------------------------------------------------------------*/
void assignSICSType(pSICSData self, int start, int end, int type){
assignType(self,start,end,type);
}
/*------------------------------------------------------------------------
netEncode transforms the data in the array into network format.
- int become ints in network byte order

View File

@ -11,6 +11,9 @@
----------------------------------------------------------------------*/
#ifndef SICSDATA
#define SICSDATA
#define INTTYPE 0
#define FLOATTYPE 1
typedef struct {
pObjectDescriptor pDes;
@ -27,6 +30,8 @@
pSICSData createSICSData(void);
void assignSICSType(pSICSData self, int start, int end, int type);
int SICSDataFactory(SConnection *pCon, SicsInterp *pSics,
void *pData,
int argc, char *argv[]);

View File

@ -39,6 +39,8 @@ This object exports the following functions:
pSICSData createSICSData(void);
void assignSICSType(pSICSData self, int start, int end, int type);
int SICSDataFactory(SConnection *pCon, SicsInterp *pSics,
void *pData,
int argc, char *argv[]);
@ -71,6 +73,9 @@ which users may interact with the SICSData element.
----------------------------------------------------------------------*/
#ifndef SICSDATA
#define SICSDATA
#define INTTYPE 0
#define FLOATTYPE 1
@<sidastruc@>
/*------------------------------------------------------------------*/
@<sidafunc@>

View File

@ -0,0 +1,3 @@
# Counter counter
counter SetPreset 300.000000
counter SetMode Timer

View File

@ -32,7 +32,15 @@ static void syncLogin(void)
connect
*/
connection = NETConnect(hostname, port);
for(i = 0; i < 10; i++)
{
NETRead(connection,pBueffel,1020,10*1000);
if(strstr(pBueffel,"OK") != NULL)
{
break;
}
SicsWait(1);
}
if(connection != NULL)
{
/*

View File

@ -5,7 +5,7 @@
This is the header file for the SICS token management
functions. It implements the token command.
Mark Koennecke, January 1998
Mark Koenencke, January 1998
copyright: see copyright.h

197
varlog.c
View File

@ -6,12 +6,16 @@
Mark Koennecke, September 1997
Substantially revised to calculate running measn and standard deviations
instead of storing data ain a list. The module now supports running
Substantially revised to calculate running means and standard deviations
instead of storing data in a list. The module now supports running
averages and logging to file.
Mark Koennecke, April 2000
Added support for a circular buffer of logged values.
Mark Koennecke, December 2003
Copyright:
Labor fuer Neutronenstreuung
@ -50,10 +54,17 @@
#include <math.h>
#include "fortify.h"
#include "lld.h"
#include "conman.h"
#include "sics.h"
#include "varlog.h"
#include "commandlog.h"
#include "circular.h"
#include "sicsdata.h"
/*-----------------------------------------------------------------------*/
/*
maximum values in the circular buffer
*/
#define MAXRING 1024
/*------------------------------------------------------------------------*/
typedef struct __VarLog
{
@ -63,6 +74,7 @@
double dSum;
double dDeviation;
FILE *fd;
pCircular pTail;
}VarLog;
/*------------------------------------------------------------------------*/
@ -87,6 +99,12 @@
pNew->dSum = 0.;
pNew->dDeviation = 0.;
pNew->fd = NULL;
pNew->pTail = createCircular(MAXRING,free);
if(!pNew->pTail)
{
VarlogDelete(pNew);
return 0;
}
*self = pNew;
return 1;
@ -98,6 +116,10 @@
{
fclose(self->fd);
}
if(self->pTail != NULL)
{
deleteCircular(self->pTail);
}
return 1;
}
/*--------------------------------------------------------------------------*/
@ -129,6 +151,7 @@
int iFile = 0;
char pBuffer[80];
double dMean, dTmp;
pLogItem newLog = NULL;
assert(self);
@ -161,7 +184,7 @@
return 1;
}
/* if, log time passed, write to file */
/* if, log time passed, write to file and into ring buffer */
if(tCurrent > self->tNext)
{
if(iFile)
@ -169,6 +192,14 @@
VLFormatTime(tCurrent,pBuffer,79);
fprintf(self->fd," %s %f \n", pBuffer,fVal);
}
newLog = (pLogItem)malloc(sizeof(LogItem));
if(newLog != NULL)
{
newLog->tTime = tCurrent;
newLog->fVal = fVal;
setCircular(self->pTail,newLog);
nextCircular(self->pTail);
}
self->tNext = tCurrent + self->tFrequency;
return 1;
}
@ -203,6 +234,112 @@
return success;
}
/*-----------------------------------------------------------------------*/
static int VarlogToSicsData(pVarLog self, pSICSData data)
{
int i, length;
int *dataPtr = NULL;
pLogItem log = NULL;
dataPtr = getSICSDataPointer(data,0,2*MAXRING+1);
if(!dataPtr)
{
return 0;
}
dataPtr[0] = MAXRING;
/*
skip back MAXRING steps
*/
for(i = 0; i < MAXRING; i++)
{
previousCircular(self->pTail);
}
/*
forward again and copy data
*/
for(i = 0; i < MAXRING; i++)
{
log = getCircular(self->pTail);
if(log != NULL)
{
dataPtr[i+1] = (int)log->tTime;
memcpy(&dataPtr[i+1+MAXRING],&log->fVal,sizeof(float));
}
nextCircular(self->pTail);
}
/*
assign data types
*/
assignSICSType(data,0,MAXRING+1,INTTYPE);
assignSICSType(data,MAXRING+1,2*MAXRING+1,FLOATTYPE);
return 1;
}
/*-----------------------------------------------------------------------*/
static void VarlogDump(pVarLog self, SConnection *pCon)
{
int i, length;
pLogItem log = NULL;
char timeBuffer[132], pBueffel[256];
/*
skip back MAXRING steps
*/
for(i = 0; i < MAXRING; i++)
{
previousCircular(self->pTail);
}
/*
forward again and print data
*/
for(i = 0; i < MAXRING; i++)
{
log = getCircular(self->pTail);
if(log != NULL)
{
if(log->tTime > 0)
{
VLFormatTime(log->tTime,timeBuffer,131);
snprintf(pBueffel,255,"%s %12.3f",timeBuffer,log->fVal);
SCWrite(pCon,pBueffel,eValue);
}
}
nextCircular(self->pTail);
}
}
/*-----------------------------------------------------------------------*/
static void VarLogDumpFile(pVarLog self, FILE *fd)
{
int i, length;
pLogItem log = NULL;
char timeBuffer[132], pBueffel[256];
/*
skip back MAXRING steps
*/
for(i = 0; i < MAXRING; i++)
{
previousCircular(self->pTail);
}
/*
forward again and print data
*/
for(i = 0; i < MAXRING; i++)
{
log = getCircular(self->pTail);
if(log != NULL)
{
if(log->tTime > 0)
{
VLFormatTime(log->tTime,timeBuffer,131);
fprintf(fd,"%s %12.3f",timeBuffer,log->fVal);
}
}
nextCircular(self->pTail);
}
}
/*--------------------------------------------------------------------------*/
int VarlogWrapper(pVarLog self, SConnection *pCon,
char *subcommand, char *sub2, char *pVarName)
@ -213,6 +350,8 @@
char pBueffel[256];
char *pData = NULL;
long lNew;
pSICSData data = NULL;
FILE *fd = NULL;
strtolower(subcommand);
@ -315,6 +454,54 @@
return 1;
}
}
/*-------------- tosicsdata */
else if(strcmp(subcommand,"tosicsdata") == 0)
{
if(!sub2)
{
SCWrite(pCon,"ERROR: tosicsdata needs an argument",eError);
return 0;
}
data = FindCommandData(pServ->pSics,sub2,"SICSData");
if(!data)
{
snprintf(pBueffel,255,"ERROR: %s is no sicsdata object",sub2);
SCWrite(pCon,pBueffel,eError);
return 0;
}
iRet = VarlogToSicsData(self,data);
if(iRet == 0)
{
SCWrite(pCon,"ERROR: out of memory in VarlogToSicsData",eError);
return 0;
}
SCSendOK(pCon);
return 1;
}
/* ---------------- dumpring */
else if(strcmp(subcommand,"dump") == 0)
{
VarlogDump(self,pCon);
return 1;
}
/*---------------- dumptofile */
else if(strcmp(subcommand,"dumptofile") == 0)
{
if(sub2 != NULL)
{
fd = fopen(sub2,"w");
}
if(fd == NULL)
{
snprintf(pBueffel,255,"ERROR: failed to open %s",sub2);
SCWrite(pCon,pBueffel,eError);
return 0;
}
VarLogDumpFile(self,fd);
fclose(fd);
SCSendOK(pCon);
return 1;
}
/* command not recognized */
else
{
@ -323,3 +510,5 @@
return 0;
}
}

View File

@ -23,9 +23,11 @@
int VarlogAdd(pVarLog self, float fVal);
/*------------------------------ data recovery -------------------------*/
int VarlogLength(pVarLog self, int *iLength);
int VarlogGetTime(pVarLog self, time_t *tTime);
int VarlogGetVal(pVarLog self, float *fValues);
int VarlogGetMean(pVarLog self, float *fMean, float *fStdDev);
/*------------------------------ interpreter ---------------------------*/
int VarlogWrapper(pVarLog self, SConnection *pCon,
int VarlogWrapper(pVarLog self,SConnection *pCon,
char *subcommand, char *sub2,char *pVarName);
#endif

View File

@ -27,7 +27,7 @@ $\langle$logint {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ int VarlogGetVal(pVarLog self, float *fValues);@\\
\mbox{}\verb@ int VarlogGetMean(pVarLog self, float *fMean, float *fStdDev);@\\
\mbox{}\verb@/*------------------------------ interpreter ---------------------------*/@\\
\mbox{}\verb@ int VarlogWrapper(pVarLog self, int *iSwitch, SConnection *pCon, @\\
\mbox{}\verb@ int VarlogWrapper(pVarLog self,SConnection *pCon, @\\
\mbox{}\verb@ char *subcommand, char *sub2,char *pVarName);@\\
\mbox{}\verb@@$\diamond$
\end{list}

View File

@ -22,7 +22,7 @@ The following functions are provided:
int VarlogGetVal(pVarLog self, float *fValues);
int VarlogGetMean(pVarLog self, float *fMean, float *fStdDev);
/*------------------------------ interpreter ---------------------------*/
int VarlogWrapper(pVarLog self, int *iSwitch, SConnection *pCon,
int VarlogWrapper(pVarLog self,SConnection *pCon,
char *subcommand, char *sub2,char *pVarName);
@}

View File

@ -44,6 +44,8 @@
/*-------------------- live & death ----------------------------------------*/
pVelSelDriv VSCreateSim(void);
pVelSelDriv VSCreateDornierSINQ(char *name,Tcl_Interp *pTcl);
void VSDeleteDriver(pVelSelDriv self);
#endif

50
wwildcard.c Normal file
View File

@ -0,0 +1,50 @@
#define MAX_CALLS 200
#include <ctype.h>
int match(const char *mask, const char *name)
{
int calls=0, wild=0, q=0;
const char *m=mask, *n=name, *ma=mask, *na=name;
for(;;) {
if (++calls > MAX_CALLS) return 1;
if (*m == '*') {
while (*m == '*') ++m;
wild = 1;
ma = m;
na = n;
}
if (!*m) {
if (!*n) return 0;
for (--m; (m > mask) && (*m == '?'); --m) ;
if ((*m == '*') && (m > mask) &&
(m[-1] != '\\'))
return 0;
if (!wild)
return 1;
m = ma;
} else if (!*n) {
while(*m == '*') ++m;
return (*m != 0);
}
if ((*m == '\\') && ((m[1] == '*') || (m[1] == '?'))) {
++m;
q = 1;
} else {
q = 0;
}
if ((tolower(*m) != tolower(*n)) && ((*m != '?') || q)) {
if (!wild) return 1;
m = ma;
n = ++na;
} else {
if (*m) ++m;
if (*n) ++n;
}
}
}