Capitalized FieldNames onn public fields

This commit is contained in:
glax 2024-02-12 02:03:35 +01:00
parent 639b813fb6
commit 8d70879c68
3 changed files with 20 additions and 23 deletions

View File

@ -19,7 +19,7 @@ public class OpenShockHttp : OpenShockApi
string json = "{" + string json = "{" +
" \"shocks\": [" + " \"shocks\": [" +
" {" + " {" +
$" \"id\": \"{openShockShocker.id}\"," + $" \"id\": \"{openShockShocker.ID}\"," +
$" \"type\": {ControlActionToByte(action)}," + $" \"type\": {ControlActionToByte(action)}," +
$" \"intensity\": {intensity}," + $" \"intensity\": {intensity}," +
$" \"duration\": {duration}" + $" \"duration\": {duration}" +

View File

@ -36,8 +36,8 @@ public class OpenShockSerial : OpenShockApi
return; return;
} }
string json = "rftransmit {" + string json = "rftransmit {" +
$"\"model\":\"{Enum.GetName(openShockShocker.model)!.ToLower()}\"," + $"\"model\":\"{Enum.GetName(openShockShocker.Model)!.ToLower()}\"," +
$"\"id\":{openShockShocker.rfId}," + $"\"id\":{openShockShocker.RfId}," +
$"\"type\":\"{ControlActionToString(action)}\"," + $"\"type\":\"{ControlActionToString(action)}\"," +
$"\"intensity\":{intensity}," + $"\"intensity\":{intensity}," +
$"\"durationMs\":{duration}" + $"\"durationMs\":{duration}" +

View File

@ -11,22 +11,17 @@ public class OpenShockShocker : Shocker
public readonly OpenShockModel Model; public readonly OpenShockModel Model;
public readonly DateTime CreatedOn; public readonly DateTime CreatedOn;
public readonly bool IsPaused; public readonly bool IsPaused;
public string name, id;
public short rfId;
public OpenShockModel model;
public DateTime createdOn;
public bool isPaused;
public OpenShockShocker(Api api, string name, string id, short rfId, OpenShockModel model, DateTime createdOn, bool isPaused) : base (api) public OpenShockShocker(Api api, string name, string id, short rfId, OpenShockModel model, DateTime createdOn, bool isPaused) : base (api)
{ {
if (api is not OpenShockApi) if (api is not OpenShockApi)
throw new Exception($"API-Type {api.GetType().FullName} is not usable with Shocker {this.GetType().FullName}"); throw new Exception($"API-Type {api.GetType().FullName} is not usable with Shocker {this.GetType().FullName}");
this.name = name; this.Name = name;
this.id = id; this.ID = id;
this.rfId = rfId; this.RfId = rfId;
this.model = model; this.Model = model;
this.createdOn = createdOn; this.CreatedOn = createdOn;
this.isPaused = isPaused; this.IsPaused = isPaused;
} }
public enum OpenShockModel : byte public enum OpenShockModel : byte
@ -37,13 +32,15 @@ public class OpenShockShocker : Shocker
public override string ToString() public override string ToString()
{ {
return $"{GetType().Name}\n" + return $"{string.Join("\n\t",
$"Name: {name}\n" + $"{GetType().Name}",
$"ID: {id}\n" + $"Name: {Name}",
$"RF-ID: {rfId}\n" + $"ID: {ID}",
$"Model: {Enum.GetName(model)}\n" + $"RF-ID: {RfId}",
$"Created On: {createdOn}\n" + $"Model: {Enum.GetName(Model)}",
$"Paused: {isPaused}\n\r"; $"Created On: {CreatedOn}",
$"Paused: {IsPaused}")}" +
$"\n\r";
} }
public override bool Equals(object? obj) public override bool Equals(object? obj)
@ -54,11 +51,11 @@ public class OpenShockShocker : Shocker
private bool Equals(OpenShockShocker other) private bool Equals(OpenShockShocker other)
{ {
return id == other.id && rfId == other.rfId && model == other.model && createdOn.Equals(other.createdOn); return ID == other.ID;
} }
public override int GetHashCode() public override int GetHashCode()
{ {
return HashCode.Combine(id, rfId, (int)model, createdOn); return ID.GetHashCode();
} }
} }