From c23ace2300f1a2461108837a218a7538e1ebab62 Mon Sep 17 00:00:00 2001 From: sam_hajdukiewicz Date: Sun, 20 Oct 2024 11:37:36 -0500 Subject: [PATCH 1/5] Current set up for the Raman Spectroscopy graph. --- Basestation_Software.Api/Data/data.db-shm | Bin 32768 -> 0 bytes Basestation_Software.Api/Data/data.db-wal | 0 .../Core/Components/RamanGraph.razor | 150 ++++++++++++++++-- .../Core/Services/RamanGraphService.cs | 15 +- 4 files changed, 145 insertions(+), 20 deletions(-) delete mode 100644 Basestation_Software.Api/Data/data.db-shm delete mode 100644 Basestation_Software.Api/Data/data.db-wal diff --git a/Basestation_Software.Api/Data/data.db-shm b/Basestation_Software.Api/Data/data.db-shm deleted file mode 100644 index fe9ac2845eca6fe6da8a63cd096d9cf9e24ece10..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32768 zcmeIuAr62r3 -
-
-
-
RamanGraph
-
-
+
+
Raman Spectroscopy Graph
-
+

+ + + +

+ + @code { + //Variables + private static List _raman1 = new List(500), + _raman2 = new List(500), + _raman3 = new List(500), + _raman4 = new List(500), + _raman5 = new List(48); - BlazorPlot BlazorPlot { get; set; } = new(); - protected override void OnAfterRender(bool firstRender) + class DataItem { - BlazorPlot.Plot.Add.Signal(Generate.Sin()); - BlazorPlot.Plot.Add.Signal(Generate.Cos()); + public int Raman_Shift { get; set; } + public double Intensity { get; set; } + + public DataItem() + { + Raman_Shift = 0; + Intensity = 0f; + } + } + + DataItem[] ramanGraph = new DataItem[2048]; + + + private async void RequestRamanData() + { + await _RoveCommService.SendAsync("Instruments", "RequestRamanReading", [0], reliable: false); + + for (int i = 0; i < 2048; i++) + { + if (i < 500) + { + ramanGraph[i] = new DataItem + { + Raman_Shift = i, + Intensity = _raman1[i], + }; + } + else if (i >= 500 && i < 1000) + { + ramanGraph[i] = new DataItem + { + Raman_Shift = i, + Intensity = _raman2[i - 500], + }; + } + + else if (i >= 1000 && i < 1500) + { + ramanGraph[i] = new DataItem + { + Raman_Shift = i, + Intensity = _raman3[i - 1000], + }; + } + + else if (i >= 1500 && i < 2000) + { + ramanGraph[i] = new DataItem + { + Raman_Shift = i, + Intensity = _raman4[i - 1500], + }; + } + + else + { + ramanGraph[i] = new DataItem + { + Raman_Shift = i, + Intensity = _raman5[i - 2000], + }; + } + } } -} + + + protected override async Task OnInitializedAsync() + { + //Initialize values of ramanGraph and _raman variables to not throw errors if RoveComm packets not sent + for (int i = 0; i < 2048; i++) + { + ramanGraph[i] = new DataItem(); + } + + for (int i = 0; i < 500; i++) + { + _raman1.Add(0); + _raman2.Add(0); + _raman3.Add(0); + _raman4.Add(0); + } + + for (int i = 0; i < 48; i++) + { + _raman5.Add(0); + } + + //Receiving RoveComm packets if they are sent in + _RoveCommService.On("Instruments", "RamanReading_Part1", async (packet) => + { + _raman1 = packet.Data; + await InvokeAsync(StateHasChanged); + }); + + await Task.CompletedTask; + _RoveCommService.On("Instruments", "RamanReading_Part2", async (packet) => + { + _raman2 = packet.Data; + await InvokeAsync(StateHasChanged); + }); + + _RoveCommService.On("Instruments", "RamanReading_Part3", async (packet) => + { + _raman3 = packet.Data; + await InvokeAsync(StateHasChanged); + }); + + _RoveCommService.On("Instruments", "RamanReading_Part4", async (packet) => + { + _raman4 = packet.Data; + await InvokeAsync(StateHasChanged); + }); + + _RoveCommService.On("Instruments", "RamanReading_Part5", async (packet) => + { + _raman5 = packet.Data; + await InvokeAsync(StateHasChanged); + }); + } +} \ No newline at end of file diff --git a/Basestation_Software.Web/Core/Services/RamanGraphService.cs b/Basestation_Software.Web/Core/Services/RamanGraphService.cs index 76e9df4..9bc5992 100644 --- a/Basestation_Software.Web/Core/Services/RamanGraphService.cs +++ b/Basestation_Software.Web/Core/Services/RamanGraphService.cs @@ -1,12 +1,15 @@ -using ScottPlot.Blazor; -using ScottPlot; - -namespace Basestation_Software.Web.Core.Services +namespace Basestation_Software.Web.Core.Services { public class RamanGraphService { - BlazorPlot BlazorPlot { get; set; } = new(); + class DataItem + { + public int Raman_Shift { get; set; } + public double Intensity { get; set; } + } + + } + - } } From 6ce2e3c344ac81595d9f82f6e07ac1b49b185c0b Mon Sep 17 00:00:00 2001 From: Brendan Westley Date: Sun, 20 Oct 2024 17:35:51 -0500 Subject: [PATCH 2/5] Update raman graph after data is received and not before --- .../Core/Components/RamanGraph.razor | 94 ++----------------- 1 file changed, 9 insertions(+), 85 deletions(-) diff --git a/Basestation_Software.Web/Core/Components/RamanGraph.razor b/Basestation_Software.Web/Core/Components/RamanGraph.razor index fe0d003..cbb5f29 100644 --- a/Basestation_Software.Web/Core/Components/RamanGraph.razor +++ b/Basestation_Software.Web/Core/Components/RamanGraph.razor @@ -7,6 +7,7 @@

+

@@ -14,132 +15,55 @@ @code { - //Variables - private static List _raman1 = new List(500), - _raman2 = new List(500), - _raman3 = new List(500), - _raman4 = new List(500), - _raman5 = new List(48); - - class DataItem { public int Raman_Shift { get; set; } public double Intensity { get; set; } - - public DataItem() - { - Raman_Shift = 0; - Intensity = 0f; - } } DataItem[] ramanGraph = new DataItem[2048]; - private async void RequestRamanData() + private async Task RequestRamanData() { await _RoveCommService.SendAsync("Instruments", "RequestRamanReading", [0], reliable: false); - - for (int i = 0; i < 2048; i++) - { - if (i < 500) - { - ramanGraph[i] = new DataItem - { - Raman_Shift = i, - Intensity = _raman1[i], - }; - } - else if (i >= 500 && i < 1000) - { - ramanGraph[i] = new DataItem - { - Raman_Shift = i, - Intensity = _raman2[i - 500], - }; - } - - else if (i >= 1000 && i < 1500) - { - ramanGraph[i] = new DataItem - { - Raman_Shift = i, - Intensity = _raman3[i - 1000], - }; - } - - else if (i >= 1500 && i < 2000) - { - ramanGraph[i] = new DataItem - { - Raman_Shift = i, - Intensity = _raman4[i - 1500], - }; - } - - else - { - ramanGraph[i] = new DataItem - { - Raman_Shift = i, - Intensity = _raman5[i - 2000], - }; - } - } } - protected override async Task OnInitializedAsync() { - //Initialize values of ramanGraph and _raman variables to not throw errors if RoveComm packets not sent + // Initialize ramanGraph for (int i = 0; i < 2048; i++) - { - ramanGraph[i] = new DataItem(); - } - - for (int i = 0; i < 500; i++) - { - _raman1.Add(0); - _raman2.Add(0); - _raman3.Add(0); - _raman4.Add(0); - } - - for (int i = 0; i < 48; i++) - { - _raman5.Add(0); - } + ramanGraph[i] = new DataItem { Raman_Shift = i, Intensity = 0 }; //Receiving RoveComm packets if they are sent in _RoveCommService.On("Instruments", "RamanReading_Part1", async (packet) => { - _raman1 = packet.Data; + for (int i = 0; i < 500; i++) ramanGraph[i].Intensity = packet.Data[i]; await InvokeAsync(StateHasChanged); }); await Task.CompletedTask; _RoveCommService.On("Instruments", "RamanReading_Part2", async (packet) => { - _raman2 = packet.Data; + for (int i = 0; i < 500; i++) ramanGraph[i + 500].Intensity = packet.Data[i]; await InvokeAsync(StateHasChanged); }); _RoveCommService.On("Instruments", "RamanReading_Part3", async (packet) => { - _raman3 = packet.Data; + for (int i = 0; i < 500; i++) ramanGraph[i + 1000].Intensity = packet.Data[i]; await InvokeAsync(StateHasChanged); }); _RoveCommService.On("Instruments", "RamanReading_Part4", async (packet) => { - _raman4 = packet.Data; + for (int i = 0; i < 500; i++) ramanGraph[i + 1500].Intensity = packet.Data[i]; await InvokeAsync(StateHasChanged); }); _RoveCommService.On("Instruments", "RamanReading_Part5", async (packet) => { - _raman5 = packet.Data; + for (int i = 0; i < 48; i++) ramanGraph[i + 2000].Intensity = packet.Data[i]; await InvokeAsync(StateHasChanged); }); } From 6d7ba338c755fd2fc5c00fbc546ad6f2c7b0099e Mon Sep 17 00:00:00 2001 From: sam_hajdukiewicz Date: Wed, 23 Oct 2024 10:55:28 -0500 Subject: [PATCH 3/5] Moved the DataItem class to .Models --- Basestation_Software.Api/Data/data.db-shm | Bin 0 -> 32768 bytes Basestation_Software.Api/Data/data.db-wal | 0 Basestation_Software.Models/RamanGraphType.cs | 21 ++++++++++++++++++ .../Basestation_Software.Web.csproj | 1 + .../Core/Components/RamanGraph.razor | 6 +---- .../Core/Services/RamanGraphService.cs | 11 +-------- Basestation_Software.Web/Program.cs | 1 + 7 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 Basestation_Software.Api/Data/data.db-shm create mode 100644 Basestation_Software.Api/Data/data.db-wal create mode 100644 Basestation_Software.Models/RamanGraphType.cs diff --git a/Basestation_Software.Api/Data/data.db-shm b/Basestation_Software.Api/Data/data.db-shm new file mode 100644 index 0000000000000000000000000000000000000000..fe9ac2845eca6fe6da8a63cd096d9cf9e24ece10 GIT binary patch literal 32768 zcmeIuAr62r3 + diff --git a/Basestation_Software.Web/Core/Components/RamanGraph.razor b/Basestation_Software.Web/Core/Components/RamanGraph.razor index cbb5f29..2c29eb7 100644 --- a/Basestation_Software.Web/Core/Components/RamanGraph.razor +++ b/Basestation_Software.Web/Core/Components/RamanGraph.razor @@ -1,4 +1,5 @@ @inject RoveCommService _RoveCommService +@using static Basestation_Software.Models.RamanGraphType
@@ -15,11 +16,6 @@ @code { - class DataItem - { - public int Raman_Shift { get; set; } - public double Intensity { get; set; } - } DataItem[] ramanGraph = new DataItem[2048]; diff --git a/Basestation_Software.Web/Core/Services/RamanGraphService.cs b/Basestation_Software.Web/Core/Services/RamanGraphService.cs index 9bc5992..f66a928 100644 --- a/Basestation_Software.Web/Core/Services/RamanGraphService.cs +++ b/Basestation_Software.Web/Core/Services/RamanGraphService.cs @@ -1,15 +1,6 @@ namespace Basestation_Software.Web.Core.Services { - public class RamanGraphService - { - class DataItem - { - public int Raman_Shift { get; set; } - public double Intensity { get; set; } - } - - - } + public class RamanGraphService{} } diff --git a/Basestation_Software.Web/Program.cs b/Basestation_Software.Web/Program.cs index 64254ba..23fee68 100644 --- a/Basestation_Software.Web/Program.cs +++ b/Basestation_Software.Web/Program.cs @@ -25,6 +25,7 @@ builder.Services.AddHttpClient(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); +builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddHostedService((sp) => sp.GetRequiredService()); From 3dfaae9249f3315edfa76136796c8fdc0824645f Mon Sep 17 00:00:00 2001 From: mjjm4d Date: Wed, 23 Oct 2024 21:09:59 -0500 Subject: [PATCH 4/5] Cleanup some raman files --- .../RamanGraph/DataItem.cs | 13 ++++++++++++ Basestation_Software.Models/RamanGraphType.cs | 21 ------------------- .../Core/Components/RamanGraph.razor | 5 ++--- .../Core/Services/RamanGraphService.cs | 6 ------ Basestation_Software.Web/Program.cs | 1 - 5 files changed, 15 insertions(+), 31 deletions(-) create mode 100644 Basestation_Software.Models/RamanGraph/DataItem.cs delete mode 100644 Basestation_Software.Models/RamanGraphType.cs delete mode 100644 Basestation_Software.Web/Core/Services/RamanGraphService.cs diff --git a/Basestation_Software.Models/RamanGraph/DataItem.cs b/Basestation_Software.Models/RamanGraph/DataItem.cs new file mode 100644 index 0000000..e2c5473 --- /dev/null +++ b/Basestation_Software.Models/RamanGraph/DataItem.cs @@ -0,0 +1,13 @@ +namespace Basestation_Software.Models.RamanGraph; + +public class DataItem +{ + public int Raman_Shift { get; set; } + public double Intensity { get; set; } + + public DataItem() + { + Raman_Shift = 0; + Intensity = 0f; + } +} diff --git a/Basestation_Software.Models/RamanGraphType.cs b/Basestation_Software.Models/RamanGraphType.cs deleted file mode 100644 index 9dcfbcf..0000000 --- a/Basestation_Software.Models/RamanGraphType.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Basestation_Software.Models; -public class RamanGraphType -{ - public class DataItem - { - public int Raman_Shift { get; set; } - public double Intensity { get; set; } - - public DataItem() - { - Raman_Shift = 0; - Intensity = 0f; - } - } -} diff --git a/Basestation_Software.Web/Core/Components/RamanGraph.razor b/Basestation_Software.Web/Core/Components/RamanGraph.razor index 2c29eb7..601903b 100644 --- a/Basestation_Software.Web/Core/Components/RamanGraph.razor +++ b/Basestation_Software.Web/Core/Components/RamanGraph.razor @@ -1,5 +1,5 @@ @inject RoveCommService _RoveCommService -@using static Basestation_Software.Models.RamanGraphType +@using Basestation_Software.Models.RamanGraph
@@ -16,7 +16,6 @@ @code { - DataItem[] ramanGraph = new DataItem[2048]; @@ -63,4 +62,4 @@ await InvokeAsync(StateHasChanged); }); } -} \ No newline at end of file +} diff --git a/Basestation_Software.Web/Core/Services/RamanGraphService.cs b/Basestation_Software.Web/Core/Services/RamanGraphService.cs deleted file mode 100644 index f66a928..0000000 --- a/Basestation_Software.Web/Core/Services/RamanGraphService.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Basestation_Software.Web.Core.Services -{ - public class RamanGraphService{} - - -} diff --git a/Basestation_Software.Web/Program.cs b/Basestation_Software.Web/Program.cs index 23fee68..64254ba 100644 --- a/Basestation_Software.Web/Program.cs +++ b/Basestation_Software.Web/Program.cs @@ -25,7 +25,6 @@ builder.Services.AddHttpClient(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); -builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddHostedService((sp) => sp.GetRequiredService()); From 91fca6c6176301159f2e12b0d8d0426cbdf7eb39 Mon Sep 17 00:00:00 2001 From: Brendan Westley Date: Wed, 30 Oct 2024 20:08:09 -0500 Subject: [PATCH 5/5] Adapt RamanGraph for custom layout --- Basestation_Software.Web/Core/Components/RamanGraph.razor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Basestation_Software.Web/Core/Components/RamanGraph.razor b/Basestation_Software.Web/Core/Components/RamanGraph.razor index 601903b..35439d3 100644 --- a/Basestation_Software.Web/Core/Components/RamanGraph.razor +++ b/Basestation_Software.Web/Core/Components/RamanGraph.razor @@ -1,17 +1,17 @@ @inject RoveCommService _RoveCommService @using Basestation_Software.Models.RamanGraph -
+
Raman Spectroscopy Graph
-

+

-

+