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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@
|
||||
|
||||
AQHOME_API 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);
|
||||
|
||||
AQHOME_API AQH_VALUE *AQH_IpcdMessageSetData_ReadValue(const GWEN_TAG16_LIST *tagList);
|
||||
AQHOME_API char *AQH_IpcdMessageSetData_ReadData(const GWEN_TAG16_LIST *tagList);
|
||||
AQHOME_API double AQH_IpcdMessageSetData_ReadData(const GWEN_TAG16_LIST *tagList);
|
||||
|
||||
AQHOME_API void AQH_IpcdMessageSetData_DumpToBuffer(const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList,
|
||||
GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
@@ -161,6 +161,19 @@ uint64_t AQH_Tag16_GetTagDataAsUint64(const GWEN_TAG16_LIST *tagList, unsigned i
|
||||
|
||||
|
||||
|
||||
double AQH_Tag16_GetTagDataAsDouble(const GWEN_TAG16_LIST *tagList, unsigned int tagType, double defaultValue)
|
||||
{
|
||||
if (tagList) {
|
||||
const GWEN_TAG16 *tag;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, tagType);
|
||||
return tag?GWEN_Tag16_GetTagDataAsDouble(tag, defaultValue):defaultValue;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int AQH_Tag16_WriteValueListAsTagsToBuffer(unsigned int tagType, const AQH_VALUE_LIST *valueList, GWEN_BUFFER *buf)
|
||||
{
|
||||
if (valueList) {
|
||||
|
||||
@@ -27,6 +27,7 @@ AQHOME_API GWEN_TAG16_LIST *AQH_Tag16_ParseTags(const uint8_t *payloadPtr, uint3
|
||||
AQHOME_API char *AQH_Tag16_GetTagDataAsNewString(const GWEN_TAG16_LIST *tagList, unsigned int tagType, const char *defaultValue);
|
||||
AQHOME_API uint32_t AQH_Tag16_GetTagDataAsUint32(const GWEN_TAG16_LIST *tagList, unsigned int tagType, uint32_t defaultValue);
|
||||
AQHOME_API uint64_t AQH_Tag16_GetTagDataAsUint64(const GWEN_TAG16_LIST *tagList, unsigned int tagType, uint64_t defaultValue);
|
||||
AQHOME_API double AQH_Tag16_GetTagDataAsDouble(const GWEN_TAG16_LIST *tagList, unsigned int tagType, double defaultValue);
|
||||
|
||||
/* utils */
|
||||
AQHOME_API int AQH_Tag16_WriteValueListAsTagsToBuffer(unsigned int tagType, const AQH_VALUE_LIST *valueList, GWEN_BUFFER *buf);
|
||||
|
||||
Reference in New Issue
Block a user