- 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
This commit is contained in:
koennecke
2010-02-02 12:38:10 +00:00
parent 1dff223146
commit 09cc25ec5b
15 changed files with 282 additions and 212 deletions

View File

@ -52,6 +52,14 @@
Paul Hathaway, May 2004 Paul Hathaway, May 2004
Added FindAlias function, Mark Koennecke, January 2007 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 <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -244,6 +252,33 @@ int RemoveCommand(SicsInterp * pInterp, char *pName)
extern char *stptok(char *s, char *tok, unsigned int toklen, char *brk); extern char *stptok(char *s, char *tok, unsigned int toklen, char *brk);
extern char *SkipSpace(char *pPtr); 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 InterpExecute(SicsInterp * self, SConnection * pCon, char *pText)
{ {
int iCount = 0; int iCount = 0;
@ -271,6 +306,9 @@ int InterpExecute(SicsInterp * self, SConnection * pCon, char *pText)
SICSLogWrite(pBueffel, eCommand); SICSLogWrite(pBueffel, eCommand);
} }
if(strstr(pText,tclescape) == pText){
return TclExecFunc(pCon,self,NULL,pText);
}
/* convert to argc, argv */ /* convert to argc, argv */
argc = 0; argc = 0;

View File

@ -23,6 +23,9 @@ typedef struct __SINTER *pSicsInterp;
typedef int (*ObjectFunc) (pSConnection pCon, pSicsInterp pInter, void typedef int (*ObjectFunc) (pSConnection pCon, pSicsInterp pInter, void
*pData, int argc, char *argv[]); *pData, int argc, char *argv[]);
typedef int (*ObjectFuncSelfParse) (pSConnection pCon, pSicsInterp pInter, void
*pData, char *command);
typedef void (*KillFunc) (void *pData); typedef void (*KillFunc) (void *pData);
typedef struct __Clist { typedef struct __Clist {

View File

@ -65,8 +65,6 @@ struct Ascon {
char *hostport; /**< host:port to connect */ char *hostport; /**< host:port to connect */
pDynString errmsg; /**< error message */ pDynString errmsg; /**< error message */
double start; /**< unix time when read was started */ 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 noResponse; /**< no response expected */
int responseValid; /**< a valid response is ready */ int responseValid; /**< a valid response is ready */
AsconHandler handler; /**< handler function */ AsconHandler handler; /**< handler function */
@ -75,6 +73,8 @@ struct Ascon {
char lastChar; /**< last char read */ char lastChar; /**< last char read */
char *separator; /**< (std) separator for multiline responses */ char *separator; /**< (std) separator for multiline responses */
int lineCount; /**< number of lines expected (counting down) */ 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 #define ASCON_SELECT_ERROR -1

View File

@ -1041,7 +1041,7 @@ int SCWriteZipped(SConnection * self, char *pName, void *pData,
*/ */
if (self->iTelnet) { if (self->iTelnet) {
SCWrite(self, SCWrite(self,
"ERROR: the telnet protocoll will currupt compressed data!", "ERROR: the telnet protocoll will corrupt compressed data!",
eError); eError);
return 0; return 0;
} }
@ -1150,6 +1150,8 @@ int SCWriteZipped(SConnection * self, char *pName, void *pData,
SCWrite(self, outBuf, eError); SCWrite(self, outBuf, eError);
return 0; return 0;
} }
/* printf("Sent zipped data: %s with %d\n", pHeader, iRet); */
deflateEnd(&compStream); deflateEnd(&compStream);
free(pHeader); free(pHeader);
free(pBuf); free(pBuf);

View File

@ -293,10 +293,10 @@ int DevSchedule(DevSer * devser, void *actionData,
&& matchFunc(actionData, action->data)) { && matchFunc(actionData, action->data)) {
if (prio == action->prio && interval < 0) { if (prio == action->prio && interval < 0) {
/* do not move an action with equal prio */ /* do not move an action with equal prio */
if (killFunc) { if(killFunc != NULL && actionData != NULL){
killFunc(actionData); killFunc(actionData);
} }
return 0; /* not queued */ return 0;
} }
/* remove action from list */ /* remove action from list */
*ptr2prev = action->next; *ptr2prev = action->next;

View File

@ -108,6 +108,12 @@ experiment.
<dd>Put a hipadaba path. The alias to put the data too is found in one of two places: as the nxalias <dd>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 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. the data. Please note that hipadaba stores all floats as double which is NX_FLOAT64 as number type.
<dt>nxscript puthdboff path offset ?alias</dt>
<dd>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.
<dt>nxscript puthdbslab path start size <dt>nxscript puthdbslab path start size
<dd>Put a hipdaba node as a slab. The node must have a property nxalias to determine where to write to. <dd>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 Start and size are Tcl lists which give the start point where to write and the size of the data

View File

@ -701,8 +701,10 @@ long GetHistMonitor(pHistMem self, int i, SConnection * pCon)
void HistDirty(pHistMem self) void HistDirty(pHistMem self)
{ {
assert(self); assert(self);
if(self->pDriv != NULL){
updateHMData(self->pDriv->data); updateHMData(self->pDriv->data);
} }
}
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
const float *GetHistTimeBin(pHistMem self, int *iLength) const float *GetHistTimeBin(pHistMem self, int *iLength)

View File

@ -136,10 +136,15 @@ static int SicsUnknownProc(ClientData pData, Tcl_Interp * pInter,
/* get the datastructures */ /* get the datastructures */
pSics = (struct __SicsUnknown *) pData; pSics = (struct __SicsUnknown *) pData;
assert(pSics); 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; pSinter = pSics->pInter;
pCon = pSics->pCon[pSics->iStack]; pCon = pSics->pCon[pSics->iStack];
lastCommand = pSics->lastUnknown[pSics->iStack]; lastCommand = pSics->lastUnknown[pSics->iStack];
pCon->sicsError = 0;
assert(pSinter); assert(pSinter);
assert(pCon); assert(pCon);
@ -176,6 +181,7 @@ static int SicsUnknownProc(ClientData pData, Tcl_Interp * pInter,
pSics->lastUnknown[pSics->iStack] = strdup(comBuffer); pSics->lastUnknown[pSics->iStack] = strdup(comBuffer);
/* invoke */ /* invoke */
pCon->sicsError = 0;
iMacro = SCinMacro(pCon); iMacro = SCinMacro(pCon);
SCsetMacro(pCon, 1); SCsetMacro(pCon, 1);
old = StatisticsBegin(pCommand->stat); old = StatisticsBegin(pCommand->stat);

View File

@ -513,7 +513,71 @@ static void putHdb(SConnection * pCon, SicsInterp * pSics, pNXScript self,
} }
ReleaseHdbValue(&v); 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, static void putHdbSlab(SConnection * pCon, SicsInterp * pSics,
pNXScript self, int argc, char *argv[]) pNXScript self, int argc, char *argv[])
@ -1283,6 +1347,10 @@ static int handlePut(SConnection * pCon, SicsInterp * pSics,
/* ================ */ /* ================ */
putHdb(pCon, pSics, self, argc, argv); putHdb(pCon, pSics, self, argc, argv);
return 1; return 1;
} else if (strcmp(argv[1], "puthdboff") == 0) {
/* ================ */
putHdbOff(pCon, pSics, self, argc, argv);
return 1;
} else if (strcmp(argv[1], "puthdbslab") == 0) { } else if (strcmp(argv[1], "puthdbslab") == 0) {
/* ================ */ /* ================ */
putHdbSlab(pCon, pSics, self, argc, argv); putHdbSlab(pCon, pSics, self, argc, argv);
@ -1313,7 +1381,7 @@ static int handlePut(SConnection * pCon, SicsInterp * pSics,
/*===============*/ /*===============*/
putSlab(pCon, pSics, self, argc, argv); putSlab(pCon, pSics, self, argc, argv);
} else { } else {
SCWrite(pCon, "ERROR: put command not recognised", eLogError); SCPrintf(pCon, eLogError, "ERROR: put command %s not recognised", argv[1] );
} }
return 1; return 1;
} }

6
ofac.c
View File

@ -15,7 +15,9 @@
#include "exeman.h" #include "exeman.h"
#include "statusfile.h" #include "statusfile.h"
#include "site.h" #include "site.h"
#include "sicshipadaba.h"
extern void DevExecInit(void); /* devexec.c */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
static void InitGeneral(void) static void InitGeneral(void)
{ {
@ -107,7 +109,6 @@ static void InitIniCommands(SicsInterp * pInter)
SCMD("allowexec", AllowExec); SCMD("allowexec", AllowExec);
SCMD("AntiCollisionInstall", AntiColliderFactory); SCMD("AntiCollisionInstall", AntiColliderFactory);
SCMD("ChopperAdapter", CHAdapterFactory); SCMD("ChopperAdapter", CHAdapterFactory);
SCMD("InstallHdb", InstallSICSHipadaba);
SCMD("InstallSinfox", InstallSinfox); SCMD("InstallSinfox", InstallSinfox);
SCMD("MakeAsyncProtocol", AsyncProtocolFactory); SCMD("MakeAsyncProtocol", AsyncProtocolFactory);
SCMD("MakeAsyncQueue", AsyncQueueFactory); SCMD("MakeAsyncQueue", AsyncQueueFactory);
@ -195,6 +196,7 @@ int InitObjectCommands(pServer pServ, char *file)
pExe = CreateExeList(pServ->pTasker); pExe = CreateExeList(pServ->pTasker);
pServ->pExecutor = pExe; pServ->pExecutor = pExe;
pEnv = CreateEnvMon(); pEnv = CreateEnvMon();
DevExecInit();
assert(pExe); assert(pExe);
assert(pEnv); assert(pEnv);
@ -209,7 +211,7 @@ int InitObjectCommands(pServer pServ, char *file)
} }
InstallBckRestore(pCon, pSics); InstallBckRestore(pCon, pSics);
InstallSICSHipadaba(pCon, pSics,NULL,0,NULL);
/* evaluate the file */ /* evaluate the file */
snprintf(pBueffel,sizeof(pBueffel)-1, "fileeval %s", file); snprintf(pBueffel,sizeof(pBueffel)-1, "fileeval %s", file);

View File

@ -2255,71 +2255,6 @@ static int MakeHdbNode(SConnection * pCon, SicsInterp * pSics, void *pData,
return 1; 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) static int isNodeProtected(pHdb node)
{ {
@ -2970,62 +2905,6 @@ static int RemoveHdbCallback(SConnection * pCon, SicsInterp * pSics,
return 1; 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) static int isArrayNode(pHdb node)
{ {
@ -3046,7 +2925,8 @@ static int HdbArrayNode(SConnection * pCon, SicsInterp * pSics, void *pData,
{ {
pHdb node = NULL; pHdb node = NULL;
pObjectDescriptor pDes = NULL; pObjectDescriptor pDes = NULL;
int length, idx; int length, idx, ival, i;
double dval;
hdbValue v; hdbValue v;
if (argc < 4) { if (argc < 4) {
@ -3057,7 +2937,7 @@ static int HdbArrayNode(SConnection * pCon, SicsInterp * pSics, void *pData,
return 0; return 0;
} }
node = GetHipadabaNode(root, argv[1]); node = FindHdbNode(NULL, argv[1], pCon);
if (node == NULL) { if (node == NULL) {
SCPrintf(pCon, eError, "ERROR: path %s NOT found!", argv[1]); SCPrintf(pCon, eError, "ERROR: path %s NOT found!", argv[1]);
return 0; return 0;
@ -3076,6 +2956,30 @@ static int HdbArrayNode(SConnection * pCon, SicsInterp * pSics, void *pData,
return 1; 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]); idx = atoi(argv[2]);
if(idx < 0 || idx >= node->value.arrayLength ){ if(idx < 0 || idx >= node->value.arrayLength ){
SCPrintf(pCon,eError,"ERROR: %d is out of range 0 - %d", SCPrintf(pCon,eError,"ERROR: %d is out of range 0 - %d",
@ -3285,55 +3189,6 @@ static hdbCallbackReturn CommandGetCallback(pHdb node, void *userData,
return hdbContinue; 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 ================================*/ /*======================= Property Functions ================================*/
static int SetSICSHdbProperty(SConnection * pCon, SicsInterp * pSics, static int SetSICSHdbProperty(SConnection * pCon, SicsInterp * pSics,
void *pData, int argc, char *argv[]) void *pData, int argc, char *argv[])
@ -3545,9 +3400,7 @@ int InstallSICSHipadaba(SConnection * pCon, SicsInterp * pSics,
{ {
root = MakeHipadabaNode("/", HIPNONE, 0); root = MakeHipadabaNode("/", HIPNONE, 0);
AddCommand(pSics, "hmake", MakeHdbNode, NULL, NULL);
AddCommand(pSics, "hfactory", HdbNodeFactory, NULL, NULL); AddCommand(pSics, "hfactory", HdbNodeFactory, NULL, NULL);
AddCommand(pSics, "hmakescript", MakeHdbScriptNode, NULL, NULL);
AddCommand(pSics, "hattach", SICSHdbAdapter, NULL, NULL); AddCommand(pSics, "hattach", SICSHdbAdapter, NULL, NULL);
AddCommand(pSics, "hsubsamplehm", HdbSubSample, NULL, NULL); AddCommand(pSics, "hsubsamplehm", HdbSubSample, NULL, NULL);
AddCommand(pSics, "hdel", DeleteHdbNode, 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, "hlist", ListHdbNode, NULL, NULL);
AddCommand(pSics, "hnotify", AutoNotifyHdbNode, NULL, NULL); AddCommand(pSics, "hnotify", AutoNotifyHdbNode, NULL, NULL);
AddCommand(pSics, "hdelcb", RemoveHdbCallback, NULL, NULL); AddCommand(pSics, "hdelcb", RemoveHdbCallback, NULL, NULL);
AddCommand(pSics, "hlink", LinkHdbNode, NULL, NULL);
AddCommand(pSics, "hinfo", HdbNodeInfo, NULL, NULL); AddCommand(pSics, "hinfo", HdbNodeInfo, NULL, NULL);
AddCommand(pSics, "hval", HdbNodeVal, NULL, NULL); AddCommand(pSics, "hval", HdbNodeVal, NULL, NULL);
AddCommand(pSics, "hchain", ChainHdbNode, NULL, NULL); AddCommand(pSics, "hchain", ChainHdbNode, NULL, NULL);
AddCommand(pSics, "harray", HdbArrayNode, NULL, NULL); AddCommand(pSics, "harray", HdbArrayNode, NULL, NULL);
AddCommand(pSics, "hcommand", SicsCommandNode, NULL, NULL);
AddCommand(pSics, "hsetprop", SetSICSHdbProperty, NULL, NULL); AddCommand(pSics, "hsetprop", SetSICSHdbProperty, NULL, NULL);
AddCommand(pSics, "hdelprop", DelSICSHdbProperty, NULL, NULL); AddCommand(pSics, "hdelprop", DelSICSHdbProperty, NULL, NULL);
AddCommand(pSics, "hgetprop", GetSICSHdbProperty, NULL, NULL); AddCommand(pSics, "hgetprop", GetSICSHdbProperty, NULL, NULL);

View File

@ -15,7 +15,6 @@
#---------------------------------------------------------------------- #----------------------------------------------------------------------
if { [info exists hdbinit] == 0 } { if { [info exists hdbinit] == 0 } {
set hdbinit 1 set hdbinit 1
InstallHdb
MakeStateMon MakeStateMon
Publish getgumtreexml Spy Publish getgumtreexml Spy
if {[string first tmp $home] < 0} { if {[string first tmp $home] < 0} {
@ -36,10 +35,10 @@ if { [info exists hdbinit] == 0 } {
Publish cscan User Publish cscan User
Publish sscan User Publish sscan User
Publish scan Spy Publish scan Spy
# Publish hmake Mugger Publish hmake Mugger
# Publish hmakescript Mugger Publish hmakescript Mugger
# Publish hlink Mugger Publish hlink Mugger
# Publish hcommand Mugger Publish hcommand Mugger
Publish hdbstorenexus User Publish hdbstorenexus User
Publish scaninfo Spy Publish scaninfo Spy
} }

91
tcl/simhm.tcl Normal file
View File

@ -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
}

View File

@ -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 tasub update
#----- MultiMotor sa #----- MultiMotor sa
sa recovernampos noeff a3 24 a4 48 sa recovernampos noeff a3 24 a4 48
ref anglesheader stt,om,chi,phi
ref clear ref clear
singlex cell 0 0 0 0 0 0 singlex cell 0 0 0 0 0 0
singlex oldub 0 0 0 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 difftheta 0.300000
ubcalc maxindex 5 ubcalc maxindex 5
ubcalc maxlist 10 ubcalc maxlist 10
fmesstable clear
messref anglesheader stt,om,chi,phi
messref clear messref clear
fmess weak 0 fmess weak 0
fmess weakthreshold 20 fmess weakthreshold 20
fmess fast 0
fmess hkllim -10 -10 10 10 10 10 fmess hkllim -10 -10 10 10 10 10
fmess sttlim 5 180 fmess sttlim 5 180
fmess table clear fmess table clear
@ -244,16 +248,5 @@ cone qscale 1
cone center unknown cone center unknown
simidx sttlim 0.2 simidx sttlim 0.2
simidx anglim 0.5 simidx anglim 0.5
alge targetposition -170 simi preset 3
alge sign 1 simi mode monitor
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

View File

@ -632,6 +632,14 @@ if {$hmhttp == 1} {
apple init 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 set phytron 0
if {$phytron == 1} { if {$phytron == 1} {
@ -673,8 +681,9 @@ mf lowerlimit -10
mf tolerance .1 mf tolerance .1
} }
set dc-804 1 set dc-804 0
if {${dc-804} == 1} {
source ../tcl/pimotor.tcl source ../tcl/pimotor.tcl
makesctcontroller dc804sct std localhost:8080 "\r" 10 "\x03" "\x03" makesctcontroller dc804sct std localhost:8080 "\r" 10 "\x03" "\x03"
pimotor::makepimotor dc1 1 dc804sct -10000 10000 pimotor::makepimotor dc1 1 dc804sct -10000 10000
}