- Added reflection generation for symmetriqally missing reflections
to fourmess - Fixed hdbtable, reflist and tasub up to work with GTSE - Made TRICS do fast scans again - Added support for SANS beam center calculations - Fixed a bug where SICS apparently did double counting but in fact just omitted an error message and did not - Added the harray command
This commit is contained in:
120
tasub.c
120
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 <assert.h>
|
||||
#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);
|
||||
|
Reference in New Issue
Block a user