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

17 SkullOS - Rework Architecture #19

Merged
merged 10 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
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
69 changes: 19 additions & 50 deletions ServoSkull.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,39 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.Core", "skullOS.Cor
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS", "skullOS\skullOS.csproj", "{6D3C5D36-0002-4EFD-A3B9-0924D6D3CCD8}"
ProjectSection(ProjectDependencies) = postProject
{464B162B-62FC-49CC-A6AB-72DBE959DD8C} = {464B162B-62FC-49CC-A6AB-72DBE959DD8C}
{5E1EC385-4B61-4E8C-82C7-46695A33AC72} = {5E1EC385-4B61-4E8C-82C7-46695A33AC72}
{9AC8960C-539A-4B2C-9D24-5169AF4337FA} = {9AC8960C-539A-4B2C-9D24-5169AF4337FA}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.Camera", "skullOS.Camera\skullOS.Camera.csproj", "{D4E9CB35-2264-4717-BDB6-7797E84B5DFE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.Input", "skullOS.Input\skullOS.Input.csproj", "{FDE1F7EA-F552-4B2E-990E-327612D46939}"
ProjectSection(ProjectDependencies) = postProject
{6D3C5D36-0002-4EFD-A3B9-0924D6D3CCD8} = {6D3C5D36-0002-4EFD-A3B9-0924D6D3CCD8}
{DE800E5A-E68B-4BCA-AC99-4BC9DB44FD56} = {DE800E5A-E68B-4BCA-AC99-4BC9DB44FD56}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.Tests", "skullOS.Tests\skullOS.Tests.csproj", "{9B4C6E1D-BE16-40F3-AFB7-369ACA5BFDBC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.Camera.Tests", "skullOS.Camera.Tests\skullOS.Camera.Tests.csproj", "{45513FCC-E0E9-4C2A-A48F-239A380347BC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.Input.Tests", "skullOS.Input.Tests\skullOS.Input.Tests.csproj", "{237A08B2-E8F4-4384-A894-4C356CE45E92}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.Core.Tests", "skullOS.Core.Tests\skullOS.Core.Tests.csproj", "{BA89208E-E059-45A3-8A0D-4052063C79D4}"
ProjectSection(ProjectDependencies) = postProject
{464B162B-62FC-49CC-A6AB-72DBE959DD8C} = {464B162B-62FC-49CC-A6AB-72DBE959DD8C}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B50B951E-DF9B-49DD-9CAC-ED8B01C6B1E7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.Output", "skullOS.Output\skullOS.Output.csproj", "{9AC8960C-539A-4B2C-9D24-5169AF4337FA}"
ProjectSection(ProjectDependencies) = postProject
{464B162B-62FC-49CC-A6AB-72DBE959DD8C} = {464B162B-62FC-49CC-A6AB-72DBE959DD8C}
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EE38A10C-F0BB-40B5-B1E6-8CB16C6E452C}"
ProjectSection(SolutionItems) = preProject
Pinout.md = Pinout.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.Interlink", "skullOS.Interlink\skullOS.Interlink.csproj", "{E6CD1206-E775-44B6-93C1-CB2DEFB3C89B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.API", "skullOS.API\skullOS.API.csproj", "{5E1EC385-4B61-4E8C-82C7-46695A33AC72}"
ProjectSection(ProjectDependencies) = postProject
{464B162B-62FC-49CC-A6AB-72DBE959DD8C} = {464B162B-62FC-49CC-A6AB-72DBE959DD8C}
{9AC8960C-539A-4B2C-9D24-5169AF4337FA} = {9AC8960C-539A-4B2C-9D24-5169AF4337FA}
{D4E9CB35-2264-4717-BDB6-7797E84B5DFE} = {D4E9CB35-2264-4717-BDB6-7797E84B5DFE}
{DE800E5A-E68B-4BCA-AC99-4BC9DB44FD56} = {DE800E5A-E68B-4BCA-AC99-4BC9DB44FD56}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EE38A10C-F0BB-40B5-B1E6-8CB16C6E452C}"
ProjectSection(SolutionItems) = preProject
Pinout.md = Pinout.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "skullOS.API", "skullOS.API\skullOS.API.csproj", "{5E1EC385-4B61-4E8C-82C7-46695A33AC72}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.Modules", "skullOS.Modules\skullOS.Modules.csproj", "{DE800E5A-E68B-4BCA-AC99-4BC9DB44FD56}"
ProjectSection(ProjectDependencies) = postProject
{3CBE1B63-957B-43B6-939D-070EAC517C7C} = {3CBE1B63-957B-43B6-939D-070EAC517C7C}
{464B162B-62FC-49CC-A6AB-72DBE959DD8C} = {464B162B-62FC-49CC-A6AB-72DBE959DD8C}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "skullOS.HardwareServices", "skullOS.HardwareServices\skullOS.HardwareServices.csproj", "{3CBE1B63-957B-43B6-939D-070EAC517C7C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -73,51 +60,33 @@ Global
{6D3C5D36-0002-4EFD-A3B9-0924D6D3CCD8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D3C5D36-0002-4EFD-A3B9-0924D6D3CCD8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D3C5D36-0002-4EFD-A3B9-0924D6D3CCD8}.Release|Any CPU.Build.0 = Release|Any CPU
{D4E9CB35-2264-4717-BDB6-7797E84B5DFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4E9CB35-2264-4717-BDB6-7797E84B5DFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4E9CB35-2264-4717-BDB6-7797E84B5DFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4E9CB35-2264-4717-BDB6-7797E84B5DFE}.Release|Any CPU.Build.0 = Release|Any CPU
{FDE1F7EA-F552-4B2E-990E-327612D46939}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FDE1F7EA-F552-4B2E-990E-327612D46939}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FDE1F7EA-F552-4B2E-990E-327612D46939}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FDE1F7EA-F552-4B2E-990E-327612D46939}.Release|Any CPU.Build.0 = Release|Any CPU
{9B4C6E1D-BE16-40F3-AFB7-369ACA5BFDBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9B4C6E1D-BE16-40F3-AFB7-369ACA5BFDBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B4C6E1D-BE16-40F3-AFB7-369ACA5BFDBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B4C6E1D-BE16-40F3-AFB7-369ACA5BFDBC}.Release|Any CPU.Build.0 = Release|Any CPU
{45513FCC-E0E9-4C2A-A48F-239A380347BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45513FCC-E0E9-4C2A-A48F-239A380347BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45513FCC-E0E9-4C2A-A48F-239A380347BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45513FCC-E0E9-4C2A-A48F-239A380347BC}.Release|Any CPU.Build.0 = Release|Any CPU
{237A08B2-E8F4-4384-A894-4C356CE45E92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{237A08B2-E8F4-4384-A894-4C356CE45E92}.Debug|Any CPU.Build.0 = Debug|Any CPU
{237A08B2-E8F4-4384-A894-4C356CE45E92}.Release|Any CPU.ActiveCfg = Release|Any CPU
{237A08B2-E8F4-4384-A894-4C356CE45E92}.Release|Any CPU.Build.0 = Release|Any CPU
{BA89208E-E059-45A3-8A0D-4052063C79D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BA89208E-E059-45A3-8A0D-4052063C79D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BA89208E-E059-45A3-8A0D-4052063C79D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BA89208E-E059-45A3-8A0D-4052063C79D4}.Release|Any CPU.Build.0 = Release|Any CPU
{9AC8960C-539A-4B2C-9D24-5169AF4337FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9AC8960C-539A-4B2C-9D24-5169AF4337FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9AC8960C-539A-4B2C-9D24-5169AF4337FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9AC8960C-539A-4B2C-9D24-5169AF4337FA}.Release|Any CPU.Build.0 = Release|Any CPU
{E6CD1206-E775-44B6-93C1-CB2DEFB3C89B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E6CD1206-E775-44B6-93C1-CB2DEFB3C89B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6CD1206-E775-44B6-93C1-CB2DEFB3C89B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E6CD1206-E775-44B6-93C1-CB2DEFB3C89B}.Release|Any CPU.Build.0 = Release|Any CPU
{5E1EC385-4B61-4E8C-82C7-46695A33AC72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E1EC385-4B61-4E8C-82C7-46695A33AC72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E1EC385-4B61-4E8C-82C7-46695A33AC72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E1EC385-4B61-4E8C-82C7-46695A33AC72}.Release|Any CPU.Build.0 = Release|Any CPU
{DE800E5A-E68B-4BCA-AC99-4BC9DB44FD56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DE800E5A-E68B-4BCA-AC99-4BC9DB44FD56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE800E5A-E68B-4BCA-AC99-4BC9DB44FD56}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE800E5A-E68B-4BCA-AC99-4BC9DB44FD56}.Release|Any CPU.Build.0 = Release|Any CPU
{3CBE1B63-957B-43B6-939D-070EAC517C7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3CBE1B63-957B-43B6-939D-070EAC517C7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CBE1B63-957B-43B6-939D-070EAC517C7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CBE1B63-957B-43B6-939D-070EAC517C7C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{7EA7E587-5434-4E16-8CDD-217D36A401D9} = {EE38A10C-F0BB-40B5-B1E6-8CB16C6E452C}
{9B4C6E1D-BE16-40F3-AFB7-369ACA5BFDBC} = {B50B951E-DF9B-49DD-9CAC-ED8B01C6B1E7}
{45513FCC-E0E9-4C2A-A48F-239A380347BC} = {B50B951E-DF9B-49DD-9CAC-ED8B01C6B1E7}
{237A08B2-E8F4-4384-A894-4C356CE45E92} = {B50B951E-DF9B-49DD-9CAC-ED8B01C6B1E7}
{BA89208E-E059-45A3-8A0D-4052063C79D4} = {B50B951E-DF9B-49DD-9CAC-ED8B01C6B1E7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
9 changes: 8 additions & 1 deletion skullOS.API/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {}
"tools": {
"dotnet-ef": {
"version": "8.0.0",
"commands": [
"dotnet-ef"
]
}
}
}
29 changes: 29 additions & 0 deletions skullOS.API/Controllers/BuzzerController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Microsoft.AspNetCore.Mvc;
using skullOS.Modules.Interfaces;
using static skullOS.Modules.BuzzerLibrary;

namespace skullOS.API.Controllers
{
[Route("Buzzer")]
[ApiController]
public class BuzzerController : ControllerBase
{
private readonly ILogger<BuzzerController> _logger;
private IBuzzerModule _module;

public BuzzerController(ILogger<BuzzerController> logger, IBuzzerModule buzzer)
{
_logger = logger;
_module = buzzer;
}

[HttpGet("PlayTune")]
public string PlayTune(string tune)
{
Tunes tuneToPlay = (Tunes)Enum.Parse(typeof(Tunes), tune);
_module.PlayTune(tuneToPlay);
return "Playing " + tuneToPlay.ToString();
}

}
}
33 changes: 33 additions & 0 deletions skullOS.API/Controllers/CameraController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;
using skullOS.Modules.Interfaces;

namespace skullOS.API.Controllers
{
[Route("Camera")]
[ApiController]
public class CameraController : ControllerBase
{
private readonly ILogger<CameraController> _logger;
private ICameraModule _module;

public CameraController(ILogger<CameraController> logger, ICameraModule camera)
{
_logger = logger;
_module = camera;
}

[HttpGet("TakePicture")]
public string TakePicture()
{
_module.TakePicture();
return "Picture Taken!";
}

[HttpGet("RecordVideo")]
public string RecordVideo()
{
_module.RecordShortVideo();
return "Video Recorded!";
}
}
}
7 changes: 7 additions & 0 deletions skullOS.API/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using skullOS.Modules;
using skullOS.Modules.Interfaces;

namespace skullOS.API
{
Expand All @@ -15,6 +17,11 @@ public static void Main(string[] args)
builder.Services.AddSwaggerGen();
builder.WebHost.UseUrls("http://*:5000;https://*:5001");

#region Skull Modules
builder.Services.AddScoped<ICameraModule, Camera>();
builder.Services.AddScoped<IBuzzerModule, Buzzer>();
#endregion

var app = builder.Build();

// Configure the HTTP request pipeline.
Expand Down
128 changes: 128 additions & 0 deletions skullOS.API/Runner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
using skullOS.Modules;
using skullOS.Modules.Interfaces;

namespace skullOS.API
{
public class Runner
{
public Task StartWebApiTask(string[] args)
{
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.WebHost.UseUrls("http://*:5000;https://*:5001");

#region Skull Modules
builder.Services.AddScoped<ICameraModule, Camera>();
builder.Services.AddScoped<IBuzzerModule, Buzzer>();
#endregion


var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
if (!app.Environment.IsDevelopment())
{
app.UseHttpsRedirection();
}


app.UseAuthorization();


app.MapControllers();

return app.RunAsync();
}
public void StartWebApiAsync(string[] args)
{
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.WebHost.UseUrls("http://*:5000;https://*:5001");

#region Skull Modules
//builder.Services.AddScoped<ICameraModule, Camera>();
//builder.Services.AddScoped<IBuzzerModule, Buzzer>();
#endregion


var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
if (!app.Environment.IsDevelopment())
{
app.UseHttpsRedirection();
}


app.UseAuthorization();


app.MapControllers();

app.RunAsync();
}

public void StartWebApi(string[] args)
{
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.WebHost.UseUrls("http://*:5000;https://*:5001");

#region Skull Modules
builder.Services.AddScoped<ICameraModule, Camera>();
builder.Services.AddScoped<IBuzzerModule, Buzzer>();
#endregion


var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
if (!app.Environment.IsDevelopment())
{
app.UseHttpsRedirection();
}


app.UseAuthorization();


app.MapControllers();

app.Run();
}

}
}
1 change: 1 addition & 0 deletions skullOS.API/skullOS.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

<ItemGroup>
<ProjectReference Include="..\skullOS.Core\skullOS.Core.csproj" />
<ProjectReference Include="..\skullOS.Modules\skullOS.Modules.csproj" />
</ItemGroup>

</Project>
Loading
Loading