mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-27 11:24:55 +00:00
Fixed share button sync issues around power off dialogs
This commit is contained in:
@@ -138,6 +138,7 @@
|
||||
<Compile Include="Devices\IVolumeAndAudioInterfaces.cs" />
|
||||
<Compile Include="Display\BasicIrDisplay.cs" />
|
||||
<Compile Include="Feedbacks\BoolFeedbackOneShot.cs" />
|
||||
<Compile Include="Ramps and Increments\NumericalHelpers.cs" />
|
||||
<Compile Include="Ramps and Increments\UshortSigIncrementer.cs" />
|
||||
<Compile Include="Routing\ICardPortsDevice.cs" />
|
||||
<Compile Include="InUseTracking\IInUseTracking.cs" />
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public class NumericalHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Scales a value
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <param name="inMin"></param>
|
||||
/// <param name="inMax"></param>
|
||||
/// <param name="outMin"></param>
|
||||
/// <param name="outMax"></param>
|
||||
/// <returns></returns>
|
||||
public static double Scale(double input, double inMin, double inMax, double outMin, double outMax)
|
||||
{
|
||||
//Debug.Console(2, this, "Scaling (double) input '{0}' with min '{1}'/max '{2}' to output range min '{3}'/max '{4}'", input, inMin, inMax, outMin, outMax);
|
||||
|
||||
double inputRange = inMax - inMin;
|
||||
|
||||
if (inputRange <= 0)
|
||||
{
|
||||
throw new ArithmeticException(string.Format("Invalid Input Range '{0}' for Scaling. Min '{1}' Max '{2}'.", inputRange, inMin, inMax));
|
||||
}
|
||||
|
||||
double outputRange = outMax - outMin;
|
||||
|
||||
var output = (((input - inMin) * outputRange) / inputRange) + outMin;
|
||||
|
||||
// Debug.Console(2, this, "Scaled output '{0}'", output);
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,8 +89,10 @@ namespace PepperDash.Essentials.DM
|
||||
public void VolumeDown(bool pressRelease)
|
||||
{
|
||||
if (pressRelease)
|
||||
Output.Volume.CreateRamp(0, 400);
|
||||
#warning SCALE THIS RAMP
|
||||
{
|
||||
var remainingRatio = Output.Volume.UShortValue / 65535;
|
||||
Output.Volume.CreateRamp(0, (uint)(400 * remainingRatio));
|
||||
}
|
||||
else
|
||||
Output.Volume.StopRamp();
|
||||
}
|
||||
@@ -101,7 +103,10 @@ namespace PepperDash.Essentials.DM
|
||||
public void VolumeUp(bool pressRelease)
|
||||
{
|
||||
if (pressRelease)
|
||||
{
|
||||
var remainingRatio = (65535 - Output.Volume.UShortValue) / 65535;
|
||||
Output.Volume.CreateRamp(65535, 400);
|
||||
}
|
||||
else
|
||||
Output.Volume.StopRamp();
|
||||
}
|
||||
|
||||
@@ -10,18 +10,6 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace PepperDash.Essentials.Devices.Common.DSP
|
||||
{
|
||||
|
||||
// QUESTIONS:
|
||||
//
|
||||
// When subscribing, just use the Instance ID for Custom Name?
|
||||
|
||||
// Verbose on subscriptions?
|
||||
|
||||
// ! "publishToken":"name" "value":-77.0
|
||||
// ! "myLevelName" -77
|
||||
|
||||
#warning Working here when set aside for config editor work
|
||||
|
||||
public class TesiraForteLevelControl : TesiraForteControlPoint, IDspLevelControl, IKeyed
|
||||
{
|
||||
bool _IsMuted;
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace PepperDash.Essentials.Devices.Displays
|
||||
/// </summary>
|
||||
void UpdateVolumeFB(byte b)
|
||||
{
|
||||
var newVol = (ushort)Scale((double)b, 0, 100, 0, 65535);
|
||||
var newVol = (ushort)NumericalHelpers.Scale((double)b, 0, 100, 0, 65535);
|
||||
if (!VolumeIsRamping)
|
||||
_LastVolumeSent = newVol;
|
||||
if (newVol != _VolumeLevelForSig)
|
||||
@@ -482,40 +482,11 @@ namespace PepperDash.Essentials.Devices.Displays
|
||||
public void SetVolume(ushort level)
|
||||
{
|
||||
_LastVolumeSent = level;
|
||||
var scaled = (int)Scale(level, 0, 65535, 0, 100);
|
||||
var scaled = (int)NumericalHelpers.Scale(level, 0, 65535, 0, 100);
|
||||
// The inputs to Scale ensure that byte won't overflow
|
||||
SendBytes(new byte[] { 0xAA, 0x12, 0x00, 0x01, Convert.ToByte(scaled), 0x00 });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <param name="inMin"></param>
|
||||
/// <param name="inMax"></param>
|
||||
/// <param name="outMin"></param>
|
||||
/// <param name="outMax"></param>
|
||||
/// <returns></returns>
|
||||
double Scale(double input, double inMin, double inMax, double outMin, double outMax)
|
||||
{
|
||||
//Debug.Console(2, this, "Scaling (double) input '{0}' with min '{1}'/max '{2}' to output range min '{3}'/max '{4}'", input, inMin, inMax, outMin, outMax);
|
||||
|
||||
double inputRange = inMax - inMin;
|
||||
|
||||
if (inputRange <= 0)
|
||||
{
|
||||
throw new ArithmeticException(string.Format("Invalid Input Range '{0}' for Scaling. Min '{1}' Max '{2}'.", inputRange, inMin, inMax));
|
||||
}
|
||||
|
||||
double outputRange = outMax - outMin;
|
||||
|
||||
var output = (((input - inMin) * outputRange) / inputRange) + outMin;
|
||||
|
||||
// Debug.Console(2, this, "Scaled output '{0}'", output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
#region IBasicVolumeWithFeedback Members
|
||||
|
||||
public IntFeedback VolumeLevelFeedback { get; private set; }
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using Crestron.SimplSharp;
|
||||
//using Crestron.SimplSharpPro;
|
||||
|
||||
//using PepperDash.Core;
|
||||
//using PepperDash.Essentials.Core;
|
||||
|
||||
//namespace PepperDash.Essentials
|
||||
//{
|
||||
// //***************************************************************************************************
|
||||
// public abstract class EssentialsRoom : Room
|
||||
// {
|
||||
// public event EventHandler<EssentialsRoomSourceChangeEventArgs> PresentationSourceChange;
|
||||
// public event EventHandler<EssentialsRoomAudioDeviceChangeEventArgs> AudioDeviceWillChange;
|
||||
// public Dictionary<uint, Device> Sources { get; protected set; }
|
||||
|
||||
// public abstract BoolFeedback RoomIsOnStandby { get; protected set; }
|
||||
// public abstract BoolFeedback RoomIsOccupied { get; protected set; }
|
||||
|
||||
// public uint UnattendedShutdownTimeMs { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// For use when turning on room without a source selection - e.g. from
|
||||
// /// wake-on signal or occ sensor
|
||||
// /// </summary>
|
||||
// public SourceListItem DefaultPresentationSource { get; set; }
|
||||
|
||||
//#warning This might need more "guts" and shouldn't be public
|
||||
// public SourceListItem CurrentPresentationSourceInfo { get; set; }
|
||||
|
||||
// //public IPresentationSource CurrentPresentationSource { get; protected set; }
|
||||
// //{
|
||||
// // get
|
||||
// // {
|
||||
// // if (_CurrentPresentationSource == null)
|
||||
// // _CurrentPresentationSource = PresentationDevice.Default;
|
||||
// // return _CurrentPresentationSource;
|
||||
// // }
|
||||
// // protected set { _CurrentPresentationSource = value; }
|
||||
// //}
|
||||
// //IPresentationSource _CurrentPresentationSource;
|
||||
|
||||
// /// <summary>
|
||||
// /// The volume control device for this room - changing it will trigger event
|
||||
// /// </summary>
|
||||
// public IBasicVolumeControls CurrentAudioDevice
|
||||
// {
|
||||
// get { return _CurrentAudioDevice; }
|
||||
// protected set
|
||||
// {
|
||||
// if (value != _CurrentAudioDevice)
|
||||
// if (AudioDeviceWillChange != null)
|
||||
// AudioDeviceWillChange(this,
|
||||
// new EssentialsRoomAudioDeviceChangeEventArgs(this, _CurrentAudioDevice, value));
|
||||
// _CurrentAudioDevice = value;
|
||||
// }
|
||||
// }
|
||||
// IBasicVolumeControls _CurrentAudioDevice;
|
||||
|
||||
// public EssentialsRoom(string key, string name)
|
||||
// : base(key, name)
|
||||
// {
|
||||
// }
|
||||
|
||||
// public virtual void SelectSource(uint sourceNum) { }
|
||||
|
||||
// public virtual void SelectSource(IPresentationSource newSrc) { }
|
||||
|
||||
// /// <summary>
|
||||
// /// Make sure that this is called before changing the source
|
||||
// /// </summary>
|
||||
// protected void OnPresentationSourceChange(SourceListItem currentSource, SourceListItem newSource)
|
||||
// {
|
||||
// var handler = PresentationSourceChange;
|
||||
// if (handler != null)
|
||||
// PresentationSourceChange(this,
|
||||
// new EssentialsRoomSourceChangeEventArgs(this, currentSource, newSource));
|
||||
// }
|
||||
// }
|
||||
|
||||
//}
|
||||
@@ -1,45 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using Crestron.SimplSharp;
|
||||
//using Crestron.SimplSharpPro;
|
||||
|
||||
//using PepperDash.Core;
|
||||
//using PepperDash.Essentials.Core;
|
||||
|
||||
//namespace PepperDash.Essentials
|
||||
//{
|
||||
// public class EssentialsRoomSourceChangeEventArgs : EventArgs
|
||||
// {
|
||||
// public EssentialsRoom Room { get; private set; }
|
||||
// public SourceListItem OldSource { get; private set; }
|
||||
// public SourceListItem NewSource { get; private set; }
|
||||
|
||||
// public EssentialsRoomSourceChangeEventArgs(EssentialsRoom room,
|
||||
// SourceListItem oldSource, SourceListItem newSource)
|
||||
// {
|
||||
// Room = room;
|
||||
// OldSource = oldSource;
|
||||
// NewSource = newSource;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// public class EssentialsRoomAudioDeviceChangeEventArgs : EventArgs
|
||||
// {
|
||||
// public EssentialsRoom Room { get; private set; }
|
||||
// public IBasicVolumeControls OldDevice { get; private set; }
|
||||
// public IBasicVolumeControls NewDevice { get; private set; }
|
||||
|
||||
// public EssentialsRoomAudioDeviceChangeEventArgs(EssentialsRoom room,
|
||||
// IBasicVolumeControls oldDevice, IBasicVolumeControls newDevice)
|
||||
// {
|
||||
// Room = room;
|
||||
// OldDevice = oldDevice;
|
||||
// NewDevice = newDevice;
|
||||
// }
|
||||
// }
|
||||
|
||||
//}
|
||||
@@ -141,7 +141,6 @@
|
||||
<Compile Include="Fusion\FusionSystemController.cs" />
|
||||
<Compile Include="HttpApiHandler.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="FOR REFERENCE Room\EssentialsRoom.cs" />
|
||||
<Compile Include="Room\Cotija\CotijaConfig.cs" />
|
||||
<Compile Include="Room\Cotija\CotijaRoomBridge.cs" />
|
||||
<Compile Include="Room\Cotija\DeviceTypeInterfaces\IChannelExtensions.cs" />
|
||||
@@ -155,15 +154,13 @@
|
||||
<Compile Include="Room\EssentialsPresentationRoom.cs" />
|
||||
<Compile Include="Room\EssentialsRoomBase.cs" />
|
||||
<Compile Include="Room\EssentialsRoomConfig.cs" />
|
||||
<Compile Include="FOR REFERENCE Room\HuddleSpaceRoom.cs" />
|
||||
<Compile Include="FOR REFERENCE Room\RoomEventArgs.cs" />
|
||||
<Compile Include="FOR REFERENCE UI\PageControllers\DevicePageControllerBase.cs" />
|
||||
<Compile Include="FOR REFERENCE UI\PageControllers\PageControllerLaptop.cs" />
|
||||
<Compile Include="FOR REFERENCE UI\PageControllers\PageControllerLargeDvd.cs" />
|
||||
<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="Room\VolumeAndSourceChangeArgs.cs" />
|
||||
<Compile Include="UI Drivers\VolumeAndSourceChangeArgs.cs" />
|
||||
<Compile Include="UI Drivers\UISmartObjectJoin.cs" />
|
||||
<Compile Include="UI Drivers\UIStringlJoin.cs" />
|
||||
<Compile Include="UI Drivers\UIUshortJoin.cs" />
|
||||
@@ -177,14 +174,14 @@
|
||||
<Compile Include="UI Drivers\SmartObjectRoomsList.cs" />
|
||||
<Compile Include="UI Drivers\UIBoolJoin.cs" />
|
||||
<Compile Include="Room\Cotija\CotijaSystemController.cs" />
|
||||
<Compile Include="UI\DualDisplaySourceSRLController.cs" />
|
||||
<Compile Include="UI\SubpageReferenceListActivityItem.cs" />
|
||||
<Compile Include="UI\CrestronTouchpanelPropertiesConfig.cs" />
|
||||
<Compile Include="Room\UI\DualDisplaySourceSRLController.cs" />
|
||||
<Compile Include="Room\UI\SubpageReferenceListActivityItem.cs" />
|
||||
<Compile Include="Room\UI\CrestronTouchpanelPropertiesConfig.cs" />
|
||||
<Compile Include="FOR REFERENCE UI\Panels\REMOVE UiCue.cs" />
|
||||
<Compile Include="FOR REFERENCE UI\SRL\SourceListSubpageReferenceList.cs" />
|
||||
<Compile Include="Room\EssentialsHuddleSpaceRoom.cs" />
|
||||
<Compile Include="UI\EssentialsTouchpanelController.cs" />
|
||||
<Compile Include="UI\SubpageReferenceListSourceItem.cs" />
|
||||
<Compile Include="Room\UI\EssentialsTouchpanelController.cs" />
|
||||
<Compile Include="Room\UI\SubpageReferenceListSourceItem.cs" />
|
||||
<None Include="app.config" />
|
||||
<None Include="Properties\ControlSystem.cfg" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,224 +1,221 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronIO;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Crestron.SimplSharpPro.UI;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.PageManagers;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
public class EssentialsTouchpanelController : Device
|
||||
{
|
||||
public BasicTriListWithSmartObject Panel { get; private set; }
|
||||
|
||||
public PanelDriverBase PanelDriver { get; private set; }
|
||||
|
||||
CTimer BacklightTransitionedOnTimer;
|
||||
|
||||
public EssentialsTouchpanelController(string key, string name, Tswx52ButtonVoiceControl tsw,
|
||||
string projectName, string sgdPath)
|
||||
: base(key, name)
|
||||
{
|
||||
Panel = tsw;
|
||||
tsw.LoadSmartObjects(sgdPath);
|
||||
tsw.SigChange += new Crestron.SimplSharpPro.DeviceSupport.SigEventHandler(Tsw_SigChange);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Config constructor
|
||||
/// </summary>
|
||||
public EssentialsTouchpanelController(string key, string name, string type, CrestronTouchpanelPropertiesConfig props, uint id)
|
||||
: base(key, name)
|
||||
{
|
||||
AddPostActivationAction(() =>
|
||||
{
|
||||
Debug.Console(2, this, "post-activation linking");
|
||||
type = type.ToLower();
|
||||
try
|
||||
{
|
||||
if (type == "crestronapp")
|
||||
{
|
||||
var app = new CrestronApp(id, Global.ControlSystem);
|
||||
app.ParameterProjectName.Value = props.ProjectName;
|
||||
Panel = app;
|
||||
}
|
||||
else if (type == "tsw560")
|
||||
Panel = new Tsw560(id, Global.ControlSystem);
|
||||
else if (type == "tsw752")
|
||||
Panel = new Tsw752(id, Global.ControlSystem);
|
||||
else if (type == "tsw1052")
|
||||
Panel = new Tsw1052(id, Global.ControlSystem);
|
||||
else
|
||||
{
|
||||
Debug.Console(0, this, "WARNING: Cannot create TSW controller with type '{0}'", type);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, this, "WARNING: Cannot create TSW base class. Panel will not function: {0}", e.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
// Reserved sigs
|
||||
if (Panel is TswFt5ButtonSystem)
|
||||
{
|
||||
var tsw = Panel as TswFt5ButtonSystem;
|
||||
tsw.ExtenderSystemReservedSigs.Use();
|
||||
tsw.ExtenderSystemReservedSigs.DeviceExtenderSigChange
|
||||
+= ExtenderSystemReservedSigs_DeviceExtenderSigChange;
|
||||
}
|
||||
|
||||
new CTimer(o =>
|
||||
{
|
||||
var regSuccess = Panel.Register();
|
||||
if (regSuccess != eDeviceRegistrationUnRegistrationResponse.Success)
|
||||
Debug.Console(0, this, "WARNING: Registration failed. Continuing, but panel may not function: {0}", regSuccess);
|
||||
|
||||
// Give up cleanly if SGD is not present.
|
||||
var sgdName = @"\NVRAM\Program" + InitialParametersClass.ApplicationNumber
|
||||
+ @"\sgd\" + props.SgdFile;
|
||||
if (!File.Exists(sgdName))
|
||||
{
|
||||
Debug.Console(0, this, "WARNING: Smart object file '{0}' not present. Exiting TSW load", sgdName);
|
||||
return;
|
||||
}
|
||||
|
||||
Panel.LoadSmartObjects(sgdName);
|
||||
Panel.SigChange += Tsw_SigChange;
|
||||
|
||||
var mainDriver = new EssentialsPanelMainInterfaceDriver(Panel, props);
|
||||
// Then the AV driver
|
||||
|
||||
// spin up different room drivers depending on room type
|
||||
var room = DeviceManager.GetDeviceForKey(props.DefaultRoomKey);
|
||||
if (room is EssentialsHuddleSpaceRoom)
|
||||
{
|
||||
Debug.Console(0, this, "Adding huddle space driver");
|
||||
var avDriver = new EssentialsHuddlePanelAvFunctionsDriver(mainDriver, props);
|
||||
avDriver.CurrentRoom = room as EssentialsHuddleSpaceRoom;
|
||||
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.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
|
||||
{
|
||||
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)
|
||||
Debug.Console(2, this, "Home pressed from dark screen");
|
||||
else
|
||||
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)
|
||||
{
|
||||
Debug.Console(2, this, "Backlight transitioning on");
|
||||
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);
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronIO;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Crestron.SimplSharpPro.UI;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.PageManagers;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
public class EssentialsTouchpanelController : Device
|
||||
{
|
||||
public BasicTriListWithSmartObject Panel { get; private set; }
|
||||
|
||||
public PanelDriverBase PanelDriver { get; private set; }
|
||||
|
||||
CTimer BacklightTransitionedOnTimer;
|
||||
|
||||
public EssentialsTouchpanelController(string key, string name, Tswx52ButtonVoiceControl tsw,
|
||||
string projectName, string sgdPath)
|
||||
: base(key, name)
|
||||
{
|
||||
Panel = tsw;
|
||||
tsw.LoadSmartObjects(sgdPath);
|
||||
tsw.SigChange += new Crestron.SimplSharpPro.DeviceSupport.SigEventHandler(Tsw_SigChange);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Config constructor
|
||||
/// </summary>
|
||||
public EssentialsTouchpanelController(string key, string name, string type, CrestronTouchpanelPropertiesConfig props, uint id)
|
||||
: base(key, name)
|
||||
{
|
||||
AddPostActivationAction(() =>
|
||||
{
|
||||
Debug.Console(0, this, "post-activation linking");
|
||||
type = type.ToLower();
|
||||
try
|
||||
{
|
||||
if (type == "crestronapp")
|
||||
{
|
||||
var app = new CrestronApp(id, Global.ControlSystem);
|
||||
app.ParameterProjectName.Value = props.ProjectName;
|
||||
Panel = app;
|
||||
}
|
||||
else if (type == "tsw560")
|
||||
Panel = new Tsw560(id, Global.ControlSystem);
|
||||
else if (type == "tsw752")
|
||||
Panel = new Tsw752(id, Global.ControlSystem);
|
||||
else if (type == "tsw1052")
|
||||
Panel = new Tsw1052(id, Global.ControlSystem);
|
||||
else
|
||||
{
|
||||
Debug.Console(0, this, "WARNING: Cannot create TSW controller with type '{0}'", type);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, this, "WARNING: Cannot create TSW base class. Panel will not function: {0}", e.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
// Reserved sigs
|
||||
if (Panel is TswFt5ButtonSystem)
|
||||
{
|
||||
var tsw = Panel as TswFt5ButtonSystem;
|
||||
tsw.ExtenderSystemReservedSigs.Use();
|
||||
tsw.ExtenderSystemReservedSigs.DeviceExtenderSigChange
|
||||
+= ExtenderSystemReservedSigs_DeviceExtenderSigChange;
|
||||
}
|
||||
|
||||
new CTimer(o =>
|
||||
{
|
||||
var regSuccess = Panel.Register();
|
||||
if (regSuccess != eDeviceRegistrationUnRegistrationResponse.Success)
|
||||
Debug.Console(0, this, "WARNING: Registration failed. Continuing, but panel may not function: {0}", regSuccess);
|
||||
|
||||
// Give up cleanly if SGD is not present.
|
||||
var sgdName = @"\NVRAM\Program" + InitialParametersClass.ApplicationNumber
|
||||
+ @"\sgd\" + props.SgdFile;
|
||||
if (!File.Exists(sgdName))
|
||||
{
|
||||
Debug.Console(0, this, "WARNING: Smart object file '{0}' not present. Exiting TSW load", sgdName);
|
||||
return;
|
||||
}
|
||||
|
||||
Panel.LoadSmartObjects(sgdName);
|
||||
Panel.SigChange += Tsw_SigChange;
|
||||
|
||||
var mainDriver = new EssentialsPanelMainInterfaceDriver(Panel, props);
|
||||
// Then the AV driver
|
||||
|
||||
// spin up different room drivers depending on room type
|
||||
var room = DeviceManager.GetDeviceForKey(props.DefaultRoomKey);
|
||||
if (room is EssentialsHuddleSpaceRoom)
|
||||
{
|
||||
Debug.Console(0, this, "Adding huddle space driver");
|
||||
var avDriver = new EssentialsHuddlePanelAvFunctionsDriver(mainDriver, props);
|
||||
avDriver.CurrentRoom = room as EssentialsHuddleSpaceRoom;
|
||||
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.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
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -334,6 +334,7 @@ namespace PepperDash.Essentials
|
||||
ActivityFooterSrl.Count = 2;
|
||||
TriList.UShortInput[UIUshortJoin.PresentationListCaretMode].UShortValue = 1;
|
||||
EndMeetingButtonSig = ActivityFooterSrl.BoolInputSig(2, 1);
|
||||
ShareButtonSig.BoolValue = CurrentRoom.OnFeedback.BoolValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -529,7 +530,7 @@ namespace PepperDash.Essentials
|
||||
/// <param name="e"></param>
|
||||
void ShutdownPromptTimer_HasFinished(object sender, EventArgs e)
|
||||
{
|
||||
Debug.Console(2, "*#*UI shutdown prompt finished");
|
||||
//Debug.Console(2, "*#*UI shutdown prompt finished");
|
||||
EndMeetingButtonSig.BoolValue = false;
|
||||
CurrentRoom.ShutdownPromptTimer.TimeRemainingFeedback.OutputChange -= ShutdownPromptTimer_TimeRemainingFeedback_OutputChange;
|
||||
CurrentRoom.ShutdownPromptTimer.PercentFeedback.OutputChange -= ShutdownPromptTimer_PercentFeedback_OutputChange;
|
||||
@@ -543,10 +544,11 @@ namespace PepperDash.Essentials
|
||||
/// <param name="e"></param>
|
||||
void ShutdownPromptTimer_WasCancelled(object sender, EventArgs e)
|
||||
{
|
||||
Debug.Console(2, "*#*UI shutdown prompt cancelled");
|
||||
//Debug.Console(2, "*#*UI shutdown prompt cancelled");
|
||||
if (PowerDownModal != null)
|
||||
PowerDownModal.HideDialog();
|
||||
EndMeetingButtonSig.BoolValue = false;
|
||||
ShareButtonSig.BoolValue = CurrentRoom.OnFeedback.BoolValue;
|
||||
|
||||
CurrentRoom.ShutdownPromptTimer.TimeRemainingFeedback.OutputChange += ShutdownPromptTimer_TimeRemainingFeedback_OutputChange;
|
||||
CurrentRoom.ShutdownPromptTimer.PercentFeedback.OutputChange -= ShutdownPromptTimer_PercentFeedback_OutputChange;
|
||||
@@ -663,7 +665,7 @@ namespace PepperDash.Essentials
|
||||
var actualSource = DeviceManager.GetDeviceForKey(srcConfig.SourceKey) as Device;
|
||||
if (actualSource == null)
|
||||
{
|
||||
Debug.Console(0, "Cannot assign missing source '{0}' to source UI list",
|
||||
Debug.Console(1, "Cannot assign missing source '{0}' to source UI list",
|
||||
srcConfig.SourceKey);
|
||||
continue;
|
||||
}
|
||||
@@ -679,13 +681,11 @@ namespace PepperDash.Essentials
|
||||
TriList.StringInput[UIStringJoin.CurrentRoomName].StringValue = _CurrentRoom.Name;
|
||||
if (_CurrentRoom.LogoUrl == null)
|
||||
{
|
||||
Debug.Console(2, _CurrentRoom, "Using default logo");
|
||||
TriList.BooleanInput[UIBoolJoin.LogoDefaultVisible].BoolValue = true;
|
||||
TriList.BooleanInput[UIBoolJoin.LogoUrlVisible].BoolValue = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(2, _CurrentRoom, "Using logo at URL: {0}", _CurrentRoom.LogoUrl);
|
||||
TriList.BooleanInput[UIBoolJoin.LogoDefaultVisible].BoolValue = false;
|
||||
TriList.BooleanInput[UIBoolJoin.LogoUrlVisible].BoolValue = true;
|
||||
TriList.StringInput[UIStringJoin.LogoUrl].StringValue = _CurrentRoom.LogoUrl;
|
||||
@@ -697,7 +697,6 @@ namespace PepperDash.Essentials
|
||||
_CurrentRoom.ShutdownPromptTimer.WasCancelled += ShutdownPromptTimer_WasCancelled;
|
||||
|
||||
// Link up all the change events from the room
|
||||
Debug.Console(2, "UI -- Room is already on={0} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%", _CurrentRoom.OnFeedback.BoolValue);
|
||||
_CurrentRoom.OnFeedback.OutputChange += CurrentRoom_OnFeedback_OutputChange;
|
||||
CurrentRoom_SyncOnFeedback();
|
||||
_CurrentRoom.IsWarmingUpFeedback.OutputChange += CurrentRoom_IsWarmingFeedback_OutputChange;
|
||||
@@ -726,7 +725,7 @@ namespace PepperDash.Essentials
|
||||
void CurrentRoom_SyncOnFeedback()
|
||||
{
|
||||
var value = _CurrentRoom.OnFeedback.BoolValue;
|
||||
Debug.Console(2, CurrentRoom, "UI: Is on event={0}", value);
|
||||
//Debug.Console(2, CurrentRoom, "UI: Is on event={0}", value);
|
||||
TriList.BooleanInput[UIBoolJoin.RoomIsOn].BoolValue = value;
|
||||
|
||||
if (value) //ON
|
||||
@@ -736,6 +735,7 @@ namespace PepperDash.Essentials
|
||||
TriList.BooleanInput[UIBoolJoin.StagingPageVisible].BoolValue = true;
|
||||
TriList.BooleanInput[UIBoolJoin.StartPageVisible].BoolValue = false;
|
||||
TriList.BooleanInput[UIBoolJoin.VolumeSingleMute1Visible].BoolValue = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -752,7 +752,7 @@ namespace PepperDash.Essentials
|
||||
void CurrentRoom_IsWarmingFeedback_OutputChange(object sender, EventArgs e)
|
||||
{
|
||||
var value = CurrentRoom.IsWarmingUpFeedback.BoolValue;
|
||||
Debug.Console(2, CurrentRoom, "UI: WARMING event={0}", value);
|
||||
//Debug.Console(2, CurrentRoom, "UI: WARMING event={0}", value);
|
||||
|
||||
if (value)
|
||||
{
|
||||
@@ -771,7 +771,7 @@ namespace PepperDash.Essentials
|
||||
void IsCoolingDownFeedback_OutputChange(object sender, EventArgs e)
|
||||
{
|
||||
var value = CurrentRoom.IsCoolingDownFeedback.BoolValue;
|
||||
Debug.Console(2, CurrentRoom, "UI: Cooldown event={0}", value);
|
||||
//Debug.Console(2, CurrentRoom, "UI: Cooldown event={0}", value);
|
||||
|
||||
if (value)
|
||||
{
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user