Add hdbnode to diffscan

This commit is contained in:
Douglas Clowes
2012-12-18 14:03:58 +11:00
parent 907f0e2ba6
commit 4fa515c351
2 changed files with 41 additions and 1 deletions

View File

@ -135,7 +135,7 @@ int DiffScanWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
return 0;
}
else if (self->sicsvar->eType != veText) {
SCPrintf(pCon, eError, "SICS Variable\t be TEXT not %s\n",
SCPrintf(pCon, eError, "SICS Variable must be TEXT not %s\n",
self->sicsvar->eType == veInt ? "INT" :
self->sicsvar->eType == veFloat ? "FLOAT" : "unknown");
self->sicsvar = NULL;
@ -148,6 +148,32 @@ int DiffScanWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
return 1;
}
}
if (strcasecmp(argv[1], "hdbnode") == 0) {
if (argc > 2) {
if (strcasecmp(argv[2], "none") == 0) {
self->hdbnode = NULL;
return 1;
} else {
self->hdbnode = FindHdbNode(NULL, argv[2], pCon);
if (self->hdbnode == NULL) {
SCPrintf(pCon, eError, "Cannot find HDB Node: %s\n", argv[2]);
return 0;
}
else if (self->hdbnode->value.dataType != HIPTEXT) {
SCPrintf(pCon, eError, "HDB Node %s must be TEXT\n", argv[2]);
self->hdbnode = NULL;
return 0;
}
}
return 1;
} else {
char *path = NULL;
if (self->hdbnode != NULL)
path = GetHipadabaPath(self->hdbnode);
SCPrintf(pCon, eValue, "hdbnode = %s\n", path ? path : "none");
return 1;
}
}
/*
if we end here we are treating variables
*/
@ -403,6 +429,17 @@ static int DiffScanTask(void *pData)
SCWrite(self->scanObject->pCon, pBueffel, eLog);
if (self->sicsvar != NULL && self->sicsvar->eType == veText)
VarSetText(self->sicsvar, pBueffel, usInternal);
if (self->hdbnode != NULL && self->hdbnode->value.dataType == HIPTEXT) {
hdbValue v;
char error[512];
cloneHdbValue(&self->hdbnode->value, &v);
if (!readHdbValue(&v, pBueffel, error, 512)) {
SCWrite(self->scanObject->pCon, error, eError);
} else {
UpdateHipadabaPar(self->hdbnode, v, self->scanObject->pCon);
}
ReleaseHdbValue(&v);
}
InvokeCallBack(self->scanObject->pCall, SCANPOINT, self->scanObject);
traceSys("diffscan","RUN: pos, count, rawcount, rawmon: %f, %d, %d, %d",
fPos, countValue, rawCount, rawMon);

View File

@ -13,6 +13,8 @@
#include "scan.h"
#include "scan.i"
#include "sicsvar.h"
#include "hipadaba.h"
#include "sicshipadaba.h"
typedef struct {
pObjectDescriptor pDes;
@ -25,6 +27,7 @@ typedef struct {
pScanData scanObject;
double last_report_time;
pSicsVariable sicsvar;
pHdb hdbnode;
} DiffScan, *pDiffScan;
/*==================================================================*/