aqhome-react: major rebuild of unit handling.

now nested networks are allowed to allow for complex networks.
This commit is contained in:
Martin Preuss
2024-04-17 22:26:17 +02:00
parent ec816bddcf
commit 1050ee1c75
34 changed files with 1336 additions and 1616 deletions

View File

@@ -96,7 +96,11 @@ int AqHomeReact_Init(AQHOME_REACT *aqh, int argc, char **argv)
}
}
AqHomeReact_ReloadUnitNets(aqh);
rv=AqHomeReact_ReloadUnitNets(aqh);
if (rv<0) {
DBG_ERROR(NULL, "Error reading unit network files (%d)", rv);
return rv;
}
rv=_setupBroker(aqh, dbArgs);
if (rv<0) {
@@ -109,33 +113,31 @@ int AqHomeReact_Init(AQHOME_REACT *aqh, int argc, char **argv)
void AqHomeReact_ReloadUnitNets(AQHOME_REACT *aqh)
int AqHomeReact_ReloadUnitNets(AQHOME_REACT *aqh)
{
AQHREACT_UNIT_NET_LIST *unitNetList;
int rv;
AQHREACT_UnitNet_List_Clear(aqh->unitNetList);
AQHREACT_Unit_List_Clear(aqh->unitList);
aqh->timerUnit=NULL;
aqh->varChangeUnit=NULL;
_setupBuiltinUnits(aqh);
unitNetList=AQHomeReact_ReadUnitNetFiles(aqh);
if (unitNetList) {
AQHREACT_UnitNet_List_free(aqh->unitNetList);
aqh->unitNetList=unitNetList;
{
GWEN_BUFFER *dbuf;
rv=AQHomeReact_ReadUnitNetFiles(aqh);
if (rv<0) {
DBG_ERROR(NULL, "Error reading network files (%d)", rv);
return rv;
}
{
GWEN_BUFFER *dbuf;
dbuf=GWEN_Buffer_new(0, 256, 0, 1);
AQHREACT_UnitNet_List_Dump(unitNetList, dbuf, 2, "Loaded networks:");
fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(dbuf));
GWEN_Buffer_free(dbuf);
}
}
else {
DBG_INFO(NULL, "No unit nets read");
}
dbuf=GWEN_Buffer_new(0, 256, 0, 1);
AQHREACT_Unit_List_Dump(aqh->unitList, dbuf, 2, "Loaded networks:");
fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(dbuf));
GWEN_Buffer_free(dbuf);
}
return 0;
}