Removes essentials-framework as a submodule and brings the files back into the main repo

This commit is contained in:
Neil Dorin
2019-07-09 17:21:53 -06:00
parent 2cd68d40dc
commit 48c6bb78bc
362 changed files with 54624 additions and 5 deletions

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
namespace PepperDash.Essentials.Core.SmartObjects
{
public class SmartObjectDPad : SmartObjectHelperBase
{
public BoolOutputSig SigUp { get { return GetBoolOutputNamed("Up"); } }
public BoolOutputSig SigDown { get { return GetBoolOutputNamed("Down"); } }
public BoolOutputSig SigLeft { get { return GetBoolOutputNamed("Left"); } }
public BoolOutputSig SigRight { get { return GetBoolOutputNamed("Right"); } }
public BoolOutputSig SigCenter { get { return GetBoolOutputNamed("Center"); } }
public SmartObjectDPad(SmartObject so, bool useUserObjectHandler)
: base(so, useUserObjectHandler)
{
}
}
}

View File

@@ -0,0 +1,128 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
namespace PepperDash.Essentials.Core.SmartObjects
{
public class SmartObjectDynamicList : SmartObjectHelperBase
{
public const string SigNameScrollToItem = "Scroll To Item";
public const string SigNameSetNumberOfItems = "Set Number of Items";
public uint NameSigOffset { get; private set; }
public ushort Count
{
get
{
return SmartObject.UShortInput[SigNameSetNumberOfItems].UShortValue;
}
set { SmartObject.UShortInput[SigNameSetNumberOfItems].UShortValue = value; }
}
/// <summary>
/// The limit of the list object, as defined by VTPro settings. Zero if object
/// is not a list
/// </summary>
public int MaxCount { get; private set; }
/// <summary>
/// Wrapper for smart object
/// </summary>
/// <param name="so"></param>
/// <param name="useUserObjectHandler">True if the standard user object action handler will be used</param>
/// <param name="nameSigOffset">The starting join of the string sigs for the button labels</param>
public SmartObjectDynamicList(SmartObject so, bool useUserObjectHandler, uint nameSigOffset) : base(so, useUserObjectHandler)
{
try
{
// Just try to touch the count signal to make sure this is indeed a dynamic list
var c = Count;
NameSigOffset = nameSigOffset;
MaxCount = SmartObject.BooleanOutput.Count(s => s.Name.EndsWith("Pressed"));
//Debug.Console(2, "Smart object {0} has {1} max", so.ID, MaxCount);
}
catch
{
var msg = string.Format("SmartObjectDynamicList: Smart Object {0:X2}-{1} is not a dynamic list. Ignoring", so.Device.ID, so.ID);
Debug.Console(0, Debug.ErrorLogLevel.Error, msg);
}
}
/// <summary>
/// Builds a new list item
/// </summary>
public void SetItem(uint index, string mainText, string iconName, Action<bool> action)
{
SetItemMainText(index, mainText);
SetItemIcon(index, iconName);
SetItemButtonAction(index, action);
//try
//{
// SetMainButtonText(index, text);
// SetIcon(index, iconName);
// SetButtonAction(index, action);
//}
//catch(Exception e)
//{
// Debug.Console(1, "Cannot set Dynamic List item {0} on smart object {1}", index, SmartObject.ID);
// ErrorLog.Warn(e.ToString());
//}
}
public void SetItemMainText(uint index, string text)
{
if (index > MaxCount) return;
// The list item template defines CIPS tags that refer to standard joins
(SmartObject.Device as BasicTriList).StringInput[NameSigOffset + index].StringValue = text;
}
public void SetItemIcon(uint index, string iconName)
{
if (index > MaxCount) return;
SmartObject.StringInput[string.Format("Set Item {0} Icon Serial", index)].StringValue = iconName;
}
public void SetItemButtonAction(uint index, Action<bool> action)
{
if (index > MaxCount) return;
SmartObject.BooleanOutput[string.Format("Item {0} Pressed", index)].UserObject = action;
}
/// <summary>
/// Sets the feedback on the given line, clearing others when interlocked is set
/// </summary>
public void SetFeedback(uint index, bool interlocked)
{
if (interlocked)
ClearFeedbacks();
SmartObject.BooleanInput[string.Format("Item {0} Selected", index)].BoolValue = true;
}
/// <summary>
/// Clears all button feedbacks
/// </summary>
public void ClearFeedbacks()
{
for(int i = 1; i<= Count; i++)
SmartObject.BooleanInput[string.Format("Item {0} Selected", i)].BoolValue = false;
}
/// <summary>
/// Removes Action object from all buttons
/// </summary>
public void ClearActions()
{
Debug.Console(2, "SO CLEAR");
for(ushort i = 1; i <= MaxCount; i++)
SmartObject.BooleanOutput[string.Format("Item {0} Pressed", i)].UserObject = null;
}
}
}

