Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

namespace AXOpen.Core
{

public partial class AxoComponentView : RenderableComplexComponentBase<AxoComponent>, IDisposable
{
private bool areDetailsCollapsed = true;
Expand All @@ -32,6 +31,8 @@ public partial class AxoComponentView : RenderableComplexComponentBase<AxoCompon
[Parameter]
public bool IsControllable { get; set; }

private Pocos.AXOpen.Core.AxoComponent _lastPocoValue = new();

public override void AddToPolling(ITwinElement element, int pollingInterval = 250)
{
if (element is AxoComponent axoComponent)
Expand Down Expand Up @@ -61,6 +62,7 @@ private IEnumerable<ITwinElement> GetAllKidsWithComponentDetailsAttribute(ITwinO
}

private ITwinObject header;

private ITwinObject Header
{
get
Expand All @@ -70,7 +72,11 @@ private ITwinObject Header
.ToList());
}
}
private IEnumerable<ITwinObject> DetailsTabs => CreateDetailsTabs();

private IEnumerable<ITwinObject> DetailsTabs
{
get { return detailsTabs = detailsTabs ?? CreateDetailsTabs(); }
}

private IEnumerable<ITwinObject> CreateDetailsTabs()
{
Expand Down Expand Up @@ -105,15 +111,34 @@ private IEnumerable<ITwinObject> CreateDetailsTabs()
return _detailsTabs;
}

protected override void OnInitialized()
protected override async void OnInitialized()
{
base.OnInitialized();
containsHeaderAttribute = this.Header.GetKids().Count() != 0;
tabNames = GetAllTabNames(this.Component);
containsDetailsAttribute = this.DetailsTabs.Count() != 0;

// read variables that are needed for fist render
var requstedVariablesForFistRender = new List<ITwinPrimitive>() { Component._isManuallyControllable };
await Component.GetConnector().ReadBatchAsync(requstedVariablesForFistRender);

UpdateValuesOnChange(Component);
}

protected override bool ShouldRender()
{
if (_lastPocoValue._isManuallyControllable != this.Component._isManuallyControllable.LastValue)
{
saveLastPocoValue();
return true;
}

return true;
}


private void saveLastPocoValue()
{
_lastPocoValue._isManuallyControllable = this.Component._isManuallyControllable.LastValue;
}

protected override async Task OnInitializedAsync()
Expand All @@ -128,7 +153,6 @@ protected override async Task OnInitializedAsync()
await base.OnInitializedAsync();
}


private bool DisplayByTheRole(string role)
{
if (identities != null && role != null)
Expand All @@ -149,58 +173,60 @@ private bool DisplayByTheRole(string role)
return false;
}


[Inject]
private AuthenticationStateProvider? AuthenticationStateProvider { get; set; }

private async Task<IEnumerable<ClaimsIdentity>?> GetClaimsIdentitiesAsync()
{
var authenticationState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
return authenticationState?.User?.Identities;
}
private IEnumerable<AxoMessenger>? Messengers => this.Component?.GetChildren().Flatten(p => p.GetChildren()).OfType<AxoMessenger>();

private IEnumerable<AxoMessenger>? Messengers => this.Component?.GetChildren().Flatten(p => p.GetChildren()).OfType<AxoMessenger>();

private eAlarmLevel AlarmLevel
{
get
{

var _messengers = Messengers?.ToList();
if (_messengers == null) { return eAlarmLevel.NoAlarms; }

if (_messengers.Any(p => p.State > eAxoMessengerState.Idle))
{

var seriousness = (eAxoMessageCategory)_messengers.Max(p => p.Category.LastValue);

switch (seriousness)
{
case eAxoMessageCategory.All:
case eAxoMessageCategory.Trace:
case eAxoMessageCategory.Debug:
case eAxoMessageCategory.All:
case eAxoMessageCategory.Trace:
case eAxoMessageCategory.Debug:
case eAxoMessageCategory.Info:
return eAlarmLevel.ActiveInfo;
case eAxoMessageCategory.TimedOut:
case eAxoMessageCategory.Notification:

case eAxoMessageCategory.TimedOut:
case eAxoMessageCategory.Notification:
case eAxoMessageCategory.Warning:
return eAlarmLevel.ActiveWarnings;
case eAxoMessageCategory.Error:
case eAxoMessageCategory.ProgrammingError:
case eAxoMessageCategory.Critical:
case eAxoMessageCategory.Fatal:

case eAxoMessageCategory.Error:
case eAxoMessageCategory.ProgrammingError:
case eAxoMessageCategory.Critical:
case eAxoMessageCategory.Fatal:
case eAxoMessageCategory.Catastrophic:
return eAlarmLevel.ActiveErrors;

case eAxoMessageCategory.None:
break;

default:
break;
}
}
}
else if (_messengers.Any(p => p.State > eAxoMessengerState.NotActiveWatingAckn))
{
return eAlarmLevel.Unacknowledged;
}

return eAlarmLevel.NoAlarms;
}
}
Expand Down Expand Up @@ -240,5 +266,4 @@ public AxoComponentStatusView()
IsControllable = false;
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using AXSharp.Connector;
using AXSharp.Presentation.Blazor.Controls;

