let setData use double values instead of strings.

this allows for storing value set with setData which can then be used in
the cgi module to retrieve the last value set.
This commit is contained in:
Martin Preuss
2025-10-07 23:50:50 +02:00
parent 1aeeed9845
commit d0c8b3b284
22 changed files with 421 additions and 186 deletions

View File

@@ -37,7 +37,7 @@
AQH_MESSAGE *AQH_IpcdMessageSetData_new(uint16_t code,
uint32_t msgId, uint32_t refMsgId,
const AQH_VALUE *value, const char *data)
const AQH_VALUE *value, double data)
{
AQH_MESSAGE *msg;
GWEN_BUFFER *buf;
@@ -51,8 +51,7 @@ AQH_MESSAGE *AQH_IpcdMessageSetData_new(uint16_t code,
GWEN_Buffer_free(buf);
return NULL;
}
if (data && *data)
GWEN_Tag16_WriteStringTagToBuffer(AQH_MSGDATA_SET_TAGS_DATA, data, buf);
GWEN_Tag16_WriteDoubleTagToBuffer(AQH_MSGDATA_SET_TAGS_DATA, data, buf);
msg=AQH_IpcMessage_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msgId, refMsgId,
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
@@ -78,9 +77,9 @@ AQH_VALUE *AQH_IpcdMessageSetData_ReadValue(const GWEN_TAG16_LIST *tagList)
char *AQH_IpcdMessageSetData_ReadData(const GWEN_TAG16_LIST *tagList)
double AQH_IpcdMessageSetData_ReadData(const GWEN_TAG16_LIST *tagList)
{
return AQH_Tag16_GetTagDataAsNewString(tagList, AQH_MSGDATA_SET_TAGS_DATA, NULL);
return AQH_Tag16_GetTagDataAsDouble(tagList, AQH_MSGDATA_SET_TAGS_DATA, 0.0);
}
@@ -92,16 +91,16 @@ void AQH_IpcdMessageSetData_DumpToBuffer(const AQH_MESSAGE *msg, const GWEN_TAG1
const char *valueName;
const char *valueUnits;
int valueType;
char *data;
double data;
value=tagList?AQH_IpcdMessageSetData_ReadValue(tagList):NULL;
valueName=value?AQH_Value_GetNameForSystem(value):NULL;
valueUnits=value?AQH_Value_GetValueUnits(value):NULL;
valueType=value?AQH_Value_GetValueType(value):0;
data=tagList?AQH_IpcdMessageSetData_ReadData(tagList):NULL;
data=tagList?AQH_IpcdMessageSetData_ReadData(tagList):0.0;
GWEN_Buffer_AppendArgs(dbuf,
"SETDATA(%s) %s (code=%d, proto=%d, proto version=%d, name=%s, units=%s, type=%d, value=%s)\n",
"SETDATA(%s) %s (code=%d, proto=%d, proto version=%d, name=%s, units=%s, type=%d, value=%.2f)\n",
AQH_IpcdMessage_MsgTypeToChar(AQH_IpcMessage_GetCode(msg)),
sText?sText:"",
AQH_IpcMessage_GetCode(msg),
@@ -110,8 +109,7 @@ void AQH_IpcdMessageSetData_DumpToBuffer(const AQH_MESSAGE *msg, const GWEN_TAG1
valueName?valueName:"<empty>",
valueUnits?valueUnits:"<empty>",
valueType,
data?data:"<empty>");
free(data);
data);
AQH_Value_free(value);
}