Completed Environment UI effort. Tested with EssentialsHuddleRoom type

This commit is contained in:
Neil Dorin
2018-05-24 09:44:13 -06:00
parent 80377a41d0
commit 3cf188f820
16 changed files with 467 additions and 96 deletions

View File

@@ -30,8 +30,32 @@ namespace PepperDash.Essentials.Core.Lighting
public abstract void SelectScene(LightingScene scene); 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();
}
}
/// <summary>
/// Sets the IsActive property on each scene and fires the LightingSceneChange event
/// </summary>
protected void OnLightingSceneChange() protected void OnLightingSceneChange()
{ {
foreach (var scene in LightingScenes)
{
if (scene == CurrentLightingScene)
scene.IsActive = true;
else
scene.IsActive = false;
}
var handler = LightingSceneChange; var handler = LightingSceneChange;
if (handler != null) if (handler != null)
{ {
@@ -45,5 +69,24 @@ namespace PepperDash.Essentials.Core.Lighting
{ {
public string Name { get; set; } public string Name { get; set; }
public string ID { 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<bool>(() => IsActive));
}
} }
} }

View File

@@ -179,6 +179,7 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Lutron
/// <param name="scene"></param> /// <param name="scene"></param>
public override void SelectScene(LightingScene scene) 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)); SendLine(string.Format("{0}AREA,{1},{2},{3}", Set, IntegrationId, eAction.Scene, scene.ID));
} }

View File

@@ -46,6 +46,7 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Somfy
public override void Open() public override void Open()
{ {
Debug.Console(1, this, "Opening Shade: '{0}'", this.Name);
StopRelay.Off(); StopRelay.Off();
CloseRelay.Off(); CloseRelay.Off();
@@ -54,6 +55,7 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Somfy
public void Stop() public void Stop()
{ {
Debug.Console(1, this, "Stopping Shade: '{0}'", this.Name);
OpenRelay.Off(); OpenRelay.Off();
CloseRelay.Off(); CloseRelay.Off();
@@ -63,6 +65,7 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Somfy
public override void Close() public override void Close()
{ {
Debug.Console(1, this, "Closing Shade: '{0}'", this.Name);
OpenRelay.Off(); OpenRelay.Off();
StopRelay.Off(); StopRelay.Off();

View File

@@ -34,8 +34,8 @@ namespace PepperDash.Essentials
{ {
DeterminePlatform(); DeterminePlatform();
CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Loads configuration file", //CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Loads configuration file",
ConsoleAccessLevelEnum.AccessOperator); // ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.AddNewConsoleCommand(s =>
{ {
@@ -59,7 +59,7 @@ namespace PepperDash.Essentials
"Template URL: {1}", ConfigReader.ConfigObject.SystemUrl, ConfigReader.ConfigObject.TemplateUrl); "Template URL: {1}", ConfigReader.ConfigObject.SystemUrl, ConfigReader.ConfigObject.TemplateUrl);
}, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator); }, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator);
//GoWithLoad(); GoWithLoad();
} }
/// <summary> /// <summary>

View File

@@ -72,7 +72,7 @@ namespace PepperDash.Essentials
{ {
if (!b) if (!b)
{ {
mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin); //mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin);
mainDriver.EnvironmentDriver.Toggle(); mainDriver.EnvironmentDriver.Toggle();
} }
}); });
@@ -141,7 +141,7 @@ namespace PepperDash.Essentials
{ {
if (!b) if (!b)
{ {
mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin); //mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin);
mainDriver.EnvironmentDriver.Toggle(); mainDriver.EnvironmentDriver.Toggle();
} }
}); });

View File

