Environment Driver now showing and correct background subpage is appearing

This commit is contained in:
Neil Dorin
2018-05-22 23:15:08 -06:00
parent a0ebc08838
commit 80377a41d0
16 changed files with 530 additions and 107 deletions

View File

@@ -4,6 +4,8 @@ using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
namespace PepperDash.Essentials.Core.Shades
{
public interface IShades
@@ -12,12 +14,29 @@ namespace PepperDash.Essentials.Core.Shades
}
/// <summary>
/// Requirements for a device that implements basic shade control
/// Requirements for a device that implements basic Open/Close shade control
/// </summary>
public interface iShadesRaiseLower
public interface IShadesOpenClose
{
void Open();
void Stop();
void Close();
}
/// <summary>
/// Requirements for a device that implements basic Open/Close/Stop shade control
/// </summary>
public interface IShadesOpenCloseStop : IShadesOpenClose
{
void Stop();
}
/// <summary>
/// Requirements for a shade device that provides open/closed feedback
/// </summary>
public interface iShadesRaiseLowerFeedback
{
BoolFeedback ShadeIsOpenFeedback { get; }
BoolFeedback ShadeIsClosedFeedback { get; }
}
}

View File

@@ -9,20 +9,20 @@ using PepperDash.Essentials.Core.CrestronIO;
namespace PepperDash.Essentials.Core.Shades
{
public abstract class ShadeBase : Device, iShadesRaiseLower
/// <summary>
/// Base class for a shade device
/// </summary>
public abstract class ShadeBase : Device, IShadesOpenClose
{
public ISwitchedOutput SwitchedOutput;
public ShadeBase(string key, string name)
: base(key, name)
{
}
#region iShadesRaiseLower Members
#region iShadesOpenClose Members
public abstract void Open();
public abstract void Stop();
public abstract void Close();
#endregion

View File

@@ -14,7 +14,7 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Somfy
/// <summary>
/// Controls a single shade using three relays
/// </summary>
public class RelayControlledShade : ShadeBase
public class RelayControlledShade : ShadeBase, IShadesOpenCloseStop
{
RelayControlledShadeConfigProperties Config;
@@ -52,7 +52,7 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Somfy
OpenRelay.On();
}
public override void Stop()
public void Stop()
{
OpenRelay.Off();
CloseRelay.Off();

View File

@@ -53,6 +53,8 @@ namespace PepperDash.Essentials
{
Debug.Console(0, panelController, "Adding environment driver");
mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props);
mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.Config.Environment);
}
mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom);
@@ -65,6 +67,15 @@ namespace PepperDash.Essentials
// Wire up hard keys
tsw.Power.UserObject = new Action<bool>(b => { if (!b) avDriver.PowerButtonPressed(); });
//tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); });
if(mainDriver.EnvironmentDriver != null)
tsw.Lights.UserObject = new Action<bool>(b =>
{
if (!b)
{
mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin);
mainDriver.EnvironmentDriver.Toggle();
}
});
tsw.Up.UserObject = new Action<bool>(avDriver.VolumeUpPress);
tsw.Down.UserObject = new Action<bool>(avDriver.VolumeDownPress);
}
@@ -111,6 +122,8 @@ namespace PepperDash.Essentials
{
Debug.Console(0, panelController, "Adding environment driver");
mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props);
mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.Config.Environment);
}
mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom);
@@ -123,6 +136,15 @@ namespace PepperDash.Essentials
// Wire up hard keys
tsw.Power.UserObject = new Action<bool>(b => { if (!b) avDriver.EndMeetingPress(); });
//tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); });
if (mainDriver.EnvironmentDriver != null)
tsw.Lights.UserObject = new Action<bool>(b =>
{
if (!b)
{
mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin);
mainDriver.EnvironmentDriver.Toggle();
}
});
tsw.Up.UserObject = new Action<bool>(avDriver.VolumeUpPress);
tsw.Down.UserObject = new Action<bool>(avDriver.VolumeDownPress);
}

View File

@@ -169,7 +169,8 @@
<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\Essentials\EssentialsEnvironmentDriver.cs" />
<Compile Include="UIDrivers\Environment Drivers\EssentialsEnvironmentDriver.cs" />
<Compile Include="UIDrivers\Environment Drivers\EssentialsShadeDriver.cs" />
<Compile Include="UIDrivers\Essentials\EssentialsHeaderDriver.cs" />
<Compile Include="UIDrivers\SigInterlock.cs" />
<Compile Include="UIDrivers\EssentialsHuddleVTC\EssentialsHuddlePresentationUiDriver.cs" />

View File

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

View File

