From 57f2d7c9389aa70719611efec2cb31c658503e3f Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 2 Mar 2021 15:09:24 -0700 Subject: [PATCH] #637 Updates LinkToApi method to map configured tuners --- .../Room/Config/EssentialsTechRoomConfig.cs | 2 +- .../Room/Types/EssentialsTechRoom.cs | 50 +++++++++++++++---- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/PepperDashEssentials/Room/Config/EssentialsTechRoomConfig.cs b/PepperDashEssentials/Room/Config/EssentialsTechRoomConfig.cs index 4404b377..9ff3a2d2 100644 --- a/PepperDashEssentials/Room/Config/EssentialsTechRoomConfig.cs +++ b/PepperDashEssentials/Room/Config/EssentialsTechRoomConfig.cs @@ -54,7 +54,7 @@ namespace PepperDash.Essentials.Room.Config /// Indicates which tuners should mirror preset recall when two rooms are configured in a primary->secondary scenario /// [JsonProperty("mirroredTuners")] - public List MirroredTuners { get; set; } + public Dictionary MirroredTuners { get; set; } /// /// Indicates the room diff --git a/PepperDashEssentials/Room/Types/EssentialsTechRoom.cs b/PepperDashEssentials/Room/Types/EssentialsTechRoom.cs index bfa56646..2908642a 100644 --- a/PepperDashEssentials/Room/Types/EssentialsTechRoom.cs +++ b/PepperDashEssentials/Room/Types/EssentialsTechRoom.cs @@ -373,13 +373,30 @@ Params: {2}" uint i; if (_config.IsPrimary) { - i = 0; - foreach (var feedback in CurrentPresetsFeedbacks) + + if (_config.MirroredTuners != null && _config.MirroredTuners.Count > 0) { - feedback.Value.LinkInputSig(trilist.StringInput[(uint) (joinMap.CurrentPreset.JoinNumber + i)]); - i++; + foreach (var tuner in _config.MirroredTuners) + { + var f = CurrentPresetsFeedbacks[tuner.Value]; + + if (f == null) + { + Debug.Console(1, this, "Unable to find feedback with key: {0}", tuner.Value); + continue; + } + + f.LinkInputSig(trilist.StringInput[(uint)(joinMap.CurrentPreset.JoinNumber + tuner.Key)]); + } } + //i = 0; + //foreach (var feedback in CurrentPresetsFeedbacks) + //{ + // feedback.Value.LinkInputSig(trilist.StringInput[(uint) (joinMap.CurrentPreset.JoinNumber + i)]); + // i++; + //} + trilist.OnlineStatusChange += (device, args) => { if (!args.DeviceOnLine) @@ -396,14 +413,29 @@ Params: {2}" return; } - i = 0; - foreach (var setTopBox in _tuners) + + if (_config.MirroredTuners != null && _config.MirroredTuners.Count > 0) { - var tuner = setTopBox; + foreach (var tuner in _config.MirroredTuners) + { + var t = _tuners[tuner.Value]; - trilist.SetStringSigAction(joinMap.CurrentPreset.JoinNumber + i, s => _tunerPresets.Dial(s, tuner.Value)); + if (t == null) + { + Debug.Console(1, this, "Unable to find tuner with key: {0}", tuner.Value); + continue; + } - i++; + trilist.SetStringSigAction(joinMap.CurrentPreset.JoinNumber + tuner.Key, s => _tunerPresets.Dial(s, t)); + } + + //foreach (var setTopBox in _tuners) + //{ + // var tuner = setTopBox; + + // trilist.SetStringSigAction(joinMap.CurrentPreset.JoinNumber + i, s => _tunerPresets.Dial(s, tuner.Value)); + + //} } }