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

78 lines
2.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_passthrough.h"
#include <gwenhywfar/debug.h>
/* ------------------------------------------------------------------------------------------------
* defines
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* forward declarations
* ------------------------------------------------------------------------------------------------
*/
static void _cbInputData(AQHREACT_UNIT *unit, int slotIdForUnit, const AQHREACT_DATAOBJECT *dataObject);
/* ------------------------------------------------------------------------------------------------
* implementations
* ------------------------------------------------------------------------------------------------
*/
AQHREACT_UNIT *AqHomeReact_UnitPassthrough_new(AQHOME_REACT *aqh)
{
AQHREACT_UNIT *unit;
AQHREACT_OUTPUT_SLOT *outputSlot;
AQHREACT_INPUT_SLOT *inputSlot;
unit=AQHREACT_Unit_new(aqh);
AQHREACT_Unit_SetName(unit, "passthrough");
AQHREACT_Unit_SetDescription(unit, "Generic passthrough unit");
AQHREACT_Unit_SetInputDataFn(unit, _cbInputData);
outputSlot=AQHREACT_OutputSlot_new();
AQHREACT_OutputSlot_SetName(outputSlot, "output");
AQHREACT_OutputSlot_SetIdForUnit(outputSlot, AQHOMEREACT_UNIT_PASSTHROUGH_OUTSLOT_OUTPUT);
AQHREACT_OutputSlot_SetEmittedDataType(outputSlot, AQHREACT_DATAOBJECTTYPE_DOUBLE);
AQHREACT_Unit_AddOutputSlot(unit, outputSlot);
inputSlot=AQHREACT_InputSlot_new();
AQHREACT_InputSlot_SetName(inputSlot, "input");
AQHREACT_InputSlot_SetIdForUnit(inputSlot, AQHOMEREACT_UNIT_PASSTHROUGH_OUTSLOT_OUTPUT);
AQHREACT_InputSlot_SetAcceptedDataType(inputSlot, AQHREACT_DATAOBJECTTYPE_DOUBLE);
AQHREACT_Unit_AddInputSlot(unit, inputSlot);
return unit;
}
void _cbInputData(AQHREACT_UNIT *unit, int slotIdForUnit, const AQHREACT_DATAOBJECT *dataObject)
{
if (unit && dataObject && slotIdForUnit==AQHOMEREACT_UNIT_PASSTHROUGH_INSLOT_INPUT)
AQHREACT_Unit_OutputData(unit, AQHOMEREACT_UNIT_PASSTHROUGH_OUTSLOT_OUTPUT, dataObject);
}