/**************************************************************************** * 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 #endif #include "./u_valueset.h" #include /* ------------------------------------------------------------------------------------------------ * 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 } } } }