Add TestApp
This commit is contained in:
@ -6,13 +6,34 @@ namespace CShocker.Shockers.APIS;
|
||||
|
||||
public class PiShockSerial : SerialShocker
|
||||
{
|
||||
public PiShockSerial(List<string> shockerIds, IntensityRange intensityRange, DurationRange durationRange, ILogger? logger = null) : base(shockerIds, intensityRange, durationRange, ShockerApi.PiShockSerial, logger)
|
||||
private const int BaudRate = 115200;
|
||||
public PiShockSerial(List<string> shockerIds, IntensityRange intensityRange, DurationRange durationRange, SerialPortInfo serialPortI, ILogger? logger = null) : base(shockerIds, intensityRange, durationRange, serialPortI, BaudRate, ShockerApi.PiShockSerial, logger)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void ControlInternal(ControlAction action, string shockerId, int intensity, int duration)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
string json = "{" +
|
||||
"\"cmd\": \"operate\"," +
|
||||
"\"value\":{" +
|
||||
$"\"op\": \"{ControlActionToOp(action)}\"," +
|
||||
$"\"duration\": {duration}," +
|
||||
$"\"intensity\": {intensity}," +
|
||||
$"\"id\": " +
|
||||
"}" +
|
||||
"}";
|
||||
serialPort.WriteLine(json);
|
||||
}
|
||||
|
||||
private static string ControlActionToOp(ControlAction action)
|
||||
{
|
||||
return action switch
|
||||
{
|
||||
ControlAction.Beep => "",
|
||||
ControlAction.Vibrate => "vibrate",
|
||||
ControlAction.Shock => "",
|
||||
_ => ""
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user