aqhome-cgi: optionally check for last change.
This commit is contained in:
@@ -511,8 +511,10 @@ void _writePageDataSet(AQH_MD_PAGECTX *ctx, const char *sPageId, GWEN_XMLNODE *n
|
||||
const char *sVarType;
|
||||
const char *sModality;
|
||||
const char *sVarName;
|
||||
const char *sLastChange;
|
||||
int modality;
|
||||
int varType;
|
||||
uint64_t lastChange;
|
||||
AQH_MD_PAGECTX *newCtx;
|
||||
|
||||
/* prepare new context */
|
||||
@@ -520,9 +522,11 @@ void _writePageDataSet(AQH_MD_PAGECTX *ctx, const char *sPageId, GWEN_XMLNODE *n
|
||||
sRoom=GWEN_XMLNode_GetProperty(nElement, "room", NULL);
|
||||
sModality=GWEN_XMLNode_GetProperty(nElement, "modality", NULL);
|
||||
sVarName=GWEN_XMLNode_GetProperty(nElement, "varname", NULL);
|
||||
sLastChange=GWEN_XMLNode_GetProperty(nElement, "lastChange", NULL);
|
||||
modality=sModality?AQH_ValueModality_fromString(sModality):AQH_ValueModality_Unknown;
|
||||
varType=sVarType?AQH_ValueType_fromString(sVarType):AQH_ValueType_Sensor;
|
||||
newCtx=AQH_MDPageCtx_CopyWithMatchingVars(ctx, varType, sRoom, modality, sVarName);
|
||||
lastChange=sLastChange?AQH_ParseTime(sLastChange):0;
|
||||
newCtx=AQH_MDPageCtx_CopyWithMatchingVars(ctx, varType, sRoom, modality, sVarName, lastChange);
|
||||
/* enter context */
|
||||
_writePageChildElements(newCtx, sPageId, nElement, dbuf);
|
||||
/* free new context */
|
||||
|
||||
@@ -33,7 +33,7 @@ GWEN_TREE2_FUNCTIONS(AQH_MD_PAGECTX, AQH_MDPageCtx);
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int _valueMatches(const AQH_VALUE *value, int varType, const char *room, int modality, const char *vname);
|
||||
static int _valueMatches(const AQH_VALUE *value, int varType, const char *room, int modality, const char *vname, uint64_t lastChange);
|
||||
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ void AQH_MDPageCtx_free(AQH_MD_PAGECTX *ctx)
|
||||
|
||||
|
||||
AQH_MD_PAGECTX *AQH_MDPageCtx_CopyWithMatchingVars(const AQH_MD_PAGECTX *octx,
|
||||
int varType, const char *room, int modality, const char *vname)
|
||||
int varType, const char *room, int modality, const char *vname, uint64_t lastChange)
|
||||
{
|
||||
AQH_MD_PAGECTX *ctx=NULL;
|
||||
|
||||
@@ -92,7 +92,7 @@ AQH_MD_PAGECTX *AQH_MDPageCtx_CopyWithMatchingVars(const AQH_MD_PAGECTX *octx,
|
||||
valueList=AQH_Value_List_new();
|
||||
vSrc=AQH_Value_List_First(octx->valueList);
|
||||
while(vSrc) {
|
||||
if (_valueMatches(vSrc, varType, room, modality, vname)) {
|
||||
if (_valueMatches(vSrc, varType, room, modality, vname, lastChange)) {
|
||||
AQH_VALUE *vDest;
|
||||
|
||||
DBG_ERROR(NULL, "+ %s", AQH_Value_GetNameForSystem(vSrc));
|
||||
@@ -115,7 +115,7 @@ AQH_MD_PAGECTX *AQH_MDPageCtx_CopyWithMatchingVars(const AQH_MD_PAGECTX *octx,
|
||||
|
||||
|
||||
|
||||
int _valueMatches(const AQH_VALUE *value, int varType, const char *room, int modality, const char *vname)
|
||||
int _valueMatches(const AQH_VALUE *value, int varType, const char *room, int modality, const char *vname, uint64_t lastChange)
|
||||
{
|
||||
int matches=1;
|
||||
|
||||
@@ -125,6 +125,8 @@ int _valueMatches(const AQH_VALUE *value, int varType, const char *room, int mod
|
||||
if (matches && modality && modality!=AQH_Value_GetModality(value))
|
||||
matches=0;
|
||||
/* then slower compares */
|
||||
if (matches && lastChange && AQH_Value_GetTimestampLastChange(value)<lastChange)
|
||||
matches=0;
|
||||
if (matches && vname) {
|
||||
const char *sName;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ AQH_MD_PAGECTX *AQH_MDPageCtx_new(AQCGI_MODULE *module, AQH_DATACLIENT *dataClie
|
||||
void AQH_MDPageCtx_free(AQH_MD_PAGECTX *ctx);
|
||||
|
||||
AQH_MD_PAGECTX *AQH_MDPageCtx_CopyWithMatchingVars(const AQH_MD_PAGECTX *octx,
|
||||
int varType, const char *room, int modality, const char *vname);
|
||||
int varType, const char *room, int modality, const char *vname, uint64_t lastChange);
|
||||
|
||||
AQCGI_MODULE *AQH_MDPageCtx_GetModule(const AQH_MD_PAGECTX *ctx);
|
||||
AQH_DATACLIENT *AQH_MDPageCtx_GetDataClient(const AQH_MD_PAGECTX *ctx);
|
||||
|
||||
Reference in New Issue
Block a user