Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove schedule web api #100

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions src/Qynit.PulseGen.Server/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Fast.Components.FluentUI;

using Qynit.PulseGen.Server.Models;
using Qynit.PulseGen.Server.Services;

namespace Qynit.PulseGen.Server;
Expand Down Expand Up @@ -44,8 +43,6 @@ public static Server CreateApp(string[] args, bool embedded)
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");

app.AddScheduleApi();

return new Server(app);
}

Expand Down Expand Up @@ -110,31 +107,6 @@ public Task WaitForStartAsync(CancellationToken cancellationToken)

internal static class BuilderExtensions
{
internal static void AddScheduleApi(this WebApplication app)
{
const string contentType = "application/msgpack";

app.MapPost("/api/schedule", async (HttpRequest request, HttpResponse response, CancellationToken token, IPlotService plotService) =>
{
if (request.ContentType != contentType)
{
return Results.BadRequest();
}

var pgRequest = await MessagePackSerializer.DeserializeAsync<ScheduleRequest>(request.Body, Server.MessagePackSerializerOptions, token);
var runner = new ScheduleRunner(pgRequest);
var waveforms = runner.Run();
var arcWaveforms = waveforms.Select(ArcUnsafe.Wrap).ToList();
plotService.UpdatePlots(pgRequest.ChannelTable!.Zip(arcWaveforms).ToDictionary(x => x.First.Name, x => new PlotData(x.First.Name, x.Second.Clone(), 1.0 / x.First.SampleRate)));
var pgResponse = new PulseGenResponse(arcWaveforms);
response.RegisterForDispose(pgResponse);
return Results.Extensions.MessagePack(pgResponse, Server.MessagePackSerializerOptions);
})
.WithName("Schedule")
.Accepts<ScheduleRequest>(contentType)
.Produces(StatusCodes.Status400BadRequest);
}

internal static void ServeSciChartWasm(this WebApplication app)
{
var fileExtensionContentTypeProvider = new FileExtensionContentTypeProvider();
Expand Down