More work on aqhome-react service.
This commit is contained in:
@@ -45,6 +45,8 @@
|
||||
u_lowpass.h
|
||||
u_highpass.h
|
||||
u_stabilize.h
|
||||
u_valueset.h
|
||||
u_zeroposnegstring.h
|
||||
</headers>
|
||||
|
||||
<sources>
|
||||
@@ -57,6 +59,8 @@
|
||||
u_lowpass.c
|
||||
u_highpass.c
|
||||
u_stabilize.c
|
||||
u_valueset.c
|
||||
u_zeroposnegstring.c
|
||||
</sources>
|
||||
|
||||
<useTargets>
|
||||
|
||||
88
apps/aqhome-react/units/u_valueset.c
Normal file
88
apps/aqhome-react/units/u_valueset.c
Normal file
@@ -0,0 +1,88 @@
|
||||
/****************************************************************************
|
||||
* 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_valueset.h"
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* defines
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define AQHOMEREACT_UNIT_VALUESET_INSLOT_VALUE 0
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* forward declarations
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void _cbInputData(AQHREACT_UNIT *unit, int slotIdForUnit, const AQHREACT_DATAOBJECT *dataObject);
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* implementations
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
AQHREACT_UNIT *AqHomeReact_UnitValueSet_new(AQHOME_REACT *aqh)
|
||||
{
|
||||
AQHREACT_UNIT *unit;
|
||||
AQHREACT_INPUT_SLOT *inputSlot;
|
||||
AQHREACT_PARAM *param;
|
||||
|
||||
unit=AQHREACT_Unit_new(aqh);
|
||||
AQHREACT_Unit_SetName(unit, "valueset");
|
||||
AQHREACT_Unit_SetDescription(unit, "Set value by value path");
|
||||
AQHREACT_Unit_SetInputDataFn(unit, _cbInputData);
|
||||
|
||||
inputSlot=AQHREACT_InputSlot_new();
|
||||
AQHREACT_InputSlot_SetName(inputSlot, "input");
|
||||
AQHREACT_InputSlot_SetIdForUnit(inputSlot, AQHOMEREACT_UNIT_VALUESET_INSLOT_VALUE);
|
||||
AQHREACT_InputSlot_SetAcceptedDataType(inputSlot, AQHREACT_DATAOBJECTTYPE_STRING);
|
||||
AQHREACT_Unit_AddInputSlot(unit, inputSlot);
|
||||
|
||||
param=AQHREACT_Param_new();
|
||||
AQHREACT_Param_SetName(param, AQHOMEREACT_UNIT_VALUESET_PARAM_VALUENAME);
|
||||
AQHREACT_Param_SetDataType(param, AQHREACT_DATAOBJECTTYPE_STRING);
|
||||
AQHREACT_Unit_AddParam(unit, param);
|
||||
|
||||
return unit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _cbInputData(AQHREACT_UNIT *unit, int slotIdForUnit, const AQHREACT_DATAOBJECT *dataObject)
|
||||
{
|
||||
if (unit && dataObject && slotIdForUnit==AQHOMEREACT_UNIT_VALUESET_INSLOT_VALUE) {
|
||||
const char *sSystemValueId;
|
||||
|
||||
sSystemValueId=AQHREACT_DataObject_GetSystemValueId(dataObject);
|
||||
if (sSystemValueId && *sSystemValueId) {
|
||||
const char *sValueName;
|
||||
|
||||
sValueName=AQHREACT_Unit_GetParamValueString(unit, AQHOMEREACT_UNIT_VALUESET_PARAM_VALUENAME, NULL);
|
||||
if (sValueName && *sValueName) {
|
||||
// TODO: set value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
26
apps/aqhome-react/units/u_valueset.h
Normal file
26
apps/aqhome-react/units/u_valueset.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQHOMEREACT_U_VALUESET_H
|
||||
#define AQHOMEREACT_U_VALUESET_H
|
||||
|
||||
|
||||
#include "aqhome-react/aqhome_react.h"
|
||||
#include "aqhome-react/types/unit.h"
|
||||
|
||||
|
||||
#define AQHOMEREACT_UNIT_VALUESET_PARAM_VALUENAME "valueName"
|
||||
|
||||
|
||||
AQHREACT_UNIT *AqHomeReact_UnitValueSet_new(AQHOME_REACT *aqh);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
119
apps/aqhome-react/units/u_zeroposnegstring.c
Normal file
119
apps/aqhome-react/units/u_zeroposnegstring.c
Normal file
@@ -0,0 +1,119 @@
|
||||
/****************************************************************************
|
||||
* 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_zeroposnegstring.h"
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* defines
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define AQHOMEREACT_UNIT_ZEROPOSNEGSTRING_INSLOT_VALUE 0
|
||||
|
||||
#define AQHOMEREACT_UNIT_ZEROPOSNEGSTRING_OUTSLOT_RESULT 0
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* forward declarations
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void _cbInputData(AQHREACT_UNIT *unit, int slotIdForUnit, const AQHREACT_DATAOBJECT *dataObject);
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* implementations
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
AQHREACT_UNIT *AqHomeReact_UnitZeroPosNegString_new(AQHOME_REACT *aqh)
|
||||
{
|
||||
AQHREACT_UNIT *unit;
|
||||
AQHREACT_OUTPUT_SLOT *outputSlot;
|
||||
AQHREACT_INPUT_SLOT *inputSlot;
|
||||
AQHREACT_PARAM *param;
|
||||
|
||||
unit=AQHREACT_Unit_new(aqh);
|
||||
AQHREACT_Unit_SetName(unit, "zeroPosNegString");
|
||||
AQHREACT_Unit_SetDescription(unit, "Translate double value into strings for zero, positive, negative values");
|
||||
AQHREACT_Unit_SetInputDataFn(unit, _cbInputData);
|
||||
|
||||
outputSlot=AQHREACT_OutputSlot_new();
|
||||
AQHREACT_OutputSlot_SetName(outputSlot, "output");
|
||||
AQHREACT_OutputSlot_SetIdForUnit(outputSlot, AQHOMEREACT_UNIT_ZEROPOSNEGSTRING_OUTSLOT_RESULT);
|
||||
AQHREACT_OutputSlot_SetEmittedDataType(outputSlot, AQHREACT_DATAOBJECTTYPE_STRING);
|
||||
AQHREACT_Unit_AddOutputSlot(unit, outputSlot);
|
||||
|
||||
inputSlot=AQHREACT_InputSlot_new();
|
||||
AQHREACT_InputSlot_SetName(inputSlot, "input");
|
||||
AQHREACT_InputSlot_SetIdForUnit(inputSlot, AQHOMEREACT_UNIT_ZEROPOSNEGSTRING_INSLOT_VALUE);
|
||||
AQHREACT_InputSlot_SetAcceptedDataType(inputSlot, AQHREACT_DATAOBJECTTYPE_DOUBLE);
|
||||
AQHREACT_Unit_AddInputSlot(unit, inputSlot);
|
||||
|
||||
param=AQHREACT_Param_new();
|
||||
AQHREACT_Param_SetName(param, AQHOMEREACT_UNIT_VALUESET_PARAM_VALUE_NEG);
|
||||
AQHREACT_Param_SetDataType(param, AQHREACT_DATAOBJECTTYPE_STRING);
|
||||
AQHREACT_Unit_AddParam(unit, param);
|
||||
|
||||
param=AQHREACT_Param_new();
|
||||
AQHREACT_Param_SetName(param, AQHOMEREACT_UNIT_VALUESET_PARAM_VALUE_POS);
|
||||
AQHREACT_Param_SetDataType(param, AQHREACT_DATAOBJECTTYPE_STRING);
|
||||
AQHREACT_Unit_AddParam(unit, param);
|
||||
|
||||
param=AQHREACT_Param_new();
|
||||
AQHREACT_Param_SetName(param, AQHOMEREACT_UNIT_VALUESET_PARAM_VALUE_ZERO);
|
||||
AQHREACT_Param_SetDataType(param, AQHREACT_DATAOBJECTTYPE_STRING);
|
||||
AQHREACT_Unit_AddParam(unit, param);
|
||||
|
||||
return unit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _cbInputData(AQHREACT_UNIT *unit, int slotIdForUnit, const AQHREACT_DATAOBJECT *dataObject)
|
||||
{
|
||||
if (unit && dataObject) {
|
||||
const char *result=NULL;
|
||||
const AQHREACT_INPUT_SLOT *inputSlot;
|
||||
|
||||
inputSlot=AQHREACT_Unit_GetInputSlotByIdForUnit(unit, slotIdForUnit);
|
||||
if (inputSlot) {
|
||||
AQHREACT_DATAOBJECT *dataObject;
|
||||
|
||||
dataObject=AQHREACT_InputSlot_GetCurrentDataObject(inputSlot);
|
||||
if (dataObject) {
|
||||
double data;
|
||||
|
||||
data=AQHREACT_DataObject_GetDoubleData(dataObject);
|
||||
if (data>0.0)
|
||||
result=AQHREACT_Unit_GetParamValueString(unit, AQHOMEREACT_UNIT_VALUESET_PARAM_VALUE_POS, NULL);
|
||||
else if (data<0.0)
|
||||
result=AQHREACT_Unit_GetParamValueString(unit, AQHOMEREACT_UNIT_VALUESET_PARAM_VALUE_NEG, NULL);
|
||||
else
|
||||
result=AQHREACT_Unit_GetParamValueString(unit, AQHOMEREACT_UNIT_VALUESET_PARAM_VALUE_ZERO, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (result && *result)
|
||||
AQHREACT_Unit_OutputStringData(unit, AQHOMEREACT_UNIT_ZEROPOSNEGSTRING_OUTSLOT_RESULT, result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
28
apps/aqhome-react/units/u_zeroposnegstring.h
Normal file
28
apps/aqhome-react/units/u_zeroposnegstring.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQHOMEREACT_U_ZEROPOSNEGSTRING_H
|
||||
#define AQHOMEREACT_U_ZEROPOSNEGSTRING_H
|
||||
|
||||
|
||||
#include "aqhome-react/aqhome_react.h"
|
||||
#include "aqhome-react/types/unit.h"
|
||||
|
||||
|
||||
#define AQHOMEREACT_UNIT_VALUESET_PARAM_VALUE_NEG "valueIfNegative"
|
||||
#define AQHOMEREACT_UNIT_VALUESET_PARAM_VALUE_POS "valueIfPositive"
|
||||
#define AQHOMEREACT_UNIT_VALUESET_PARAM_VALUE_ZERO "valueIfZero"
|
||||
|
||||
|
||||
AQHREACT_UNIT *AqHomeReact_UnitZeroPosNegString_new(AQHOME_REACT *aqh);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user