From 4fa515c3517219790f6c43591c4f35785ba8dd44 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Tue, 18 Dec 2012 14:03:58 +1100 Subject: [PATCH] Add hdbnode to diffscan --- diffscan.c | 39 ++++++++++++++++++++++++++++++++++++++- diffscan.h | 3 +++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/diffscan.c b/diffscan.c index 7f6a57b4..6334b0c3 100644 --- a/diffscan.c +++ b/diffscan.c @@ -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); diff --git a/diffscan.h b/diffscan.h index fcc50cdd..b4e3c707 100644 --- a/diffscan.h +++ b/diffscan.h @@ -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; /*==================================================================*/