Merge branch 'development' of http://code.pepperdash.net/scm/pec/essentials into development

This commit is contained in:
Heath Volmer
2018-06-15 14:11:17 -06:00
6 changed files with 351 additions and 202 deletions

View File

@@ -59,7 +59,7 @@ namespace PepperDash.Essentials
"Template URL: {1}", ConfigReader.ConfigObject.SystemUrl, ConfigReader.ConfigObject.TemplateUrl); "Template URL: {1}", ConfigReader.ConfigObject.SystemUrl, ConfigReader.ConfigObject.TemplateUrl);
}, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator); }, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator);
GoWithLoad(); //GoWithLoad();
} }
/// <summary> /// <summary>

View File

@@ -1005,6 +1005,10 @@ namespace PepperDash.Essentials.Fusion
/// </summary> /// </summary>
void SetUpCommunitcationMonitors() void SetUpCommunitcationMonitors()
{ {
uint displayNum = 0;
uint touchpanelNum = 0;
uint xpanelNum = 0;
// Attach to all room's devices with monitors. // Attach to all room's devices with monitors.
//foreach (var dev in DeviceManager.Devices) //foreach (var dev in DeviceManager.Devices)
foreach (var dev in DeviceManager.GetDevices()) foreach (var dev in DeviceManager.GetDevices())
@@ -1012,41 +1016,56 @@ namespace PepperDash.Essentials.Fusion
if (!(dev is ICommunicationMonitor)) if (!(dev is ICommunicationMonitor))
continue; continue;
var keyNum = ExtractNumberFromKey(dev.Key); string attrName = null;
if (keyNum == -1) uint attrNum = 1;
{
Debug.Console(1, this, "WARNING: Cannot link device '{0}' to numbered Fusion monitoring attributes",
dev.Key);
continue;
}
string attrName = null;
uint attrNum = Convert.ToUInt32(keyNum);
if (dev is EssentialsTouchpanelController) //var keyNum = ExtractNumberFromKey(dev.Key);
//if (keyNum == -1)
//{
// Debug.Console(1, this, "WARNING: Cannot link device '{0}' to numbered Fusion monitoring attributes",
// dev.Key);
// continue;
//}
//uint attrNum = Convert.ToUInt32(keyNum);
// Check for UI devices
var uiDev = dev as EssentialsTouchpanelController;
if (uiDev != null)
{ {
if ((dev as EssentialsTouchpanelController).Panel is Crestron.SimplSharpPro.DeviceSupport.TswFt5Button) if (uiDev.Panel is Crestron.SimplSharpPro.UI.XpanelForSmartGraphics)
{
if (attrNum > 10)
continue;
attrName = "Online - Touch Panel " + attrNum;
attrNum += 150;
}
else if ((dev as EssentialsTouchpanelController).Panel is Crestron.SimplSharpPro.UI.XpanelForSmartGraphics)
{ {
attrNum = attrNum + touchpanelNum;
if (attrNum > 10) if (attrNum > 10)
continue; continue;
attrName = "Online - XPanel " + attrNum; attrName = "Online - XPanel " + attrNum;
attrNum += 160; attrNum += 160;
touchpanelNum++;
} }
} else
{
attrNum = attrNum + xpanelNum;
if (attrNum > 10)
continue;
attrName = "Online - Touch Panel " + attrNum;
attrNum += 150;
xpanelNum++;
}
}
//else //else
if (dev is DisplayBase) if (dev is DisplayBase)
{ {
attrNum = attrNum + displayNum;
if (attrNum > 10) if (attrNum > 10)
continue; continue;
attrName = "Online - Display " + attrNum; attrName = "Online - Display " + attrNum;
attrNum += 170; attrNum += 170;
displayNum++;
} }
//else if (dev is DvdDeviceBase) //else if (dev is DvdDeviceBase)
//{ //{
@@ -1265,7 +1284,7 @@ namespace PepperDash.Essentials.Fusion
/// <returns>-1 if no number matched</returns> /// <returns>-1 if no number matched</returns>
int ExtractNumberFromKey(string key) int ExtractNumberFromKey(string key)
{ {
var capture = System.Text.RegularExpressions.Regex.Match(key, @"\D+(\d+)"); var capture = System.Text.RegularExpressions.Regex.Match(key, @"\b(\d+)");
if (!capture.Success) if (!capture.Success)
return -1; return -1;
else return Convert.ToInt32(capture.Groups[1].Value); else return Convert.ToInt32(capture.Groups[1].Value);

View File

@@ -12,7 +12,9 @@
public bool ShowDate { get; set; } public bool ShowDate { get; set; }
public bool ShowTime { get; set; } public bool ShowTime { get; set; }
public UiSetupPropertiesConfig Setup { get; set; } public UiSetupPropertiesConfig Setup { get; set; }
public string HeaderStyle { get; set; } public string HeaderStyle { get; set; }
public bool IncludeInFusionRoomHealth { get; set; }
/// <summary> /// <summary>
/// The count of sources that will trigger the "additional" arrows to show on the SRL. /// The count of sources that will trigger the "additional" arrows to show on the SRL.

View File

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