Fix OpenShockHttp: Wrong json caused Bad Request

Get OpenShock Shockers from API.
Save Shockers for PiShock and OpenShock in different structs
Implement Action Queue, to avoid synchronous actions getting lost.

Moved SerialPortInfo to own file
Created ShockerJsonConverter
Better separation of Devices/APIs and Shockers
This commit is contained in:
2024-01-29 15:37:19 +01:00
parent e255caeb64
commit ac19e20fb7
22 changed files with 530 additions and 399 deletions

View File

@ -0,0 +1,32 @@
using System.Diagnostics.CodeAnalysis;
using CShocker.Shockers.Abstract;
namespace CShocker.Shockers;
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
[SuppressMessage("ReSharper", "InconsistentNaming")]
public struct OpenShockShocker : IShocker
{
public string name, id;
public short rfId;
public OpenShockModel model;
public DateTime createdOn;
public bool isPaused;
public enum OpenShockModel : byte
{
CaiXianlin = 0,
Petrainer = 1
}
public override string ToString()
{
return $"{GetType().Name}\n" +
$"Name: {name}\n" +
$"ID: {id}\n" +
$"RF-ID: {rfId}\n" +
$"Model: {Enum.GetName(model)}\n" +
$"Created On: {createdOn}\n" +
$"Paused: {isPaused}\n\r";
}
}