Updates to LutronQuantum.cs

This commit is contained in:
Neil Dorin
2018-04-05 17:08:42 -06:00
parent afa1cff0e0
commit 6d913e8a72
5 changed files with 485 additions and 284 deletions

View File

@@ -1,18 +1,18 @@
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronDataStore; using Crestron.SimplSharp.CrestronDataStore;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
//using PepperDash.Essentials.Core.Http; //using PepperDash.Essentials.Core.Http;
using PepperDash.Essentials.License; using PepperDash.Essentials.License;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
public static class Global public static class Global
{ {
public static CrestronControlSystem ControlSystem { get; set; } public static CrestronControlSystem ControlSystem { get; set; }
public static LicenseManager LicenseManager { get; set; } public static LicenseManager LicenseManager { get; set; }
public static string FilePathPrefix { get; private set; } public static string FilePathPrefix { get; private set; }
@@ -32,18 +32,18 @@ namespace PepperDash.Essentials.Core
public static void SetFilePathPrefix(string prefix) public static void SetFilePathPrefix(string prefix)
{ {
FilePathPrefix = prefix; FilePathPrefix = prefix;
} }
static Global() static Global()
{ {
// Fire up CrestronDataStoreStatic // Fire up CrestronDataStoreStatic
var err = CrestronDataStoreStatic.InitCrestronDataStore(); var err = CrestronDataStoreStatic.InitCrestronDataStore();
if (err != CrestronDataStore.CDS_ERROR.CDS_SUCCESS) if (err != CrestronDataStore.CDS_ERROR.CDS_SUCCESS)
{ {
CrestronConsole.PrintLine("Error starting CrestronDataStoreStatic: {0}", err); CrestronConsole.PrintLine("Error starting CrestronDataStoreStatic: {0}", err);
return; return;
} }
} }
} }
} }

View File

