- Added asynchronous IO code from ANSTO

- Added new ACT protocol
- Extended sicshdbadapter to cover counters and status to put the status
 into Hipadaba
- Fixes to napi5.c
- Exe now supports hdbrun which allows to write output for a buffer into
 hdb node.
This commit is contained in:
koennecke
2007-06-22 11:44:46 +00:00
parent d5ff6410bc
commit 08c5e037a0
24 changed files with 13224 additions and 1291 deletions

View File

@ -21,6 +21,8 @@
#include "motor.h"
#include "HistMem.h"
#include "sicsvar.h"
#include "counter.h"
#include "lld.h"
#include "sicshipadaba.h"
#include "sicshdbadapter.h"
@ -411,6 +413,54 @@ static pHdb MakeSicsVarNode(pSicsVariable pVar, char *name){
node->protected = 1;
return node;
}
/*================ counter =============================================*/
typedef struct {
pHdb node;
int monitor; /* -1 == time */
pCounter counter;
} CountEntry;
static int countList = -10;
/*---------------------------------------------------------------------*/
static void updateCountList(){
int status;
hdbValue v;
CountEntry hugo;
long monitor;
float time;
SConnection *pDummy = NULL;
if(countList < 0){
return;
}
pDummy = SCCreateDummyConnection(pServ->pSics);
if(pDummy == NULL){
return;
}
status = LLDnodePtr2First(countList);
while(status != 0){
LLDnodeDataTo(countList,&hugo);
if(hugo.monitor < 0){
time = GetCountTime(hugo.counter,pDummy);
v = MakeHdbFloat((double)time);
UpdateHipadabaPar(hugo.node,v, NULL);
} else {
monitor = GetMonitor(hugo.counter, hugo.monitor, pDummy);
v = MakeHdbInt((int)monitor);
UpdateHipadabaPar(hugo.node,v, NULL);
}
status = LLDnodePtr2Next(countList);
}
SCDeleteConnection(pDummy);
}
/*---------------------------------------------------------------------------*/
static int CounterCallback(int iEvent, void *eventData, void *userData,
commandContext cc){
if(iEvent == MONITOR || iEvent == COUNTEND || iEvent == COUNTSTART){
updateCountList();
}
return 1;
}
/*============== interpreter function ==================================*/
int SICSHdbAdapter(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]){
@ -423,6 +473,8 @@ int SICSHdbAdapter(SConnection *pCon, SicsInterp *pSics, void *pData,
pIDrivable pDriv = NULL;
pSicsVariable pVar = NULL;
char buffer[512];
pCounter pCount = NULL;
CountEntry hugo;
root = GetHipadabaRoot();
assert(root != NULL);
@ -505,6 +557,31 @@ int SICSHdbAdapter(SConnection *pCon, SicsInterp *pSics, void *pData,
return 1;
}
/**
* look for counters
*/
pCount = (pCounter)FindCommandData(pSics,argv[2],"SingleCounter");
if(pCount != NULL){
hugo.monitor = atoi(argv[3]);
hugo.counter = pCount;
hugo.node = path;
if(countList < 0){
countList = LLDcreate(sizeof(CountEntry));
RegisterCallback(pCount->pCall, SCGetContext(pCon),
COUNTSTART, CounterCallback,
NULL, NULL);
RegisterCallback(pCount->pCall, SCGetContext(pCon),
COUNTEND, CounterCallback,
NULL, NULL);
RegisterCallback(pCount->pCall, SCGetContext(pCon),
MONITOR, CounterCallback,
NULL, NULL);
}
LLDnodeAppendFrom(countList,&hugo);
SCSendOK(pCon);
return 1;
}
snprintf(buffer,511,
"ERROR: attaching this type of object: %s at %s not implemented",
argv[2], argv[1]);