@@ -169,6 +169,7 @@
<Compile Include="FOR REFERENCE UI\PageControllers\PageControllerLargeSetTopBoxGeneric.cs" /> <Compile Include="FOR REFERENCE UI\PageControllers\PageControllerLargeSetTopBoxGeneric.cs" />
<Compile Include="FOR REFERENCE UI\PageControllers\LargeTouchpanelControllerBase.cs" /> <Compile Include="FOR REFERENCE UI\PageControllers\LargeTouchpanelControllerBase.cs" />
<Compile Include="FOR REFERENCE UI\Panels\SmartGraphicsTouchpanelControllerBase.cs" /> <Compile Include="FOR REFERENCE UI\Panels\SmartGraphicsTouchpanelControllerBase.cs" />
<Compile Include="UIDrivers\Environment Drivers\EssentialsLightingDriver.cs" />
<Compile Include="UIDrivers\Environment Drivers\EssentialsEnvironmentDriver.cs" /> <Compile Include="UIDrivers\Environment Drivers\EssentialsEnvironmentDriver.cs" />
<Compile Include="UIDrivers\Environment Drivers\EssentialsShadeDriver.cs" /> <Compile Include="UIDrivers\Environment Drivers\EssentialsShadeDriver.cs" />
<Compile Include="UIDrivers\Essentials\EssentialsHeaderDriver.cs" /> <Compile Include="UIDrivers\Essentials\EssentialsHeaderDriver.cs" />

View File

@@ -4,5 +4,5 @@
[assembly: AssemblyCompany("PepperDash Technology Corp")] [assembly: AssemblyCompany("PepperDash Technology Corp")]
[assembly: AssemblyProduct("PepperDashEssentials")] [assembly: AssemblyProduct("PepperDashEssentials")]
[assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")] [assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")]
[assembly: AssemblyVersion("1.2.0.*")] [assembly: AssemblyVersion("1.3.0.*")]

View File

@@ -234,78 +234,102 @@ namespace PepperDash.Essentials
// Popup Container // Popup Container
/// <summary> /// <summary>
/// 3001 - 3004 /// 2001 - 2004
/// </summary> /// </summary>
public const uint EnvironmentPopupSubpageVisibleBase = 3000; public const uint EnvironmentBackgroundSubpageVisibleBase = 2000;
// ColumnOne // ColumnOne
/// <summary> /// <summary>
/// 3011 - 3015 /// 2011 - 2015
/// </summary> /// </summary>
public const uint EnvironmentColumnOneLightingTypeVisibleBase = 3010; public const uint EnvironmentColumnOneLightingTypeVisibleBase = 2010;
/// <summary> /// <summary>
/// 3016 - 3020 /// 2016 - 2020
/// </summary> /// </summary>
public const uint EnvironmentColumnOneShadingTypeVisibleBase = 3015; public const uint EnvironmentColumnOneShadingTypeVisibleBase = 2015;
// ColumnTwo // ColumnTwo
/// <summary> /// <summary>
/// 3021 - 3025 /// 2021 - 2025
/// </summary> /// </summary>
public const uint EnvironmentColumnTwoLightingTypeVisibleBase = 3020; public const uint EnvironmentColumnTwoLightingTypeVisibleBase = 2020;
/// <summary> /// <summary>
/// 3026 - 3030 /// 2026 - 2030
/// </summary> /// </summary>
public const uint EnvironmentColumnTwoShadingTypeVisibleBase = 3025; public const uint EnvironmentColumnTwoShadingTypeVisibleBase = 2025;
// ColumnThree // ColumnThree
/// <summary> /// <summary>
/// 3031 - 3035 /// 2031 - 2035
/// </summary> /// </summary>
public const uint EnvironmentColumnThreeLightingTypeVisibleBase = 3030; public const uint EnvironmentColumnThreeLightingTypeVisibleBase = 2030;
/// <summary> /// <summary>
/// 3036 - 3040 /// 2036 - 2040
/// </summary> /// </summary>
public const uint EnvironmentColumnThreeShadingTypeVisibleBase = 3035; public const uint EnvironmentColumnThreeShadingTypeVisibleBase = 2035;
// ColumnFour // ColumnFour
/// <summary> /// <summary>
/// 3041 - 3045 /// 2041 - 2045
/// </summary> /// </summary>
public const uint EnvironmentColumnFourLightingTypeVisibleBase = 3040; public const uint EnvironmentColumnFourLightingTypeVisibleBase = 2040;
/// <summary> /// <summary>
/// 3046 - 3050 /// 2046 - 2050
/// </summary> /// </summary>
public const uint EnvironmentColumnFourShadingTypeVisibleBase = 3045; public const uint EnvironmentColumnFourShadingTypeVisibleBase = 2045;
// Button press
/// <summary> /// <summary>
/// 3051 - 3060 /// 2051 - 2060
/// </summary> /// </summary>
public const uint EnvironmentColumnOneButtonPressBase = 3050; public const uint EnvironmentColumnOneButtonPressBase = 2050;
/// <summary> /// <summary>
/// 3061 - 3070 /// 2061 - 2070
/// </summary> /// </summary>
public const uint EnvironmentColumnTwoButtonPressBase = 3060; public const uint EnvironmentColumnTwoButtonPressBase = 2060;
/// <summary> /// <summary>
/// 3071 - 3080 /// 2071 - 2080
/// </summary> /// </summary>
public const uint EnvironmentColumnThreeButtonPressBase = 3070; public const uint EnvironmentColumnThreeButtonPressBase = 2070;
/// <summary> /// <summary>
/// 3081 - 3090 /// 2081 - 2090
/// </summary> /// </summary>
public const uint EnvironmentColumnFourButtonPressBase = 3080; public const uint EnvironmentColumnFourButtonPressBase = 2080;
// Button visibility
/// <summary>
/// 2151 - 2160
/// </summary>
public const uint EnvironmentColumnOneButtonVisibleBase = 2150;
/// <summary>
/// 2161 - 2170
/// </summary>
public const uint EnvironmentColumnTwoButtonVisibleBase = 2160;
/// <summary>
/// 2171 - 2180
/// </summary>
public const uint EnvironmentColumnThreeButtonVisibleBase = 2170;
/// <summary>
/// 2181 - 2190
/// </summary>
public const uint EnvironmentColumnFourButtonVisibleBase = 2180;
//****************************************************** //******************************************************

