From 09cc25ec5b14c263f8d961cf61c61fd41c120e55 Mon Sep 17 00:00:00 2001 From: koennecke Date: Tue, 2 Feb 2010 12:38:10 +0000 Subject: [PATCH] - Implemented tcl: prefix which allows to execute a command in Tcl directly - Fixed a stack overrun bug in macro.c - Fixed a killing bug in devser.c - Added node writing with offset to nxscript.c - Wrote a simulation driver for second generation HM's - Readded devexec commands to SICS - Readded Hipadaba initialisation to SICS - Fixed a bug in sinqhttprot.c which is triggered when a reconnect happens during a node based download of data. SKIPPED: psi/sinqhttpprot.c --- SCinter.c | 38 ++++++++ SCinter.h | 3 + ascon.i | 4 +- conman.c | 4 +- devser.c | 8 +- doc/manager/nxscript.htm | 8 +- histmem.c | 4 +- macro.c | 8 +- nxscript.c | 70 +++++++++++++- ofac.c | 6 +- sicshipadaba.c | 203 ++++++--------------------------------- tcl/hdbutil.tcl | 9 +- tcl/simhm.tcl | 91 ++++++++++++++++++ test/sicsstat.tcl | 19 ++-- test/testini.tcl | 19 +++- 15 files changed, 282 insertions(+), 212 deletions(-) create mode 100644 tcl/simhm.tcl diff --git a/SCinter.c b/SCinter.c index ad1d491b..469e6ba8 100644 --- a/SCinter.c +++ b/SCinter.c @@ -52,6 +52,14 @@ Paul Hathaway, May 2004 Added FindAlias function, Mark Koennecke, January 2007 + + A new type of object function has been introduced ObjectFuncSelfParse. This + type of object function parses its command itself. As of now only one is + implemented for issuing Tcl commands from the command line, which will + stay a hidden feature. If more things of this type come along, then this + has to be expanded to become a full infrastructure. + + Mark Koennecke, January 2010 ---------------------------------------------------------------------------*/ #include #include @@ -244,6 +252,33 @@ int RemoveCommand(SicsInterp * pInterp, char *pName) extern char *stptok(char *s, char *tok, unsigned int toklen, char *brk); extern char *SkipSpace(char *pPtr); /*-----------------------------------------------------------------------*/ +static char tclescape[] = "tcl:"; + +static int TclExecFunc(SConnection *pCon, SicsInterp *pInter, void *data, + char *command) +{ + int status; + char *realcommand; + + if(!SCMatchRights(pCon,usMugger)){ + return 0; + } + + realcommand = command + strlen(tclescape); + MacroPush(pCon); + status = Tcl_Eval(InterpGetTcl(pInter), realcommand); + MacroPop(); + if(status == TCL_OK){ + SCWrite(pCon,(char *)Tcl_GetStringResult(InterpGetTcl(pInter)), eValue ); + return 1; + } else { + SCWrite(pCon,(char *)Tcl_GetStringResult(InterpGetTcl(pInter)), eValue ); + return 0; + + } + return 0; +} +/*-----------------------------------------------------------------------*/ int InterpExecute(SicsInterp * self, SConnection * pCon, char *pText) { int iCount = 0; @@ -271,6 +306,9 @@ int InterpExecute(SicsInterp * self, SConnection * pCon, char *pText) SICSLogWrite(pBueffel, eCommand); } + if(strstr(pText,tclescape) == pText){ + return TclExecFunc(pCon,self,NULL,pText); + } /* convert to argc, argv */ argc = 0; diff --git a/SCinter.h b/SCinter.h index 02b790e0..fd126154 100644 --- a/SCinter.h +++ b/SCinter.h @@ -23,6 +23,9 @@ typedef struct __SINTER *pSicsInterp; typedef int (*ObjectFunc) (pSConnection pCon, pSicsInterp pInter, void *pData, int argc, char *argv[]); +typedef int (*ObjectFuncSelfParse) (pSConnection pCon, pSicsInterp pInter, void + *pData, char *command); + typedef void (*KillFunc) (void *pData); typedef struct __Clist { diff --git a/ascon.i b/ascon.i index 97ff1d54..df92d82c 100644 --- a/ascon.i +++ b/ascon.i @@ -65,8 +65,6 @@ struct Ascon { char *hostport; /**< host:port to connect */ pDynString errmsg; /**< error message */ double start; /**< unix time when read was started */ - void *private; /**< private data of protocol */ - void (*killPrivate)(void *); /**< kill function for private */ int noResponse; /**< no response expected */ int responseValid; /**< a valid response is ready */ AsconHandler handler; /**< handler function */ @@ -75,6 +73,8 @@ struct Ascon { char lastChar; /**< last char read */ char *separator; /**< (std) separator for multiline responses */ int lineCount; /**< number of lines expected (counting down) */ + void *private; /**< private data of protocol */ + void (*killPrivate)(void *); /**< kill function for private */ }; #define ASCON_SELECT_ERROR -1 diff --git a/conman.c b/conman.c index 2340c219..958f5a9e 100644 --- a/conman.c +++ b/conman.c @@ -1041,7 +1041,7 @@ int SCWriteZipped(SConnection * self, char *pName, void *pData, */ if (self->iTelnet) { SCWrite(self, - "ERROR: the telnet protocoll will currupt compressed data!", + "ERROR: the telnet protocoll will corrupt compressed data!", eError); return 0; } @@ -1150,6 +1150,8 @@ int SCWriteZipped(SConnection * self, char *pName, void *pData, SCWrite(self, outBuf, eError); return 0; } + /* printf("Sent zipped data: %s with %d\n", pHeader, iRet); */ + deflateEnd(&compStream); free(pHeader); free(pBuf); diff --git a/devser.c b/devser.c index fc5d33f2..115b2d45 100644 --- a/devser.c +++ b/devser.c @@ -293,10 +293,10 @@ int DevSchedule(DevSer * devser, void *actionData, && matchFunc(actionData, action->data)) { if (prio == action->prio && interval < 0) { /* do not move an action with equal prio */ - if (killFunc) { - killFunc(actionData); - } - return 0; /* not queued */ + if(killFunc != NULL && actionData != NULL){ + killFunc(actionData); + } + return 0; } /* remove action from list */ *ptr2prev = action->next; diff --git a/doc/manager/nxscript.htm b/doc/manager/nxscript.htm index d7752afa..fc8635f4 100644 --- a/doc/manager/nxscript.htm +++ b/doc/manager/nxscript.htm @@ -108,7 +108,13 @@ experiment.
Put a hipadaba path. The alias to put the data too is found in one of two places: as the nxalias property on the node or as given on the command line. The alias is expected to match the size and type of the data. Please note that hipadaba stores all floats as double which is NX_FLOAT64 as number type. -
nxscript puthdbslab path start size +
nxscript puthdboff path offset ?alias
+
Put a hipadaba path. The alias to put the data too is found in one of two places: as the nxalias + property on the node or as given on the command line. The alias is expected to match the size and type of + the data. Please note that hipadaba stores all floats as double which is NX_FLOAT64 as number type. Writing + data is started with the offset specified from the start of the data. This is useful to split a histogram + memory area into separate detectors or whatever. +
nxscript puthdbslab path start size
Put a hipdaba node as a slab. The node must have a property nxalias to determine where to write to. Start and size are Tcl lists which give the start point where to write and the size of the data to write. See nxscript putslab for more information. diff --git a/histmem.c b/histmem.c index 166b8e34..abaa1282 100644 --- a/histmem.c +++ b/histmem.c @@ -701,7 +701,9 @@ long GetHistMonitor(pHistMem self, int i, SConnection * pCon) void HistDirty(pHistMem self) { assert(self); - updateHMData(self->pDriv->data); + if(self->pDriv != NULL){ + updateHMData(self->pDriv->data); + } } /*-------------------------------------------------------------------------*/ diff --git a/macro.c b/macro.c index 81ed22ea..e525598a 100644 --- a/macro.c +++ b/macro.c @@ -136,10 +136,15 @@ static int SicsUnknownProc(ClientData pData, Tcl_Interp * pInter, /* get the datastructures */ pSics = (struct __SicsUnknown *) pData; assert(pSics); + + if(pSics->iStack >= MAXSTACK -1) { + Tcl_SetResult(pInter,"ERROR: cyclic call or to deep a nesting of SICSUnknown", + TCL_VOLATILE); + return 0; + } pSinter = pSics->pInter; pCon = pSics->pCon[pSics->iStack]; lastCommand = pSics->lastUnknown[pSics->iStack]; - pCon->sicsError = 0; assert(pSinter); assert(pCon); @@ -176,6 +181,7 @@ static int SicsUnknownProc(ClientData pData, Tcl_Interp * pInter, pSics->lastUnknown[pSics->iStack] = strdup(comBuffer); /* invoke */ + pCon->sicsError = 0; iMacro = SCinMacro(pCon); SCsetMacro(pCon, 1); old = StatisticsBegin(pCommand->stat); diff --git a/nxscript.c b/nxscript.c index 11db6e25..8b83cae8 100644 --- a/nxscript.c +++ b/nxscript.c @@ -513,7 +513,71 @@ static void putHdb(SConnection * pCon, SicsInterp * pSics, pNXScript self, } ReleaseHdbValue(&v); } +/*----------------------------------------------------------------------*/ +static void putHdbOff(SConnection * pCon, SicsInterp * pSics, pNXScript self, + int argc, char *argv[]) +{ + pHdb node = NULL; + char alias[512]; + hdbValue v; + float fVal, *floatAr = NULL; + int i, offset; + if (argc < 4) { + SCWrite(pCon, "ERROR: putHdbOff needs at least a node name and an offset", eLogError); + return; + } + node = FindHdbNode(NULL, argv[2], pCon); + if (node == NULL) { + SCPrintf(pCon, eLogError, "ERROR: node %s not found", argv[2]); + return; + } + memset(alias, 0, 512 * sizeof(char)); + if (!GetHdbProperty(node, "nxalias", alias, 512)) { + if (argc < 5) { + SCPrintf(pCon, eLogError, + "ERROR: neither nxalias property nor alias on command line found for %s", + argv[2]); + return; + } else { + strncpy(alias, argv[4], 512); + } + } + offset = atoi(argv[3]); + + GetHipadabaPar(node, &v, pCon); + if(offset < 0 || offset > v.arrayLength){ + SCPrintf(pCon,eLogError,"ERROR: invalid offset %d speicified", offset ); + return; + } + switch (v.dataType) { + case HIPNONE: + return; + break; + case HIPINTAR: + case HIPINTVARAR: + NXDputalias(self->fileHandle, self->dictHandle, alias, v.v.intArray+offset); + break; + case HIPFLOATAR: + case HIPFLOATVARAR: + floatAr = malloc(v.arrayLength * sizeof(float)); + if (floatAr == NULL) { + SCPrintf(pCon, eLogError, "ERROR: out of memory writing %s", + node->name); + return; + } + for (i = 0; i < v.arrayLength; i++) { + floatAr[i] = v.v.floatArray[i]; + } + NXDputalias(self->fileHandle, self->dictHandle, alias, floatAr+offset); + free(floatAr); + break; + default: + SCPrintf(pCon,eLogError,"ERROR: offsets can only be used with array data types"); + return; + } + ReleaseHdbValue(&v); +} /*----------------------------------------------------------------------*/ static void putHdbSlab(SConnection * pCon, SicsInterp * pSics, pNXScript self, int argc, char *argv[]) @@ -1283,6 +1347,10 @@ static int handlePut(SConnection * pCon, SicsInterp * pSics, /* ================ */ putHdb(pCon, pSics, self, argc, argv); return 1; + } else if (strcmp(argv[1], "puthdboff") == 0) { + /* ================ */ + putHdbOff(pCon, pSics, self, argc, argv); + return 1; } else if (strcmp(argv[1], "puthdbslab") == 0) { /* ================ */ putHdbSlab(pCon, pSics, self, argc, argv); @@ -1313,7 +1381,7 @@ static int handlePut(SConnection * pCon, SicsInterp * pSics, /*===============*/ putSlab(pCon, pSics, self, argc, argv); } else { - SCWrite(pCon, "ERROR: put command not recognised", eLogError); + SCPrintf(pCon, eLogError, "ERROR: put command %s not recognised", argv[1] ); } return 1; } diff --git a/ofac.c b/ofac.c index c7bacc98..edfc8b8f 100644 --- a/ofac.c +++ b/ofac.c @@ -15,7 +15,9 @@ #include "exeman.h" #include "statusfile.h" #include "site.h" +#include "sicshipadaba.h" +extern void DevExecInit(void); /* devexec.c */ /*--------------------------------------------------------------------------*/ static void InitGeneral(void) { @@ -107,7 +109,6 @@ static void InitIniCommands(SicsInterp * pInter) SCMD("allowexec", AllowExec); SCMD("AntiCollisionInstall", AntiColliderFactory); SCMD("ChopperAdapter", CHAdapterFactory); - SCMD("InstallHdb", InstallSICSHipadaba); SCMD("InstallSinfox", InstallSinfox); SCMD("MakeAsyncProtocol", AsyncProtocolFactory); SCMD("MakeAsyncQueue", AsyncQueueFactory); @@ -195,6 +196,7 @@ int InitObjectCommands(pServer pServ, char *file) pExe = CreateExeList(pServ->pTasker); pServ->pExecutor = pExe; pEnv = CreateEnvMon(); + DevExecInit(); assert(pExe); assert(pEnv); @@ -209,7 +211,7 @@ int InitObjectCommands(pServer pServ, char *file) } InstallBckRestore(pCon, pSics); - + InstallSICSHipadaba(pCon, pSics,NULL,0,NULL); /* evaluate the file */ snprintf(pBueffel,sizeof(pBueffel)-1, "fileeval %s", file); diff --git a/sicshipadaba.c b/sicshipadaba.c index fcdb9558..d6bc7c09 100644 --- a/sicshipadaba.c +++ b/sicshipadaba.c @@ -2255,71 +2255,6 @@ static int MakeHdbNode(SConnection * pCon, SicsInterp * pSics, void *pData, return 1; } -/*--------------------------------------------------------------------------*/ -static int MakeHdbScriptNode(SConnection * pCon, SicsInterp * pSics, - void *pData, int argc, char *argv[]) -{ - int type = 0, i, length = 0; - char *name = NULL; - pHdb parent = NULL; - pHdb child = NULL; - pHdb current = NULL; - char *urgv[] = { "5", NULL }; - char driver[] = { "hdb" }; - char buffer[512], buffer2[512]; - - - if (!SCMatchRights(pCon, usMugger)) { - return 0; - } - - if (argc < 5) { - SCWrite(pCon, "ERROR: not enough arguments to MakeHdbNode", eError); - return 0; - } - - /* - * convert datatype - */ - strtolower(argv[4]); - type = convertHdbType(argv[4]); - if (type >= 7) { - SCWrite(pCon, - "ERROR: invalid type requested: none, int, float, text, intar, floatar, intvarar, floatvarar supported", - eError); - return 0; - } - if (type > 2) { - if (argc < 6) { - SCWrite(pCon, "ERROR: array length missing for array data type", - eError); - return 0; - } else { - length = atoi(argv[5]); - } - } - - parent = FindHdbParent(NULL, argv[1], &name, pCon); - if (parent == NULL) { - return 0; /* error messages written inside FindHdbParent */ - } - child = MakeSICSScriptPar(name, argv[3], argv[2], - makeHdbValue(type, length)); - if (child == NULL) { - SCWrite(pCon, "ERROR: out of memory creating node", eError); - return 0; - } - - AddHipadabaChild(parent, child, pCon); - /* - * have it polled automatically - */ - addPollObject(poller, pCon, GetHipadabaPath(child), driver, 1, urgv); - - SCSendOK(pCon); - return 1; -} - /*------------------------------------------------------------------------------*/ static int isNodeProtected(pHdb node) { @@ -2970,62 +2905,6 @@ static int RemoveHdbCallback(SConnection * pCon, SicsInterp * pSics, return 1; } -/*---------------------------------------------------------------------------*/ -static int LinkHdbNode(SConnection * pCon, SicsInterp * pSics, void *pData, - int argc, char *argv[]) -{ - pHdb node = NULL; - char buffer[256]; - pObjectDescriptor pDes = NULL; - - if (argc < 3) { - SCWrite(pCon, "ERROR: need path and object name to link", eError); - return 0; - } - if (!SCMatchRights(pCon, usMugger)) { - return 0; - } - - node = GetHipadabaNode(root, argv[1]); - if (node == NULL) { - snprintf(buffer, 255, "ERROR: path %s NOT found!", argv[1]); - SCWrite(pCon, buffer, eError); - return 0; - } - - pDes = FindCommandDescriptor(pSics, argv[2]); - if (pDes == NULL) { - snprintf(buffer, 255, "ERROR: failed to find object %s", argv[2]); - SCWrite(pCon, buffer, eError); - return 0; - } - if (pDes->parNode == NULL) { - snprintf(buffer, 255, - "ERROR: Object %s does not use Hipadaba natively and thus cannot be linked", - argv[2]); - SCWrite(pCon, buffer, eError); - return 0; - } - - if (pDes->parNode->mama != NULL) { - snprintf(buffer, 255, - "ERROR: Object %s is already linked somewhere else", argv[2]); - SCWrite(pCon, buffer, eError); - return 0; - } - - AddHipadabaChild(node, pDes->parNode, pCon); - - if (argc > 3) { - if (pDes->parNode->name != NULL) { - free(pDes->parNode->name); - } - pDes->parNode->name = strdup(argv[3]); - } - - SCSendOK(pCon); - return 1; -} /*-------------------------------------------------------------------------*/ static int isArrayNode(pHdb node) { @@ -3046,7 +2925,8 @@ static int HdbArrayNode(SConnection * pCon, SicsInterp * pSics, void *pData, { pHdb node = NULL; pObjectDescriptor pDes = NULL; - int length, idx; + int length, idx, ival, i; + double dval; hdbValue v; if (argc < 4) { @@ -3057,7 +2937,7 @@ static int HdbArrayNode(SConnection * pCon, SicsInterp * pSics, void *pData, return 0; } - node = GetHipadabaNode(root, argv[1]); + node = FindHdbNode(NULL, argv[1], pCon); if (node == NULL) { SCPrintf(pCon, eError, "ERROR: path %s NOT found!", argv[1]); return 0; @@ -3076,6 +2956,30 @@ static int HdbArrayNode(SConnection * pCon, SicsInterp * pSics, void *pData, return 1; } + if(strcmp(argv[2], "init") == 0){ + v = makeHdbValue(node->value.dataType, length); + switch(node->value.dataType){ + case HIPINTAR: + case HIPINTVARAR: + ival = atoi(argv[3]); + for(i = 0; i < v.arrayLength; i++){ + v.v.intArray[i] = ival; + } + break; + case HIPFLOATAR: + case HIPFLOATVARAR: + dval = atof(argv[3]); + for(i = 0; i < v.arrayLength; i++){ + v.v.intArray[i] = dval; + } + break; + } + 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", @@ -3285,55 +3189,6 @@ static hdbCallbackReturn CommandGetCallback(pHdb node, void *userData, return hdbContinue; } -/*--------------------------------------------------------------------------*/ -static int SicsCommandNode(SConnection * pCon, SicsInterp * pSics, - void *pData, int argc, char *argv[]) -{ - char *name = NULL; - pHdbCallback kalle = NULL; - pHdb parent = NULL, node = NULL; - - if (argc < 3) { - SCWrite(pCon, "ERROR: insufficent number of arguments to hcommand", - eError); - } - if (!SCMatchRights(pCon, usMugger)) { - return 0; - } - - parent = FindHdbParent(NULL, argv[1], &name, pCon); - if (parent == NULL) { - return 0; /* error message already written */ - } - node = MakeHipadabaNode(name, HIPTEXT, 1); - if (node == NULL) { - SCWrite(pCon, "ERROR: out of memory in hcommand", eError); - return 0; - } - node->value.v.text = strdup(argv[2]); - node->value.arrayLength = strlen(argv[2]); - SetHdbProperty(node, "sicscommand", argv[2]); - - kalle = MakeHipadabaCallback(CommandSetCallback, NULL, NULL); - if (kalle == NULL) { - SCWrite(pCon, "ERROR: out of memory in hcommand", eError); - return 0; - } - AppendHipadabaCallback(node, kalle); - - kalle = MakeHipadabaCallback(CommandGetCallback, NULL, NULL); - if (kalle == NULL) { - SCWrite(pCon, "ERROR: out of memory in hcommand", eError); - return 0; - } - AppendHipadabaCallback(node, kalle); - - AddHipadabaChild(parent, node, pCon); - - SCSendOK(pCon); - return 1; -} - /*======================= Property Functions ================================*/ static int SetSICSHdbProperty(SConnection * pCon, SicsInterp * pSics, void *pData, int argc, char *argv[]) @@ -3545,9 +3400,7 @@ int InstallSICSHipadaba(SConnection * pCon, SicsInterp * pSics, { root = MakeHipadabaNode("/", HIPNONE, 0); - AddCommand(pSics, "hmake", MakeHdbNode, NULL, NULL); AddCommand(pSics, "hfactory", HdbNodeFactory, NULL, NULL); - AddCommand(pSics, "hmakescript", MakeHdbScriptNode, NULL, NULL); AddCommand(pSics, "hattach", SICSHdbAdapter, NULL, NULL); AddCommand(pSics, "hsubsamplehm", HdbSubSample, NULL, NULL); AddCommand(pSics, "hdel", DeleteHdbNode, NULL, NULL); @@ -3559,12 +3412,10 @@ int InstallSICSHipadaba(SConnection * pCon, SicsInterp * pSics, AddCommand(pSics, "hlist", ListHdbNode, NULL, NULL); AddCommand(pSics, "hnotify", AutoNotifyHdbNode, NULL, NULL); AddCommand(pSics, "hdelcb", RemoveHdbCallback, NULL, NULL); - AddCommand(pSics, "hlink", LinkHdbNode, NULL, NULL); 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); AddCommand(pSics, "hgetprop", GetSICSHdbProperty, NULL, NULL); diff --git a/tcl/hdbutil.tcl b/tcl/hdbutil.tcl index 82b83619..87efe06f 100644 --- a/tcl/hdbutil.tcl +++ b/tcl/hdbutil.tcl @@ -15,7 +15,6 @@ #---------------------------------------------------------------------- if { [info exists hdbinit] == 0 } { set hdbinit 1 - InstallHdb MakeStateMon Publish getgumtreexml Spy if {[string first tmp $home] < 0} { @@ -36,10 +35,10 @@ if { [info exists hdbinit] == 0 } { Publish cscan User Publish sscan User Publish scan Spy -# Publish hmake Mugger -# Publish hmakescript Mugger -# Publish hlink Mugger -# Publish hcommand Mugger + Publish hmake Mugger + Publish hmakescript Mugger + Publish hlink Mugger + Publish hcommand Mugger Publish hdbstorenexus User Publish scaninfo Spy } diff --git a/tcl/simhm.tcl b/tcl/simhm.tcl new file mode 100644 index 00000000..8785d093 --- /dev/null +++ b/tcl/simhm.tcl @@ -0,0 +1,91 @@ +#----------------------------------------------------- +# This is a simulation driver for the second +# generation histogram memory. It provides +# for a fill value which is used to initialize +# data. +# +# copyright: see file COPYRIGHT +# +# Mark Koennecke, January 2010 +#----------------------------------------------------- +namespace eval simhm {} +#----------------------------------------------------- +proc simhm::getcontrol {name} { + return -9999.99 +} +#---------------------------------------------------- +proc simhm::setcontrol {name val} { + switch $val { + 1000 { + hset /sics/${name}/internalstatus run + set pp [hval /sics/${name}/preset] + hset /sics/${name}/finishtime [expr $pp + [clock seconds]] + return idle + } + 1001 { + hset /sics/${name}/internalstatus error + return idle + } + 1002 { + hset /sics/${name}/internalstatus pause + return idle + } + 1003 { + hset /sics/${name}/internalstatus run + return idle + } + 1005 { + return idle + } + default { + clientput "ERROR: bad start target $target given to control" + return idle + } + } +} +#---------------------------------------------------- +proc simhm::getstatus {name} { + set status [string trim [hval /sics/${name}/internalstatus]] + if {[string first run $status] >= 0} { + set fin [string trim [hval /sics/${name}/finishtime]] + if {[clock seconds] > $fin} { + hset /sics/${name}/internalstatus idle + set val [string trim [hval /sics/${name}/initval]] + $name set $val + set second [string trim [hval /sics/${name}/secondbank]] + if {[string compare $second NULL] != 0} { + harray /sics/${name}/${second} init $val + } + } + } + return $status +} +#----------------------------------------------------- +proc simhm::MakeSimHM {name rank {tof NULL} } { + MakeSecHM $name $rank $tof + hfactory /sics/${name}/initval plain user int + hset /sics/${name}/initval 0 + + hfactory /sics/${name}/finishtime plain user int + hfactory /sics/${name}/internalstatus plain user text + hupdate /sics/${name}/internalstatus idle + + hdel /sics/${name}/control + hfactory /sics/${name}/control script \ + "simhm::getcontrol $name" "simhm::setcontrol $name" float + hsetprop /sics/${name}/control priv user + + hdel /sics/${name}/status + hfactory /sics/${name}/status script \ + "simhm::getstatus $name" hdbReadOnly text + hsetprop /sics/${name}/control priv user + hupdate /sics/${name}/status idle + + hfactory /sics/${name}/secondbank plain user text + hupdate /sics/${name}/secondbank NULL +} +#------------------------------------------------------ +proc simhm::makeSecond {name bankname length} { + hfactory /sics/${name}/${bankname} plain user intvarar $length + hupdate /sics/${name}/secondbank $bankname +} diff --git a/test/sicsstat.tcl b/test/sicsstat.tcl index a2b9c954..23e6ac8e 100644 --- a/test/sicsstat.tcl +++ b/test/sicsstat.tcl @@ -209,6 +209,7 @@ tasub r2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 tasub update #----- MultiMotor sa sa recovernampos noeff a3 24 a4 48 +ref anglesheader stt,om,chi,phi ref clear singlex cell 0 0 0 0 0 0 singlex oldub 0 0 0 0 0 0 0 0 0 @@ -233,9 +234,12 @@ hkl scantolerance 2.500000 ubcalc difftheta 0.300000 ubcalc maxindex 5 ubcalc maxlist 10 +fmesstable clear +messref anglesheader stt,om,chi,phi messref clear fmess weak 0 fmess weakthreshold 20 +fmess fast 0 fmess hkllim -10 -10 10 10 10 10 fmess sttlim 5 180 fmess table clear @@ -244,16 +248,5 @@ cone qscale 1 cone center unknown simidx sttlim 0.2 simidx anglim 0.5 -alge targetposition -170 -alge sign 1 -alge softzero 0 -alge softlowerlim -360 -alge softupperlim 0 -alge fixed -1 -alge interruptmode 0 -alge precision 0.01 -alge accesscode 2 -alge failafter 3 -alge maxretry 3 -alge ignorefault 0 -alge movecount 10 +simi preset 3 +simi mode monitor diff --git a/test/testini.tcl b/test/testini.tcl index 4678e151..09a3d3dc 100644 --- a/test/testini.tcl +++ b/test/testini.tcl @@ -632,6 +632,14 @@ if {$hmhttp == 1} { apple init } +set simhm 1 +#if {$simhm == 1} { + source ../tcl/simhm.tcl + simhm::MakeSimHM simi 2 +# simhm::makeSecond simi singledet 30 + simi dim 64 64 + simi init +#} set phytron 0 if {$phytron == 1} { @@ -673,8 +681,9 @@ mf lowerlimit -10 mf tolerance .1 } -set dc-804 1 - -source ../tcl/pimotor.tcl -makesctcontroller dc804sct std localhost:8080 "\r" 10 "\x03" "\x03" -pimotor::makepimotor dc1 1 dc804sct -10000 10000 \ No newline at end of file +set dc-804 0 +if {${dc-804} == 1} { + source ../tcl/pimotor.tcl + makesctcontroller dc804sct std localhost:8080 "\r" 10 "\x03" "\x03" + pimotor::makepimotor dc1 1 dc804sct -10000 10000 +} \ No newline at end of file