-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from MissouriMRDT/feature/raman-graph
Raman Spectroscopy Graph
- Loading branch information
Showing
4 changed files
with
70 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 56 additions & 15 deletions
71
Basestation_Software.Web/Core/Components/RamanGraph.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,65 @@ | ||
@using ScottPlot | ||
@using ScottPlot.Blazor | ||
|
||
<div class="card full-height"> | ||
<div class="card-header"> | ||
<div class="row"> | ||
<div class="col-6 d-flex align-self-center"> | ||
<h5>RamanGraph</h5> | ||
</div> | ||
</div> | ||
@inject RoveCommService _RoveCommService | ||
@using Basestation_Software.Models.RamanGraph | ||
|
||
<div class="card h-100"> | ||
<div class="card-header"> | ||
<h5>Raman Spectroscopy Graph</h5> | ||
</div> | ||
<div class="card-body w-100"> | ||
<RadzenChart> | ||
<RadzenLineSeries Data="@ramanGraph" CategoryProperty="Raman_Shift" ValueProperty="Intensity" /> | ||
<RadzenValueAxis Min="0" Max="65535" Step="10000" /> | ||
</RadzenChart> | ||
<button @onclick=RequestRamanData> Request Raman Spectroscopy Data </button> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
@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<uint>("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<ushort>("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<ushort>("Instruments", "RamanReading_Part2", async (packet) => | ||
{ | ||
for (int i = 0; i < 500; i++) ramanGraph[i + 500].Intensity = packet.Data[i]; | ||
await InvokeAsync(StateHasChanged); | ||
}); | ||
|
||
_RoveCommService.On<ushort>("Instruments", "RamanReading_Part3", async (packet) => | ||
{ | ||
for (int i = 0; i < 500; i++) ramanGraph[i + 1000].Intensity = packet.Data[i]; | ||
await InvokeAsync(StateHasChanged); | ||
}); | ||
|
||
_RoveCommService.On<ushort>("Instruments", "RamanReading_Part4", async (packet) => | ||
{ | ||
for (int i = 0; i < 500; i++) ramanGraph[i + 1500].Intensity = packet.Data[i]; | ||
await InvokeAsync(StateHasChanged); | ||
}); | ||
|
||
_RoveCommService.On<ushort>("Instruments", "RamanReading_Part5", async (packet) => | ||
{ | ||
for (int i = 0; i < 48; i++) ramanGraph[i + 2000].Intensity = packet.Data[i]; | ||
await InvokeAsync(StateHasChanged); | ||
}); | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
Basestation_Software.Web/Core/Services/RamanGraphService.cs
This file was deleted.
Oops, something went wrong.