Commit 8a5c62ac authored by koennecke's avatar koennecke
Browse files

Merge branch 'rhel7' into gelf

parents d1a85982 748a10ec
......@@ -11,6 +11,10 @@
*
* Created on: Jul 7, 2010
* Author: Mark Koennecke
*
* Updated to use long names to avoid collisions
*
* Mark Koennecke, May 2017
*/
#include <sics.h>
#include <sicsobj.h>
......@@ -29,6 +33,7 @@ typedef struct {
int dblength;
int switchdbnum;
int switchdblength;
int longName;
}SPSS7, *pSPSS7;
/*------------------------------------------------------------------*/
typedef struct {
......@@ -169,6 +174,7 @@ static void UpdateSPSDataBase(pS7Action self)
{
char *pPtr;
char name[15], unit[9], description[25], reference[11], error[50], alarms[10];
char longName[80]; /* must hold name+unit+description */
unsigned char type, alarm;
unsigned short val;
int ival;
......@@ -186,7 +192,12 @@ static void UpdateSPSDataBase(pS7Action self)
pPtr += decodeString(pPtr, unit,8);
pPtr += decodeString(pPtr, description,24);
pPtr += decodeString(pPtr, reference,10);
node = GetHipadabaNode(self->spsNode,name);
if(self->sps->longName == 1) {
snprintf(longName,sizeof(longName),"%s%s%s", name,unit,description);
node = GetHipadabaNode(self->spsNode,longName);
} else {
node = GetHipadabaNode(self->spsNode,name);
}
if(node == NULL){
printf("Something very fishy is happening here: did Roman change the SPS layout under our feet?\n");
continue;
......@@ -316,6 +327,7 @@ static void InitializeSPSDataBase(pS7Action self, pHdb parent)
{
char *pPtr;
char name[15], unit[9], description[25], reference[11], num[11], error[50], alarms[10];
char longName[80]; /* must hold name+unit+description */
unsigned char type, alarm;
short val;
int ival;
......@@ -333,10 +345,15 @@ static void InitializeSPSDataBase(pS7Action self, pHdb parent)
pPtr += decodeString(pPtr, unit,8);
pPtr += decodeString(pPtr, description,24);
pPtr += decodeString(pPtr, reference,10);
if(self->sps->longName == 1) {
snprintf(longName,sizeof(longName),"%s%s%s", name,unit,description);
} else {
strcpy(longName,name);
}
switch (type) {
case 1:
case 4:
node = MakeHipadabaNode(name,HIPINT,1);
node = MakeHipadabaNode(longName,HIPINT,1);
memcpy(&bval,pPtr+1,1);
hdbVal = MakeHdbInt(bval);
UpdateHipadabaPar(node,hdbVal,NULL);
......@@ -345,7 +362,7 @@ static void InitializeSPSDataBase(pS7Action self, pHdb parent)
pPtr += 2;
break;
case 2:
node = MakeHipadabaNode(name,HIPINT,1);
node = MakeHipadabaNode(longName,HIPINT,1);
memcpy(&ival,pPtr,4);
hdbVal = MakeHdbInt(ntohl(ival));
UpdateHipadabaPar(node,hdbVal,NULL);
......@@ -354,7 +371,7 @@ static void InitializeSPSDataBase(pS7Action self, pHdb parent)
pPtr += 4;
break;
case 3:
node = MakeHipadabaNode(name,HIPFLOAT,1);
node = MakeHipadabaNode(longName,HIPFLOAT,1);
memcpy(&ival,pPtr+2,4);
ival = htonl(ival);
memcpy(&fval,&ival,4);
......@@ -553,6 +570,19 @@ int MakeSPSS7(SConnection * con, SicsInterp * sics,
self->dbnum = atoi(argv[2]);
self->switchdbnum = atoi(argv[3]);
self->switchdblength = NOTLOADED;
self->longName = 0;
/*
test the longname flag
*/
if(argc > 4) {
self->longName = atoi(argv[4]);
if(self->longName != 0 && self->longName != 1) {
SCWrite(con,"ERROR: invalid value for longName flag on spss7", eError);
self->longName = 0;
}
}
pNew = MakeSICSOBJv(argv[1],"SPS-S7", HIPNONE, usInternal);
if(pNew == NULL){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment