- Many fixes to the new scriptcontext to make it work

This commit is contained in:
koennecke
2008-06-18 14:08:25 +00:00
parent ed304fb5f1
commit 45ac6c526f
12 changed files with 74 additions and 13 deletions

View File

@ -366,6 +366,7 @@ extern pServer pServ;
} }
assert( (iMode == 0) || (iMode == 1)); assert( (iMode == 0) || (iMode == 1));
self->iMacro = iMode; self->iMacro = iMode;
/* SCPrintf(self,eError, "SCsetMacro = %lx, %d\n", (long int)self, iMode); */
return 1; return 1;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -2272,7 +2273,7 @@ SConnection *SCStorePush(SCStore *conStore) {
/* push macro flag on stack */ /* push macro flag on stack */
conStore->macroStack <<= 1; conStore->macroStack <<= 1;
conStore->macroStack |= (pCon->iMacro != 0); conStore->macroStack |= (pCon->iMacro != 0);
pCon->iMacro = conStore->inMacro; SCsetMacro(pCon, conStore->inMacro);
SCPushContext2(pCon, conStore->cc); SCPushContext2(pCon, conStore->cc);
return pCon; return pCon;
} }
@ -2282,8 +2283,10 @@ void SCStorePop(SCStore *conStore) {
pCon = SCLoad(conStore); pCon = SCLoad(conStore);
SCPopContext(pCon); SCPopContext(pCon);
/* pop macro flag from stack */ /* pop macro flag from stack
pCon->iMacro = (conStore->macroStack | 1); SCsetMacro(pCon,conStore->macroStack);
*/
SCsetMacro(pCon, (conStore->macroStack & 1));
conStore->macroStack >>= 1; conStore->macroStack >>= 1;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/

12
event.h
View File

@ -1,5 +1,5 @@
#line 98 "event.w" #line 100 "event.w"
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
E V E N T E V E N T
@ -18,7 +18,7 @@
int Text2Event(char *pText); int Text2Event(char *pText);
#line 111 "event.w" #line 113 "event.w"
@ -45,13 +45,15 @@
#define STATUS 18 #define STATUS 18
#define POSITION 19 #define POSITION 19
#define HDBVAL 20 #define HDBVAL 20
#define STSTART 21
#define STEND 22
#line 113 "event.w" #line 115 "event.w"
/*--------------- Signals for the Signalfunction of each task ------------*/ /*--------------- Signals for the Signalfunction of each task ------------*/
#line 80 "event.w" #line 82 "event.w"
#define SICSINT 300 #define SICSINT 300
#define SICSBROADCAST 301 #define SICSBROADCAST 301
@ -60,6 +62,6 @@
#define COMLOG 304 #define COMLOG 304
#define CRONLIST 305 #define CRONLIST 305
#line 116 "event.w" #line 118 "event.w"
#endif #endif

View File

@ -56,6 +56,8 @@ $\langle$VE {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@#define STATUS 18@\\ \mbox{}\verb@#define STATUS 18@\\
\mbox{}\verb@#define POSITION 19@\\ \mbox{}\verb@#define POSITION 19@\\
\mbox{}\verb@#define HDBVAL 20@\\ \mbox{}\verb@#define HDBVAL 20@\\
\mbox{}\verb@#define STSTART 21@\\
\mbox{}\verb@#define STEND 22@\\
\mbox{}\verb@@$\Diamond$ \mbox{}\verb@@$\Diamond$
\end{list} \end{list}
\vspace{-1ex} \vspace{-1ex}

View File

@ -39,6 +39,8 @@ if the event code is not known, else the apropriate event code.
#define STATUS 18 #define STATUS 18
#define POSITION 19 #define POSITION 19
#define HDBVAL 20 #define HDBVAL 20
#define STSTART 21
#define STEND 22
@} @}
\begin{description} \begin{description}
\item[VALUECHANGE] This is a variable changing its value. As event data a pointer to the \item[VALUECHANGE] This is a variable changing its value. As event data a pointer to the

View File

