From bbcf45a00be5898adec6a10f776647733f4457a2 Mon Sep 17 00:00:00 2001 From: Luc-Sol Date: Thu, 15 May 2025 12:17:24 +0200 Subject: [PATCH 1/7] PV sliders Split collection ordered PV Systems into two, one for houses and one for companies. Started working on list of GCs as argument to the slider functions. Added the function that calculates the percentage --- .../Agents/Zero_Interface/Code/Functions.java | 30 +++++++++- _alp/Agents/Zero_Interface/Variables.xml | 40 +++++++++---- .../Agents/tabElectricity/Code/Functions.java | 56 +++++++++++++++---- _alp/Agents/tabElectricity/Code/Functions.xml | 46 +++++++++++++++ .../tabElectricity/Levels/Level.level.xml | 25 +++++++++ 5 files changed, 171 insertions(+), 26 deletions(-) diff --git a/_alp/Agents/Zero_Interface/Code/Functions.java b/_alp/Agents/Zero_Interface/Code/Functions.java index 0b0c5d1e..2b07a992 100644 --- a/_alp/Agents/Zero_Interface/Code/Functions.java +++ b/_alp/Agents/Zero_Interface/Code/Functions.java @@ -615,6 +615,7 @@ else if (v_previousClickedObjectType == OL_GISObjectType.BUILDING || double f_initialPVSystemsOrder() {/*ALCODESTART::1714130288661*/ +/* // First we make a copy of all the Uitility GridConnections List GCs = new ArrayList<>(energyModel.f_getGridConnections()); List GCs_detailedCompanies = new ArrayList<>(energyModel.f_getGridConnections()); @@ -643,6 +644,29 @@ else if (v_previousClickedObjectType == OL_GISObjectType.BUILDING || c_orderedPVSystems = otherGCs; c_orderedPVSystems.addAll(datailedCompanyGCsnoPV); +*/ + +List houses = new ArrayList(energyModel.Houses.findAll( x -> true)); +List housesWithoutPV = houses.stream().filter( gc -> !gc.v_hasPV ).collect(Collectors.toList()); +List housesWithPV = new ArrayList<>(houses); +housesWithPV.removeAll(housesWithoutPV); + +c_orderedPVSystemsHouses = new ArrayList<>(housesWithoutPV); +c_orderedPVSystemsHouses.addAll(housesWithPV); + + +List companies = new ArrayList(energyModel.UtilityConnections.findAll( x -> true)); +List companiesWithoutPV = companies.stream().filter( gc -> !gc.v_hasPV ).collect(Collectors.toList()); +List companiesWithPV = companies.stream().filter( gc -> gc.v_hasPV ).collect(Collectors.toList()); +List detailedCompaniesWithPV = companiesWithPV.stream().filter( gc -> gc.p_owner != null && gc.p_owner.p_detailedCompany ).collect(Collectors.toList()); +List genericCompaniesWithPV = new ArrayList<>(companiesWithPV); +genericCompaniesWithPV.removeAll(detailedCompaniesWithPV); + +c_orderedPVSystemsCompanies = new ArrayList<>(companiesWithoutPV); +c_orderedPVSystemsCompanies.addAll(genericCompaniesWithPV); +c_orderedPVSystemsCompanies.addAll(detailedCompaniesWithPV); + + /*ALCODEEND*/} double f_initialElectricVehiclesOrder() @@ -1021,7 +1045,7 @@ else if (vehicle instanceof J_EAHydrogenVehicle && vehicle.getEAType() == OL_Ene double f_setColorsBasedOnGridTopology_objects(GIS_Object gis_area) {/*ALCODESTART::1718566260603*/ if (gis_area.c_containedGridConnections.size() > 0) { - Color c = gis_area.c_containedGridConnections.get(0).l_parentNodeElectric.getConnectedAgent().p_uniqueColor; + Color c = gis_area.c_containedGridConnections.get(0).p_parentNodeElectric.p_uniqueColor; gis_area.f_style(c, black, 1.0, null); } /*ALCODEEND*/} @@ -1614,7 +1638,7 @@ else if(c_selectedFilterOptions.contains(selectedFilter_OL)){ // Remove filter if (b.gisRegion.isVisible()) { //only allow us to click on visible objects if (b.c_containedGridConnections.size() > 0 ) { // only allow buildings with gridconnections GridConnection clickedGridConnection = b.c_containedGridConnections.get(0); // Find buildings powered by the same GC as the clicked building - GridNode clickedGridConnectionConnectedGridNode = clickedGridConnection.l_parentNodeElectric.getConnectedAgent(); + GridNode clickedGridConnectionConnectedGridNode = clickedGridConnection.p_parentNodeElectric; ArrayList allGridNodes = new ArrayList(energyModel.f_getGridNodesTopLevel()); allGridNodes.addAll(energyModel.f_getGridNodesNotTopLevel()); @@ -1626,7 +1650,7 @@ else if(c_selectedFilterOptions.contains(selectedFilter_OL)){ // Remove filter clickedGridConnectionConnectedGridNode = findFirst(allGridNodes, GN -> GN.p_gridNodeID.equals(parentNodeName)); } else{ // At top node --> select the directly attached grid node instead, and break out of while loop. - clickedGridConnectionConnectedGridNode = clickedGridConnection.l_parentNodeElectric.getConnectedAgent(); + clickedGridConnectionConnectedGridNode = clickedGridConnection.p_parentNodeElectric; break; } } diff --git a/_alp/Agents/Zero_Interface/Variables.xml b/_alp/Agents/Zero_Interface/Variables.xml index 6c12cb15..033b1208 100644 --- a/_alp/Agents/Zero_Interface/Variables.xml +++ b/_alp/Agents/Zero_Interface/Variables.xml @@ -2411,7 +2411,7 @@ 1715178022675 68 - -550 + -535