From 51cdedb1198625c7b0ec7f12481119626f564900 Mon Sep 17 00:00:00 2001 From: aorzelskiGH Date: Thu, 4 Jul 2024 13:41:59 +0200 Subject: [PATCH] PCF value for testing Property with total PCF value GET by API for automatic testing --- .../Properties/launchSettings.json | 4 +-- src/AasxServerStandardBib/SecurityClient.cs | 35 ++++++++++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/AasxServerBlazor/Properties/launchSettings.json b/src/AasxServerBlazor/Properties/launchSettings.json index 2237077ac..318a980f1 100644 --- a/src/AasxServerBlazor/Properties/launchSettings.json +++ b/src/AasxServerBlazor/Properties/launchSettings.json @@ -10,11 +10,11 @@ }, "AasxServerBlazor": { "commandName": "Project", - "commandLineArgs": "--no-security --secret-string-api 1234 --aasx-in-memory 1000 --data-path \"\\\\wsl.localhost\\Ubuntu\\home\\oze\\Integration-Plugfest\\aasxs-registry\" --edit --external-blazor http://localhost:5001", + "commandLineArgs": "--no-security --secret-string-api 1234 --aasx-in-memory 1000 --data-path \"C:\\Development\\PCF View\" --edit --external-blazor http://localhost:5001", "launchBrowser": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", - "AASREGISTRY": "http://localhost:50001", + "AASREGISTRY": "https://registry.dpp40-2-v2.industrialdigitaltwin.org/", "IFRAMEPATH": "https://dpp40-2-v2.industrialdigitaltwin.org/dashboard/submodelViewV3.html" }, "applicationUrl": "http://localhost:5001", diff --git a/src/AasxServerStandardBib/SecurityClient.cs b/src/AasxServerStandardBib/SecurityClient.cs index 0231479c1..e014ec0ed 100644 --- a/src/AasxServerStandardBib/SecurityClient.cs +++ b/src/AasxServerStandardBib/SecurityClient.cs @@ -1580,6 +1580,7 @@ public class cfpNode public static cfpNode root = null; public static string asbuilt_total = null; + public static Property pCO2eqTotal = null; public static bool cfpValid = false; public static DateTime lastCreateTimestamp = new DateTime(); public static bool credentialsChanged = false; @@ -1754,7 +1755,8 @@ public static bool createCfpTree(int envIndex, DateTime timeStamp) Dictionary assetCfp = new Dictionary(); // cfpNode root = new cfpNode(); aascount = AasxServer.Program.env.Length; - root = null; + root = null; + ISubmodel co2eqSubmodel = null; // Collect data from all AAS into cfpNode(s) for (int i = 0; i < aascount; i++) @@ -1789,7 +1791,8 @@ public static bool createCfpTree(int envIndex, DateTime timeStamp) } if (sm.SubmodelElements != null) - { + { + co2eqSubmodel = sm; foreach (var v in sm.SubmodelElements) { if (v is SubmodelElementCollection c) @@ -1806,7 +1809,7 @@ public static bool createCfpTree(int envIndex, DateTime timeStamp) case "LifeCyclePhase": lifeCyclePhase = v2.ValueAsText(); break; - case "CO2eq": + case "CO2eq": co2eq = v2 as Property; break; } @@ -1874,6 +1877,7 @@ public static bool createCfpTree(int envIndex, DateTime timeStamp) if (sm.SubmodelElements != null) { + co2eqSubmodel = sm; foreach (var v in sm.SubmodelElements) { if (v is SubmodelElementCollection c) @@ -2111,7 +2115,26 @@ public static bool createCfpTree(int envIndex, DateTime timeStamp) { //TODO: elements need proper deep clone method implemented within AAS metamodel classes if (asbuilt_total == null) - asbuilt_total = new String(root.cradleToGateCombination.Value); + asbuilt_total = new String(root.cradleToGateCombination.Value); + if (co2eqSubmodel != null) + { + pCO2eqTotal = null; + foreach (var sme in co2eqSubmodel.SubmodelElements) + { + if (sme is Property p && p.IdShort == "CO2eqTotal") + { + pCO2eqTotal = p; + } + } + if (pCO2eqTotal == null) + { + pCO2eqTotal = new Property(DataTypeDefXsd.String, idShort: "CO2eqTotal"); + co2eqSubmodel.SubmodelElements.Add(pCO2eqTotal); + pCO2eqTotal.SetAllParentsAndTimestamps(co2eqSubmodel, timeStamp, co2eqSubmodel.TimeStampCreate); + pCO2eqTotal.SetTimeStamp(timeStamp); + pCO2eqTotal.Value = "0"; + } + } } if (Program.showWeight && root.weightCombination != null) @@ -2339,6 +2362,10 @@ public static void operation_calculate_cfp(Operation op, int envIndex, DateTime } } + if (pCO2eqTotal != null) + { + pCO2eqTotal.Value = root.cradleToGateCombination.Value; + } // once = true; // if (root != null && root.bomTimestamp > lastCreateTimestamp) if (changed || credentialsChanged)