@ -290,6 +290,10 @@ static hdbCallbackReturn MapParCallback(pHdb node, void *userData,
char command[1024]; char command[1024];
pDynString data = NULL; pDynString data = NULL;
if(GetHdbKillNodeMessage(message) != NULL ){
return hdbContinue;
}
GetHdbProperty(node->mama, "proxy", proxyDev,80); GetHdbProperty(node->mama, "proxy", proxyDev,80);
pCom = FindCommand(pServ->pSics, proxyDev); pCom = FindCommand(pServ->pSics, proxyDev);
if(pCom == NULL){ if(pCom == NULL){

View File

@ -268,6 +268,7 @@ static char *SctActionHandler(void *actionData, char *lastReply) {
char *send = NULL; char *send = NULL;
int i; int i;
SConnection *con; SConnection *con;
char timeKey[50], timeVal[50];
if (currentCon) { if (currentCon) {
con = SCStorePush(currentCon); con = SCStorePush(currentCon);
@ -297,6 +298,12 @@ static char *SctActionHandler(void *actionData, char *lastReply) {
if (currentCon && ! data->answered) { if (currentCon && ! data->answered) {
SCWrite(con, "o.k.", eValue); 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; goto finish;
} }
SetProp(node, controller->node, "state", state); SetProp(node, controller->node, "state", state);
@ -1022,3 +1029,7 @@ void SctInit(void) {
AddCommand(pServ->pSics, "sct", SctCommand, SctKill, sct); AddCommand(pServ->pSics, "sct", SctCommand, SctKill, sct);
AddCmd("makesctcontroller", SctMakeController); AddCmd("makesctcontroller", SctMakeController);
} }
int SctVerbose(SctController *c){
return c->verbose;
}

View File

@ -29,5 +29,10 @@ void SctQueueNode(SctController *controller, Hdb *node,
*/ */
int SctCallInContext(SConnection *con, char *script, Hdb *node, int SctCallInContext(SConnection *con, char *script, Hdb *node,
SctController *controller, char **resPtr); 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 #endif

View File

@ -78,6 +78,10 @@ static int SCTDRIVCheckLimits(void *data, float val,
if(GetHdbProperty(self->node,"checklimits",script,1024)){ if(GetHdbProperty(self->node,"checklimits",script,1024)){
status = SctCallInContext(pServ->dummyCon, script, status = SctCallInContext(pServ->dummyCon, script,
self->node, self->c, &result); 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){ if(status == 0){
strncpy(error,result,errlen); strncpy(error,result,errlen);
return 0; return 0;
@ -102,6 +106,7 @@ static long SCTDRIVSetValue(void *data, SConnection *pCon, float val){
self = (pSctDrive)data; self = (pSctDrive)data;
v.dataType = HIPFLOAT; v.dataType = HIPFLOAT;
v.v.doubleValue = (double)val; v.v.doubleValue = (double)val;
SetHdbProperty(self->node,"writestatus", "start");
status = SetHipadabaPar(self->node, v, pCon); status = SetHipadabaPar(self->node, v, pCon);
if(status == 1){ if(status == 1){
return OKOK; return OKOK;
@ -125,9 +130,22 @@ static int SCTDRIVCheckStatus(void *data, SConnection *pCon){
int status; int status;
Tcl_Interp *pTcl = NULL; Tcl_Interp *pTcl = NULL;
char *result; char *result;
SConnection *con;
self = (pSctDrive)data; 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,"checkstatus",script,1024)){
if (!GetHdbProperty(self->node,"status",script,1024)){ if (!GetHdbProperty(self->node,"status",script,1024)){
SCWrite(pCon, SCWrite(pCon,
@ -139,9 +157,14 @@ static int SCTDRIVCheckStatus(void *data, SConnection *pCon){
status = SctCallInContext(pCon,script, self->node, status = SctCallInContext(pCon,script, self->node,
self->c, &result); self->c, &result);
if (status == 0) { if (status == 0) {
SCWrite(pCon,result, eError); SCPrintf(pCon,eError," script %s returned %s",
script, result);
return HWFault; 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; return HWBusy;

View File

@ -31,6 +31,7 @@
#include "statusfile.h" #include "statusfile.h"
#include <splitter.h> #include <splitter.h>
#include "sicsobj.h" #include "sicsobj.h"
#include <macro.h>
#define MAX_HDB_PATH 1024 #define MAX_HDB_PATH 1024
@ -691,7 +692,13 @@ static hdbCallbackReturn SICSScriptReadCallback(pHdb node, void *userData,
/* /*
* evaluate * evaluate
*/ */
if(pCon != NULL){
MacroPush(pCon);
}
status = Tcl_Eval(InterpGetTcl(pServ->pSics),command); status = Tcl_Eval(InterpGetTcl(pServ->pSics),command);
if(pCon != NULL){
MacroPop();
}
if(status != TCL_OK){ if(status != TCL_OK){
snprintf(error,1023,"ERROR: Tcl returned error: %s", snprintf(error,1023,"ERROR: Tcl returned error: %s",
Tcl_GetStringResult(InterpGetTcl(pServ->pSics))); Tcl_GetStringResult(InterpGetTcl(pServ->pSics)));

View File

@ -6,6 +6,7 @@
#DFORTIFY= -DFORTIFY #DFORTIFY= -DFORTIFY
#FORTIFYOBJ= fortify.o strdup.o #FORTIFYOBJ= fortify.o strdup.o
#DFORTIFY= -p
MFLAGS=-f makefile_linux$(DUMMY) MFLAGS=-f makefile_linux$(DUMMY)

View File

@ -289,6 +289,7 @@
SetStatus(eEager); SetStatus(eEager);
SetInterrupt(eContinue); SetInterrupt(eContinue);
ClearExecutor(GetExecutor()); ClearExecutor(GetExecutor());
SCsetMacro(pCon,0);
return 1; return 1;
} }
/* ===================== Control Connection Management ====================*/ /* ===================== Control Connection Management ====================*/