@@ -223,12 +223,92 @@ namespace PepperDash.Essentials
/// <summary>
/// 1256
/// </summary>
public const uint VCMinMaxEnable = 1256;
public const uint VCMinMaxEnable = 1256;
// Letter joins start at 2921;
//******************************************************
// Letter joins start at 2921;
// Environment Joins
// Popup Container
/// <summary>
/// 3001 - 3004
/// </summary>
public const uint EnvironmentPopupSubpageVisibleBase = 3000;
// ColumnOne
/// <summary>
/// 3011 - 3015
/// </summary>
public const uint EnvironmentColumnOneLightingTypeVisibleBase = 3010;
/// <summary>
/// 3016 - 3020
/// </summary>
public const uint EnvironmentColumnOneShadingTypeVisibleBase = 3015;
// ColumnTwo
/// <summary>
/// 3021 - 3025
/// </summary>
public const uint EnvironmentColumnTwoLightingTypeVisibleBase = 3020;
/// <summary>
/// 3026 - 3030
/// </summary>
public const uint EnvironmentColumnTwoShadingTypeVisibleBase = 3025;
// ColumnThree
/// <summary>
/// 3031 - 3035
/// </summary>
public const uint EnvironmentColumnThreeLightingTypeVisibleBase = 3030;
/// <summary>
/// 3036 - 3040
/// </summary>
public const uint EnvironmentColumnThreeShadingTypeVisibleBase = 3035;
// ColumnFour
/// <summary>
/// 3041 - 3045
/// </summary>
public const uint EnvironmentColumnFourLightingTypeVisibleBase = 3040;
/// <summary>
/// 3046 - 3050
/// </summary>
public const uint EnvironmentColumnFourShadingTypeVisibleBase = 3045;
/// <summary>
/// 3051 - 3060
/// </summary>
public const uint EnvironmentColumnOneButtonPressBase = 3050;
/// <summary>
/// 3061 - 3070
/// </summary>
public const uint EnvironmentColumnTwoButtonPressBase = 3060;
/// <summary>
/// 3071 - 3080
/// </summary>
public const uint EnvironmentColumnThreeButtonPressBase = 3070;
/// <summary>
/// 3081 - 3090
/// </summary>
public const uint EnvironmentColumnFourButtonPressBase = 3080;
//******************************************************
/// <summary>
/// 3101
@@ -263,7 +343,7 @@ namespace PepperDash.Essentials
/// </summary>
public const uint TechSchedulerVisible = 3112;
//******************************************************
//*****************************************************
/// <summary>
/// 3811
/// </summary>

View File

@@ -68,6 +68,34 @@ namespace PepperDash.Essentials
/// </summary>
//public const uint KeypadText = 2901;
//******************************************************
// Environment Joins
/// <summary>
/// 3001 - 3010
/// </summary>
public const uint EnvironmentColumnOneLabelBase = 3000;
/// <summary>
/// 3011 - 3020
/// </summary>
public const uint EnvironmentColumnTwoLabelBase = 3010;
/// <summary>
/// 3021 - 3030
/// </summary>
public const uint EnvironmentColumnThreeLabelBase = 3020;
/// <summary>
/// 3031 - 3040
/// </summary>
public const uint EnvironmentColumnFourLabelBase = 3030;
// 3050, 3060, 3070 and 3080 reserved for column device name labels
//******************************************************
/// <summary>
/// 3101 - This is the start of the range 3101 - 3120
/// </summary>

View File

