+
+
+
+
+ {
+ PointTimerChange(x.Value.ToString());
+ })">
+
+
+
+
+
+
+
-
@@ -37,16 +70,20 @@
-
-
-
-
-
-
@code {
private bool RecalculateValues = false;
+ private bool TimerEnabled = false;
+ protected override void OnInitialized()
+ {
+ TimerEnabled = _PointsService.GetTImerStatus();
+ _PointsService.EventUpdateTopBar += UpdateView;
+ }
+
+ ///
+ /// Start downloading CSV file with points
+ ///
private async void DownloadFile()
{
// Název souboru
@@ -56,10 +93,25 @@
await _JSRuntime.InvokeVoidAsync("DownloadFile", fileName, await _PointsService.CreatePointsFileLines(RecalculateValues));
}
+ ///
+ /// Timer Time Change
+ ///
+ ///
+ private void PointTimerChange(string? time)
+ {
+ if (time == null || time == "") { return; }
+
+ time = time.Replace(".", ",");
+ _PointsService.SetTimerInterval(int.Parse(time));
+ }
-
-
-
+ public async Task UpdateView(object? o, bool b)
+ {
+ await InvokeAsync(() =>
+ {
+ StateHasChanged();
+ });
+ }
}
diff --git a/Components/PointsTableRTD8TMComponent.razor b/Components/PointsTableRTD8TMComponent.razor
index 650165b..46b02b7 100644
--- a/Components/PointsTableRTD8TMComponent.razor
+++ b/Components/PointsTableRTD8TMComponent.razor
@@ -9,56 +9,82 @@
+@if (_RTD8TMService.GetActualData() != null)
+{
+
+
+
+ Time |
-
-
-
- Time |
-
- @foreach (byte stack in _RTD8TMService.GetActualData().Keys)
- {
- for (byte chanel = 0; chanel < 8; chanel++)
- {
- if (_RTD8TMService.GetChanelName(stack, chanel) != "----------")
- {
-
- @_RTD8TMService.GetChanelName(stack, chanel)
-
- @if (_RTD8TMService.GetValueType(stack, chanel) == RTD8TMSensorTypes.PT100)
- {
- @Celsius
- }
- else
- {
- @Ohm
- }
- |
- }
- }
- }
-
-
-
- @foreach (long time in TableData.Keys)
- {
-
- @(new DateTime(time).ToString("HH:mm:ss")) |
-
- @foreach (byte stack in TableData[time].Keys)
+ @foreach (byte stack in _RTD8TMService.GetActualData().Keys)
{
for (byte chanel = 0; chanel < 8; chanel++)
{
if (_RTD8TMService.GetChanelName(stack, chanel) != "----------")
{
- @(new RTD8TMChanelComponent().RecalculateValues(TableData[time][stack][chanel], _RTD8TMService.GetValueType(stack, chanel))) |
+
+ @_RTD8TMService.GetChanelName(stack, chanel)
+
+ @if (_RTD8TMService.GetValueType(stack, chanel) == RTD8TMSensorTypes.PT100)
+ {
+ @Celsius
+ }
+ else
+ {
+ @Ohm
+ }
+ |
}
}
}
- }
-
-
+
+
+ @foreach (long time in TableData.Keys)
+ {
+
+ @(new DateTime(time).ToString("HH:mm:ss")) |
+
+ @foreach (byte stack in TableData[time].Keys)
+ {
+ for (byte chanel = 0; chanel < 8; chanel++)
+ {
+ if (_RTD8TMService.GetChanelName(stack, chanel) != "----------")
+ {
+ @(new RTD8TMChanelComponent().RecalculateValues(TableData[time][stack][chanel], _RTD8TMService.GetValueType(stack, chanel))) |
+ }
+ }
+ }
+
+ }
+
+
+ @if (TableData.Keys.Count > 1)
+ {
+
+
+ 30min Change |
+
+ @foreach (byte stack in TableData[TableData.Keys.OrderDescending().First()].Keys)
+ {
+ for (byte chanel = 0; chanel < 8; chanel++)
+ {
+ if (_RTD8TMService.GetChanelName(stack, chanel) != "----------")
+ {
+ @Math.Round(new RTD8TMChanelComponent().RecalculateValues(TableData[LastDataTime][stack][chanel], _RTD8TMService.GetValueType(stack, chanel)) - new RTD8TMChanelComponent().RecalculateValues(TableData[AfterHalfHour][stack][chanel], _RTD8TMService.GetValueType(stack, chanel)), 2) |
+ }
+ }
+ }
+
+
+ }
+
+}
+else
+{
+
No data
+}
@code {
@@ -66,12 +92,14 @@
private string Ohm = " (Ω)";
private string Celsius = " (°C)";
private bool TableBackground = false;
+ private long LastDataTime = 0;
+ private long AfterHalfHour = 0;
protected override void OnInitialized()
{
TableData = _PointsService.GetPoints().RTD8TM;
-
+ _PointsService.EventPointPage += UpdateView;
}
private string TableBacgroundChanger()
@@ -88,14 +116,21 @@
}
}
+ private void HalfHourTime()
+ {
+ LastDataTime = TableData.Keys.OrderDescending().First();
+ long backhalfhour = new DateTime(LastDataTime).AddMinutes(-30).Ticks;
+ AfterHalfHour = TableData.Keys.OrderBy(item => Math.Abs(backhalfhour - item)).First();
+ }
-
-
-
-
-
-
-
-
+ public async Task UpdateView(object? o, bool b)
+ {
+ await InvokeAsync(() =>
+ {
+ TableBackground = false;
+ StateHasChanged();
+ HalfHourTime();
+ });
+ }
}
diff --git a/Components/RTD8TMChanelComponent.razor b/Components/RTD8TMChanelComponent.razor
index d08d7df..a823819 100644
--- a/Components/RTD8TMChanelComponent.razor
+++ b/Components/RTD8TMChanelComponent.razor
@@ -23,6 +23,12 @@
ChangeName(x.Value.ToString()))" >
}
+ else if (Calibration)
+ {
+
+ CalibrationChanged(x.Value.ToString()))">
+
+ }
else
{
@(RTD8tmService.GetChanelName(StackID, ChanelID))
@@ -42,6 +48,9 @@
[Parameter]
public bool Edit { get; set; }
+ [Parameter]
+ public bool Calibration { get; set; }
+
[Parameter]
public RTD8TMService RTD8tmService { get; set; }
@@ -61,6 +70,11 @@
RTD8tmService.SetChanelNames(StackID, ChanelID, NewName);
}
+ private void CalibrationChanged(string NewCalibration)
+ {
+ NewCalibration = NewCalibration.Replace(".", ",");
+ RTD8tmService.SetCalibration(StackID, ChanelID, float.Parse(NewCalibration));
+ }
public float RecalculateValues(float resistance, byte Type = 0)
diff --git a/Pages/PointsPage.razor b/Pages/PointsPage.razor
index f6ee40d..8ec450c 100644
--- a/Pages/PointsPage.razor
+++ b/Pages/PointsPage.razor
@@ -4,6 +4,10 @@
@using UI_SequentMicrosystems.Services
@using UI_SequentMicrosystems.Models
+@inject PointsService _PointsService
+@inject RTD8TMService _RTD8TMService
+@inject NavigationManager Navigator
+
Saved Points
@@ -21,7 +25,12 @@
@code {
+ protected override void OnInitialized()
+ {
+ //_RTD8TMService.SetAddress("http://10.250.251.131/");
+ _RTD8TMService.SetAddress(Navigator.BaseUri);
+ }
diff --git a/Pages/RTD8TMPage.razor b/Pages/RTD8TMPage.razor
index c83c1ef..652a0a5 100644
--- a/Pages/RTD8TMPage.razor
+++ b/Pages/RTD8TMPage.razor
@@ -15,22 +15,47 @@
Device Address: @_RTD8TMService.GetAddress() | DataUpdate: @_UpdateCounter | Chart Points: @_RTD8TMService.CountChartData() / @_RTD8TMService.CountFilteredChartData()
+
+
@if (EditName)
{
@@ -59,7 +84,7 @@
Stack ID: @StackID
@for (byte chanel = 0; chanel < 8; chanel++)
{
-
+
}
}
@@ -72,6 +97,7 @@
@code {
public int _UpdateCounter = 0;
private bool EditName = false;
+ private bool Calibration = false;
[CascadingParameter] public IModalService Modal { get; set; } = default!;
diff --git a/Pages/Start.razor b/Pages/Start.razor
index bf1512b..86a2e3e 100644
--- a/Pages/Start.razor
+++ b/Pages/Start.razor
@@ -6,8 +6,14 @@
Welcome
-
TesDevice App V1.0
-
+
+
TesDevice App V1.1
+
Added Automatic points Saving, Calibration and Calculating RTDCard values change in last 3O minutes in saved points
+
+
+
TesDevice App V1.O
+
Firt Fully function Build --> Reading RTD cards, RTD Graph, Points Saving and exporting as csv
+
diff --git a/Services/PointsService.cs b/Services/PointsService.cs
index 836ba5f..5629664 100644
--- a/Services/PointsService.cs
+++ b/Services/PointsService.cs
@@ -1,4 +1,5 @@
-using UI_SequentMicrosystems.Components;
+using System.Timers;
+using UI_SequentMicrosystems.Components;
using UI_SequentMicrosystems.Constants;
using UI_SequentMicrosystems.Models;
@@ -11,18 +12,24 @@ namespace UI_SequentMicrosystems.Services
private PointsModel _PointsModel = new();
private int PointsCount = 0;
+ private System.Timers.Timer _Timer = new System.Timers.Timer(300000);
+ public delegate Task AsyncEventHandler
(object? sender, TEventArgs? e);
+ public event AsyncEventHandler? EventUpdateTopBar;
+ public event AsyncEventHandler? EventPointPage;
public PointsService(RTD8TMService RTD8TM)
{
_RTD8TMService = RTD8TM;
+ _Timer.Elapsed += SavePoint;
+ _Timer.AutoReset = true;
}
///
/// Save actual data point
///
- public void SavePoint()
+ public async void SavePoint()
{
long time = DateTime.Now.Ticks;
_PointsModel.RTD8TM.Add(time, new());
@@ -42,8 +49,18 @@ namespace UI_SequentMicrosystems.Services
_PointsModel.RTD8TM[time][stack].Add(RTD8TMActual[stack][chanel]);
}
}
+
//other card types points saving
+ if (EventUpdateTopBar != null)
+ {
+ await EventUpdateTopBar.Invoke(this, true);
+ }
+
+ if (EventPointPage != null)
+ {
+ await EventPointPage.Invoke(this, true);
+ }
}
///
@@ -64,6 +81,7 @@ namespace UI_SequentMicrosystems.Services
return PointsCount;
}
+ //Create File Lines
///
/// Create Points Lines for CSV File
@@ -82,7 +100,6 @@ namespace UI_SequentMicrosystems.Services
return string.Join(Environment.NewLine, Lines);
}
-
///
/// Create Title Line of CSV File
///
@@ -179,8 +196,55 @@ namespace UI_SequentMicrosystems.Services
+ //Timer
+ private void SavePoint(object? o, ElapsedEventArgs? e)
+ {
+ SavePoint();
+ }
+ ///
+ /// Read Timer Interval
+ ///
+ /// Interval in seconds
+ public int GetTimerInterval()
+ {
+ return (int)(_Timer.Interval / 1000);
+ }
+
+ ///
+ /// Set Timer Interval
+ ///
+ /// interval in seconds
+ public void SetTimerInterval(int interval)
+ {
+ _Timer.Interval = interval * 1000;
+ }
+
+ ///
+ /// Start Timer
+ ///
+ public void StartTimer()
+ {
+ _Timer.Start();
+ }
+
+ ///
+ /// Stop Timer
+ ///
+ public void StopTimer()
+ {
+ _Timer.Stop();
+ }
+
+ ///
+ /// Get Timer status
+ ///
+ ///
+ public bool GetTImerStatus()
+ {
+ return _Timer.Enabled;
+ }
}
diff --git a/Services/RTD8TMService.cs b/Services/RTD8TMService.cs
index 6a7c266..d95575a 100644
--- a/Services/RTD8TMService.cs
+++ b/Services/RTD8TMService.cs
@@ -11,6 +11,7 @@ namespace UI_SequentMicrosystems.Services
private SortedList ChanelNames = new SortedList();
private SortedList ActualValues = new SortedList();
private SortedList ValuesType = new SortedList();
+ private SortedList Calibrations = new SortedList();
public SortedList>> GraphData = new();
public SortedList>> GraphFiltered = new();
private byte GraphDataCounterCount = 10;
@@ -44,6 +45,7 @@ namespace UI_SequentMicrosystems.Services
Address = address;
GetChanelsNames();
GetValueTypes();
+ GetCalibrations();
}
///
@@ -73,6 +75,18 @@ namespace UI_SequentMicrosystems.Services
ActualValues = await _RTD8TM.Get(Address);
+ foreach (byte stack in ActualValues.Keys)
+ {
+ if (Calibrations.ContainsKey(stack))
+ {
+ for (byte chanel = 0; chanel < 8; chanel++)
+ {
+ ActualValues[stack][chanel] += Calibrations[stack][chanel];
+ }
+ }
+ }
+
+
if (GraphDataCounter >= GraphDataCounterCount)
{
GraphDataCounter = 0;
@@ -482,6 +496,70 @@ namespace UI_SequentMicrosystems.Services
ValuesType.Clear();
}
+ //calibrations
+
+ ///
+ /// Read Calibrations from API
+ ///
+ private async void GetCalibrations()
+ {
+ if (Address == null) { return; }
+
+ Calibrations = await _RTD8TM.GetCalibration(Address);
+
+ foreach (byte stack in ActualValues.Keys)
+ {
+ if (!Calibrations.ContainsKey(stack))
+ {
+ Calibrations.Add(stack, new float[8]);
+ }
+ }
+ }
+
+ ///
+ /// Post calibrations to API
+ ///
+ public void PostCalibrations()
+ {
+ if (Address == null) { return; }
+
+ _RTD8TM.PostCalibration(Address, Calibrations);
+ }
+
+ ///
+ /// Get calibration of specific chanel
+ ///
+ ///
+ ///
+ ///
+ public float GetCalibration(byte stack, byte chanel)
+ {
+ if (Calibrations.ContainsKey(stack))
+ {
+ return Calibrations[stack][chanel];
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ ///
+ /// Set chanel Calibration Change
+ ///
+ ///
+ ///
+ ///
+ public void SetCalibration(byte stack, byte chanel, float value)
+ {
+ if (!Calibrations.ContainsKey(stack))
+ {
+ Calibrations.Add(stack, new float[8]);
+ }
+
+ Calibrations[stack][chanel] = value;
+ }
+
}
}