@@ -11,10 +11,9 @@ namespace PepperDash.Essentials.Core.Lighting
{ {
public abstract class LightingBase : Device, ILightingScenes public abstract class LightingBase : Device, ILightingScenes
{ {
#region ILightingScenes Members #region ILightingScenes Members
event EventHandler<LightingSceneChangeEventArgs> ILightingScenes.LightingSceneChange public event EventHandler<LightingSceneChangeEventArgs> LightingSceneChange
{ {
add { throw new NotImplementedException(); } add { throw new NotImplementedException(); }
remove { throw new NotImplementedException(); } remove { throw new NotImplementedException(); }
@@ -27,8 +26,8 @@ namespace PepperDash.Essentials.Core.Lighting
#endregion #endregion
public LightingBase(string key, string name) : public LightingBase(string key, string name)
base(key, name) : base(key, name)
{ {
LightingScenes = new List<LightingScene>(); LightingScenes = new List<LightingScene>();
} }
@@ -41,5 +40,6 @@ namespace PepperDash.Essentials.Core.Lighting
public class LightingScene public class LightingScene
{ {
public string Name { get; set; } public string Name { get; set; }
public object ID { get; set; }
} }
} }

View File

@@ -0,0 +1,200 @@
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.Lighting;
namespace PepperDash.Essentials.Devices.Common.Environment.Lutron
{
public class LutronQuantumArea : LightingBase, ILightingMasterRaiseLower, ICommunicationMonitor
{
public IBasicCommunication Communication { get; private set; }
public CommunicationGather PortGather { get; private set; }
public StatusMonitorBase CommunicationMonitor { get; private set; }
public int IntegrationId;
public string Password;
const string Delimiter = "\x0d\x0a";
const string Set = "#";
const string Get = "?";
public LutronQuantumArea(string key, string name, IBasicCommunication comm, LutronQuantumPropertiesConfig props)
: base(key, name)
{
Communication = comm;
IntegrationId = props.IntegrationId;
Password = props.Password;
LightingScenes = props.Scenes;
var socket = comm as ISocketStatus;
if (socket != null)
{
// IP Control
socket.ConnectionChange += new EventHandler<GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
}
else
{
// RS-232 Control
}
PortGather = new CommunicationGather(Communication, Delimiter);
PortGather.LineReceived += new EventHandler<GenericCommMethodReceiveTextArgs>(PortGather_LineReceived);
if (props.CommunicationMonitorProperties != null)
{
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, props.CommunicationMonitorProperties);
}
else
{
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 120000, 120000, 300000, "?SYSTEM,1\x0d\x0a");
}
}
public override bool CustomActivate()
{
Communication.Connect();
CommunicationMonitor.StatusChange += (o, a) => { Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); };
CommunicationMonitor.Start();
return true;
}
void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
{
Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString());
if (e.Client.IsConnected)
{
// Tasks on connect
}
}
void PortGather_LineReceived(object sender, GenericCommMethodReceiveTextArgs args)
{
try
{
if (args.Text.IndexOf("login:") > -1)
{
// Login
SendLine(Password);
}
else if (args.Text.IndexOf("~AREA") > -1)
{
var response = args.Text.Split(',');
var integrationId = Int32.Parse(response[1]);
if (integrationId != IntegrationId)
{
Debug.Console(2, this, "Response is not for correct Integration ID");
return;
}
else
{
var action = Int32.Parse(response[2]);
switch (action)
{
case (int)eAction.Scene:
{
var scene = Int32.Parse(response[3]);
CurrentLightingScene = LightingScenes.FirstOrDefault(s => s.ID.Equals(scene));
var handler = LightingSceneChange;
if (handler != null)
{
handler(this, new LightingSceneChangeEventArgs(CurrentLightingScene));
}
break;
}
default:
break;
}
}
}
}
catch (Exception e)
{
Debug.Console(2, this, "Error parsing response:\n{0}", e);
}
}
/// <summary>
/// Recalls the specified scene
/// </summary>
/// <param name="scene"></param>
public void SelectScene(LightingScene scene)
{
SendLine(string.Format("{0}AREA,{1},{2},{3}", Set, IntegrationId, (int)eAction.Scene, (int)scene.ID));
}
/// <summary>
/// Begins raising the lights in the area
/// </summary>
public void MasterRaise()
{
SendLine(string.Format("{0}AREA,{1},{2}", Set, IntegrationId, (int)eAction.Raise));
}
/// <summary>
/// Begins lowering the lights in the area
/// </summary>
public void MasterLower()
{
SendLine(string.Format("{0}AREA,{1},{2}", Set, IntegrationId, (int)eAction.Lower));
}
/// <summary>
/// Stops the current raise/lower action
/// </summary>
public void MasterRaiseLowerStop()
{
SendLine(string.Format("{0}AREA,{1},{2}", Set, IntegrationId, (int)eAction.Stop));
}
/// <summary>
/// Appends the delimiter and sends the string
/// </summary>
/// <param name="s"></param>
public void SendLine(string s)
{
Debug.Console(1, this, "TX: '{0}'", s);
Communication.SendText(s + Delimiter);
}
}
public enum eAction
{
SetLevel = 1,
Raise = 2,
Lower = 3,
Stop = 4,
Scene = 6,
DaylightMode = 7,
OccupancyState = 8,
OccupancyMode = 9,
OccupiedLevelOrScene = 12,
UnoccupiedLevelOrScene = 13,
HyperionShaddowSensorOverrideState = 26,
HyperionBrightnessSensorOverrideStatue = 27
}
public class LutronQuantumPropertiesConfig
{
public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; }
public ControlPropertiesConfig Control { get; set; }
public int IntegrationId { get; set; }
public List<LightingScene> Scenes{ get; set; }
public string Password { get; set; }
}
}

View File

@@ -118,6 +118,7 @@
<Compile Include="DSP\BiampTesira\BiampTesiraForteDsp.cs" /> <Compile Include="DSP\BiampTesira\BiampTesiraForteDsp.cs" />
<Compile Include="DSP\BiampTesira\BiampTesiraFortePropertiesConfig.cs" /> <Compile Include="DSP\BiampTesira\BiampTesiraFortePropertiesConfig.cs" />
<Compile Include="DSP\PolycomSoundStructure\SoundStructureBasics.cs" /> <Compile Include="DSP\PolycomSoundStructure\SoundStructureBasics.cs" />
<Compile Include="Environment\Lutron\LutronQuantum.cs" />
<Compile Include="Factory\DeviceFactory.cs" /> <Compile Include="Factory\DeviceFactory.cs" />
<Compile Include="Generic\GenericSource.cs" /> <Compile Include="Generic\GenericSource.cs" />
<Compile Include="Microphone\MicrophonePrivacyController.cs" /> <Compile Include="Microphone\MicrophonePrivacyController.cs" />

View File

