diff --git a/Makefile b/Makefile index 07cea372..59de78ee 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,8 @@ SOBJ = network.o ifile.o conman.o SCinter.o splitter.o passwd.o \ hklscan.o xytable.o amor2t.o nxamor.o amorscan.o amorstat.o \ circular.o el755driv.o maximize.o sicscron.o tecsdriv.o sanscook.o \ tasinit.o tasutil.o t_rlp.o t_conv.o d_sign.o d_mod.o \ - tasdrive.o tasscan.o synchronize.o definealias.o swmotor.o t_update.o + tasdrive.o tasscan.o synchronize.o definealias.o swmotor.o t_update.o \ + hmcontrol.o MOTOROBJ = motor.o el734driv.o simdriv.o el734dc.o pipiezo.o pimotor.o COUNTEROBJ = countdriv.o simcter.o counter.o diff --git a/callback.c b/callback.c index 4068da09..234a210b 100644 --- a/callback.c +++ b/callback.c @@ -42,8 +42,7 @@ #include #include "fortify.h" #include "lld.h" -#include "conman.h" -#include "interface.h" +#include "sics.h" #define CALLBACK 17777 diff --git a/conman.c b/conman.c index 04c1a093..4e8a188b 100644 --- a/conman.c +++ b/conman.c @@ -34,17 +34,13 @@ #include #include #include "lld.h" -#include "conman.h" +#include "sics.h" #include "passwd.h" -#include "SCinter.h" -#include "Scommon.h" #include "splitter.h" #include "macro.h" #include "servlog.h" #include "status.h" #include "interrupt.h" -#include "interface.h" -#include "event.h" #include "ifile.h" #include "token.h" #include "uubuffer.h" @@ -826,7 +822,7 @@ extern pServer pServ; #define ZIPBUF 8192 int SCWriteZipped(SConnection *self, char *pName, void *pData, int iDataLen) { - char outBuf[65546], *pBuf = NULL, noutBuf[ZIPBUF]; + char outBuf[65546], *pBuf = NULL, noutBuf[ZIPBUF], *pHeader = NULL; int compressedLength, iRet, iRet2, iCount; z_stream compStream; @@ -895,7 +891,12 @@ extern pServer pServ; /* write header line */ memset(outBuf,0,65536); sprintf(outBuf,"SICSBIN ZIP %s %d\r\n",pName,compressedLength); - SCWrite(self,outBuf,eValue); + pHeader = strdup(outBuf); + if(pHeader == NULL) + { + SCWrite(self,"ERROR: out of memory in SCWriteZipped",eError); + return 0; + } /* now reset the deflater and do the same with writing data */ compStream.zalloc = (alloc_func)NULL; @@ -924,12 +925,13 @@ extern pServer pServ; compStream.avail_in = iDataLen; compStream.avail_out = iDataLen + iDataLen/10 + 50; iRet = deflate(&compStream,Z_FINISH); - if(iRet != Z_STREAM_END && iRet != Z_OK) + if(iRet != Z_STREAM_END) { sprintf(outBuf,"ERROR: zlib error: %d",iRet); SCWrite(self,outBuf,eError); return 0; } + iRet = NETWrite(self->pSock,pHeader,strlen(pHeader)); iRet = NETWrite(self->pSock,pBuf,compStream.total_out); if(iRet != 1) { @@ -938,6 +940,8 @@ extern pServer pServ; return 0; } deflateEnd(&compStream); + free(pHeader); + free(pBuf); /* diff --git a/countdriv.c b/countdriv.c index f19527d6..40d1967b 100644 --- a/countdriv.c +++ b/countdriv.c @@ -41,7 +41,7 @@ #include #include "fortify.h" #include -#include "Scommon.h" +#include "sics.h" #include "countdriv.h" #include "hardsup/sinq_prototypes.h" #include "hardsup/el737_def.h" diff --git a/countdriv.h b/countdriv.h index 95c703ff..55e4305a 100644 --- a/countdriv.h +++ b/countdriv.h @@ -24,10 +24,6 @@ #define MAXCOUNT 9 /* No of monitors + actual counter */ - typedef enum { - eTimer, - ePreset - }CounterMode; /* Parameter codes for the Set/Get pair of routines */ /*-------- threshold */ diff --git a/counter.c b/counter.c index 3d8d7a60..3d825b6e 100644 --- a/counter.c +++ b/counter.c @@ -70,6 +70,17 @@ return self->pDriv->Halt(self->pDriv); } +/*--------------------------------------------------------------------------*/ + static void SetCountParameters(void *pData, float fPreset, CounterMode eMode) + { + pCounter self = NULL; + + assert(pData); + self = (pCounter)pData; + + self->pDriv->fPreset = fPreset; + self->pDriv->eMode = eMode; + } /*-----------------------------------------------------------------------*/ static int StartCount(void *pData, SConnection *pCon) { @@ -355,6 +366,7 @@ free(pRes); return NULL; } + pRes->pCountInt->SetCountParameters = SetCountParameters; pRes->pCountInt->StartCount = StartCount; pRes->pCountInt->CheckCountStatus = CheckCountStatus; pRes->pCountInt->TransferData = TransferData; diff --git a/danu.dat b/danu.dat index 4e4480c7..134b8581 100644 --- a/danu.dat +++ b/danu.dat @@ -1,3 +1,3 @@ - 7740 + 7746 NEVER, EVER modify or delete this file You'll risk eternal damnation and a reincarnation as a cockroach!|n \ No newline at end of file diff --git a/devexec.c b/devexec.c index e091e3a4..0372876e 100644 --- a/devexec.c +++ b/devexec.c @@ -42,18 +42,14 @@ #include #include #include "fortify.h" -#include "conman.h" -#include "Scommon.h" -#include "interface.h" +#include "sics.h" #include "nserver.h" #include "motor.h" #include "countdriv.h" #include "counter.h" -#include "task.h" #include "devexec.h" #include "status.h" #include "lld.h" -#include "event.h" /* #define DEBUG 1 diff --git a/drive.c b/drive.c index 92977887..1761c42e 100644 --- a/drive.c +++ b/drive.c @@ -41,11 +41,8 @@ #include #include #include "fortify.h" +#include "sics.h" #include "drive.h" -#include "obdes.h" -#include "interface.h" -#include "SCinter.h" -#include "conman.h" #include "nserver.h" /* for SicsWait */ #include "drive.h" #include "splitter.h" diff --git a/emon.c b/emon.c index a1d9e60f..e158510c 100644 --- a/emon.c +++ b/emon.c @@ -42,10 +42,7 @@ #include /* for DString */ #include "fortify.h" #include "lld.h" -#include "conman.h" -#include "SCinter.h" -#include "obdes.h" -#include "interface.h" +#include "sics.h" #include "emon.i" #include "emon.h" #include "event.h" @@ -383,4 +380,4 @@ } } } - \ No newline at end of file + diff --git a/histdriv.c b/histdriv.c index f6a261a9..f1510275 100644 --- a/histdriv.c +++ b/histdriv.c @@ -41,9 +41,7 @@ #include #include #include "fortify.h" -#include "conman.h" -#include "obdes.h" -#include "interface.h" +#include "sics.h" #include "countdriv.h" #include "counter.h" #include "splitter.h" diff --git a/histmem.c b/histmem.c index 08382c4f..ec301277 100644 --- a/histmem.c +++ b/histmem.c @@ -134,6 +134,17 @@ } return NULL; } +/*------------------------------------------------------------------------*/ + static void HistSetParameter(void *pData, float fPreset, CounterMode eMode) + { + pHistMem self = NULL; + + self = (pHistMem)pData; + assert(self); + + self->pDriv->eCount = eMode; + self->pDriv->fCountPreset = fPreset; + } /*-------------------------------------------------------------------------*/ static int HistStartCount(void *pData, SConnection *pCon) { @@ -409,6 +420,7 @@ free(pNew); return NULL; } + pNew->pCountInt->SetCountParameters = HistSetParameter; pNew->pCountInt->StartCount = HistStartCount; pNew->pCountInt->CheckCountStatus = HistCountStatus; pNew->pCountInt->TransferData = HistTransfer; diff --git a/histsim.c b/histsim.c index eb0d0939..4dff8888 100644 --- a/histsim.c +++ b/histsim.c @@ -41,9 +41,7 @@ #include #include #include "fortify.h" -#include "conman.h" -#include "obdes.h" -#include "interface.h" +#include "sics.h" #include "countdriv.h" #include "counter.h" #include "stringdict.h" @@ -65,7 +63,9 @@ static int SimConfig(pHistDriver self, SConnection *pCon, pStringDict pOption, SicsInterp *pSics) { - int i, iLength = 1; + int i, iLength = 1, status; + char pData[132]; + float fFail; if(self->eHistMode == eHTOF) { @@ -76,6 +76,18 @@ iLength *= self->iTimeChan; self->iLength = iLength; } + + /* + deal with failrate + */ + status = StringDictGet(pOption,"failrate",pData,131); + if(status) + { + fFail = atof(pData); + free(self->pPriv); + self->pPriv = NewSIMCounter("HistoSim",fFail); + } + return 1; } /*-------------------------------------------------------------------------*/ @@ -265,6 +277,7 @@ pNew->FreePrivate = SimFreePrivate; pNew->Pause = SimPause; pNew->Continue = SimContinue; + StringDictAddPair(pOpt,"failrate","-1"); return pNew; } diff --git a/hmcontrol.c b/hmcontrol.c new file mode 100644 index 00000000..f347f10f --- /dev/null +++ b/hmcontrol.c @@ -0,0 +1,349 @@ +/*------------------------------------------------------------------------ + H M C O N T R O L + + A module for coordinating several counters and histogram + memories. One of the counters is the master counter and the rest are + slaves which have to be kept in sync with the master in their + operations. + + copyright: see copyright.h + + Mark Koennecke, June 2001 +-------------------------------------------------------------------------*/ + +#include +#include +#include +#include "fortify.h" +#include "hmcontrol.h" +#include "devexec.h" + + +/*-------------------------------------------------------------------------*/ +static void *HMCGetInterface(void *pData, int ID) +{ + pHMcontrol self = NULL; + + self = (pHMcontrol)pData; + assert(self); + + if(ID == COUNTID) + return self->pCount; + else + return NULL; +} +/*------------------------------------------------------------------------*/ +static int HMCHalt(void *pData) +{ + int i, retVal = OKOK, status; + pHMcontrol self = NULL; + + self = (pHMcontrol)pData; + assert(self); + + for(i = 0; i < self->nSlaves; i++) + { + status = self->slaves[i]->Halt(self->slaveData[i]); + if(status != OKOK) + retVal = status; + } + return retVal; +} +/*-----------------------------------------------------------------------*/ +static int HMCStart(void *pData, SConnection *pCon) +{ + int i, status; + pHMcontrol self = NULL; + + self = (pHMcontrol)pData; + assert(self); + + for(i = 0; i < self->nSlaves; i++) + { + status = self->slaves[i]->StartCount(self->slaveData[i],pCon); + if(status != OKOK) + { + HMCHalt(self); + return status; + } + } + return OKOK; +} +/*----------------------------------------------------------------------*/ +static int HMCStatus(void *pData, SConnection *pCon) +{ + int status; + pHMcontrol self = NULL; + + self = (pHMcontrol)pData; + assert(self); + + status = self->slaves[0]->CheckCountStatus(self->slaveData[0],pCon); + if(status == HWIdle || status == HWFault) + { + /* + stop counting on slaves when finished or when an error + occurred. + */ + HMCHalt(self); + } + return status; +} +/*-------------------------------------------------------------------------*/ +static int HMCPause(void *pData, SConnection *pCon) +{ + int i, status; + pHMcontrol self = NULL; + + self = (pHMcontrol)pData; + assert(self); + + for(i = 0; i < self->nSlaves; i++) + { + status = self->slaves[i]->Pause(self->slaveData[i],pCon); + if(status != OKOK) + { + HMCHalt(self); + return status; + } + } + return OKOK; +} +/*------------------------------------------------------------------------*/ +static int HMCContinue(void *pData, SConnection *pCon) +{ + int i, status; + pHMcontrol self = NULL; + + self = (pHMcontrol)pData; + assert(self); + + for(i = 0; i < self->nSlaves; i++) + { + status = self->slaves[i]->Continue(self->slaveData[i],pCon); + if(status != OKOK) + { + HMCHalt(self); + return status; + } + } + return OKOK; +} +/*----------------------------------------------------------------------*/ +static int HMCTransfer(void *pData, SConnection *pCon) +{ + int i, retVal = OKOK, status; + pHMcontrol self = NULL; + char pBueffel[132]; + + self = (pHMcontrol)pData; + assert(self); + + for(i = 0; i < self->nSlaves; i++) + { + status = self->slaves[i]->TransferData(self->slaveData[i], pCon); + if(status != OKOK) + { + retVal = status; + sprintf(pBueffel,"WARNING: slave histogram %d failed to transfer data", + i); + SCWrite(pCon,pBueffel,eWarning); + } + } + return retVal; +} +/*-----------------------------------------------------------------------*/ +static void HMCParameter(void *pData, float fPreset, CounterMode eMode ) +{ + int i; + pHMcontrol self = NULL; + + self = (pHMcontrol)pData; + assert(self); + + for(i = 0; i < self->nSlaves; i++) + { + self->slaves[i]->SetCountParameters(self->slaveData[i], fPreset, + eMode); + } +} +/*----------------------------------------------------------------------*/ +static void KillHMcontrol(void *pData) +{ + pHMcontrol self; + + self = (pHMcontrol)pData; + if(!self) + return; + + if(self->pDes) + DeleteDescriptor(self->pDes); + if(self->pCount) + free(self->pCount); + free(self); +} +/*-----------------------------------------------------------------------*/ +int MakeHMControl(SConnection *pCon, SicsInterp *pSics, + void *pData, int argc, char *argv[]) +{ + int i, status; + pHMcontrol pNew = NULL; + char pBueffel[132]; + CommandList *pCom; + pICountable pCount; + + /* + need at least two parameters + */ + if(argc < 3) + { + SCWrite(pCon,"ERROR: insufficient number of arguments to MakeHMControl", + eError); + return 0; + } + + /* + allocate our data structure + */ + pNew = (pHMcontrol)malloc(sizeof(HMcontrol)); + if(!pNew) + { + SCWrite(pCon,"ERROR: out of memory in MakeHMControl",eError); + return 0; + } + memset(pNew,0,sizeof(HMcontrol)); + pNew->pDes = CreateDescriptor("HMcontrol"); + pNew->pCount = CreateCountableInterface(); + if(!pNew->pDes || ! pNew->pCount) + { + SCWrite(pCon,"ERROR: out of memory in MakeHMControl",eError); + KillHMcontrol(pNew); + return 0; + } + + /* + assign interface functions + */ + pNew->pDes->GetInterface = HMCGetInterface; + pNew->pCount->Halt = HMCHalt; + pNew->pCount->StartCount = HMCStart; + pNew->pCount->CheckCountStatus = HMCStatus; + pNew->pCount->Pause = HMCPause; + pNew->pCount->Continue = HMCContinue; + pNew->pCount->TransferData = HMCTransfer; + pNew->pCount->SetCountParameters = HMCParameter; + + /* + now loop through the remaining arguments, thereby entering them into + the slave list. + */ + for(i = 2; i < argc; i++) + { + pCom = FindCommand(pSics,argv[i]); + if(!pCom) + { + sprintf(pBueffel,"ERROR: object %s not found in MakeHMcontrol", + argv[i]); + SCWrite(pCon,pBueffel,eError); + continue; + } + pCount = GetCountableInterface(pCom->pData); + if(!pCount) + { + sprintf(pBueffel,"ERROR: object %s is NOT countable", + argv[i]); + SCWrite(pCon,pBueffel,eError); + continue; + } + pNew->slaves[pNew->nSlaves] = pCount; + pNew->slaveData[pNew->nSlaves] = pCom->pData; + pNew->nSlaves++; + } + + /* + now install our action command and we are done + */ + status = AddCommand(pSics,argv[1],HMControlAction,KillHMcontrol, + pNew); + if(!status) + { + sprintf(pBueffel,"ERROR: duplicate command %s not created",argv[1]); + SCWrite(pCon,pBueffel,eError); + KillHMcontrol(pNew); + return 0; + } + + return 1; +} +/*----------------------------------------------------------------------- + Syntax: whatever start preset mode + ------------------------------------------------------------------------*/ +int HMControlAction(SConnection *pCon, SicsInterp *pSics, + void *pData, int argc, char *argv[]) +{ + pHMcontrol self; + char pBueffel[132]; + double dPreset; + CounterMode eMode; + int status; + + /* + checks + */ + self = (pHMcontrol)pData; + assert(self); + if(argc < 4) + { + sprintf("ERROR: Usage %s start preset mode", argv[0]); + SCWrite(pCon,pBueffel,eError); + return 0; + } + strtolower(argv[1]); + if(strcmp(argv[1],"start") == 0) + { + /* + interpret count parameters + */ + status = Tcl_GetDouble(pSics->pTcl,argv[2],&dPreset); + if(status != TCL_OK) + { + sprintf(pBueffel,"ERROR: failed to convert %s to number", + argv[2]); + SCWrite(pCon,pBueffel,eError); + return 0; + } + strtolower(argv[3]); + if(strcmp(argv[3],"timer") == 0) + eMode = eTimer; + else if(strcmp(argv[3],"monitor") == 0) + eMode = ePreset; + else + { + sprintf(pBueffel,"ERROR: %s is no recognized count mode",argv[3]); + SCWrite(pCon,pBueffel,eError); + return 0; + } + + /* + set count parameters and go + */ + self->pCount->SetCountParameters(self,(float)dPreset,eMode); + status = StartDevice(pServ->pExecutor,"hmcontrol",self->pDes, + self,pCon,99); + if(!status) + { + SCWrite(pCon,"ERROR: failed to start counting",eError); + return 0; + } + SCSendOK(pCon); + } + else + { + SCWrite(pCon,"ERROR: subcommand not recognized",eError); + return 0; + } + + return 1; +} + + diff --git a/hmcontrol.h b/hmcontrol.h new file mode 100644 index 00000000..0b62fa8f --- /dev/null +++ b/hmcontrol.h @@ -0,0 +1,45 @@ + +/*------------------------------------------------------------------------ + H M C O N T R O L + + A module for coordinating several counters and histogram + memories. One of the counters is the master counter and the rest are + slaves which have to be kept in sync with the master in their + operations. + + copyright: see copyright.h + + Mark Koennecke, June 2001 +-------------------------------------------------------------------------*/ +#ifndef HMCONTROL +#define HMCONTROL + +/* +the maximum number of slaves +*/ +#include "sics.h" +#include "counter.h" + +#define MAXSLAVE 5 + + + typedef struct { + pObjectDescriptor pDes; + pICountable pCount; + pICountable slaves[MAXSLAVE]; + void *slaveData[MAXSLAVE]; + int nSlaves; + float fPreset; + CounterMode eMode; + } HMcontrol, *pHMcontrol; + + + + int MakeHMControl(SConnection *pCon, SicsInterp *pSics, + void *pData, int argc, char *argv[]); + int HMControlAction(SConnection *pCon, SicsInterp *pSics, + void *pData, int argc, char *argv[]); + + +#endif + diff --git a/hmcontrol.w b/hmcontrol.w new file mode 100644 index 00000000..75c625a3 --- /dev/null +++ b/hmcontrol.w @@ -0,0 +1,73 @@ +\subsection{HM control} +At TRICS (and possibly at other instruments) it it necessary to coordinate the +operation of the counter and one to many histogram memories. The +neutron counter will act as the actual controlling instance and the +histogram memories will act as slaves. This is implemented in this +module. + +The modules data structure: +@d hmcontroldata @{ + typedef struct { + pObjectDescriptor pDes; + pICountable pCount; + pICountable slaves[MAXSLAVE]; + void *slaveData[MAXSLAVE]; + int nSlaves; + float fPreset; + CounterMode eMode; + } HMcontrol, *pHMcontrol; +@} +The fields are: +\begin{description} +\item[pDes] The standard SICS object descriptor. +\item[pCount] The countable interface of this module. +\item[slaves] The slave counters or histogram memories. +\item[slaveData] is the data structure for the slave. The first slave +is always the neutron counter. +\item[nSlaves] The number of active slaves. +\item[fPreset] The counting preset. +\item[eMode] The counting mode. +\end{description} + + +Most of this modules functionality is built into the countable +interface functions. Just an interface to the interpreter is needed: + +@d hmcontrolint @{ + int MakeHMControl(SConnection *pCon, SicsInterp *pSics, + void *pData, int argc, char *argv[]); + int HMControlAction(SConnection *pCon, SicsInterp *pSics, + void *pData, int argc, char *argv[]); + +@} + +@o hmcontrol.h @{ +/*------------------------------------------------------------------------ + H M C O N T R O L + + A module for coordinating several counters and histogram + memories. One of the counters is the master counter and the rest are + slaves which have to be kept in sync with the master in their + operations. + + copyright: see copyright.h + + Mark Koennecke, June 2001 +-------------------------------------------------------------------------*/ +#ifndef HMCONTROL +#define HMCONTROL + +/* +the maximum number of slaves +*/ +#include "sics.h" +#include "counter.h" + +#define MAXSLAVE 5 + +@ + +@ +#endif + +@} diff --git a/interface.c b/interface.c index 93b41d10..5663fdda 100644 --- a/interface.c +++ b/interface.c @@ -40,9 +40,8 @@ #include #include #include "fortify.h" -#include "conman.h" -#include "obdes.h" -#include "interface.h" +#include "sics.h" + /*-------------------------------------------------------------------------*/ pIDrivable CreateDrivableInterface(void) diff --git a/interface.h b/interface.h index 1dd1f16b..fba9b139 100644 --- a/interface.h +++ b/interface.h @@ -1,5 +1,5 @@ -#line 343 "interface.w" +#line 345 "interface.w" /*--------------------------------------------------------------------------- I N T E R F A C E S @@ -44,7 +44,7 @@ pIDrivable GetDrivableInterface(void *pObject); -#line 368 "interface.w" +#line 370 "interface.w" pIDrivable CreateDrivableInterface(void); @@ -56,6 +56,8 @@ typedef struct { int ID; int (*Halt)(void *self); + void (*SetCountParameters)(void *self, float fPreset, + CounterMode eMode);\ int (*StartCount)(void *self, SConnection *pCon); int (*CheckCountStatus)(void *self, SConnection *pCon); int (*Pause)(void *self, SConnection *pCon); @@ -66,23 +68,23 @@ pICountable GetCountableInterface(void *pObject); -#line 373 "interface.w" +#line 375 "interface.w" pICountable CreateCountableInterface(void); /* ------------------------- The CallBack Interface --------------------*/ -#line 227 "interface.w" +#line 229 "interface.w" typedef void (*KillFuncIT)(void *pData); typedef int (*SICSCallBack)(int iEvent, void *pEventData, void *pUserData); -#line 378 "interface.w" +#line 380 "interface.w" -#line 249 "interface.w" +#line 251 "interface.w" typedef struct __ICallBack *pICallBack; @@ -97,11 +99,11 @@ int RemoveCallback(pICallBack pInterface, long iID); int RemoveCallback2(pICallBack pInterface, void *pUserData); -#line 379 "interface.w" +#line 381 "interface.w" /*---------------------- The Environment Interface --------------------*/ -#line 307 "interface.w" +#line 309 "interface.w" typedef enum { EVIdle, EVDrive, EVMonitor, EVError } EVMode; typedef struct { @@ -111,13 +113,13 @@ int (*HandleError)(void *self); } EVInterface, *pEVInterface; -#line 381 "interface.w" +#line 383 "interface.w" -#line 333 "interface.w" +#line 335 "interface.w" pEVInterface CreateEVInterface(void); -#line 382 "interface.w" +#line 384 "interface.w" #endif diff --git a/interface.tex b/interface.tex index fc5bab80..724888b9 100644 --- a/interface.tex +++ b/interface.tex @@ -207,6 +207,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);@\\ diff --git a/interface.w b/interface.w index db0c06e2..5e106038 100644 --- a/interface.w +++ b/interface.w @@ -177,6 +177,8 @@ This is an interface for interacting with anything which counts. typedef struct { int ID; int (*Halt)(void *self); + void (*SetCountParameters)(void *self, float fPreset, + CounterMode eMode);\ int (*StartCount)(void *self, SConnection *pCon); int (*CheckCountStatus)(void *self, SConnection *pCon); int (*Pause)(void *self, SConnection *pCon); diff --git a/itc4.c b/itc4.c index 18580435..35dbfca0 100644 --- a/itc4.c +++ b/itc4.c @@ -41,10 +41,8 @@ #include #include #include "fortify.h" -#include "conman.h" +#include "sics.h" #include "splitter.h" -#include "obdes.h" -#include "interface.h" #include "obpar.h" #include "devexec.h" #include "nserver.h" diff --git a/motor.c b/motor.c index 41c558a3..d4448952 100644 --- a/motor.c +++ b/motor.c @@ -47,15 +47,12 @@ #include #include #include "fortify.h" -#include "conman.h" -#include "SCinter.h" +#include "sics.h" #include "devexec.h" #include "motor.h" #include "splitter.h" -#include "Scommon.h" #include "status.h" #include "servlog.h" -#include "event.h" /*------------------------------------------------------------------------- some lokal defines diff --git a/mumoconf.c b/mumoconf.c index a1c04580..a7131da5 100644 --- a/mumoconf.c +++ b/mumoconf.c @@ -50,10 +50,9 @@ #include #include #include "fortify.h" -#include "conman.h" +#include "sics.h" #include "devexec.h" #include "motor.h" -#include "obdes.h" #include "splitter.h" #include "stringdict.h" #include "mumo.h" diff --git a/napi.c b/napi.c index b0d5c755..1a5edaf3 100644 --- a/napi.c +++ b/napi.c @@ -35,7 +35,7 @@ ----------------------------------------------------------------------------*/ -static const char* rscid = "$Id: napi.c,v 1.3 2000/09/11 09:17:44 cvs Exp $"; /* Revision interted by CVS */ +static const char* rscid = "$Id: napi.c,v 1.4 2001/06/08 15:18:37 cvs Exp $"; /* Revision interted by CVS */ #include #include @@ -507,7 +507,7 @@ static const char* rscid = "$Id: napi.c,v 1.3 2000/09/11 09:17:44 cvs Exp $"; /* } /* start Vgroup API */ - pNew->iVID = Hopen (filename, am, 100); + pNew->iVID = Hopen (filename, am, 5000); if (pNew->iVID <= 0) { sprintf (pBuffer, "ERROR: cannot open file: %s", filename); NXIReportError (NXpData, pBuffer); @@ -1050,6 +1050,43 @@ static const char* rscid = "$Id: napi.c,v 1.3 2000/09/11 09:17:44 cvs Exp $"; /* return NX_OK; } + NXstatus + NXsetdimname(NXhandle fid, int iDim, CONSTCHAR *name) + { + pNexusFile pFile; + int32 dim_id, iRet; + + pFile = NXIassert (fid); + + /* check if there is an SDS open */ + if (pFile->iCurrentSDS == 0) { + NXIReportError (NXpData, "ERROR: no SDS open"); + return NX_ERROR; + } + + /* + get dimension ID + */ + dim_id = SDgetdimid(pFile->iCurrentSDS,iDim); + if(dim_id < 0){ + NXIReportError(NXpData, + "ERROR: trying to set dimension name for non existent dimension"); + return NX_ERROR; + } + + /* + set name + */ + iRet = SDsetdimname(dim_id,name); + if(iRet < 0){ + NXIReportError(NXpData, + "ERROR: failed to set dimension name"); + return NX_ERROR; + } + + return NX_OK; + } + NXstatus NXputdata (NXhandle fid, void *data) diff --git a/napi.h b/napi.h index e4f1bca9..23f57519 100644 --- a/napi.h +++ b/napi.h @@ -33,7 +33,7 @@ For further information, see - $Id: napi.h,v 1.2 2000/02/21 08:11:15 cvs Exp $ + $Id: napi.h,v 1.3 2001/06/08 15:18:37 cvs Exp $ ----------------------------------------------------------------------------*/ @@ -241,6 +241,8 @@ extern "C" { NXstatus NXclosegroup(NXhandle handle); NXstatus NXmakedata (NXhandle handle, CONSTCHAR* label, int datatype, int rank, int dim[]); + NXstatus NXsetdimname(NXhandle handle, int iDim, CONSTCHAR *name); + NXstatus NXopendata (NXhandle handle, CONSTCHAR* label); NXstatus NXcompress (NXhandle handle, int compr_type); NXstatus NXclosedata(NXhandle handle); diff --git a/nextrics.c b/nextrics.c index e10541c9..646947e6 100644 --- a/nextrics.c +++ b/nextrics.c @@ -320,7 +320,15 @@ "frametilt","DG1"); GetHistogram(self->pHistogram1,pCon,0,0,DET1X*DET1Y,lData, DET1X*DET1Y*sizeof(HistInt)); + /* NXDputalias(hfil,self->pDict,"framecounts",lData); + */ + NXDopenalias(hfil,self->pDict,"framecounts"); + NXputdata(hfil,lData); + NXsetdimname(hfil,0,"frame_x"); + NXsetdimname(hfil,1,"frame_y"); + NXclosedata(hfil); + fVal = fTTheta; NXDputalias(hfil,self->pDict,"frame2theta",&fVal); @@ -340,7 +348,15 @@ "frametilt","DG2"); GetHistogram(self->pHistogram2,pCon,0,0,DET2X*DET2Y,lData, DET2X*DET2Y*sizeof(HistInt)); + /* NXDputalias(hfil,self->pDict,"framecounts",lData); + */ + NXDopenalias(hfil,self->pDict,"framecounts"); + NXputdata(hfil,lData); + NXsetdimname(hfil,0,"frame_x"); + NXsetdimname(hfil,1,"frame_y"); + NXclosedata(hfil); + fVal = fTTheta + self->hm2Off; NXDputalias(hfil,self->pDict,"frame2theta",&fVal); @@ -360,7 +376,16 @@ "frametilt","DG3"); GetHistogram(self->pHistogram2,pCon,0,0,DET3X*DET3Y,lData, DET3X*DET3Y*sizeof(HistInt)); + + /* NXDputalias(hfil,self->pDict,"framecounts",lData); + */ + NXDopenalias(hfil,self->pDict,"framecounts"); + NXputdata(hfil,lData); + NXsetdimname(hfil,0,"frame_x"); + NXsetdimname(hfil,1,"frame_y"); + NXclosedata(hfil); + fVal = fTTheta + self->hm3Off; NXDputalias(hfil,self->pDict,"frame2theta",&fVal); @@ -1095,7 +1120,7 @@ if(self->pCurrentFile) free(self->pCurrentFile); iRet = IncrementDataNumber(self->pDanu,&iYear); - sprintf(pBueffel,"%s/trics%4.4d%4.4d.hdf",self->pFileRoot,iRet, iYear); + sprintf(pBueffel,"%s/trics%5.5d%4.4d.hdf",self->pFileRoot,iRet, iYear); self->pCurrentFile = strdup(pBueffel); iRet = NXopen(self->pCurrentFile,NXACC_CREATE,&hfil); if(iRet != NX_OK) diff --git a/nserver.c b/nserver.c index b6f77a8f..e9e9ada4 100644 --- a/nserver.c +++ b/nserver.c @@ -21,20 +21,17 @@ #include #include #include -#include "conman.h" -#include "SCinter.h" +#include "sics.h" #include "network.h" #include "ifile.h" #include "status.h" #include "devexec.h" -#include "ofac.h" #include "passwd.h" #include "lld.h" #include "macro.h" -#include "interface.h" #include "perfmon.h" #include "nread.h" -#include "event.h" +#include "ofac.h" #include "telnet.h" #include "nserver.h" diff --git a/nxdata.c b/nxdata.c index 656c7391..6b028d04 100644 --- a/nxdata.c +++ b/nxdata.c @@ -44,9 +44,7 @@ #include #include #include "fortify.h" -#include "conman.h" -#include "obdes.h" -#include "interface.h" +#include "sics.h" #include "sicsvar.h" #include "nxdict.h" #include "modriv.h" diff --git a/nxdict.c b/nxdict.c index 7dc51116..5c8a6303 100644 --- a/nxdict.c +++ b/nxdict.c @@ -1167,6 +1167,14 @@ LLDdelete(iList); return iRet; } + /* + stop creation of superfluous dimension scales for single + numbers + */ + if(iRank == 1 && iDim[0] == 1) + { + NXsetdimname(hfil,0,"singleDim"); + } /* deal with compression, if appropriate */ if(iCompress != 0) { diff --git a/nxsans.c b/nxsans.c index b3f4588c..ee8a9034 100644 --- a/nxsans.c +++ b/nxsans.c @@ -44,9 +44,7 @@ #include #include #include "fortify.h" -#include "conman.h" -#include "obdes.h" -#include "interface.h" +#include "sics.h" #include "sicsvar.h" #include "napi.h" #include "nxdict.h" diff --git a/o2t.c b/o2t.c index 854c3f67..9bd33133 100644 --- a/o2t.c +++ b/o2t.c @@ -43,9 +43,7 @@ #include #include #include "fortify.h" -#include "conman.h" -#include "obdes.h" -#include "interface.h" +#include "sics.h" #include "fupa.h" #include "motor.h" #include "o2t.h" diff --git a/obdes.h b/obdes.h index 13e046cf..249dc2a0 100644 --- a/obdes.h +++ b/obdes.h @@ -1,5 +1,5 @@ -#line 339 "interface.w" +#line 341 "interface.w" #line 29 "interface.w" @@ -51,5 +51,5 @@ typedef struct { #endif -#line 340 "interface.w" +#line 342 "interface.w" diff --git a/ofac.c b/ofac.c index e268f5d5..bef1e74b 100644 --- a/ofac.c +++ b/ofac.c @@ -41,15 +41,12 @@ #include #include #include "fortify.h" +#include "sics.h" #include "ifile.h" #include "sicsexit.h" -#include "obdes.h" -#include "interface.h" #include "passwd.h" -#include "conman.h" #include "macro.h" #include "splitter.h" -#include "SCinter.h" #include "sicsvar.h" #include "drive.h" #include "motor.h" @@ -106,6 +103,7 @@ #include "synchronize.h" #include "definealias.h" #include "swmotor.h" +#include "hmcontrol.h" /*----------------------- Server options creation -------------------------*/ static int IFServerOption(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]) @@ -284,6 +282,7 @@ AddCommand(pInter,"MakeTAS",TASFactory,NULL,NULL); AddCommand(pInter,"MakeSync",MakeSync,NULL,NULL); AddCommand(pInter,"MakeSWMotor",MakeSWMotor,NULL,NULL); + AddCommand(pInter,"MakeHMControl",MakeHMControl,NULL,NULL); } /*---------------------------------------------------------------------------*/ static void KillIniCommands(SicsInterp *pSics) @@ -339,6 +338,7 @@ RemoveCommand(pSics,"MakeTAS"); RemoveCommand(pSics,"MakeSync"); RemoveCommand(pSics,"MakeSWMotor"); + RemoveCommand(pSics,"MakeHMControl"); } diff --git a/perfmon.c b/perfmon.c index 47d267c7..e43cfaac 100644 --- a/perfmon.c +++ b/perfmon.c @@ -40,11 +40,7 @@ #include #include #include "fortify.h" -#include "conman.h" -#include "SCinter.h" -#include "obdes.h" -#include "interface.h" -#include "event.h" +#include "sics.h" #include "servlog.h" #include "perfmon.h" #include "perfmon.i" @@ -254,4 +250,4 @@ } } } - \ No newline at end of file + diff --git a/scan.c b/scan.c index 8ea70b6e..4017c706 100644 --- a/scan.c +++ b/scan.c @@ -371,7 +371,7 @@ extern void SNXFormatTime(char *pBuffer, int iLen); strcat(pInfo,pItem); } } - strcat(pLine,"Counts "); + strcat(pLine," Counts "); strcat(pLine,"Monitor1 "); strcat(pLine,"Monitor2 "); strcat(pLine,"Monitor3 "); @@ -411,7 +411,7 @@ extern void SNXFormatTime(char *pBuffer, int iLen); pData = (pCountEntry)pPtr; if(pData) { - sprintf(pItem,"%-12ld",pData->lCount); + sprintf(pItem," %-12ld",pData->lCount); strcat(pLine,pItem); sprintf(pItem,"%-12ld",pData->Monitors[0]); strcat(pLine,pItem); diff --git a/script.c b/script.c index 133cc029..5b2cc9c6 100644 --- a/script.c +++ b/script.c @@ -45,8 +45,7 @@ #include #include #include "fortify.h" -#include "conman.h" -#include "obdes.h" +#include "sics.h" #include "fupa.h" #include "motor.h" #include "countdriv.h" diff --git a/selector.c b/selector.c index 1490c16c..df0846e5 100644 --- a/selector.c +++ b/selector.c @@ -44,11 +44,7 @@ #include #include #include "fortify.h" -#include "conman.h" -#include "SCinter.h" -#include "Scommon.h" -#include "obdes.h" -#include "interface.h" +#include "sics.h" #include "motor.h" #include "splitter.h" #include "devexec.h" diff --git a/selvar.c b/selvar.c index 932f6c9e..711274a1 100644 --- a/selvar.c +++ b/selvar.c @@ -44,17 +44,12 @@ #include #include #include "fortify.h" -#include "conman.h" -#include "SCinter.h" -#include "Scommon.h" -#include "obdes.h" +#include "sics.h" #include "motor.h" #include "splitter.h" #include "devexec.h" #include "selector.h" #include "selvar.h" -#include "interface.h" -#include "event.h" #define DRIVE "drive" #include "selvar.i" diff --git a/sics.h b/sics.h index 6f6339f5..1e3a3e24 100644 --- a/sics.h +++ b/sics.h @@ -9,6 +9,12 @@ -----------------------------------------------------------------------------*/ #ifndef SICSSICS #define SICSSICS + + typedef enum { + eTimer, + ePreset + }CounterMode; + #include #include #include @@ -24,6 +30,7 @@ #include "nserver.h" #include "servlog.h" extern pServer pServ; + #endif - \ No newline at end of file + diff --git a/sicsstatus.tcl b/sicsstatus.tcl index 1a9eb239..fa848d29 100644 --- a/sicsstatus.tcl +++ b/sicsstatus.tcl @@ -1,30 +1,9 @@ -a5l.length 80.000000 -flightpathlength 0.000000 -flightpathlength setAccess 1 -flightpath 0.000000 -flightpath setAccess 1 -delay 2500.000000 -delay setAccess 1 -hm CountMode timer -hm preset 100.000000 -hm genbin 120.000000 35.000000 512 -hm init -datafile focus-1001848.hdf -datafile setAccess 3 +hm3 CountMode timer +hm3 preset 50.000000 hm2 CountMode timer -hm2 preset 100.000000 +hm2 preset 50.000000 hm1 CountMode timer -hm1 preset 100.000000 -dbfile UNKNOWN -dbfile setAccess 2 -# Motor th -th SoftZero 0.000000 -th SoftLowerLim -120.000000 -th SoftUpperLim 120.000000 -th Fixed -1.000000 -th sign 1.000000 -th InterruptMode 0.000000 -th AccessCode 2.000000 +hm1 preset 50.000000 #Crystallographic Settings hkl lambda 0.703790 hkl setub -0.124702 0.001618 -0.041357 -0.104448 -0.001326 0.049388 0.000751 0.084094 0.001574 @@ -148,8 +127,6 @@ twotheta InterruptMode 0.000000 twotheta AccessCode 2.000000 lastscancommand UNKNOWN lastscancommand setAccess 2 -banana CountMode timer -banana preset 2.000000 sample_mur 0.000000 sample_mur setAccess 2 email UNKNOWN @@ -161,7 +138,7 @@ phone setAccess 2 adress UNKNOWN adress setAccess 2 # Counter counter -counter SetPreset 10.000000 +counter SetPreset 50.000000 counter SetMode Timer # Motor som som SoftZero 0.000000 @@ -433,5 +410,5 @@ sample DanielOxid sample setAccess 2 title TopsiTupsiTapsi title setAccess 2 -starttime 2001-03-12 14:55:05 +starttime 2001-06-06 14:23:05 starttime setAccess 2 diff --git a/sicvar.c b/sicvar.c index fae69cf1..49a3c81f 100644 --- a/sicvar.c +++ b/sicvar.c @@ -39,14 +39,10 @@ #include "fortify.h" #include #include -#include "Scommon.h" +#include "sics.h" #include -#include "SCinter.h" -#include "conman.h" #include "splitter.h" #include "status.h" -#include "interface.h" -#include "event.h" #include "sicsvar.h" /*-------------------------------------------------------------------------*/ diff --git a/simcter.c b/simcter.c index 72fc3d73..608d504a 100644 --- a/simcter.c +++ b/simcter.c @@ -44,7 +44,7 @@ #include #include "fortify.h" #include -#include "Scommon.h" +#include "sics.h" #include "countdriv.h" /*--------------------------------------------------------------------------- A SIMCOUNTER HAS a BUILT IN FAILURE RATE OF 10% FOR TESTING ERROR HANDLING diff --git a/sinqhm/SinqHM_def.h b/sinqhm/SinqHM_def.h index 724cf110..7d1ee8e6 100755 --- a/sinqhm/SinqHM_def.h +++ b/sinqhm/SinqHM_def.h @@ -23,7 +23,7 @@ #define MAX_CLIENTS 8 /* The maximum number of active clients */ #define MAX_TOF_CNTR 1024 /* The maximum number of individual counters .. ** which can be handled in TOF mode */ -#define MAX_PSD_CNTR 65536 /* maximum number of PSD elements */ +#define MAX_PSD_CNTR 1048576 /* maximum number of PSD elements */ #define MAX_TOF_NBINS 32768 /* The maximum number of bins in a TOF histog */ #define MAX_TOF_EDGE 16 /* The maximum number of TOF edge arrays */ #define VMIO_BASE_ADDR 0x1900 /* VME address of a (possible) VMIO10 module */ diff --git a/sinqhm/SinqHM_srv_filler.c b/sinqhm/SinqHM_srv_filler.c index e8ebd4c9..f16b7673 100755 --- a/sinqhm/SinqHM_srv_filler.c +++ b/sinqhm/SinqHM_srv_filler.c @@ -168,6 +168,7 @@ taskDelay (0); /* If FIFO is empty, we can take a breather! */ }else if ((lwl_hdr.ui4 & LWL_HDR_TYPE_MASK) == LWL_HM_NC_C1) { VmioBase[VMIO_PORT_A] = 0xff; /* Set timer level (if present) */ + for (i=0; i<1000000; i++) { lwl_data.ui4 = *Lwl_fifo; /* Get the 16 bits of data */ @@ -176,7 +177,7 @@ } taskDelay (0); /* But wait if FIFO is slow! */ } - + if (lwl_data.ui4 == LWL_FIFO_EMPTY) { printf ("Time-out getting histogram data word! Event # = %d\n", N_events); @@ -255,7 +256,6 @@ */ }else { /* Anything else gets flushed */ lwl_Packet_Read (lwl_hdr.ui4, my_buff); - } /* if (FillTimer_expired) { */ @@ -809,8 +809,8 @@ if(yPos >= 32767) yPos -= 65536; - xPos = (xPos + psdXOffset)/psdXFactor; - yPos = (yPos + psdYOffset)/psdYFactor; + xPos = xPos/psdXFactor + psdXOffset; + yPos = yPos/psdYFactor + psdYOffset; if(xPos < 0 || xPos > psdXSize) { printf("X position out of range: %d, alllowed 0 - %d\n", diff --git a/sinqhmdriv.c b/sinqhmdriv.c index 03027cb4..425ff437 100644 --- a/sinqhmdriv.c +++ b/sinqhmdriv.c @@ -44,10 +44,7 @@ #include #include #include "fortify.h" -#include "conman.h" -#include "SCinter.h" -#include "obdes.h" -#include "interface.h" +#include "sics.h" #include "countdriv.h" #include "counter.h" #include "HistMem.h" diff --git a/status.c b/status.c index 23c7856d..b755bd3c 100644 --- a/status.c +++ b/status.c @@ -41,11 +41,10 @@ #include #include "fortify.h" #include -#include "conman.h" +#include "sics.h" #include "status.h" #include "interrupt.h" #include "devexec.h" -#include "interface.h" #define VALUECHANGE 2 static Status eCode = eEager; diff --git a/tecsdriv.c b/tecsdriv.c index 36b53001..00a4c749 100644 --- a/tecsdriv.c +++ b/tecsdriv.c @@ -43,10 +43,8 @@ #include #include #include "fortify.h" -#include "conman.h" +#include "sics.h" #include "splitter.h" -#include "obdes.h" -#include "interface.h" #include "obpar.h" #include "devexec.h" #include "nserver.h" diff --git a/trics.dic b/trics.dic index e728fe4c..fc590ac6 100644 --- a/trics.dic +++ b/trics.dic @@ -72,7 +72,7 @@ frametilt = /$(framename),NXentry/TRICS,NXinstrument/$(dnumber),NXdetector/SDS -attr {units,degrees} framecounts = /$(framename),NXentry/TRICS,NXinstrument/$(dnumber),NXdetector/SDS counts \ -attr {signal,1} -attr {units,counts} -type DFNT_INT32 \ - -LZW -rank 2 -dim {$(framedim1),$(framedim2)} + -rank 2 -dim {$(framedim1),$(framedim2)} detzerox = \ /frame0000,NXentry/TRICS,NXinstrument/$(dnumber),NXdetector/SDS x_zero_point \ -attr {units,pixel}