- Poldi data file writing with automatic update
- many fixes to TAS - Changed HM code for ILL PSD to account for Christoph's offset to positive.
This commit is contained in:
@ -10,7 +10,7 @@
|
|||||||
----------------------------------------------------------------------------*/
|
----------------------------------------------------------------------------*/
|
||||||
#ifndef SICSHISTDRIV
|
#ifndef SICSHISTDRIV
|
||||||
#define SICSHISTDRIV
|
#define SICSHISTDRIV
|
||||||
#define MAXCHAN 4096
|
#define MAXCHAN 16834
|
||||||
|
|
||||||
|
|
||||||
#line 82 "histogram.w"
|
#line 82 "histogram.w"
|
||||||
|
@ -185,8 +185,8 @@ Motor COX SIM -100. 100. .1 2. # counter x
|
|||||||
ClientPut "Motors initialized"
|
ClientPut "Motors initialized"
|
||||||
|
|
||||||
#======================== histogram memory
|
#======================== histogram memory
|
||||||
MakeHM hm SinqHM
|
#MakeHM hm SinqHM
|
||||||
#MakeHM hm SIM
|
MakeHM hm SIM
|
||||||
hm configure HistMode PSD
|
hm configure HistMode PSD
|
||||||
hm configure OverFlowMode Ceil
|
hm configure OverFlowMode Ceil
|
||||||
hm configure Rank 1
|
hm configure Rank 1
|
||||||
|
2
danu.dat
2
danu.dat
@ -1,3 +1,3 @@
|
|||||||
189
|
212
|
||||||
NEVER, EVER modify or delete this file
|
NEVER, EVER modify or delete this file
|
||||||
You'll risk eternal damnation and a reincarnation as a cockroach!|n
|
You'll risk eternal damnation and a reincarnation as a cockroach!|n
|
@ -62,7 +62,6 @@
|
|||||||
#include "dynstring.h"
|
#include "dynstring.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "status.h"
|
#include "status.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define LOADDEBUG 1
|
#define LOADDEBUG 1
|
||||||
*/
|
*/
|
||||||
|
@ -629,7 +629,7 @@ following.
|
|||||||
\mbox{}\verb@----------------------------------------------------------------------------*/@\\
|
\mbox{}\verb@----------------------------------------------------------------------------*/@\\
|
||||||
\mbox{}\verb@#ifndef SICSHISTDRIV@\\
|
\mbox{}\verb@#ifndef SICSHISTDRIV@\\
|
||||||
\mbox{}\verb@#define SICSHISTDRIV@\\
|
\mbox{}\verb@#define SICSHISTDRIV@\\
|
||||||
\mbox{}\verb@#define MAXCHAN 4096@\\
|
\mbox{}\verb@#define MAXCHAN 16834 @\\
|
||||||
\mbox{}\verb@@\\
|
\mbox{}\verb@@\\
|
||||||
\mbox{}\verb@@$\langle$HistType {\footnotesize ?}$\rangle$\verb@@\\
|
\mbox{}\verb@@$\langle$HistType {\footnotesize ?}$\rangle$\verb@@\\
|
||||||
\mbox{}\verb@@$\langle$HistDrivProt {\footnotesize ?}$\rangle$\verb@@\\
|
\mbox{}\verb@@$\langle$HistDrivProt {\footnotesize ?}$\rangle$\verb@@\\
|
||||||
|
@ -484,7 +484,7 @@ following.
|
|||||||
----------------------------------------------------------------------------*/
|
----------------------------------------------------------------------------*/
|
||||||
#ifndef SICSHISTDRIV
|
#ifndef SICSHISTDRIV
|
||||||
#define SICSHISTDRIV
|
#define SICSHISTDRIV
|
||||||
#define MAXCHAN 4096
|
#define MAXCHAN 16834
|
||||||
|
|
||||||
@< HistType@>
|
@< HistType@>
|
||||||
@< HistDrivProt @>
|
@< HistDrivProt @>
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "udpquieck.h"
|
#include "udpquieck.h"
|
||||||
#include "nextrics.h"
|
#include "nextrics.h"
|
||||||
|
|
||||||
|
|
||||||
#define DET1X 256 /* x -length of detector 1 */
|
#define DET1X 256 /* x -length of detector 1 */
|
||||||
#define DET1Y 128 /* y-length of detector 1 */
|
#define DET1Y 128 /* y-length of detector 1 */
|
||||||
#define DET1XS 2 /* pixel size in x of detector 1 */
|
#define DET1XS 2 /* pixel size in x of detector 1 */
|
||||||
@ -308,7 +309,7 @@ name of hkl object holding crystallographic information
|
|||||||
CounterMode eMode;
|
CounterMode eMode;
|
||||||
HistInt lData[DET1X*DET1Y], i, lVal;
|
HistInt lData[DET1X*DET1Y], i, lVal;
|
||||||
int32 iVal,lBeam;
|
int32 iVal,lBeam;
|
||||||
float fVal, fTTheta;
|
float fVal, fTTheta, fTime = 0.;
|
||||||
pMotor pMot;
|
pMotor pMot;
|
||||||
|
|
||||||
/* write motors */
|
/* write motors */
|
||||||
@ -368,6 +369,7 @@ name of hkl object holding crystallographic information
|
|||||||
eMode = GetCounterMode(self->pCount);
|
eMode = GetCounterMode(self->pCount);
|
||||||
fVal = GetCounterPreset(self->pCount);
|
fVal = GetCounterPreset(self->pCount);
|
||||||
lVal = GetMonitor(self->pCount,1,pCon);
|
lVal = GetMonitor(self->pCount,1,pCon);
|
||||||
|
fTime = GetCountTime(self->pCount,pCon);
|
||||||
lBeam = GetMonitor(self->pCount,4,pCon);
|
lBeam = GetMonitor(self->pCount,4,pCon);
|
||||||
}
|
}
|
||||||
if(eMode == eTimer)
|
if(eMode == eTimer)
|
||||||
@ -384,6 +386,7 @@ name of hkl object holding crystallographic information
|
|||||||
NXDputalias(hfil,self->pDict,"framemonitor",&iVal);
|
NXDputalias(hfil,self->pDict,"framemonitor",&iVal);
|
||||||
iVal = (int32)lBeam;
|
iVal = (int32)lBeam;
|
||||||
NXDputalias(hfil,self->pDict,"sinqmonitor",&iVal);
|
NXDputalias(hfil,self->pDict,"sinqmonitor",&iVal);
|
||||||
|
NXDputalias(hfil,self->pDict,"cctime",&fTime);
|
||||||
|
|
||||||
/* write detector1 histogram */
|
/* write detector1 histogram */
|
||||||
if(self->pHistogram1 != NULL)
|
if(self->pHistogram1 != NULL)
|
||||||
|
8
nxdata.c
8
nxdata.c
@ -347,7 +347,7 @@
|
|||||||
void *pData)
|
void *pData)
|
||||||
{
|
{
|
||||||
int iStat;
|
int iStat;
|
||||||
int32 iDim[2];
|
int iDim[2];
|
||||||
|
|
||||||
iDim[0] = iLong;
|
iDim[0] = iLong;
|
||||||
iStat = NXmakedata (Nfil, name, datatype, 1, (int *) iDim);
|
iStat = NXmakedata (Nfil, name, datatype, 1, (int *) iDim);
|
||||||
@ -383,7 +383,7 @@
|
|||||||
void *pData, char *attname, char *val)
|
void *pData, char *attname, char *val)
|
||||||
{
|
{
|
||||||
int iStat;
|
int iStat;
|
||||||
int32 iDim[2];
|
int iDim[2];
|
||||||
|
|
||||||
iDim[0] = iLong;
|
iDim[0] = iLong;
|
||||||
iStat = NXmakedata (Nfil, name, datatype, 1, (int *) iDim);
|
iStat = NXmakedata (Nfil, name, datatype, 1, (int *) iDim);
|
||||||
@ -465,7 +465,7 @@
|
|||||||
pSelVar pPell;
|
pSelVar pPell;
|
||||||
char *pP;
|
char *pP;
|
||||||
float fVal;
|
float fVal;
|
||||||
float32 *fTheta;
|
float *fTheta;
|
||||||
float fTh, f2Th, fB1, fB2;
|
float fTh, f2Th, fB1, fB2;
|
||||||
pMotor pMot = NULL;
|
pMotor pMot = NULL;
|
||||||
CommandList *pCom = NULL;
|
CommandList *pCom = NULL;
|
||||||
@ -474,7 +474,7 @@
|
|||||||
pHistMem pHist = NULL;
|
pHistMem pHist = NULL;
|
||||||
HistInt *lData = NULL;
|
HistInt *lData = NULL;
|
||||||
CounterMode eCount;
|
CounterMode eCount;
|
||||||
int32 *iTVal = NULL;
|
int *iTVal = NULL;
|
||||||
pDummy pDum;
|
pDummy pDum;
|
||||||
int bHRPT = 0;
|
int bHRPT = 0;
|
||||||
float fMean, fStdDev;
|
float fMean, fStdDev;
|
||||||
|
1
nxdict.c
1
nxdict.c
@ -34,7 +34,6 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <mfhdf.h>
|
|
||||||
#include "lld.h"
|
#include "lld.h"
|
||||||
#include "napi.h"
|
#include "napi.h"
|
||||||
#include "stringdict.h"
|
#include "stringdict.h"
|
||||||
|
1
nxsans.c
1
nxsans.c
@ -62,6 +62,7 @@
|
|||||||
#include "mumo.h"
|
#include "mumo.h"
|
||||||
#include "sanswave.h"
|
#include "sanswave.h"
|
||||||
|
|
||||||
|
|
||||||
#define HISTNAME "banana"
|
#define HISTNAME "banana"
|
||||||
#define SAMPLETABLE "sampletable"
|
#define SAMPLETABLE "sampletable"
|
||||||
|
|
||||||
|
682
polterwrite.c
682
polterwrite.c
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
P O L T E R W R I T E
|
P O L T E R W R I T E
|
||||||
|
|
||||||
fowrite is an object for writing POLTERDI data files.
|
Polterwrite is an object for writing POLTI data files.
|
||||||
|
|
||||||
copyright: see copyright.h
|
copyright: see copyright.h
|
||||||
|
|
||||||
@ -9,8 +9,12 @@
|
|||||||
----------------------------------------------------------------------------*/
|
----------------------------------------------------------------------------*/
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "fortify.h"
|
#include <math.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <tcl.h>
|
||||||
|
#undef VOID
|
||||||
#include "sics.h"
|
#include "sics.h"
|
||||||
|
#include "event.h"
|
||||||
#include "counter.h"
|
#include "counter.h"
|
||||||
#include "HistMem.h"
|
#include "HistMem.h"
|
||||||
#include "nxdict.h"
|
#include "nxdict.h"
|
||||||
@ -22,41 +26,68 @@
|
|||||||
/*
|
/*
|
||||||
diaphragm1 - chopper
|
diaphragm1 - chopper
|
||||||
*/
|
*/
|
||||||
#define DIA1DIST 3000
|
#define DIA1DIST 8000
|
||||||
/*
|
|
||||||
diaphragm2 - diaphragm1
|
|
||||||
*/
|
|
||||||
#define DIA2DIST 500
|
|
||||||
|
|
||||||
/*
|
|
||||||
diaphragm2 - sample position
|
|
||||||
*/
|
|
||||||
#define SADIST 500
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
histogram memory name
|
histogram memory name
|
||||||
*/
|
*/
|
||||||
#define HM "hm"
|
#define HM "hm"
|
||||||
/*
|
|
||||||
detector distance - sample
|
|
||||||
*/
|
|
||||||
#define DETDIST 700
|
|
||||||
/*
|
|
||||||
no detectors, change in poldi.dic as well
|
|
||||||
*/
|
|
||||||
#define NODET 400
|
|
||||||
/*
|
|
||||||
theta spacing
|
|
||||||
*/
|
|
||||||
#define THSPACE .3
|
|
||||||
|
|
||||||
|
|
||||||
|
#define DETRADIUS 3000
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
pObjectDescriptor pDes;
|
pObjectDescriptor pDes;
|
||||||
|
pHistMem pHist;
|
||||||
|
int iNew;
|
||||||
|
time_t tUpdate;
|
||||||
|
int iInterval;
|
||||||
|
int iEnd;
|
||||||
|
SConnection *pCon;
|
||||||
char *dictfile;
|
char *dictfile;
|
||||||
|
char *pFile;
|
||||||
}Polterdi, *pPolterdi;
|
}Polterdi, *pPolterdi;
|
||||||
|
|
||||||
|
/* ------------------- forward declaration of task function --------------*/
|
||||||
|
static int PoldiTask(void *pData);
|
||||||
|
static void PoldiUpdate(pPolterdi self, SConnection *pCon);
|
||||||
|
|
||||||
|
/*------------------ The Countstart Callback Function ----------------------*/
|
||||||
|
static int Countstartcallback(int iEvent, void *pEventData, void *pUser)
|
||||||
|
{
|
||||||
|
pPolterdi self = NULL;
|
||||||
|
|
||||||
|
if(iEvent == COUNTSTART)
|
||||||
|
{
|
||||||
|
self = (pPolterdi)pUser;
|
||||||
|
assert(self);
|
||||||
|
self->iNew = 1;
|
||||||
|
self->iEnd = 0;
|
||||||
|
self->tUpdate = time(NULL);
|
||||||
|
self->pCon = (SConnection *)pEventData;
|
||||||
|
TaskRegister(pServ->pTasker,PoldiTask,NULL,NULL,self,1);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/*------------------ The Countend Callback Function ----------------------*/
|
||||||
|
static int Countendcallback(int iEvent, void *pEventData, void *pUser)
|
||||||
|
{
|
||||||
|
pPolterdi self = NULL;
|
||||||
|
|
||||||
|
if(iEvent == COUNTEND)
|
||||||
|
{
|
||||||
|
self = (pPolterdi)pUser;
|
||||||
|
assert(self);
|
||||||
|
self->tUpdate = time(NULL);
|
||||||
|
self->iEnd = 1;
|
||||||
|
PoldiUpdate(self,self->pCon);
|
||||||
|
/*
|
||||||
|
Fortify_CheckAllMemory();
|
||||||
|
*/
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
static void KillPolterdi(void *pData){
|
static void KillPolterdi(void *pData){
|
||||||
pPolterdi self = (pPolterdi)pData;
|
pPolterdi self = (pPolterdi)pData;
|
||||||
@ -66,6 +97,9 @@ static void KillPolterdi(void *pData){
|
|||||||
if(self->pDes){
|
if(self->pDes){
|
||||||
DeleteDescriptor(self->pDes);
|
DeleteDescriptor(self->pDes);
|
||||||
}
|
}
|
||||||
|
if(self->pFile){
|
||||||
|
free(self->pFile);
|
||||||
|
}
|
||||||
if(self->dictfile){
|
if(self->dictfile){
|
||||||
free(self->dictfile);
|
free(self->dictfile);
|
||||||
}
|
}
|
||||||
@ -77,12 +111,26 @@ int PolterInstall(SConnection *pCon, SicsInterp *pSics,
|
|||||||
void *pData, int argc, char *argv[])
|
void *pData, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
pPolterdi pNew = NULL;
|
pPolterdi pNew = NULL;
|
||||||
|
pICallBack pCall = NULL;
|
||||||
|
pDummy pDum;
|
||||||
|
pHistMem pHist = NULL;
|
||||||
|
|
||||||
|
/* configure fortify */
|
||||||
|
/*
|
||||||
|
iFortifyScope = Fortify_EnterScope();
|
||||||
|
Fortify_CheckAllMemory();
|
||||||
|
*/
|
||||||
if(argc < 2){
|
if(argc < 2){
|
||||||
SCWrite(pCon,"ERROR: insufficient number of arguments to PolterInstall",
|
SCWrite(pCon,"ERROR: insufficient number of arguments to PolterInstall",
|
||||||
eError);
|
eError);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
pHist = (pHistMem)FindCommandData(pSics,HM,"HistMem");
|
||||||
|
|
||||||
|
if (!pHist)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
pNew = (pPolterdi)malloc(sizeof(Polterdi));
|
pNew = (pPolterdi)malloc(sizeof(Polterdi));
|
||||||
if(!pNew){
|
if(!pNew){
|
||||||
@ -92,24 +140,42 @@ int PolterInstall(SConnection *pCon, SicsInterp *pSics,
|
|||||||
}
|
}
|
||||||
memset(pNew,0,sizeof(Polterdi));
|
memset(pNew,0,sizeof(Polterdi));
|
||||||
pNew->pDes = CreateDescriptor("PolterdiWrite");
|
pNew->pDes = CreateDescriptor("PolterdiWrite");
|
||||||
|
pNew->pHist = pHist;
|
||||||
pNew->dictfile = strdup(argv[1]);
|
pNew->dictfile = strdup(argv[1]);
|
||||||
|
pNew->iInterval = 20*60;
|
||||||
if(!pNew->pDes || !pNew->dictfile){
|
if(!pNew->pDes || !pNew->dictfile){
|
||||||
SCWrite(pCon,"ERROR: out of memory in PolterInstall",
|
SCWrite(pCon,"ERROR: out of memory in PolterInstall",
|
||||||
eError);
|
eError);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return AddCommand(pSics,"storedata",PolterAction,KillPolterdi,pNew);
|
/* install callbacks */
|
||||||
|
pDum = (pDummy)pHist;
|
||||||
|
pCall = (pICallBack)pDum->pDescriptor->GetInterface(pHist,CALLBACKINTERFACE);
|
||||||
|
if(!pCall)
|
||||||
|
{
|
||||||
|
SCWrite(pCon,
|
||||||
|
"ERROR: no callback interface found at your histogram memory",
|
||||||
|
eError);
|
||||||
|
KillPolterdi(pNew);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
RegisterCallback(pCall,COUNTSTART,Countstartcallback,pNew,NULL);
|
||||||
|
RegisterCallback(pCall,COUNTEND,Countendcallback,pNew,NULL);
|
||||||
|
|
||||||
|
AddCommand(pSics,"storedata",PolterAction,KillPolterdi,pNew);
|
||||||
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
/*-------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------*/
|
||||||
static void writePolterdiGlobal(NXhandle hfil, NXdict hdict, SConnection *pCon,
|
static void writePolterdiGlobal(NXhandle hfil, NXdict hdict,
|
||||||
SicsInterp *pSics){
|
SConnection *pCon){
|
||||||
char pBueffel[512];
|
char pBueffel[512];
|
||||||
|
|
||||||
SNXSPutVariable(pSics,pCon,hfil,hdict,"etitle","title");
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"etitle","title");
|
||||||
SNXFormatTime(pBueffel,511);
|
SNXFormatTime(pBueffel,511);
|
||||||
|
|
||||||
NXDputalias(hfil,hdict,"estart",pBueffel);
|
NXDputalias(hfil,hdict,"estart",pBueffel);
|
||||||
SNXSPutVariable(pSics,pCon,hfil,hdict,"iname","instrument");
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"iname","instrument");
|
||||||
sprintf(pBueffel,"%d",strlen("SINQ, PSI, Switzerland"));
|
sprintf(pBueffel,"%d",strlen("SINQ, PSI, Switzerland"));
|
||||||
NXDupdate(hdict,"strdim",pBueffel);
|
NXDupdate(hdict,"strdim",pBueffel);
|
||||||
NXDputalias(hfil,hdict,"sname","SINQ, PSI, Switzerland");
|
NXDputalias(hfil,hdict,"sname","SINQ, PSI, Switzerland");
|
||||||
@ -119,95 +185,142 @@ static void writePolterdiGlobal(NXhandle hfil, NXdict hdict, SConnection *pCon,
|
|||||||
NXDupdate(hdict,"strdim","132");
|
NXDupdate(hdict,"strdim","132");
|
||||||
}
|
}
|
||||||
/*-------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------*/
|
||||||
static void writeChopper(NXhandle hfil, NXdict hdict, SConnection *pCon,
|
static void writeChopper(NXhandle hfil, NXdict hdict, SConnection *pCon){
|
||||||
SicsInterp *pSics){
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"cname","choppername");
|
||||||
SNXSPutVariable(pSics,pCon,hfil,hdict,"cname","choppername");
|
SNXSPutDrivable(pServ->pSics,pCon,hfil,hdict,"chopperspeed","crot");
|
||||||
SNXSPutDrivable(pSics,pCon,hfil,hdict,"chopperspeed","crot");
|
|
||||||
}
|
}
|
||||||
/*-------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------*/
|
||||||
static void writeDiaphragm1(NXhandle hfil, NXdict hdict, SConnection *pCon,
|
static void writeDiaphragm1(NXhandle hfil, NXdict hdict,
|
||||||
SicsInterp *pSics){
|
SConnection *pCon){
|
||||||
float dist;
|
float dist;
|
||||||
|
|
||||||
SNXSPutMotor(pSics,pCon,hfil,hdict,"dia1x","d1m");
|
SNXSPutMotor(pServ->pSics,pCon,hfil,hdict,"dia1x","d1m");
|
||||||
SNXSPutMotorNull(pSics,pCon,hfil,hdict,"dia1x0","d1m");
|
SNXSPutMotorNull(pServ->pSics,pCon,hfil,hdict,"dia1x0","d1m");
|
||||||
SNXSPutMotor(pSics,pCon,hfil,hdict,"dia1y","d1o");
|
SNXSPutMotor(pServ->pSics,pCon,hfil,hdict,"dia1y","d1o");
|
||||||
SNXSPutMotorNull(pSics,pCon,hfil,hdict,"dia1y0","d1o");
|
SNXSPutMotorNull(pServ->pSics,pCon,hfil,hdict,"dia1y0","d1o");
|
||||||
dist = (float)DIA1DIST;
|
dist = (float)DIA1DIST;
|
||||||
NXDputalias(hfil,hdict,"dia1dist",&dist);
|
NXDputalias(hfil,hdict,"dia1dist",&dist);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
|
|
||||||
static void writeDiaphragm2(NXhandle hfil, NXdict hdict, SConnection *pCon,
|
static void writeDiaphragm2(NXhandle hfil, NXdict hdict,
|
||||||
SicsInterp *pSics){
|
SConnection *pCon){
|
||||||
float dist2;
|
|
||||||
|
|
||||||
SNXSPutMotor(pSics, pCon, hfil, hdict, "dia2x_plus", "d2m");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "dia2x_plus", "d2m");
|
||||||
SNXSPutMotorNull(pSics, pCon, hfil, hdict, "dia2xplus0", "d2m");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "dia2xplus0", "d2m");
|
||||||
SNXSPutMotor(pSics, pCon, hfil, hdict, "dia2x_minus", "d2u");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "dia2x_minus", "d2u");
|
||||||
SNXSPutMotorNull(pSics, pCon, hfil, hdict, "dia2xminus0", "d2u");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "dia2xminus0", "d2u");
|
||||||
SNXSPutMotor(pSics, pCon, hfil, hdict, "dia2z_plus", "d2o");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "dia2z_plus", "d2o");
|
||||||
SNXSPutMotorNull(pSics, pCon, hfil, hdict, "dia2zplus0", "d2o");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "dia2zplus0", "d2o");
|
||||||
SNXSPutMotor(pSics, pCon, hfil, hdict, "dia2z_minus", "d2l");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "dia2z_minus", "d2l");
|
||||||
SNXSPutMotorNull(pSics, pCon, hfil, hdict, "dia2zminus0", "d2l");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "dia2zminus0", "d2l");
|
||||||
|
|
||||||
dist2 = (float) DIA2DIST;
|
|
||||||
|
|
||||||
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"dia2dist","dia1_dia2");
|
||||||
}
|
}
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
static void writeSample(NXhandle hfil, NXdict hdict, SConnection *pCon,
|
static void writeSample(NXhandle hfil, NXdict hdict,
|
||||||
SicsInterp *pSics)
|
SConnection *pCon)
|
||||||
{
|
{
|
||||||
float sadist = (float)SADIST;
|
|
||||||
|
|
||||||
NXDputalias(hfil, hdict, "sdist", &sadist);
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"sdist","dia2_sample");
|
||||||
SNXSPutVariable(pSics,pCon,hfil,hdict,"saname","sample");
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"chopperdist","chopper_sample");
|
||||||
SNXSPutVariable(pSics,pCon,hfil,hdict,"senvir","environment");
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"saname","sample");
|
||||||
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"senvir","environment");
|
||||||
SNXSPutEVVar(hfil,hdict,"temperature",pCon,"stemp","stddev");
|
SNXSPutEVVar(hfil,hdict,"temperature",pCon,"stemp","stddev");
|
||||||
|
|
||||||
SNXSPutMotor(pSics, pCon, hfil, hdict, "srsu", "rsu");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "srsu", "rsu");
|
||||||
SNXSPutMotorNull(pSics, pCon, hfil, hdict, "srsu0", "rsu");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "srsu0", "rsu");
|
||||||
SNXSPutMotor(pSics, pCon, hfil, hdict, "srsl", "rsl");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "srsl", "rsl");
|
||||||
SNXSPutMotorNull(pSics, pCon, hfil, hdict, "srsl0", "rsl");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "srsl0", "rsl");
|
||||||
SNXSPutMotor(pSics, pCon, hfil, hdict, "srsa", "rsa");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "srsa", "rsa");
|
||||||
SNXSPutMotorNull(pSics, pCon, hfil, hdict, "srsa0", "rsa");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "srsa0", "rsa");
|
||||||
SNXSPutMotor(pSics, pCon, hfil, hdict, "sshu", "shu");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "sshu", "shu");
|
||||||
SNXSPutMotorNull(pSics, pCon, hfil, hdict, "sshu0", "shu");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "sshu0", "shu");
|
||||||
SNXSPutMotor(pSics, pCon, hfil, hdict, "sshl", "shl");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "sshl", "shl");
|
||||||
SNXSPutMotorNull(pSics, pCon, hfil, hdict, "sshl0", "shl");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "sshl0", "shl");
|
||||||
SNXSPutMotor(pSics, pCon, hfil, hdict, "ssgu", "sgu");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "ssgu", "sgu");
|
||||||
SNXSPutMotorNull(pSics, pCon, hfil, hdict, "ssgu0", "sgu");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "ssgu0", "sgu");
|
||||||
SNXSPutMotor(pSics, pCon, hfil, hdict, "ssgl", "sgl");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "ssgl", "sgl");
|
||||||
SNXSPutMotorNull(pSics, pCon, hfil, hdict, "ssgl0", "sgl");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "ssgl0", "sgl");
|
||||||
SNXSPutMotor(pSics, pCon, hfil, hdict, "ssv", "sv");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "ssv", "sv");
|
||||||
SNXSPutMotorNull(pSics, pCon, hfil, hdict, "ssv0", "sv");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "ssv0", "sv");
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------*/
|
|
||||||
static void writeDetector(NXhandle hfil, NXdict hdict, SConnection *pCon,
|
/*--------------------------------------------------------------------*/
|
||||||
SicsInterp *pSics)
|
|
||||||
|
static int PoldiStart(pPolterdi self, SConnection *pCon)
|
||||||
{
|
{
|
||||||
|
char pBueffel[256];
|
||||||
|
NXhandle hfil = NULL;
|
||||||
|
NXdict hdict= NULL;
|
||||||
|
int status;
|
||||||
const float *fTime = NULL;
|
const float *fTime = NULL;
|
||||||
CounterMode eMode;
|
CounterMode eMode;
|
||||||
pHistMem pHist= NULL;
|
float *fTime2 = NULL,fTheta0[801],fTheta[801], fVal;
|
||||||
float *fTime2 = NULL, fTheta[NODET], fVal;
|
pSicsVariable pVar = NULL;
|
||||||
int iLength, i;
|
float det_radius, det_size, x0det, y0det, twothet;
|
||||||
char pBueffel[80];
|
float pi, alpha1, alphasamp, sms, phidetav, phim;
|
||||||
|
float phi2det, val1, val2, nodet;
|
||||||
|
int iLength, i, nzell;
|
||||||
pMotor sa;
|
pMotor sa;
|
||||||
HistInt *lData = NULL;
|
HistInt *lData = NULL;
|
||||||
long lVal;
|
long lVal;
|
||||||
|
|
||||||
pHist = (pHistMem)FindCommandData(pSics,HM,"HistMem");
|
/* create filename */
|
||||||
if(!pHist)
|
self->pFile = SNXMakeFileName(pServ->pSics,pCon);
|
||||||
|
if(!self->pFile)
|
||||||
{
|
{
|
||||||
SCWrite(pCon,"ERROR: Histogram memory NOT found",eError);
|
SCWrite(pCon,"ERROR: Extra severe: failed to create data file name",
|
||||||
return;
|
eError);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* create a Nexus file */
|
||||||
|
NXopen(self->pFile,NXACC_CREATE,&hfil);
|
||||||
|
if(!hfil)
|
||||||
|
{
|
||||||
|
SCWrite(pCon,"ERROR: cannot create data file ",eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* tell Uwe User what we are doing */
|
||||||
|
sprintf(pBueffel,"Writing %s ......",self->pFile);
|
||||||
|
SCWrite(pCon,pBueffel,eWarning);
|
||||||
|
|
||||||
|
/* write globals */
|
||||||
|
SNXSPutGlobals(hfil,self->pFile,"POLDI",pCon);
|
||||||
|
|
||||||
|
/* open nxdict */
|
||||||
|
status = NXDinitfromfile(self->dictfile,&hdict);
|
||||||
|
if(status != NX_OK)
|
||||||
|
{
|
||||||
|
sprintf(pBueffel,"ERROR: failed to open dictionary file %s",
|
||||||
|
self->dictfile);
|
||||||
|
SCWrite(pCon,pBueffel,eError);
|
||||||
|
SCWrite(pCon,"ERROR: Aborting data file writing",eError);
|
||||||
|
SCWrite(pCon,"ERROR: This is a SERIOUS problem!",eError);
|
||||||
|
SCWrite(pCon,"ERROR: DATA NOT WRITTEN",eError);
|
||||||
|
NXclose(&hfil);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
writePolterdiGlobal(hfil,hdict,pCon);
|
||||||
|
|
||||||
|
writeChopper(hfil,hdict,pCon);
|
||||||
|
|
||||||
|
writeDiaphragm1(hfil,hdict,pCon);
|
||||||
|
|
||||||
|
writeDiaphragm2(hfil,hdict,pCon);
|
||||||
|
|
||||||
|
writeSample(hfil,hdict,pCon);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
write time binning
|
write time binning
|
||||||
*/
|
*/
|
||||||
fTime = GetHistTimeBin(pHist,&iLength);
|
|
||||||
|
fTime = GetHistTimeBin(self->pHist,&iLength);
|
||||||
fTime2 = (float *)malloc(iLength*sizeof(float));
|
fTime2 = (float *)malloc(iLength*sizeof(float));
|
||||||
if(fTime2)
|
if(fTime2)
|
||||||
{
|
{
|
||||||
@ -226,31 +339,100 @@ static void writeDetector(NXhandle hfil, NXdict hdict, SConnection *pCon,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
do theta
|
theta calculation
|
||||||
*/
|
*/
|
||||||
fVal = -999.;
|
det_radius = (float)DETRADIUS;
|
||||||
sa = FindMotor(pSics,"sa");
|
pVar = FindVariable(pServ->pSics,"det_size");
|
||||||
if(sa)
|
if(pVar)
|
||||||
{
|
{
|
||||||
MotorGetSoftPosition(sa,pCon,&fVal);
|
VarGetFloat(pVar,&det_size);
|
||||||
|
} else {
|
||||||
|
SCWrite(pCon,"ERROR: Command not found!",eError);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
pVar = NULL;
|
||||||
|
pVar = FindVariable(pServ->pSics,"nodet");
|
||||||
|
if(pVar)
|
||||||
{
|
{
|
||||||
SCWrite(pCon,"ERROR: failed to locate two theta motor",eError);
|
VarGetFloat(pVar,&nodet);
|
||||||
|
} else {
|
||||||
|
SCWrite(pCon,"ERROR: Command not found!",eError);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for(i = 0; i < NODET; i++)
|
pVar = NULL;
|
||||||
|
nzell = (int)nodet;
|
||||||
|
|
||||||
|
pVar = FindVariable(pServ->pSics,"x0_det");
|
||||||
|
if(pVar)
|
||||||
{
|
{
|
||||||
fTheta[i] = fVal + i * THSPACE;
|
VarGetFloat(pVar,&x0det);
|
||||||
|
} else {
|
||||||
|
SCWrite(pCon,"ERROR: Command not found!",eError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pVar = NULL;
|
||||||
|
pVar = FindVariable(pServ->pSics,"y0_det");
|
||||||
|
if(pVar)
|
||||||
|
{
|
||||||
|
VarGetFloat(pVar, &y0det);
|
||||||
|
} else {
|
||||||
|
SCWrite(pCon,"ERROR: Command not found!",eError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pVar = NULL;
|
||||||
|
pVar = FindVariable(pServ->pSics,"twotheta");
|
||||||
|
if(pVar)
|
||||||
|
{
|
||||||
|
VarGetFloat(pVar, &twothet);
|
||||||
|
} else {
|
||||||
|
SCWrite(pCon,"ERROR: Command not found!",eError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pi = 3.1415926536;
|
||||||
|
/* transformation to radient */
|
||||||
|
twothet = twothet*pi/180;
|
||||||
|
if (x0det < 0) {
|
||||||
|
alpha1 = atan(y0det/x0det);
|
||||||
|
}
|
||||||
|
if (x0det > 0) {
|
||||||
|
alpha1 = pi + atan(y0det/x0det);
|
||||||
|
}
|
||||||
|
alphasamp=pi + alpha1 - twothet;
|
||||||
|
sms = sqrt(x0det*x0det + y0det*y0det);
|
||||||
|
phidetav = pi - alphasamp - asin(sms/det_radius*sin(alphasamp)) + alpha1;
|
||||||
|
phim = atan(y0det/x0det);
|
||||||
|
if (phim < 0) {
|
||||||
|
phim = pi + phim;
|
||||||
|
}
|
||||||
|
for(i = 0; i <= nzell; i++)
|
||||||
|
{
|
||||||
|
phi2det = phidetav+(i-0.5*(nzell-1.0))*det_size/(det_radius);
|
||||||
|
val1 = det_radius*sin(phi2det) - sms*sin(phim);
|
||||||
|
val2 = det_radius*cos(phi2det) - sms*cos(phim);
|
||||||
|
fTheta0[i] = atan(val1/val2);
|
||||||
|
if (fTheta0[i] < 0) {
|
||||||
|
fTheta0[i] = pi + fTheta0[i];
|
||||||
|
}
|
||||||
|
/* transformation to degree */
|
||||||
|
fTheta0[i] = fTheta0[i]*180/pi;
|
||||||
|
}
|
||||||
|
for (i=0;i<=nzell;i++)
|
||||||
|
{
|
||||||
|
fTheta[i]=fTheta0[nzell-i];
|
||||||
}
|
}
|
||||||
NXDputalias(hfil,hdict,"dtheta",fTheta);
|
NXDputalias(hfil,hdict,"dtheta",fTheta);
|
||||||
|
NXDputalias(hfil,hdict,"detector_radius",&det_radius);
|
||||||
fVal = (float)DETDIST;
|
NXDputalias(hfil,hdict,"cell_size",&det_size);
|
||||||
NXDputalias(hfil,hdict,"ddist",&fVal);
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"ddist","detectordist");
|
||||||
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"sangle","scatt_angle");
|
||||||
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"detx0","x0_det");
|
||||||
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"dety0","y0_det");
|
||||||
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"theta","twotheta");
|
||||||
/*
|
/*
|
||||||
write Histogram
|
write Histogram
|
||||||
*/
|
*/
|
||||||
lData = GetHistogramPointer(pHist,pCon);
|
lData = GetHistogramPointer(self->pHist,pCon);
|
||||||
if(lData)
|
if(lData)
|
||||||
{
|
{
|
||||||
NXDputalias(hfil,hdict,"dcounts",lData);
|
NXDputalias(hfil,hdict,"dcounts",lData);
|
||||||
@ -263,11 +445,11 @@ static void writeDetector(NXhandle hfil, NXdict hdict, SConnection *pCon,
|
|||||||
/*
|
/*
|
||||||
write counting data
|
write counting data
|
||||||
*/
|
*/
|
||||||
fVal = GetHistCountTime(pHist,pCon);
|
fVal = GetHistCountTime(self->pHist,pCon);
|
||||||
NXDputalias(hfil,hdict,"cntime",&fVal);
|
NXDputalias(hfil,hdict,"cntime",&fVal);
|
||||||
lVal = GetHistMonitor(pHist,1,pCon);
|
lVal = GetHistMonitor(self->pHist,1,pCon);
|
||||||
NXDputalias(hfil,hdict,"cnmon1",&lVal);
|
NXDputalias(hfil,hdict,"cnmon1",&lVal);
|
||||||
eMode = GetHistCountMode(pHist);
|
eMode = GetHistCountMode(self->pHist);
|
||||||
if(eMode == eTimer)
|
if(eMode == eTimer)
|
||||||
{
|
{
|
||||||
strcpy(pBueffel,"timer");
|
strcpy(pBueffel,"timer");
|
||||||
@ -277,52 +459,42 @@ static void writeDetector(NXhandle hfil, NXdict hdict, SConnection *pCon,
|
|||||||
strcpy(pBueffel,"monitor");
|
strcpy(pBueffel,"monitor");
|
||||||
}
|
}
|
||||||
NXDputalias(hfil,hdict,"cnmode",pBueffel);
|
NXDputalias(hfil,hdict,"cnmode",pBueffel);
|
||||||
fVal = GetHistPreset(pHist);
|
fVal = GetHistPreset(self->pHist);
|
||||||
NXDputalias(hfil,hdict,"cnpreset",&fVal);
|
NXDputalias(hfil,hdict,"cnpreset",&fVal);
|
||||||
|
|
||||||
|
/* close everything */
|
||||||
|
NXclose(&hfil);
|
||||||
|
NXDclose(hdict,NULL);
|
||||||
|
self->iNew = 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------*/
|
|
||||||
static void makeLinks(NXhandle hfil, NXdict hdict, SConnection *pCon,
|
/*---------------------------------------------------------------------------*/
|
||||||
SicsInterp *pSics)
|
|
||||||
|
static void PoldiUpdate(pPolterdi self, SConnection *pCon)
|
||||||
{
|
{
|
||||||
NXDaliaslink(hfil,hdict,"dana","dcounts");
|
char pBueffel[256];
|
||||||
NXDaliaslink(hfil,hdict,"dana","dtheta");
|
|
||||||
NXDaliaslink(hfil,hdict,"dana","dtime");
|
|
||||||
}
|
|
||||||
/*--------------------------------------------------------------------*/
|
|
||||||
static int StoreData(SConnection *pCon, SicsInterp *pSics, pPolterdi self)
|
|
||||||
{
|
|
||||||
char pBueffel[256], *pFile = NULL;
|
|
||||||
NXhandle hfil = NULL;
|
NXhandle hfil = NULL;
|
||||||
NXdict hdict = NULL;
|
NXdict hdict = NULL;
|
||||||
int status;
|
int status;
|
||||||
|
const float *fTime = NULL;
|
||||||
|
CounterMode eMode;
|
||||||
|
float *fTime2 = NULL, fTheta[801], fVal;
|
||||||
|
pSicsVariable pVar = NULL;
|
||||||
|
float det_radius, det_size, x0det, y0det, twothet;
|
||||||
|
float pi, alpha1, alphasamp, sms, phidetav, phim;
|
||||||
|
float phi2det, val1, val2, nodet;
|
||||||
|
int iLength, i, nzell;
|
||||||
|
pMotor sa;
|
||||||
|
HistInt *lData = NULL;
|
||||||
|
long lVal;
|
||||||
|
|
||||||
/* create filename */
|
/* open everything again */
|
||||||
pFile = SNXMakeFileName(pSics,pCon);
|
NXopen(self->pFile,NXACC_RDWR,&hfil);
|
||||||
if(!pFile)
|
if(!self->pFile)
|
||||||
{
|
{
|
||||||
SCWrite(pCon,"ERROR: Extra severe: failed to create data file name",
|
SCWrite(pCon,"ERROR: cannot reopen data file ",eError);
|
||||||
eError);
|
return;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a Nexus file */
|
|
||||||
NXopen(pFile,NXACC_CREATE,&hfil);
|
|
||||||
if(!hfil)
|
|
||||||
{
|
|
||||||
SCWrite(pCon,"ERROR: cannot create data file ",eError);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* tell Uwe User what we are doing */
|
|
||||||
sprintf(pBueffel,"Writing %s ......",pFile);
|
|
||||||
SCWrite(pCon,pBueffel,eWarning);
|
|
||||||
|
|
||||||
/* write globals */
|
|
||||||
SNXSPutGlobals(hfil,pFile,"POLTERDI",pCon);
|
|
||||||
free(pFile);
|
|
||||||
pFile = NULL;
|
|
||||||
|
|
||||||
/* open nxdict */
|
|
||||||
status = NXDinitfromfile(self->dictfile,&hdict);
|
status = NXDinitfromfile(self->dictfile,&hdict);
|
||||||
if(status != NX_OK)
|
if(status != NX_OK)
|
||||||
{
|
{
|
||||||
@ -333,42 +505,240 @@ static int StoreData(SConnection *pCon, SicsInterp *pSics, pPolterdi self)
|
|||||||
SCWrite(pCon,"ERROR: This is a SERIOUS problem!",eError);
|
SCWrite(pCon,"ERROR: This is a SERIOUS problem!",eError);
|
||||||
SCWrite(pCon,"ERROR: DATA NOT WRITTEN",eError);
|
SCWrite(pCon,"ERROR: DATA NOT WRITTEN",eError);
|
||||||
NXclose(&hfil);
|
NXclose(&hfil);
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* tell the user that something is happening */
|
||||||
|
sprintf(pBueffel,"Updating %s",self->pFile);
|
||||||
|
SCWrite(pCon,pBueffel,eWarning);
|
||||||
|
|
||||||
writePolterdiGlobal(hfil,hdict,pCon,pSics);
|
/*
|
||||||
|
write time binning
|
||||||
|
*/
|
||||||
|
|
||||||
writeChopper(hfil,hdict,pCon,pSics);
|
fTime = GetHistTimeBin(self->pHist,&iLength);
|
||||||
|
fTime2 = (float *)malloc(iLength*sizeof(float));
|
||||||
|
if(fTime2)
|
||||||
|
{
|
||||||
|
for(i = 0;i < iLength; i++)
|
||||||
|
{
|
||||||
|
fTime2[i] = fTime[i]/10.;
|
||||||
|
}
|
||||||
|
sprintf(pBueffel,"%d",iLength);
|
||||||
|
NXDupdate(hdict,"timebin",pBueffel);
|
||||||
|
NXDputalias(hfil,hdict,"dtime",fTime2);
|
||||||
|
free(fTime2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SCWrite(pCon,"ERROR: out of memory while writing time binning",eError);
|
||||||
|
}
|
||||||
|
|
||||||
writeDiaphragm1(hfil,hdict,pCon,pSics);
|
/*
|
||||||
|
write Histogram
|
||||||
|
*/
|
||||||
|
|
||||||
writeDiaphragm2(hfil,hdict,pCon,pSics);
|
lData = GetHistogramPointer(self->pHist,pCon);
|
||||||
|
if(lData)
|
||||||
|
{
|
||||||
|
NXDputalias(hfil,hdict,"dcounts",lData);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SCWrite(pCon,"ERROR: failed to get histogram data",eError);
|
||||||
|
}
|
||||||
|
|
||||||
writeSample(hfil,hdict,pCon,pSics);
|
/*
|
||||||
|
write counting data
|
||||||
|
*/
|
||||||
|
fVal = GetHistCountTime(self->pHist,pCon);
|
||||||
|
NXDputalias(hfil,hdict,"cntime",&fVal);
|
||||||
|
lVal = GetHistMonitor(self->pHist,1,pCon);
|
||||||
|
NXDputalias(hfil,hdict,"cnmon1",&lVal);
|
||||||
|
eMode = GetHistCountMode(self->pHist);
|
||||||
|
if(eMode == eTimer)
|
||||||
|
{
|
||||||
|
strcpy(pBueffel,"timer");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strcpy(pBueffel,"monitor");
|
||||||
|
}
|
||||||
|
NXDputalias(hfil,hdict,"cnmode",pBueffel);
|
||||||
|
fVal = GetHistPreset(self->pHist);
|
||||||
|
NXDputalias(hfil,hdict,"cnpreset",&fVal);
|
||||||
|
|
||||||
writeDetector(hfil,hdict,pCon,pSics);
|
|
||||||
|
|
||||||
makeLinks(hfil,hdict,pCon,pSics);
|
|
||||||
|
|
||||||
/* close everything */
|
/* close everything */
|
||||||
NXclose(&hfil);
|
NXclose(&hfil);
|
||||||
NXDclose(hdict,NULL);
|
NXDclose(hdict,NULL);
|
||||||
|
|
||||||
SCSendOK(pCon);
|
}
|
||||||
return 1;
|
|
||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
FoLink sets all the links for the NXdata vGroup. Had to be separate because
|
||||||
|
at least one update is necessary before this can be done.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void PoldiLink(pPolterdi self, SConnection *pCon)
|
||||||
|
{
|
||||||
|
NXhandle hfil = NULL;
|
||||||
|
NXdict hdict = NULL;
|
||||||
|
int status;
|
||||||
|
char pBueffel[512];
|
||||||
|
|
||||||
|
/* open everything again */
|
||||||
|
NXopen(self->pFile,NXACC_RDWR,&hfil);
|
||||||
|
if(!self->pFile)
|
||||||
|
{
|
||||||
|
SCWrite(pCon,"ERROR: cannot reopen data file ",eError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
status = NXDinitfromfile(self->dictfile,&hdict);
|
||||||
|
if(status != NX_OK)
|
||||||
|
{
|
||||||
|
sprintf(pBueffel,"ERROR: failed to open dictionary file %s",
|
||||||
|
self->dictfile);
|
||||||
|
SCWrite(pCon,pBueffel,eError);
|
||||||
|
SCWrite(pCon,"ERROR: Aborting data file writing",eError);
|
||||||
|
SCWrite(pCon,"ERROR: This is a SERIOUS problem!",eError);
|
||||||
|
SCWrite(pCon,"ERROR: DATA NOT WRITTEN",eError);
|
||||||
|
NXclose(&hfil);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NXDaliaslink(hfil,hdict,"dana","dcounts");
|
||||||
|
NXDaliaslink(hfil,hdict,"dana","dtheta");
|
||||||
|
NXDaliaslink(hfil,hdict,"dana","dtime");
|
||||||
|
|
||||||
|
/* close everything */
|
||||||
|
NXclose(&hfil);
|
||||||
|
NXDclose(hdict,NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------
|
||||||
|
This is the task function for updating the data file any now and then
|
||||||
|
automatically
|
||||||
|
--------------------------------------------------------------------------*/
|
||||||
|
static int PoldiTask(void *pData)
|
||||||
|
{
|
||||||
|
pPolterdi self = NULL;
|
||||||
|
int iWrite, iRet;
|
||||||
|
|
||||||
|
self = (pPolterdi)pData;
|
||||||
|
if(!self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* figure out if we need to write */
|
||||||
|
iWrite = 0;
|
||||||
|
iRet = 1;
|
||||||
|
/* first case: update intervall */
|
||||||
|
if(time(NULL) >= self->tUpdate)
|
||||||
|
{
|
||||||
|
self->tUpdate = time(NULL) + self->iInterval;
|
||||||
|
iWrite = 1;
|
||||||
|
iRet = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(self->iEnd)
|
||||||
|
{
|
||||||
|
self->tUpdate = 0;
|
||||||
|
SCWrite(self->pCon,"Writing finished!",eError);
|
||||||
|
iWrite = 0;
|
||||||
|
iRet = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(iWrite)
|
||||||
|
{
|
||||||
|
if(self->iNew)
|
||||||
|
{
|
||||||
|
PoldiStart(self,self->pCon);
|
||||||
|
PoldiUpdate(self,self->pCon);
|
||||||
|
PoldiLink(self,self->pCon);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PoldiUpdate(self,self->pCon);
|
||||||
|
PoldiLink(self,self->pCon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return iRet;
|
||||||
}
|
}
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
int PolterAction(SConnection *pCon, SicsInterp *pSics,
|
int PolterAction(SConnection *pCon, SicsInterp *pSics,
|
||||||
void *pData, int argc, char *argv[])
|
void *pData, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
pPolterdi self = (pPolterdi)pData;
|
int iRet, iVal;
|
||||||
|
pPolterdi self = NULL;
|
||||||
|
char pBueffel[512];
|
||||||
|
|
||||||
|
if(argc < 2)
|
||||||
|
{
|
||||||
|
SCWrite(pCon,"ERROR: Insufficient number of arguments to StoreData",
|
||||||
|
eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
self = (pPolterdi)pData;
|
||||||
assert(self);
|
assert(self);
|
||||||
assert(pCon);
|
|
||||||
assert(pSics);
|
|
||||||
|
|
||||||
return StoreData(pCon,pSics,self);
|
strtolower(argv[1]);
|
||||||
|
if(strcmp(argv[1],"start") == 0)
|
||||||
|
{
|
||||||
|
PoldiStart(self,pCon);
|
||||||
|
PoldiUpdate(self,pCon);
|
||||||
|
PoldiLink(self,pCon);
|
||||||
|
return 1;
|
||||||
|
} else if(strcmp(argv[1],"update") == 0)
|
||||||
|
{
|
||||||
|
if((self->iNew) || (!self->pFile))
|
||||||
|
{
|
||||||
|
PoldiStart(self,pCon);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PoldiUpdate(self,pCon);
|
||||||
|
PoldiLink(self,pCon);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if(strcmp(argv[1],"getfile") == 0)
|
||||||
|
{
|
||||||
|
sprintf(pBueffel,"StoreData.file = %s",self->pFile);
|
||||||
|
SCWrite(pCon,pBueffel,eValue);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if(strcmp(argv[1],"interval") == 0)
|
||||||
|
{
|
||||||
|
if(argc > 2) /* set value */
|
||||||
|
{
|
||||||
|
if(!SCMatchRights(pCon,usUser))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
iRet = Tcl_GetInt(pSics->pTcl,argv[2],&iVal);
|
||||||
|
if(iRet != TCL_OK)
|
||||||
|
{
|
||||||
|
sprintf(pBueffel,"ERROR: cannot convert --> %s <-- to number ",
|
||||||
|
argv[2]);
|
||||||
|
SCWrite(pCon,pBueffel,eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
self->iInterval = iVal*60; /* go to seconds from minutes*/
|
||||||
|
SCSendOK(pCon);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else /* read the value */
|
||||||
|
{
|
||||||
|
sprintf(pBueffel,"storefocus.interval = %d",self->iInterval/60);
|
||||||
|
SCWrite(pCon,pBueffel,eValue);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SCWrite(pCon,"ERROR: subcommand to StoreData not recognized",eError);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,11 +47,11 @@ ps.phiend setAccess 2
|
|||||||
ps.phistart 0.000000
|
ps.phistart 0.000000
|
||||||
ps.phistart setAccess 2
|
ps.phistart setAccess 2
|
||||||
hm3 CountMode timer
|
hm3 CountMode timer
|
||||||
hm3 preset 10.000000
|
hm3 preset 3600.000000
|
||||||
hm2 CountMode monitor
|
hm2 CountMode timer
|
||||||
hm2 preset 2.000000
|
hm2 preset 3600.000000
|
||||||
hm1 CountMode monitor
|
hm1 CountMode timer
|
||||||
hm1 preset 2.000000
|
hm1 preset 3600.000000
|
||||||
#Crystallographic Settings
|
#Crystallographic Settings
|
||||||
hkl lambda 1.179000
|
hkl lambda 1.179000
|
||||||
hkl setub -0.017880 -0.074923 0.028280 -0.007008 -0.036800 -0.057747 0.160912 -0.009928 0.000627
|
hkl setub -0.017880 -0.074923 0.028280 -0.007008 -0.036800 -0.057747 0.160912 -0.009928 0.000627
|
||||||
@ -458,5 +458,5 @@ sample D20 30K SNP Okt 2001 GS
|
|||||||
sample setAccess 2
|
sample setAccess 2
|
||||||
title snp gs apd 30K
|
title snp gs apd 30K
|
||||||
title setAccess 2
|
title setAccess 2
|
||||||
starttime 2001-11-16 08:55:46
|
starttime 2002-04-23 10:49:18
|
||||||
starttime setAccess 2
|
starttime setAccess 2
|
||||||
|
@ -1590,7 +1590,7 @@
|
|||||||
int my_daq_save;
|
int my_daq_save;
|
||||||
uint maxbins, my_nbins, bins_in_buff;
|
uint maxbins, my_nbins, bins_in_buff;
|
||||||
uint nxtbin_to_send, nbins_to_send, bytes_in_buff;
|
uint nxtbin_to_send, nbins_to_send, bytes_in_buff;
|
||||||
uint bins_to_go;
|
uint bins_to_go, lastbin;
|
||||||
struct req_buff_struct my_rqst;
|
struct req_buff_struct my_rqst;
|
||||||
struct rply_buff_struct my_rply;
|
struct rply_buff_struct my_rply;
|
||||||
uchar *buff_pntr, *last_byte, *nxt;
|
uchar *buff_pntr, *last_byte, *nxt;
|
||||||
@ -1710,9 +1710,13 @@
|
|||||||
nxt = (char *) my_pntr.base;
|
nxt = (char *) my_pntr.base;
|
||||||
while (nbins_to_send > 0) {
|
while (nbins_to_send > 0) {
|
||||||
/* Read some histogram data into buffer */
|
/* Read some histogram data into buffer */
|
||||||
|
lastbin = nxtbin_to_send + bins_in_buff;
|
||||||
|
if(lastbin > my_nbins-1){
|
||||||
|
lastbin = my_nbins-1;
|
||||||
|
}
|
||||||
bins_to_go = FS_read_hm (index, pkt_size,
|
bins_to_go = FS_read_hm (index, pkt_size,
|
||||||
my_pntr.base, bins_in_buff,
|
my_pntr.base, bins_in_buff,
|
||||||
nxtbin_to_send, (my_fstbin + my_nbins - 1));
|
nxtbin_to_send, lastbin);
|
||||||
if (bins_to_go <= 0) {
|
if (bins_to_go <= 0) {
|
||||||
perror (StrJoin (buff, pkt_size,
|
perror (StrJoin (buff, pkt_size,
|
||||||
FS_name[index], "/FS_do_read: FS_read_hm error"));
|
FS_name[index], "/FS_do_read: FS_read_hm error"));
|
||||||
|
@ -808,6 +808,10 @@
|
|||||||
/*
|
/*
|
||||||
We have a valid PSD packet. Find and check positions.
|
We have a valid PSD packet. Find and check positions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
old style calculation, left in for now
|
||||||
|
|
||||||
xPos = xData.ui2[1];
|
xPos = xData.ui2[1];
|
||||||
if(xPos > 32767)
|
if(xPos > 32767)
|
||||||
xPos -= 65536;
|
xPos -= 65536;
|
||||||
@ -816,20 +820,20 @@
|
|||||||
if(yPos > 32767)
|
if(yPos > 32767)
|
||||||
yPos -= 65536;
|
yPos -= 65536;
|
||||||
|
|
||||||
/*
|
|
||||||
if(xPos > 0)
|
|
||||||
xPos =(int)((float)xPos/(float)psdXFactor +.5 + psdXOffset);
|
|
||||||
else
|
|
||||||
xPos =(int)((float)xPos/(float)psdXFactor -.49999 + psdXOffset);
|
|
||||||
|
|
||||||
if(yPos > 0)
|
|
||||||
yPos =(int)((float)yPos/(float)psdYFactor +.5 + psdYOffset);
|
|
||||||
else
|
|
||||||
yPos =(int)((float)yPos/(float)psdYFactor -.49999 + psdYOffset);
|
|
||||||
*/
|
|
||||||
|
|
||||||
xPos = (int) ( (float)(xPos+xOff)/(float)psdXFactor);
|
xPos = (int) ( (float)(xPos+xOff)/(float)psdXFactor);
|
||||||
yPos = (int)( (float)(yPos+yOff)/(float)psdYFactor);
|
yPos = (int)( (float)(yPos+yOff)/(float)psdYFactor);
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
This is the new version where all values are offset by 4096
|
||||||
|
in order to give positive values at all times. This relates
|
||||||
|
to a zero point in the middle of the detector. As we want a
|
||||||
|
zero point in the lower left corner, we subtract 2048.
|
||||||
|
*/
|
||||||
|
xPos = xData.ui2[1];
|
||||||
|
xPos = (xPos - 2048)/psdXFactor;
|
||||||
|
yPos = yData.ui2[1];
|
||||||
|
yPos = (yPos - 2048)/psdYFactor;
|
||||||
|
|
||||||
|
|
||||||
if(xPos < 0 || xPos > psdXSize)
|
if(xPos < 0 || xPos > psdXSize)
|
||||||
|
@ -151,7 +151,7 @@
|
|||||||
|
|
||||||
Dbg_mask = 0;
|
Dbg_mask = 0;
|
||||||
Dbg_lev0 = 0;
|
Dbg_lev0 = 0;
|
||||||
Dbg_lev1 = 1;
|
Dbg_lev1 = 0;
|
||||||
Dbg_lev2 = 0;
|
Dbg_lev2 = 0;
|
||||||
Dbg_lev3 = 0;
|
Dbg_lev3 = 0;
|
||||||
Cfgn_done = 0; /* Force a configuration before we can do anything. */
|
Cfgn_done = 0; /* Force a configuration before we can do anything. */
|
||||||
|
@ -1205,7 +1205,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
switch debugging on by default
|
switch debugging on by default
|
||||||
Dbg_lev1 = 1;
|
Dbg_lev1 = 0;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
11
tascom.tcl
11
tascom.tcl
@ -495,8 +495,10 @@ proc co args {
|
|||||||
#----- format output
|
#----- format output
|
||||||
set cts [tasSplit [counter getcounts]]
|
set cts [tasSplit [counter getcounts]]
|
||||||
set m1 [tasSplit [counter getmonitor 1]]
|
set m1 [tasSplit [counter getmonitor 1]]
|
||||||
set m3 [tasSplit [counter getmonitor 2]]
|
set m2 [tasSplit [counter getmonitor 2]]
|
||||||
return [format " Counts = %8d, M1 = %8d, M3 = %8d" $cts $m1 $m3]
|
set m3 [tasSplit [counter getmonitor 3]]
|
||||||
|
return [format " Counts = %8d, M1 = %8d, M2 = %8d, M3 = %8d" \
|
||||||
|
$cts $m1 $m2 $m3]
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
@ -775,7 +777,7 @@ proc le args {
|
|||||||
set v2 [tasSplit [qm]]
|
set v2 [tasSplit [qm]]
|
||||||
set val [format " %9.4f %9.4f\n" $v1 $v2]
|
set val [format " %9.4f %9.4f\n" $v1 $v2]
|
||||||
set v1 [tasSplit [ten]]
|
set v1 [tasSplit [ten]]
|
||||||
set v2 [tasSplit [qm]]
|
set v2 [tasSplit [tqm]]
|
||||||
set val2 [format " %9.4f %9.4f\n" $v1 $v2]
|
set val2 [format " %9.4f %9.4f\n" $v1 $v2]
|
||||||
append output [format "POSN: %s" $val]
|
append output [format "POSN: %s" $val]
|
||||||
append output [format "TARG: %s" $val2]
|
append output [format "TARG: %s" $val2]
|
||||||
@ -926,8 +928,7 @@ proc sz args {
|
|||||||
"%-8sOld: %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n" \
|
"%-8sOld: %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n" \
|
||||||
$mot $loh $los $pos $targ $his $hih $zero]
|
$mot $loh $los $pos $targ $his $hih $zero]
|
||||||
#-------action
|
#-------action
|
||||||
set newZero [expr $zero + ($val - $pos)]
|
madZero $mot $val
|
||||||
madZero $mot $newZero
|
|
||||||
catch {updateqe} msg
|
catch {updateqe} msg
|
||||||
#-------- more output
|
#-------- more output
|
||||||
set zero [tasSplit [madZero $mot]]
|
set zero [tasSplit [madZero $mot]]
|
||||||
|
@ -48,6 +48,7 @@ extern char *tasMotorOrder[] = { "a1",
|
|||||||
"sgl",
|
"sgl",
|
||||||
"sgu",
|
"sgu",
|
||||||
"agl",
|
"agl",
|
||||||
|
"tt",
|
||||||
"i1" ,
|
"i1" ,
|
||||||
"i2",
|
"i2",
|
||||||
"i3",
|
"i3",
|
||||||
@ -211,10 +212,10 @@ static int MonitorCallback(int iEvent, void *pEvent, void *pUser)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
SetCounterMode(self->pScan->pCounterData,ePreset);
|
SetCounterMode(self->pScan->pCounterData,ePreset);
|
||||||
SetCounterPreset(self->pScan->pCounterData,self->tasPar[MN]->fVal);
|
SetCounterPreset(self->pScan->pCounterData,(float)self->tasPar[MN]->iVal);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
/*---------------------------------------------------------------------*/
|
||||||
static int TimerCallback(int iEvent, void *pEvent, void *pUser)
|
static int TimerCallback(int iEvent, void *pEvent, void *pUser)
|
||||||
{
|
{
|
||||||
pTASdata self = (pTASdata)pUser;
|
pTASdata self = (pTASdata)pUser;
|
||||||
|
@ -52,6 +52,8 @@ framemode = /$(framename),NXentry/TRICS,NXinstrument/count_control,NXcounter/SDS
|
|||||||
framemonitor = /$(framename),NXentry/TRICS,NXinstrument/count_control,NXcounter/SDS monitor -type DFNT_INT32
|
framemonitor = /$(framename),NXentry/TRICS,NXinstrument/count_control,NXcounter/SDS monitor -type DFNT_INT32
|
||||||
sinqmonitor= /$(framename),NXentry/TRICS,NXinstrument/count_control,NXcounter/SDS beam_monitor \
|
sinqmonitor= /$(framename),NXentry/TRICS,NXinstrument/count_control,NXcounter/SDS beam_monitor \
|
||||||
-type DFNT_INT32
|
-type DFNT_INT32
|
||||||
|
cctime= /$(framename),NXentry/TRICS,NXinstrument/count_control,NXcounter/SDS \
|
||||||
|
time -attr {units,seconds}
|
||||||
#------------------------ Detector
|
#------------------------ Detector
|
||||||
dnumber = detector1
|
dnumber = detector1
|
||||||
framedim1 = 256
|
framedim1 = 256
|
||||||
|
Reference in New Issue
Block a user