aqhome-react: allow for int values.
those will be used e.g. to count number of open windows etc.
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
#endif
|
||||
|
||||
#include "./u_varchanges.h"
|
||||
#include "./u_passthrough.h"
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
@@ -20,10 +19,29 @@
|
||||
AQHREACT_UNIT *AqHomeReact_UnitVarChanges_new(AQHOME_REACT *aqh)
|
||||
{
|
||||
AQHREACT_UNIT *unit;
|
||||
AQHREACT_PORT *port;
|
||||
|
||||
unit=AqHomeReact_UnitPassthrough_new(aqh);
|
||||
unit=AQHREACT_Unit_new(aqh);
|
||||
AQHREACT_Unit_SetTypeName(unit, "varchanges");
|
||||
AQHREACT_Unit_SetDescription(unit, "Propagates changes of values on the data server");
|
||||
AQHREACT_Unit_SetDescription(unit, "Propagates changes of values (server or local)");
|
||||
|
||||
port=AQHREACT_Port_new();
|
||||
AQHREACT_Port_SetName(port, "intOutput");
|
||||
AQHREACT_Port_SetIdForUnit(port, AQHOMEREACT_UNIT_VARCHANGES_OUTSLOT_OUTINT);
|
||||
AQHREACT_Port_SetDataType(port, AQHREACT_DATAOBJECTTYPE_INT);
|
||||
AQHREACT_Unit_AddOutputPort(unit, port);
|
||||
|
||||
port=AQHREACT_Port_new();
|
||||
AQHREACT_Port_SetName(port, "doubleOutput");
|
||||
AQHREACT_Port_SetIdForUnit(port, AQHOMEREACT_UNIT_VARCHANGES_OUTSLOT_OUTDOUBLE);
|
||||
AQHREACT_Port_SetDataType(port, AQHREACT_DATAOBJECTTYPE_DOUBLE);
|
||||
AQHREACT_Unit_AddOutputPort(unit, port);
|
||||
|
||||
port=AQHREACT_Port_new();
|
||||
AQHREACT_Port_SetName(port, "stringOutput");
|
||||
AQHREACT_Port_SetIdForUnit(port, AQHOMEREACT_UNIT_VARCHANGES_OUTSLOT_OUTSTRING);
|
||||
AQHREACT_Port_SetDataType(port, AQHREACT_DATAOBJECTTYPE_STRING);
|
||||
AQHREACT_Unit_AddOutputPort(unit, port);
|
||||
|
||||
return unit;
|
||||
}
|
||||
@@ -34,7 +52,7 @@ void AqHomeReact_UnitVarChanges_ValueUpdated(AQHREACT_UNIT *unit, const AQH_VALU
|
||||
{
|
||||
AQHREACT_PORT *outputPort;
|
||||
|
||||
outputPort=AQHREACT_Unit_GetOutputPortByIdForUnit(unit, AQHOMEREACT_UNIT_PASSTHROUGH_OUTSLOT_OUTPUT);
|
||||
outputPort=AQHREACT_Unit_GetOutputPortByIdForUnit(unit, AQHOMEREACT_UNIT_VARCHANGES_OUTSLOT_OUTDOUBLE);
|
||||
if (outputPort) {
|
||||
AQHREACT_DATAOBJECT *dataObject;
|
||||
|
||||
@@ -56,7 +74,7 @@ void AqHomeReact_UnitVarChanges_DoubleVarUpdated(AQHREACT_UNIT *unit, const char
|
||||
{
|
||||
AQHREACT_PORT *outputPort;
|
||||
|
||||
outputPort=AQHREACT_Unit_GetOutputPortByIdForUnit(unit, AQHOMEREACT_UNIT_PASSTHROUGH_OUTSLOT_OUTPUT);
|
||||
outputPort=AQHREACT_Unit_GetOutputPortByIdForUnit(unit, AQHOMEREACT_UNIT_VARCHANGES_OUTSLOT_OUTDOUBLE);
|
||||
if (outputPort) {
|
||||
AQHREACT_DATAOBJECT *dataObject;
|
||||
|
||||
@@ -77,7 +95,7 @@ void AqHomeReact_UnitVarChanges_StringVarUpdated(AQHREACT_UNIT *unit, const char
|
||||
{
|
||||
AQHREACT_PORT *outputPort;
|
||||
|
||||
outputPort=AQHREACT_Unit_GetOutputPortByIdForUnit(unit, AQHOMEREACT_UNIT_PASSTHROUGH_OUTSLOT_OUTPUT);
|
||||
outputPort=AQHREACT_Unit_GetOutputPortByIdForUnit(unit, AQHOMEREACT_UNIT_VARCHANGES_OUTSLOT_OUTSTRING);
|
||||
if (outputPort) {
|
||||
AQHREACT_DATAOBJECT *dataObject;
|
||||
|
||||
@@ -94,6 +112,28 @@ void AqHomeReact_UnitVarChanges_StringVarUpdated(AQHREACT_UNIT *unit, const char
|
||||
|
||||
|
||||
|
||||
void AqHomeReact_UnitVarChanges_IntVarUpdated(AQHREACT_UNIT *unit, const char *varName, uint64_t timestamp, int data)
|
||||
{
|
||||
AQHREACT_PORT *outputPort;
|
||||
|
||||
outputPort=AQHREACT_Unit_GetOutputPortByIdForUnit(unit, AQHOMEREACT_UNIT_VARCHANGES_OUTSLOT_OUTINT);
|
||||
if (outputPort) {
|
||||
AQHREACT_DATAOBJECT *dataObject;
|
||||
|
||||
DBG_DEBUG(NULL, "Variable \"%s\" changed (int)", varName);
|
||||
dataObject=AQHREACT_DataObject_new();
|
||||
AQHREACT_DataObject_SetDataType(dataObject, AQHREACT_DATAOBJECTTYPE_INT);
|
||||
AQHREACT_DataObject_SetTimestamp(dataObject, timestamp);
|
||||
AQHREACT_DataObject_SetIntData(dataObject, data);
|
||||
AQHREACT_DataObject_SetSystemValueId(dataObject, varName);
|
||||
AQHREACT_Unit_OutputData(unit, outputPort, dataObject);
|
||||
AQHREACT_DataObject_free(dataObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
#include "aqhome/data/value.h"
|
||||
|
||||
|
||||
#define AQHOMEREACT_UNIT_VARCHANGES_OUTSLOT_OUTINT 0
|
||||
#define AQHOMEREACT_UNIT_VARCHANGES_OUTSLOT_OUTDOUBLE 1
|
||||
#define AQHOMEREACT_UNIT_VARCHANGES_OUTSLOT_OUTSTRING 2
|
||||
|
||||
|
||||
|
||||
AQHREACT_UNIT *AqHomeReact_UnitVarChanges_new(AQHOME_REACT *aqh);
|
||||
|
||||
/**
|
||||
@@ -34,6 +40,12 @@ void AqHomeReact_UnitVarChanges_DoubleVarUpdated(AQHREACT_UNIT *unit, const char
|
||||
void AqHomeReact_UnitVarChanges_StringVarUpdated(AQHREACT_UNIT *unit, const char *varName, uint64_t timestamp, const char *data);
|
||||
|
||||
|
||||
/**
|
||||
* Called from AqHomeReact when a local variable changed (see @ref AqHomeReact_SetIntValue).
|
||||
*/
|
||||
void AqHomeReact_UnitVarChanges_IntVarUpdated(AQHREACT_UNIT *unit, const char *varName, uint64_t timestamp, int data);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user