bugfixing
parent
8b62c82a15
commit
03413fb499
|
@ -135,11 +135,11 @@ else
|
|||
await InvokeAsync(() =>
|
||||
{
|
||||
TableBackground = false;
|
||||
StateHasChanged();
|
||||
if (TableData.Keys.Count > 1)
|
||||
{
|
||||
HalfHourTime();
|
||||
}
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
|
||||
<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>
|
||||
<div class="col-2 col-sm-4 col-md-4 col-xl-4 h5 text-end align-self-center"><strong>@(Math.Round(RecalculateValues(RTD8tmService.GetActualData(StackID, ChanelID), RTD8tmService.GetValueType(StackID, ChanelID)), 2))</strong></div>
|
||||
|
||||
@if (Edit)
|
||||
{
|
||||
|
@ -70,8 +70,13 @@
|
|||
RTD8tmService.SetChanelNames(StackID, ChanelID, NewName);
|
||||
}
|
||||
|
||||
private void CalibrationChanged(string NewCalibration)
|
||||
private void CalibrationChanged(string? NewCalibration)
|
||||
{
|
||||
if (NewCalibration == null || NewCalibration == "")
|
||||
{
|
||||
NewCalibration = "0";
|
||||
}
|
||||
|
||||
NewCalibration = NewCalibration.Replace(".", ",");
|
||||
RTD8tmService.SetCalibration(StackID, ChanelID, float.Parse(NewCalibration));
|
||||
}
|
||||
|
|
|
@ -1,31 +1,47 @@
|
|||
@using ApexCharts
|
||||
@using Newtonsoft.Json
|
||||
@using UI_SequentMicrosystems.Components
|
||||
@using UI_SequentMicrosystems.Services
|
||||
@using UI_SequentMicrosystems.Models
|
||||
|
||||
@inject RTD8TMService _RTD8TMService
|
||||
<ApexChart TItem="RTD8TMPointModel"
|
||||
Title="Temperature"
|
||||
Options="chartOptions"
|
||||
@ref="chart">
|
||||
|
||||
@foreach (byte stack in _RTD8TMService.GetActualData().Keys)
|
||||
@if (_RTD8TMService.GetActualData().Keys.Count > 0)
|
||||
{
|
||||
if (false)
|
||||
{
|
||||
for (byte chanel = 0; chanel < 8; chanel++)
|
||||
<div>
|
||||
<input type="text" class="form-control form-control-sm bg-black text-white no-border" placeholder="Json syntax with Chart Points" @onchange="((x) => ChartPointsAdd(x.Value.ToString()))">
|
||||
</div>
|
||||
}
|
||||
|
||||
<ApexChart TItem="RTD8TMPointModel"
|
||||
Title="Temperature"
|
||||
Options="chartOptions"
|
||||
@ref="chart">
|
||||
|
||||
@foreach (byte stack in _RTD8TMService.GetActualData().Keys)
|
||||
{
|
||||
if (_RTD8TMService.GetChanelName(stack, chanel) != "----------")
|
||||
for (byte chanel = 0; chanel < 8; chanel++)
|
||||
{
|
||||
<ApexPointSeries TItem="RTD8TMPointModel"
|
||||
Items="@_RTD8TMService.GetChartData(stack, chanel)"
|
||||
Name="@(_RTD8TMService.GetChanelName(stack, chanel))"
|
||||
SeriesType="SeriesType.Line"
|
||||
XValue="@(e => e.Time.ToString("HH:mm:ss"))"
|
||||
YValue="@(e => (decimal)e.Value)"
|
||||
OrderBy="e=>e.X" />
|
||||
if (_RTD8TMService.GetChanelName(stack, chanel) != "----------")
|
||||
{
|
||||
//Console.WriteLine($"Chart Data: Stack: {stack} | Chanel: {chanel} | {JsonConvert.SerializeObject(_RTD8TMService.GetChartData(stack, chanel))}");
|
||||
|
||||
<ApexPointSeries TItem="RTD8TMPointModel"
|
||||
Items="@_RTD8TMService.GetChartData(stack, chanel)"
|
||||
Name="@(_RTD8TMService.GetChanelName(stack, chanel))"
|
||||
SeriesType="SeriesType.Line"
|
||||
XValue="@(e => e.Time.ToString("HH:mm:ss"))"
|
||||
YValue="@(e => (decimal)e.Value)"
|
||||
OrderBy="e=>e.X" />
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</ApexChart>
|
||||
</ApexChart>
|
||||
}
|
||||
|
||||
|
||||
@code {
|
||||
private ApexChart<RTD8TMPointModel> chart;
|
||||
|
@ -36,20 +52,20 @@
|
|||
{
|
||||
_RTD8TMService.EventUpdateGraph += UpdateChart;
|
||||
|
||||
|
||||
chartOptions = new ApexChartOptions<RTD8TMPointModel>
|
||||
{
|
||||
Theme = new Theme
|
||||
{
|
||||
Mode = Mode.Dark,
|
||||
},
|
||||
Legend = new Legend
|
||||
{
|
||||
Position = LegendPosition.Bottom,
|
||||
FontSize = "20px",
|
||||
HorizontalAlign = Align.Center
|
||||
}
|
||||
};
|
||||
Theme = new Theme
|
||||
{
|
||||
Mode = Mode.Dark,
|
||||
},
|
||||
Legend = new Legend
|
||||
{
|
||||
Position = LegendPosition.Bottom,
|
||||
FontSize = "15px",
|
||||
HorizontalAlign = Align.Center
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public async Task UpdateChart(object? o, bool b)
|
||||
|
@ -63,7 +79,10 @@
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
public void ChartPointsAdd(string points)
|
||||
{
|
||||
_RTD8TMService.SetChartData(JsonConvert.DeserializeObject<SortedList<byte, List<List<RTD8TMPointModel>>>>(points));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System.Threading.Channels;
|
||||
using Newtonsoft.Json;
|
||||
using System.Diagnostics.Metrics;
|
||||
using System.Threading.Channels;
|
||||
using System.Timers;
|
||||
using UI_SequentMicrosystems.Components;
|
||||
using UI_SequentMicrosystems.Models;
|
||||
|
@ -14,13 +16,14 @@ namespace UI_SequentMicrosystems.Services
|
|||
private SortedList<byte, float[]> Calibrations = new SortedList<byte, float[]>();
|
||||
public SortedList<byte, List<List<RTD8TMPointModel>>> GraphData = new();
|
||||
public SortedList<byte, List<List<RTD8TMPointModel>>> GraphFiltered = new();
|
||||
private int GraphFilteredCountPoint { get; set; }
|
||||
private byte GraphDataCounterCount = 10;
|
||||
private byte GraphDataCounter = 9;
|
||||
|
||||
private string? Address { get; set; }
|
||||
|
||||
private RTD8TM _RTD8TM = new RTD8TM();
|
||||
private System.Timers.Timer _timer = new(1000);
|
||||
private System.Timers.Timer _timer = new(1000); //update timer
|
||||
|
||||
public delegate Task AsyncEventHandler<TEventArgs>(object? sender, TEventArgs? e);
|
||||
public event AsyncEventHandler<bool>? EventUpdateValues;
|
||||
|
@ -75,35 +78,37 @@ namespace UI_SequentMicrosystems.Services
|
|||
private async void GetActualValues()
|
||||
{
|
||||
if (Address == null) { return; }
|
||||
|
||||
ActualValues = await _RTD8TM.Get(Address);
|
||||
|
||||
foreach (byte stack in ActualValues.Keys)
|
||||
try
|
||||
{
|
||||
if (Calibrations.ContainsKey(stack))
|
||||
ActualValues = await _RTD8TM.Get(Address);
|
||||
|
||||
foreach (byte stack in ActualValues.Keys)
|
||||
{
|
||||
for (byte chanel = 0; chanel < 8; chanel++)
|
||||
if (Calibrations.ContainsKey(stack))
|
||||
{
|
||||
ActualValues[stack][chanel] += Calibrations[stack][chanel];
|
||||
for (byte chanel = 0; chanel < 8; chanel++)
|
||||
{
|
||||
ActualValues[stack][chanel] += Calibrations[stack][chanel];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (GraphDataCounter >= GraphDataCounterCount)
|
||||
{
|
||||
GraphDataCounter = 0;
|
||||
|
||||
ReadChartData();
|
||||
|
||||
if (EventUpdateGraph != null)
|
||||
if (GraphDataCounter >= GraphDataCounterCount)
|
||||
{
|
||||
await EventUpdateGraph.Invoke(this, true);
|
||||
GraphDataCounter = 0;
|
||||
|
||||
ReadChartData();
|
||||
}
|
||||
else
|
||||
{
|
||||
GraphDataCounter++;
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
GraphDataCounter++;
|
||||
Console.WriteLine($"Reading actual Data fail with message: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,21 +293,38 @@ namespace UI_SequentMicrosystems.Services
|
|||
/// <returns>saved chart chanel Data</returns>
|
||||
public List<RTD8TMPointModel> GetChartData(byte StackID, byte Chanel)
|
||||
{
|
||||
Console.WriteLine($"RTD8TMService:GetChartData({StackID}, {Chanel}) - start reading");
|
||||
|
||||
if (!GraphFiltered.ContainsKey(StackID))
|
||||
{
|
||||
Console.WriteLine($"RTD8TMService:GetChartData({StackID}, {Chanel}) - Return new() - Unknow StackID - Stack_Keys: {JsonConvert.SerializeObject(GraphFiltered.Keys)}");
|
||||
return new List<RTD8TMPointModel>();
|
||||
}
|
||||
|
||||
List<RTD8TMPointModel> RecalculatedData = new();
|
||||
byte chanelRecalcTo = GetValueType(StackID, Chanel);
|
||||
|
||||
RTD8TMChanelComponent _RTD8TMChanelComponent = new RTD8TMChanelComponent();
|
||||
float LastValue = -1;
|
||||
int CountErrors = 0;
|
||||
|
||||
foreach (RTD8TMPointModel point in GraphFiltered[StackID][Chanel])
|
||||
{
|
||||
RTD8TMPointModel recalculated = new() { Time = point.Time, Value = new RTD8TMChanelComponent().RecalculateValues(point.Value, chanelRecalcTo) };
|
||||
RecalculatedData.Add(recalculated);
|
||||
RTD8TMPointModel recalculated = new() { Time = point.Time, Value = _RTD8TMChanelComponent.RecalculateValues(point.Value, chanelRecalcTo) };
|
||||
|
||||
if (LastValue == -1 || CountErrors > 1 || (recalculated.Value >= (LastValue - 10) && recalculated.Value <= (LastValue + 10)))
|
||||
{
|
||||
RecalculatedData.Add(recalculated);
|
||||
LastValue = recalculated.Value;
|
||||
CountErrors = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
CountErrors++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Console.WriteLine($"RTD8TMService:GetChartData({StackID}, {Chanel})");
|
||||
|
||||
return RecalculatedData;
|
||||
}
|
||||
|
@ -315,21 +337,24 @@ namespace UI_SequentMicrosystems.Services
|
|||
GraphData.Clear();
|
||||
}
|
||||
|
||||
private void GetFilteredChartData()
|
||||
private async void GetFilteredChartData()
|
||||
{
|
||||
foreach ( byte stack in GraphData.Keys)
|
||||
GraphFiltered = new SortedList<byte, List<List<RTD8TMPointModel>>>();
|
||||
|
||||
foreach (byte stack in GraphData.Keys)
|
||||
{
|
||||
int pointsCount = GraphData[stack][0].Count;
|
||||
int counter = 0;
|
||||
|
||||
Console.WriteLine($"RTD8TMService:GetFilteredChartData - Stack: {stack} | PointsCount: {pointsCount} | counter: {counter} | GraphData_Keys: {JsonConvert.SerializeObject(GraphData.Keys)}");
|
||||
|
||||
if (pointsCount < 100)
|
||||
{
|
||||
GraphFiltered = GraphData;
|
||||
}
|
||||
else if (pointsCount > 100 && pointsCount < 500) // one from five
|
||||
else if (pointsCount >= 100 && pointsCount < 500) // one from five
|
||||
{
|
||||
GraphFiltered = new();
|
||||
GraphFiltered.Add(stack, new());
|
||||
GraphFiltered.Add(stack, new List<List<RTD8TMPointModel>>());
|
||||
|
||||
for (int chanel = 0; chanel < 8; chanel++)
|
||||
{
|
||||
|
@ -348,9 +373,8 @@ namespace UI_SequentMicrosystems.Services
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (pointsCount > 500 && pointsCount < 1000) // one from ten
|
||||
else if (pointsCount >= 500 && pointsCount < 1000) // one from ten
|
||||
{
|
||||
GraphFiltered = new();
|
||||
GraphFiltered.Add(stack, new());
|
||||
|
||||
for (int chanel = 0; chanel < 8; chanel++)
|
||||
|
@ -370,9 +394,8 @@ namespace UI_SequentMicrosystems.Services
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (pointsCount > 1000 && pointsCount < 1500) // one from fifteen
|
||||
else if (pointsCount >= 1000 && pointsCount < 1500) // one from fifteen
|
||||
{
|
||||
GraphFiltered = new();
|
||||
GraphFiltered.Add(stack, new());
|
||||
|
||||
for (int chanel = 0; chanel < 8; chanel++)
|
||||
|
@ -392,9 +415,8 @@ namespace UI_SequentMicrosystems.Services
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (pointsCount > 1500) // one from twenty
|
||||
else if (pointsCount >= 1500 && pointsCount < 2000) // one from twenty
|
||||
{
|
||||
GraphFiltered = new();
|
||||
GraphFiltered.Add(stack, new());
|
||||
|
||||
for (int chanel = 0; chanel < 8; chanel++)
|
||||
|
@ -414,9 +436,61 @@ namespace UI_SequentMicrosystems.Services
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (pointsCount >= 2000 && pointsCount < 3500) // one from TwentyFive
|
||||
{
|
||||
GraphFiltered.Add(stack, new());
|
||||
|
||||
for (int chanel = 0; chanel < 8; chanel++)
|
||||
{
|
||||
GraphFiltered[stack].Add(new());
|
||||
foreach (RTD8TMPointModel GraphPoint in GraphData[stack][chanel])
|
||||
{
|
||||
if (counter > 23)
|
||||
{
|
||||
GraphFiltered[stack][chanel].Add(GraphPoint);
|
||||
counter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pointsCount >= 3500) // one from twenty
|
||||
{
|
||||
GraphFiltered.Add(stack, new());
|
||||
|
||||
for (int chanel = 0; chanel < 8; chanel++)
|
||||
{
|
||||
GraphFiltered[stack].Add(new());
|
||||
foreach (RTD8TMPointModel GraphPoint in GraphData[stack][chanel])
|
||||
{
|
||||
if (counter > 28)
|
||||
{
|
||||
GraphFiltered[stack][chanel].Add(GraphPoint);
|
||||
counter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//případně další
|
||||
|
||||
}
|
||||
|
||||
if (EventUpdateGraph != null)
|
||||
{
|
||||
if (CountFilteredChartData() != GraphFilteredCountPoint)
|
||||
{
|
||||
GraphFilteredCountPoint = CountFilteredChartData();
|
||||
await EventUpdateGraph.Invoke(this, true);
|
||||
}
|
||||
}
|
||||
Console.WriteLine($"RTD8TMService:GetFilteredChartData - GraphFiltered_Keys: {JsonConvert.SerializeObject(GraphFiltered.Keys)}");
|
||||
}
|
||||
|
||||
public int CountFilteredChartData()
|
||||
|
@ -453,6 +527,7 @@ namespace UI_SequentMicrosystems.Services
|
|||
/// <param name="data"></param>
|
||||
public void SetChartData(SortedList<byte, List<List<RTD8TMPointModel>>> data)
|
||||
{
|
||||
Console.WriteLine($"RTD8TMService:SetChartData - {JsonConvert.SerializeObject(data)}");
|
||||
GraphData = data;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue