diff --git a/asynnet.c b/asynnet.c index 8367ac4e..0f7651f9 100644 --- a/asynnet.c +++ b/asynnet.c @@ -221,19 +221,21 @@ int ANETconnect(char *name, int iPort) struct hostent *host; int socke, status; - /* check for aaa.bbb.ccc.ddd first */ - addr.s_addr = inet_addr(name); - if (addr.s_addr < 0) { - host = gethostbyname(name); - if (host == NULL) { - anetLog(ANETERROR, "Failed to locate host: %s", name); - return ANETOPENFAIL; - } - memcpy(&addr, host->h_addr_list, sizeof(struct in_addr)); - } memset(&addresse, 0, sizeof(struct sockaddr_in)); addresse.sin_family = AF_INET; addresse.sin_port = htons((unsigned short)(iPort &0xFFFF)); + host = gethostbyname(name); + if (host != NULL) { + memcpy((char *) &addr, + (char *)host->h_addr_list[0], (size_t)host->h_length); + } else { + /* check for aaa.bbbb.ccc.dddd */ + addr.s_addr = inet_addr(name); + if(addr.s_addr == (unsigned long) -1) { + anetLog(ANETERROR, "Failed to locate host: %s", name); + return ANETOPENFAIL; + } + } addresse.sin_addr.s_addr = addr.s_addr; socke = socket(AF_INET, SOCK_STREAM, 0); status = connect(socke, (struct sockaddr *) &addresse, diff --git a/devexec.c b/devexec.c index 23a41f06..987e8d3c 100644 --- a/devexec.c +++ b/devexec.c @@ -311,7 +311,7 @@ int StartDevice(pExeList self, char *name, pObjectDescriptor pDes, } else { SCWrite(pCon, "ERROR: somebody else is still driving, Request rejected", - eError); + eLogError); return 0; } } diff --git a/fourlib.c b/fourlib.c index 57734cca..3ce972c2 100644 --- a/fourlib.c +++ b/fourlib.c @@ -546,7 +546,7 @@ int z1mToNormalBeam(double lambda, MATRIX z1m, double *gamma, double *om, b = sign(1, b) * floor(ABS(b)); omdeg = omdeg - 360. * b; *nu = asin(lambda * z1m[2][0]); - *gamma = acos(cos(2. * (theta / RD))) / cos(*nu); + *gamma = acos(cos(2. * (theta / RD)) / cos(*nu)); *om = omdeg; *nu = *nu * RD; *gamma = *gamma * RD; diff --git a/fourmess.c b/fourmess.c index 778a7cfb..f50221d6 100644 --- a/fourmess.c +++ b/fourmess.c @@ -640,7 +640,12 @@ static int FourMessWeak(pSICSOBJ self, SConnection * pCon, return 1; } -/*----------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------- + * Usage of the suppress flag: + * 0 do notthing + * 1 suppress symmetriqually equivalent reflections + * 2 opposite: add only reflections NOT allowed by the spacegroup + * ---------------------------------------------------------------------------*/ static int GenIndex(pSICSOBJ self, SConnection * pCon, pHdb commandNode, pHdb par[], int nPar) { @@ -689,12 +694,20 @@ static int GenIndex(pSICSOBJ self, SConnection * pCon, pHdb commandNode, for (l = hkllim.v.intArray[2]; l <= hkllim.v.intArray[5]; l++) { /* SCPrintf(pCon,eLog, "Testing %d, %d, %d", h,k,l); */ /* first test: extinct */ - if (IsSysAbsent_hkl(sginfo, h, k, l, NULL) != 0) { - /* SCPrintf(pCon,eLog, "%d, %d, %d rejected for sys absent", h, k, l); */ - continue; - } + + if(suppress != 2){ + if (IsSysAbsent_hkl(sginfo, h, k, l, NULL) != 0) { + /* SCPrintf(pCon,eLog, "%d, %d, %d rejected for sys absent", h, k, l); */ + continue; + } + } else { + if (!IsSysAbsent_hkl(sginfo, h, k, l, NULL) != 0) { + /* SCPrintf(pCon,eLog, "%d, %d, %d rejected for not sys absent", h, k, l); */ + continue; + } + } /* second test: a symmetrically equivalent already seen */ - if ((suppress != 0) && IsSuppressed_hkl(sginfo, minh, mink, minl, + if ((suppress > 0) && IsSuppressed_hkl(sginfo, minh, mink, minl, hkllim.v.intArray[1], hkllim.v.intArray[2], h, k, l) != 0) { @@ -745,15 +758,20 @@ static int GenInconsumerate(pSICSOBJ self, SConnection * pCon, qvec[2] = par[2]->value.v.doubleValue; for (i = 0; i < priv->masterCount; i++) { - GetRefIndex(priv->messList, i, hkl); + GetRefIndex(priv->messList, i, hkl); for (j = 0; j < 3; j++) { hkl[j] += qvec[j]; } AddRefIdx(priv->messList, hkl); + GetRefIndex(priv->messList, i, hkl); + for (j = 0; j < 3; j++) { + hkl[j] -= qvec[j]; + } + AddRefIdx(priv->messList, hkl); } SCPrintf(pCon, eValue, "%d additional inconsumerate reflections generated", - priv->masterCount); + priv->masterCount*2); return 1; } @@ -865,6 +883,8 @@ void InstallFourMess(SConnection * pCon, SicsInterp * pSics) pNew->KillPrivate = KillFourMess; priv->stepTable = MakeFourCircleTable(); + AddCommand(pSics, "fmesstable", InterInvokeSICSOBJ, NULL, priv->stepTable); + priv->messList = CreateReflectionList(pCon, pSics, "messref"); if (priv->stepTable < 0 || priv->messList == NULL) { SCWrite(pCon, "ERROR: out of memory creating fourmess", eError); @@ -875,6 +895,10 @@ void InstallFourMess(SConnection * pCon, SicsInterp * pSics) cmd = AddSICSHdbPar(pNew->objectNode, "weakthreshold", usUser, MakeHdbInt(20)); SetHdbProperty(cmd, "__save", "true"); + + cmd = AddSICSHdbPar(pNew->objectNode, "fast", usUser, MakeHdbInt(0)); + SetHdbProperty(cmd, "__save", "true"); + cmd = AddSICSHdbPar(pNew->objectNode, "mode", usUser, MakeHdbText("Monitor")); @@ -962,7 +986,7 @@ void InstallFourMess(SConnection * pCon, SicsInterp * pSics) MakeHipadabaCallback(SetScannerCB, priv, NULL)); priv->pScanner = FindCommandData(pSics, "xxxscan", "ScanObject"); - AddHipadabaChild(pNew->objectNode, priv->stepTable->objectNode,pCon); + /* AddHipadabaChild(pNew->objectNode, priv->stepTable->objectNode,pCon); */ AddCommand(pSics, "fmess", FourMessAction, KillSICSOBJ, pNew); } diff --git a/hdbtable.c b/hdbtable.c index fb04c84e..95cd4a4b 100644 --- a/hdbtable.c +++ b/hdbtable.c @@ -52,22 +52,22 @@ int SaveHdbTable(void *data, char *name, FILE * fd) static int ClearTblCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode, pHdb par[], int nPar) { - pHdb node; + pHdb node, child, tmp; node = GetHipadabaNode(self->objectNode,"data"); if(node != NULL){ if(CountHdbChildren(node) < 1){ return 1; } - DeleteNodeData(node); - RemoveHdbNodeFromParent(node, pCon); + child = node->child; + while(child != NULL){ + tmp = child; + child = child->next; + DeleteNodeData(tmp); + } } - node = MakeHipadabaNode("data",HIPNONE,1); - if(node == NULL){ - SCWrite(pCon,"ERROR: out of memory in ClearTblCmd", eError); - return 0; - } - AddHipadabaChild(self->objectNode,node,NULL); + node->child = NULL; + SendTreeChangeMessage(node,pCon); SetDescriptorKey(self->pDes,"rowcount","0"); if(pCon != NULL){ SCparChange(pCon); @@ -100,7 +100,8 @@ static int AddTblRowCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode, child = template->child; count = 0; while(child != NULL){ - val = MakeHipadabaNode(child->name,child->value.dataType, child->value.arrayLength); + val = MakeSICSHdbPar(child->name,usUser, + makeHdbValue(child->value.dataType, child->value.arrayLength)); if(count < nPar){ UpdateHipadabaPar(val,par[count]->value,pCon); } @@ -112,6 +113,7 @@ static int AddTblRowCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode, child = GetHipadabaNode(self->objectNode,"data"); assert(child != NULL); AddHipadabaChild(child,row, pCon); + SendTreeChangeMessage(child,pCon); if(pCon != NULL){ SCparChange(pCon); } @@ -125,6 +127,10 @@ static int RepTblRowCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode, char path[132]; pHdb row, val, child; + if(nPar < 1) { + SCPrintf(pCon,eError,"ERROR: no parameters found to reprow"); + return 0; + } snprintf(path,131,"data/%s", par[0]->value.v.text); row = GetHipadabaNode(self->objectNode,path); if(row == NULL){ @@ -134,7 +140,7 @@ static int RepTblRowCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode, child = row->child; count = 1; - while(child != NULL){ + while(child != NULL && count < nPar){ if(count < nPar){ UpdateHipadabaPar(child,par[count]->value,pCon); } @@ -162,6 +168,7 @@ int ReadTableTemplate(pSICSOBJ self, SConnection *con) template = GetHipadabaNode(self->objectNode,"template"); assert(template != NULL); + /* mogrify addrow */ node = GetHipadabaNode(self->objectNode,"addrow"); if(node != NULL){ DeleteHipadabaNode(node,pCon); @@ -173,9 +180,12 @@ int ReadTableTemplate(pSICSOBJ self, SConnection *con) SCWrite(pCon,"ERROR: out of memory in ReadTemplateCmd",eError ); return 0; } + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","user"); child = template->child; while(child != NULL){ - node = MakeHipadabaNode(child->name, child->value.dataType, child->value.arrayLength); + node = MakeSICSHdbPar(child->name, usUser, + makeHdbValue(child->value.dataType, child->value.arrayLength)); if(node == NULL){ SCWrite(pCon,"ERROR: out of memory in ReadTemplateCmd",eError ); return 0; @@ -184,18 +194,26 @@ int ReadTableTemplate(pSICSOBJ self, SConnection *con) child = child->next; } + /* mogrify reprow */ + node = GetHipadabaNode(self->objectNode,"reprow"); + if(node != NULL){ + DeleteHipadabaNode(node,pCon); + } cmd = AddSICSHdbPar(self->objectNode, "reprow", usUser, - MakeSICSFunc(AddTblRowCmd)); + MakeSICSFunc(RepTblRowCmd)); if(cmd == NULL){ SCWrite(pCon,"ERROR: out of memory in ReadTemplateCmd",eError ); return 0; } - node = MakeHipadabaNode("id",HIPTEXT,1); + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","user"); + node = MakeSICSHdbPar("id",usUser, makeHdbValue(HIPTEXT,1)); AddHipadabaChild(cmd,node, pCon); child = template->child; while(child != NULL){ - node = MakeHipadabaNode(child->name, child->value.dataType, child->value.arrayLength); + node = MakeSICSHdbPar(child->name, usUser, + makeHdbValue(child->value.dataType, child->value.arrayLength)); if(node == NULL){ SCWrite(pCon,"ERROR: out of memory in ReadTemplateCmd",eError ); return 0; @@ -215,7 +233,7 @@ static int ReadTemplateCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode, static int DelRowCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode, pHdb par[], int nPar) { - pHdb row = NULL; + pHdb row = NULL, data; char path[132]; if(nPar < 1){ @@ -228,10 +246,12 @@ static int DelRowCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode, SCPrintf(pCon,eError,"ERROR: row with ID %s not found", par[0]->value.v.text); return 0; } + data = row->mama; DeleteHipadabaNode(row,pCon); if(pCon != NULL){ SCparChange(pCon); } + SendTreeChangeMessage(data,pCon); SCSendOK(pCon); return 1; } @@ -342,7 +362,7 @@ pSICSOBJ MakeHdbTable(char *name, char *hdbclass) SetHdbProperty(result->objectNode,"viewer","mountaingumui.TableViewer"); result->pDes->SaveStatus = SaveHdbTable; - node = MakeHipadabaNode("template",HIPNONE,1); + node = MakeSICSHdbPar("template",usMugger,MakeHdbText("x,y")); if(node == NULL){ return NULL; } @@ -358,15 +378,23 @@ pSICSOBJ MakeHdbTable(char *name, char *hdbclass) cmd = AddSICSHdbPar(result->objectNode, "clear", usUser, MakeSICSFunc(ClearTblCmd)); + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","user"); cmd = AddSICSHdbPar(result->objectNode, "print", usUser, MakeSICSFunc(ListTblCmd)); + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","user"); cmd = AddSICSHdbPar(result->objectNode, "addrow", usUser, MakeSICSFunc(AddTblRowCmd)); + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","user"); cmd = AddSICSHdbPar(result->objectNode, "reprow", usUser, MakeSICSFunc(RepTblRowCmd)); + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","user"); cmd = AddSICSHdbPar(result->objectNode, "readtemplate", usUser, MakeSICSFunc(ReadTemplateCmd)); @@ -374,12 +402,44 @@ pSICSOBJ MakeHdbTable(char *name, char *hdbclass) cmd = AddSICSHdbPar(result->objectNode, "del", usUser, MakeSICSFunc(DelRowCmd)); node = MakeHipadabaNode("id",HIPTEXT,1); + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","user"); + SetHdbProperty(node,"priv","user"); AddHipadabaChild(cmd,node, NULL); cmd = AddSICSHdbPar(result->objectNode, "get", usUser, MakeSICSFunc(GetRowCmd)); + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","user"); node = MakeHipadabaNode("id",HIPTEXT,1); + SetHdbProperty(node,"priv","user"); AddHipadabaChild(cmd,node, NULL); return result; } +/*---------------------------------------------------------------------------*/ +int HdbTableFactory(SConnection *pCon, SicsInterp *pSics, void *pData, + int argc, char *argv[]) +{ + pSICSOBJ pNew = NULL; + int status; + + if(argc < 2) { + SCWrite(pCon,"ERROR: need name of table to create", eError); + return 0; + } + + pNew = MakeHdbTable(argv[1],"HdbTable"); + if(pNew == NULL){ + SCWrite(pCon,"ERROR: out of memory in MakeHdbTable", eError); + return 0; + } + + status = AddCommand(pSics, argv[1], InterInvokeSICSOBJ, DefaultKill, pNew); + if (status != 1) { + SCWrite(pCon, "ERROR: duplicate HdbTable command not created", eError); + return 0; + } + + return 1; +} diff --git a/hdbtable.h b/hdbtable.h index c1848a0d..816755a3 100644 --- a/hdbtable.h +++ b/hdbtable.h @@ -12,5 +12,6 @@ pSICSOBJ MakeHdbTable(char *name, char *hdbclass); int ReadTableTemplate(pSICSOBJ self, SConnection *con); - +int HdbTableFactory(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]); + #endif /*HDBTABLE_H_*/ diff --git a/hmcontrol.c b/hmcontrol.c index dc1c5763..522c6f91 100644 --- a/hmcontrol.c +++ b/hmcontrol.c @@ -178,6 +178,9 @@ static void HMCParameter(void *pData, float fPreset, CounterMode eMode) self = (pHMcontrol) pData; assert(self); + if(isRunning(self->pCount)){ + return; + } for (i = 0; i < self->nSlaves; i++) { self->slaves[i]->SetCountParameters(self->slaveData[i], fPreset, eMode); diff --git a/make_gen b/make_gen index b7a2193f..45ac77ca 100644 --- a/make_gen +++ b/make_gen @@ -41,7 +41,7 @@ SOBJ = network.o ifile.o conman.o SCinter.o splitter.o passwd.o \ sgclib.o sgfind.o sgio.o sgsi.o sghkl.o singlediff.o singlebi.o \ singlenb.o simindex.o simidx.o uselect.o singletas.o motorsec.o \ rwpuffer.o asynnet.o background.o countersec.o hdbtable.o velosec.o \ - histmemsec.o + histmemsec.o sansbc.o MOTOROBJ = motor.o simdriv.o COUNTEROBJ = countdriv.o simcter.o counter.o diff --git a/multicounter.c b/multicounter.c index 35ffd86e..694b865c 100644 --- a/multicounter.c +++ b/multicounter.c @@ -113,7 +113,7 @@ static int MMCCStart(void *pData, SConnection * pCon) static int MMCCStatus(void *pData, SConnection * pCon) { int status, i; - pCounter pCount = NULL; + pCounter pCount = NULL, pMaster = NULL;; pMultiCounter self = NULL; pDummy pDum = NULL; @@ -130,6 +130,8 @@ static int MMCCStatus(void *pData, SConnection * pCon) } status = self->slaves[0]->CheckCountStatus(self->slaveData[0], pCon); + pMaster = (pCounter)self->slaveData[0]; + pCount->pDriv->fLastCurrent = pMaster->pDriv->fLastCurrent; if (status == HWIdle || status == HWFault) { /* stop counting on slaves when finished or when an error diff --git a/ofac.c b/ofac.c index 69456f3d..958f2198 100644 --- a/ofac.c +++ b/ofac.c @@ -133,6 +133,8 @@ #include "background.h" #include "velosec.h" #include "histmemsec.h" +#include "hdbtable.h" +#include "sansbc.h" /*----------------------- Server options creation -------------------------*/ static int IFServerOption(SConnection * pCon, SicsInterp * pSics, void *pData, int argc, char *argv[]) @@ -343,6 +345,9 @@ static void InitIniCommands(SicsInterp * pInter, pTaskMan pTask) AddCommand(pInter, "MakeSecMotor", SecMotorFactory, NULL, NULL); AddCommand(pInter, "MakeSecNVS", MakeSecNVS, NULL, NULL); AddCommand(pInter, "MakeSecHM", MakeSecHM, NULL, NULL); + AddCommand(pInter, "MakeHdbTable", HdbTableFactory, NULL, NULL); + AddCommand(pInter, "MakeSansBC", SansBCFactory, NULL, NULL); + /* install site specific commands @@ -425,6 +430,8 @@ static void KillIniCommands(SicsInterp * pSics) RemoveCommand(pSics, "MakeSecMotor"); RemoveCommand(pSics, "MakeSecNVS"); RemoveCommand(pSics, "MakeSecHM"); + RemoveCommand(pSics, "MakeHdbTable"); + RemoveCommand(pSics, "MakeSansBC"); /* remove site specific installation commands */ diff --git a/reflist.c b/reflist.c index e9a0e241..4c2b1c6d 100644 --- a/reflist.c +++ b/reflist.c @@ -111,7 +111,7 @@ pSICSOBJ MakeReflectionListInt(char *name) priv->idxCount = 3; v = MakeHdbText("stt,om,chi,phi"); - node = MakeSICSHdbPar("anglesheader", usMugger, v); + node = MakeSICSHdbPar("anglesheader", usUser, v); AppendHipadabaCallback(node, MakeHipadabaCallback(CalcConfiguration, pNew, NULL)); AddHipadabaChild(pNew->objectNode, node, NULL); @@ -455,6 +455,8 @@ pSICSOBJ CreateReflectionList(SConnection * pCon, SicsInterp * pSics, cmd = AddSICSHdbPar(pNew->objectNode, "addx", usUser, MakeSICSFunc(AddIndexCmd)); + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","user"); AddSICSHdbPar(cmd, "h", usUser, MakeHdbFloat(.0)); AddSICSHdbPar(cmd, "k", usUser, MakeHdbFloat(.0)); AddSICSHdbPar(cmd, "l", usUser, MakeHdbFloat(.0)); @@ -462,6 +464,8 @@ pSICSOBJ CreateReflectionList(SConnection * pCon, SicsInterp * pSics, cmd = AddSICSHdbPar(pNew->objectNode, "setx", usUser, MakeSICSFunc(SetIndexCmd)); + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","user"); AddSICSHdbPar(cmd, "id", usUser, MakeHdbText("")); AddSICSHdbPar(cmd, "h", usUser, MakeHdbFloat(.0)); AddSICSHdbPar(cmd, "k", usUser, MakeHdbFloat(.0)); @@ -470,6 +474,8 @@ pSICSOBJ CreateReflectionList(SConnection * pCon, SicsInterp * pSics, cmd = AddSICSHdbPar(pNew->objectNode, "adda", usUser, MakeSICSFunc(AddAnglesCmd)); + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","user"); AddSICSHdbPar(cmd, "stt", usUser, MakeHdbFloat(.0)); AddSICSHdbPar(cmd, "om", usUser, MakeHdbFloat(.0)); AddSICSHdbPar(cmd, "chi", usUser, MakeHdbFloat(.0)); @@ -478,6 +484,8 @@ pSICSOBJ CreateReflectionList(SConnection * pCon, SicsInterp * pSics, cmd = AddSICSHdbPar(pNew->objectNode, "seta", usUser, MakeSICSFunc(SetAnglesCmd)); + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","user"); AddSICSHdbPar(cmd, "id", usUser, MakeHdbText("")); AddSICSHdbPar(cmd, "stt", usUser, MakeHdbFloat(.0)); AddSICSHdbPar(cmd, "om", usUser, MakeHdbFloat(.0)); @@ -487,6 +495,8 @@ pSICSOBJ CreateReflectionList(SConnection * pCon, SicsInterp * pSics, cmd = AddSICSHdbPar(pNew->objectNode, "addax", usUser, MakeSICSFunc(AddIndexesAnglesCmd)); + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","user"); AddSICSHdbPar(cmd, "h", usUser, MakeHdbFloat(.0)); AddSICSHdbPar(cmd, "k", usUser, MakeHdbFloat(.0)); AddSICSHdbPar(cmd, "l", usUser, MakeHdbFloat(.0)); @@ -498,6 +508,8 @@ pSICSOBJ CreateReflectionList(SConnection * pCon, SicsInterp * pSics, cmd = AddSICSHdbPar(pNew->objectNode, "show", usUser, MakeSICSFunc(ShowCmd)); + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","user"); AddSICSHdbPar(cmd, "id", usUser, MakeHdbText("")); AddCommand(pSics, name, InterInvokeSICSOBJ, KillSICSOBJ, pNew); diff --git a/sansbc.c b/sansbc.c new file mode 100644 index 00000000..b9137584 --- /dev/null +++ b/sansbc.c @@ -0,0 +1,248 @@ +/** + * This is a little routine to calculate the beam center from SANS data + * in the detector. This is basically a COG or COC (center of contour) + * calculation above a given threshold. Where we make an effor to + * find the threshold ourselves. + * + * copyright: GPL + * + * Mark Koennecke, July 2009 + */ +#include +#include +#include "HistMem.h" +#include "sicsobj.h" +#include "sicshipadaba.h" + +extern float nintf(float x); +/*---------------------------------------------------------------------*/ +static int calculateCOG(int *iData, int xsize, int ysize, + float *i, float *j, int *intensity, float contour, + float level) +{ + int threshold, nCount; + float cogTotal, cogX, cogY, conMin, conMax; + int *iPtr, x, y; + + conMin = contour - (contour *level); + conMax = contour + (contour *level); + + /* + build the sums + */ + nCount = 0; + cogTotal = cogY = cogX = .0; + for (y = 0; y < ysize; y++) { + iPtr = iData + y * xsize; + for (x = 0; x < xsize; x++) { + if (iPtr[x] > conMin && iPtr[x] < conMax) { + nCount++; + cogTotal += iPtr[x]; + cogY += y * iPtr[x]; + cogX += x * iPtr[x]; + } + } + } + if (cogTotal <= .0) { + return 0; + } + + *i = cogX / cogTotal; + *j = cogY / cogTotal; + *intensity = (int) cogTotal; + + return 1; +} +/*------------------------------------------------------------------*/ +static int calculateCOC(int *iData, int xsize, int ysize, + float *i, float *j, int *intensity, float contour) +{ + int threshold, nCount; + float cogTotal, cogX, cogY; + int *iPtr, x, y; + + /* + build the sums + */ + nCount = 0; + cogTotal = cogY = cogX = .0; + for (y = 0; y < ysize; y++) { + iPtr = iData + y * xsize; + for (x = 0; x < xsize; x++) { + if (iPtr[x] > contour) { + nCount++; + cogTotal += 1; + cogY += y * 1; + cogX += x * 1; + } + } + } + if (cogTotal <= .0) { + return 0; + } + + *i = cogX / cogTotal; + *j = cogY / cogTotal; + *intensity = (int) cogTotal; + + return 1; +} +/*-------------------------------------------------------------------------*/ +static int COGCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode, + pHdb par[], int nPar) +{ + pHistMem hm = NULL; + float contour, level, x = .0, y = .0; + int length, intensity, dim[3]; + + if(nPar < 3){ + SCWrite(pCon,"ERROR: need hm-name, contour and level for COG calculation", + eError); + return 0; + } + + hm = FindCommandData(pServ->pSics, + par[0]->value.v.text, "HistMem"); + if(hm == NULL){ + SCPrintf(pCon,eError,"ERROR: hm %s not found", par[0]->value.v.text); + return 0; + } + contour = par[1]->value.v.doubleValue; + level = par[2]->value.v.doubleValue; + + + GetHistDim(hm, dim, &length); + if(length != 2) { + SCPrintf(pCon,eError,"ERROR: hm %s is not 2D", par[0]->value.v.text); + return 0; + } + + calculateCOG(GetHistogramPointer(hm,pCon), + dim[0], dim[1], &x, &y, &intensity, contour, level); + + SCPrintf(pCon,eValue,"BC = %.2f,%.2f", x,y); + return 1; +} +/*-------------------------------------------------------------------------*/ +static int COCCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode, + pHdb par[], int nPar) +{ + pHistMem hm = NULL; + float contour, x, y; + int length, intensity, dim[3]; + + if(nPar < 2){ + SCWrite(pCon,"ERROR: need hm-name and contour for COG calculation", + eError); + return 0; + } + + hm = FindCommandData(pServ->pSics, + par[0]->value.v.text, "HistMem"); + if(hm == NULL){ + SCPrintf(pCon,eError,"ERROR: hm %s not found", par[0]->value.v.text); + return 0; + } + contour = par[1]->value.v.doubleValue; + + GetHistDim(hm, dim, &length); + if(length != 2) { + SCPrintf(pCon,eError,"ERROR: hm %s is not 2D", par[0]->value.v.text); + return 0; + } + + calculateCOC(GetHistogramPointer(hm,pCon), + dim[0], dim[1], &x, &y, &intensity, contour); + + SCPrintf(pCon,eValue,"BC = %.2f,%.2f", x,y); + return 1; +} +/*-------------------------------------------------------------------------*/ +static int StatCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode, + pHdb par[], int nPar) +{ + pHistMem hm = NULL; + long sum, max, min; + double average; + int dim[3], i, length; + HistInt *data = NULL; + + if(nPar < 1){ + SCWrite(pCon,"ERROR: need hm-name for statistics", + eError); + return 0; + } + + hm = FindCommandData(pServ->pSics, + par[0]->value.v.text, "HistMem"); + if(hm == NULL){ + SCPrintf(pCon,eError,"ERROR: hm %s not found", par[0]->value.v.text); + return 0; + } + + GetHistDim(hm, dim, &i); + if(i != 2) { + SCPrintf(pCon,eError,"ERROR: hm %s is not 2D", par[0]->value.v.text); + return 0; + } + data = GetHistogramPointer(hm,pCon); + max = -9999; + min = 99999.99; + length = dim[0]*dim[1]; + for(i = 0, sum = 0; i < length; i++){ + sum += data[i]; + if(data[i] > max){ + max = data[i]; + } + if(data[i] < min ){ + min = data[i]; + } + } + average = (double)sum/(double)length; + + SCPrintf(pCon,eValue,"Stat:sum,max,min,av = %d,%d,%d,%f", sum,max,min,average); + return 1; +} + +/*--------------------------------------------------------------------*/ +int SansBCFactory(SConnection *pCon, SicsInterp *pSics, void *pData, + int argc, char *argv[]) +{ + pSICSOBJ pNew = NULL; + pHdb cmd = NULL, node; + + pNew = SetupSICSOBJ(pCon,pSics,pData,argc,argv); + if(pNew == NULL){ + return 0; + } + + cmd = AddSICSHdbPar(pNew->objectNode, "cog", usSpy, + MakeSICSFunc(COGCmd)); + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","spy"); + node = MakeSICSHdbPar("hm",usSpy,MakeHdbText("banana")); + AddHipadabaChild(cmd,node,NULL); + node = MakeSICSHdbPar("contour",usSpy,MakeHdbFloat(100.)); + AddHipadabaChild(cmd,node,NULL); + node = MakeSICSHdbPar("level",usSpy,MakeHdbFloat(.1)); + AddHipadabaChild(cmd,node,NULL); + + cmd = AddSICSHdbPar(pNew->objectNode, "coc", usSpy, + MakeSICSFunc(COCCmd)); + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","spy"); + node = MakeSICSHdbPar("hm",usSpy,MakeHdbText("banana")); + AddHipadabaChild(cmd,node,NULL); + node = MakeSICSHdbPar("contour",usSpy,MakeHdbFloat(100.)); + AddHipadabaChild(cmd,node,NULL); + + cmd = AddSICSHdbPar(pNew->objectNode, "stat", usSpy, + MakeSICSFunc(StatCmd)); + SetHdbProperty(cmd,"type","command"); + SetHdbProperty(cmd,"priv","spy"); + node = MakeSICSHdbPar("hm",usSpy,MakeHdbText("banana")); + AddHipadabaChild(cmd,node,NULL); + + return 1; +} +/*-------------------------------------------------------------------*/ diff --git a/sansbc.h b/sansbc.h new file mode 100644 index 00000000..cee0faf8 --- /dev/null +++ b/sansbc.h @@ -0,0 +1,16 @@ +/** + * This is a little routine to calculate the beam center from SANS data + * in the detector. This is basically a COG or COC (center of contour) + * calculation above a given threshold. Where we make an effor to + * find the threshold ourselves. + * + * copyright: GPL + * + * Mark Koennecke, July 2009 + */ +#ifndef SANSBC_H_ +#define SANSBC_H_ +int SansBCFactory(SConnection *pCon, SicsInterp *pSics, void *pData, + int argc, char *argv[]); + +#endif /*SANSBC_H_*/ diff --git a/sicshdbadapter.c b/sicshdbadapter.c index c7207343..7d3aec26 100644 --- a/sicshdbadapter.c +++ b/sicshdbadapter.c @@ -688,7 +688,7 @@ int SICSHdbAdapter(SConnection * pCon, SicsInterp * pSics, void *pData, pMot = (pMotor) FindCommandData(pSics, argv[2], "Motor"); if (pMot != NULL) { if(pMot->ParArray == NULL){ - SCWrite(pCon,"ERROR: secong generation motors need to be linked rather then adapted", + SCWrite(pCon,"ERROR: second generation motors need to be linked rather then adapted", eError); return 0; } diff --git a/sicshdbfactory.c b/sicshdbfactory.c index 26708c9a..c2f8d411 100644 --- a/sicshdbfactory.c +++ b/sicshdbfactory.c @@ -163,7 +163,7 @@ static int MakeLinkNode(pHdb parent, char *name, SConnection * pCon, char buffer[256]; if (argc < 4) { - SCWrite(pCon, "ERROR: not enough arguments to create script node", + SCWrite(pCon, "ERROR: not enough arguments to create link node", eError); return 0; } diff --git a/sicshipadaba.c b/sicshipadaba.c index c7c9598f..efa3eec0 100644 --- a/sicshipadaba.c +++ b/sicshipadaba.c @@ -3012,7 +3012,76 @@ static int LinkHdbNode(SConnection * pCon, SicsInterp * pSics, void *pData, SCSendOK(pCon); return 1; } +/*-------------------------------------------------------------------------*/ +static int isArrayNode(pHdb node) +{ + switch(node->value.dataType) { + case HIPINTAR: + case HIPFLOATAR: + case HIPINTVARAR: + case HIPFLOATVARAR: + return 1; + default: + return 0; + } + return 0; +} +/*-------------------------------------------------------------------------*/ +static int HdbArrayNode(SConnection * pCon, SicsInterp * pSics, void *pData, + int argc, char *argv[]) +{ + pHdb node = NULL; + pObjectDescriptor pDes = NULL; + int length, idx; + hdbValue v; + + if (argc < 4) { + SCWrite(pCon, "ERROR: need at least three arguments to harray", eError); + return 0; + } + if (!SCMatchRights(pCon, usUser)) { + return 0; + } + node = GetHipadabaNode(root, argv[1]); + if (node == NULL) { + SCPrintf(pCon, eError, "ERROR: path %s NOT found!", argv[1]); + return 0; + } + if(!isArrayNode(node)){ + SCPrintf(pCon,eError,"ERROR: %s is no array node!", argv[1]); + return 0; + } + + if(strcmp(argv[2], "resize") == 0){ + length = atoi(argv[3]); + v = makeHdbValue(node->value.dataType, length); + UpdateHipadabaPar(node, v, pCon); + ReleaseHdbValue(&v); + SCSendOK(pCon); + return 1; + } + + idx = atoi(argv[2]); + if(idx < 0 || idx >= node->value.arrayLength ){ + SCPrintf(pCon,eError,"ERROR: %d is out of range 0 - %d", + idx, node->value.arrayLength); + return 0; + } + switch(node->value.dataType){ + case HIPINTAR: + case HIPINTVARAR: + node->value.v.intArray[idx] = atoi(argv[3]); + break; + case HIPFLOATAR: + case HIPFLOATVARAR: + node->value.v.floatArray[idx] = atof(argv[3]); + break; + } + NotifyHipadabaPar(node, pCon); + SCSendOK(pCon); + return 1; +} /*-------------------------------------------------------------------------*/ static hdbCallbackReturn ChainCallback(pHdb node, void *userData, pHdbMessage message) @@ -3480,6 +3549,7 @@ int InstallSICSHipadaba(SConnection * pCon, SicsInterp * pSics, AddCommand(pSics, "hinfo", HdbNodeInfo, NULL, NULL); AddCommand(pSics, "hval", HdbNodeVal, NULL, NULL); AddCommand(pSics, "hchain", ChainHdbNode, NULL, NULL); + AddCommand(pSics, "harray", HdbArrayNode, NULL, NULL); AddCommand(pSics, "hcommand", SicsCommandNode, NULL, NULL); AddCommand(pSics, "hsetprop", SetSICSHdbProperty, NULL, NULL); AddCommand(pSics, "hdelprop", DelSICSHdbProperty, NULL, NULL); diff --git a/simindex.c b/simindex.c index f4e1648f..a9ad9518 100644 --- a/simindex.c +++ b/simindex.c @@ -115,8 +115,9 @@ static int RunIndexCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode, double ang[4], z1[3]; IndexSolution is; MATRIX ub; + pHdb nSol = NULL; - SimIdxSetLambda(SXGetLambda()); + SimIdxSetLambda(SXGetLambda()); SimIdxSetCell((double *) SXGetCell()); SimIdxSetSpacegroup(SXGetSpaceGroup()); SimIdxOutput(pCon, SicsOutFunc, 10); @@ -130,14 +131,19 @@ static int RunIndexCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode, SimIdxAddReflection(z1); } + nSol = GetHipadabaNode(self->objectNode,"nsolutions"); + assert(nSol != NULL); + status = SimIdxRun(); filterSolutions(); if (status == 1) { if (SimIdxGetNSolutions() < 1) { SCWrite(pCon, "No solutions were found", eLog); + UpdateHipadabaPar(nSol,MakeHdbInt(0), pCon); return 0; } SCWrite(pCon, "Indexing Suggestions:", eLog); + UpdateHipadabaPar(nSol,MakeHdbInt(SimIdxGetNSolutions()), pCon); for (i = 0; i < SimIdxGetNSolutions(); i++) { is = SimIdxGetSolution(i); SCPrintf(pCon, eLog, "Solution No : %d, GOF = %6.3f", i, @@ -158,6 +164,7 @@ static int RunIndexCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode, } } } + return status; } /*-----------------------------------------------------------------------*/ @@ -302,6 +309,9 @@ void InitSimpleIndex(SConnection * pCon, SicsInterp * pSics) AppendHipadabaCallback(cmd, MakeHipadabaCallback(SetAngLim, NULL, NULL)); SetHdbProperty(cmd, "__save", "true"); + cmd = AddSICSHdbPar(pNew->objectNode, "nsolutions", usUser, + MakeHdbInt(0)); + cmd = AddSICSHdbPar(pNew->objectNode, "run", usUser, MakeSICSFunc(RunIndexCmd)); diff --git a/stdscan.c b/stdscan.c index 4c9f8d1d..0a2378b7 100644 --- a/stdscan.c +++ b/stdscan.c @@ -1098,6 +1098,8 @@ int StandardScanWrapper(SConnection * pCon, SicsInterp * pSics, if (strcmp(argv[1], "drive") == 0) { return ScanDrive(self, iPoint); + } else if (strcmp(argv[1], "fastdrive") == 0) { + return ScanFastDrive(self, iPoint); } else if (strcmp(argv[1], "count") == 0) { return ScanCount(self, iPoint); } else if (strcmp(argv[1], "collect") == 0) { diff --git a/tasdrive.h b/tasdrive.h index 8fcc8e22..c6c061ca 100644 --- a/tasdrive.h +++ b/tasdrive.h @@ -10,9 +10,8 @@ #define TASDRIV #include "tasub.h" -int InstallTasMotor(SicsInterp * pSics, ptasUB self, int tasVar, - char *name); -int InstallTasQMMotor(SicsInterp * pSics, ptasUB self); -int TasMot(SConnection * pCon, SicsInterp * pSics, void *pData, - int argc, char *argv[]); +int InstallTasMotor(SicsInterp *pSics, ptasUB self, int tasVar, char *name); +int InstallTasQMMotor(SicsInterp *pSics, ptasUB self); +int TasMot(SConnection *pCon,SicsInterp *pSics, void *pData, + int argc, char *argv[]); #endif diff --git a/tasub.c b/tasub.c index b515ee50..21b83df5 100644 --- a/tasub.c +++ b/tasub.c @@ -5,6 +5,10 @@ copyright: see file COPYRIGHT Mark Koennecke, April-May 2005 + + Reworked to support an updater script for Integration into Hipadaba + + Mark Koennecke, July 2009 ----------------------------------------------------------------------*/ #include #include "sics.h" @@ -26,6 +30,16 @@ #define ACV 10 #define ACH 11 /*----------------- data structure management code -------------------*/ +static void invokeUpdate(ptasUB self, SConnection *pCon, char *key) +{ + char buffer[1024]; + + if(self->updater != NULL){ + snprintf(buffer,1024,"%s %s", self->updater, key); + InterpExecute(pServ->pSics,pCon,buffer); + } +} +/*--------------------------------------------------------------------*/ static void saveCrystal(char *objName, char *name, pmaCrystal crystal, FILE * fd) { @@ -174,6 +188,9 @@ static void KillTasUB(void *pData) if (self->machine.planeNormal != NULL) { mat_free(self->machine.planeNormal); } + if(self->updater != NULL){ + free(self->updater); + } free(self); } @@ -1049,6 +1066,7 @@ static int addAuxReflection(ptasUB self, SConnection * pCon, } LLDnodeAppend(self->reflectionList, &r2); SCSendOK(pCon); + invokeUpdate(self,pCon,"ref"); return 1; } @@ -1229,6 +1247,7 @@ static int calcUB(ptasUB self, SConnection * pCon, SicsInterp * pSics, self->ubValid = 1; listUB(self, pCon); listDiagnostik(self, pCon); + invokeUpdate(self,pCon,"main"); SCparChange(pCon); return 1; } @@ -1278,6 +1297,7 @@ static int calcUBFromCell(ptasUB self, SConnection * pCon) self->machine.planeNormal[2][0] = 1.; self->ubValid = 1; SCparChange(pCon); + invokeUpdate(self,pCon,"main"); mat_free(U); mat_free(B); return 1; @@ -1570,6 +1590,7 @@ static int setUB(SConnection * pCon, SicsInterp * pSics, ptasUB self, self->ubValid = 1; SCSendOK(pCon); SCparChange(pCon); + invokeUpdate(self,pCon,"main"); return 1; } @@ -1643,6 +1664,22 @@ static int setNormal(SConnection * pCon, SicsInterp * pSics, ptasUB self, return 1; } +/*------------------------------------------------------------------*/ +static int getNormal(SConnection * pCon, SicsInterp * pSics, ptasUB self, + int argc, char *argv[]) +{ + double value; + char pBueffel[512]; + int status; + + snprintf(pBueffel, 511, "tasub.normal = %f %f %f", + self->machine.planeNormal[0][0], self->machine.planeNormal[1][0], + self->machine.planeNormal[2][0]); + SCWrite(pCon, pBueffel, eValue); + + return 1; +} + /*------------------------------------------------------------------*/ static int setTarget(SConnection * pCon, SicsInterp * pSics, ptasUB self, int argc, char *argv[]) @@ -1765,6 +1802,51 @@ static int deleteReflection(SConnection * pCon, SicsInterp * pSics, count++; } SCSendOK(pCon); + invokeUpdate(self,pCon,"ref"); + return 1; +} + +/*------------------------------------------------------------------*/ +static int replaceReflection(SConnection * pCon, SicsInterp * pSics, + ptasUB self, int argc, char *argv[]) +{ + int idx, count = 0, status; + char pBueffel[256]; + tasReflection r; + + if (argc < 12) { + SCWrite(pCon, "ERROR: need id and new values to replace", eError); + return 0; + } + status = Tcl_GetInt(InterpGetTcl(pSics), argv[2], &idx); + if (status != TCL_OK) { + snprintf(pBueffel, 255, "ERROR: failed to convert %s to number", + argv[2]); + SCWrite(pCon, pBueffel, eError); + return 0; + } + idx--; + status = LLDnodePtr2First(self->reflectionList); + while (status == 1) { + if (count == idx) { + LLDnodeDataTo(self->reflectionList,&r); + r.qe.qh = atof(argv[3]); + r.qe.qk = atof(argv[4]); + r.qe.ql = atof(argv[5]); + r.angles.a3 = atof(argv[6]); + r.angles.sample_two_theta = atof(argv[7]); + r.angles.sgu = atof(argv[8]); + r.angles.sgl = atof(argv[9]); + r.qe.ki = energyToK(atof(argv[10])); + r.qe.kf = energyToK(atof(argv[11])); + LLDnodeDataFrom(self->reflectionList,&r); + break; + } + status = LLDnodePtr2Next(self->reflectionList); + count++; + } + SCSendOK(pCon); + invokeUpdate(self,pCon,"ref"); return 1; } @@ -1789,16 +1871,24 @@ int TasUBWrapper(SConnection * pCon, SicsInterp * pSics, void *pData, status = handleCrystalCommands(&self->machine.monochromator, pCon, argc, argv); + if(argc > 3){ + invokeUpdate(self,pCon,"mono"); + } self->mustRecalculate = 1; return status; } else if (strcmp(argv[1], "ana") == 0) { status = handleCrystalCommands(&self->machine.analyzer, pCon, argc, argv); self->mustRecalculate = 1; + if(argc > 3){ + invokeUpdate(self,pCon,"ana"); + } return status; } else if (strcmp(argv[1], "cell") == 0) { if (argc > 2) { - return tasReadCell(pCon, self, argc, argv); + status = tasReadCell(pCon, self, argc, argv); + invokeUpdate(self,pCon,"main"); + return status; } else { tasListCell(pCon, argv[0], self->cell); return 1; @@ -1807,13 +1897,19 @@ int TasUBWrapper(SConnection * pCon, SicsInterp * pSics, void *pData, clearReflections(self); clearReflections(self); SCWrite(pCon, "WARNING: UB is now invalid", eWarning); + invokeUpdate(self,pCon,"ref"); SCSendOK(pCon); return 1; } else if (strcmp(argv[1], "listref") == 0) { listReflections(self, pCon); return 1; } else if (strcmp(argv[1], "addref") == 0) { - return addReflection(self, pSics, pCon, argc, argv); + status = addReflection(self, pSics, pCon, argc, argv); + invokeUpdate(self, pCon,"ref"); + return status; + } else if (strcmp(argv[1], "repref") == 0) { + status = replaceReflection(pCon, pSics, self, argc, argv); + return status; } else if (strcmp(argv[1], "listub") == 0) { listUB(self, pCon); return 1; @@ -1835,6 +1931,8 @@ int TasUBWrapper(SConnection * pCon, SicsInterp * pSics, void *pData, return getUB(pCon, pSics, self, argc, argv); } else if (strcmp(argv[1], "setnormal") == 0) { return setNormal(pCon, pSics, self, argc, argv); + } else if (strcmp(argv[1], "getnormal") == 0) { + return getNormal(pCon, pSics, self, argc, argv); } else if (strcmp(argv[1], "settarget") == 0) { return setTarget(pCon, pSics, self, argc, argv); } else if (strcmp(argv[1], "update") == 0) { @@ -1867,6 +1965,7 @@ int TasUBWrapper(SConnection * pCon, SicsInterp * pSics, void *pData, eError); return 0; } + invokeUpdate(self,pCon,"main"); SCSendOK(pCon); return 1; } else { @@ -1900,6 +1999,7 @@ int TasUBWrapper(SConnection * pCon, SicsInterp * pSics, void *pData, } self->machine.ss_sample = newSS; tasUpdate(pCon, self); + invokeUpdate(self,pCon,"main"); SCSendOK(pCon); return 1; } else { @@ -1921,6 +2021,7 @@ int TasUBWrapper(SConnection * pCon, SicsInterp * pSics, void *pData, return 0; } self->outOfPlaneAllowed = newSS; + invokeUpdate(self,pCon,"main"); SCSendOK(pCon); return 1; } else { @@ -1949,7 +2050,20 @@ int TasUBWrapper(SConnection * pCon, SicsInterp * pSics, void *pData, SCWrite(pCon, pBueffel, eValue); return 1; } - } else { + } else if (strcmp(argv[1], "updater") == 0) { + if (argc > 2) { + if (!SCMatchRights(pCon, usMugger)) { + return 0; + } + self->updater = strdup(argv[2]); + SCSendOK(pCon); + return 1; + } else { + snprintf(pBueffel, 131, "%s.updater = %s", argv[0], self->updater); + SCWrite(pCon, pBueffel, eValue); + return 1; + } + } else { snprintf(pBueffel, 131, "ERROR: subcommand %s to %s not defined", argv[1], argv[0]); SCWrite(pCon, pBueffel, eError); diff --git a/tasub.h b/tasub.h index d94e7284..cfd0da20 100644 --- a/tasub.h +++ b/tasub.h @@ -15,40 +15,41 @@ #include "motor.h" /*------------------- defines for tasMode -----------------------------------*/ -typedef struct { - pObjectDescriptor pDes; - tasMachine machine; - int reflectionList; - lattice cell; - tasQEPosition target; - tasQEPosition current; - int tasMode; - int outOfPlaneAllowed; - double targetEn, actualEn; - int mustRecalculate; - int mustDrive; - pMotor motors[12]; - tasReflection r1, r2; - int ubValid; - int silent; -} tasUB, *ptasUB; + typedef struct{ + pObjectDescriptor pDes; + tasMachine machine; + int reflectionList; + lattice cell; + tasQEPosition target; + tasQEPosition current; + int tasMode; + int outOfPlaneAllowed; + double targetEn, actualEn; + int mustRecalculate; + int mustDrive; + pMotor motors[12]; + tasReflection r1, r2; + int ubValid; + int silent; + char *updater; +}tasUB, *ptasUB; /*--------------------- the tas virtual motor data structure ---------------------*/ typedef struct { - pObjectDescriptor pDes; - pIDrivable pDriv; - ptasUB math; - int code; -} tasMot, *ptasMot; + pObjectDescriptor pDes; + pIDrivable pDriv; + ptasUB math; + int code; + }tasMot, *ptasMot; /*--------------------------------------------------------------------*/ -int TasUBFactory(SConnection * pCon, SicsInterp * pSics, void *pData, - int argc, char *argv[]); -int TasUBWrapper(SConnection * pCon, SicsInterp * pSics, void *pData, - int argc, char *argv[]); +int TasUBFactory(SConnection *pCon,SicsInterp *pSics, void *pData, + int argc, char *argv[]); +int TasUBWrapper(SConnection *pCon,SicsInterp *pSics, void *pData, + int argc, char *argv[]); int findReflection(int list, int idx, ptasReflection r); -#endif +#endif diff --git a/tasub.w b/tasub.w index a74ba7f1..bcedf49b 100644 --- a/tasub.w +++ b/tasub.w @@ -33,6 +33,7 @@ A data structure: tasReflection r1, r2; int ubValid; int silent; + char *updater; }tasUB, *ptasUB; @} \begin{description} @@ -59,6 +60,7 @@ A data structure: \item[ubValid] a flag denoting if the UB is valid. \item[silent] A flga which when 1 suppresses the printing of motor positions when driving. Usefule for scans. +\item[updates] The optiona name of a script to call when tasu had been updated. This is to support Hipadaba tree integration without changing this complicated module too much. \end{description} For the virtual motors, there must be a data structure, too: