diff --git a/MP.IOC/Components/Pages/CallStats.razor b/MP.IOC/Components/Pages/CallStats.razor index 8aeac068..a5e5ecdb 100644 --- a/MP.IOC/Components/Pages/CallStats.razor +++ b/MP.IOC/Components/Pages/CallStats.razor @@ -69,13 +69,7 @@ } else { -
- @tsDataDetail.Count values - - @* *@ - - -
+ } } diff --git a/MP.IOC/Components/Pages/CallStats.razor.cs b/MP.IOC/Components/Pages/CallStats.razor.cs index b25c8758..c76330a8 100644 --- a/MP.IOC/Components/Pages/CallStats.razor.cs +++ b/MP.IOC/Components/Pages/CallStats.razor.cs @@ -9,19 +9,6 @@ namespace MP.IOC.Components.Pages { public partial class CallStats { - #region Protected Properties - - /// - /// Genera colori sfondo 33% rosso / arancione / giallo - /// - /// - protected List bgColors - { - get => semaphColors(currData.Count, "0.3"); - } - - #endregion Protected Properties - #region Protected Methods protected override async Task OnInitializedAsync() @@ -35,20 +22,46 @@ namespace MP.IOC.Components.Pages private List currData = new(); - private string currId = ""; - private string currHistId = ""; - private string currPieId = ""; - private string currTsId = ""; + private string currDetail = ""; + private string currHistId = ""; + + private string currId = ""; + + private string currPieId = ""; private string currTitle = ""; + private string currTsId = ""; + + private List lineTitles = new List(); + private Dictionary> ParetoDay = new(); + private List tsData = new List(); + + private List tsDataDetail = new(); + + private List> TSDataMulti = new(); + #endregion Private Fields #region Private Properties + /// + /// Genera colori sfondo 33% rosso / arancione / giallo + /// + /// + private List bgColors + { + get => GetSemaforicColors(currData.Count, "0.3"); + } + + private List bgColorsMLine + { + get => GetDistinctColors(tsDataDetail.Count, "0.3"); + } + private List DatiPareto { get => currData.Select(x => x.Value).ToList(); @@ -59,13 +72,23 @@ namespace MP.IOC.Components.Pages get => currData.Select(x => x.Label).ToList(); } + private List LabelPlot + { + get => tsData.Select(r => $"{r.x:yyyy-MM-dd}").ToList(); + } + /// /// Genera colori sfondo 33% rosso / arancione / giallo /// /// private List lineColors { - get => semaphColors(currData.Count, "1"); + get => GetSemaforicColors(currData.Count, "1"); + } + + private List lineColorsMLine + { + get => GetDistinctColors(tsDataDetail.Count, "1"); } [Inject] @@ -134,9 +157,93 @@ namespace MP.IOC.Components.Pages return answ; } - #endregion Private Methods + private List GetSemaforicColors(int numRecords, string alpha) + { + List colors = new List(); + if (numRecords <= 0) return colors; + if (numRecords == 1) { colors.Add($"rgba(54, 235, 82, {alpha})"); return colors; } - private string currDetail = ""; + // Definiamo i punti chiave (R, G, B) + (int r, int g, int b) green = (54, 235, 82); + (int r, int g, int b) yellow = (255, 206, 86); + (int r, int g, int b) red = (255, 99, 132); + + for (int i = 0; i < numRecords; i++) + { + // t va da 0.0 (primo record) a 1.0 (ultimo record) + double t = (double)i / (numRecords - 1); + int r, g, b; + + if (t < 0.5) + { + // Da Verde a Giallo (mappiamo 0->0.5 su 0->1) + double localT = t * 2; + r = (int)(green.r + (yellow.r - green.r) * localT); + g = (int)(green.g + (yellow.g - green.g) * localT); + b = (int)(green.b + (yellow.b - green.b) * localT); + } + else + { + // Da Giallo a Rosso (mappiamo 0.5->1 su 0->1) + double localT = (t - 0.5) * 2; + r = (int)(yellow.r + (red.r - yellow.r) * localT); + g = (int)(yellow.g + (red.g - yellow.g) * localT); + b = (int)(yellow.b + (red.b - yellow.b) * localT); + } + + colors.Add($"rgba({r}, {g}, {b}, {alpha})"); + } + + return colors; + } + //private List GetDistinctColors(int numRecords, string alpha) + //{ + // List colors = new List(); + + // for (int i = 0; i < numRecords; i++) + // { + // // Distribuiamo la tonalità (Hue) uniformemente sui 360 gradi + // double hue = (double)i * 360 / numRecords; + + // // Usiamo il formato CSS hsla() che è più semplice da generare direttamente + // // Saturazione 70% e Luminosità 50-60% di solito danno colori vivaci e distinti + // colors.Add($"hsla({hue:0.##}, 70%, 50%, {alpha})"); + // } + + // return colors; + //} + private List GetDistinctColors(int numRecords, string alpha) + { + List colors = new List(); + if (numRecords <= 0) return colors; + + // Partiamo dal Blu (240°) invece che dal Rosso (0°) + double startHue = 240.0; + + for (int i = 0; i < numRecords; i++) + { + // Distribuiamo la tonalità aggiungendo l'offset iniziale + // L'operatore % 360 assicura di rimanere nel cerchio se superiamo il rosso + double hue = (startHue + ((double)i * 360 / numRecords)) % 360; + + // Strategia di distinzione (attiva sempre, ma più efficace sopra i 5 colori) + // Alterniamo i valori per i record pari/dispari + string saturation = "70%"; + string lightness = "50%"; + + if (numRecords > 5) + { + // Se i colori sono molti, alterniamo luminosità e saturazione + // I record dispari saranno più chiari e saturi, i pari più scuri e tenui + lightness = (i % 2 == 0) ? "45%" : "65%"; + saturation = (i % 2 == 0) ? "80%" : "60%"; + } + + colors.Add($"hsla({hue:0.##}, {saturation}, {lightness}, {alpha})"); + } + + return colors; + } /// /// abilita visualizzaione grafico dettagli x metodo indicato @@ -148,7 +255,7 @@ namespace MP.IOC.Components.Pages // recupero dettaglio 7gg... DateTime adesso = DateTime.Now; List rawData = await SDetService.GetFiltAsync(adesso.AddDays(-3), adesso, "", selDetail); - // conversione con grouping + // conversione con grouping tsData = rawData.Select(r => new chartJsData.chartJsTSerie() { x = r.Hour, y = (double)r.AvgDuration }) .OrderBy(o => o.x) .ToList(); @@ -157,16 +264,6 @@ namespace MP.IOC.Components.Pages TSDataMulti = tsDataDetail.Select(x => x.DataPoints).ToList(); } - private List LabelPlot - { - get => tsData.Select(r => $"{r.x:yyyy-MM-dd}").ToList(); - } - - private List tsDataDetail = new(); - - private List tsData = new List(); - - private List> TSDataMulti = new(); - private List lineTitles = new List(); + #endregion Private Methods } } \ No newline at end of file diff --git a/MP.IOC/Controllers/IOBController.cs b/MP.IOC/Controllers/IOBController.cs index ac09fab3..2b067704 100644 --- a/MP.IOC/Controllers/IOBController.cs +++ b/MP.IOC/Controllers/IOBController.cs @@ -10,6 +10,7 @@ namespace MP.IOC.Controllers [ApiController] public class IOBController : ControllerBase { + #region Public Constructors public IOBController(IConfiguration configuration, MpDataService DataService) { @@ -17,15 +18,7 @@ namespace MP.IOC.Controllers DService = DataService; } - - private static IConfiguration _configuration = null!; - - private static Logger Log = LogManager.GetCurrentClassLogger(); - - /// - /// Dataservice x accesso DB - /// - protected MpDataService DService { get; set; } + #endregion Public Constructors #region Public Methods @@ -48,28 +41,27 @@ namespace MP.IOC.Controllers { } return answ; } + +#if false /// - /// Recupera TASK richiesto x macchina: - /// - /// GET: IOB/getOptPar/SIMUL_03 + /// GET: IOB/ /// - /// - /// Json contenente 1..n task da eseguire - [HttpGet("getOptPar/{id}")] - public string getOptPar(string id) + /// + [HttpGet("")] + public string alive() { - string answ = ""; - // scrivo keep alive!!! (se necessario, altrimenti è in cache...) - DService.ScriviKeepAlive(id, DateTime.Now); - try - { - // leggo da REDIS eventuale elenco task x macchina... - Dictionary valori = DService.mOptParMacchina(id); - answ = JsonConvert.SerializeObject(valori); - } - catch - { } - return answ; + return "OK"; + } +#endif + + /// + /// GET: IOB/ + /// + /// + [HttpGet] + public IActionResult Alive() + { + return Ok("OK"); // Restituisce Status 200 } /// @@ -95,6 +87,61 @@ namespace MP.IOC.Controllers } } + /// + /// Recupera TASK richiesto x macchina: + /// + /// GET: IOB/getOptPar/SIMUL_03 + /// + /// + /// Json contenente 1..n task da eseguire + [HttpGet("getOptPar/{id}")] + public string getOptPar(string id) + { + string answ = ""; + // scrivo keep alive!!! (se necessario, altrimenti è in cache...) + DService.ScriviKeepAlive(id, DateTime.Now); + try + { + // leggo da REDIS eventuale elenco task x macchina... + Dictionary valori = DService.mOptParMacchina(id); + answ = JsonConvert.SerializeObject(valori); + } + catch + { } + return answ; + } + + [HttpGet("version")] + public string version() + { + var version = Assembly + .GetExecutingAssembly() + .GetName() + .Version? + .ToString() ?? "unknown"; + + return version; + } + + #endregion Public Methods + + #region Protected Properties + + /// + /// Dataservice x accesso DB + /// + protected MpDataService DService { get; set; } + + #endregion Protected Properties + + #region Private Fields + + private static IConfiguration _configuration = null!; + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields + ///// AGGIUNGE TASK richiesto x macchina: ///// ///// GET: IOB/addTask2Exe/3010?taskName=startSetup&taskVal=T190406101512 @@ -2217,22 +2264,6 @@ namespace MP.IOC.Controllers // } // return answ; //} - - [HttpGet("version")] - public string version() - { - var version = Assembly - .GetExecutingAssembly() - .GetName() - .Version? - .ToString() ?? "unknown"; - - return version; - } - #endregion Public Methods - - #region Private Methods - ///// ///// Effettua vera chiamata x salvataggio snapshot dati FluxLog ///// @@ -2261,7 +2292,5 @@ namespace MP.IOC.Controllers // return answ; //} - - #endregion Private Methods } -} +} \ No newline at end of file diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index f7ca4f05..3502570b 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 6.16.2604.1016 + 6.16.2604.1017 diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index 9f14d510..e95de881 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

Versione: 6.16.2604.1016

+

Versione: 6.16.2604.1017


Note di rilascio:
  • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index 7659c690..43632be8 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2604.1016 +6.16.2604.1017 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index d8446449..6875b321 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2604.1016 + 6.16.2604.1017 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false