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.Web/Basestation_Software.Web.csproj b/Basestation_Software.Web/Basestation_Software.Web.csproj index 1926b95..db945c7 100644 --- a/Basestation_Software.Web/Basestation_Software.Web.csproj +++ b/Basestation_Software.Web/Basestation_Software.Web.csproj @@ -13,6 +13,7 @@ + diff --git a/Basestation_Software.Web/Core/Components/RamanGraph.razor b/Basestation_Software.Web/Core/Components/RamanGraph.razor index 5d49465..35439d3 100644 --- a/Basestation_Software.Web/Core/Components/RamanGraph.razor +++ b/Basestation_Software.Web/Core/Components/RamanGraph.razor @@ -1,24 +1,65 @@ -@using ScottPlot -@using ScottPlot.Blazor - -
-
-
-
-
RamanGraph
-
-
+@inject RoveCommService _RoveCommService +@using Basestation_Software.Models.RamanGraph + +
+
+
Raman Spectroscopy Graph
+
+
+ + + + +
-
+
@code { + DataItem[] ramanGraph = new DataItem[2048]; - BlazorPlot BlazorPlot { get; set; } = new(); - protected override void OnAfterRender(bool firstRender) + private async Task RequestRamanData() { - BlazorPlot.Plot.Add.Signal(Generate.Sin()); - BlazorPlot.Plot.Add.Signal(Generate.Cos()); + await _RoveCommService.SendAsync("Instruments", "RequestRamanReading", [0], reliable: false); } + + protected override async Task OnInitializedAsync() + { + // Initialize ramanGraph + for (int i = 0; i < 2048; i++) + ramanGraph[i] = new DataItem { Raman_Shift = i, Intensity = 0 }; + + //Receiving RoveComm packets if they are sent in + _RoveCommService.On("Instruments", "RamanReading_Part1", async (packet) => + { + 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) => + { + for (int i = 0; i < 500; i++) ramanGraph[i + 500].Intensity = packet.Data[i]; + await InvokeAsync(StateHasChanged); + }); + + _RoveCommService.On("Instruments", "RamanReading_Part3", async (packet) => + { + for (int i = 0; i < 500; i++) ramanGraph[i + 1000].Intensity = packet.Data[i]; + await InvokeAsync(StateHasChanged); + }); + + _RoveCommService.On("Instruments", "RamanReading_Part4", async (packet) => + { + for (int i = 0; i < 500; i++) ramanGraph[i + 1500].Intensity = packet.Data[i]; + await InvokeAsync(StateHasChanged); + }); + + _RoveCommService.On("Instruments", "RamanReading_Part5", async (packet) => + { + for (int i = 0; i < 48; i++) ramanGraph[i + 2000].Intensity = packet.Data[i]; + await InvokeAsync(StateHasChanged); + }); + } } diff --git a/Basestation_Software.Web/Core/Services/RamanGraphService.cs b/Basestation_Software.Web/Core/Services/RamanGraphService.cs deleted file mode 100644 index 76e9df4..0000000 --- a/Basestation_Software.Web/Core/Services/RamanGraphService.cs +++ /dev/null @@ -1,12 +0,0 @@ -using ScottPlot.Blazor; -using ScottPlot; - -namespace Basestation_Software.Web.Core.Services -{ - public class RamanGraphService - { - BlazorPlot BlazorPlot { get; set; } = new(); - - - } -}