UI_SequentMicrosystems-RPI/Pages/RTD8TMPage.razor

102 lines
3.0 KiB
Plaintext

@page "/RTD8TM"
@using Blazored.Modal.Services
@using UI_SequentMicrosystems.Components
@using UI_SequentMicrosystems.Services
@using UI_SequentMicrosystems.Models
@using Blazored.Modal
@inject NavigationManager Navigator
@inject RTD8TMService _RTD8TMService
@inject PointsService _PointsService
<PageTitle>Temperature</PageTitle>
<div class="row text-center">
<div class="col-6">Device Address: @_RTD8TMService.GetAddress() | DataUpdate: @_UpdateCounter | Chart Points: @_RTD8TMService.CountChartData() / @_RTD8TMService.CountFilteredChartData() </div>
<div class="col text-start">
<div class="form-check form-switch">
@if (EditName)
{
<input class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckDefault" @onclick="(() =>
{
EditName = false;
Task.Run(() =>_RTD8TMService.SetChanelsNames());
Task.Run(() => _RTD8TMService.PostValueTypes());
})" checked>
}
else
{
<input class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckDefault" @onclick="(() => EditName = true)">
}
<label class="form-check-label" for="flexSwitchCheckDefault">Configure Inputs</label>
</div>
</div>
@if (EditName)
{
<div class="col text-start">
<button class="btn btn-dark text-white no-border" @onclick="(() => _RTD8TMService.ClearChanelNames())">Reset Names</button>
</div>
<div class="col text-start">
<button class="btn btn-dark text-white no-border" @onclick="(() => _RTD8TMService.ClearValueTypes())">Reset Value Types</button>
</div>
}
</div>
<div class="row">
<div class="col-lg-6">
@if (_RTD8TMService.GraphData.Keys.Count != 0)
{
<RTD8TMGraphComponent/>
}
</div>
<div class="col-lg-6">
<div class="row">
@foreach(byte StackID in _RTD8TMService.GetActualData().Keys)
{
<div class="col-sm-6 col-xxl-4">
<div class="text-center">Stack ID: @StackID</div>
@for (byte chanel = 0; chanel < 8; chanel++)
{
<RTD8TMChanelComponent StackID=@StackID ChanelID=@chanel Edit=@EditName RTD8tmService=@_RTD8TMService />
}
</div>
}
</div>
</div>
</div>
@code {
public int _UpdateCounter = 0;
private bool EditName = false;
[CascadingParameter] public IModalService Modal { get; set; } = default!;
protected override void OnInitialized()
{
//_RTD8TMService.SetAddress("http://10.250.251.131/");
_RTD8TMService.SetAddress(Navigator.BaseUri);
_RTD8TMService.EventUpdateValues += UpdateView;
}
public async Task UpdateView(object? o, bool b)
{
await InvokeAsync(() =>
{
StateHasChanged();
_UpdateCounter++;
});
}
}