Skip to content

Commit

Permalink
#17 Making Moderate progress
Browse files Browse the repository at this point in the history
It's now looking more workable
  • Loading branch information
David032 committed Nov 23, 2023
1 parent 777a884 commit 4bcc423
Show file tree
Hide file tree
Showing 21 changed files with 271 additions and 179 deletions.
2 changes: 1 addition & 1 deletion skullOS.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static void Main(string[] args)

app.MapControllers();

app.Run();
Task webAPIStatus = app.RunAsync();
}
}
}
40 changes: 40 additions & 0 deletions skullOS.API/Runner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace skullOS.API
{
public class Runner
{
public Task 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");


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();
}
}
}
64 changes: 0 additions & 64 deletions skullOS.Core/Modules.cs

This file was deleted.

21 changes: 21 additions & 0 deletions skullOS.Core/SkullLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace skullOS.Core
{
public class SkullLogger
{
string filepath;
public SkullLogger()
{
string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
filepath = FileManager.GetSkullDirectory() + @"\" + fileName + ".txt";
}


public void LogMessage(string message)
{
#if DEBUG
Console.WriteLine(message);
#endif
File.AppendAllText(filepath, message);
}
}
}
30 changes: 30 additions & 0 deletions skullOS.Modules/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,35 @@ public void RecordShortVideo()
CameraService.RecordVideoAsync(FileManager.GetSkullDirectory() + "/Captures", 30);
MicrophoneService.Microphone.Record(30, audioLocation);
}

public override void OnEnable(string[] args)
{
if (Enum.TryParse(args[0], out CameraMode mode))
{
CameraMode = mode;
}
}

public override void OnAction(string[] args)
{
switch (CameraMode)
{
case CameraMode.Image:
TakePicture();
break;
case CameraMode.ShortVideo:
RecordShortVideo();
break;
case CameraMode.ContinuousVideo:
break;
default:
break;
}
}

public override string ToString()
{
return "Camera";
}
}
}
23 changes: 15 additions & 8 deletions skullOS.Modules/Downlink.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skullOS.Modules
namespace skullOS.Modules
{
internal class Downlink
public class Downlink : Module, IDownlinkModule
{
public override void OnAction(string[] args)
{
throw new NotImplementedException();
}

public override void OnEnable(string[] args)
{
throw new NotImplementedException();
}
public override string ToString()
{
throw new NotImplementedException();
}
}
}
6 changes: 6 additions & 0 deletions skullOS.Modules/Interfaces/IDownlinkModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace skullOS.Modules
{
internal interface IDownlinkModule
{
}
}
6 changes: 6 additions & 0 deletions skullOS.Modules/Interfaces/IPropModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace skullOS.Modules
{
internal interface IPropModule
{
}
}
6 changes: 6 additions & 0 deletions skullOS.Modules/Interfaces/IQrCodeReaderModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace skullOS.Modules
{
internal interface IQrCodeReaderModule
{
}
}
6 changes: 6 additions & 0 deletions skullOS.Modules/Interfaces/IUplinkModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace skullOS.Modules.Interfaces
{
internal interface IUplinkModule
{
}
}
3 changes: 3 additions & 0 deletions skullOS.Modules/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
{
public abstract class Module
{
public abstract void OnEnable(string[] args);
public abstract void OnAction(object? sender, EventArgs e);

public abstract override string ToString();
}
}
23 changes: 15 additions & 8 deletions skullOS.Modules/Prop.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skullOS.Modules
namespace skullOS.Modules
{
internal class Prop
public class Prop : Module, IPropModule
{
public override void OnAction(string[] args)
{
throw new NotImplementedException();
}

public override void OnEnable(string[] args)
{
throw new NotImplementedException();
}
public override string ToString()
{
throw new NotImplementedException();
}
}
}
23 changes: 15 additions & 8 deletions skullOS.Modules/QrCodeReader.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skullOS.Modules
namespace skullOS.Modules
{
internal class QrCodeReader
public class QrCodeReader : Module, IQrCodeReaderModule
{
public override void OnAction(string[] args)
{
throw new NotImplementedException();
}

public override void OnEnable(string[] args)
{
throw new NotImplementedException();
}
public override string ToString()
{
throw new NotImplementedException();
}
}
}
21 changes: 15 additions & 6 deletions skullOS.Modules/Uplink.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skullOS.Modules.Interfaces;

namespace skullOS.Modules
{
internal class Uplink
public class Uplink : Module, IUplinkModule
{
public override void OnAction(string[] args)
{
throw new NotImplementedException();
}

public override void OnEnable(string[] args)
{
throw new NotImplementedException();
}
public override string ToString()
{
throw new NotImplementedException();
}
}
}
Empty file.
1 change: 1 addition & 0 deletions skullOS/Data/InputSettings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Camera(Image)=0
7 changes: 5 additions & 2 deletions skullOS/Data/Modules.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Camera = True
Output = True
Interlink = True
Downlink = True
Uplink = True
Prop = True
QrCodeReader = True

29 changes: 29 additions & 0 deletions skullOS/DeviceManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using skullOS.Modules;
using System.Device.Gpio;

namespace skullOS
{
public class DeviceManager
{
Task apiStatus;
List<Module> Modules;
GpioController Controller;

public DeviceManager(GpioController gpio)
{
Controller = gpio;
}

public void AttachApi(Task apiTask)
{
apiStatus = apiTask;
}

public void AttachModules(List<Module> modules)
{
Modules = modules;
}


}
}
Loading

0 comments on commit 4bcc423

Please sign in to comment.