Files
aqhomecontrol/apps/aqhome-react/units/u_varchanges.c
2024-03-24 18:51:56 +01:00

53 lines
1.5 KiB
C

/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2024 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "./u_varchanges.h"
#include "./u_passthrough.h"
#include <gwenhywfar/debug.h>
AQHREACT_UNIT *AqHomeReact_UnitVarChanges_new(AQHOME_REACT *aqh)
{
AQHREACT_UNIT *unit;
unit=AqHomeReact_UnitPassthrough_new(aqh);
AQHREACT_Unit_SetName(unit, "varchanges");
AQHREACT_Unit_SetDescription(unit, "Propagates changes of values on the data server");
return unit;
}
void AqHomeReact_UnitVarChanges_ValueUpdated(AQHREACT_UNIT *unit, const AQH_VALUE *value, uint64_t timestamp, double data)
{
AQHREACT_DATAOBJECT *dataObject;
DBG_INFO(NULL, "Value \"%s\" changed", AQH_Value_GetNameForSystem(value));
dataObject=AQHREACT_DataObject_new();
AQHREACT_DataObject_SetDataType(dataObject, AQHREACT_DATAOBJECTTYPE_DOUBLE);
AQHREACT_DataObject_SetTimestamp(dataObject, timestamp);
AQHREACT_DataObject_SetDoubleData(dataObject, data);
AQHREACT_DataObject_SetSystemValueId(dataObject, AQH_Value_GetNameForSystem(value));
AQHREACT_DataObject_SetValueId(dataObject, AQH_Value_GetId(value));
AQHREACT_Unit_OutputData(unit, AQHOMEREACT_UNIT_PASSTHROUGH_OUTSLOT_OUTPUT, dataObject);
AQHREACT_DataObject_free(dataObject);
}