Fixed share button sync issues around power off dialogs

This commit is contained in:
Heath Volmer
2017-08-25 15:16:21 -06:00
parent efd630c8f1
commit d55d30be3f
17 changed files with 285 additions and 415 deletions

View File

@@ -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" />

View File

@@ -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;
}
}
}

View File

@@ -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();
}

View File

@@ -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;

View File

@@ -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; }

View File

@@ -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));
// }
// }
//}

View File

@@ -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;
// }
// }
//}

View File

@@ -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>

View File

@@ -38,7 +38,7 @@ namespace PepperDash.Essentials
{
AddPostActivationAction(() =>
{
Debug.Console(2, this, "post-activation linking");
Debug.Console(0, this, "post-activation linking");
type = type.ToLower();
try
{
@@ -154,9 +154,7 @@ namespace PepperDash.Essentials
void HomePressed()
{
if (BacklightTransitionedOnTimer != null)
Debug.Console(2, this, "Home pressed from dark screen");
else
if (BacklightTransitionedOnTimer == null)
PanelDriver.BackButtonPressed();
}
@@ -167,7 +165,6 @@ namespace PepperDash.Essentials
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;

View File

@@ -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)
{