View File

@@ -0,0 +1,128 @@
using System;
using System.Linq;
using System.Collections.Generic;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
public class SmartObjectHelper
{
public static uint GetSmartObjectJoinForTypeAndObject(uint sourceType, uint typeOffset)
{
return (uint)(10000 + (sourceType * 100) + typeOffset);
}
//public static void DumpSmartObject(SmartGraphicsTouchpanelControllerBase tp, uint id)
//{
// if (!tp.TriList.SmartObjects.Contains(id))
// {
// Debug.Console(0, tp, "does not contain smart object ID {0}", id);
// return;
// }
// var so = tp.TriList.SmartObjects[id];
// Debug.Console(0, tp, "Signals for smart object ID {0}", id);
// Debug.Console(0, "BooleanInput -------------------------------");
// foreach (var s in so.BooleanInput)
// Debug.Console(0, " {0,5} {1}", s.Number, s.Name);
// Debug.Console(0, "UShortInput -------------------------------");
// foreach (var s in so.UShortInput)
// Debug.Console(0, " {0,5} {1}", s.Number, s.Name);
// Debug.Console(0, "StringInput -------------------------------");
// foreach (var s in so.StringInput)
// Debug.Console(0, " {0,5} {1}", s.Number, s.Name);
// Debug.Console(0, "BooleanOutput -------------------------------");
// foreach (var s in so.BooleanOutput)
// Debug.Console(0, " {0,5} {1}", s.Number, s.Name);
// Debug.Console(0, "UShortOutput -------------------------------");
// foreach (var s in so.UShortOutput)
// Debug.Console(0, " {0,5} {1}", s.Number, s.Name);
// Debug.Console(0, "StringOutput -------------------------------");
// foreach (var s in so.StringOutput)
// Debug.Console(0, " {0,5} {1}", s.Number, s.Name);
//}
///// <summary>
///// Inserts/removes the appropriate UO's onto sigs
///// </summary>
///// <param name="triList"></param>
///// <param name="smartObjectId"></param>
///// <param name="deviceUserObjects"></param>
///// <param name="state"></param>
//public static void LinkNumpadWithUserObjects(BasicTriListWithSmartObject triList,
// uint smartObjectId, List<CueActionPair> deviceUserObjects, Cue Misc_1Function, Cue Misc_2Function, bool state)
//{
// var sigDict = new Dictionary<string, Cue>
// {
// { "0", CommonBoolCue.Digit0 },
// { "1", CommonBoolCue.Digit1 },
// { "2", CommonBoolCue.Digit2 },
// { "3", CommonBoolCue.Digit3 },
// { "4", CommonBoolCue.Digit4 },
// { "5", CommonBoolCue.Digit5 },
// { "6", CommonBoolCue.Digit6 },
// { "7", CommonBoolCue.Digit7 },
// { "8", CommonBoolCue.Digit8 },
// { "9", CommonBoolCue.Digit9 },
// { "Misc_1", Misc_1Function },
// { "Misc_2", Misc_2Function },
// };
// LinkSmartObjectWithUserObjects(triList, smartObjectId, deviceUserObjects, sigDict, state);
//}
//public static void LinkDpadWithUserObjects(BasicTriListWithSmartObject triList,
// uint smartObjectId, List<CueActionPair> deviceUserObjects, bool state)
//{
// var sigDict = new Dictionary<string, Cue>
// {
// { "Up", CommonBoolCue.Up },
// { "Down", CommonBoolCue.Down },
// { "Left", CommonBoolCue.Left },
// { "Right", CommonBoolCue.Right },
// { "OK", CommonBoolCue.Select },
// };
// LinkSmartObjectWithUserObjects(triList, smartObjectId, deviceUserObjects, sigDict, state);
//}
///// <summary>
///// MOVE TO HELPER CLASS
///// </summary>
///// <param name="triList"></param>
///// <param name="smartObjectId"></param>
///// <param name="deviceUserObjects"></param>
///// <param name="smartObjectSigMap"></param>
///// <param name="state"></param>
//public static void LinkSmartObjectWithUserObjects(BasicTriListWithSmartObject triList,
// uint smartObjectId, List<CueActionPair> deviceUserObjects, Dictionary<string, Cue> smartObjectSigMap, bool state)
//{
// // Hook up smart objects if applicable
// if (triList.SmartObjects.Contains(smartObjectId))
// {
// var smartObject = triList.SmartObjects[smartObjectId];
// foreach (var kvp in smartObjectSigMap)
// {
// if (smartObject.BooleanOutput.Contains(kvp.Key))
// {
// if (state)
// {
// // look for a user object and if so, attach/detach it to/from the sig.
// var uo = deviceUserObjects.FirstOrDefault(ao => ao.Cue == kvp.Value);
// if (uo != null)
// smartObject.BooleanOutput[kvp.Key].UserObject = uo;
// }
// else
// smartObject.BooleanOutput[kvp.Key].UserObject = null;
// }
// else
// Debug.Console(0, "Smart object {0} does not contain Sig {1}", smartObject.ID, kvp.Key);
// }
// }
// else
// Debug.Console(0, "ERROR Smart object {0} not found on {1:X2}", smartObjectId, triList.ID);
//}
}
}

View File

@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
namespace PepperDash.Essentials.Core.SmartObjects
{
public class SmartObjectHelperBase
{
public SmartObject SmartObject { get; private set; }
/// <summary>
/// This should be set by all inheriting classes, after the class has verified that it is linked to the right object.
/// </summary>
public bool Validated { get; protected set; }
public SmartObjectHelperBase(SmartObject so, bool useUserObjectHandler)
{
SmartObject = so;
if (useUserObjectHandler)
{
// Prevent this from double-registering
SmartObject.SigChange -= this.SmartObject_SigChange;
SmartObject.SigChange += this.SmartObject_SigChange;
}
}
~SmartObjectHelperBase()
{
SmartObject.SigChange -= this.SmartObject_SigChange;
}
/// <summary>
/// Helper to get a sig name with debugging when fail
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public BoolOutputSig GetBoolOutputNamed(string name)
{
if (SmartObject.BooleanOutput.Contains(name))
return SmartObject.BooleanOutput[name];
else
Debug.Console(0, "WARNING: Cannot get signal. Smart object {0} on trilist {1:x2} does not contain signal '{2}'",
SmartObject.ID, SmartObject.Device.ID, name);
return null;
}
/// <summary>
/// Sets action on signal after checking for existence.
/// </summary>
/// <param name="name"></param>
/// <param name="a"></param>
public void SetBoolAction(string name, Action<bool> a)
{
if (SmartObject.BooleanOutput.Contains(name))
SmartObject.BooleanOutput[name].UserObject = a;
else
{
Debug.Console(0, "WARNING: Cannot set action. Smart object {0} on trilist {1:x2} does not contain signal '{2}'",
SmartObject.ID, SmartObject.Device.ID, name);
}
}
/// <summary>
/// Standard Action listener
/// </summary>
/// <param name="currentDevice"></param>
/// <param name="args"></param>
void SmartObject_SigChange(GenericBase currentDevice, SmartObjectEventArgs args)
{
var uo = args.Sig.UserObject;
if (uo is Action<bool>)
(uo as Action<bool>)(args.Sig.BoolValue);
else if (uo is Action<ushort>)
(uo as Action<ushort>)(args.Sig.UShortValue);
else if (uo is Action<string>)
(uo as Action<string>)(args.Sig.StringValue);
}
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
namespace PepperDash.Essentials.Core.SmartObjects
{
public class SmartObjectNumeric : SmartObjectHelperBase
{
/// <summary>
/// Defaults to "Misc_1". The name of the button in VTPro (Usually the text)
/// </summary>
public string Misc1SigName { get; set; }
/// <summary>
/// Defaults to "Misc_2". The name of the button in VTPro (Usually the text)
/// </summary>
public string Misc2SigName { get; set; }
public BoolOutputSig Digit1 { get { return GetBoolOutputNamed("1"); } }
public BoolOutputSig Digit2 { get { return GetBoolOutputNamed("2"); } }
public BoolOutputSig Digit3 { get { return GetBoolOutputNamed("3"); } }
public BoolOutputSig Digit4 { get { return GetBoolOutputNamed("4"); } }
public BoolOutputSig Digit5 { get { return GetBoolOutputNamed("5"); } }
public BoolOutputSig Digit6 { get { return GetBoolOutputNamed("6"); } }
public BoolOutputSig Digit7 { get { return GetBoolOutputNamed("7"); } }
public BoolOutputSig Digit8 { get { return GetBoolOutputNamed("8"); } }
public BoolOutputSig Digit9 { get { return GetBoolOutputNamed("9"); } }
public BoolOutputSig Digit0 { get { return GetBoolOutputNamed("0"); } }
public BoolOutputSig Misc1 { get { return GetBoolOutputNamed(Misc1SigName); } }
public BoolOutputSig Misc2 { get { return GetBoolOutputNamed(Misc2SigName); } }
public SmartObjectNumeric(SmartObject so, bool useUserObjectHandler) : base(so, useUserObjectHandler)
{
Misc1SigName = "Misc_1";
Misc2SigName = "Misc_2";
}
}
}

View File

@@ -0,0 +1,167 @@
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using Crestron.SimplSharp;
//using Crestron.SimplSharpPro;
//using Crestron.SimplSharpPro.DeviceSupport;
//using Crestron.SimplSharpPro.UI;
//using PepperDash.Core;
//namespace PepperDash.Essentials.Core
//{
// //*****************************************************************************
// /// <summary>
// /// Wrapper class for subpage reference list. Contains helpful methods to get at the various signal groupings
// /// and to get individual signals using an index and a join.
// /// </summary>
// public class SourceListSubpageReferenceList : SubpageReferenceList
// {
// public const uint SmartObjectJoin = 3801;
// Action<uint> SourceSelectCallback;
// EssentialsRoom CurrentRoom;
// public SourceListSubpageReferenceList(BasicTriListWithSmartObject tl,
// Action<uint> sourceSelectCallback)
// : base(tl, SmartObjectJoin, 3, 1, 3)
// {
// SourceSelectCallback = sourceSelectCallback;
// }
// void SetSourceList(Dictionary<uint, IPresentationSource> dict)
// {
// // Iterate all positions, including ones missing from the dict.
// var max = dict.Keys.Max();
// for (uint i = 1; i <= max; i++)
// {
// // Add the source if it's in the dict
// if (dict.ContainsKey(i))
// {
// Items.Add(new SourceListSubpageReferenceListItem(i, dict[i], this, SourceSelectCallback));
// // Plug the callback function into the buttons
// }
// // Blank the line
// else
// Items.Add(new SourceListSubpageReferenceListItem(i, null,
// this, SourceSelectCallback));
// }
// Count = (ushort)max;
// }
// /// <summary>
// /// Links the SRL to the Room's PresentationSourceChange event for updating of the UI
// /// </summary>
// /// <param name="room"></param>
// public void AttachToRoom(EssentialsRoom room)
// {
// CurrentRoom = room;
// SetSourceList(room.Sources);
// CurrentRoom.PresentationSourceChange -= CurrentRoom_PresentationSourceChange;
// CurrentRoom.PresentationSourceChange += CurrentRoom_PresentationSourceChange;
// SetPresentationSourceFb(CurrentRoom.CurrentPresentationSource);
// }
// /// <summary>
// /// Disconnects the SRL from a Room's PresentationSourceChange
// /// </summary>
// public void DetachFromCurrentRoom()
// {
// ClearPresentationSourceFb(CurrentRoom.CurrentPresentationSource);
// if(CurrentRoom != null)
// CurrentRoom.PresentationSourceChange -= CurrentRoom_PresentationSourceChange;
// CurrentRoom = null;
// }
// // Handler to route source changes into list feedback
// void CurrentRoom_PresentationSourceChange(object sender, EssentialsRoomSourceChangeEventArgs args)
// {
// Debug.Console(2, "SRL received source change");
// ClearPresentationSourceFb(args.OldSource);
// SetPresentationSourceFb(args.NewSource);
// }
// void ClearPresentationSourceFb(IPresentationSource source)
// {
// if (source == null) return;
// var oldSourceItem = (SourceListSubpageReferenceListItem)Items.FirstOrDefault(
// i => ((SourceListSubpageReferenceListItem)i).SourceDevice == source);
// if (oldSourceItem != null)
// oldSourceItem.ClearFeedback();
// }
// void SetPresentationSourceFb(IPresentationSource source)
// {
// if (source == null) return;
// // Now set the new source to light up
// var newSourceItem = (SourceListSubpageReferenceListItem)Items.FirstOrDefault(
// i => ((SourceListSubpageReferenceListItem)i).SourceDevice == source);
// if (newSourceItem != null)
// newSourceItem.SetFeedback();
// }
// }
// public class SourceListSubpageReferenceListItem : SubpageReferenceListItem
// {
// public readonly IPresentationSource SourceDevice;
// public const uint ButtonPressJoin = 1;
// public const uint SelectedFeedbackJoin = 2;
// public const uint ButtonTextJoin = 1;
// public const uint IconNameJoin = 2;
// public SourceListSubpageReferenceListItem(uint index,
// IPresentationSource srcDevice, SubpageReferenceList owner, Action<uint> sourceSelectCallback)
// : base(index, owner)
// {
// if (srcDevice == null) throw new ArgumentNullException("srcDevice");
// if (owner == null) throw new ArgumentNullException("owner");
// if (sourceSelectCallback == null) throw new ArgumentNullException("sourceSelectCallback");
// SourceDevice = srcDevice;
// var nameSig = owner.StringInputSig(index, ButtonTextJoin);
// // Should be able to see if there is not enough buttons right here
// if (nameSig == null)
// {
// Debug.Console(0, "ERROR: Item {0} does not exist on source list SRL", index);
// return;
// }
// nameSig.StringValue = srcDevice.Name;
// owner.StringInputSig(index, IconNameJoin).StringValue = srcDevice.IconName;
// // Assign a source selection action to the appropriate button's UserObject - on release
// owner.GetBoolFeedbackSig(index, ButtonPressJoin).UserObject = new Action<bool>(b =>
// { if (!b) sourceSelectCallback(index); });
// // hook up the video icon
// var videoDev = srcDevice as IAttachVideoStatus;
// if (videoDev != null)
// {
// var status = videoDev.GetVideoStatuses();
// if (status != null)
// {
// Debug.Console(1, "Linking {0} video status to SRL", videoDev.Key);
// videoDev.GetVideoStatuses().VideoSyncFeedback.LinkInputSig(owner.BoolInputSig(index, 3));
// }
// }
// }
// public void SetFeedback()
// {
// Owner.BoolInputSig(Index, SelectedFeedbackJoin).BoolValue = true;
// }
// public void ClearFeedback()
// {
// Owner.BoolInputSig(Index, SelectedFeedbackJoin).BoolValue = false;
// }
// }
//}

View File

@@ -0,0 +1,263 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.UI;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
////*****************************************************************************
///// <summary>
///// Base class for all subpage reference list controllers
///// </summary>
//public class SubpageReferenceListController
//{
// public SubpageReferenceList TheList { get; protected set; }
//}
//*****************************************************************************
/// <summary>
/// Wrapper class for subpage reference list. Contains helpful methods to get at the various signal groupings
/// and to get individual signals using an index and a join.
/// </summary>
public class SubpageReferenceList
{
public ushort Count
{
get { return SetNumberOfItemsSig.UShortValue; }
set { SetNumberOfItemsSig.UShortValue = value; }
}
public ushort MaxDefinedItems { get; private set; }
public UShortInputSig ScrollToItemSig { get; private set; }
UShortInputSig SetNumberOfItemsSig;
public uint BoolIncrement { get; protected set; }
public uint UShortIncrement { get; protected set; }
public uint StringIncrement { get; protected set; }
protected readonly SmartObject SRL;
protected readonly List<SubpageReferenceListItem> Items = new List<SubpageReferenceListItem>();
public SubpageReferenceList(BasicTriListWithSmartObject triList, uint smartObjectId,
uint boolIncrement, uint ushortIncrement, uint stringIncrement)
{
SmartObject obj;
// Fail cleanly if not defined
if (triList.SmartObjects == null || triList.SmartObjects.Count == 0)
{
Debug.Console(0, "TriList {0:X2} Smart objects have not been loaded", triList.ID, smartObjectId);
return;
}
if (triList.SmartObjects.TryGetValue(smartObjectId, out obj))
{
SRL = triList.SmartObjects[smartObjectId];
ScrollToItemSig = SRL.UShortInput["Scroll To Item"];
SetNumberOfItemsSig = SRL.UShortInput["Set Number of Items"];
BoolIncrement = boolIncrement;
UShortIncrement = ushortIncrement;
StringIncrement = stringIncrement;
// Count the enable lines to see what max items is
MaxDefinedItems = (ushort)SRL.BooleanInput
.Where(s => s.Name.Contains("Enable")).Count();
Debug.Console(2, "SRL {0} contains max {1} items", SRL.ID, MaxDefinedItems);
SRL.SigChange -= new SmartObjectSigChangeEventHandler(SRL_SigChange);
SRL.SigChange += new SmartObjectSigChangeEventHandler(SRL_SigChange);
}
else
Debug.Console(0, "ERROR: TriList 0x{0:X2} Cannot load smart object {1}. Verify correct SGD file is loaded",
triList.ID, smartObjectId);
}
/// <summary>
/// Adds item to saved list of displayed items (not necessarily in order)
/// DOES NOT adjust Count
/// </summary>
/// <param name="item"></param>
public void AddItem(SubpageReferenceListItem item)
{
Items.Add(item);
}
/// <summary>
/// Items need to be responsible for managing their own deallocation process,
/// disconnecting from events, etc.
///
/// </summary>
public void Clear()
{
// If a line item needs to disconnect an CueActionPair or do something to release RAM
foreach (var item in Items) item.Clear();
// Empty the list
Items.Clear();
// Clean up the SRL
Count = 0;
ScrollToItemSig.UShortValue = 1;
}
/// <summary>
/// Optional call to refresh the signals on the objects in the SRL - this calls Refresh() on
/// all SubpageReferenceListItem items
/// </summary>
public void Refresh()
{
foreach (var item in Items) item.Refresh();
}
// Helpers to get sigs by their weird SO names
/// <summary>
/// Returns the Sig associated with a given SRL line index
/// and the join number of the object on the SRL subpage.
/// Note: If the join number exceeds the increment range, or the count of Sigs on the
/// list object, this will return null
/// </summary>
/// <param name="index">The line or item position on the SRL</param>
/// <param name="sigNum">The join number of the item on the SRL subpage</param>
/// <returns>A Sig or null if the numbers are out of range</returns>
public BoolOutputSig GetBoolFeedbackSig(uint index, uint sigNum)
{
if (sigNum > BoolIncrement) return null;
return SRL.BooleanOutput.FirstOrDefault(s => s.Name.Equals(GetBoolFeedbackSigName(index, sigNum)));
}
/// <summary>
/// Returns the Sig associated with a given SRL line index
/// and the join number of the object on the SRL subpage.
/// Note: If the join number exceeds the increment range, or the count of Sigs on the
/// list object, this will return null
/// </summary>
/// <param name="index">The line or item position on the SRL</param>
/// <param name="sigNum">The join number of the item on the SRL subpage</param>
/// <returns>A Sig or null if the numbers are out of range</returns>
public UShortOutputSig GetUShortOutputSig(uint index, uint sigNum)
{
if (sigNum > UShortIncrement) return null;
return SRL.UShortOutput.FirstOrDefault(s => s.Name.Equals(GetBoolFeedbackSigName(index, sigNum)));
}
/// <summary>
/// Returns the Sig associated with a given SRL line index
/// and the join number of the object on the SRL subpage.
/// Note: If the join number exceeds the increment range, or the count of Sigs on the
/// list object, this will return null
/// </summary>
/// <param name="index">The line or item position on the SRL</param>
/// <param name="sigNum">The join number of the item on the SRL subpage</param>
/// <returns>A Sig or null if the numbers are out of range</returns>
public StringOutputSig GetStringOutputSig(uint index, uint sigNum)
{
if (sigNum > StringIncrement) return null;
return SRL.StringOutput.FirstOrDefault(s => s.Name.Equals(GetBoolFeedbackSigName(index, sigNum)));
}
/// <summary>
/// Returns the Sig associated with a given SRL line index
/// and the join number of the object on the SRL subpage.
/// Note: If the join number exceeds the increment range, or the count of Sigs on the
/// list object, this will return null
/// </summary>
/// <param name="index">The line on the SRL</param>
/// <param name="sigNum">The join number of the item on the SRL subpage</param>
/// <returns>A Sig or null if the numbers are out of range</returns>
public BoolInputSig BoolInputSig(uint index, uint sigNum)
{
if (sigNum > BoolIncrement) return null;
return SRL.BooleanInput.FirstOrDefault(s => s.Name.Equals(GetBoolInputSigName(index, sigNum)));
}
/// <summary>
/// Returns the Sig associated with a given SRL line index
/// and the join number of the object on the SRL subpage.
/// Note: If the join number exceeds the increment range, or the count of Sigs on the
/// list object, this will return null
/// </summary>
/// <param name="index">The line on the SRL</param>
/// <param name="sigNum">The join number of the item on the SRL subpage</param>
/// <returns>A Sig or null if the numbers are out of range</returns>
public UShortInputSig UShortInputSig(uint index, uint sigNum)
{
if (sigNum > UShortIncrement) return null;
return SRL.UShortInput.FirstOrDefault(s => s.Name.Equals(GetUShortInputSigName(index, sigNum)));
}
/// <summary>
/// Returns the Sig associated with a given SRL line index
/// and the join number of the object on the SRL subpage.
/// Note: If the join number exceeds the increment range, or the count of Sigs on the
/// list object, this will return null
/// </summary>
/// <param name="index">The line on the SRL</param>
/// <param name="sigNum">The join number of the item on the SRL subpage</param>
/// <returns>A Sig or null if the numbers are out of range</returns>
public StringInputSig StringInputSig(uint index, uint sigNum)
{
if (sigNum > StringIncrement) return null;
return SRL.StringInput.FirstOrDefault(s => s.Name.Equals(GetStringInputSigName(index, sigNum)));
}
// Helpers to get signal names
string GetBoolFeedbackSigName(uint index, uint sigNum)
{
var num = (index - 1) * BoolIncrement + sigNum;
return String.Format("press{0}", num);
}
string GetUShortOutputSigName(uint index, uint sigNum)
{
var num = (index - 1) * UShortIncrement + sigNum;
return String.Format("an_act{0}", num);
}
string GetStringOutputSigName(uint index, uint sigNum)
{
var num = (index - 1) * StringIncrement + sigNum;
return String.Format("text-i{0}", num);
}
string GetBoolInputSigName(uint index, uint sigNum)
{
var num = (index - 1) * BoolIncrement + sigNum;
return String.Format("fb{0}", num);
}
string GetUShortInputSigName(uint index, uint sigNum)
{
var num = (index - 1) * UShortIncrement + sigNum;
return String.Format("an_fb{0}", num);
}
string GetStringInputSigName(uint index, uint sigNum)
{
var num = (index - 1) * StringIncrement + sigNum;
return String.Format("text-o{0}", num);
}
/// <summary>
/// Stock SigChange handler
/// </summary>
/// <param name="currentDevice"></param>
/// <param name="args"></param>
public static void SRL_SigChange(GenericBase currentDevice, SmartObjectEventArgs args)
{
var uo = args.Sig.UserObject;
if (uo is Action<bool>)
(uo as Action<bool>)(args.Sig.BoolValue);
else if (uo is Action<ushort>)
(uo as Action<ushort>)(args.Sig.UShortValue);
else if (uo is Action<string>)
(uo as Action<string>)(args.Sig.StringValue);
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.UI;
namespace PepperDash.Essentials.Core
{
public class SubpageReferenceListItem
{
/// <summary>
/// The list that this lives in
/// </summary>
protected SubpageReferenceList Owner;
protected uint Index;
public SubpageReferenceListItem(uint index, SubpageReferenceList owner)
{
Index = index;
Owner = owner;
}
/// <summary>
/// Called by SRL to release all referenced objects
/// </summary>
public virtual void Clear()
{
}
public virtual void Refresh() { }
}
}