aqhome-react: More work on units.
This commit is contained in:
@@ -37,6 +37,8 @@
|
|||||||
</setVar>
|
</setVar>
|
||||||
|
|
||||||
<headers dist="true" >
|
<headers dist="true" >
|
||||||
|
aqhome_react.h
|
||||||
|
aqhome_react_p.h
|
||||||
</headers>
|
</headers>
|
||||||
|
|
||||||
<sources>
|
<sources>
|
||||||
|
|||||||
@@ -41,12 +41,24 @@
|
|||||||
dataobject_p.h
|
dataobject_p.h
|
||||||
inputslot.h
|
inputslot.h
|
||||||
inputslot_p.h
|
inputslot_p.h
|
||||||
|
outputslot.h
|
||||||
|
outputslot_p.h
|
||||||
|
link.h
|
||||||
|
link_p.h
|
||||||
|
param.h
|
||||||
|
param_p.h
|
||||||
|
unit.h
|
||||||
|
unit_p.h
|
||||||
</headers>
|
</headers>
|
||||||
|
|
||||||
<sources>
|
<sources>
|
||||||
$(local/typefiles)
|
$(local/typefiles)
|
||||||
dataobject.c
|
dataobject.c
|
||||||
inputslot.c
|
inputslot.c
|
||||||
|
outputslot.c
|
||||||
|
link.c
|
||||||
|
param.c
|
||||||
|
unit.c
|
||||||
</sources>
|
</sources>
|
||||||
|
|
||||||
<useTargets>
|
<useTargets>
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
#include <gwenhywfar/debug.h>
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
GWEN_LIST_FUNCTIONS(AQHREACT_INPUT_SLOT, AQHREACT_InputSlot);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AQHREACT_INPUT_SLOT *AQHREACT_InputSlot_new()
|
AQHREACT_INPUT_SLOT *AQHREACT_InputSlot_new()
|
||||||
@@ -24,6 +26,7 @@ AQHREACT_INPUT_SLOT *AQHREACT_InputSlot_new()
|
|||||||
AQHREACT_INPUT_SLOT *inSlot;
|
AQHREACT_INPUT_SLOT *inSlot;
|
||||||
|
|
||||||
GWEN_NEW_OBJECT(AQHREACT_INPUT_SLOT, inSlot);
|
GWEN_NEW_OBJECT(AQHREACT_INPUT_SLOT, inSlot);
|
||||||
|
GWEN_LIST_INIT(AQHREACT_INPUT_SLOT, inSlot);
|
||||||
return inSlot;
|
return inSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,6 +35,7 @@ AQHREACT_INPUT_SLOT *AQHREACT_InputSlot_new()
|
|||||||
void AQHREACT_InputSlot_free(AQHREACT_INPUT_SLOT *inSlot)
|
void AQHREACT_InputSlot_free(AQHREACT_INPUT_SLOT *inSlot)
|
||||||
{
|
{
|
||||||
if (inSlot) {
|
if (inSlot) {
|
||||||
|
GWEN_LIST_FINI(AQHREACT_INPUT_SLOT, inSlot);
|
||||||
free(inSlot->name);
|
free(inSlot->name);
|
||||||
free(inSlot->description);
|
free(inSlot->description);
|
||||||
AQHREACT_DataObject_free(inSlot->currentDataObject);
|
AQHREACT_DataObject_free(inSlot->currentDataObject);
|
||||||
@@ -41,6 +45,26 @@ void AQHREACT_InputSlot_free(AQHREACT_INPUT_SLOT *inSlot)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_INPUT_SLOT *AQHREACT_InputSlot_dup(const AQHREACT_INPUT_SLOT *origSlot)
|
||||||
|
{
|
||||||
|
if (origSlot) {
|
||||||
|
AQHREACT_INPUT_SLOT *inSlot;
|
||||||
|
|
||||||
|
inSlot=AQHREACT_InputSlot_new();
|
||||||
|
AQHREACT_InputSlot_SetName(inSlot, origSlot->name);
|
||||||
|
AQHREACT_InputSlot_SetDescription(inSlot, origSlot->description);
|
||||||
|
inSlot->idForUnit=origSlot->idForUnit;
|
||||||
|
inSlot->flags=origSlot->flags;
|
||||||
|
inSlot->acceptedDataType=origSlot->acceptedDataType;
|
||||||
|
/* don't copy current dataObject */
|
||||||
|
return inSlot;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char *AQHREACT_InputSlot_GetName(const AQHREACT_INPUT_SLOT *inSlot)
|
const char *AQHREACT_InputSlot_GetName(const AQHREACT_INPUT_SLOT *inSlot)
|
||||||
{
|
{
|
||||||
return inSlot?inSlot->name:NULL;
|
return inSlot?inSlot->name:NULL;
|
||||||
@@ -75,6 +99,21 @@ void AQHREACT_InputSlot_SetDescription(AQHREACT_INPUT_SLOT *inSlot, const char *
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQHREACT_InputSlot_GetIdForUnit(const AQHREACT_INPUT_SLOT *inSlot)
|
||||||
|
{
|
||||||
|
return inSlot?inSlot->idForUnit:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_InputSlot_SetIdForUnit(AQHREACT_INPUT_SLOT *inSlot, int i)
|
||||||
|
{
|
||||||
|
if (inSlot)
|
||||||
|
inSlot->idForUnit=i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint32_t AQHREACT_InputSlot_GetFlags(const AQHREACT_INPUT_SLOT *inSlot)
|
uint32_t AQHREACT_InputSlot_GetFlags(const AQHREACT_INPUT_SLOT *inSlot)
|
||||||
{
|
{
|
||||||
return inSlot?inSlot->flags:0;
|
return inSlot?inSlot->flags:0;
|
||||||
|
|||||||
@@ -12,13 +12,18 @@
|
|||||||
|
|
||||||
#include "aqhome-react/aqhome_react.h"
|
#include "aqhome-react/aqhome_react.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/list.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct AQHREACT_INPUT_SLOT AQHREACT_INPUT_SLOT;
|
typedef struct AQHREACT_INPUT_SLOT AQHREACT_INPUT_SLOT;
|
||||||
|
GWEN_LIST_FUNCTION_DEFS(AQHREACT_INPUT_SLOT, AQHREACT_InputSlot)
|
||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/types/dataobject.h"
|
#include "aqhome-react/types/dataobject.h"
|
||||||
|
|
||||||
|
|
||||||
AQHREACT_INPUT_SLOT *AQHREACT_InputSlot_new();
|
AQHREACT_INPUT_SLOT *AQHREACT_InputSlot_new();
|
||||||
|
AQHREACT_INPUT_SLOT *AQHREACT_InputSlot_dup(const AQHREACT_INPUT_SLOT *origSlot);
|
||||||
void AQHREACT_InputSlot_free(AQHREACT_INPUT_SLOT *inSlot);
|
void AQHREACT_InputSlot_free(AQHREACT_INPUT_SLOT *inSlot);
|
||||||
|
|
||||||
const char *AQHREACT_InputSlot_GetName(const AQHREACT_INPUT_SLOT *inSlot);
|
const char *AQHREACT_InputSlot_GetName(const AQHREACT_INPUT_SLOT *inSlot);
|
||||||
@@ -27,6 +32,9 @@ void AQHREACT_InputSlot_SetName(AQHREACT_INPUT_SLOT *inSlot, const char *s);
|
|||||||
const char *AQHREACT_InputSlot_GetDescription(const AQHREACT_INPUT_SLOT *inSlot);
|
const char *AQHREACT_InputSlot_GetDescription(const AQHREACT_INPUT_SLOT *inSlot);
|
||||||
void AQHREACT_InputSlot_SetDescription(AQHREACT_INPUT_SLOT *inSlot, const char *s);
|
void AQHREACT_InputSlot_SetDescription(AQHREACT_INPUT_SLOT *inSlot, const char *s);
|
||||||
|
|
||||||
|
int AQHREACT_InputSlot_GetIdForUnit(const AQHREACT_INPUT_SLOT *inSlot);
|
||||||
|
void AQHREACT_InputSlot_SetIdForUnit(AQHREACT_INPUT_SLOT *inSlot, int i);
|
||||||
|
|
||||||
uint32_t AQHREACT_InputSlot_GetFlags(const AQHREACT_INPUT_SLOT *inSlot);
|
uint32_t AQHREACT_InputSlot_GetFlags(const AQHREACT_INPUT_SLOT *inSlot);
|
||||||
void AQHREACT_InputSlot_SetFlags(AQHREACT_INPUT_SLOT *inSlot, uint32_t i);
|
void AQHREACT_InputSlot_SetFlags(AQHREACT_INPUT_SLOT *inSlot, uint32_t i);
|
||||||
void AQHREACT_InputSlot_AddFlags(AQHREACT_INPUT_SLOT *inSlot, uint32_t i);
|
void AQHREACT_InputSlot_AddFlags(AQHREACT_INPUT_SLOT *inSlot, uint32_t i);
|
||||||
|
|||||||
@@ -14,8 +14,11 @@
|
|||||||
|
|
||||||
|
|
||||||
struct AQHREACT_INPUT_SLOT {
|
struct AQHREACT_INPUT_SLOT {
|
||||||
|
GWEN_LIST_ELEMENT(AQHREACT_INPUT_SLOT)
|
||||||
|
|
||||||
char *name;
|
char *name;
|
||||||
char *description;
|
char *description;
|
||||||
|
int idForUnit;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
int acceptedDataType;
|
int acceptedDataType;
|
||||||
AQHREACT_DATAOBJECT *currentDataObject;
|
AQHREACT_DATAOBJECT *currentDataObject;
|
||||||
|
|||||||
93
apps/aqhome-react/types/link.c
Normal file
93
apps/aqhome-react/types/link.c
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* 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 "./link_p.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
GWEN_LIST_FUNCTIONS(AQHREACT_LINK, AQHREACT_Link)
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_LINK *AQHREACT_Link_new()
|
||||||
|
{
|
||||||
|
AQHREACT_LINK *lnk;
|
||||||
|
|
||||||
|
GWEN_NEW_OBJECT(AQHREACT_LINK, lnk);
|
||||||
|
GWEN_LIST_INIT(AQHREACT_LINK, lnk);
|
||||||
|
lnk->targetInputSlotIdx=-1;
|
||||||
|
|
||||||
|
return lnk;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Link_free(AQHREACT_LINK *lnk)
|
||||||
|
{
|
||||||
|
if (lnk) {
|
||||||
|
GWEN_LIST_FINI(AQHREACT_LINK, lnk);
|
||||||
|
free(lnk->targetUnitId);
|
||||||
|
GWEN_FREE_OBJECT(lnk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const char *AQHREACT_Link_GetTargetUnitId(const AQHREACT_LINK *lnk)
|
||||||
|
{
|
||||||
|
return lnk?lnk->targetUnitId:NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Link_SetTargetUnitId(AQHREACT_LINK *lnk, const char *s)
|
||||||
|
{
|
||||||
|
if (lnk) {
|
||||||
|
free(lnk->targetUnitId);
|
||||||
|
lnk->targetUnitId=s?strdup(s):NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQHREACT_Link_GetTargetInputSlotIdx(const AQHREACT_LINK *lnk)
|
||||||
|
{
|
||||||
|
return lnk?lnk->targetInputSlotIdx:-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Link_SetTargetInputSlotIdx(AQHREACT_LINK *lnk, int i)
|
||||||
|
{
|
||||||
|
if (lnk)
|
||||||
|
lnk->targetInputSlotIdx=i;;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_UNIT *AQHREACT_Link_GetTargetUnit(const AQHREACT_LINK *lnk)
|
||||||
|
{
|
||||||
|
return lnk?lnk->targetUnit:NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Link_SetTargetUnit(AQHREACT_LINK *lnk, AQHREACT_UNIT *unit)
|
||||||
|
{
|
||||||
|
if (lnk)
|
||||||
|
lnk->targetUnit=unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
38
apps/aqhome-react/types/link.h
Normal file
38
apps/aqhome-react/types/link.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* 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 AQHOME_REACT_LINK_H
|
||||||
|
#define AQHOME_REACT_LINK_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <gwenhywfar/list.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct AQHREACT_LINK AQHREACT_LINK;
|
||||||
|
GWEN_LIST_FUNCTION_DEFS(AQHREACT_LINK, AQHREACT_Link)
|
||||||
|
|
||||||
|
|
||||||
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_LINK *AQHREACT_Link_new();
|
||||||
|
void AQHREACT_Link_free(AQHREACT_LINK *lnk);
|
||||||
|
|
||||||
|
|
||||||
|
const char *AQHREACT_Link_GetTargetUnitId(const AQHREACT_LINK *lnk);
|
||||||
|
void AQHREACT_Link_SetTargetUnitId(AQHREACT_LINK *lnk, const char *s);
|
||||||
|
|
||||||
|
int AQHREACT_Link_GetTargetInputSlotIdx(const AQHREACT_LINK *lnk);
|
||||||
|
void AQHREACT_Link_SetTargetInputSlotIdx(AQHREACT_LINK *lnk, int i);
|
||||||
|
|
||||||
|
AQHREACT_UNIT *AQHREACT_Link_GetTargetUnit(const AQHREACT_LINK *lnk);
|
||||||
|
void AQHREACT_Link_SetTargetUnit(AQHREACT_LINK *lnk, AQHREACT_UNIT *unit);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
27
apps/aqhome-react/types/link_p.h
Normal file
27
apps/aqhome-react/types/link_p.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* 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 AQHOME_REACT_LINK_P_H
|
||||||
|
#define AQHOME_REACT_LINK_P_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "aqhome-react/types/link.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct AQHREACT_LINK {
|
||||||
|
GWEN_LIST_ELEMENT(AQHREACT_LINK)
|
||||||
|
|
||||||
|
char *targetUnitId;
|
||||||
|
int targetInputSlotIdx;
|
||||||
|
|
||||||
|
AQHREACT_UNIT *targetUnit;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
149
apps/aqhome-react/types/outputslot.c
Normal file
149
apps/aqhome-react/types/outputslot.c
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* 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 "./outputslot_p.h"
|
||||||
|
#include "aqhome-react/types/dataobject.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GWEN_LIST_FUNCTIONS(AQHREACT_OUTPUT_SLOT, AQHREACT_OutputSlot)
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_OUTPUT_SLOT *AQHREACT_OutputSlot_new()
|
||||||
|
{
|
||||||
|
AQHREACT_OUTPUT_SLOT *outSlot;
|
||||||
|
|
||||||
|
GWEN_NEW_OBJECT(AQHREACT_OUTPUT_SLOT, outSlot);
|
||||||
|
GWEN_LIST_INIT(AQHREACT_OUTPUT_SLOT, outSlot);
|
||||||
|
outSlot->linkList=AQHREACT_Link_List_new();
|
||||||
|
return outSlot;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_OutputSlot_free(AQHREACT_OUTPUT_SLOT *outSlot)
|
||||||
|
{
|
||||||
|
if (outSlot) {
|
||||||
|
GWEN_LIST_FINI(AQHREACT_OUTPUT_SLOT, outSlot);
|
||||||
|
free(outSlot->name);
|
||||||
|
free(outSlot->description);
|
||||||
|
AQHREACT_Link_List_free(outSlot->linkList);
|
||||||
|
GWEN_FREE_OBJECT(outSlot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const char *AQHREACT_OutputSlot_GetName(const AQHREACT_OUTPUT_SLOT *outSlot)
|
||||||
|
{
|
||||||
|
return outSlot?outSlot->name:NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_OutputSlot_SetName(AQHREACT_OUTPUT_SLOT *outSlot, const char *s)
|
||||||
|
{
|
||||||
|
if (outSlot) {
|
||||||
|
free(outSlot->name);
|
||||||
|
outSlot->name=s?strdup(s):NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const char *AQHREACT_OutputSlot_GetDescription(const AQHREACT_OUTPUT_SLOT *outSlot)
|
||||||
|
{
|
||||||
|
return outSlot?outSlot->description:NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_OutputSlot_SetDescription(AQHREACT_OUTPUT_SLOT *outSlot, const char *s)
|
||||||
|
{
|
||||||
|
if (outSlot) {
|
||||||
|
free(outSlot->description);
|
||||||
|
outSlot->description=s?strdup(s):NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t AQHREACT_OutputSlot_GetFlags(const AQHREACT_OUTPUT_SLOT *outSlot)
|
||||||
|
{
|
||||||
|
return outSlot?outSlot->flags:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_OutputSlot_SetFlags(AQHREACT_OUTPUT_SLOT *outSlot, uint32_t f)
|
||||||
|
{
|
||||||
|
if (outSlot)
|
||||||
|
outSlot->flags=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_OutputSlot_AddFlags(AQHREACT_OUTPUT_SLOT *outSlot, uint32_t f)
|
||||||
|
{
|
||||||
|
if (outSlot)
|
||||||
|
outSlot->flags|=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_OutputSlot_SubFlags(AQHREACT_OUTPUT_SLOT *outSlot, uint32_t f)
|
||||||
|
{
|
||||||
|
if (outSlot)
|
||||||
|
outSlot->flags&=~f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQHREACT_OutputSlot_GetEmittedDataType(const AQHREACT_OUTPUT_SLOT *outSlot)
|
||||||
|
{
|
||||||
|
return outSlot?outSlot->emittedDataType:AQHREACT_DATAOBJECTTYPE_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_OutputSlot_SetEmittedDataType(AQHREACT_OUTPUT_SLOT *outSlot, int i)
|
||||||
|
{
|
||||||
|
if (outSlot)
|
||||||
|
outSlot->emittedDataType=i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_LINK_LIST *AQHREACT_OutputSlot_GetLinkList(const AQHREACT_OUTPUT_SLOT *outSlot)
|
||||||
|
{
|
||||||
|
return outSlot?outSlot->linkList:NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_OutputSlot_AddLink(AQHREACT_OUTPUT_SLOT *outSlot, AQHREACT_LINK *lnk)
|
||||||
|
{
|
||||||
|
if (outSlot)
|
||||||
|
AQHREACT_Link_List_Add(lnk, outSlot->linkList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
49
apps/aqhome-react/types/outputslot.h
Normal file
49
apps/aqhome-react/types/outputslot.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* 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 AQHOME_REACT_OUTPUTSLOT_H
|
||||||
|
#define AQHOME_REACT_OUTPUTSLOT_H
|
||||||
|
|
||||||
|
#include "aqhome-react/aqhome_react.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/list.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct AQHREACT_OUTPUT_SLOT AQHREACT_OUTPUT_SLOT;
|
||||||
|
GWEN_LIST_FUNCTION_DEFS(AQHREACT_OUTPUT_SLOT, AQHREACT_OutputSlot)
|
||||||
|
|
||||||
|
|
||||||
|
#include "aqhome-react/types/link.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_OUTPUT_SLOT *AQHREACT_OutputSlot_new();
|
||||||
|
void AQHREACT_OutputSlot_free(AQHREACT_OUTPUT_SLOT *outSlot);
|
||||||
|
|
||||||
|
const char *AQHREACT_OutputSlot_GetName(const AQHREACT_OUTPUT_SLOT *outSlot);
|
||||||
|
void AQHREACT_OutputSlot_SetName(AQHREACT_OUTPUT_SLOT *outSlot, const char *s);
|
||||||
|
|
||||||
|
const char *AQHREACT_OutputSlot_GetDescription(const AQHREACT_OUTPUT_SLOT *outSlot);
|
||||||
|
void AQHREACT_OutputSlot_SetDescription(AQHREACT_OUTPUT_SLOT *outSlot, const char *s);
|
||||||
|
|
||||||
|
uint32_t AQHREACT_OutputSlot_GetFlags(const AQHREACT_OUTPUT_SLOT *outSlot);
|
||||||
|
void AQHREACT_OutputSlot_SetFlags(AQHREACT_OUTPUT_SLOT *outSlot, uint32_t f);
|
||||||
|
void AQHREACT_OutputSlot_AddFlags(AQHREACT_OUTPUT_SLOT *outSlot, uint32_t f);
|
||||||
|
void AQHREACT_OutputSlot_SubFlags(AQHREACT_OUTPUT_SLOT *outSlot, uint32_t f);
|
||||||
|
|
||||||
|
int AQHREACT_OutputSlot_GetEmittedDataType(const AQHREACT_OUTPUT_SLOT *outSlot);
|
||||||
|
void AQHREACT_OutputSlot_SetEmittedDataType(AQHREACT_OUTPUT_SLOT *outSlot, int i);
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_LINK_LIST *AQHREACT_OutputSlot_GetLinkList(const AQHREACT_OUTPUT_SLOT *outSlot);
|
||||||
|
void AQHREACT_OutputSlot_AddLink(AQHREACT_OUTPUT_SLOT *outSlot, AQHREACT_LINK *lnk);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
29
apps/aqhome-react/types/outputslot_p.h
Normal file
29
apps/aqhome-react/types/outputslot_p.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* 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 AQHOME_REACT_OUTPUTSLOT_P_H
|
||||||
|
#define AQHOME_REACT_OUTPUTSLOT_P_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "aqhome-react/types/outputslot.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct AQHREACT_OUTPUT_SLOT {
|
||||||
|
GWEN_LIST_ELEMENT(AQHREACT_OUTPUT_SLOT)
|
||||||
|
|
||||||
|
char *name;
|
||||||
|
char *description;
|
||||||
|
uint32_t flags;
|
||||||
|
int emittedDataType;
|
||||||
|
|
||||||
|
AQHREACT_LINK_LIST *linkList;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
162
apps/aqhome-react/types/param.c
Normal file
162
apps/aqhome-react/types/param.c
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* 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 "./param_p.h"
|
||||||
|
#include "./dataobject.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GWEN_LIST_FUNCTIONS(AQHREACT_PARAM, AQHREACT_Param)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_PARAM *AQHREACT_Param_new()
|
||||||
|
{
|
||||||
|
AQHREACT_PARAM *param;
|
||||||
|
|
||||||
|
GWEN_NEW_OBJECT(AQHREACT_PARAM, param);
|
||||||
|
GWEN_LIST_INIT(AQHREACT_PARAM, param);
|
||||||
|
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Param_free(AQHREACT_PARAM *param)
|
||||||
|
{
|
||||||
|
if (param) {
|
||||||
|
GWEN_LIST_FINI(AQHREACT_PARAM, param);
|
||||||
|
free(param->name);
|
||||||
|
free(param->description);
|
||||||
|
free(param->stringValue);
|
||||||
|
GWEN_FREE_OBJECT(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const char *AQHREACT_Param_GetName(const AQHREACT_PARAM *param)
|
||||||
|
{
|
||||||
|
return param?param->name:NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Param_SetName(AQHREACT_PARAM *param, const char *s)
|
||||||
|
{
|
||||||
|
if (param) {
|
||||||
|
free(param->name);
|
||||||
|
param->name=s?strdup(s):NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const char *AQHREACT_Param_GetDescription(const AQHREACT_PARAM *param)
|
||||||
|
{
|
||||||
|
return param?param->description:NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Param_SetDescription(AQHREACT_PARAM *param, const char *s)
|
||||||
|
{
|
||||||
|
if (param) {
|
||||||
|
free(param->description);
|
||||||
|
param->description=s?strdup(s):NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQHREACT_Param_GetDataType(const AQHREACT_PARAM *param)
|
||||||
|
{
|
||||||
|
return param?param->dataType:AQHREACT_DATAOBJECTTYPE_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Param_SetDataType(AQHREACT_PARAM *param, int i)
|
||||||
|
{
|
||||||
|
if (param)
|
||||||
|
param->dataType=i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const char *AQHREACT_Param_GetStringValue(const AQHREACT_PARAM *param)
|
||||||
|
{
|
||||||
|
return param?param->stringValue:NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Param_SetStringValue(AQHREACT_PARAM *param, const char *s)
|
||||||
|
{
|
||||||
|
if (param) {
|
||||||
|
free(param->stringValue);
|
||||||
|
param->stringValue=s?strdup(s):NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
double AQHREACT_Param_GetDoubleValue(const AQHREACT_PARAM *param)
|
||||||
|
{
|
||||||
|
return param?param->doubleValue:0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Param_SetDoubleValue(AQHREACT_PARAM *param, double d)
|
||||||
|
{
|
||||||
|
if (param)
|
||||||
|
param->doubleValue=d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t AQHREACT_Param_GetFlags(const AQHREACT_PARAM *param)
|
||||||
|
{
|
||||||
|
return param?param->flags:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Param_SetFlags(AQHREACT_PARAM *param, uint32_t f)
|
||||||
|
{
|
||||||
|
if (param)
|
||||||
|
param->flags=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Param_AddFlags(AQHREACT_PARAM *param, uint32_t f)
|
||||||
|
{
|
||||||
|
if (param)
|
||||||
|
param->flags|=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Param_SubFlags(AQHREACT_PARAM *param, uint32_t f)
|
||||||
|
{
|
||||||
|
if (param)
|
||||||
|
param->flags&=~f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
48
apps/aqhome-react/types/param.h
Normal file
48
apps/aqhome-react/types/param.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* 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 AQHOME_REACT_PARAM_H
|
||||||
|
#define AQHOME_REACT_PARAM_H
|
||||||
|
|
||||||
|
#include "aqhome-react/aqhome_react.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <gwenhywfar/list.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct AQHREACT_PARAM AQHREACT_PARAM;
|
||||||
|
GWEN_LIST_FUNCTION_DEFS(AQHREACT_PARAM, AQHREACT_Param)
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_PARAM *AQHREACT_Param_new();
|
||||||
|
void AQHREACT_Param_free(AQHREACT_PARAM *param);
|
||||||
|
|
||||||
|
const char *AQHREACT_Param_GetName(const AQHREACT_PARAM *param);
|
||||||
|
void AQHREACT_Param_SetName(AQHREACT_PARAM *param, const char *s);
|
||||||
|
|
||||||
|
const char *AQHREACT_Param_GetDescription(const AQHREACT_PARAM *param);
|
||||||
|
void AQHREACT_Param_SetDescription(AQHREACT_PARAM *param, const char *s);
|
||||||
|
|
||||||
|
int AQHREACT_Param_GetDataType(const AQHREACT_PARAM *param);
|
||||||
|
void AQHREACT_Param_SetDataType(AQHREACT_PARAM *param, int i);
|
||||||
|
|
||||||
|
const char *AQHREACT_Param_GetStringValue(const AQHREACT_PARAM *param);
|
||||||
|
void AQHREACT_Param_SetStringValue(AQHREACT_PARAM *param, const char *s);
|
||||||
|
|
||||||
|
double AQHREACT_Param_GetDoubleValue(const AQHREACT_PARAM *param);
|
||||||
|
void AQHREACT_Param_SetDoubleValue(AQHREACT_PARAM *param, double d);
|
||||||
|
|
||||||
|
uint32_t AQHREACT_Param_GetFlags(const AQHREACT_PARAM *param);
|
||||||
|
void AQHREACT_Param_SetFlags(AQHREACT_PARAM *param, uint32_t f);
|
||||||
|
void AQHREACT_Param_AddFlags(AQHREACT_PARAM *param, uint32_t f);
|
||||||
|
void AQHREACT_Param_SubFlags(AQHREACT_PARAM *param, uint32_t f);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
30
apps/aqhome-react/types/param_p.h
Normal file
30
apps/aqhome-react/types/param_p.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* 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 AQHOME_REACT_PARAM_P_H
|
||||||
|
#define AQHOME_REACT_PARAM_P_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "aqhome-react/types/param.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct AQHREACT_PARAM {
|
||||||
|
GWEN_LIST_ELEMENT(AQHREACT_PARAM)
|
||||||
|
|
||||||
|
char *name;
|
||||||
|
char *description;
|
||||||
|
int dataType;
|
||||||
|
char *stringValue;
|
||||||
|
double doubleValue;
|
||||||
|
|
||||||
|
uint32_t flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
335
apps/aqhome-react/types/unit.c
Normal file
335
apps/aqhome-react/types/unit.c
Normal file
@@ -0,0 +1,335 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqHome.
|
||||||
|
* AqHome (c) by 2023 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 "./unit_p.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
GWEN_LIST_FUNCTIONS(AQHREACT_UNIT, AQHREACT_Unit)
|
||||||
|
GWEN_INHERIT_FUNCTIONS(AQHREACT_UNIT)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_UNIT *AQHREACT_Unit_new()
|
||||||
|
{
|
||||||
|
AQHREACT_UNIT *unit;
|
||||||
|
|
||||||
|
GWEN_NEW_OBJECT(AQHREACT_UNIT, unit);
|
||||||
|
GWEN_INHERIT_INIT(AQHREACT_UNIT, unit);
|
||||||
|
GWEN_LIST_INIT(AQHREACT_UNIT, unit);
|
||||||
|
|
||||||
|
unit->inputSlotList=AQHREACT_InputSlot_List_new();
|
||||||
|
unit->outputSlotList=AQHREACT_OutputSlot_List_new();
|
||||||
|
unit->paramList=AQHREACT_Param_List_new();
|
||||||
|
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Unit_free(AQHREACT_UNIT *unit)
|
||||||
|
{
|
||||||
|
if (unit) {
|
||||||
|
GWEN_LIST_FINI(AQHREACT_UNIT, unit);
|
||||||
|
GWEN_INHERIT_FINI(AQHREACT_UNIT, unit);
|
||||||
|
free(unit->name);
|
||||||
|
free(unit->description);
|
||||||
|
AQHREACT_InputSlot_List_free(unit->inputSlotList);
|
||||||
|
AQHREACT_OutputSlot_List_free(unit->outputSlotList);
|
||||||
|
AQHREACT_Param_List_free(unit->paramList);
|
||||||
|
GWEN_FREE_OBJECT(unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const char *AQHREACT_Unit_GetName(const AQHREACT_UNIT *unit)
|
||||||
|
{
|
||||||
|
return unit?unit->name:NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Unit_SetName(AQHREACT_UNIT *unit, const char *s)
|
||||||
|
{
|
||||||
|
if (unit) {
|
||||||
|
free(unit->name);
|
||||||
|
unit->name=s?strdup(s):NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const char *AQHREACT_Unit_GetDescription(const AQHREACT_UNIT *unit)
|
||||||
|
{
|
||||||
|
return unit?unit->description:NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Unit_SetDescription(AQHREACT_UNIT *unit, const char *s)
|
||||||
|
{
|
||||||
|
if (unit) {
|
||||||
|
free(unit->description);
|
||||||
|
unit->description=s?strdup(s):NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const char *AQHREACT_Unit_GetId(const AQHREACT_UNIT *unit)
|
||||||
|
{
|
||||||
|
return unit?unit->id:NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Unit_SetId(AQHREACT_UNIT *unit, const char *s)
|
||||||
|
{
|
||||||
|
if (unit) {
|
||||||
|
free(unit->id);
|
||||||
|
unit->id=s?strdup(s):NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t AQHREACT_Unit_GetFlags(const AQHREACT_UNIT *unit)
|
||||||
|
{
|
||||||
|
return unit?unit->flags:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Unit_SetFlags(AQHREACT_UNIT *unit, uint32_t i)
|
||||||
|
{
|
||||||
|
if (unit)
|
||||||
|
unit->flags=i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Unit_AddFlags(AQHREACT_UNIT *unit, uint32_t i)
|
||||||
|
{
|
||||||
|
if (unit)
|
||||||
|
unit->flags|=i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Unit_SubFlags(AQHREACT_UNIT *unit, uint32_t i)
|
||||||
|
{
|
||||||
|
if (unit)
|
||||||
|
unit->flags&=~i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_INPUT_SLOT_LIST *AQHREACT_Unit_GetInputSlots(const AQHREACT_UNIT *unit)
|
||||||
|
{
|
||||||
|
return unit?unit->inputSlotList:NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Unit_AddInputSlot(AQHREACT_UNIT *unit, AQHREACT_INPUT_SLOT *inSlot)
|
||||||
|
{
|
||||||
|
if (unit)
|
||||||
|
AQHREACT_InputSlot_List_Add(inSlot, unit->inputSlotList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_OUTPUT_SLOT_LIST *AQHREACT_Unit_GetOutputSlots(const AQHREACT_UNIT *unit)
|
||||||
|
{
|
||||||
|
return unit?unit->outputSlotList:NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Unit_AddOutputSlot(AQHREACT_UNIT *unit, AQHREACT_OUTPUT_SLOT *outSlot)
|
||||||
|
{
|
||||||
|
if (unit)
|
||||||
|
AQHREACT_OutputSlot_List_Add(outSlot, unit->outputSlotList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_PARAM_LIST *AQHREACT_Unit_GetParamList(const AQHREACT_UNIT *unit)
|
||||||
|
{
|
||||||
|
return unit?unit->paramList:NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Unit_AddParam(AQHREACT_UNIT *unit, AQHREACT_PARAM *param)
|
||||||
|
{
|
||||||
|
if (unit)
|
||||||
|
AQHREACT_Param_List_Add(param, unit->paramList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_UNIT_INPUTDATA_FN AQHREACT_Unit_SetInputDataFn(AQHREACT_UNIT *unit, AQHREACT_UNIT_INPUTDATA_FN f)
|
||||||
|
{
|
||||||
|
if (unit) {
|
||||||
|
AQHREACT_UNIT_INPUTDATA_FN oldFn;
|
||||||
|
|
||||||
|
oldFn=unit->inputDataFn;
|
||||||
|
unit->inputDataFn=f;
|
||||||
|
return oldFn;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_UNIT_PROCESS_FN AQHREACT_Unit_SetProcessFn(AQHREACT_UNIT *unit, AQHREACT_UNIT_PROCESS_FN f)
|
||||||
|
{
|
||||||
|
if (unit) {
|
||||||
|
AQHREACT_UNIT_PROCESS_FN oldFn;
|
||||||
|
|
||||||
|
oldFn=unit->processFn;
|
||||||
|
unit->processFn=f;
|
||||||
|
return oldFn;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Unit_OutputData(AQHREACT_UNIT *unit, int slotIndex, const AQHREACT_DATAOBJECT *dataObject)
|
||||||
|
{
|
||||||
|
if (unit && unit->outputSlotList) {
|
||||||
|
AQHREACT_OUTPUT_SLOT *slot;
|
||||||
|
|
||||||
|
slot=AQHREACT_Unit_GetOutputSlotAt(unit, slotIndex);
|
||||||
|
if (slot) {
|
||||||
|
AQHREACT_LINK_LIST *linkList;
|
||||||
|
|
||||||
|
linkList=AQHREACT_OutputSlot_GetLinkList(slot);
|
||||||
|
if (linkList) {
|
||||||
|
AQHREACT_LINK *lnk;
|
||||||
|
|
||||||
|
lnk=AQHREACT_Link_List_First(linkList);
|
||||||
|
while(lnk) {
|
||||||
|
AQHREACT_UNIT *targetUnit;
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
targetUnit=AQHREACT_Link_GetTargetUnit(lnk);
|
||||||
|
idx=AQHREACT_Link_GetTargetInputSlotIdx(lnk);
|
||||||
|
if (targetUnit && idx>=0)
|
||||||
|
AQHREACT_Unit_InputData(targetUnit, idx, dataObject);
|
||||||
|
lnk=AQHREACT_Link_List_Next(lnk);
|
||||||
|
} /* while */
|
||||||
|
} /* if linkList */
|
||||||
|
} /* if slot */
|
||||||
|
} /* if unit */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Unit_InputData(AQHREACT_UNIT *unit, int slotIndex, const AQHREACT_DATAOBJECT *dataObject)
|
||||||
|
{
|
||||||
|
if (unit) {
|
||||||
|
if (unit->inputDataFn)
|
||||||
|
(unit->inputDataFn)(unit, slotIndex, dataObject);
|
||||||
|
else {
|
||||||
|
AQHREACT_Unit_ClearChangeFlagsInUnitAndInputSlots(unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DBG_ERROR(NULL, "Nullpointer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQHREACT_Unit_Process(AQHREACT_UNIT *unit)
|
||||||
|
{
|
||||||
|
if (unit) {
|
||||||
|
if (unit->processFn)
|
||||||
|
return (unit->processFn)(unit);
|
||||||
|
else {
|
||||||
|
AQHREACT_INPUT_SLOT *slot;
|
||||||
|
|
||||||
|
unit->flags&=~AQHREACT_UNIT_FLAGS_CHANGED;
|
||||||
|
slot=AQHREACT_InputSlot_List_First(unit->inputSlotList);
|
||||||
|
while(slot) {
|
||||||
|
AQHREACT_InputSlot_SubFlags(slot, AQHREACT_UNIT_FLAGS_CHANGED);
|
||||||
|
slot=AQHREACT_InputSlot_List_Next(slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_INPUT_SLOT *AQHREACT_Unit_GetInputSlotAt(AQHREACT_UNIT *unit, int idx)
|
||||||
|
{
|
||||||
|
if (unit && unit->inputSlotList && idx>=0) {
|
||||||
|
AQHREACT_INPUT_SLOT *slot;
|
||||||
|
|
||||||
|
slot=AQHREACT_InputSlot_List_First(unit->inputSlotList);
|
||||||
|
while(slot && idx) {
|
||||||
|
slot=AQHREACT_InputSlot_List_Next(slot);
|
||||||
|
idx--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_OUTPUT_SLOT *AQHREACT_Unit_GetOutputSlotAt(AQHREACT_UNIT *unit, int idx)
|
||||||
|
{
|
||||||
|
if (unit && unit->outputSlotList && idx>=0) {
|
||||||
|
AQHREACT_OUTPUT_SLOT *slot;
|
||||||
|
|
||||||
|
slot=AQHREACT_OutputSlot_List_First(unit->outputSlotList);
|
||||||
|
while(slot && idx) {
|
||||||
|
slot=AQHREACT_OutputSlot_List_Next(slot);
|
||||||
|
idx--;
|
||||||
|
}
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Unit_ClearChangeFlagsInUnitAndInputSlots(AQHREACT_UNIT *unit)
|
||||||
|
{
|
||||||
|
if (unit) {
|
||||||
|
AQHREACT_INPUT_SLOT *slot;
|
||||||
|
|
||||||
|
unit->flags&=~AQHREACT_UNIT_FLAGS_CHANGED;
|
||||||
|
slot=AQHREACT_InputSlot_List_First(unit->inputSlotList);
|
||||||
|
while(slot) {
|
||||||
|
AQHREACT_InputSlot_SubFlags(slot, AQHREACT_UNIT_FLAGS_CHANGED);
|
||||||
|
slot=AQHREACT_InputSlot_List_Next(slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
84
apps/aqhome-react/types/unit.h
Normal file
84
apps/aqhome-react/types/unit.h
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqHome.
|
||||||
|
* AqHome (c) by 2023 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 AQHOME_REACT_UNIT_H
|
||||||
|
#define AQHOME_REACT_UNIT_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "aqhome-react/aqhome_react.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/list.h>
|
||||||
|
#include <gwenhywfar/inherit.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct AQHREACT_UNIT AQHREACT_UNIT;
|
||||||
|
GWEN_LIST_FUNCTION_DEFS(AQHREACT_UNIT, AQHREACT_Unit)
|
||||||
|
GWEN_INHERIT_FUNCTION_DEFS(AQHREACT_UNIT)
|
||||||
|
|
||||||
|
|
||||||
|
#define AQHREACT_UNIT_FLAGS_CHANGED 0x80000000
|
||||||
|
#define AQHREACT_UNIT_FLAGS_INUSE 0x40000000
|
||||||
|
#define AQHREACT_UNIT_FLAGS_MULTI 0x20000000
|
||||||
|
|
||||||
|
|
||||||
|
#include "aqhome-react/types/inputslot.h"
|
||||||
|
#include "aqhome-react/types/outputslot.h"
|
||||||
|
#include "aqhome-react/types/param.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef void (*AQHREACT_UNIT_INPUTDATA_FN)(AQHREACT_UNIT *unit, int slotIndex, const AQHREACT_DATAOBJECT *dataObject);
|
||||||
|
typedef int (*AQHREACT_UNIT_PROCESS_FN)(AQHREACT_UNIT *unit);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_UNIT *AQHREACT_Unit_new();
|
||||||
|
void AQHREACT_Unit_free(AQHREACT_UNIT *unit);
|
||||||
|
|
||||||
|
const char *AQHREACT_Unit_GetName(const AQHREACT_UNIT *unit);
|
||||||
|
void AQHREACT_Unit_SetName(AQHREACT_UNIT *unit, const char *s);
|
||||||
|
|
||||||
|
const char *AQHREACT_Unit_GetDescription(const AQHREACT_UNIT *unit);
|
||||||
|
void AQHREACT_Unit_SetDescription(AQHREACT_UNIT *unit, const char *s);
|
||||||
|
|
||||||
|
const char *AQHREACT_Unit_GetId(const AQHREACT_UNIT *unit);
|
||||||
|
void AQHREACT_Unit_SetId(AQHREACT_UNIT *unit, const char *s);
|
||||||
|
|
||||||
|
uint32_t AQHREACT_Unit_GetFlags(const AQHREACT_UNIT *unit);
|
||||||
|
void AQHREACT_Unit_SetFlags(AQHREACT_UNIT *unit, uint32_t i);
|
||||||
|
void AQHREACT_Unit_AddFlags(AQHREACT_UNIT *unit, uint32_t i);
|
||||||
|
void AQHREACT_Unit_SubFlags(AQHREACT_UNIT *unit, uint32_t i);
|
||||||
|
|
||||||
|
AQHREACT_INPUT_SLOT_LIST *AQHREACT_Unit_GetInputSlots(const AQHREACT_UNIT *unit);
|
||||||
|
void AQHREACT_Unit_AddInputSlot(AQHREACT_UNIT *unit, AQHREACT_INPUT_SLOT *inSlot);
|
||||||
|
AQHREACT_INPUT_SLOT *AQHREACT_Unit_GetInputSlotAt(AQHREACT_UNIT *unit, int idx);
|
||||||
|
|
||||||
|
AQHREACT_OUTPUT_SLOT_LIST *AQHREACT_Unit_GetOutputSlots(const AQHREACT_UNIT *unit);
|
||||||
|
void AQHREACT_Unit_AddOutputSlot(AQHREACT_UNIT *unit, AQHREACT_OUTPUT_SLOT *outSlot);
|
||||||
|
AQHREACT_OUTPUT_SLOT *AQHREACT_Unit_GetOutputSlotAt(AQHREACT_UNIT *unit, int idx);
|
||||||
|
|
||||||
|
void AQHREACT_Unit_ClearChangeFlagsInUnitAndInputSlots(AQHREACT_UNIT *unit);
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_PARAM_LIST *AQHREACT_Unit_GetParamList(const AQHREACT_UNIT *unit);
|
||||||
|
void AQHREACT_Unit_AddParam(AQHREACT_UNIT *unit, AQHREACT_PARAM *param);
|
||||||
|
|
||||||
|
|
||||||
|
void AQHREACT_Unit_OutputData(AQHREACT_UNIT *unit, int slotIndex, const AQHREACT_DATAOBJECT *dataObject);
|
||||||
|
|
||||||
|
void AQHREACT_Unit_InputData(AQHREACT_UNIT *unit, int slotIndex, const AQHREACT_DATAOBJECT *dataObject);
|
||||||
|
|
||||||
|
int AQHREACT_Unit_Process(AQHREACT_UNIT *unit);
|
||||||
|
|
||||||
|
|
||||||
|
AQHREACT_UNIT_INPUTDATA_FN AQHREACT_Unit_SetInputDataFn(AQHREACT_UNIT *unit, AQHREACT_UNIT_INPUTDATA_FN f);
|
||||||
|
AQHREACT_UNIT_PROCESS_FN AQHREACT_Unit_SetProcessFn(AQHREACT_UNIT *unit, AQHREACT_UNIT_PROCESS_FN f);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
37
apps/aqhome-react/types/unit_p.h
Normal file
37
apps/aqhome-react/types/unit_p.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqHome.
|
||||||
|
* AqHome (c) by 2023 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 AQHOME_REACT_UNIT_P_H
|
||||||
|
#define AQHOME_REACT_UNIT_P_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct AQHREACT_UNIT {
|
||||||
|
GWEN_INHERIT_ELEMENT(AQHREACT_UNIT)
|
||||||
|
GWEN_LIST_ELEMENT(AQHREACT_UNIT)
|
||||||
|
|
||||||
|
char *name;
|
||||||
|
char *description;
|
||||||
|
char *id;
|
||||||
|
|
||||||
|
uint32_t flags;
|
||||||
|
|
||||||
|
AQHREACT_INPUT_SLOT_LIST *inputSlotList;
|
||||||
|
AQHREACT_OUTPUT_SLOT_LIST *outputSlotList;
|
||||||
|
|
||||||
|
AQHREACT_PARAM_LIST *paramList;
|
||||||
|
|
||||||
|
AQHREACT_UNIT_INPUTDATA_FN inputDataFn;
|
||||||
|
AQHREACT_UNIT_PROCESS_FN processFn;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
Reference in New Issue
Block a user