@@ -0,0 +1,213 @@
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.Shades;
using PepperDash.Essentials.Core.Lighting;
namespace PepperDash.Essentials
{
public class EssentialsEnvironmentDriver : PanelDriverBase
{
/// <summary>
/// Do I need this here?
/// </summary>
CrestronTouchpanelPropertiesConfig Config;
/// <summary>
/// The list of devices this driver is responsible for controlling
/// </summary>
public List<IKeyed> Devices { get; private set; }
/// <summary>
/// The parent driver for this
/// </summary>
EssentialsPanelMainInterfaceDriver Parent;
/// <summary>
/// The list of sub drivers for the devices
/// </summary>
public List<PanelDriverBase> DeviceSubDrivers { get; private set; }
public uint BackgroundSubpageJoin { get; private set; }
public EssentialsEnvironmentDriver(EssentialsPanelMainInterfaceDriver parent, CrestronTouchpanelPropertiesConfig config)
: base(parent.TriList)
{
Config = config;
Parent = parent;
Devices = new List<IKeyed>();
DeviceSubDrivers = new List<PanelDriverBase>();
// Calculate the join offests for each device page and assign join actions for each button
}
/// <summary>
/// Shows this driver and all sub drivers
/// </summary>
public override void Show()
{
//TriList.SetBool(BackgroundSubpageJoin, true);
foreach (var driver in DeviceSubDrivers)
{
driver.Show();
}
base.Show();
}
/// <summary>
/// Hides this driver and all sub drivers
/// </summary>
public override void Hide()
{
//TriList.SetBool(BackgroundSubpageJoin, false);
foreach (var driver in DeviceSubDrivers)
{
driver.Hide();
}
base.Hide();
}
public override void Toggle()
{
base.Toggle();
}
/// <summary>
/// Reads the device keys from the config and gets the devices by key
/// </summary>
public void GetDevicesFromConfig(Room.Config.EssentialsEnvironmentPropertiesConfig EnvironmentPropertiesConfig)
{
if (EnvironmentPropertiesConfig != null)
{
Devices.Clear();
DeviceSubDrivers.Clear();
uint column = 4;
foreach (var dKey in EnvironmentPropertiesConfig.DeviceKeys)
{
var device = DeviceManager.GetDeviceForKey(dKey);
if (device != null)
{
Devices.Add(device);
// Add new PanelDriverBase SubDriver
DeviceSubDrivers.Add(GetPanelDriverForDevice(device, column));
Debug.Console(1, "Adding '{0}' to Environment Devices", device.Key);
}
column --;
}
SetupEnvironmentUiJoins();
}
else
{
Debug.Console(1, "Unable to get devices from config. No EnvironmentPropertiesConfig object in room config");
}
}
/// <summary>
/// Returns the appropriate panel driver for the device
/// </summary>
/// <param name="device"></param>
/// <param name="column"></param>
/// <returns></returns>
PanelDriverBase GetPanelDriverForDevice(IKeyed device, uint column)
{
PanelDriverBase panelDriver = null;
uint digitalJoinBase = 0;
uint stringJoinBase = 0;
uint shadeTypeVisibleBase = 0;
uint lightingTypeVisibleBase = 0;
switch (column)
{
case 4:
{
digitalJoinBase = UIBoolJoin.EnvironmentColumnFourButtonPressBase;
stringJoinBase = UIStringJoin.EnvironmentColumnFourLabelBase;
shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnFourShadingTypeVisibleBase;
lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnFourLightingTypeVisibleBase;
break;
}
case 3:
{
digitalJoinBase = UIBoolJoin.EnvironmentColumnThreeButtonPressBase;
stringJoinBase = UIStringJoin.EnvironmentColumnThreeLabelBase;
shadeTypeVisibleBase = UIBoolJoin.EnvironmentColumnThreeShadingTypeVisibleBase;
lightingTypeVisibleBase = UIBoolJoin.EnvironmentColumnThreeLightingTypeVisibleBase;
break;
}
case 2:
{
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;
break;
}
default:
{
Debug.Console(1, "Environment Driver: Invalid column number specified");
break;
}
}
// 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);
}
else if (device is LightingBase)
{
//panelDriver = new EssentialsLightingDriver(this, device.Key, digitalJoinBase, stringJoinBase, lightingTypeVisibleBase);
}
// Return the driver
return panelDriver;
}
/// <summary>
/// Determines the join values for the generic environment subpages
/// </summary>
void SetupEnvironmentUiJoins()
{
// Calculate which background subpage join to use
BackgroundSubpageJoin = UIBoolJoin.EnvironmentPopupSubpageVisibleBase + (uint)DeviceSubDrivers.Count;
}
}
public interface IEnvironmentSubdriver
{
uint SubpageVisibleJoin { get; }
}
}

View File

@@ -0,0 +1,83 @@
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.Shades;
namespace PepperDash.Essentials
{
public class EssentialsShadeDriver : PanelDriverBase, IEnvironmentSubdriver
{
EssentialsEnvironmentDriver Parent;
public ShadeBase ShadeDevice { get; private set; }
public uint SubpageVisibleJoin { get; private set; }
uint DigitalJoinBase;
uint StringJoinBase;
eShadeDeviceType DeviceType;
public EssentialsShadeDriver(EssentialsEnvironmentDriver parent, string deviceKey, uint digitalJoinBase, uint stringJoinBase, uint subpageVisibleBase)
: base(parent.TriList)
{
Parent = parent;
DigitalJoinBase = digitalJoinBase;
StringJoinBase = stringJoinBase;
ShadeDevice = DeviceManager.GetDeviceForKey(deviceKey) as ShadeBase;
SetDeviceType();
SetSubpageVisibleJoin(subpageVisibleBase);
}
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 + 50, ShadeDevice.Name);
}
void SetDeviceType()
{
if (ShadeDevice is IShadesOpenCloseStop)
DeviceType = eShadeDeviceType.OpenCloseStop;
else if (ShadeDevice is IShadesOpenClose)
DeviceType = eShadeDeviceType.OpenClose;
}
void SetSubpageVisibleJoin(uint subpageVisibleBase)
{
SubpageVisibleJoin = subpageVisibleBase + (uint)DeviceType;
}
}
enum eShadeDeviceType : uint
{
None = 0,
OpenCloseStop = 1,
OpenClose = 2,
DiscreteLevel = 3
}
}

