Merge branch 'release/UpdateDisplay_01'

This commit is contained in:
Samuele Locatelli
2025-12-03 07:56:48 +01:00
3 changed files with 55 additions and 39 deletions
+10 -2
View File
@@ -1183,8 +1183,16 @@ namespace IOB_MAN.Core.Services
private void UpdateCounters()
{
numProcStarted = ListIobAdapters.Where(x => x.isRunning).Count();
numProcRunning = ListIobAdapters.Where(x => x.isRunning && x.plcOk && x.iobOnline).Count();
if (ListIobAdapters != null && ListIobAdapters.Count > 0)
{
numProcStarted = ListIobAdapters.Where(x => x.isRunning).Count();
numProcRunning = ListIobAdapters.Where(x => x.isRunning && x.plcOk && x.iobOnline).Count();
}
else
{
numProcStarted = 0;
numProcRunning = 0;
}
}
#endregion Private Methods
@@ -1,9 +1,9 @@
/// <summary>
/// Component responsible for monitoring and managing IOB (Industrial Operation Block) services.
///
///
/// This Blazor component displays real-time status of running processes, provides UI controls
/// for starting/stopping services, and manages auto-restart logic based on configuration and thresholds.
///
///
/// Key Features:
/// - Displays live status of IOB services (running, stopped, ratio, color-coded indicators).
/// - Enables user to open process folders (config, logs, target paths).
@@ -29,7 +29,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Cleans up event subscriptions and resources when the component is disposed.
///
///
/// Specifically:
/// - Unsubscribes from ACService.StatusUpdated event.
/// </summary>
@@ -67,7 +67,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Gets or sets whether auto-restart is enabled.
///
///
/// Behavior:
/// - When enabled, triggers automatic restart of closed services.
/// - When disabled, delays restart until a configurable threshold (VetoAutoCheck) is reached.
@@ -91,7 +91,7 @@ namespace IOB_MAN.Components.Compo
ACService.DelayRestart(!value);
}
currPage = 1;
ForceReload();
DoReload();
}
}
}
@@ -107,7 +107,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// CSS class for process startup status indicator.
///
///
/// Color logic:
/// - If fewer than configured processes are started → "text-info"
/// - If <50% of processes are running → "text-danger"
@@ -140,7 +140,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// CSS class for "active processes" status.
///
///
/// Color logic:
/// - If <50% of started processes are running → "bg-danger"
/// - If 50% to 100% running → "bg-warning"
@@ -166,7 +166,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// CSS class for "started processes" status.
///
///
/// Color logic:
/// - If <50% of configured processes are started → "bg-danger"
/// - If 50% to 100% started → "bg-warning"
@@ -218,7 +218,7 @@ namespace IOB_MAN.Components.Compo
if (iobTypeSel != value)
{
iobTypeSel = value;
ForceReload();
DoReload();
}
}
}
@@ -297,7 +297,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Returns CSS class based on whether a specific IOB is running.
///
///
/// Style:
/// - If not running → "bg-danger bg-opacity-25"
/// - Otherwise → empty (default background)
@@ -312,7 +312,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Delays a restart request by setting a countdown timer in the UI.
///
///
/// Used when auto-restart is disabled to prevent immediate restarts.
/// </summary>
protected void DelayRestart()
@@ -322,7 +322,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Closes all child IOB processes and refreshes the UI.
///
///
/// Actions:
/// - Stops all running services.
/// - Triggers a full scan to update state.
@@ -332,12 +332,12 @@ namespace IOB_MAN.Components.Compo
{
CloseAllChild(false);
await ACService.DoScan();
// ForceReload(); // Optional: can be removed if UI refresh is handled elsewhere
// DoReload(); // Optional: can be removed if UI refresh is handled elsewhere
}
/// <summary>
/// Closes a specific child IOB process.
///
///
/// Action:
/// - Sends a close command to the service.
/// - Hides the right-click menu.
@@ -351,7 +351,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Minimizes all IOB process windows to the system tray.
///
///
/// Behavior:
/// - Iterates over all CurrRecords.
/// - For each process, retrieves its MainWindowHandle and minimizes it.
@@ -376,7 +376,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Reboots all IOB processes and optionally reloads configuration.
///
///
/// Actions:
/// - Closes all services.
/// - If 'reloadConf' is true, re-scans configuration and reloads it.
@@ -398,7 +398,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Restores all IOB process windows to full screen.
///
///
/// Behavior:
/// - Iterates over all CurrRecords.
/// - For each process, retrieves its MainWindowHandle and restores it.
@@ -423,7 +423,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Restores a specific IOB process window.
///
///
/// Action:
/// - Finds the process by ID and restores it to normal view.
/// </summary>
@@ -444,7 +444,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Starts a specific IOB process.
///
///
/// Action:
/// - Sends a command to ACService to open and start the selected IOB.
/// - Hides the right-click menu.
@@ -458,7 +458,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Forces a full scan of all IOB services and updates UI state.
///
///
/// Actions:
/// - Sets isLoading to true.
/// - Clears current records.
@@ -477,7 +477,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Initializes the component.
///
///
/// Action:
/// - Subscribes to ACService.StatusUpdated event to update UI on status changes.
/// </summary>
@@ -488,7 +488,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Called when parameters change (e.g., user selects a new IOB type).
///
///
/// Actions:
/// - Triggers a full scan of services.
/// - Updates the UI with filtered records.
@@ -496,12 +496,12 @@ namespace IOB_MAN.Components.Compo
protected override async Task OnParametersSetAsync()
{
await ACService.DoScan();
ForceReload();
DoReload();
}
/// <summary>
/// Updates the number of records per page (e.g., from 10 to 20).
///
///
/// Behavior:
/// - Updates the page count and triggers a reload to refresh the UI.
/// </summary>
@@ -515,7 +515,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Updates the current page (e.g., page 2, 3, etc.).
///
///
/// Behavior:
/// - Updates the page number and triggers a reload to refresh the UI.
/// </summary>
@@ -589,7 +589,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// CSS class for "Close All" button.
///
///
/// Behavior:
/// - Enabled only if at least one service is currently running.
/// - Disabled otherwise (grayed out).
@@ -678,7 +678,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Handles status updates from ACService.
///
///
/// Logic:
/// - If auto-restart is disabled, shows countdown until auto-restart is triggered.
/// - When countdown reaches zero, enables auto-restart.
@@ -695,12 +695,12 @@ namespace IOB_MAN.Components.Compo
AutoRestart = true;
}
}
ForceReload();
DoReload();
}
/// <summary>
/// Closes all child IOB processes.
///
///
/// Parameters:
/// - doReset: if true, resets the internal list of services.
/// </summary>
@@ -712,9 +712,20 @@ namespace IOB_MAN.Components.Compo
enableKillTask = true;
}
/// <summary>
/// Check if reload is needed (no more than 2Hz) then triggers a ForceReload
/// </summary>
private void DoReload()
{
if ((DateTime.Now - _lastRender).TotalSeconds < 0.5)
return;
ForceReload();
}
/// <summary>
/// Triggers a reboot request with user confirmation.
///
///
/// Behavior:
/// - Uses JSRuntime to show a confirmation dialog.
/// - If confirmed, raises a reboot request to ACService.
@@ -730,7 +741,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Forces a UI reload with current filters and pagination.
///
///
/// Behavior:
/// - Skips if too soon (less than 1 second since last render).
/// - Updates filtered list based on IOB type.
@@ -739,9 +750,6 @@ namespace IOB_MAN.Components.Compo
/// </summary>
private void ForceReload()
{
if ((DateTime.Now - _lastRender).TotalSeconds < 1)
return;
_lastRender = DateTime.Now;
isLoading = true;
var filtered = CurrRecords;
@@ -816,7 +824,7 @@ namespace IOB_MAN.Components.Compo
/// <summary>
/// Handles right-click event on an IOB record.
///
///
/// Behavior:
/// - Sets selected IOB.
/// - Shows context menu at mouse position.
@@ -836,4 +844,4 @@ namespace IOB_MAN.Components.Compo
#endregion Private Methods
}
}
}
+1 -1
View File
@@ -8,7 +8,7 @@
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<Version>4.0.2512.0111</Version>
<Version>4.0.2512.0307</Version>
<Configurations>Debug;Release;Remote_DEBUG</Configurations>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>