View File

@@ -73,26 +73,26 @@ namespace PepperDash.Essentials
// Environment Joins // Environment Joins
/// <summary> /// <summary>
/// 3001 - 3010 /// 2001 - 2010
/// </summary> /// </summary>
public const uint EnvironmentColumnOneLabelBase = 3000; public const uint EnvironmentColumnOneLabelBase = 2000;
/// <summary> /// <summary>
/// 3011 - 3020 /// 2011 - 2020
/// </summary> /// </summary>
public const uint EnvironmentColumnTwoLabelBase = 3010; public const uint EnvironmentColumnTwoLabelBase = 2010;
/// <summary> /// <summary>
/// 3021 - 3030 /// 2021 - 2030
/// </summary> /// </summary>
public const uint EnvironmentColumnThreeLabelBase = 3020; public const uint EnvironmentColumnThreeLabelBase = 2020;
/// <summary> /// <summary>
/// 3031 - 3040 /// 2031 - 2040
/// </summary> /// </summary>
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
//****************************************************** //******************************************************

View File

@@ -45,15 +45,31 @@ namespace PepperDash.Essentials
Devices = new List<IKeyed>(); Devices = new List<IKeyed>();
DeviceSubDrivers = new List<PanelDriverBase>(); DeviceSubDrivers = new List<PanelDriverBase>();
Parent.AvDriver.PopupInterlock.IsShownFeedback.OutputChange += new EventHandler<EventArgs>(IsShownFeedback_OutputChange);
// Calculate the join offests for each device page and assign join actions for each button // 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();
}
}
/// <summary> /// <summary>
/// Shows this driver and all sub drivers /// Shows this driver and all sub drivers
/// </summary> /// </summary>
public override void Show() public override void Show()
{ {
//TriList.SetBool(BackgroundSubpageJoin, true); Parent.AvDriver.PopupInterlock.ShowInterlockedWithToggle(BackgroundSubpageJoin);
foreach (var driver in DeviceSubDrivers) foreach (var driver in DeviceSubDrivers)
{ {
@@ -68,7 +84,7 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
public override void Hide() public override void Hide()
{ {
//TriList.SetBool(BackgroundSubpageJoin, false); Parent.AvDriver.PopupInterlock.HideAndClear();
foreach (var driver in DeviceSubDrivers) foreach (var driver in DeviceSubDrivers)
{ {
@@ -80,7 +96,10 @@ namespace PepperDash.Essentials
public override void Toggle() public override void Toggle()
{ {
base.Toggle(); if (IsVisible)
Hide();
else
Show();
} }
@@ -94,7 +113,7 @@ namespace PepperDash.Essentials
Devices.Clear(); Devices.Clear();
DeviceSubDrivers.Clear(); DeviceSubDrivers.Clear();
uint column = 4; uint column = 1;
foreach (var dKey in EnvironmentPropertiesConfig.DeviceKeys) foreach (var dKey in EnvironmentPropertiesConfig.DeviceKeys)
{ {
@@ -103,14 +122,23 @@ namespace PepperDash.Essentials
if (device != null) if (device != null)
{ {
Devices.Add(device); Devices.Add(device);
// Build the driver
var devicePanelDriver = GetPanelDriverForDevice(device, column);
// Add new PanelDriverBase SubDriver // 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); Debug.Console(1, "Adding '{0}' to Environment Devices", device.Key);
column++;
// Quit if device count is exceeded
if (column > 4)
break;
} }
column --;
} }
SetupEnvironmentUiJoins(); SetupEnvironmentUiJoins();
@@ -131,43 +159,48 @@ namespace PepperDash.Essentials
{ {
PanelDriverBase panelDriver = null; PanelDriverBase panelDriver = null;
uint digitalJoinBase = 0; uint buttonPressJoinBase = 0;
uint buttonVisibleJoinBase = 0;
uint stringJoinBase = 0; uint stringJoinBase = 0;
uint shadeTypeVisibleBase = 0; uint shadeTypeVisibleBase = 0;
uint lightingTypeVisibleBase = 0; uint lightingTypeVisibleBase = 0;
switch (column) switch (column)
{ {
case 4: case 1:
{ {
digitalJoinBase = UIBoolJoin.EnvironmentColumnFourButtonPressBase; buttonPressJoinBase = UIBoolJoin.EnvironmentColumnOneButtonPressBase;
stringJoinBase = UIStringJoin.EnvironmentColumnFourLabelBase; buttonVisibleJoinBase = UIBoolJoin.EnvironmentColumnOneButtonVisibleBase;
shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnFourShadingTypeVisibleBase; stringJoinBase = UIStringJoin.EnvironmentColumnOneLabelBase;
lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnFourLightingTypeVisibleBase; 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; break;
} }
case 3: case 3:
{ {
digitalJoinBase = UIBoolJoin.EnvironmentColumnThreeButtonPressBase; buttonPressJoinBase = UIBoolJoin.EnvironmentColumnThreeButtonPressBase;
buttonVisibleJoinBase = UIBoolJoin.EnvironmentColumnThreeButtonVisibleBase;
stringJoinBase = UIStringJoin.EnvironmentColumnThreeLabelBase; stringJoinBase = UIStringJoin.EnvironmentColumnThreeLabelBase;
shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnThreeShadingTypeVisibleBase; shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnThreeShadingTypeVisibleBase;
lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnThreeLightingTypeVisibleBase; lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnThreeLightingTypeVisibleBase;
break; break;
} }
case 2: case 4:
{ {
digitalJoinBase = UIBoolJoin.EnvironmentColumnTwoButtonPressBase; buttonPressJoinBase = UIBoolJoin.EnvironmentColumnFourButtonPressBase;
stringJoinBase = UIStringJoin.EnvironmentColumnTwoLabelBase; buttonVisibleJoinBase = UIBoolJoin.EnvironmentColumnFourButtonVisibleBase;
shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnTwoShadingTypeVisibleBase; stringJoinBase = UIStringJoin.EnvironmentColumnFourLabelBase;
lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnTwoLightingTypeVisibleBase; shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnFourShadingTypeVisibleBase;
break; lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnFourLightingTypeVisibleBase;
}
case 1:
{
digitalJoinBase = UIBoolJoin.EnvironmentColumnOneButtonPressBase;
stringJoinBase = UIStringJoin.EnvironmentColumnOneLabelBase;
shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnOneShadingTypeVisibleBase;
lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnOneLightingTypeVisibleBase;
break; break;
} }
default: default:
@@ -180,11 +213,11 @@ namespace PepperDash.Essentials
// Determine if device is a shade or lighting type and construct the appropriate driver // Determine if device is a shade or lighting type and construct the appropriate driver
if (device is ShadeBase) 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) 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 // Return the driver
@@ -198,7 +231,7 @@ namespace PepperDash.Essentials
void SetupEnvironmentUiJoins() void SetupEnvironmentUiJoins()
{ {
// Calculate which background subpage join to use // Calculate which background subpage join to use
BackgroundSubpageJoin = UIBoolJoin.EnvironmentPopupSubpageVisibleBase + (uint)DeviceSubDrivers.Count; BackgroundSubpageJoin = UIBoolJoin.EnvironmentBackgroundSubpageVisibleBase + (uint)DeviceSubDrivers.Count;
} }

View File

@@ -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
{
/// <summary>
/// Supports a lighting device with up to 6 scenes
/// </summary>
public class EssentialsLightingDriver : PanelDriverBase, IEnvironmentSubdriver
{
EssentialsEnvironmentDriver Parent;
public LightingBase LightingDevice { get; private set; }
public uint SubpageVisibleJoin { get; private set; }
/// <summary>
/// The base join number that all button visibilty joins are offset from
/// </summary>
uint ButtonVisibleJoinBase;
/// <summary>
/// The base join number that all button presses are offset from
/// </summary>
uint ButtonPressJoinBase;
/// <summary>
/// The base join number that all string lables are offset from
/// </summary>
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<LightingSceneChangeEventArgs>(LightingDevice_LightingSceneChange);
SetDeviceType();
SetSubpageVisibleJoin(subpageVisibleBase);
SetUpDeviceName();
SetUpButtonActions();
}
/// <summary>
/// Handles setting feedback for the currently selected scene button
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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;
}
/// <summary>
/// Drase
/// </summary>
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);
}
}
}
/// <summary>
/// Computes the desired join offset to try to achieve the most centered appearance when using a subpage with 6 scene buttons
/// </summary>
/// <returns></returns>
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,
}
}

View File

@@ -19,18 +19,26 @@ namespace PepperDash.Essentials
public uint SubpageVisibleJoin { get; private set; } public uint SubpageVisibleJoin { get; private set; }
uint DigitalJoinBase; /// <summary>
/// The base join number that all button presses are offset from
/// </summary>
uint ButtonPressJoinBase;
/// <summary>
/// The base join number that all string lables are offset from
/// </summary>
uint StringJoinBase; uint StringJoinBase;
eShadeDeviceType DeviceType; 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) : base(parent.TriList)
{ {
Parent = parent; Parent = parent;
DigitalJoinBase = digitalJoinBase; ButtonPressJoinBase = buttonPressJoinBase;
StringJoinBase = stringJoinBase; StringJoinBase = stringJoinBase;
ShadeDevice = DeviceManager.GetDeviceForKey(deviceKey) as ShadeBase; ShadeDevice = DeviceManager.GetDeviceForKey(deviceKey) as ShadeBase;
@@ -38,6 +46,10 @@ namespace PepperDash.Essentials
SetDeviceType(); SetDeviceType();
SetSubpageVisibleJoin(subpageVisibleBase); SetSubpageVisibleJoin(subpageVisibleBase);
SetUpDeviceName();
SetUpButtonActions();
} }
public override void Show() public override void Show()
@@ -56,7 +68,7 @@ namespace PepperDash.Essentials
void SetUpDeviceName() void SetUpDeviceName()
{ {
Parent.TriList.SetString(StringJoinBase + 50, ShadeDevice.Name); Parent.TriList.SetString(StringJoinBase + DeviceNameJoinOffset, ShadeDevice.Name);
} }
void SetDeviceType() void SetDeviceType()
@@ -71,6 +83,24 @@ namespace PepperDash.Essentials
{ {
SubpageVisibleJoin = subpageVisibleBase + (uint)DeviceType; 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 enum eShadeDeviceType : uint

View File

@@ -103,13 +103,7 @@ namespace PepperDash.Essentials
if (environmentDriver != null) if (environmentDriver != null)
{ {
TriList.SetString(nextJoin, "Lights"); TriList.SetString(nextJoin, "Lights");
TriList.SetSigFalseAction(nextJoin, () => TriList.SetSigFalseAction(nextJoin, environmentDriver.Toggle);
{
Parent.AvDriver.PopupInterlock.ShowInterlockedWithToggle(environmentDriver.BackgroundSubpageJoin);
environmentDriver.Toggle();
});
//TriList.SetSigFalseAction(nextJoin, environmentDriver.Toggle);
#warning Check the best way to show the environment subpage
nextJoin--; nextJoin--;
return nextJoin; return nextJoin;
} }

View File

@@ -14,11 +14,32 @@ namespace PepperDash.Essentials
{ {
public uint CurrentJoin { get; private set; } 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) public JoinedSigInterlock(BasicTriList triList)
{ {
TriList = triList; TriList = triList;
IsShownFeedback = new BoolFeedback(new Func<bool>( () => _IsShown));
} }
/// <summary> /// <summary>
@@ -31,7 +52,8 @@ namespace PepperDash.Essentials
if (CurrentJoin == join && TriList.BooleanInput[join].BoolValue) if (CurrentJoin == join && TriList.BooleanInput[join].BoolValue)
return; return;
SetButDontShow(join); SetButDontShow(join);
TriList.SetBool(CurrentJoin, true); TriList.SetBool(CurrentJoin, true);
IsShown = true;
} }
/// <summary> /// <summary>
@@ -48,7 +70,8 @@ namespace PepperDash.Essentials
if (CurrentJoin > 0) if (CurrentJoin > 0)
TriList.BooleanInput[CurrentJoin].BoolValue = false; TriList.BooleanInput[CurrentJoin].BoolValue = false;
CurrentJoin = join; CurrentJoin = join;
TriList.BooleanInput[CurrentJoin].BoolValue = true; TriList.BooleanInput[CurrentJoin].BoolValue = true;
IsShown = true;
} }
} }
/// <summary> /// <summary>
@@ -67,9 +90,12 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
public void Hide() public void Hide()
{ {
Debug.Console(2, "Trilist {0:X2}, interlock hiding {1}", TriList.ID, CurrentJoin); Debug.Console(2, "Trilist {0:X2}, interlock hiding {1}", TriList.ID, CurrentJoin);
if (CurrentJoin > 0) if (CurrentJoin > 0)
TriList.BooleanInput[CurrentJoin].BoolValue = false; {
TriList.BooleanInput[CurrentJoin].BoolValue = false;
IsShown = false;
}
} }
/// <summary> /// <summary>
@@ -77,9 +103,12 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
public void Show() public void Show()
{ {
Debug.Console(2, "Trilist {0:X2}, interlock showing {1}", TriList.ID, CurrentJoin); Debug.Console(2, "Trilist {0:X2}, interlock showing {1}", TriList.ID, CurrentJoin);
if (CurrentJoin > 0) if (CurrentJoin > 0)
TriList.BooleanInput[CurrentJoin].BoolValue = true; {
TriList.BooleanInput[CurrentJoin].BoolValue = true;
IsShown = true;
}
} }
/// <summary> /// <summary>
@@ -87,9 +116,12 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
/// <param name="join"></param> /// <param name="join"></param>
public void SetButDontShow(uint join) public void SetButDontShow(uint join)
{ {
if (CurrentJoin > 0) if (CurrentJoin > 0)
TriList.BooleanInput[CurrentJoin].BoolValue = false; {
TriList.BooleanInput[CurrentJoin].BoolValue = false;
IsShown = false;
}
CurrentJoin = join; CurrentJoin = join;
} }