-
Device Address: @_RTD8TMService.GetAddress() | DataUpdate: @_UpdateCounter |
+
Device Address: @_RTD8TMService.GetAddress() | DataUpdate: @_UpdateCounter | Chart Points: @_RTD8TMService.CountChartData() / @_RTD8TMService.CountFilteredChartData()
@if (EditName)
@@ -40,6 +41,7 @@
}
+
@@ -75,7 +77,8 @@
protected override void OnInitialized()
{
- _RTD8TMService.SetAddress("http://10.1.20.5/");//Navigator.BaseUri);
+ //_RTD8TMService.SetAddress("http://10.250.251.131/");
+ _RTD8TMService.SetAddress(Navigator.BaseUri);
_RTD8TMService.EventUpdateValues += UpdateView;
}
diff --git a/Pages/Start.razor b/Pages/Start.razor
index fc2f45e..bf1512b 100644
--- a/Pages/Start.razor
+++ b/Pages/Start.razor
@@ -4,11 +4,11 @@
@inject NavigationManager Navigator
@inject RTD8TMService _RTD8TMService
-
Home
+
Welcome
+
+
TesDevice App V1.0
-
Hello, world!
-Welcome to your new app.
@@ -17,7 +17,8 @@ Welcome to your new app.
protected override void OnInitialized()
{
- _RTD8TMService.SetAddress("http://10.1.20.5/");// Navigator.BaseUri);
+ //_RTD8TMService.SetAddress("http://10.250.251.131/");
+ _RTD8TMService.SetAddress(Navigator.BaseUri);
diff --git a/Program.cs b/Program.cs
index 40445fa..0b4a6c2 100644
--- a/Program.cs
+++ b/Program.cs
@@ -17,6 +17,7 @@ namespace UI_SequentMicrosystems
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddSingleton
();
+ builder.Services.AddSingleton();
await builder.Build().RunAsync();
}
diff --git a/Services/PointsService.cs b/Services/PointsService.cs
new file mode 100644
index 0000000..836ba5f
--- /dev/null
+++ b/Services/PointsService.cs
@@ -0,0 +1,187 @@
+using UI_SequentMicrosystems.Components;
+using UI_SequentMicrosystems.Constants;
+using UI_SequentMicrosystems.Models;
+
+namespace UI_SequentMicrosystems.Services
+{
+ public class PointsService
+ {
+ private RTD8TMService _RTD8TMService { get; set; }
+
+
+ private PointsModel _PointsModel = new();
+ private int PointsCount = 0;
+
+
+ public PointsService(RTD8TMService RTD8TM)
+ {
+ _RTD8TMService = RTD8TM;
+ }
+
+
+ ///
+ /// Save actual data point
+ ///
+ public void SavePoint()
+ {
+ long time = DateTime.Now.Ticks;
+ _PointsModel.RTD8TM.Add(time, new());
+ PointsCount++;
+
+ //Read RTD8TM actual data to point
+ SortedList RTD8TMActual = _RTD8TMService.GetActualData();
+ foreach (byte stack in RTD8TMActual.Keys)
+ {
+ if (!_PointsModel.RTD8TM[time].ContainsKey(stack))
+ {
+ _PointsModel.RTD8TM[time].Add(stack, new());
+ }
+
+ for (byte chanel = 0; chanel < 8; chanel++)
+ {
+ _PointsModel.RTD8TM[time][stack].Add(RTD8TMActual[stack][chanel]);
+ }
+ }
+ //other card types points saving
+
+ }
+
+ ///
+ /// Read points
+ ///
+ ///
+ public PointsModel GetPoints()
+ {
+ return _PointsModel;
+ }
+
+ ///
+ /// Get points Count
+ ///
+ ///
+ public int GetPointsCount()
+ {
+ return PointsCount;
+ }
+
+
+ ///
+ /// Create Points Lines for CSV File
+ ///
+ ///
+ #pragma warning disable CS1998 // V této asynchronní metodě chybí operátory await a spustí se synchronně.
+ public async Task CreatePointsFileLines(bool recalculate)
+ #pragma warning restore CS1998 // V této asynchronní metodě chybí operátory await a spustí se synchronně.
+ {
+ List Lines = new List();
+
+ Lines.Add(CreateTitleLine(recalculate));
+
+ Lines.AddRange(CreateDataLines(recalculate));
+
+ return string.Join(Environment.NewLine, Lines);
+ }
+
+
+ ///
+ /// Create Title Line of CSV File
+ ///
+ ///
+ private string CreateTitleLine(bool Recalculate)
+ {
+ string Line = "Time";
+
+ //RTD8TM
+ foreach (long time in _PointsModel.RTD8TM.Keys)
+ {
+ foreach (byte stack in _RTD8TMService.GetActualData().Keys)
+ {
+ for (byte chanel = 0; chanel < 8; chanel++)
+ {
+ if (_RTD8TMService.GetChanelName(stack, chanel) != "----------")
+ {
+ if (!Line.EndsWith(";"))
+ Line += ";";
+
+ if (Recalculate && _RTD8TMService.GetValueType(stack, chanel) == RTD8TMSensorTypes.PT100)
+ {
+ Line += $"{_RTD8TMService.GetChanelName(stack, chanel)} °C";
+ }
+ else
+ {
+ Line += $"{_RTD8TMService.GetChanelName(stack, chanel)} Ω";
+ }
+ }
+ }
+ }
+
+ break;
+ }
+
+ //other types
+
+ return Line;
+ }
+
+ ///
+ /// Create Data Lines of CSV File
+ ///
+ ///
+ private List CreateDataLines(bool Recalculate)
+ {
+ Console.WriteLine("Creting Data Lines");
+
+ List Lines = new();
+
+ //RTD8TM
+ foreach (long time in _PointsModel.RTD8TM.Keys)
+ {
+ Console.WriteLine($"DataLine Time: {new DateTime(time).ToString("HH:mm:ss")}");
+
+ string Line = new DateTime(time).ToString("HH:mm:ss");
+
+ foreach (byte stack in _PointsModel.RTD8TM[time].Keys)
+ {
+ Console.WriteLine($"DataLine Stack: {stack}");
+
+ for (byte chanel = 0; chanel < 8; chanel++)
+ {
+ Console.WriteLine($"DataLine Chanel: {chanel}");
+
+ if (_RTD8TMService.GetChanelName(stack, chanel) != "----------")
+ {
+ Console.WriteLine($"DataLine No default Name");
+
+ if (!Line.EndsWith(";"))
+ Line += ";";
+
+ if (Recalculate)
+ {
+ Line += new RTD8TMChanelComponent().RecalculateValues(_PointsModel.RTD8TM[time][stack][chanel], _RTD8TMService.GetValueType(stack, chanel)).ToString();
+ }
+ else
+ {
+ Line += _PointsModel.RTD8TM[time][stack][chanel].ToString();
+ }
+
+ }
+ }
+ }
+
+ //Other Types
+
+
+ Lines.Add(Line);
+ }
+
+ return Lines;
+ }
+
+
+
+
+
+
+
+ }
+}
diff --git a/Services/RTD8TMService.cs b/Services/RTD8TMService.cs
index f6d7f35..6a7c266 100644
--- a/Services/RTD8TMService.cs
+++ b/Services/RTD8TMService.cs
@@ -1,4 +1,5 @@
-using System.Timers;
+using System.Threading.Channels;
+using System.Timers;
using UI_SequentMicrosystems.Components;
using UI_SequentMicrosystems.Models;
using Wrapper_Api_SequentMicrosystems.RTD8TM;
@@ -10,7 +11,8 @@ namespace UI_SequentMicrosystems.Services
private SortedList ChanelNames = new SortedList();
private SortedList ActualValues = new SortedList();
private SortedList ValuesType = new SortedList();
- public SortedList>> GraphData = new();
+ public SortedList>> GraphData = new();
+ public SortedList>> GraphFiltered = new();
private byte GraphDataCounterCount = 10;
private byte GraphDataCounter = 9;
@@ -256,23 +258,36 @@ namespace UI_SequentMicrosystems.Services
for (byte chanel = 0; chanel < 8; chanel++)
{
- GraphData[stack][chanel].Add(new RTD8TMGraphPointModel() { Value = new RTD8TMChanelComponent().RecalculateValues(ActualValues[stack][chanel], GetValueType(stack, chanel)), Time = time });
+ GraphData[stack][chanel].Add(new RTD8TMPointModel() { Value = ActualValues[stack][chanel], Time = time });
}
}
+
+ GetFilteredChartData();
}
///
/// Get data for graph visualize
///
/// saved chart chanel Data
- public List GetChartData(byte StackID, byte Chanel)
+ public List GetChartData(byte StackID, byte Chanel)
{
- if (!GraphData.ContainsKey(StackID))
+ if (!GraphFiltered.ContainsKey(StackID))
{
- return new List();
+ return new List();
}
- return GraphData[StackID][Chanel];
+ List RecalculatedData = new();
+ byte chanelRecalcTo = GetValueType(StackID, Chanel);
+
+ foreach (RTD8TMPointModel point in GraphFiltered[StackID][Chanel])
+ {
+ RTD8TMPointModel recalculated = new() { Time = point.Time, Value = new RTD8TMChanelComponent().RecalculateValues(point.Value, chanelRecalcTo) };
+ RecalculatedData.Add(recalculated);
+ }
+
+
+
+ return RecalculatedData;
}
///
@@ -283,7 +298,128 @@ namespace UI_SequentMicrosystems.Services
GraphData.Clear();
}
+ private void GetFilteredChartData()
+ {
+ foreach ( byte stack in GraphData.Keys)
+ {
+ int pointsCount = GraphData[stack][0].Count;
+ int counter = 0;
+ if (pointsCount < 100)
+ {
+ GraphFiltered = GraphData;
+ }
+ else if (pointsCount > 100 && pointsCount < 500) // one from five
+ {
+ GraphFiltered = new();
+ GraphFiltered.Add(stack, new());
+
+ for (int chanel = 0; chanel < 8; chanel++)
+ {
+ GraphFiltered[stack].Add(new());
+ foreach (RTD8TMPointModel GraphPoint in GraphData[stack][chanel])
+ {
+ if (counter > 3)
+ {
+ GraphFiltered[stack][chanel].Add(GraphPoint);
+ counter = 0;
+ }
+ else
+ {
+ counter++;
+ }
+ }
+ }
+ }
+ else if (pointsCount > 500 && pointsCount < 1000) // one from ten
+ {
+ GraphFiltered = new();
+ GraphFiltered.Add(stack, new());
+
+ for (int chanel = 0; chanel < 8; chanel++)
+ {
+ GraphFiltered[stack].Add(new());
+ foreach (RTD8TMPointModel GraphPoint in GraphData[stack][chanel])
+ {
+ if (counter > 8)
+ {
+ GraphFiltered[stack][chanel].Add(GraphPoint);
+ counter = 0;
+ }
+ else
+ {
+ counter++;
+ }
+ }
+ }
+ }
+ else if (pointsCount > 1000 && pointsCount < 1500) // one from fifteen
+ {
+ GraphFiltered = new();
+ GraphFiltered.Add(stack, new());
+
+ for (int chanel = 0; chanel < 8; chanel++)
+ {
+ GraphFiltered[stack].Add(new());
+ foreach (RTD8TMPointModel GraphPoint in GraphData[stack][chanel])
+ {
+ if (counter > 13)
+ {
+ GraphFiltered[stack][chanel].Add(GraphPoint);
+ counter = 0;
+ }
+ else
+ {
+ counter++;
+ }
+ }
+ }
+ }
+ else if (pointsCount > 1500) // one from twenty
+ {
+ GraphFiltered = new();
+ GraphFiltered.Add(stack, new());
+
+ for (int chanel = 0; chanel < 8; chanel++)
+ {
+ GraphFiltered[stack].Add(new());
+ foreach (RTD8TMPointModel GraphPoint in GraphData[stack][chanel])
+ {
+ if (counter > 18)
+ {
+ GraphFiltered[stack][chanel].Add(GraphPoint);
+ counter = 0;
+ }
+ else
+ {
+ counter++;
+ }
+ }
+ }
+ }
+ //případně další
+
+ }
+ }
+
+ public int CountFilteredChartData()
+ {
+ foreach (byte stack in GraphFiltered.Keys)
+ {
+ return GraphFiltered[stack][0].Count;
+ }
+
+ return 0;
+ }
+ public int CountChartData()
+ {
+ foreach (byte stack in GraphData.Keys)
+ {
+ return GraphData[stack][0].Count;
+ }
+
+ return 0;
+ }
//Values Types
diff --git a/wwwroot/DownloadFile.js b/wwwroot/DownloadFile.js
new file mode 100644
index 0000000..a6472e0
--- /dev/null
+++ b/wwwroot/DownloadFile.js
@@ -0,0 +1,14 @@
+window.DownloadFile = function (fileName, content) {
+ const blob = new Blob([content], { type: "text/plain;charset=utf-8" });
+ const url = URL.createObjectURL(blob);
+
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = fileName;
+ document.body.appendChild(a);
+ a.click();
+
+ // Po stisknutí tlačítka, odstraníme element a URL objekt
+ document.body.removeChild(a);
+ URL.revokeObjectURL(url);
+};
\ No newline at end of file
diff --git a/wwwroot/index.html b/wwwroot/index.html
index 0c3620c..c6de9fa 100644
--- a/wwwroot/index.html
+++ b/wwwroot/index.html
@@ -33,6 +33,7 @@
+