@@ -1,260 +1,260 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.UI; using Crestron.SimplSharpPro.UI;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.PageManagers; using PepperDash.Essentials.Core.PageManagers;
namespace PepperDash.Essentials namespace PepperDash.Essentials
{ {
public class EssentialsTouchpanelController : Device public class EssentialsTouchpanelController : Device
{ {
public BasicTriListWithSmartObject Panel { get; private set; } public BasicTriListWithSmartObject Panel { get; private set; }
public PanelDriverBase PanelDriver { get; private set; } public PanelDriverBase PanelDriver { get; private set; }
CTimer BacklightTransitionedOnTimer; CTimer BacklightTransitionedOnTimer;
public EssentialsTouchpanelController(string key, string name, Tswx52ButtonVoiceControl tsw, public EssentialsTouchpanelController(string key, string name, Tswx52ButtonVoiceControl tsw,
string projectName, string sgdPath) string projectName, string sgdPath)
: base(key, name) : base(key, name)
{ {
Panel = tsw; Panel = tsw;
tsw.LoadSmartObjects(sgdPath); tsw.LoadSmartObjects(sgdPath);
tsw.SigChange += new Crestron.SimplSharpPro.DeviceSupport.SigEventHandler(Tsw_SigChange); tsw.SigChange += new Crestron.SimplSharpPro.DeviceSupport.SigEventHandler(Tsw_SigChange);
} }
/// <summary> /// <summary>
/// Config constructor /// Config constructor
/// </summary> /// </summary>
public EssentialsTouchpanelController(string key, string name, string type, CrestronTouchpanelPropertiesConfig props, uint id) public EssentialsTouchpanelController(string key, string name, string type, CrestronTouchpanelPropertiesConfig props, uint id)
: base(key, name) : base(key, name)
{ {
AddPostActivationAction(() => AddPostActivationAction(() =>
{ {
#warning Temporary Error logging for XiO Edge Debugging #warning Temporary Error logging for XiO Edge Debugging
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Creating touchpanel hardware..."); Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Creating touchpanel hardware...");
type = type.ToLower(); type = type.ToLower();
try try
{ {
if (type == "crestronapp") if (type == "crestronapp")
{ {
var app = new CrestronApp(id, Global.ControlSystem); var app = new CrestronApp(id, Global.ControlSystem);
app.ParameterProjectName.Value = props.ProjectName; app.ParameterProjectName.Value = props.ProjectName;
Panel = app; Panel = app;
} }
else if (type == "tsw550") else if (type == "tsw550")
Panel = new Tsw550(id, Global.ControlSystem); Panel = new Tsw550(id, Global.ControlSystem);
else if (type == "tsw552") else if (type == "tsw552")
Panel = new Tsw552(id, Global.ControlSystem); Panel = new Tsw552(id, Global.ControlSystem);
else if (type == "tsw560") else if (type == "tsw560")
Panel = new Tsw560(id, Global.ControlSystem); Panel = new Tsw560(id, Global.ControlSystem);
else if (type == "tsw750") else if (type == "tsw750")
Panel = new Tsw750(id, Global.ControlSystem); Panel = new Tsw750(id, Global.ControlSystem);
else if (type == "tsw752") else if (type == "tsw752")
Panel = new Tsw752(id, Global.ControlSystem); Panel = new Tsw752(id, Global.ControlSystem);
else if (type == "tsw760") else if (type == "tsw760")
Panel = new Tsw760(id, Global.ControlSystem); Panel = new Tsw760(id, Global.ControlSystem);
else if (type == "tsw1050") else if (type == "tsw1050")
Panel = new Tsw1050(id, Global.ControlSystem); Panel = new Tsw1050(id, Global.ControlSystem);
else if (type == "tsw1052") else if (type == "tsw1052")
Panel = new Tsw1052(id, Global.ControlSystem); Panel = new Tsw1052(id, Global.ControlSystem);
else if (type == "tsw1060") else if (type == "tsw1060")
Panel = new Tsw1060(id, Global.ControlSystem); Panel = new Tsw1060(id, Global.ControlSystem);
else else
{ {
#warning Temporary Error logging for XiO Edge Debugging #warning Temporary Error logging for XiO Edge Debugging
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create TSW controller with type '{0}'", type); Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create TSW controller with type '{0}'", type);
return; return;
} }
} }
catch (Exception e) catch (Exception e)
{ {
#warning Temporary Error logging for XiO Edge Debugging #warning Temporary Error logging for XiO Edge Debugging
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create TSW base class. Panel will not function: {0}", e.Message); Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create TSW base class. Panel will not function: {0}", e.Message);
return; return;
} }
// Reserved sigs // Reserved sigs
if (Panel is TswFt5ButtonSystem) if (Panel is TswFt5ButtonSystem)
{ {
var tsw = Panel as TswFt5ButtonSystem; var tsw = Panel as TswFt5ButtonSystem;
tsw.ExtenderSystemReservedSigs.Use(); tsw.ExtenderSystemReservedSigs.Use();
tsw.ExtenderSystemReservedSigs.DeviceExtenderSigChange tsw.ExtenderSystemReservedSigs.DeviceExtenderSigChange
+= ExtenderSystemReservedSigs_DeviceExtenderSigChange; += ExtenderSystemReservedSigs_DeviceExtenderSigChange;
} }
//CrestronInvoke.BeginInvoke(o => //CrestronInvoke.BeginInvoke(o =>
// { // {
var regSuccess = Panel.Register(); var regSuccess = Panel.Register();
#warning Temporary Error logging for XiO Edge Debugging #warning Temporary Error logging for XiO Edge Debugging
if (regSuccess != eDeviceRegistrationUnRegistrationResponse.Success) if (regSuccess != eDeviceRegistrationUnRegistrationResponse.Success)
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "WARNING: Registration failed. Continuing, but panel may not function: {0}", regSuccess); Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "WARNING: Registration failed. Continuing, but panel may not function: {0}", regSuccess);
// Give up cleanly if SGD is not present. // Give up cleanly if SGD is not present.
var sgdName = Global.FilePathPrefix var sgdName = Global.FilePathPrefix
+ Global.DirectorySeparator + "sgd" + Global.DirectorySeparator + props.SgdFile; + Global.DirectorySeparator + "sgd" + Global.DirectorySeparator + props.SgdFile;
if (!File.Exists(sgdName)) if (!File.Exists(sgdName))
{ {
Debug.Console(0, this, "ERROR: Smart object file '{0}' not present. Exiting TSW load", sgdName); Debug.Console(0, this, "ERROR: Smart object file '{0}' not present. Exiting TSW load", sgdName);
return; return;
} }
Panel.LoadSmartObjects(sgdName); Panel.LoadSmartObjects(sgdName);
Panel.SigChange += Tsw_SigChange; Panel.SigChange += Tsw_SigChange;
var mainDriver = new EssentialsPanelMainInterfaceDriver(Panel, props); var mainDriver = new EssentialsPanelMainInterfaceDriver(Panel, props);
// Then the AV driver // Then the AV driver
// spin up different room drivers depending on room type // spin up different room drivers depending on room type
var room = DeviceManager.GetDeviceForKey(props.DefaultRoomKey); var room = DeviceManager.GetDeviceForKey(props.DefaultRoomKey);
if (room is EssentialsHuddleSpaceRoom) if (room is EssentialsHuddleSpaceRoom)
{ {
Debug.Console(0, this, "Adding huddle space driver"); Debug.Console(0, this, "Adding huddle space driver");
var avDriver = new EssentialsHuddlePanelAvFunctionsDriver(mainDriver, props); var avDriver = new EssentialsHuddlePanelAvFunctionsDriver(mainDriver, props);
avDriver.CurrentRoom = room as EssentialsHuddleSpaceRoom; avDriver.CurrentRoom = room as EssentialsHuddleSpaceRoom;
avDriver.DefaultRoomKey = props.DefaultRoomKey; avDriver.DefaultRoomKey = props.DefaultRoomKey;
mainDriver.AvDriver = avDriver; mainDriver.AvDriver = avDriver;
LoadAndShowDriver(mainDriver); // This is a little convoluted. LoadAndShowDriver(mainDriver); // This is a little convoluted.
if (Panel is TswFt5ButtonSystem) if (Panel is TswFt5ButtonSystem)
{ {
var tsw = Panel as TswFt5ButtonSystem; var tsw = Panel as TswFt5ButtonSystem;
// Wire up hard keys // Wire up hard keys
tsw.Power.UserObject = new Action<bool>(b => { if (!b) avDriver.PowerButtonPressed(); }); tsw.Power.UserObject = new Action<bool>(b => { if (!b) avDriver.PowerButtonPressed(); });
//tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); }); //tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); });
tsw.Up.UserObject = new Action<bool>(avDriver.VolumeUpPress); tsw.Up.UserObject = new Action<bool>(avDriver.VolumeUpPress);
tsw.Down.UserObject = new Action<bool>(avDriver.VolumeDownPress); tsw.Down.UserObject = new Action<bool>(avDriver.VolumeDownPress);
tsw.ButtonStateChange += new ButtonEventHandler(Tsw_ButtonStateChange); tsw.ButtonStateChange += new ButtonEventHandler(Tsw_ButtonStateChange);
} }
} }
else if (room is EssentialsPresentationRoom) else if (room is EssentialsPresentationRoom)
{ {
Debug.Console(0, this, "Adding presentation room driver"); Debug.Console(0, this, "Adding presentation room driver");
var avDriver = new EssentialsPresentationPanelAvFunctionsDriver(mainDriver, props); var avDriver = new EssentialsPresentationPanelAvFunctionsDriver(mainDriver, props);
avDriver.CurrentRoom = room as EssentialsPresentationRoom; avDriver.CurrentRoom = room as EssentialsPresentationRoom;
avDriver.DefaultRoomKey = props.DefaultRoomKey; avDriver.DefaultRoomKey = props.DefaultRoomKey;
mainDriver.AvDriver = avDriver; mainDriver.AvDriver = avDriver;
LoadAndShowDriver(mainDriver); LoadAndShowDriver(mainDriver);
if (Panel is TswFt5ButtonSystem) if (Panel is TswFt5ButtonSystem)
{ {
var tsw = Panel as TswFt5ButtonSystem; var tsw = Panel as TswFt5ButtonSystem;
// Wire up hard keys // Wire up hard keys
tsw.Power.UserObject = new Action<bool>(b => { if (!b) avDriver.PowerButtonPressed(); }); tsw.Power.UserObject = new Action<bool>(b => { if (!b) avDriver.PowerButtonPressed(); });
//tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); }); //tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); });
tsw.Up.UserObject = new Action<bool>(avDriver.VolumeUpPress); tsw.Up.UserObject = new Action<bool>(avDriver.VolumeUpPress);
tsw.Down.UserObject = new Action<bool>(avDriver.VolumeDownPress); tsw.Down.UserObject = new Action<bool>(avDriver.VolumeDownPress);
tsw.ButtonStateChange += new ButtonEventHandler(Tsw_ButtonStateChange); tsw.ButtonStateChange += new ButtonEventHandler(Tsw_ButtonStateChange);
} }
} }
else if (room is EssentialsHuddleVtc1Room) else if (room is EssentialsHuddleVtc1Room)
{ {
Debug.Console(0, this, "Adding huddle space driver"); Debug.Console(0, this, "Adding huddle space driver");
var avDriver = new EssentialsHuddleVtc1PanelAvFunctionsDriver(mainDriver, props); var avDriver = new EssentialsHuddleVtc1PanelAvFunctionsDriver(mainDriver, props);
var codecDriver = new PepperDash.Essentials.UIDrivers.VC.EssentialsVideoCodecUiDriver(Panel, avDriver, var codecDriver = new PepperDash.Essentials.UIDrivers.VC.EssentialsVideoCodecUiDriver(Panel, avDriver,
(room as EssentialsHuddleVtc1Room).VideoCodec); (room as EssentialsHuddleVtc1Room).VideoCodec);
avDriver.SetVideoCodecDriver(codecDriver); avDriver.SetVideoCodecDriver(codecDriver);
avDriver.CurrentRoom = room as EssentialsHuddleVtc1Room; avDriver.CurrentRoom = room as EssentialsHuddleVtc1Room;
avDriver.DefaultRoomKey = props.DefaultRoomKey; avDriver.DefaultRoomKey = props.DefaultRoomKey;
mainDriver.AvDriver = avDriver; mainDriver.AvDriver = avDriver;
LoadAndShowDriver(mainDriver); // This is a little convoluted. LoadAndShowDriver(mainDriver); // This is a little convoluted.
if (Panel is TswFt5ButtonSystem) if (Panel is TswFt5ButtonSystem)
{ {
var tsw = Panel as TswFt5ButtonSystem; var tsw = Panel as TswFt5ButtonSystem;
// Wire up hard keys // Wire up hard keys
tsw.Power.UserObject = new Action<bool>(b => { if (!b) avDriver.EndMeetingPress(); }); tsw.Power.UserObject = new Action<bool>(b => { if (!b) avDriver.EndMeetingPress(); });
//tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); }); //tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); });
tsw.Up.UserObject = new Action<bool>(avDriver.VolumeUpPress); tsw.Up.UserObject = new Action<bool>(avDriver.VolumeUpPress);
tsw.Down.UserObject = new Action<bool>(avDriver.VolumeDownPress); tsw.Down.UserObject = new Action<bool>(avDriver.VolumeDownPress);
tsw.ButtonStateChange += new ButtonEventHandler(Tsw_ButtonStateChange); tsw.ButtonStateChange += new ButtonEventHandler(Tsw_ButtonStateChange);
} }
} }
else else
{ {
Debug.Console(0, this, "ERROR: Cannot load AvFunctionsDriver for room '{0}'", props.DefaultRoomKey); Debug.Console(0, this, "ERROR: Cannot load AvFunctionsDriver for room '{0}'", props.DefaultRoomKey);
} }
//}, 0); //}, 0);
}); });
} }
public void LoadAndShowDriver(PanelDriverBase driver) public void LoadAndShowDriver(PanelDriverBase driver)
{ {
PanelDriver = driver; PanelDriver = driver;
driver.Show(); driver.Show();
} }
void HomePressed() void HomePressed()
{ {
if (BacklightTransitionedOnTimer == null) if (BacklightTransitionedOnTimer == null)
PanelDriver.BackButtonPressed(); PanelDriver.BackButtonPressed();
} }
void ExtenderSystemReservedSigs_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args) void ExtenderSystemReservedSigs_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender, SigEventArgs args)
{ {
// If the sig is transitioning on, mark it in case it was home button that transitioned it // If the sig is transitioning on, mark it in case it was home button that transitioned it
var blOnSig = (Panel as TswFt5ButtonSystem).ExtenderSystemReservedSigs.BacklightOnFeedback; var blOnSig = (Panel as TswFt5ButtonSystem).ExtenderSystemReservedSigs.BacklightOnFeedback;
if (args.Sig == blOnSig && blOnSig.BoolValue) if (args.Sig == blOnSig && blOnSig.BoolValue)
{ {
BacklightTransitionedOnTimer = new CTimer(o => BacklightTransitionedOnTimer = new CTimer(o =>
{ {
BacklightTransitionedOnTimer = null; BacklightTransitionedOnTimer = null;
}, 200); }, 200);
} }
} }
public void PulseBool(uint join) public void PulseBool(uint join)
{ {
var act = Panel.BooleanInput[join].UserObject as Action<bool>; var act = Panel.BooleanInput[join].UserObject as Action<bool>;
if (act != null) if (act != null)
{ {
act(true); act(true);
act(false); act(false);
} }
} }
public void SetBoolSig(uint join, bool value) public void SetBoolSig(uint join, bool value)
{ {
var act = Panel.BooleanInput[join].UserObject as Action<bool>; var act = Panel.BooleanInput[join].UserObject as Action<bool>;
if (act != null) if (act != null)
act(value); act(value);
} }
public void SetIntSig(uint join, ushort value) public void SetIntSig(uint join, ushort value)
{ {
var act = Panel.BooleanInput[join].UserObject as Action<ushort>; var act = Panel.BooleanInput[join].UserObject as Action<ushort>;
if (act != null) if (act != null)
{ {
act(value); act(value);
} }
} }
void Tsw_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args) void Tsw_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args)
{ {
if (Debug.Level == 2) if (Debug.Level == 2)
Debug.Console(2, this, "Sig change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); Debug.Console(2, this, "Sig change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
var uo = args.Sig.UserObject; var uo = args.Sig.UserObject;
if (uo is Action<bool>) if (uo is Action<bool>)
(uo as Action<bool>)(args.Sig.BoolValue); (uo as Action<bool>)(args.Sig.BoolValue);
else if (uo is Action<ushort>) else if (uo is Action<ushort>)
(uo as Action<ushort>)(args.Sig.UShortValue); (uo as Action<ushort>)(args.Sig.UShortValue);
else if (uo is Action<string>) else if (uo is Action<string>)
(uo as Action<string>)(args.Sig.StringValue); (uo as Action<string>)(args.Sig.StringValue);
} }
void Tsw_ButtonStateChange(GenericBase device, ButtonEventArgs args) void Tsw_ButtonStateChange(GenericBase device, ButtonEventArgs args)
{ {
var uo = args.Button.UserObject; var uo = args.Button.UserObject;
if(uo is Action<bool>) if(uo is Action<bool>)
(uo as Action<bool>)(args.Button.State == eButtonState.Pressed); (uo as Action<bool>)(args.Button.State == eButtonState.Pressed);
} }
} }
} }