- Recovered POLDI from the land of lost files
This commit is contained in:
2
choco.c
2
choco.c
@ -231,7 +231,7 @@ extern pCodri MakeCookerDriver(char *pHost, int iPort, int iChannel);
|
|||||||
SCWrite(pCon,pBueffel,eError);
|
SCWrite(pCon,pBueffel,eError);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(argc > 7)
|
if(argc > 6)
|
||||||
{
|
{
|
||||||
iRet = Tcl_GetInt(pSics->pTcl,argv[6],&iSingle);
|
iRet = Tcl_GetInt(pSics->pTcl,argv[6],&iSingle);
|
||||||
if(iRet != TCL_OK)
|
if(iRet != TCL_OK)
|
||||||
|
19
docho.c
19
docho.c
@ -94,7 +94,7 @@ extern char *trim(char *pTrim); /* trim.c */
|
|||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
static void SplitChopperReply(pCodri self, char *prefix, char *pBueffel)
|
static void SplitChopperReply(pCodri self, char *prefix, char *pBueffel)
|
||||||
{
|
{
|
||||||
char pToken[30], pValue[20];
|
char pToken[30], pValue[20], pEntry[80];
|
||||||
char *pPtr, *pTok, *pVal;
|
char *pPtr, *pTok, *pVal;
|
||||||
int iCount, iRet;
|
int iCount, iRet;
|
||||||
pDoCho pPriv = NULL;
|
pDoCho pPriv = NULL;
|
||||||
@ -110,12 +110,13 @@ static void SplitChopperReply(pCodri self, char *prefix, char *pBueffel)
|
|||||||
{
|
{
|
||||||
pTok = trim(pToken);
|
pTok = trim(pToken);
|
||||||
pVal = trim(pValue);
|
pVal = trim(pValue);
|
||||||
sprintf(pToken,"%s.%s",prefix,pTok);
|
pEntry[0] = '\0';
|
||||||
iRet = StringDictUpdate(pPriv->pPar,pToken,pVal);
|
sprintf(pEntry,"%s.%s",prefix,pTok);
|
||||||
|
iRet = StringDictUpdate(pPriv->pPar,pEntry,pVal);
|
||||||
if(!iRet)
|
if(!iRet)
|
||||||
{
|
{
|
||||||
StringDictAddPair(pPriv->pPar,pToken,pVal);
|
StringDictAddPair(pPriv->pPar,pEntry,pVal);
|
||||||
strcat(self->pParList,pToken);
|
strcat(self->pParList,pEntry);
|
||||||
strcat(self->pParList,",");
|
strcat(self->pParList,",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,14 +125,14 @@ static void SplitChopperReply(pCodri self, char *prefix, char *pBueffel)
|
|||||||
/* this fixes a bug with oversized messages in dphas */
|
/* this fixes a bug with oversized messages in dphas */
|
||||||
if(strstr(pPtr,"dphas") != NULL)
|
if(strstr(pPtr,"dphas") != NULL)
|
||||||
{
|
{
|
||||||
sprintf(pToken,"%s.dphas",prefix);
|
sprintf(pEntry,"%s.dphas",prefix);
|
||||||
iRet = StringDictUpdate(pPriv->pPar,
|
iRet = StringDictUpdate(pPriv->pPar,
|
||||||
pToken,pPtr+5);
|
pEntry,pPtr+5);
|
||||||
if(!iRet)
|
if(!iRet)
|
||||||
{
|
{
|
||||||
StringDictAddPair(pPriv->pPar,pToken,
|
StringDictAddPair(pPriv->pPar,pEntry,
|
||||||
pPtr+5);
|
pPtr+5);
|
||||||
strcat(self->pParList,pToken);
|
strcat(self->pParList,pEntry);
|
||||||
strcat(self->pParList,",");
|
strcat(self->pParList,",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
33
histmem.c
33
histmem.c
@ -711,6 +711,15 @@
|
|||||||
return StartDevice(GetExecutor(),"HistogramMemory", self->pDes, self,
|
return StartDevice(GetExecutor(),"HistogramMemory", self->pDes, self,
|
||||||
pCon, self->pDriv->fCountPreset);
|
pCon, self->pDriv->fCountPreset);
|
||||||
}
|
}
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
int HistDoEnd(pHistMem self, SConnection *pCon)
|
||||||
|
{
|
||||||
|
assert(self);
|
||||||
|
assert(self->pCall);
|
||||||
|
|
||||||
|
/* send a COUNTEND event */
|
||||||
|
InvokeCallBack(self->pCall,COUNTEND,NULL);
|
||||||
|
}
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
int HistBlockCount(pHistMem self, SConnection *pCon)
|
int HistBlockCount(pHistMem self, SConnection *pCon)
|
||||||
{
|
{
|
||||||
@ -1171,6 +1180,30 @@ static int checkHMEnd(pHistMem self, char *text){
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
/* COUNTEND signal*/
|
||||||
|
else if(strcmp(argv[1],"countend") == 0)
|
||||||
|
{
|
||||||
|
if(SCMatchRights(pCon,self->iAccess))
|
||||||
|
{
|
||||||
|
if(IsCounting(pServ->pExecutor))
|
||||||
|
{
|
||||||
|
SCWrite(pCon,"WARNING: HM is counting!",eWarning);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
iRet = HistDoEnd(self,pCon);
|
||||||
|
if(iRet == 1)
|
||||||
|
{
|
||||||
|
SCSendOK(pCon);
|
||||||
|
}
|
||||||
|
return iRet;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SCWrite(pCon,
|
||||||
|
"ERROR: you are not privileged for attempted operation",eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* forced count, for the case several hm need to be started */
|
/* forced count, for the case several hm need to be started */
|
||||||
else if(strcmp(argv[1],"countf") == 0)
|
else if(strcmp(argv[1],"countf") == 0)
|
||||||
|
6
hmdata.c
6
hmdata.c
@ -67,7 +67,11 @@ int configureHMdata(pHMdata self, pStringDict pOpt,
|
|||||||
float fVal;
|
float fVal;
|
||||||
char pValue[80];
|
char pValue[80];
|
||||||
|
|
||||||
self->tofMode = 0;
|
if(self->nTimeChan > 2) {
|
||||||
|
self->tofMode = 1;
|
||||||
|
} else {
|
||||||
|
self->tofMode = 0;
|
||||||
|
}
|
||||||
status = StringDictGetAsNumber(pOpt,"rank",&fVal);
|
status = StringDictGetAsNumber(pOpt,"rank",&fVal);
|
||||||
if(!status){
|
if(!status){
|
||||||
SCWrite(pCon,"ERROR: critical configuration problem: no rank found",
|
SCWrite(pCon,"ERROR: critical configuration problem: no rank found",
|
||||||
|
287
polterwrite.c
287
polterwrite.c
@ -81,91 +81,21 @@ typedef struct {
|
|||||||
self->tUpdate = time(NULL);
|
self->tUpdate = time(NULL);
|
||||||
self->iEnd = 1;
|
self->iEnd = 1;
|
||||||
PoldiUpdate(self,self->pCon);
|
PoldiUpdate(self,self->pCon);
|
||||||
/*
|
|
||||||
Fortify_CheckAllMemory();
|
|
||||||
*/
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*----------------------------------------------------------------------*/
|
|
||||||
static void KillPolterdi(void *pData){
|
|
||||||
pPolterdi self = (pPolterdi)pData;
|
|
||||||
if(!self)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(self->pDes){
|
|
||||||
DeleteDescriptor(self->pDes);
|
|
||||||
}
|
|
||||||
if(self->pFile){
|
|
||||||
free(self->pFile);
|
|
||||||
}
|
|
||||||
if(self->dictfile){
|
|
||||||
free(self->dictfile);
|
|
||||||
}
|
|
||||||
free(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
int PolterInstall(SConnection *pCon, SicsInterp *pSics,
|
static void SNError(void *pData, char *text)
|
||||||
void *pData, int argc, char *argv[])
|
|
||||||
{
|
|
||||||
pPolterdi pNew = NULL;
|
|
||||||
pICallBack pCall = NULL;
|
|
||||||
pDummy pDum;
|
|
||||||
pHistMem pHist = NULL;
|
|
||||||
|
|
||||||
/* configure fortify */
|
|
||||||
/*
|
|
||||||
iFortifyScope = Fortify_EnterScope();
|
|
||||||
Fortify_CheckAllMemory();
|
|
||||||
*/
|
|
||||||
if(argc < 2){
|
|
||||||
SCWrite(pCon,"ERROR: insufficient number of arguments to PolterInstall",
|
|
||||||
eError);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
pHist = (pHistMem)FindCommandData(pSics,HM,"HistMem");
|
|
||||||
|
|
||||||
if (!pHist)
|
|
||||||
{
|
{
|
||||||
|
SConnection *pCon;
|
||||||
|
|
||||||
|
assert(pData);
|
||||||
|
pCon = (SConnection *)pData;
|
||||||
|
SCWrite(pCon,text,eError);
|
||||||
}
|
}
|
||||||
|
|
||||||
pNew = (pPolterdi)malloc(sizeof(Polterdi));
|
|
||||||
if(!pNew){
|
|
||||||
SCWrite(pCon,"ERROR: out of memory in PolterInstall",
|
|
||||||
eError);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
memset(pNew,0,sizeof(Polterdi));
|
|
||||||
pNew->pDes = CreateDescriptor("PolterdiWrite");
|
|
||||||
pNew->pHist = pHist;
|
|
||||||
pNew->dictfile = strdup(argv[1]);
|
|
||||||
pNew->iInterval = 20*60;
|
|
||||||
if(!pNew->pDes || !pNew->dictfile){
|
|
||||||
SCWrite(pCon,"ERROR: out of memory in PolterInstall",
|
|
||||||
eError);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/* 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,
|
static void writePolterdiGlobal(NXhandle hfil, NXdict hdict,
|
||||||
SConnection *pCon){
|
SConnection *pCon){
|
||||||
@ -194,10 +124,10 @@ static void writeDiaphragm1(NXhandle hfil, NXdict hdict,
|
|||||||
SConnection *pCon){
|
SConnection *pCon){
|
||||||
float dist;
|
float dist;
|
||||||
|
|
||||||
SNXSPutMotor(pServ->pSics,pCon,hfil,hdict,"dia1x","d1m");
|
SNXSPutMotor(pServ->pSics,pCon,hfil,hdict,"dia1x","d1hl");
|
||||||
SNXSPutMotorNull(pServ->pSics,pCon,hfil,hdict,"dia1x0","d1m");
|
SNXSPutMotorNull(pServ->pSics,pCon,hfil,hdict,"dia1x0","d1hl");
|
||||||
SNXSPutMotor(pServ->pSics,pCon,hfil,hdict,"dia1y","d1o");
|
SNXSPutMotor(pServ->pSics,pCon,hfil,hdict,"dia1y","d1hr");
|
||||||
SNXSPutMotorNull(pServ->pSics,pCon,hfil,hdict,"dia1y0","d1o");
|
SNXSPutMotorNull(pServ->pSics,pCon,hfil,hdict,"dia1y0","d1hr");
|
||||||
dist = (float)DIA1DIST;
|
dist = (float)DIA1DIST;
|
||||||
NXDputalias(hfil,hdict,"dia1dist",&dist);
|
NXDputalias(hfil,hdict,"dia1dist",&dist);
|
||||||
}
|
}
|
||||||
@ -207,14 +137,14 @@ static void writeDiaphragm1(NXhandle hfil, NXdict hdict,
|
|||||||
static void writeDiaphragm2(NXhandle hfil, NXdict hdict,
|
static void writeDiaphragm2(NXhandle hfil, NXdict hdict,
|
||||||
SConnection *pCon){
|
SConnection *pCon){
|
||||||
|
|
||||||
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "dia2x_plus", "d2m");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "dia2x_plus", "d2hl");
|
||||||
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "dia2xplus0", "d2m");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "dia2xplus0", "d2hl");
|
||||||
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "dia2x_minus", "d2u");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "dia2x_minus", "d2hr");
|
||||||
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "dia2xminus0", "d2u");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "dia2xminus0", "d2hr");
|
||||||
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "dia2z_plus", "d2o");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "dia2z_plus", "d2vu");
|
||||||
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "dia2zplus0", "d2o");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "dia2zplus0", "d2vu");
|
||||||
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "dia2z_minus", "d2l");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "dia2z_minus", "d2vl");
|
||||||
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "dia2zminus0", "d2l");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "dia2zminus0", "d2vl");
|
||||||
|
|
||||||
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"dia2dist","dia1_dia2");
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"dia2dist","dia1_dia2");
|
||||||
}
|
}
|
||||||
@ -227,14 +157,15 @@ static void writeSample(NXhandle hfil, NXdict hdict,
|
|||||||
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"chopperdist","chopper_sample");
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"chopperdist","chopper_sample");
|
||||||
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"saname","sample");
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"saname","sample");
|
||||||
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"senvir","environment");
|
SNXSPutVariable(pServ->pSics,pCon,hfil,hdict,"senvir","environment");
|
||||||
|
/*
|
||||||
SNXSPutEVVar(hfil,hdict,"temperature",pCon,"stemp","stddev");
|
SNXSPutEVVar(hfil,hdict,"temperature",pCon,"stemp","stddev");
|
||||||
|
|
||||||
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "srsu", "rsu");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "srsu", "rsu");
|
||||||
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "srsu0", "rsu");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "srsu0", "rsu");
|
||||||
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "srsl", "rsl");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "srsl", "rsl");
|
||||||
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "srsl0", "rsl");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "srsl0", "rsl");
|
||||||
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "srsa", "rsa");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "srsa", "rsa");
|
||||||
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "srsa0", "rsa");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "srsa0", "rsa");
|
||||||
|
*/
|
||||||
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "sshu", "shu");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "sshu", "shu");
|
||||||
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "sshu0", "shu");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "sshu0", "shu");
|
||||||
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "sshl", "shl");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "sshl", "shl");
|
||||||
@ -245,6 +176,8 @@ static void writeSample(NXhandle hfil, NXdict hdict,
|
|||||||
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "ssgl0", "sgl");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "ssgl0", "sgl");
|
||||||
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "ssv", "sv");
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "ssv", "sv");
|
||||||
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "ssv0", "sv");
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "ssv0", "sv");
|
||||||
|
SNXSPutMotor(pServ->pSics, pCon, hfil, hdict, "ssa", "sa");
|
||||||
|
SNXSPutMotorNull(pServ->pSics, pCon, hfil, hdict, "ssa0", "sa");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
@ -261,7 +194,7 @@ static int PoldiStart(pPolterdi self, SConnection *pCon)
|
|||||||
pSicsVariable pVar = NULL;
|
pSicsVariable pVar = NULL;
|
||||||
float det_radius, det_size, x0det, y0det, twothet;
|
float det_radius, det_size, x0det, y0det, twothet;
|
||||||
float pi, alpha1, alphasamp, sms, phidetav, phim;
|
float pi, alpha1, alphasamp, sms, phidetav, phim;
|
||||||
float phi2det, val1, val2, nodet;
|
float phi2det, val1, val2, nodet,scancheck;
|
||||||
int iLength, i, nzell;
|
int iLength, i, nzell;
|
||||||
pMotor sa;
|
pMotor sa;
|
||||||
HistInt *lData = NULL;
|
HistInt *lData = NULL;
|
||||||
@ -275,7 +208,6 @@ static int PoldiStart(pPolterdi self, SConnection *pCon)
|
|||||||
eError);
|
eError);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a Nexus file */
|
/* create a Nexus file */
|
||||||
NXopen(self->pFile,NXACC_CREATE,&hfil);
|
NXopen(self->pFile,NXACC_CREATE,&hfil);
|
||||||
if(!hfil)
|
if(!hfil)
|
||||||
@ -283,10 +215,21 @@ static int PoldiStart(pPolterdi self, SConnection *pCon)
|
|||||||
SCWrite(pCon,"ERROR: cannot create data file ",eError);
|
SCWrite(pCon,"ERROR: cannot create data file ",eError);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tell Uwe User what we are doing */
|
/* tell Uwe User what we are doing */
|
||||||
sprintf(pBueffel,"Writing %s ......",self->pFile);
|
pVar = NULL;
|
||||||
SCWrite(pCon,pBueffel,eWarning);
|
pVar = FindVariable(pServ->pSics,"scancheck");
|
||||||
|
if(pVar)
|
||||||
|
{
|
||||||
|
VarGetFloat(pVar, &scancheck);
|
||||||
|
} else {
|
||||||
|
SCWrite(pCon,"ERROR: Command not found!",eError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (scancheck == 0) {
|
||||||
|
sprintf(pBueffel,"Writing %s ......",self->pFile);
|
||||||
|
SCWrite(pCon,pBueffel,eWarning);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* write globals */
|
/* write globals */
|
||||||
SNXSPutGlobals(hfil,self->pFile,"POLDI",pCon);
|
SNXSPutGlobals(hfil,self->pFile,"POLDI",pCon);
|
||||||
@ -326,7 +269,7 @@ static int PoldiStart(pPolterdi self, SConnection *pCon)
|
|||||||
{
|
{
|
||||||
for(i = 0;i < iLength; i++)
|
for(i = 0;i < iLength; i++)
|
||||||
{
|
{
|
||||||
fTime2[i] = fTime[i]/10.;
|
fTime2[i] = fTime[i]/2.;
|
||||||
}
|
}
|
||||||
sprintf(pBueffel,"%d",iLength);
|
sprintf(pBueffel,"%d",iLength);
|
||||||
NXDupdate(hdict,"timebin",pBueffel);
|
NXDupdate(hdict,"timebin",pBueffel);
|
||||||
@ -482,16 +425,17 @@ static int PoldiStart(pPolterdi self, SConnection *pCon)
|
|||||||
pSicsVariable pVar = NULL;
|
pSicsVariable pVar = NULL;
|
||||||
float det_radius, det_size, x0det, y0det, twothet;
|
float det_radius, det_size, x0det, y0det, twothet;
|
||||||
float pi, alpha1, alphasamp, sms, phidetav, phim;
|
float pi, alpha1, alphasamp, sms, phidetav, phim;
|
||||||
float phi2det, val1, val2, nodet;
|
float phi2det, val1, val2, nodet, scancheck;
|
||||||
int iLength, i, nzell;
|
int iLength, i, nzell;
|
||||||
pMotor sa;
|
pMotor sa;
|
||||||
HistInt *lData = NULL;
|
HistInt *lData = NULL;
|
||||||
long lVal;
|
long lVal;
|
||||||
|
time_t zeit;
|
||||||
|
|
||||||
/* open everything again */
|
/* open everything again */
|
||||||
status = NXopen(self->pFile,NXACC_RDWR,&hfil);
|
status = NXopen(self->pFile,NXACC_RDWR,&hfil);
|
||||||
if(status != NX_OK)
|
if(status != NX_OK)
|
||||||
{
|
{
|
||||||
SCWrite(pCon,"ERROR: cannot reopen data file ",eError);
|
SCWrite(pCon,"ERROR: cannot reopen data file ",eError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -509,30 +453,38 @@ static int PoldiStart(pPolterdi self, SConnection *pCon)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* tell the user that something is happening */
|
/* tell the user that something is happening */
|
||||||
sprintf(pBueffel,"Updating %s",self->pFile);
|
pVar = NULL;
|
||||||
SCWrite(pCon,pBueffel,eWarning);
|
pVar = FindVariable(pServ->pSics,"scancheck");
|
||||||
|
if(pVar)
|
||||||
|
{
|
||||||
|
VarGetFloat(pVar, &scancheck);
|
||||||
|
} else {
|
||||||
|
SCWrite(pCon,"ERROR: Command not found!",eError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (scancheck == 0) {
|
||||||
|
time(&zeit);
|
||||||
|
sprintf(pBueffel,"Updating %s on %s ",self->pFile,asctime(localtime(&zeit)));
|
||||||
|
SCWrite(pCon,pBueffel,eWarning);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
write time binning
|
write time binning
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fTime = GetHistTimeBin(self->pHist,&iLength);
|
fTime = GetHistTimeBin(self->pHist,&iLength);
|
||||||
fTime2 = (float *)malloc(iLength*sizeof(float));
|
fTime2 = (float *)malloc(iLength*sizeof(float));
|
||||||
if(fTime2)
|
if(fTime2)
|
||||||
{
|
|
||||||
for(i = 0;i < iLength; i++)
|
|
||||||
{
|
{
|
||||||
fTime2[i] = fTime[i]/10.;
|
for(i = 0;i < iLength; i++) {
|
||||||
|
fTime2[i] = fTime[i]/2.;
|
||||||
|
}
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
write Histogram
|
write Histogram
|
||||||
@ -624,7 +576,7 @@ static int PoldiStart(pPolterdi self, SConnection *pCon)
|
|||||||
static int PoldiTask(void *pData)
|
static int PoldiTask(void *pData)
|
||||||
{
|
{
|
||||||
pPolterdi self = NULL;
|
pPolterdi self = NULL;
|
||||||
int iWrite, iRet;
|
int iWrite, iRet, ltask;
|
||||||
|
|
||||||
self = (pPolterdi)pData;
|
self = (pPolterdi)pData;
|
||||||
if(!self)
|
if(!self)
|
||||||
@ -636,15 +588,20 @@ static int PoldiStart(pPolterdi self, SConnection *pCon)
|
|||||||
/* first case: update intervall */
|
/* first case: update intervall */
|
||||||
if(time(NULL) >= self->tUpdate)
|
if(time(NULL) >= self->tUpdate)
|
||||||
{
|
{
|
||||||
self->tUpdate = time(NULL) + self->iInterval;
|
ltask = GetDevexecID(pServ->pExecutor);
|
||||||
iWrite = 1;
|
if (ltask > 0)
|
||||||
iRet = 1;
|
{
|
||||||
|
self->tUpdate = time(NULL) + self->iInterval;
|
||||||
|
iWrite = 1;
|
||||||
|
iRet = 1;
|
||||||
|
} else {
|
||||||
|
self->iEnd = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self->iEnd)
|
if(self->iEnd == 1)
|
||||||
{
|
{
|
||||||
self->tUpdate = 0;
|
self->tUpdate = 0;
|
||||||
SCWrite(self->pCon,"Writing finished!",eError);
|
|
||||||
iWrite = 0;
|
iWrite = 0;
|
||||||
iRet = 0;
|
iRet = 0;
|
||||||
}
|
}
|
||||||
@ -660,11 +617,94 @@ static int PoldiStart(pPolterdi self, SConnection *pCon)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
PoldiUpdate(self,self->pCon);
|
PoldiUpdate(self,self->pCon);
|
||||||
PoldiLink(self,self->pCon);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------*/
|
||||||
|
static void KillPolterdi(void *pData){
|
||||||
|
pPolterdi self = (pPolterdi)pData;
|
||||||
|
if(!self)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(self->pDes){
|
||||||
|
DeleteDescriptor(self->pDes);
|
||||||
|
}
|
||||||
|
if(self->pFile){
|
||||||
|
free(self->pFile);
|
||||||
|
}
|
||||||
|
if(self->dictfile){
|
||||||
|
free(self->dictfile);
|
||||||
|
}
|
||||||
|
free(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
int PolterInstall(SConnection *pCon, SicsInterp *pSics,
|
||||||
|
void *pData, int argc, char *argv[])
|
||||||
|
{
|
||||||
|
pPolterdi pNew = NULL;
|
||||||
|
pICallBack pCall = NULL;
|
||||||
|
pDummy pDum;
|
||||||
|
pHistMem pHist = NULL;
|
||||||
|
|
||||||
|
/* configure fortify */
|
||||||
|
/*
|
||||||
|
iFortifyScope = Fortify_EnterScope();
|
||||||
|
Fortify_CheckAllMemory();
|
||||||
|
*/
|
||||||
|
if(argc < 2){
|
||||||
|
SCWrite(pCon,"ERROR: insufficient number of arguments to PolterInstall",
|
||||||
|
eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
pHist = (pHistMem)FindCommandData(pSics,HM,"HistMem");
|
||||||
|
|
||||||
|
if (!pHist)
|
||||||
|
{
|
||||||
|
SCWrite(pCon,"ERROR: Histogram memory NOT found",eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pNew = (pPolterdi)malloc(sizeof(Polterdi));
|
||||||
|
if(!pNew){
|
||||||
|
SCWrite(pCon,"ERROR: out of memory in PolterInstall",
|
||||||
|
eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
memset(pNew,0,sizeof(Polterdi));
|
||||||
|
pNew->pDes = CreateDescriptor("PoldiWrite");
|
||||||
|
pNew->pHist = pHist;
|
||||||
|
pNew->dictfile = strdup(argv[1]);
|
||||||
|
pNew->iInterval = 20*60;
|
||||||
|
if(!pNew->pDes || !pNew->dictfile){
|
||||||
|
SCWrite(pCon,"ERROR: out of memory in PolterInstall",
|
||||||
|
eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* 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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
int PolterAction(SConnection *pCon, SicsInterp *pSics,
|
int PolterAction(SConnection *pCon, SicsInterp *pSics,
|
||||||
void *pData, int argc, char *argv[])
|
void *pData, int argc, char *argv[])
|
||||||
@ -695,11 +735,12 @@ int PolterAction(SConnection *pCon, SicsInterp *pSics,
|
|||||||
if((self->iNew) || (!self->pFile))
|
if((self->iNew) || (!self->pFile))
|
||||||
{
|
{
|
||||||
PoldiStart(self,pCon);
|
PoldiStart(self,pCon);
|
||||||
|
PoldiUpdate(self,pCon);
|
||||||
|
PoldiLink(self,pCon);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PoldiUpdate(self,pCon);
|
PoldiUpdate(self,pCon);
|
||||||
PoldiLink(self,pCon);
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -731,7 +772,7 @@ int PolterAction(SConnection *pCon, SicsInterp *pSics,
|
|||||||
}
|
}
|
||||||
else /* read the value */
|
else /* read the value */
|
||||||
{
|
{
|
||||||
sprintf(pBueffel,"storefocus.interval = %d",self->iInterval/60);
|
sprintf(pBueffel,"storedata.interval = %d",self->iInterval/60);
|
||||||
SCWrite(pCon,pBueffel,eValue);
|
SCWrite(pCon,pBueffel,eValue);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
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 POLDI data files.
|
||||||
|
|
||||||
copyright: see copyright.h
|
copyright: see copyright.h
|
||||||
|
|
||||||
Uwe Filges, November 2001
|
Uwe Filges, November 2001
|
||||||
----------------------------------------------------------------------------*/
|
----------------------------------------------------------------------------*/
|
||||||
#ifndef POLTERDIWRITE
|
#ifndef POLTERDI
|
||||||
#define POLTERDIWRITE
|
#define POLTERDI
|
||||||
|
|
||||||
int PolterInstall(SConnection *pCon, SicsInterp *pSics,
|
int PolterInstall(SConnection *pCon, SicsInterp *pSics,
|
||||||
void *pData, int argc, char *argv[]);
|
void *pData, int argc, char *argv[]);
|
||||||
|
Reference in New Issue
Block a user