Moved source selection workflow into separate class

This commit is contained in:
Heath Volmer
2017-02-15 10:50:04 -07:00
parent 23729f680c
commit 94626ca7d9
13 changed files with 216 additions and 120 deletions

View File

@@ -12,12 +12,26 @@ using PepperDash.Essentials.Core.PageManagers;
namespace PepperDash.Essentials namespace PepperDash.Essentials
{ {
public class DualDisplayRouting : PanelDriverBase public class DualDisplaySimpleOrAdvancedRouting : PanelDriverBase
{ {
EssentialsPresentationPanelAvFunctionsDriver Parent;
CTimer SourceSelectedTimer; CTimer SourceSelectedTimer;
public DualDisplayRouting(BasicTriListWithSmartObject trilist) : base(trilist) /// <summary>
/// Smart Object 3200
/// </summary>
SubpageReferenceList SourcesSrl;
bool IsSharingModeAdvanced;
public DualDisplaySimpleOrAdvancedRouting(EssentialsPresentationPanelAvFunctionsDriver parent) : base(parent.TriList)
{ {
Parent = parent;
SourcesSrl = new SubpageReferenceList(TriList, 3200, 3, 3, 3);
TriList.SetSigFalseAction(UIBoolJoin.ToggleSharingModePress, ToggleSharingModePressed);
TriList.SetSigFalseAction(UIBoolJoin.Display1AudioButtonPressAndFb, Display1AudioPress); TriList.SetSigFalseAction(UIBoolJoin.Display1AudioButtonPressAndFb, Display1AudioPress);
TriList.SetSigFalseAction(UIBoolJoin.Display1ControlButtonPress, Display1ControlPress); TriList.SetSigFalseAction(UIBoolJoin.Display1ControlButtonPress, Display1ControlPress);
TriList.SetSigTrueAction(UIBoolJoin.Display1SelectPress, Display1Press); TriList.SetSigTrueAction(UIBoolJoin.Display1SelectPress, Display1Press);
@@ -27,23 +41,102 @@ namespace PepperDash.Essentials
TriList.SetSigTrueAction(UIBoolJoin.Display2SelectPress, Display2Press); TriList.SetSigTrueAction(UIBoolJoin.Display2SelectPress, Display2Press);
} }
public void Enable() /// <summary>
{ ///
// attach to the source list SRL /// </summary>
}
public override void Show() public override void Show()
{ {
TriList.BooleanInput[UIBoolJoin.DualDisplayPageVisible].BoolValue = true; TriList.BooleanInput[UIBoolJoin.ToggleSharingModeVisible].BoolValue = true;
TriList.BooleanInput[UIBoolJoin.StagingPageVisible].BoolValue = true;
if(IsSharingModeAdvanced)
TriList.BooleanInput[UIBoolJoin.DualDisplayPageVisible].BoolValue = true;
else
TriList.BooleanInput[UIBoolJoin.SelectASourceVisible].BoolValue = true;
base.Show(); base.Show();
} }
/// <summary>
///
/// </summary>
public override void Hide() public override void Hide()
{ {
TriList.BooleanInput[UIBoolJoin.DualDisplayPageVisible].BoolValue = false; TriList.BooleanInput[UIBoolJoin.ToggleSharingModeVisible].BoolValue = false;
TriList.BooleanInput[UIBoolJoin.StagingPageVisible].BoolValue = false;
if(IsSharingModeAdvanced)
TriList.BooleanInput[UIBoolJoin.DualDisplayPageVisible].BoolValue = false;
else
TriList.BooleanInput[UIBoolJoin.SelectASourceVisible].BoolValue = false;
base.Hide(); base.Hide();
} }
public void SetCurrentRoomFromParent()
{
if (IsSharingModeAdvanced)
return; // add stuff here
else
SetupSourcesForSimpleRouting();
}
/// <summary>
///
/// </summary>
void SetupSourcesForSimpleRouting()
{
// get the source list config and set up the source list
var config = ConfigReader.ConfigObject.SourceLists;
if (config.ContainsKey(Parent.CurrentRoom.SourceListKey))
{
var srcList = config[Parent.CurrentRoom.SourceListKey]
.Values.ToList().OrderBy(s => s.Order);
// Setup sources list
uint i = 1; // counter for UI list
foreach (var srcConfig in srcList)
{
if (!srcConfig.IncludeInSourceList) // Skip sources marked this way
continue;
var sourceKey = srcConfig.SourceKey;
var actualSource = DeviceManager.GetDeviceForKey(sourceKey) as Device;
if (actualSource == null)
{
Debug.Console(0, "Cannot assign missing source '{0}' to source UI list",
srcConfig.SourceKey);
continue;
}
var localSrcConfig = srcConfig; // lambda scope below
var item = new SubpageReferenceListSourceItem(i++, SourcesSrl, srcConfig,
b => { if (!b) UiSelectSource(localSrcConfig); });
SourcesSrl.AddItem(item); // add to the SRL
item.RegisterForSourceChange(Parent.CurrentRoom);
}
SourcesSrl.Count = (ushort)(i - 1);
}
}
/// <summary>
///
/// </summary>
void ToggleSharingModePressed()
{
Hide();
IsSharingModeAdvanced = !IsSharingModeAdvanced;
TriList.BooleanInput[UIBoolJoin.ToggleSharingModePress].BoolValue = IsSharingModeAdvanced;
Show();
}
/// <summary>
/// Called from button presses on source, where We can assume we want
/// to change to the proper screen.
/// </summary>
/// <param name="key">The key name of the route to run</param>
void UiSelectSource(SourceListItem sourceItem)
{
if (IsSharingModeAdvanced)
{
SourceListButtonPress(sourceItem);
}
else
Parent.CurrentRoom.DoSourceToAllDestinationsRoute(sourceItem);
}
public void SourceListButtonPress(SourceListItem item) public void SourceListButtonPress(SourceListItem item)
{ {

View File

@@ -105,7 +105,7 @@ namespace PepperDash.Essentials
/// <summary> /// <summary>
/// Driver that manages advanced sharing features /// Driver that manages advanced sharing features
/// </summary> /// </summary>
DualDisplayRouting DualDisplayUiDriver; DualDisplaySimpleOrAdvancedRouting DualDisplayUiDriver;
/// <summary> /// <summary>
/// All children attached to this driver. For hiding and showing as a group. /// All children attached to this driver. For hiding and showing as a group.
@@ -116,10 +116,10 @@ namespace PepperDash.Essentials
//// Important smart objects //// Important smart objects
/// <summary> ///// <summary>
/// Smart Object 3200 ///// Smart Object 3200
/// </summary> ///// </summary>
SubpageReferenceList SourcesSrl; //SubpageReferenceList SourcesSrl;
/// <summary> /// <summary>
/// Smart Object 15022 /// Smart Object 15022
@@ -146,7 +146,7 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
CTimer PowerOffTimer; CTimer PowerOffTimer;
bool IsSharingModeAdvanced; //bool IsSharingModeAdvanced;
/// <summary> /// <summary>
/// Constructor /// Constructor
@@ -158,8 +158,10 @@ namespace PepperDash.Essentials
Config = config; Config = config;
Parent = parent; Parent = parent;
SourcesSrl = new SubpageReferenceList(TriList, 3200, 3, 3, 3);
//SourcesSrl = new SubpageReferenceList(TriList, 3200, 3, 3, 3);
ActivityFooterSrl = new SubpageReferenceList(TriList, 15022, 3, 3, 3); ActivityFooterSrl = new SubpageReferenceList(TriList, 15022, 3, 3, 3);
DualDisplayUiDriver = new DualDisplaySimpleOrAdvancedRouting(this);
SetupActivityFooterWhenRoomOff(); SetupActivityFooterWhenRoomOff();
ShowVolumeGauge = true; ShowVolumeGauge = true;
@@ -241,8 +243,7 @@ namespace PepperDash.Essentials
TriList.BooleanInput[UIBoolJoin.StartPageVisible].BoolValue = false; TriList.BooleanInput[UIBoolJoin.StartPageVisible].BoolValue = false;
TriList.BooleanInput[UIBoolJoin.TapToBeginVisible].BoolValue = false; TriList.BooleanInput[UIBoolJoin.TapToBeginVisible].BoolValue = false;
TriList.BooleanInput[UIBoolJoin.SelectASourceVisible].BoolValue = false; TriList.BooleanInput[UIBoolJoin.SelectASourceVisible].BoolValue = false;
TriList.BooleanInput[UIBoolJoin.StagingPageVisible].BoolValue = false; //TriList.BooleanInput[UIBoolJoin.StagingPageVisible].BoolValue = false;
TriList.BooleanInput[UIBoolJoin.ToggleSharingModeVisible].BoolValue = false;
VolumeButtonsPopupFeedback.ClearNow(); VolumeButtonsPopupFeedback.ClearNow();
CancelPowerOff(); CancelPowerOff();
@@ -264,7 +265,7 @@ namespace PepperDash.Essentials
// show start page or staging... // show start page or staging...
if (CurrentRoom.OnFeedback.BoolValue) if (CurrentRoom.OnFeedback.BoolValue)
{ {
TriList.BooleanInput[UIBoolJoin.StagingPageVisible].BoolValue = true; //TriList.BooleanInput[UIBoolJoin.StagingPageVisible].BoolValue = true;
TriList.BooleanInput[UIBoolJoin.TapToBeginVisible].BoolValue = false; TriList.BooleanInput[UIBoolJoin.TapToBeginVisible].BoolValue = false;
TriList.BooleanInput[UIBoolJoin.SelectASourceVisible].BoolValue = false; TriList.BooleanInput[UIBoolJoin.SelectASourceVisible].BoolValue = false;
} }
@@ -288,58 +289,58 @@ namespace PepperDash.Essentials
TriList.BooleanInput[UIBoolJoin.TimeOnlyVisible].BoolValue = Config.ShowTime; TriList.BooleanInput[UIBoolJoin.TimeOnlyVisible].BoolValue = Config.ShowTime;
} }
TriList.SetSigFalseAction(UIBoolJoin.ToggleSharingModePress, ToggleSharingModePressed); //TriList.SetSigFalseAction(UIBoolJoin.ToggleSharingModePress, ToggleSharingModePressed);
ShowCurrentDisplayModeSigsInUse(); ShowCurrentDisplayModeSigsInUse();
break; break;
} }
} }
/// <summary> ///// <summary>
/// /////
/// </summary> ///// </summary>
void ToggleSharingModePressed() //void ToggleSharingModePressed()
{ //{
HideSharingMode(); // HideSharingMode();
IsSharingModeAdvanced = !IsSharingModeAdvanced; // IsSharingModeAdvanced = !IsSharingModeAdvanced;
TriList.BooleanInput[UIBoolJoin.ToggleSharingModePress].BoolValue = IsSharingModeAdvanced; // TriList.BooleanInput[UIBoolJoin.ToggleSharingModePress].BoolValue = IsSharingModeAdvanced;
RevealSharingMode(); // RevealSharingMode();
} //}
/// <summary> ///// <summary>
/// /////
/// </summary> ///// </summary>
void HideSharingMode() //void HideSharingMode()
{ //{
TriList.BooleanInput[UIBoolJoin.StagingPageVisible].BoolValue = false; // TriList.BooleanInput[UIBoolJoin.StagingPageVisible].BoolValue = false;
if (IsSharingModeAdvanced) // if (IsSharingModeAdvanced)
{ // {
if (DualDisplayUiDriver != null) // if (DualDisplayUiDriver != null)
DualDisplayUiDriver.Hide(); // DualDisplayUiDriver.Hide();
} // }
else // else
{ // {
TriList.BooleanInput[UIBoolJoin.SelectASourceVisible].BoolValue = false; // TriList.BooleanInput[UIBoolJoin.SelectASourceVisible].BoolValue = false;
} // }
} //}
/// <summary> ///// <summary>
/// /////
/// </summary> ///// </summary>
void RevealSharingMode() //void RevealSharingMode()
{ //{
TriList.BooleanInput[UIBoolJoin.StagingPageVisible].BoolValue = true; // TriList.BooleanInput[UIBoolJoin.StagingPageVisible].BoolValue = true;
if (IsSharingModeAdvanced) // if (IsSharingModeAdvanced)
{ // {
if(DualDisplayUiDriver == null) // if(DualDisplayUiDriver == null)
DualDisplayUiDriver = new DualDisplayRouting(TriList); // DualDisplayUiDriver = new DualDisplaySimpleOrAdvancedRouting(this);
DualDisplayUiDriver.Show(); // DualDisplayUiDriver.Show();
} // }
else // else
{ // {
TriList.BooleanInput[UIBoolJoin.SelectASourceVisible].BoolValue = true; // TriList.BooleanInput[UIBoolJoin.SelectASourceVisible].BoolValue = true;
} // }
} //}
/// <summary> /// <summary>
/// When the room is off, set the footer SRL /// When the room is off, set the footer SRL
@@ -352,7 +353,7 @@ namespace PepperDash.Essentials
ActivityFooterSrl.AddItem(new SubpageReferenceListActivityItem(2, ActivityFooterSrl, 1, ActivityFooterSrl.AddItem(new SubpageReferenceListActivityItem(2, ActivityFooterSrl, 1,
b => { })); b => { }));
ActivityFooterSrl.Count = 2; ActivityFooterSrl.Count = 2;
TriList.UShortInput[UIUshortJoin.PresentationListCaretMode].UShortValue = 0; TriList.UShortInput[UIUshortJoin.PresentationListCaretMode].UShortValue = 1;
} }
/// <summary> /// <summary>
@@ -368,7 +369,7 @@ namespace PepperDash.Essentials
ActivityFooterSrl.AddItem(new SubpageReferenceListActivityItem(3, ActivityFooterSrl, ActivityFooterSrl.AddItem(new SubpageReferenceListActivityItem(3, ActivityFooterSrl,
3, b => { if (!b) PowerButtonPressed(); })); 3, b => { if (!b) PowerButtonPressed(); }));
ActivityFooterSrl.Count = 3; ActivityFooterSrl.Count = 3;
TriList.UShortInput[UIUshortJoin.PresentationListCaretMode].UShortValue = 1; TriList.UShortInput[UIUshortJoin.PresentationListCaretMode].UShortValue = 2;
EndMeetingButtonSig = ActivityFooterSrl.BoolInputSig(2, 1); EndMeetingButtonSig = ActivityFooterSrl.BoolInputSig(2, 1);
} }
@@ -382,8 +383,9 @@ namespace PepperDash.Essentials
{ {
ShareButtonSig.BoolValue = true; ShareButtonSig.BoolValue = true;
TriList.BooleanInput[UIBoolJoin.StartPageVisible].BoolValue = false; TriList.BooleanInput[UIBoolJoin.StartPageVisible].BoolValue = false;
TriList.BooleanInput[UIBoolJoin.ToggleSharingModeVisible].BoolValue = true; DualDisplayUiDriver.Show();
RevealSharingMode(); //TriList.BooleanInput[UIBoolJoin.ToggleSharingModeVisible].BoolValue = true;
//RevealSharingMode();
} }
} }
@@ -408,7 +410,6 @@ namespace PepperDash.Essentials
CurrentInterlockedModalJoin = 0; CurrentInterlockedModalJoin = 0;
} }
/// <summary> /// <summary>
/// Shows all sigs that are in CurrentDisplayModeSigsInUse /// Shows all sigs that are in CurrentDisplayModeSigsInUse
/// </summary> /// </summary>
@@ -482,20 +483,20 @@ namespace PepperDash.Essentials
} }
} }
/// <summary> ///// <summary>
/// Called from button presses on source, where We can assume we want ///// Called from button presses on source, where We can assume we want
/// to change to the proper screen. ///// to change to the proper screen.
/// </summary> ///// </summary>
/// <param name="key">The key name of the route to run</param> ///// <param name="key">The key name of the route to run</param>
void UiSelectSource(SourceListItem sourceItem) //void UiSelectSource(SourceListItem sourceItem)
{ //{
if (IsSharingModeAdvanced) // if (IsSharingModeAdvanced)
{ // {
DualDisplayUiDriver.SourceListButtonPress(sourceItem); // DualDisplayUiDriver.SourceListButtonPress(sourceItem);
} // }
else // else
CurrentRoom.DoSourceToAllDestinationsRoute(sourceItem); // CurrentRoom.DoSourceToAllDestinationsRoute(sourceItem);
} //}
/// <summary> /// <summary>
/// ///
@@ -615,7 +616,8 @@ namespace PepperDash.Essentials
if (_CurrentRoom != null) if (_CurrentRoom != null)
{ {
SetupSourcesForSimpleRouting(); DualDisplayUiDriver.SetCurrentRoomFromParent();
//SetupSourcesForSimpleRouting();
TriList.StringInput[UIStringJoin.CurrentRoomName].StringValue = _CurrentRoom.Name; TriList.StringInput[UIStringJoin.CurrentRoomName].StringValue = _CurrentRoom.Name;
// Link up all the change events from the room // Link up all the change events from the room
@@ -646,43 +648,44 @@ namespace PepperDash.Essentials
} }
else else
{ {
DualDisplayUiDriver.Hide();
SetupActivityFooterWhenRoomOff(); SetupActivityFooterWhenRoomOff();
TriList.BooleanInput[UIBoolJoin.StartPageVisible].BoolValue = true; TriList.BooleanInput[UIBoolJoin.StartPageVisible].BoolValue = true;
} }
} }
void SetupSourcesForSimpleRouting() //void SetupSourcesForSimpleRouting()
{ //{
// get the source list config and set up the source list // // get the source list config and set up the source list
var config = ConfigReader.ConfigObject.SourceLists; // var config = ConfigReader.ConfigObject.SourceLists;
if (config.ContainsKey(_CurrentRoom.SourceListKey)) // if (config.ContainsKey(_CurrentRoom.SourceListKey))
{ // {
var srcList = config[_CurrentRoom.SourceListKey] // var srcList = config[_CurrentRoom.SourceListKey]
.Values.ToList().OrderBy(s => s.Order); // .Values.ToList().OrderBy(s => s.Order);
// Setup sources list // // Setup sources list
uint i = 1; // counter for UI list // uint i = 1; // counter for UI list
foreach (var srcConfig in srcList) // foreach (var srcConfig in srcList)
{ // {
if (!srcConfig.IncludeInSourceList) // Skip sources marked this way // if (!srcConfig.IncludeInSourceList) // Skip sources marked this way
continue; // continue;
var sourceKey = srcConfig.SourceKey; // var sourceKey = srcConfig.SourceKey;
var actualSource = DeviceManager.GetDeviceForKey(sourceKey) as Device; // var actualSource = DeviceManager.GetDeviceForKey(sourceKey) as Device;
if (actualSource == null) // if (actualSource == null)
{ // {
Debug.Console(0, "Cannot assign missing source '{0}' to source UI list", // Debug.Console(0, "Cannot assign missing source '{0}' to source UI list",
srcConfig.SourceKey); // srcConfig.SourceKey);
continue; // continue;
} // }
var localSrcConfig = srcConfig; // lambda scope below // var localSrcConfig = srcConfig; // lambda scope below
var item = new SubpageReferenceListSourceItem(i++, SourcesSrl, srcConfig, // var item = new SubpageReferenceListSourceItem(i++, SourcesSrl, srcConfig,
b => { if (!b) UiSelectSource(localSrcConfig); }); // b => { if (!b) UiSelectSource(localSrcConfig); });
SourcesSrl.AddItem(item); // add to the SRL // SourcesSrl.AddItem(item); // add to the SRL
item.RegisterForSourceChange(_CurrentRoom); // item.RegisterForSourceChange(_CurrentRoom);
} // }
SourcesSrl.Count = (ushort)(i - 1); // SourcesSrl.Count = (ushort)(i - 1);
} // }
} //}
/// <summary> /// <summary>
/// Hides source for provided source info /// Hides source for provided source info

View File

@@ -1,6 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
namespace PepperDash.Essentials namespace PepperDash.Essentials
@@ -100,7 +100,7 @@ namespace PepperDash.Essentials
{ {
} }
public PanelDriverBase(Crestron.SimplSharpPro.DeviceSupport.BasicTriListWithSmartObject triList) public PanelDriverBase(BasicTriListWithSmartObject triList)
{ {
TriList = triList; TriList = triList;
} }
@@ -128,7 +128,7 @@ namespace PepperDash.Essentials
/// <summary> /// <summary>
/// The trilist object for the Crestron TP device /// The trilist object for the Crestron TP device
/// </summary> /// </summary>
public Crestron.SimplSharpPro.DeviceSupport.BasicTriListWithSmartObject TriList { get; private set; } public BasicTriListWithSmartObject TriList { get; private set; }
/// <summary> /// <summary>
/// ///

View File

@@ -10,8 +10,8 @@
<ArchiveName /> <ArchiveName />
</RequiredInfo> </RequiredInfo>
<OptionalInfo> <OptionalInfo>
<CompiledOn>2/14/2017 11:24:21 AM</CompiledOn> <CompiledOn>2/15/2017 10:47:23 AM</CompiledOn>
<CompilerRev>1.0.0.20529</CompilerRev> <CompilerRev>1.0.0.19420</CompilerRev>
</OptionalInfo> </OptionalInfo>
<Plugin> <Plugin>
<Version>Crestron.SIMPLSharp, Version=2.0.48.0, Culture=neutral, PublicKeyToken=812d080f93e2de10</Version> <Version>Crestron.SIMPLSharp, Version=2.0.48.0, Culture=neutral, PublicKeyToken=812d080f93e2de10</Version>

View File

@@ -1,4 +1,4 @@
MainAssembly=PepperDashEssentials.dll:0ec9394c958b83119e9ba457828c9bd0 MainAssembly=PepperDashEssentials.dll:60c91f66dea9040efb0f42a2e016ea2d
MainAssemblyMinFirmwareVersion=1.009.0029 MainAssemblyMinFirmwareVersion=1.009.0029
MainAssemblyResource=SimplSharpData.dat:315526abf906cded47fb0c7510266a7e MainAssemblyResource=SimplSharpData.dat:315526abf906cded47fb0c7510266a7e
ü ü