- Various fixes to make mountaingum work
This commit is contained in:
16
exeman.c
16
exeman.c
@ -316,7 +316,7 @@ static int SCHdbWrite(SConnection *self, char *message, int outCode){
|
||||
/*--------------------------------------------------------------------*/
|
||||
int exeHdbNode(pHdb exeNode, SConnection *pCon){
|
||||
char pBueffel[512], *name = NULL;
|
||||
pHdb node = NULL;
|
||||
pHdb node = NULL, log = NULL;
|
||||
pExeBuf buffer = NULL;
|
||||
hdbValue v;
|
||||
int status;
|
||||
@ -326,17 +326,17 @@ int exeHdbNode(pHdb exeNode, SConnection *pCon){
|
||||
/*
|
||||
* clear log buffer
|
||||
*/
|
||||
node = GetHipadabaNode(exeNode,"log");
|
||||
if(node == NULL){
|
||||
log = GetHipadabaNode(exeNode,"log");
|
||||
if(log == NULL){
|
||||
SCWrite(pCon,"ERROR: Hdb node not found or in wrong format",eError);
|
||||
return 0;
|
||||
}
|
||||
v = MakeHdbText(strdup(""));
|
||||
UpdateHipadabaPar(node,v,pCon);
|
||||
UpdateHipadabaPar(log,v,pCon);
|
||||
/*
|
||||
* prepare context
|
||||
*/
|
||||
name = GetHipadabaPath(node);
|
||||
name = GetHipadabaPath(log);
|
||||
cc = SCGetContext(pCon);
|
||||
strncpy(cc.deviceID, name,255);
|
||||
strncpy(bufferNode,name,511);
|
||||
@ -371,6 +371,12 @@ int exeHdbNode(pHdb exeNode, SConnection *pCon){
|
||||
status = exeBufProcess(buffer,pServ->pSics,pCon,NULL,0);
|
||||
SCSetWriteFunc(pCon,oldWrite);
|
||||
SCPopContext(pCon);
|
||||
exeBufDelete(buffer);
|
||||
if(strlen(log->value.v.text) < 2){
|
||||
v = MakeHdbText(strdup("OK\n"));
|
||||
UpdateHipadabaPar(log,v,pCon);
|
||||
ReleaseHdbValue(&v);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
|
80
hdbqueue.c
80
hdbqueue.c
@ -18,6 +18,7 @@
|
||||
/*--------------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
int iStop;
|
||||
int isRunning;
|
||||
SConnection *pCon;
|
||||
}HdbQueue, *pHdbQueue;
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@ -155,7 +156,7 @@ static void sequentialNames(pHdb obj,SConnection *pCon){
|
||||
current = work->child;
|
||||
while(current != NULL){
|
||||
snprintf(name,80,"%3.3d",count);
|
||||
if(current != NULL && current->name != NULL){
|
||||
if(current->name != NULL){
|
||||
free(current->name);
|
||||
}
|
||||
current->name = strdup(name);
|
||||
@ -173,6 +174,13 @@ static void sequentialNames(pHdb obj,SConnection *pCon){
|
||||
static int Dequeue(pSICSOBJ self, SConnection *pCon, pHdb par[], int nPar){
|
||||
pHdb work = NULL;
|
||||
char name[80];
|
||||
pHdbQueue priv = (pHdbQueue)self->pPrivate;
|
||||
|
||||
if(priv->isRunning == 1){
|
||||
SCWrite(pCon,"ERROR: cannot dequeue while running",eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if(nPar < 1){
|
||||
SCWrite(pCon,"ERROR: internal: not enough parameters to Dequeue",eError);
|
||||
@ -193,8 +201,13 @@ static int Dequeue(pSICSOBJ self, SConnection *pCon, pHdb par[], int nPar){
|
||||
static int Clean(pSICSOBJ self, SConnection *pCon, pHdb par[], int nPar){
|
||||
int i;
|
||||
pHdb current = NULL, queue = NULL;
|
||||
pHdb currentEntry = NULL, tmp;
|
||||
pHdb currentEntry = NULL, tmp = NULL;
|
||||
pHdbQueue priv = (pHdbQueue)self->pPrivate;
|
||||
|
||||
if(priv->isRunning == 1){
|
||||
SCWrite(pCon,"ERROR: cannot clean while running",eError);
|
||||
return 0;
|
||||
}
|
||||
currentEntry = GetHipadabaNode(self->objectNode,"control/currentEntry");
|
||||
queue = GetHipadabaNode(self->objectNode,"queue");
|
||||
current = queue->child;
|
||||
@ -211,6 +224,31 @@ static int Clean(pSICSOBJ self, SConnection *pCon, pHdb par[], int nPar){
|
||||
NotifyHipadabaPar(currentEntry,pCon);
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int CleanAll(pSICSOBJ self, SConnection *pCon, pHdb par[], int nPar){
|
||||
int i;
|
||||
pHdb current = NULL, queue = NULL;
|
||||
pHdb currentEntry = NULL, tmp;
|
||||
pHdbQueue priv = (pHdbQueue)self->pPrivate;
|
||||
|
||||
if(priv->isRunning == 1){
|
||||
SCWrite(pCon,"ERROR: cannot clear queue while executing",eError);
|
||||
return 0;
|
||||
}
|
||||
currentEntry = GetHipadabaNode(self->objectNode,"control/currentEntry");
|
||||
queue = GetHipadabaNode(self->objectNode,"queue");
|
||||
current = queue->child;
|
||||
while(current != NULL){
|
||||
tmp = current->next;
|
||||
DeleteNodeData(current);
|
||||
current = tmp;
|
||||
}
|
||||
queue->child = NULL;
|
||||
currentEntry->value.v.intValue = 0;
|
||||
sequentialNames(self->objectNode, pCon);
|
||||
NotifyHipadabaPar(currentEntry,pCon);
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static int QueueTask(void *pData){
|
||||
pSICSOBJ self = (pSICSOBJ)pData;
|
||||
@ -222,6 +260,7 @@ static int QueueTask(void *pData){
|
||||
pHdbQueue priv = (pHdbQueue)self->pPrivate;
|
||||
|
||||
if(priv->iStop == 1){
|
||||
priv->isRunning = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -238,6 +277,7 @@ static int QueueTask(void *pData){
|
||||
MacroPop();
|
||||
}
|
||||
if(priv->iStop == 1 || SCGetInterrupt(priv->pCon) != eContinue){
|
||||
priv->isRunning = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -245,6 +285,7 @@ static int QueueTask(void *pData){
|
||||
work->value.v.intValue = pos;
|
||||
NotifyHipadabaPar(work,priv->pCon);
|
||||
if(pos >= max->value.v.intValue){
|
||||
priv->isRunning = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -257,6 +298,12 @@ static int Start(pSICSOBJ self, SConnection *pCon, pHdb par[], int nPar){
|
||||
priv->iStop = 0;
|
||||
priv->pCon = pCon;
|
||||
|
||||
if(priv->isRunning == 1){
|
||||
SCWrite(pCon,"ERROR: Hdbqueue is already running",eError);
|
||||
return 0;
|
||||
}
|
||||
priv->isRunning = 1;
|
||||
|
||||
TaskRegister(pServ->pTasker,
|
||||
QueueTask,
|
||||
NULL,
|
||||
@ -266,6 +313,19 @@ static int Start(pSICSOBJ self, SConnection *pCon, pHdb par[], int nPar){
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int Restart(pSICSOBJ self, SConnection *pCon, pHdb par[], int nPar){
|
||||
pHdbQueue priv = (pHdbQueue)self->pPrivate;
|
||||
pHdb maxCurrent = NULL;
|
||||
|
||||
maxCurrent = GetHipadabaNode(self->objectNode,"control/currentEntry");
|
||||
if(maxCurrent != NULL){
|
||||
maxCurrent->value.v.intValue = 0;
|
||||
NotifyHipadabaPar(maxCurrent,pCon);
|
||||
}
|
||||
|
||||
return Start(self,pCon,par,nPar);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int Stop(pSICSOBJ self, SConnection *pCon, pHdb par[], int nPar){
|
||||
pHdbQueue priv = (pHdbQueue)self->pPrivate;
|
||||
|
||||
@ -279,6 +339,12 @@ static int Move(pSICSOBJ self, SConnection *pCon, pHdb par[], int nPar){
|
||||
pHdb prevNode = NULL, queueNode = NULL;
|
||||
pHdb tmp;
|
||||
char name[80];
|
||||
pHdbQueue priv = (pHdbQueue)self->pPrivate;
|
||||
|
||||
if(priv->isRunning == 1){
|
||||
SCWrite(pCon,"ERROR: cannot move while running",eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(nPar < 2){
|
||||
SCWrite(pCon,"ERROR: internal: not enough parameters to Move",eError);
|
||||
@ -375,11 +441,21 @@ static void Configure(pSICSOBJ self){
|
||||
AddHipadabaChild(obj,n,NULL);
|
||||
AppendHipadabaCallback(n,HCBSET,MakeSICSFuncCallback(self));
|
||||
|
||||
funcValue = makeHdbData(HIPFUNC,1,CleanAll);
|
||||
n = MakeSICSHdbPar("cleanall",usUser, funcValue);
|
||||
AddHipadabaChild(obj,n,NULL);
|
||||
AppendHipadabaCallback(n,HCBSET,MakeSICSFuncCallback(self));
|
||||
|
||||
funcValue = makeHdbData(HIPFUNC,1,Start);
|
||||
n = MakeSICSHdbPar("start",usUser, funcValue);
|
||||
AddHipadabaChild(obj,n,NULL);
|
||||
AppendHipadabaCallback(n,HCBSET,MakeSICSFuncCallback(self));
|
||||
|
||||
funcValue = makeHdbData(HIPFUNC,1,Restart);
|
||||
n = MakeSICSHdbPar("restart",usUser, funcValue);
|
||||
AddHipadabaChild(obj,n,NULL);
|
||||
AppendHipadabaCallback(n,HCBSET,MakeSICSFuncCallback(self));
|
||||
|
||||
funcValue = makeHdbData(HIPFUNC,1,Stop);
|
||||
n = MakeSICSHdbPar("stop",usUser, funcValue);
|
||||
AddHipadabaChild(obj,n,NULL);
|
||||
|
@ -457,6 +457,9 @@ int compareHdbValue(hdbValue v1, hdbValue v2){
|
||||
}
|
||||
break;
|
||||
case HIPTEXT:
|
||||
if(v1.v.text == NULL || v2.v.text == NULL){
|
||||
return 0;
|
||||
}
|
||||
if(strcmp(v1.v.text,v2.v.text) == 0){
|
||||
return 1;
|
||||
} else {
|
||||
|
@ -178,6 +178,7 @@ static int insertMonitor(pMcStasReader self, SConnection *pCon,
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(pBueffel,0,512);
|
||||
status = NXgetdata(self->handle,pBueffel);
|
||||
if(status != NX_OK){
|
||||
snprintf(pBueffel,511,"ERROR: Nexus error %s while reading %s",
|
||||
|
@ -8,6 +8,7 @@
|
||||
-----------------------------------------------------------------------------*/
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
#include "sics.h"
|
||||
#include "countdriv.h"
|
||||
#include "mccontrol.h"
|
||||
@ -76,6 +77,7 @@ static int McReadValues(struct __COUNTER *self){
|
||||
if(status == HWFault){
|
||||
self->iErrorCode = SCRIPTERROR;
|
||||
}
|
||||
self->fTime = time(NULL) - pMcStas->startTime;
|
||||
return status;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
@ -236,6 +236,7 @@
|
||||
int OpenVerifyLogFile()
|
||||
{
|
||||
char pFile[256];
|
||||
char filnam[512];
|
||||
char *pChar = NULL;
|
||||
|
||||
pChar = IFindOption(pSICSOptions,"LogFileBaseName");
|
||||
@ -245,10 +246,10 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(pFile,pChar);
|
||||
strncpy(pFile,pChar,255);
|
||||
}
|
||||
sprintf(pFile,"%s%2.2d.log",pFile, iFile);
|
||||
fLogFile = fopen(pFile,"w");
|
||||
snprintf(filnam,511,"%s%2.2d.log",pFile, iFile);
|
||||
fLogFile = fopen(filnam,"w");
|
||||
if(!fLogFile)
|
||||
{
|
||||
fprintf(stderr,"ERROR: Cannot open logfile %s for writing\n",pFile);
|
||||
|
@ -456,7 +456,7 @@ static void updateCountList(){
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int CounterCallback(int iEvent, void *eventData, void *userData,
|
||||
commandContext cc){
|
||||
if(iEvent == MONITOR || iEvent == COUNTEND || iEvent == COUNTSTART){
|
||||
if(iEvent == MONITOR || iEvent == COUNTEND){
|
||||
updateCountList();
|
||||
}
|
||||
return 1;
|
||||
|
@ -336,6 +336,7 @@ static int SICSNotifyCallback(void *userData, void *callData, pHdb node,
|
||||
SCPopContext(cbInfo->pCon);
|
||||
SCsetMacro(cbInfo->pCon,macro);
|
||||
free(pPath);
|
||||
DeleteDynString(result);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@ -472,7 +473,7 @@ static int SICSScriptReadCallback(void *userData, void *callData, pHdb node,
|
||||
command = (char *)userData;
|
||||
pCon = (SConnection *)callData;
|
||||
|
||||
assert(command != NULL && pCon != NULL);
|
||||
assert(command != NULL);
|
||||
|
||||
/*
|
||||
* evaluate
|
||||
@ -481,7 +482,9 @@ static int SICSScriptReadCallback(void *userData, void *callData, pHdb node,
|
||||
if(status != TCL_OK){
|
||||
snprintf(error,1023,"ERROR: Tcl returned error: %s",
|
||||
Tcl_GetStringResult(InterpGetTcl(pServ->pSics)));
|
||||
SCWrite(pCon,error,eError);
|
||||
if(pCon != NULL){
|
||||
SCWrite(pCon,error,eError);
|
||||
}
|
||||
status = 0;
|
||||
} else {
|
||||
status = 1;
|
||||
@ -494,7 +497,9 @@ static int SICSScriptReadCallback(void *userData, void *callData, pHdb node,
|
||||
*/
|
||||
data = (char *)Tcl_GetStringResult(InterpGetTcl(pServ->pSics));
|
||||
if(data == NULL){
|
||||
SCWrite(pCon,"ERROR: no result returned from script",eError);
|
||||
if(pCon != NULL){
|
||||
SCWrite(pCon,"ERROR: no result returned from script",eError);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
equal = strchr(data,'=');
|
||||
@ -504,7 +509,9 @@ static int SICSScriptReadCallback(void *userData, void *callData, pHdb node,
|
||||
strcpy(error,"ERROR: ");
|
||||
status = readHdbValue(&node->value,data, error+7, 1024-7);
|
||||
if(status != 1){
|
||||
SCWrite(pCon,error,eError);
|
||||
if(pCon != NULL){
|
||||
SCWrite(pCon,error,eError);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return status;
|
||||
@ -2353,12 +2360,10 @@ static int ChainCallback(void *userData, void *callData, pHdb node,
|
||||
hdbValue vv, old;
|
||||
|
||||
if(slave != NULL){
|
||||
old = slave->value;
|
||||
memset(&vv,0,sizeof(hdbValue));
|
||||
GetHipadabaPar(slave,&vv,callData);
|
||||
if(!compareHdbValue(old,vv)){
|
||||
UpdateHipadabaPar(slave, vv, callData);
|
||||
}
|
||||
UpdateHipadabaPar(slave, vv, callData);
|
||||
ReleaseHdbValue(&vv);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
35
statemon.c
35
statemon.c
@ -132,24 +132,26 @@ static pHdb recurseInterestNode(pHdb current, char *pDevice){
|
||||
*/
|
||||
alias = FindAliases(pServ->pSics,pSicsdev);
|
||||
pPtr = alias;
|
||||
while((pPtr = stptok(pPtr,pAlias,131,",")) != NULL){
|
||||
if(strcmp(pAlias,pDevice) == 0){
|
||||
return current;
|
||||
}
|
||||
}
|
||||
if(alias != NULL){
|
||||
free(alias);
|
||||
}
|
||||
}
|
||||
if(pPtr != NULL){
|
||||
while((pPtr = stptok(pPtr,pAlias,131,",")) != NULL){
|
||||
if(strcmp(pAlias,pDevice) == 0){
|
||||
return current;
|
||||
}
|
||||
}
|
||||
if(alias != NULL){
|
||||
free(alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
current = current->child;
|
||||
while(current != NULL){
|
||||
result = recurseInterestNode(current, pDevice);
|
||||
result = recurseInterestNode(current, pDevice);
|
||||
if(result != NULL){
|
||||
return result;
|
||||
}
|
||||
current = current->next;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
current = current->next;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@ -192,6 +194,9 @@ static int StateHdbInterest(int iEvent, void *pEvent, void *pUser,
|
||||
snprintf(buffer,1024,"%s FINISH", path);
|
||||
SCWriteInContext(pCon,buffer,eWarning,cc);
|
||||
}
|
||||
if(path != NULL){
|
||||
free(path);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user