View File

@@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials
{
public class EssentialsEnvironmentDriver : PanelDriverBase
{
CrestronTouchpanelPropertiesConfig Config;
/// <summary>
/// The parent driver for this
/// </summary>
EssentialsPanelMainInterfaceDriver Parent;
public EssentialsEnvironmentDriver(EssentialsPanelMainInterfaceDriver parent, CrestronTouchpanelPropertiesConfig config)
: base(parent.TriList)
{
Config = config;
Parent = parent;
}
}
}

View File

@@ -103,8 +103,13 @@ namespace PepperDash.Essentials
if (environmentDriver != null)
{
TriList.SetString(nextJoin, "Lights");
TriList.SetSigFalseAction(nextJoin, environmentDriver.Show);
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
nextJoin--;
return nextJoin;
}

View File

@@ -1,71 +1,71 @@
using System;
using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.UI;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.SmartObjects;
namespace PepperDash.Essentials
{
/// <summary>
///
/// </summary>
public class EssentialsPanelMainInterfaceDriver : PanelDriverBase
{
/// <summary>
/// Assign the appropriate A/V driver.
/// Want to keep the AvDriver alive, because it may hold states
/// </summary>
using System;
using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.UI;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.SmartObjects;
namespace PepperDash.Essentials
{
/// <summary>
///
/// </summary>
public class EssentialsPanelMainInterfaceDriver : PanelDriverBase
{
/// <summary>
/// Assign the appropriate A/V driver.
/// Want to keep the AvDriver alive, because it may hold states
/// </summary>
public IAVDriver AvDriver { get; set; }
public EssentialsHeaderDriver HeaderDriver { get; set; }
public EssentialsEnvironmentDriver EnvironmentDriver { get; set; }
public PanelDriverBase CurrentChildDriver { get; private set; }
public EssentialsEnvironmentDriver EnvironmentDriver { get; set; }
public PanelDriverBase CurrentChildDriver { get; private set; }
CrestronTouchpanelPropertiesConfig Config;
/// <summary>
/// The main interlock for popups
/// </summary>
public JoinedSigInterlock PopupInterlock { get; private set; }
public EssentialsPanelMainInterfaceDriver(BasicTriListWithSmartObject trilist,
CrestronTouchpanelPropertiesConfig config)
: base(trilist)
{
Config = config;
}
public override void Show()
{
CurrentChildDriver = null;
ShowSubDriver(AvDriver as PanelDriverBase);
base.Show();
}
public override void Hide()
{
TriList.BooleanInput[UIBoolJoin.StartPageVisible].BoolValue = false;
base.Hide();
}
void ShowSubDriver(PanelDriverBase driver)
{
CurrentChildDriver = driver;
if (driver == null)
return;
this.Hide();
driver.Show();
}
/// <summary>
///
/// </summary>
public override void BackButtonPressed()
{
if(CurrentChildDriver != null)
CurrentChildDriver.BackButtonPressed();
}
}
//public JoinedSigInterlock PopupInterlock { get; private set; }
public EssentialsPanelMainInterfaceDriver(BasicTriListWithSmartObject trilist,
CrestronTouchpanelPropertiesConfig config)
: base(trilist)
{
Config = config;
}
public override void Show()
{
CurrentChildDriver = null;
ShowSubDriver(AvDriver as PanelDriverBase);
base.Show();
}
public override void Hide()
{
TriList.BooleanInput[UIBoolJoin.StartPageVisible].BoolValue = false;
base.Hide();
}
void ShowSubDriver(PanelDriverBase driver)
{
CurrentChildDriver = driver;
if (driver == null)
return;
this.Hide();
driver.Show();
}
/// <summary>
///
/// </summary>
public override void BackButtonPressed()
{
if(CurrentChildDriver != null)
CurrentChildDriver.BackButtonPressed();
}
}
}

View File

@@ -85,7 +85,7 @@ namespace PepperDash.Essentials
/// <summary>
/// Toggles visibility of this driver
/// </summary>
public void Toggle()
public virtual void Toggle()
{
if (IsVisible)
Hide();