Skip to content

Commit

Permalink
fix: fix mics dictionary configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor Payne committed Aug 21, 2023
1 parent 7a9a5f9 commit 957c1bb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 28 deletions.
2 changes: 1 addition & 1 deletion pdt_shureMXA_epi/DeviceFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override EssentialsDevice BuildDevice(DeviceConfig dc)

if (config != null)
{
return new ShureMxwDevice(dc.Key, dc.Name, comms, dc);
return new ShureMxwDevice(dc.Key, dc.Name, comms, config);
}

Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to deserialize config for device {0}", dc.Key);
Expand Down
7 changes: 5 additions & 2 deletions pdt_shureMXA_epi/Properties.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
using PepperDash.Core;

namespace pdt_shureMXW_epi
Expand All @@ -9,8 +10,10 @@ public class Properties

[JsonProperty("cautionThreshold")]
public int CautionThreshold { get; set; }
[JsonProperty("WarningThreshold")]
[JsonProperty("warningThreshold")]
public int WarningThreshold { get; set; }
[JsonProperty("mics")]
public Dictionary<string, MicDict> Mics { get; set; }
}

public class Mic : IKeyed
Expand Down
34 changes: 10 additions & 24 deletions pdt_shureMXA_epi/ShureMxwDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,41 +106,22 @@ int WarningThreshold
}


public ShureMxwDevice(string key, string name, IBasicCommunication comm, DeviceConfig dc)
public ShureMxwDevice(string key, string name, IBasicCommunication comm, Properties dc)
: base(key, name)
{
var dc1 = dc;
Name = name;

var mics = new List<Mic>();

//Props = JsonConvert.DeserializeObject<Properties>(dc1.Properties.ToString());
Props = dc1.Properties.ToObject<Properties>();

var micsToken = dc1.Properties.SelectToken("mics");
if (micsToken is JArray)
{
mics = micsToken.ToObject<List<Mic>>();
}
if (micsToken is JObject)
{
mics = ListConvert(micsToken.ToObject<Dictionary<string, MicDict>>());
}
var mics = dc.Mics.Select(mic => new Mic(mic.Key, mic.Value)).ToList();

if (mics.Count < 1)
{
Debug.Console(0, this, "Malformed Json - check your config");
return;
}
Props = dc;

Mics = mics;


CautionThreshold = Props.CautionThreshold;
WarningThreshold = Props.WarningThreshold;

Debug.Console(1, this, "Made it to consturctor for ShureMxw {0}", Name);
Debug.Console(2, this, "ShureMxw Properties : {0}", dc1.Properties.ToString());

Communication = comm;
var socket = comm as ISocketStatus;
Expand Down Expand Up @@ -481,8 +462,13 @@ public override void LinkToApi(BasicTriList trilist, uint joinStart, string join
{
var joinMap = new ShureMxwDeviceJoinMap(joinStart);

Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(2, this, "There are {0} Mic", Mics.Count());
Debug.Console(0, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, this, "There are {0} Mic", Mics.Count());

if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}

CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
Debug.Console(2, this, "Linked Online at {0}", joinMap.IsOnline);
Expand Down
2 changes: 1 addition & 1 deletion pdt_shureMXA_epi/bin/Debug/manifest.info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MainAssembly=pdt_shureMXW_epi.dll:dd19c8bfd8b3e813e165d1f50d7b9a7a
MainAssembly=pdt_shureMXW_epi.dll:6ac4974d888cdb3493805ce8e287abe1
MainAssemblyMinFirmwareVersion=1.009.0029
MainAssemblyResource=SimplSharpData.dat:820b61c48c8a2cace82957eed4cc377c
MainAssemblyResource=SimplSharpData.dat.der:bf862965c00f3e6ec535e4e00e82d30c
Expand Down
Binary file modified pdt_shureMXA_epi/bin/Debug/manifest.ser
Binary file not shown.

0 comments on commit 957c1bb

Please sign in to comment.