- Added an autoamtic window calculation routine for RITA

This commit is contained in:
koennecke
2009-08-13 07:29:25 +00:00
parent cb296cb390
commit b3e425b965
7 changed files with 229 additions and 18 deletions

View File

@ -87,8 +87,8 @@ static void storeData(pSICSOBJ self, int start, char *lineBuffer)
pPtr = trim(pPtr);
pPtr = stptok(pPtr, number, 80, " ");
while (pPtr != NULL) {
if (strstr(number, "noinp") != NULL) {
node->value.v.floatArray[start] = -9999.99;
if (strstr(number, "noinp") != NULL || strstr(number,"----") != NULL) {
node->value.v.floatArray[start] = -99.99;
start++;
} else {
pKomma = strchr(number, ',');
@ -134,30 +134,38 @@ static int countTokens(char *lineBuffer)
/*--------------------------------------------------------------------------*/
static void interpretLine(pSICSOBJ self, pLMD200 priv)
{
pHdb node = NULL;
pHdb node = NULL, stamp = NULL;
hdbValue timeVal;
node = GetHipadabaNode(self->objectNode, "data");
assert(node != NULL);
/*
* TODO: check the message headers against what is now coming out
* of the device.
*/
/* printf("Interpreting line: %s\n", priv->lineBuffer); */
if (strstr(priv->lineBuffer, "Alarm") != NULL) {
doAlarm(self, priv->lineBuffer);
return;
} else if (strstr(priv->lineBuffer, "Pre") != NULL) {
setAlarm(self, priv->lineBuffer);
} else if (strstr(priv->lineBuffer, "...0") == NULL) {
} else if (strstr(priv->lineBuffer, "001...008") != NULL) {
storeData(self, 0, priv->lineBuffer);
NotifyHipadabaPar(node, NULL);
return;
} else if(strstr(priv->lineBuffer,"..000") == NULL) {
} else if(strstr(priv->lineBuffer,"009...016") != NULL) {
storeData(self, 8, priv->lineBuffer);
NotifyHipadabaPar(node, NULL);
} else if(strstr(priv->lineBuffer,"017...019") != NULL) {
storeData(self, 16, priv->lineBuffer);
NotifyHipadabaPar(node, NULL);
} else {
if(strlen(priv->lineBuffer) > 5){
timeVal = MakeHdbText(priv->lineBuffer);
stamp = GetHipadabaNode(self->objectNode, "timestamp");
if(stamp != NULL){
UpdateHipadabaPar(stamp, timeVal, NULL);
}
}
}
}
/*----------------------------------------------------------------------------*/
static int LMD200Callback(int handle, void *userData)
{
@ -168,13 +176,19 @@ static int LMD200Callback(int handle, void *userData)
pPtr = ANETreadPtr(priv->asChannel,&length);
pEnd = strchr(pPtr,(int)'\r');
if(pEnd != NULL){
length = pEnd - pPtr;
while(pEnd != NULL){
*pEnd = '\0';
strncpy(priv->lineBuffer,pPtr,BUFLEN);
ANETreadConsume(priv->asChannel,length+1);
strcpy(priv->lineBuffer,pPtr);
interpretLine(self,priv);
ANETreadConsume(priv->asChannel,(pEnd - pPtr)+1);
pPtr = ANETreadPtr(priv->asChannel,&length);
if(length > 0){
pEnd = strchr(pPtr,(int)'\r');
} else {
pEnd = NULL;
}
}
return 1;
}
/*---------------------------------------------------------------------------*/
@ -206,7 +220,7 @@ int MakeLMD200(SConnection * pCon, SicsInterp * pSics, void *pData,
priv->port = atoi(argv[3]);
priv->asChannel = ANETconnect(priv->host, priv->port);
if (priv->asChannel < 0) {
SCWrite(pCon, "ERROR: failed to connect to LMD200", eError);
SCWrite(pCon, "ERROR: failed to connect to LMD200", eLogError);
killLMD200(priv);
return 0;
}
@ -218,6 +232,7 @@ int MakeLMD200(SConnection * pCon, SicsInterp * pSics, void *pData,
textValue = MakeHdbText("I do not feel very alarmed");
dataValue = makeHdbValue(HIPFLOATAR, 32);
AddSICSHdbPar(self->objectNode, "alarm", usInternal, textValue);
AddSICSHdbPar(self->objectNode, "timestamp", usInternal, textValue);
AddSICSHdbPar(self->objectNode, "data", usInternal, dataValue);
self->pPrivate = priv;
self->KillPrivate = killLMD200;