UI_SequentMicrosystems-RPI/Components/RTD8TMChanelComponent.razor

85 lines
2.4 KiB
Plaintext

@using Blazored.Modal.Services
@using UI_SequentMicrosystems.Components
@using UI_SequentMicrosystems.Constants
@using UI_SequentMicrosystems.Services
@using Blazored.Modal
<div class="row">
<div class="col-2 col-sm-4 col-md-4 col-xl-4 h5 text-end align-self-center"><strong>@(RecalculateValues(RTD8tmService.GetActualData(StackID, ChanelID), RTD8tmService.GetValueType(StackID, ChanelID)))</strong></div>
@if (Edit)
{
<div class="col-2 h5 text-start align-self-center" @onclick="(() => Modal.Show<RTD8TMSensorTypeModal>(ModalTitle, new ModalParameters {{nameof(RTD8TMSensorTypeModal.StackID), StackID}, {nameof(RTD8TMSensorTypeModal.ChanelID), ChanelID}}, new ModalOptions { HideCloseButton = true }))">@(ValueType(RTD8tmService.GetValueType(StackID, ChanelID)))</div>
}
else
{
<div class="col-2 h5 text-start align-self-center">@(ValueType(RTD8tmService.GetValueType(StackID, ChanelID)))</div>
}
@if (Edit)
{
<div class="col">
<input type="text" class="form-control form-control-sm bg-black text-white no-border" value="@(RTD8tmService.GetChanelName(StackID, ChanelID))" @onchange="((x) => ChangeName(x.Value.ToString()))" >
</div>
}
else
{
<div class="col">@(RTD8tmService.GetChanelName(StackID, ChanelID))</div>
}
</div>
@code {
[Parameter]
public byte StackID { get; set; }
[Parameter]
public byte ChanelID { get; set; }
[Parameter]
public bool Edit { get; set; }
[Parameter]
public RTD8TMService RTD8tmService { get; set; }
private string ModalTitle = "Select value Type";
[CascadingParameter] public IModalService Modal { get; set; } = default!;
/// <summary>
/// Internal event for Name Change
/// </summary>
/// <param name="NewName"></param>
private void ChangeName(string NewName)
{
RTD8tmService.SetChanelNames(StackID, ChanelID, NewName);
}
private float RecalculateValues(float resistance, byte Type = 0)
{
if (Type == RTD8TMSensorTypes.PT100)
{
return (float)Math.Round(Calculations.Electric.RTD.PT100.ResistanceToTemperature(resistance), 2);
}
else
{
return resistance;
}
}
private string ValueType(byte Type)
{
if (Type == RTD8TMSensorTypes.PT100)
{
return "°C";
}
else
{
return "Ω";
}
}
}