From 230f29d3f88eb5404f22a86ae6061a891b08d62b Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Thu, 7 May 2020 15:42:46 -0500 Subject: [PATCH] Updated GenericLightingJoinMap, LightingBase, and LutronQuantum --- .../JoinMaps/GenericLightingJoinMap.cs | 56 ++++++++++--------- .../Lighting/LightingBase.cs | 25 ++++----- .../Environment/Lutron/LutronQuantum.cs | 4 +- 3 files changed, 41 insertions(+), 44 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericLightingJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericLightingJoinMap.cs index 242be651..f639cff0 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericLightingJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericLightingJoinMap.cs @@ -9,33 +9,35 @@ using PepperDash.Essentials.Core; namespace PepperDash.Essentials.Core.Bridges { - public class GenericLightingJoinMap : JoinMapBase - { - public uint IsOnline { get; set; } - public uint SelectScene { get; set; } - public uint LightingSceneOffset { get; set; } - public uint ButtonVisibilityOffset { get; set; } - public uint IntegrationIdSet { get; set; } - - public GenericLightingJoinMap() - { - // Digital - IsOnline = 1; - SelectScene = 1; - IntegrationIdSet = 1; - LightingSceneOffset = 10; - ButtonVisibilityOffset = 40; - // Analog - } - - public override void OffsetJoinNumbers(uint joinStart) - { - var joinOffset = joinStart - 1; - - IsOnline = IsOnline + joinOffset; - SelectScene = SelectScene + joinOffset; - LightingSceneOffset = LightingSceneOffset + joinOffset; - ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset; + public class GenericLightingJoinMap : JoinMapBaseAdvanced + { + + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata() { Label = "Lighting Controller Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("SelectScene")] + public JoinDataComplete SelectScene = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata() { Label = "Lighting Controller Select Scene By Index", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("SelectSceneDirect")] + public JoinDataComplete SelectSceneDirect = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 10 }, + new JoinMetadata() { Label = "Lighting Controller Select Scene", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.DigitalSerial }); + + [JoinName("ButtonVisibility")] + public JoinDataComplete ButtonVisibility = new JoinDataComplete(new JoinData() { JoinNumber = 41, JoinSpan = 10 }, + new JoinMetadata() { Label = "Lighting Controller Button Visibility", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IntegrationIdSet")] + public JoinDataComplete IntegrationIdSet = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata() { Label = "Lighting Controller Set Integration Id", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + + + + + public GenericLightingJoinMap(uint joinStart) + : base(joinStart, typeof(GenericLightingJoinMap)) + { } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs index c22745c0..d649565d 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs @@ -72,36 +72,31 @@ namespace PepperDash.Essentials.Core.Lighting protected GenericLightingJoinMap LinkLightingToApi(LightingBase lightingDevice, BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new GenericLightingJoinMap(); + { + var joinMap = new GenericLightingJoinMap(joinStart); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - joinMap.OffsetJoinNumbers(joinStart); - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(0, "Linking to Lighting Type {0}", lightingDevice.GetType().Name.ToString()); - // GenericLighitng Actions & FeedBack - trilist.SetUShortSigAction(joinMap.SelectScene, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u])); + // GenericLighitng Actions & FeedBack + trilist.SetUShortSigAction(joinMap.SelectScene.JoinNumber, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u])); - var sceneIndex = 1; + var sceneIndex = 0; foreach (var scene in lightingDevice.LightingScenes) - { - var tempIndex = sceneIndex - 1; - trilist.SetSigTrueAction((uint)(joinMap.LightingSceneOffset + sceneIndex), () => lightingDevice.SelectScene(lightingDevice.LightingScenes[tempIndex])); - scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)]); - trilist.StringInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)].StringValue = scene.Name; - trilist.BooleanInput[(uint)(joinMap.ButtonVisibilityOffset + sceneIndex)].BoolValue = true; + { + trilist.SetSigTrueAction((uint)(joinMap.SelectSceneDirect.JoinNumber + sceneIndex), () => lightingDevice.SelectScene(lightingDevice.LightingScenes[sceneIndex])); + scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.SelectSceneDirect.JoinNumber + sceneIndex)]); + trilist.StringInput[(uint)(joinMap.SelectSceneDirect.JoinNumber + sceneIndex)].StringValue = scene.Name; + trilist.BooleanInput[(uint)(joinMap.ButtonVisibility.JoinNumber + sceneIndex)].BoolValue = true; sceneIndex++; } - - return joinMap; } diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs index 84cf46c2..23bbc913 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs @@ -85,8 +85,8 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Lutron { var joinMap = LinkLightingToApi(this, trilist, joinStart, joinMapKey, bridge); - CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); - trilist.SetStringSigAction(joinMap.IntegrationIdSet, s => IntegrationId = s); + CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + trilist.SetStringSigAction(joinMap.IntegrationIdSet.JoinNumber , s => IntegrationId = s); } void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)