From 45ac6c526fd91e5f8cb86d0e4714654c47479d0f Mon Sep 17 00:00:00 2001 From: koennecke Date: Wed, 18 Jun 2008 14:08:25 +0000 Subject: [PATCH] - Many fixes to the new scriptcontext to make it work --- conman.c | 9 ++++++--- event.h | 12 +++++++----- event.tex | 2 ++ event.w | 2 ++ make_gen | 2 +- proxy.c | 4 ++++ scriptcontext.c | 11 +++++++++++ scriptcontext.h | 7 ++++++- sctdriveadapter.c | 27 +++++++++++++++++++++++++-- sicshipadaba.c | 9 ++++++++- sllinux_def | 1 + status.c | 1 + 12 files changed, 74 insertions(+), 13 deletions(-) diff --git a/conman.c b/conman.c index 98930057..ff748652 100644 --- a/conman.c +++ b/conman.c @@ -366,6 +366,7 @@ extern pServer pServ; } assert( (iMode == 0) || (iMode == 1)); self->iMacro = iMode; +/* SCPrintf(self,eError, "SCsetMacro = %lx, %d\n", (long int)self, iMode); */ return 1; } /*---------------------------------------------------------------------------*/ @@ -2272,7 +2273,7 @@ SConnection *SCStorePush(SCStore *conStore) { /* push macro flag on stack */ conStore->macroStack <<= 1; conStore->macroStack |= (pCon->iMacro != 0); - pCon->iMacro = conStore->inMacro; + SCsetMacro(pCon, conStore->inMacro); SCPushContext2(pCon, conStore->cc); return pCon; } @@ -2282,8 +2283,10 @@ void SCStorePop(SCStore *conStore) { pCon = SCLoad(conStore); SCPopContext(pCon); - /* pop macro flag from stack */ - pCon->iMacro = (conStore->macroStack | 1); + /* pop macro flag from stack + SCsetMacro(pCon,conStore->macroStack); + */ + SCsetMacro(pCon, (conStore->macroStack & 1)); conStore->macroStack >>= 1; } /*--------------------------------------------------------------------------*/ diff --git a/event.h b/event.h index 3daf4010..ee92c179 100644 --- a/event.h +++ b/event.h @@ -1,5 +1,5 @@ -#line 98 "event.w" +#line 100 "event.w" /*---------------------------------------------------------------------------- E V E N T @@ -18,7 +18,7 @@ int Text2Event(char *pText); -#line 111 "event.w" +#line 113 "event.w" @@ -45,13 +45,15 @@ #define STATUS 18 #define POSITION 19 #define HDBVAL 20 +#define STSTART 21 +#define STEND 22 -#line 113 "event.w" +#line 115 "event.w" /*--------------- Signals for the Signalfunction of each task ------------*/ -#line 80 "event.w" +#line 82 "event.w" #define SICSINT 300 #define SICSBROADCAST 301 @@ -60,6 +62,6 @@ #define COMLOG 304 #define CRONLIST 305 -#line 116 "event.w" +#line 118 "event.w" #endif diff --git a/event.tex b/event.tex index 0565bb89..c3856e01 100644 --- a/event.tex +++ b/event.tex @@ -56,6 +56,8 @@ $\langle$VE {\footnotesize ?}$\rangle\equiv$ \mbox{}\verb@#define STATUS 18@\\ \mbox{}\verb@#define POSITION 19@\\ \mbox{}\verb@#define HDBVAL 20@\\ +\mbox{}\verb@#define STSTART 21@\\ +\mbox{}\verb@#define STEND 22@\\ \mbox{}\verb@@$\Diamond$ \end{list} \vspace{-1ex} diff --git a/event.w b/event.w index 290f86fe..fc8e584d 100644 --- a/event.w +++ b/event.w @@ -39,6 +39,8 @@ if the event code is not known, else the apropriate event code. #define STATUS 18 #define POSITION 19 #define HDBVAL 20 +#define STSTART 21 +#define STEND 22 @} \begin{description} \item[VALUECHANGE] This is a variable changing its value. As event data a pointer to the diff --git a/make_gen b/make_gen index b34b8ad6..613c6f1e 100644 --- a/make_gen +++ b/make_gen @@ -60,7 +60,7 @@ full: purge all SICServer: $(SOBJ) $(MOTOROBJ) $(COUNTEROBJ) \ $(VELOOBJ) $(DIFIL) $(EXTRA) \ $(SUBLIBS) - $(CC) -g -o SICServer \ + $(CC) -g -o SICServer \ $(SOBJ) $(MOTOROBJ) $(COUNTEROBJ) \ $(VELOOBJ) $(DIFOBJ) $(EXTRA) $(LIBS) diff --git a/proxy.c b/proxy.c index e87a8dbd..a30a5dd8 100644 --- a/proxy.c +++ b/proxy.c @@ -290,6 +290,10 @@ static hdbCallbackReturn MapParCallback(pHdb node, void *userData, char command[1024]; pDynString data = NULL; + if(GetHdbKillNodeMessage(message) != NULL ){ + return hdbContinue; + } + GetHdbProperty(node->mama, "proxy", proxyDev,80); pCom = FindCommand(pServ->pSics, proxyDev); if(pCom == NULL){ diff --git a/scriptcontext.c b/scriptcontext.c index e8e67a4f..4f8524de 100644 --- a/scriptcontext.c +++ b/scriptcontext.c @@ -268,6 +268,7 @@ static char *SctActionHandler(void *actionData, char *lastReply) { char *send = NULL; int i; SConnection *con; + char timeKey[50], timeVal[50]; if (currentCon) { con = SCStorePush(currentCon); @@ -297,6 +298,12 @@ static char *SctActionHandler(void *actionData, char *lastReply) { if (currentCon && ! data->answered) { SCWrite(con, "o.k.", eValue); } + if(strcmp(data->name,"write") == 0){ + SetHdbProperty(data->node,"writestatus","commandsent"); + } + snprintf(timeKey,50,"%s_time",data->name); + snprintf(timeVal,50,"%.3f", DoubleTime()); + SetHdbProperty(data->node,timeKey,timeVal); goto finish; } SetProp(node, controller->node, "state", state); @@ -1022,3 +1029,7 @@ void SctInit(void) { AddCommand(pServ->pSics, "sct", SctCommand, SctKill, sct); AddCmd("makesctcontroller", SctMakeController); } + +int SctVerbose(SctController *c){ + return c->verbose; +} diff --git a/scriptcontext.h b/scriptcontext.h index 75ccca22..30c5bc87 100644 --- a/scriptcontext.h +++ b/scriptcontext.h @@ -29,5 +29,10 @@ void SctQueueNode(SctController *controller, Hdb *node, */ int SctCallInContext(SConnection *con, char *script, Hdb *node, SctController *controller, char **resPtr); - +/** + * test the controller verbose flag + * \param c The SctController to test + * \return 1 for verbose, 0 for silent + */ +int SctVerbose(SctController *c); #endif diff --git a/sctdriveadapter.c b/sctdriveadapter.c index f4333c61..6b65700e 100644 --- a/sctdriveadapter.c +++ b/sctdriveadapter.c @@ -78,6 +78,10 @@ static int SCTDRIVCheckLimits(void *data, float val, if(GetHdbProperty(self->node,"checklimits",script,1024)){ status = SctCallInContext(pServ->dummyCon, script, self->node, self->c, &result); + if(SctVerbose(self->c)){ + SCPrintf(pServ->dummyCon, eWarning, "script %s called with result %s\n ", + script, result); + } if(status == 0){ strncpy(error,result,errlen); return 0; @@ -102,6 +106,7 @@ static long SCTDRIVSetValue(void *data, SConnection *pCon, float val){ self = (pSctDrive)data; v.dataType = HIPFLOAT; v.v.doubleValue = (double)val; + SetHdbProperty(self->node,"writestatus", "start"); status = SetHipadabaPar(self->node, v, pCon); if(status == 1){ return OKOK; @@ -125,9 +130,22 @@ static int SCTDRIVCheckStatus(void *data, SConnection *pCon){ int status; Tcl_Interp *pTcl = NULL; char *result; + SConnection *con; self = (pSctDrive)data; + /* + * check if the write command has gone through + */ + if(GetHdbProperty(self->node,"writestatus", script,1024)){ + if(strcmp(script,"start") == 0){ + return HWBusy; + } + } + + /* + * run the checkstatus script + */ if(!GetHdbProperty(self->node,"checkstatus",script,1024)){ if (!GetHdbProperty(self->node,"status",script,1024)){ SCWrite(pCon, @@ -139,11 +157,16 @@ static int SCTDRIVCheckStatus(void *data, SConnection *pCon){ status = SctCallInContext(pCon,script, self->node, self->c, &result); if (status == 0) { - SCWrite(pCon,result, eError); + SCPrintf(pCon,eError," script %s returned %s", + script, result); return HWFault; } + if(SctVerbose(self->c)){ + SCPrintf(pCon,eError," script %s returned %s", + script, result); + } } - if(strstr(result,"busy") != NULL){ + if(strstr(result,"busy") != NULL){ return HWBusy; } else if(strstr(result,"posfault") != NULL){ return HWPosFault; diff --git a/sicshipadaba.c b/sicshipadaba.c index 6d0fe188..8aca6d6c 100644 --- a/sicshipadaba.c +++ b/sicshipadaba.c @@ -31,6 +31,7 @@ #include "statusfile.h" #include #include "sicsobj.h" +#include #define MAX_HDB_PATH 1024 @@ -691,8 +692,14 @@ static hdbCallbackReturn SICSScriptReadCallback(pHdb node, void *userData, /* * evaluate */ + if(pCon != NULL){ + MacroPush(pCon); + } status = Tcl_Eval(InterpGetTcl(pServ->pSics),command); - if(status != TCL_OK){ + if(pCon != NULL){ + MacroPop(); + } + if(status != TCL_OK){ snprintf(error,1023,"ERROR: Tcl returned error: %s", Tcl_GetStringResult(InterpGetTcl(pServ->pSics))); if(pCon != NULL){ diff --git a/sllinux_def b/sllinux_def index 38576c3a..570bc1e6 100644 --- a/sllinux_def +++ b/sllinux_def @@ -6,6 +6,7 @@ #DFORTIFY= -DFORTIFY #FORTIFYOBJ= fortify.o strdup.o +#DFORTIFY= -p MFLAGS=-f makefile_linux$(DUMMY) diff --git a/status.c b/status.c index 64f2eda4..b88b60ca 100644 --- a/status.c +++ b/status.c @@ -289,6 +289,7 @@ SetStatus(eEager); SetInterrupt(eContinue); ClearExecutor(GetExecutor()); + SCsetMacro(pCon,0); return 1; } /* ===================== Control Connection Management ====================*/