diff --git a/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs b/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs index 571a7d38..13170eb3 100644 --- a/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs +++ b/Essentials Core/PepperDashEssentialsBase/Lighting/LightingBase.cs @@ -30,8 +30,32 @@ namespace PepperDash.Essentials.Core.Lighting public abstract void SelectScene(LightingScene scene); + public void SimulateSceneSelect(string sceneName) + { + Debug.Console(1, this, "Simulating selection of scene '{0}'", sceneName); + + var scene = LightingScenes.FirstOrDefault(s => s.Name.Equals(sceneName)); + + if (scene != null) + { + CurrentLightingScene = scene; + OnLightingSceneChange(); + } + } + + /// + /// Sets the IsActive property on each scene and fires the LightingSceneChange event + /// protected void OnLightingSceneChange() { + foreach (var scene in LightingScenes) + { + if (scene == CurrentLightingScene) + scene.IsActive = true; + else + scene.IsActive = false; + } + var handler = LightingSceneChange; if (handler != null) { @@ -45,5 +69,24 @@ namespace PepperDash.Essentials.Core.Lighting { public string Name { get; set; } public string ID { get; set; } + bool _IsActive; + public bool IsActive + { + get + { + return _IsActive; + } + set + { + _IsActive = value; + IsActiveFeedback.FireUpdate(); + } + } + public BoolFeedback IsActiveFeedback { get; set; } + + public LightingScene() + { + IsActiveFeedback = new BoolFeedback(new Func(() => IsActive)); + } } } \ No newline at end of file diff --git a/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs b/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs index 83562cc2..c797218a 100644 --- a/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs +++ b/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs @@ -179,6 +179,7 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Lutron /// public override void SelectScene(LightingScene scene) { + Debug.Console(1, this, "Selecting Scene: '{0}'", scene.Name); SendLine(string.Format("{0}AREA,{1},{2},{3}", Set, IntegrationId, eAction.Scene, scene.ID)); } diff --git a/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs b/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs index ec5e5773..297a29fe 100644 --- a/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs +++ b/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs @@ -46,6 +46,7 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Somfy public override void Open() { + Debug.Console(1, this, "Opening Shade: '{0}'", this.Name); StopRelay.Off(); CloseRelay.Off(); @@ -54,6 +55,7 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Somfy public void Stop() { + Debug.Console(1, this, "Stopping Shade: '{0}'", this.Name); OpenRelay.Off(); CloseRelay.Off(); @@ -63,6 +65,7 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Somfy public override void Close() { + Debug.Console(1, this, "Closing Shade: '{0}'", this.Name); OpenRelay.Off(); StopRelay.Off(); diff --git a/Essentials/PepperDashEssentials/ControlSystem.cs b/Essentials/PepperDashEssentials/ControlSystem.cs index 82a35bd0..07caf515 100644 --- a/Essentials/PepperDashEssentials/ControlSystem.cs +++ b/Essentials/PepperDashEssentials/ControlSystem.cs @@ -34,8 +34,8 @@ namespace PepperDash.Essentials { DeterminePlatform(); - CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Loads configuration file", - ConsoleAccessLevelEnum.AccessOperator); + //CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Loads configuration file", + // ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(s => { @@ -59,7 +59,7 @@ namespace PepperDash.Essentials "Template URL: {1}", ConfigReader.ConfigObject.SystemUrl, ConfigReader.ConfigObject.TemplateUrl); }, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator); - //GoWithLoad(); + GoWithLoad(); } /// diff --git a/Essentials/PepperDashEssentials/Factory/UiDeviceFactory.cs b/Essentials/PepperDashEssentials/Factory/UiDeviceFactory.cs index 5b96ba24..851ca948 100644 --- a/Essentials/PepperDashEssentials/Factory/UiDeviceFactory.cs +++ b/Essentials/PepperDashEssentials/Factory/UiDeviceFactory.cs @@ -72,7 +72,7 @@ namespace PepperDash.Essentials { if (!b) { - mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin); + //mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin); mainDriver.EnvironmentDriver.Toggle(); } }); @@ -141,7 +141,7 @@ namespace PepperDash.Essentials { if (!b) { - mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin); + //mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin); mainDriver.EnvironmentDriver.Toggle(); } }); diff --git a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj index 4e277117..fb2aa9d6 100644 --- a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj +++ b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj @@ -169,6 +169,7 @@ + diff --git a/Essentials/PepperDashEssentials/Properties/AssemblyInfo.cs b/Essentials/PepperDashEssentials/Properties/AssemblyInfo.cs index 848e4f30..0260d88d 100644 --- a/Essentials/PepperDashEssentials/Properties/AssemblyInfo.cs +++ b/Essentials/PepperDashEssentials/Properties/AssemblyInfo.cs @@ -4,5 +4,5 @@ [assembly: AssemblyCompany("PepperDash Technology Corp")] [assembly: AssemblyProduct("PepperDashEssentials")] [assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")] -[assembly: AssemblyVersion("1.2.0.*")] +[assembly: AssemblyVersion("1.3.0.*")] diff --git a/Essentials/PepperDashEssentials/UI/JoinConstants/UIBoolJoin.cs b/Essentials/PepperDashEssentials/UI/JoinConstants/UIBoolJoin.cs index f84bdef6..623febff 100644 --- a/Essentials/PepperDashEssentials/UI/JoinConstants/UIBoolJoin.cs +++ b/Essentials/PepperDashEssentials/UI/JoinConstants/UIBoolJoin.cs @@ -234,78 +234,102 @@ namespace PepperDash.Essentials // Popup Container /// - /// 3001 - 3004 + /// 2001 - 2004 /// - public const uint EnvironmentPopupSubpageVisibleBase = 3000; + public const uint EnvironmentBackgroundSubpageVisibleBase = 2000; // ColumnOne /// - /// 3011 - 3015 + /// 2011 - 2015 /// - public const uint EnvironmentColumnOneLightingTypeVisibleBase = 3010; + public const uint EnvironmentColumnOneLightingTypeVisibleBase = 2010; /// - /// 3016 - 3020 + /// 2016 - 2020 /// - public const uint EnvironmentColumnOneShadingTypeVisibleBase = 3015; + public const uint EnvironmentColumnOneShadingTypeVisibleBase = 2015; // ColumnTwo /// - /// 3021 - 3025 + /// 2021 - 2025 /// - public const uint EnvironmentColumnTwoLightingTypeVisibleBase = 3020; + public const uint EnvironmentColumnTwoLightingTypeVisibleBase = 2020; /// - /// 3026 - 3030 + /// 2026 - 2030 /// - public const uint EnvironmentColumnTwoShadingTypeVisibleBase = 3025; + public const uint EnvironmentColumnTwoShadingTypeVisibleBase = 2025; // ColumnThree /// - /// 3031 - 3035 + /// 2031 - 2035 /// - public const uint EnvironmentColumnThreeLightingTypeVisibleBase = 3030; + public const uint EnvironmentColumnThreeLightingTypeVisibleBase = 2030; /// - /// 3036 - 3040 + /// 2036 - 2040 /// - public const uint EnvironmentColumnThreeShadingTypeVisibleBase = 3035; + public const uint EnvironmentColumnThreeShadingTypeVisibleBase = 2035; // ColumnFour /// - /// 3041 - 3045 + /// 2041 - 2045 /// - public const uint EnvironmentColumnFourLightingTypeVisibleBase = 3040; + public const uint EnvironmentColumnFourLightingTypeVisibleBase = 2040; /// - /// 3046 - 3050 + /// 2046 - 2050 /// - public const uint EnvironmentColumnFourShadingTypeVisibleBase = 3045; + public const uint EnvironmentColumnFourShadingTypeVisibleBase = 2045; + + // Button press /// - /// 3051 - 3060 + /// 2051 - 2060 /// - public const uint EnvironmentColumnOneButtonPressBase = 3050; + public const uint EnvironmentColumnOneButtonPressBase = 2050; /// - /// 3061 - 3070 + /// 2061 - 2070 /// - public const uint EnvironmentColumnTwoButtonPressBase = 3060; + public const uint EnvironmentColumnTwoButtonPressBase = 2060; /// - /// 3071 - 3080 + /// 2071 - 2080 /// - public const uint EnvironmentColumnThreeButtonPressBase = 3070; + public const uint EnvironmentColumnThreeButtonPressBase = 2070; /// - /// 3081 - 3090 + /// 2081 - 2090 /// - public const uint EnvironmentColumnFourButtonPressBase = 3080; + public const uint EnvironmentColumnFourButtonPressBase = 2080; + + // Button visibility + + /// + /// 2151 - 2160 + /// + public const uint EnvironmentColumnOneButtonVisibleBase = 2150; + + /// + /// 2161 - 2170 + /// + public const uint EnvironmentColumnTwoButtonVisibleBase = 2160; + + /// + /// 2171 - 2180 + /// + public const uint EnvironmentColumnThreeButtonVisibleBase = 2170; + + /// + /// 2181 - 2190 + /// + public const uint EnvironmentColumnFourButtonVisibleBase = 2180; //****************************************************** diff --git a/Essentials/PepperDashEssentials/UI/JoinConstants/UIStringlJoin.cs b/Essentials/PepperDashEssentials/UI/JoinConstants/UIStringlJoin.cs index d7ee032c..101c8cda 100644 --- a/Essentials/PepperDashEssentials/UI/JoinConstants/UIStringlJoin.cs +++ b/Essentials/PepperDashEssentials/UI/JoinConstants/UIStringlJoin.cs @@ -73,26 +73,26 @@ namespace PepperDash.Essentials // Environment Joins /// - /// 3001 - 3010 + /// 2001 - 2010 /// - public const uint EnvironmentColumnOneLabelBase = 3000; + public const uint EnvironmentColumnOneLabelBase = 2000; /// - /// 3011 - 3020 + /// 2011 - 2020 /// - public const uint EnvironmentColumnTwoLabelBase = 3010; + public const uint EnvironmentColumnTwoLabelBase = 2010; /// - /// 3021 - 3030 + /// 2021 - 2030 /// - public const uint EnvironmentColumnThreeLabelBase = 3020; + public const uint EnvironmentColumnThreeLabelBase = 2020; /// - /// 3031 - 3040 + /// 2031 - 2040 /// - public const uint EnvironmentColumnFourLabelBase = 3030; + public const uint EnvironmentColumnFourLabelBase = 2030; - // 3050, 3060, 3070 and 3080 reserved for column device name labels + // 2050, 2060, 2070 and 2080 reserved for column device name labels //****************************************************** diff --git a/Essentials/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsEnvironmentDriver.cs b/Essentials/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsEnvironmentDriver.cs index 8fa74712..6e0f49f5 100644 --- a/Essentials/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsEnvironmentDriver.cs +++ b/Essentials/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsEnvironmentDriver.cs @@ -45,15 +45,31 @@ namespace PepperDash.Essentials Devices = new List(); DeviceSubDrivers = new List(); + Parent.AvDriver.PopupInterlock.IsShownFeedback.OutputChange += new EventHandler(IsShownFeedback_OutputChange); + // Calculate the join offests for each device page and assign join actions for each button } + void IsShownFeedback_OutputChange(object sender, EventArgs e) + { + // Hide this driver and all sub drivers if popup interlock is not shown + if (Parent.AvDriver.PopupInterlock.IsShownFeedback.BoolValue == false) + { + foreach (var driver in DeviceSubDrivers) + { + driver.Hide(); + } + + base.Hide(); + } + } + /// /// Shows this driver and all sub drivers /// public override void Show() { - //TriList.SetBool(BackgroundSubpageJoin, true); + Parent.AvDriver.PopupInterlock.ShowInterlockedWithToggle(BackgroundSubpageJoin); foreach (var driver in DeviceSubDrivers) { @@ -68,7 +84,7 @@ namespace PepperDash.Essentials /// public override void Hide() { - //TriList.SetBool(BackgroundSubpageJoin, false); + Parent.AvDriver.PopupInterlock.HideAndClear(); foreach (var driver in DeviceSubDrivers) { @@ -80,7 +96,10 @@ namespace PepperDash.Essentials public override void Toggle() { - base.Toggle(); + if (IsVisible) + Hide(); + else + Show(); } @@ -94,7 +113,7 @@ namespace PepperDash.Essentials Devices.Clear(); DeviceSubDrivers.Clear(); - uint column = 4; + uint column = 1; foreach (var dKey in EnvironmentPropertiesConfig.DeviceKeys) { @@ -103,14 +122,23 @@ namespace PepperDash.Essentials if (device != null) { Devices.Add(device); - + + // Build the driver + var devicePanelDriver = GetPanelDriverForDevice(device, column); + // Add new PanelDriverBase SubDriver - DeviceSubDrivers.Add(GetPanelDriverForDevice(device, column)); + if (devicePanelDriver != null) + DeviceSubDrivers.Add(devicePanelDriver); Debug.Console(1, "Adding '{0}' to Environment Devices", device.Key); + + column++; + + // Quit if device count is exceeded + if (column > 4) + break; } - column --; } SetupEnvironmentUiJoins(); @@ -131,43 +159,48 @@ namespace PepperDash.Essentials { PanelDriverBase panelDriver = null; - uint digitalJoinBase = 0; + uint buttonPressJoinBase = 0; + uint buttonVisibleJoinBase = 0; uint stringJoinBase = 0; uint shadeTypeVisibleBase = 0; uint lightingTypeVisibleBase = 0; switch (column) { - case 4: + case 1: { - digitalJoinBase = UIBoolJoin.EnvironmentColumnFourButtonPressBase; - stringJoinBase = UIStringJoin.EnvironmentColumnFourLabelBase; - shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnFourShadingTypeVisibleBase; - lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnFourLightingTypeVisibleBase; + buttonPressJoinBase = UIBoolJoin.EnvironmentColumnOneButtonPressBase; + buttonVisibleJoinBase = UIBoolJoin.EnvironmentColumnOneButtonVisibleBase; + stringJoinBase = UIStringJoin.EnvironmentColumnOneLabelBase; + shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnOneShadingTypeVisibleBase; + lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnOneLightingTypeVisibleBase; + break; + } + case 2: + { + buttonPressJoinBase = UIBoolJoin.EnvironmentColumnTwoButtonPressBase; + buttonVisibleJoinBase = UIBoolJoin.EnvironmentColumnTwoButtonVisibleBase; + stringJoinBase = UIStringJoin.EnvironmentColumnTwoLabelBase; + shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnTwoShadingTypeVisibleBase; + lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnTwoLightingTypeVisibleBase; break; } case 3: { - digitalJoinBase = UIBoolJoin.EnvironmentColumnThreeButtonPressBase; + buttonPressJoinBase = UIBoolJoin.EnvironmentColumnThreeButtonPressBase; + buttonVisibleJoinBase = UIBoolJoin.EnvironmentColumnThreeButtonVisibleBase; stringJoinBase = UIStringJoin.EnvironmentColumnThreeLabelBase; - shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnThreeShadingTypeVisibleBase; + shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnThreeShadingTypeVisibleBase; lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnThreeLightingTypeVisibleBase; - break; + break; } - case 2: + case 4: { - digitalJoinBase = UIBoolJoin.EnvironmentColumnTwoButtonPressBase; - stringJoinBase = UIStringJoin.EnvironmentColumnTwoLabelBase; - shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnTwoShadingTypeVisibleBase; - lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnTwoLightingTypeVisibleBase; - break; - } - case 1: - { - digitalJoinBase = UIBoolJoin.EnvironmentColumnOneButtonPressBase; - stringJoinBase = UIStringJoin.EnvironmentColumnOneLabelBase; - shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnOneShadingTypeVisibleBase; - lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnOneLightingTypeVisibleBase; + buttonPressJoinBase = UIBoolJoin.EnvironmentColumnFourButtonPressBase; + buttonVisibleJoinBase = UIBoolJoin.EnvironmentColumnFourButtonVisibleBase; + stringJoinBase = UIStringJoin.EnvironmentColumnFourLabelBase; + shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnFourShadingTypeVisibleBase; + lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnFourLightingTypeVisibleBase; break; } default: @@ -180,11 +213,11 @@ namespace PepperDash.Essentials // Determine if device is a shade or lighting type and construct the appropriate driver if (device is ShadeBase) { - panelDriver = new EssentialsShadeDriver(this, device.Key, digitalJoinBase, stringJoinBase, shadeTypeVisibleBase); + panelDriver = new EssentialsShadeDriver(this, device.Key, buttonPressJoinBase, stringJoinBase, shadeTypeVisibleBase); } else if (device is LightingBase) { - //panelDriver = new EssentialsLightingDriver(this, device.Key, digitalJoinBase, stringJoinBase, lightingTypeVisibleBase); + panelDriver = new EssentialsLightingDriver(this, device.Key, buttonPressJoinBase, buttonVisibleJoinBase, stringJoinBase, lightingTypeVisibleBase); } // Return the driver @@ -198,7 +231,7 @@ namespace PepperDash.Essentials void SetupEnvironmentUiJoins() { // Calculate which background subpage join to use - BackgroundSubpageJoin = UIBoolJoin.EnvironmentPopupSubpageVisibleBase + (uint)DeviceSubDrivers.Count; + BackgroundSubpageJoin = UIBoolJoin.EnvironmentBackgroundSubpageVisibleBase + (uint)DeviceSubDrivers.Count; } diff --git a/Essentials/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsLightingDriver.cs b/Essentials/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsLightingDriver.cs new file mode 100644 index 00000000..0d8e438a --- /dev/null +++ b/Essentials/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsLightingDriver.cs @@ -0,0 +1,210 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.Lighting; + +namespace PepperDash.Essentials +{ + /// + /// Supports a lighting device with up to 6 scenes + /// + public class EssentialsLightingDriver : PanelDriverBase, IEnvironmentSubdriver + { + EssentialsEnvironmentDriver Parent; + + public LightingBase LightingDevice { get; private set; } + + public uint SubpageVisibleJoin { get; private set; } + + /// + /// The base join number that all button visibilty joins are offset from + /// + uint ButtonVisibleJoinBase; + + /// + /// The base join number that all button presses are offset from + /// + uint ButtonPressJoinBase; + + /// + /// The base join number that all string lables are offset from + /// + uint StringJoinBase; + + eLightsDeviceType DeviceType; + + const uint DeviceNameJoinOffset = 50; + + public EssentialsLightingDriver(EssentialsEnvironmentDriver parent, string deviceKey, uint buttonPressJoinBase, uint buttonVisibleJoinBase, uint stringJoinBase, uint subpageVisibleBase) + : base(parent.TriList) + { + Parent = parent; + + ButtonPressJoinBase = buttonPressJoinBase; + ButtonVisibleJoinBase = buttonVisibleJoinBase; + StringJoinBase = stringJoinBase; + + LightingDevice = DeviceManager.GetDeviceForKey(deviceKey) as LightingBase; + + //LightingDevice.LightingSceneChange += new EventHandler(LightingDevice_LightingSceneChange); + + SetDeviceType(); + + SetSubpageVisibleJoin(subpageVisibleBase); + + SetUpDeviceName(); + + SetUpButtonActions(); + } + + /// + /// Handles setting feedback for the currently selected scene button + /// + /// + /// + void LightingDevice_LightingSceneChange(object sender, LightingSceneChangeEventArgs e) + { + uint joinOffset = 1; + + foreach (var scene in LightingDevice.LightingScenes) + { + if (scene == e.CurrentLightingScene) + TriList.SetBool(ButtonPressJoinBase + joinOffset, true); + else + TriList.SetBool(ButtonPressJoinBase + joinOffset, false); + } + } + + public override void Show() + { + TriList.SetBool(SubpageVisibleJoin, true); + + base.Show(); + } + + public override void Hide() + { + TriList.SetBool(SubpageVisibleJoin, false); + + base.Hide(); + } + + void SetUpDeviceName() + { + Parent.TriList.SetString(StringJoinBase + DeviceNameJoinOffset, LightingDevice.Name); + } + + void SetDeviceType() + { + if (LightingDevice is ILightingScenes) + DeviceType = eLightsDeviceType.Scenes; + } + + void SetSubpageVisibleJoin(uint subpageVisibleBase) + { + SubpageVisibleJoin = subpageVisibleBase + (uint)DeviceType; + } + + /// + /// Drase + /// + void SetUpButtonActions() + { + if (DeviceType == eLightsDeviceType.Scenes) + { + uint joinOffset = ComputeJoinOffset(); + + // Clear preceding buttons + for (uint i = 1; i < joinOffset; i++) + { + TriList.SetString(StringJoinBase + i, ""); + TriList.SetSigFalseAction(ButtonPressJoinBase + i, () => { }); + TriList.SetBool(ButtonVisibleJoinBase + i, false); + } + + foreach (var scene in LightingDevice.LightingScenes) + { + TriList.SetString(StringJoinBase + joinOffset, scene.Name); + var tempScene = scene; + TriList.SetSigFalseAction(ButtonPressJoinBase + joinOffset, () => LightingDevice.SelectScene(tempScene)); + scene.IsActiveFeedback.LinkInputSig(TriList.BooleanInput[ButtonPressJoinBase + joinOffset]); + TriList.SetBool(ButtonVisibleJoinBase + joinOffset, true); + + joinOffset++; + } + + // Clear following buttons + for (uint i = joinOffset; i <= 6; i++) + { + TriList.SetString(StringJoinBase + i, ""); + TriList.SetSigFalseAction(ButtonPressJoinBase + i, () => { }); + TriList.SetBool(ButtonVisibleJoinBase + i, false); + } + } + + } + + + + /// + /// Computes the desired join offset to try to achieve the most centered appearance when using a subpage with 6 scene buttons + /// + /// + uint ComputeJoinOffset() + { + uint joinOffset = 0; + + switch (LightingDevice.LightingScenes.Count) + { + case 1: + { + joinOffset = 2; + break; + } + case 2: + { + joinOffset = 3; + break; + } + case 3: + { + joinOffset = 2; + break; + } + case 4: + { + joinOffset = 2; + break; + } + case 5: + { + joinOffset = 2; + break; + } + case 6: + { + joinOffset = 1; + break; + } + default: + { + break; + } + } + + return joinOffset; + } + } + + enum eLightsDeviceType : uint + { + None = 0, + Scenes = 1, + } +} \ No newline at end of file diff --git a/Essentials/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsShadeDriver.cs b/Essentials/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsShadeDriver.cs index 9e8ad894..490abd2a 100644 --- a/Essentials/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsShadeDriver.cs +++ b/Essentials/PepperDashEssentials/UIDrivers/Environment Drivers/EssentialsShadeDriver.cs @@ -19,18 +19,26 @@ namespace PepperDash.Essentials public uint SubpageVisibleJoin { get; private set; } - uint DigitalJoinBase; + /// + /// The base join number that all button presses are offset from + /// + uint ButtonPressJoinBase; + /// + /// The base join number that all string lables are offset from + /// uint StringJoinBase; eShadeDeviceType DeviceType; - public EssentialsShadeDriver(EssentialsEnvironmentDriver parent, string deviceKey, uint digitalJoinBase, uint stringJoinBase, uint subpageVisibleBase) + const uint DeviceNameJoinOffset = 50; + + public EssentialsShadeDriver(EssentialsEnvironmentDriver parent, string deviceKey, uint buttonPressJoinBase, uint stringJoinBase, uint subpageVisibleBase) : base(parent.TriList) { Parent = parent; - DigitalJoinBase = digitalJoinBase; + ButtonPressJoinBase = buttonPressJoinBase; StringJoinBase = stringJoinBase; ShadeDevice = DeviceManager.GetDeviceForKey(deviceKey) as ShadeBase; @@ -38,6 +46,10 @@ namespace PepperDash.Essentials SetDeviceType(); SetSubpageVisibleJoin(subpageVisibleBase); + + SetUpDeviceName(); + + SetUpButtonActions(); } public override void Show() @@ -56,7 +68,7 @@ namespace PepperDash.Essentials void SetUpDeviceName() { - Parent.TriList.SetString(StringJoinBase + 50, ShadeDevice.Name); + Parent.TriList.SetString(StringJoinBase + DeviceNameJoinOffset, ShadeDevice.Name); } void SetDeviceType() @@ -71,6 +83,24 @@ namespace PepperDash.Essentials { SubpageVisibleJoin = subpageVisibleBase + (uint)DeviceType; } + + void SetUpButtonActions() + { + if(DeviceType == eShadeDeviceType.OpenClose) + { + TriList.SetSigFalseAction(ButtonPressJoinBase + 1, ShadeDevice.Open); + + TriList.SetSigFalseAction(ButtonPressJoinBase + 2, ShadeDevice.Close); + } + else if(DeviceType == eShadeDeviceType.OpenCloseStop) + { + TriList.SetSigFalseAction(ButtonPressJoinBase + 1, ShadeDevice.Open); + + TriList.SetSigFalseAction(ButtonPressJoinBase + 2, (ShadeDevice as IShadesOpenCloseStop).Stop); + + TriList.SetSigFalseAction(ButtonPressJoinBase + 3, ShadeDevice.Close); + } + } } enum eShadeDeviceType : uint diff --git a/Essentials/PepperDashEssentials/UIDrivers/Essentials/EssentialsHeaderDriver.cs b/Essentials/PepperDashEssentials/UIDrivers/Essentials/EssentialsHeaderDriver.cs index c301cc36..b2000bc0 100644 --- a/Essentials/PepperDashEssentials/UIDrivers/Essentials/EssentialsHeaderDriver.cs +++ b/Essentials/PepperDashEssentials/UIDrivers/Essentials/EssentialsHeaderDriver.cs @@ -103,13 +103,7 @@ namespace PepperDash.Essentials if (environmentDriver != null) { TriList.SetString(nextJoin, "Lights"); - TriList.SetSigFalseAction(nextJoin, () => - { - Parent.AvDriver.PopupInterlock.ShowInterlockedWithToggle(environmentDriver.BackgroundSubpageJoin); - environmentDriver.Toggle(); - }); - //TriList.SetSigFalseAction(nextJoin, environmentDriver.Toggle); -#warning Check the best way to show the environment subpage + TriList.SetSigFalseAction(nextJoin, environmentDriver.Toggle); nextJoin--; return nextJoin; } diff --git a/Essentials/PepperDashEssentials/UIDrivers/JoinedSigInterlock.cs b/Essentials/PepperDashEssentials/UIDrivers/JoinedSigInterlock.cs index 4de87788..fbd77614 100644 --- a/Essentials/PepperDashEssentials/UIDrivers/JoinedSigInterlock.cs +++ b/Essentials/PepperDashEssentials/UIDrivers/JoinedSigInterlock.cs @@ -14,11 +14,32 @@ namespace PepperDash.Essentials { public uint CurrentJoin { get; private set; } - BasicTriList TriList; + BasicTriList TriList; + + public BoolFeedback IsShownFeedback; + + bool _IsShown; + + public bool IsShown + { + get + { + return _IsShown; + } + private set + { + _IsShown = value; + IsShownFeedback.FireUpdate(); + } + } + + //public BoolFeedback ShownFeedback { get; private set; } public JoinedSigInterlock(BasicTriList triList) { TriList = triList; + + IsShownFeedback = new BoolFeedback(new Func( () => _IsShown)); } /// @@ -31,7 +52,8 @@ namespace PepperDash.Essentials if (CurrentJoin == join && TriList.BooleanInput[join].BoolValue) return; SetButDontShow(join); - TriList.SetBool(CurrentJoin, true); + TriList.SetBool(CurrentJoin, true); + IsShown = true; } /// @@ -48,7 +70,8 @@ namespace PepperDash.Essentials if (CurrentJoin > 0) TriList.BooleanInput[CurrentJoin].BoolValue = false; CurrentJoin = join; - TriList.BooleanInput[CurrentJoin].BoolValue = true; + TriList.BooleanInput[CurrentJoin].BoolValue = true; + IsShown = true; } } /// @@ -67,9 +90,12 @@ namespace PepperDash.Essentials /// public void Hide() { - Debug.Console(2, "Trilist {0:X2}, interlock hiding {1}", TriList.ID, CurrentJoin); - if (CurrentJoin > 0) - TriList.BooleanInput[CurrentJoin].BoolValue = false; + Debug.Console(2, "Trilist {0:X2}, interlock hiding {1}", TriList.ID, CurrentJoin); + if (CurrentJoin > 0) + { + TriList.BooleanInput[CurrentJoin].BoolValue = false; + IsShown = false; + } } /// @@ -77,9 +103,12 @@ namespace PepperDash.Essentials /// public void Show() { - Debug.Console(2, "Trilist {0:X2}, interlock showing {1}", TriList.ID, CurrentJoin); - if (CurrentJoin > 0) - TriList.BooleanInput[CurrentJoin].BoolValue = true; + Debug.Console(2, "Trilist {0:X2}, interlock showing {1}", TriList.ID, CurrentJoin); + if (CurrentJoin > 0) + { + TriList.BooleanInput[CurrentJoin].BoolValue = true; + IsShown = true; + } } /// @@ -87,9 +116,12 @@ namespace PepperDash.Essentials /// /// public void SetButDontShow(uint join) - { - if (CurrentJoin > 0) - TriList.BooleanInput[CurrentJoin].BoolValue = false; + { + if (CurrentJoin > 0) + { + TriList.BooleanInput[CurrentJoin].BoolValue = false; + IsShown = false; + } CurrentJoin = join; } diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz index f20c98f9..24d5bdb9 100644 Binary files a/Release Package/PepperDashEssentials.cpz and b/Release Package/PepperDashEssentials.cpz differ diff --git a/Release Package/PepperDashEssentials.dll b/Release Package/PepperDashEssentials.dll index fce45845..23ab1960 100644 Binary files a/Release Package/PepperDashEssentials.dll and b/Release Package/PepperDashEssentials.dll differ