From ea581ee1909b082b1b1065d7a03fb2bee126d0a1 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 3 Jun 2021 12:31:05 +0200 Subject: [PATCH] Ancora refine grafici e dato ordini --- GWMS.Data/Controllers/GWMSController.cs | 30 ++++++++++++++++++++----- GWMS.Data/DTO/PlantDTO.cs | 2 ++ GWMS.UI/Components/PlantDetail.razor | 11 ++++----- GWMS.UI/Components/PlantDetail.razor.cs | 26 ++++++--------------- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 7 files changed, 42 insertions(+), 33 deletions(-) diff --git a/GWMS.Data/Controllers/GWMSController.cs b/GWMS.Data/Controllers/GWMSController.cs index dc893c2..9704e89 100644 --- a/GWMS.Data/Controllers/GWMSController.cs +++ b/GWMS.Data/Controllers/GWMSController.cs @@ -99,16 +99,33 @@ namespace GWMS.Data.Controllers // FIXME TODO !!!! รจ casuale Random rnd = new Random(); + int soglia01 = rnd.Next(6000, 7500); + int soglia02 = rnd.Next(1000, 3000); var simLevel = rnd.Next(1, (int)currPlant.LevelMax); List SimLevelTS = new List(); + List SimOrderTS = new List(); DateTime adesso = DateTime.Now; int lastLevel = simLevel; - for (int i = 100; i > 0; i--) + int lastOrder = 0; + int anticipo = 0; + for (int i = 200; i > 0; i--) { - lastLevel = lastLevel - rnd.Next(0, 100); - // se < 500 --> rialzo - lastLevel = lastLevel < 1000 ? 9000 : lastLevel; - SimLevelTS.Add(new TSData() { DtEvent = adesso.AddMinutes(-i * 3), ValDouble = lastLevel }); + anticipo = i * 30; + lastLevel = lastLevel - rnd.Next(0, 200); + // se inferiore a soglia 1 --> ordine + if (lastLevel + lastOrder < soglia01) + { + lastOrder = rnd.Next(10000 - soglia01, 10000 - soglia02); + SimOrderTS.Add(new TSData() { DtEvent = adesso.AddMinutes(-anticipo), ValDouble = lastOrder }); + } + + // se inferiore a soglia 2 --> refill + if (lastLevel < soglia02) + { + lastLevel += lastOrder; + lastOrder = 0; + } + SimLevelTS.Add(new TSData() { DtEvent = adesso.AddMinutes(-anticipo), ValDouble = lastLevel }); //SimLevelTS.Add(new TSData() { DtEvent = adesso.AddMinutes(-i), ValDouble = simLevel + i * 20 + rnd.Next(0, 5) }); } @@ -119,7 +136,8 @@ namespace GWMS.Data.Controllers PlantDesc = currPlant.PlantDesc, LevelAct = simLevel, LevelMax = currPlant.LevelMax, - LevelTS = SimLevelTS + LevelTS = SimLevelTS, + OrderTS = SimOrderTS }; return answ; } diff --git a/GWMS.Data/DTO/PlantDTO.cs b/GWMS.Data/DTO/PlantDTO.cs index 87cd3d9..bfaf564 100644 --- a/GWMS.Data/DTO/PlantDTO.cs +++ b/GWMS.Data/DTO/PlantDTO.cs @@ -35,6 +35,8 @@ namespace GWMS.Data.DTO public List LevelTS { get; set; } = new List(); + public List OrderTS { get; set; } = new List(); + public double TempMax { get; set; } = 40; public double TempAct { get; set; } = 0; diff --git a/GWMS.UI/Components/PlantDetail.razor b/GWMS.UI/Components/PlantDetail.razor index 8259e4a..aa1a96b 100644 --- a/GWMS.UI/Components/PlantDetail.razor +++ b/GWMS.UI/Components/PlantDetail.razor @@ -19,7 +19,7 @@
-
+
Livello
@@ -28,7 +28,7 @@
@currItem.LevelMax
-
+
@currItem.LevelRatio %
@@ -36,15 +36,16 @@
-
- # ordini +
+ ordini: +
@currItem.OrderTS.Count
-
+
Immagine impianto
diff --git a/GWMS.UI/Components/PlantDetail.razor.cs b/GWMS.UI/Components/PlantDetail.razor.cs index d714d29..e4aee48 100644 --- a/GWMS.UI/Components/PlantDetail.razor.cs +++ b/GWMS.UI/Components/PlantDetail.razor.cs @@ -79,6 +79,7 @@ namespace GWMS.UI.Components { var dataReload = Task.Run(async () => { + // aggiunta delay o non riesce a disegnare Thread.Sleep(50); await HandleRedraw(); }); @@ -96,9 +97,10 @@ namespace GWMS.UI.Components { //Label = "Livello", Data = _currItem.LevelTS.Select(x => x.ValDouble).ToList(), - BorderColor = backgroundColors(1, 1f), + BorderColor = getLineColors(1f), Fill = true, - PointRadius = 2, + PointRadius = 3, + BorderWidth = 2, LineTension = 0, BorderDash = new List { } }; @@ -107,7 +109,7 @@ namespace GWMS.UI.Components private List GetLineChartLabels() { - var answ = _currItem.LevelTS.Select(x => x.DtEvent.ToString("ddd dd.MM HH:mm")).ToList(); + var answ = _currItem.LevelTS.Select(x => x.DtEvent.ToString("dd.MM HH:mm")).ToList(); return answ; } @@ -120,24 +122,10 @@ namespace GWMS.UI.Components /// /// /// - protected List backgroundColors(int numRecords, float alpha) + protected List getLineColors(float alpha) { List answ = new List(); - // verde... - for (int i = 0; i < numRecords / 3; i++) - { - answ.Add(ChartColor.FromRgba(54, 235, 82, alpha)); - } - // arancione - for (int i = 0; i < numRecords / 3; i++) - { - answ.Add(ChartColor.FromRgba(255, 206, 86, alpha)); - } - while (answ.Count < numRecords) - { - answ.Add(ChartColor.FromRgba(255, 99, 132, alpha)); - } - + answ.Add(ChartColor.FromRgba(54, 82, 254, alpha)); return answ; } diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index d1174d3..d7db4a8 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo statistiche MAPO -

Versione: 1.0.2106.0311

+

Versione: 1.0.2106.0312


Note di rilascio:
    diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 56320f4..eb8a50d 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2106.0311 +1.0.2106.0312 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 06092df..6f65650 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2106.0311 + 1.0.2106.0312 http://nexus.steamware.net/repository/SWS/MP-STATS/stable/0/GWMS.UI.zip http://nexus.steamware.net/repository/SWS/MP-STATS/stable/0/ChangeLog.html false