Compare commits

..

No commits in common. "67bb9c4f9a1e8b132fe55f8a8e9c01eeeecda514" and "5de7e3c0ce20fd6b4721283118d680cc724b1d20" have entirely different histories.

11 changed files with 10 additions and 28 deletions

View File

@ -1,4 +0,0 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Caixianlin/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Petrainer/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=rftransmit/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -7,7 +7,7 @@
<Authors>Glax</Authors> <Authors>Glax</Authors>
<RepositoryUrl>https://github.com/C9Glax/CShocker</RepositoryUrl> <RepositoryUrl>https://github.com/C9Glax/CShocker</RepositoryUrl>
<RepositoryType>git</RepositoryType> <RepositoryType>git</RepositoryType>
<Version>1.3.2</Version> <Version>1.3.1</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -7,7 +7,6 @@ namespace CShocker.Shockers.APIS;
public class OpenShockSerial : SerialShocker public class OpenShockSerial : SerialShocker
{ {
// ReSharper disable once MemberCanBePrivate.Global external usage
public readonly Dictionary<string, ShockerModel> Model; public readonly Dictionary<string, ShockerModel> Model;
private const int BaudRate = 115200; private const int BaudRate = 115200;
public OpenShockSerial(Dictionary<string, ShockerModel> shockerIds, IntensityRange intensityRange, DurationRange durationRange, SerialPortInfo serialPortI, ILogger? logger = null) : base(shockerIds.Keys.ToList(), intensityRange, durationRange, serialPortI, BaudRate, ShockerApi.OpenShockSerial, logger) public OpenShockSerial(Dictionary<string, ShockerModel> shockerIds, IntensityRange intensityRange, DurationRange durationRange, SerialPortInfo serialPortI, ILogger? logger = null) : base(shockerIds.Keys.ToList(), intensityRange, durationRange, serialPortI, BaudRate, ShockerApi.OpenShockSerial, logger)
@ -24,7 +23,7 @@ public class OpenShockSerial : SerialShocker
$"\"intensity\":{intensity}," + $"\"intensity\":{intensity}," +
$"\"durationMs\":{duration}" + $"\"durationMs\":{duration}" +
"}"; "}";
SerialPort.WriteLine(json); serialPort.WriteLine(json);
} }
public Dictionary<string, ShockerModel> GetShockers() public Dictionary<string, ShockerModel> GetShockers()
@ -32,8 +31,8 @@ public class OpenShockSerial : SerialShocker
Dictionary<string, ShockerModel> ret = new(); Dictionary<string, ShockerModel> ret = new();
Regex shockerRex = new (@".*FetchDeviceInfo\(\): \[GatewayConnectionManager\] \[[a-z0-9\-]+\] rf=([0-9]{1,5}) model=([0,1])"); Regex shockerRex = new (@".*FetchDeviceInfo\(\): \[GatewayConnectionManager\] \[[a-z0-9\-]+\] rf=([0-9]{1,5}) model=([0,1])");
this.Logger?.Log(LogLevel.Debug, "Restart"); this.Logger?.Log(LogLevel.Debug, "Restart");
SerialPort.WriteLine("restart"); serialPort.WriteLine("restart");
while (SerialPort.ReadLine() is { } line && !line.Contains("Successfully verified auth token")) while (serialPort.ReadLine() is { } line && !line.Contains("Successfully verified auth token"))
{ {
this.Logger?.Log(LogLevel.Trace, line); this.Logger?.Log(LogLevel.Trace, line);
Match match = shockerRex.Match(line); Match match = shockerRex.Match(line);
@ -51,7 +50,7 @@ public class OpenShockSerial : SerialShocker
Petrainer = 1 Petrainer = 1
} }
private static string ControlActionToString(ControlAction action) private string ControlActionToString(ControlAction action)
{ {
return action switch return action switch
{ {

View File

@ -8,9 +8,7 @@ namespace CShocker.Shockers.APIS;
public class PiShockHttp : HttpShocker public class PiShockHttp : HttpShocker
{ {
// ReSharper disable twice MemberCanBePrivate.Global external usage public String Username, ShareCode;
public readonly string Username, ShareCode;
public PiShockHttp(List<string> shockerIds, IntensityRange intensityRange, DurationRange durationRange, string apiKey, string username, string shareCode, string endpoint = "https://do.pishock.com/api/apioperate", ILogger? logger = null) : base(shockerIds, intensityRange, durationRange, apiKey, endpoint, ShockerApi.PiShockHttp, logger) public PiShockHttp(List<string> shockerIds, IntensityRange intensityRange, DurationRange durationRange, string apiKey, string username, string shareCode, string endpoint = "https://do.pishock.com/api/apioperate", ILogger? logger = null) : base(shockerIds, intensityRange, durationRange, apiKey, endpoint, ShockerApi.PiShockHttp, logger)
{ {
this.Username = username; this.Username = username;

View File

@ -23,7 +23,7 @@ public class PiShockSerial : SerialShocker
$"\"id\": " + $"\"id\": " +
"}" + "}" +
"}"; "}";
SerialPort.WriteLine(json); serialPort.WriteLine(json);
} }
private static string ControlActionToOp(ControlAction action) private static string ControlActionToOp(ControlAction action)

View File

@ -6,7 +6,6 @@ namespace CShocker.Shockers.Abstract;
public abstract class HttpShocker : Shocker public abstract class HttpShocker : Shocker
{ {
protected readonly HttpClient HttpClient = new(); protected readonly HttpClient HttpClient = new();
// ReSharper disable twice MemberCanBeProtected.Global external usage
public string Endpoint { get; init; } public string Endpoint { get; init; }
public string ApiKey { get; init; } public string ApiKey { get; init; }

View File

@ -10,13 +10,13 @@ namespace CShocker.Shockers.Abstract;
public abstract class SerialShocker : Shocker public abstract class SerialShocker : Shocker
{ {
public SerialPortInfo SerialPortI; public SerialPortInfo SerialPortI;
protected readonly SerialPort SerialPort; protected SerialPort serialPort;
protected SerialShocker(List<string> shockerIds, IntensityRange intensityRange, DurationRange durationRange, SerialPortInfo serialPortI, int baudRate, ShockerApi apiType, ILogger? logger = null) : base(shockerIds, intensityRange, durationRange, apiType, logger) protected SerialShocker(List<string> shockerIds, IntensityRange intensityRange, DurationRange durationRange, SerialPortInfo serialPortI, int baudRate, ShockerApi apiType, ILogger? logger = null) : base(shockerIds, intensityRange, durationRange, apiType, logger)
{ {
this.SerialPortI = serialPortI; this.SerialPortI = serialPortI;
this.SerialPort = new SerialPort(serialPortI.PortName, baudRate); this.serialPort = new SerialPort(serialPortI.PortName, baudRate);
this.SerialPort.Open(); this.serialPort.Open();
} }
[SupportedOSPlatform("windows")] [SupportedOSPlatform("windows")]

View File

@ -6,7 +6,6 @@ namespace CShocker.Shockers.Abstract;
public abstract class Shocker public abstract class Shocker
{ {
// ReSharper disable 4 times MemberCanBePrivate.Global external use
public readonly List<string> ShockerIds; public readonly List<string> ShockerIds;
public readonly IntensityRange IntensityRange; public readonly IntensityRange IntensityRange;
public readonly DurationRange DurationRange; public readonly DurationRange DurationRange;

View File

@ -29,12 +29,6 @@ public class ShockerJsonConverter : JsonConverter
jo.SelectToken("Endpoint")!.Value<string>()! jo.SelectToken("Endpoint")!.Value<string>()!
); );
case ShockerApi.OpenShockSerial: case ShockerApi.OpenShockSerial:
return new OpenShockSerial(
jo.SelectToken("Model")!.ToObject<Dictionary<string, OpenShockSerial.ShockerModel>>()!,
jo.SelectToken("IntensityRange")!.ToObject<IntensityRange>()!,
jo.SelectToken("DurationRange")!.ToObject<DurationRange>()!,
jo.SelectToken("SerialPortI")!.ToObject<SerialShocker.SerialPortInfo>()!
);
case ShockerApi.PiShockHttp: case ShockerApi.PiShockHttp:
return new PiShockHttp( return new PiShockHttp(
jo.SelectToken("ShockerIds")!.ToObject<List<string>>()!, jo.SelectToken("ShockerIds")!.ToObject<List<string>>()!,

View File

@ -1,7 +1,5 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace TestApp;
public class Logger : ILogger public class Logger : ILogger
{ {
private LogLevel _enabledLoglevel; private LogLevel _enabledLoglevel;

View File

@ -2,7 +2,6 @@
using CShocker.Shockers.Abstract; using CShocker.Shockers.Abstract;
using CShocker.Shockers.APIS; using CShocker.Shockers.APIS;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using TestApp;
Logger logger = new (LogLevel.Trace); Logger logger = new (LogLevel.Trace);