mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-28 03:45:01 +00:00
Completed Environment UI effort. Tested with EssentialsHuddleRoom type
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the IsActive property on each scene and fires the LightingSceneChange event
|
||||
/// </summary>
|
||||
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<bool>(() => IsActive));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,6 +179,7 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Lutron
|
||||
/// <param name="scene"></param>
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -169,6 +169,7 @@
|
||||
<Compile Include="FOR REFERENCE UI\PageControllers\PageControllerLargeSetTopBoxGeneric.cs" />
|
||||
<Compile Include="FOR REFERENCE UI\PageControllers\LargeTouchpanelControllerBase.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\EssentialsShadeDriver.cs" />
|
||||
<Compile Include="UIDrivers\Essentials\EssentialsHeaderDriver.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.*")]
|
||||
|
||||
|
||||
@@ -234,78 +234,102 @@ namespace PepperDash.Essentials
|
||||
// Popup Container
|
||||
|
||||
/// <summary>
|
||||
/// 3001 - 3004
|
||||
/// 2001 - 2004
|
||||
/// </summary>
|
||||
public const uint EnvironmentPopupSubpageVisibleBase = 3000;
|
||||
public const uint EnvironmentBackgroundSubpageVisibleBase = 2000;
|
||||
|
||||
|
||||
// ColumnOne
|
||||
|
||||
/// <summary>
|
||||
/// 3011 - 3015
|
||||
/// 2011 - 2015
|
||||
/// </summary>
|
||||
public const uint EnvironmentColumnOneLightingTypeVisibleBase = 3010;
|
||||
public const uint EnvironmentColumnOneLightingTypeVisibleBase = 2010;
|
||||
|
||||
/// <summary>
|
||||
/// 3016 - 3020
|
||||
/// 2016 - 2020
|
||||
/// </summary>
|
||||
public const uint EnvironmentColumnOneShadingTypeVisibleBase = 3015;
|
||||
public const uint EnvironmentColumnOneShadingTypeVisibleBase = 2015;
|
||||
|
||||
// ColumnTwo
|
||||
|
||||
/// <summary>
|
||||
/// 3021 - 3025
|
||||
/// 2021 - 2025
|
||||
/// </summary>
|
||||
public const uint EnvironmentColumnTwoLightingTypeVisibleBase = 3020;
|
||||
public const uint EnvironmentColumnTwoLightingTypeVisibleBase = 2020;
|
||||
|
||||
/// <summary>
|
||||
/// 3026 - 3030
|
||||
/// 2026 - 2030
|
||||
/// </summary>
|
||||
public const uint EnvironmentColumnTwoShadingTypeVisibleBase = 3025;
|
||||
public const uint EnvironmentColumnTwoShadingTypeVisibleBase = 2025;
|
||||
|
||||
// ColumnThree
|
||||
|
||||
/// <summary>
|
||||
/// 3031 - 3035
|
||||
/// 2031 - 2035
|
||||
/// </summary>
|
||||
public const uint EnvironmentColumnThreeLightingTypeVisibleBase = 3030;
|
||||
public const uint EnvironmentColumnThreeLightingTypeVisibleBase = 2030;
|
||||
|
||||
/// <summary>
|
||||
/// 3036 - 3040
|
||||
/// 2036 - 2040
|
||||
/// </summary>
|
||||
public const uint EnvironmentColumnThreeShadingTypeVisibleBase = 3035;
|
||||
public const uint EnvironmentColumnThreeShadingTypeVisibleBase = 2035;
|
||||
|
||||
// ColumnFour
|
||||
|
||||
/// <summary>
|
||||
/// 3041 - 3045
|
||||
/// 2041 - 2045
|
||||
/// </summary>
|
||||
public const uint EnvironmentColumnFourLightingTypeVisibleBase = 3040;
|
||||
public const uint EnvironmentColumnFourLightingTypeVisibleBase = 2040;
|
||||
|
||||
/// <summary>
|
||||
/// 3046 - 3050
|
||||
/// 2046 - 2050
|
||||
/// </summary>
|
||||
public const uint EnvironmentColumnFourShadingTypeVisibleBase = 3045;
|
||||
public const uint EnvironmentColumnFourShadingTypeVisibleBase = 2045;
|
||||
|
||||
// Button press
|
||||
|
||||
/// <summary>
|
||||
/// 3051 - 3060
|
||||
/// 2051 - 2060
|
||||
/// </summary>
|
||||
public const uint EnvironmentColumnOneButtonPressBase = 3050;
|
||||
public const uint EnvironmentColumnOneButtonPressBase = 2050;
|
||||
|
||||
/// <summary>
|
||||
/// 3061 - 3070
|
||||
/// 2061 - 2070
|
||||
/// </summary>
|
||||
public const uint EnvironmentColumnTwoButtonPressBase = 3060;
|
||||
public const uint EnvironmentColumnTwoButtonPressBase = 2060;
|
||||
|
||||
/// <summary>
|
||||
/// 3071 - 3080
|
||||
/// 2071 - 2080
|
||||
/// </summary>
|
||||
public const uint EnvironmentColumnThreeButtonPressBase = 3070;
|
||||
public const uint EnvironmentColumnThreeButtonPressBase = 2070;
|
||||
|
||||
/// <summary>
|
||||
/// 3081 - 3090
|
||||
/// 2081 - 2090
|
||||
/// </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;
|
||||
|
||||
|
||||
//******************************************************
|
||||
|
||||
@@ -73,26 +73,26 @@ namespace PepperDash.Essentials
|
||||
// Environment Joins
|
||||
|
||||
/// <summary>
|
||||
/// 3001 - 3010
|
||||
/// 2001 - 2010
|
||||
/// </summary>
|
||||
public const uint EnvironmentColumnOneLabelBase = 3000;
|
||||
public const uint EnvironmentColumnOneLabelBase = 2000;
|
||||
|
||||
/// <summary>
|
||||
/// 3011 - 3020
|
||||
/// 2011 - 2020
|
||||
/// </summary>
|
||||
public const uint EnvironmentColumnTwoLabelBase = 3010;
|
||||
public const uint EnvironmentColumnTwoLabelBase = 2010;
|
||||
|
||||
/// <summary>
|
||||
/// 3021 - 3030
|
||||
/// 2021 - 2030
|
||||
/// </summary>
|
||||
public const uint EnvironmentColumnThreeLabelBase = 3020;
|
||||
public const uint EnvironmentColumnThreeLabelBase = 2020;
|
||||
|
||||
/// <summary>
|
||||
/// 3031 - 3040
|
||||
/// 2031 - 2040
|
||||
/// </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
|
||||
|
||||
//******************************************************
|
||||
|
||||
|
||||
@@ -45,15 +45,31 @@ namespace PepperDash.Essentials
|
||||
Devices = new List<IKeyed>();
|
||||
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
|
||||
}
|
||||
|
||||
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>
|
||||
/// Shows this driver and all sub drivers
|
||||
/// </summary>
|
||||
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
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
@@ -19,18 +19,26 @@ namespace PepperDash.Essentials
|
||||
|
||||
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;
|
||||
|
||||
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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<bool>( () => _IsShown));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -67,9 +90,12 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -77,9 +103,12 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -87,9 +116,12 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
/// <param name="join"></param>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user