Cleaned up ANSTO code to merge with sinqdev.sics
This is our new RELEASE-4_0 branch which was taken from ansto/93d9a7c Conflicts: .gitignore SICSmain.c asynnet.c confvirtualmot.c counter.c devexec.c drive.c event.h exebuf.c exeman.c histmem.c interface.h motor.c motorlist.c motorsec.c multicounter.c napi.c napi.h napi4.c network.c nwatch.c nxscript.c nxxml.c nxxml.h ofac.c reflist.c scan.c sicshipadaba.c sicsobj.c site_ansto/docs/Copyright.txt site_ansto/instrument/lyrebird/config/tasmad/sicscommon/nxsupport.tcl site_ansto/instrument/lyrebird/config/tasmad/taspub_sics/tasscript.tcl statusfile.c tasdrive.c tasub.c tasub.h tasublib.c tasublib.h
This commit is contained in:
71
reflist.c
71
reflist.c
@@ -24,6 +24,12 @@
|
||||
static char undef[] = "Undefined";
|
||||
#define IDXFMT " %8.4f"
|
||||
#define ANGFMT " %8.2f"
|
||||
|
||||
#define ABS(x) (x < 0 ? -(x) : (x))
|
||||
|
||||
int CountTblCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode,
|
||||
pHdb par[], int nPar); /* from hdbtable.c */
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
int idxCount;
|
||||
@@ -365,6 +371,32 @@ static int ShowCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
||||
return 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
const char *FindHKL(pSICSOBJ self, double h, double k, double l)
|
||||
{
|
||||
pHdb node, idx;
|
||||
|
||||
node = GetHipadabaNode(self->objectNode, "data");
|
||||
node = node->child;
|
||||
while(node != NULL){
|
||||
idx = node->child;
|
||||
if(ABS(idx->value.v.doubleValue-h) > .1){
|
||||
node = node->next;
|
||||
continue;
|
||||
}
|
||||
idx = idx->next;
|
||||
if(ABS(idx->value.v.doubleValue-k) > .1){
|
||||
node = node->next;
|
||||
continue;
|
||||
}
|
||||
idx = idx->next;
|
||||
if(ABS(idx->value.v.doubleValue-l) < .1){
|
||||
return node->name;
|
||||
}
|
||||
node = node->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static int NamesCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
||||
pHdb par[], int nPar)
|
||||
{
|
||||
@@ -390,6 +422,28 @@ static int NamesCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int RelabelCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
||||
pHdb par[], int nPar)
|
||||
{
|
||||
char buffer[10];
|
||||
pHdb node = NULL;
|
||||
int count = 0;
|
||||
|
||||
node = GetHipadabaNode(self->objectNode, "data");
|
||||
node = node->child;
|
||||
while (node != NULL) {
|
||||
snprintf(buffer,sizeof(buffer),"%4.4d", count);
|
||||
if(node->name != NULL){
|
||||
free(node->name);
|
||||
node->name = strdup(buffer);
|
||||
}
|
||||
count++;
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int SetIndexCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode,
|
||||
pHdb par[], int nPar)
|
||||
{
|
||||
@@ -549,6 +603,15 @@ pSICSOBJ CreateReflectionList(SConnection * pCon, SicsInterp * pSics,
|
||||
SetHdbProperty(cmd,"priv","user");
|
||||
AddSICSHdbPar(cmd, "id", usUser, MakeHdbText(""));
|
||||
|
||||
|
||||
cmd = AddSICSHdbPar(pNew->objectNode, "count", usUser,
|
||||
MakeSICSFunc(CountTblCmd));
|
||||
|
||||
cmd = AddSICSHdbPar(pNew->objectNode, "relabel", usUser,
|
||||
MakeSICSFunc(RelabelCmd));
|
||||
|
||||
|
||||
|
||||
AddCommand(pSics, name, InterInvokeSICSOBJ, KillSICSOBJ, pNew);
|
||||
return pNew;
|
||||
}
|
||||
@@ -679,10 +742,10 @@ int GetRefIndexID(pSICSOBJ refl, char *id, double hkl[])
|
||||
snprintf(path, 132, "data/%s", id);
|
||||
node = GetHipadabaNode(refl->objectNode, path);
|
||||
if (node != NULL) {
|
||||
child = node->child;
|
||||
for(i = 0; i < 3; i++, child = child->next){
|
||||
hkl[i] = child->value.v.doubleValue;
|
||||
}
|
||||
child = node->child;
|
||||
for(i = 0; i < 3; i++, child = child->next){
|
||||
hkl[i] = child->value.v.doubleValue;
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user