namespace AXOpen.Core
{
public static class AxoSequncerHelper
{

public static IList<ITwinPrimitive> GetStepsOrderElements(this IEnumerable<AxoStep> steps)
{
List<ITwinPrimitive> activeProperties = new();

foreach (AxoStep step in steps)
{
activeProperties.Add(step.Order);
}

return activeProperties;
}


//public static void UpdateValuesOnChangePrimitives(this AxoSequencer sequencer, IList<ITwinPrimitive> ListOfPrimitives)
//{
// throw new NotImplementedException();
//}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,45 @@
<div>
<AuthorizeView Roles="can_skip_steps_in_sequence">
<Authorized>
<RenderableContentControl Context="@Component.StepBackwardCommand" Presentation="@(IsControllable ? "Command" : "Status")" />
@if (IsControllable)
{
<AXOpen.Core.AxoTaskCommandView Component="@Component.StepBackwardCommand" />
}
else
{
<AXOpen.Core.AxoTaskStatusView Component="@Component.StepBackwardCommand" />
}
</Authorized>
<NotAuthorized>
<RenderableContentControl Context="@Component.StepBackwardCommand" Presentation="Status" />
<AXOpen.Core.AxoTaskStatusView Component="@Component.StepBackwardCommand" />
</NotAuthorized>
</AuthorizeView>
</div>

<div>
<RenderableContentControl Context="@Component.StepIn" Presentation="@(IsControllable ? "Command" : "Status")" />
@if (IsControllable)
{
<AXOpen.Core.AxoTaskCommandView Component="@Component.StepIn" />
}
else
{
<AXOpen.Core.AxoTaskStatusView Component="@Component.StepIn" />
}
</div>
<div>
<AuthorizeView Roles="can_skip_steps_in_sequence">
<Authorized>
<RenderableContentControl Context="@Component.StepForwardCommand" Presentation="@(IsControllable ? "Command" : "Status")" />
@if (IsControllable)
{
<AXOpen.Core.AxoTaskCommandView Component="@Component.StepForwardCommand" />
}
else
{
<AXOpen.Core.AxoTaskStatusView Component="@Component.StepForwardCommand" />
}
</Authorized>
<NotAuthorized>
<RenderableContentControl Context="@Component.StepForwardCommand" Presentation="Status" />
<AXOpen.Core.AxoTaskStatusView Component="@Component.StepForwardCommand" />
</NotAuthorized>
</AuthorizeView>
</div>
Expand All @@ -66,7 +88,7 @@
@if (HasStepDetails)
{
<div class="row justify-content-end">
<button type="button" class="btn btn-primary ms-auto my-2 mx-3 col-auto" data-bs-toggle="modal" data-bs-target="#showStepsModal" @onclick="RefreshComponent">Show all steps</button>
<button type="button" class="btn btn-primary ms-auto my-2 mx-3 col-auto" data-bs-toggle="modal" data-bs-target="#showStepsModal" @onclick="OnOpenModalWindow">Show all steps</button>
</div>

<div class="rounded-3 overflow-hidden">
Expand All @@ -77,38 +99,59 @@
}
</div>

@{
void OnOpenModalWindow()
{
RefreshStepsInSequnce();
this.EnableModalContent = true;
}

void OnCloseModalWindow()
{
this.EnableModalContent = false;
}
}


<div class="modal fade" id="showStepsModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Steps</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" @onclick="OnCloseModalWindow"></button>
</div>
<div class="modal-body" style="max-height: calc(95vh - 200px); overflow-x: auto;">
<table class="table rounded-3 overflow-hidden">
<thead class="bg-light">
<tr>
<th scope="col">Description</th>
<th scope="col">Duration</th>
<th scope="col">Start time</th>
</tr>
</thead>
<tbody>
@foreach (var step in this.Steps.Where(p => p != null && p.Order.Cyclic != 0).Skip(3).OrderBy(p => p.Order.Cyclic))
{
<tr class="@AxoStepHelper.StepRowColor(step)">
<th scope="row">@AxoStepHelper.Description(step)</th>
<td>@step.Duration.Cyclic.TotalSeconds</td>
<td>@Humanizer.DateHumanizeExtensions.Humanize(step.StartTimeStamp.Cyclic, culture: CultureExtensions.Culture)</td>

@if (this.EnableModalContent)
{
<table class="table rounded-3 overflow-hidden">
<thead class="bg-light">
<tr>
<th scope="col" width="30">Order</th>
<th scope="col">Description</th>
<th scope="col">Duration</th>
<th scope="col">Start time</th>
</tr>
}
</tbody>
</table>
</thead>
<tbody>
@foreach (var step in this.AllSteps.Where(p => p != null && p.Order.Cyclic != 0).OrderBy(p => p.Order.Cyclic))
{
<tr class="@AxoStepHelper.StepRowColor(step)">
<td>@step.Order.Cyclic</td>
<th scope="row">@AxoStepHelper.Description(step)</th>
<td>@step.Duration.Cyclic.TotalSeconds</td>
<td>@Humanizer.DateHumanizeExtensions.Humanize(step.StartTimeStamp.Cyclic, culture: CultureExtensions.Culture)</td>
</tr>
}
</tbody>
</table>
}
</div>

<div class="modal-footer">
<button type="button" class="btn btn-primary" @onclick="RefreshComponent">Refresh</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" @onclick="RefreshDurationAndStatus">Refresh steps duration</button>
<button type="button" class="btn btn-primary" @onclick="RefreshStepsInSequnce">Refresh steps</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @onclick="OnCloseModalWindow">Close</button>
</div>
</div>
</div>
Expand Down
Loading