From 945ed8ad059263fbeeff3b6b061dea6823c543aa Mon Sep 17 00:00:00 2001 From: PTKu <61538034+PTKu@users.noreply.github.com> Date: Mon, 9 Oct 2023 18:57:56 +0200 Subject: [PATCH] adjustments to template --- .../Static/AxoMessengerView.razor | 31 ++++++++------- .../Static/AxoMessengerView.razor.cs | 1 + .../axosimple.app/Components/Alarms.razor | 33 +++++++--------- .../Components/AlarmsButton.razor | 39 +++++++++++-------- .../axosimple.app/Components/Unit.razor | 2 +- .../Components/UnitSpotView.razor | 27 ++++++++++++- .../axosimple.app/Pages/Index.razor | 27 ------------- .../axosimple.app/Pages/Units/Units.razor | 30 ++++++++++++++ .../axosimple.app/Shared/NavMenu.razor | 3 +- 9 files changed, 115 insertions(+), 78 deletions(-) create mode 100644 src/templates.simple/axosimple.app/Pages/Units/Units.razor diff --git a/src/core/src/AXOpen.Core.Blazor/AxoMessenger/Static/AxoMessengerView.razor b/src/core/src/AXOpen.Core.Blazor/AxoMessenger/Static/AxoMessengerView.razor index 460586c05..72fc3acd5 100644 --- a/src/core/src/AXOpen.Core.Blazor/AxoMessenger/Static/AxoMessengerView.razor +++ b/src/core/src/AXOpen.Core.Blazor/AxoMessenger/Static/AxoMessengerView.razor @@ -6,21 +6,26 @@ @if (Component.WaitingForAcknowledge.Cyclic || Component.IsActive.Cyclic) { -
-
- +
+
+
+
+ - + - + +
+
} diff --git a/src/core/src/AXOpen.Core.Blazor/AxoMessenger/Static/AxoMessengerView.razor.cs b/src/core/src/AXOpen.Core.Blazor/AxoMessenger/Static/AxoMessengerView.razor.cs index 341eb7f7e..13385cce5 100644 --- a/src/core/src/AXOpen.Core.Blazor/AxoMessenger/Static/AxoMessengerView.razor.cs +++ b/src/core/src/AXOpen.Core.Blazor/AxoMessenger/Static/AxoMessengerView.razor.cs @@ -18,6 +18,7 @@ public partial class AxoMessengerView : RenderableComplexComponentBase("import", "./_content/AXOpen.Core.Blazor/AxoMessenger/Static/AxoMessengerView.razor.js"); diff --git a/src/templates.simple/axosimple.app/Components/Alarms.razor b/src/templates.simple/axosimple.app/Components/Alarms.razor index 8d993f669..680b23b7f 100644 --- a/src/templates.simple/axosimple.app/Components/Alarms.razor +++ b/src/templates.simple/axosimple.app/Components/Alarms.razor @@ -4,7 +4,7 @@ @foreach (var message in Messengers) { - if (message.IsActive.LastValue) + if (message.IsActive.LastValue || message.WaitingForAcknowledge.LastValue) { } @@ -16,38 +16,35 @@ public override void AddToPolling(ITwinElement element, int pollingInterval = 250) { - Messengers?.Select(p => p.IsActive).ToList().ForEach(messenger => - { - messenger.StartPolling(1500, this); - PolledElements.Add(messenger); - }); - - Messengers?.Select(p => p.WaitingForAcknowledge).ToList().ForEach(messenger => - { - messenger.StartPolling(1500, this); - PolledElements.Add(messenger); - }); + //Messengers?.Select(p => p.IsActive).ToList().ForEach(messenger => + //{ + // messenger.StartPolling(2500, this); + // PolledElements.Add(messenger); + //}); + + //Messengers?.Select(p => p.WaitingForAcknowledge).ToList().ForEach(messenger => + //{ + // messenger.StartPolling(2500, this); + // PolledElements.Add(messenger); + //}); } protected override async Task OnAfterRenderAsync(bool firstRender) { await UpdateMessages(); await base.OnAfterRenderAsync(firstRender); + this.StateHasChanged(); } private async Task UpdateMessages() { - var a = Messengers?.SelectMany(p => new ITwinPrimitive[] { p.Category, p.IsActive, p.WaitingForAcknowledge }); - var connector = Messengers?.FirstOrDefault()?.GetConnector(); - await connector?.ReadBatchAsync(a)!; - if (Messengers != null) MessagesCount = Messengers.Count(p => p.IsActive.Cyclic); + if (Messengers != null) MessagesCount = Messengers.Count(p => p.IsActive.LastValue || p.WaitingForAcknowledge.LastValue); } - private IEnumerable Messengers => this.Component.GetChildren().Flatten(p => p.GetChildren()).OfType(); + private AxoMessenger[] Messengers => this.Component.GetChildren().Flatten(p => p.GetChildren()).OfType().ToArray(); protected override async Task OnInitializedAsync() { - await UpdateMessages(); await base.OnInitializedAsync(); } diff --git a/src/templates.simple/axosimple.app/Components/AlarmsButton.razor b/src/templates.simple/axosimple.app/Components/AlarmsButton.razor index 3d7e0d54a..c42f73e33 100644 --- a/src/templates.simple/axosimple.app/Components/AlarmsButton.razor +++ b/src/templates.simple/axosimple.app/Components/AlarmsButton.razor @@ -2,30 +2,41 @@ @using AXSharp.Connector @inherits RenderableComplexComponentBase - +@if(MessagesCount > 0) +{ + +} +else +{ + +} + @code { - [Parameter] public int MessagesCount { get; set; } + private string Disabled => MessagesCount > 0 ? "false" : "true"; + public override void AddToPolling(ITwinElement element, int pollingInterval = 250) { Messengers?.Select(p => p.IsActive).ToList().ForEach(messenger => { - messenger.StartPolling(1500, this); + messenger.StartPolling(2500, this); PolledElements.Add(messenger); }); Messengers?.Select(p => p.WaitingForAcknowledge).ToList().ForEach(messenger => { - messenger.StartPolling(1500, this); + messenger.StartPolling(2500, this); PolledElements.Add(messenger); }); } @@ -34,22 +45,18 @@ { await UpdateMessages(); await base.OnAfterRenderAsync(firstRender); + this.StateHasChanged(); } private async Task UpdateMessages() { - var a = Messengers?.SelectMany(p => new ITwinPrimitive[] { p.Category, p.IsActive, p.WaitingForAcknowledge }); - var connector = Messengers?.FirstOrDefault()?.GetConnector(); - await connector?.ReadBatchAsync(a)!; - if (Messengers != null) MessagesCount = Messengers.Count(p => p.IsActive.Cyclic); + if (Messengers != null) MessagesCount = Messengers.Count(p => p.IsActive.Cyclic || p.WaitingForAcknowledge.Cyclic); } private IEnumerable Messengers => this.Component.GetChildren().Flatten(p => p.GetChildren()).OfType(); protected override async Task OnInitializedAsync() { - await UpdateMessages(); await base.OnInitializedAsync(); } - } diff --git a/src/templates.simple/axosimple.app/Components/Unit.razor b/src/templates.simple/axosimple.app/Components/Unit.razor index bb158f576..d11fd57cd 100644 --- a/src/templates.simple/axosimple.app/Components/Unit.razor +++ b/src/templates.simple/axosimple.app/Components/Unit.razor @@ -71,7 +71,7 @@
- +