mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-08-31 19:08:29 +00:00
Refator: Refactor timer implementation across multiple classes to use System.Timers.Timer instead of CTimer for improved consistency and performance.
- Updated RelayControlledShade to utilize Timer for output pulsing. - Refactored MockVC to replace CTimer with Timer for call status simulation. - Modified VideoCodecBase to enhance documentation and improve feedback handling. - Removed obsolete IHasCamerasMessenger and updated related classes to use IHasCamerasWithControls. - Adjusted PressAndHoldHandler to implement Timer for button hold actions. - Enhanced logging throughout MobileControl and RoomBridges for better debugging and information tracking. - Cleaned up unnecessary comments and improved exception handling in various classes.
This commit is contained in:
parent
b4d53dbe0e
commit
7076eafc21
56 changed files with 1343 additions and 2197 deletions
|
|
@ -1,94 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the eSourceListItemDestinationTypes enumeration, which represents the various destination types for source list items in a room control system.
|
||||
/// This enumeration is marked as obsolete, indicating that it may be removed in future versions and should not be used in new development.
|
||||
/// Each member of the enumeration corresponds to a specific type of display or audio output commonly found in room control systems,
|
||||
/// such as default displays, program audio, codec content, and auxiliary displays.
|
||||
/// </summary>
|
||||
[Obsolete]
|
||||
public enum eSourceListItemDestinationTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Default display, used for the main video output in a room
|
||||
/// </summary>
|
||||
defaultDisplay,
|
||||
/// <summary>
|
||||
/// Left display
|
||||
/// </summary>
|
||||
leftDisplay,
|
||||
/// <summary>
|
||||
/// Right display
|
||||
/// </summary>
|
||||
rightDisplay,
|
||||
/// <summary>
|
||||
/// Center display
|
||||
/// </summary>
|
||||
centerDisplay,
|
||||
/// <summary>
|
||||
/// Program audio, used for the main audio output in a room
|
||||
/// </summary>
|
||||
programAudio,
|
||||
/// <summary>
|
||||
/// Codec content, used for sharing content to the far end in a video call
|
||||
/// </summary>
|
||||
codecContent,
|
||||
/// <summary>
|
||||
/// Front left display, used for rooms with multiple displays
|
||||
/// </summary>
|
||||
frontLeftDisplay,
|
||||
/// <summary>
|
||||
/// Front right display, used for rooms with multiple displays
|
||||
/// </summary>
|
||||
frontRightDisplay,
|
||||
/// <summary>
|
||||
/// Rear left display, used for rooms with multiple displays
|
||||
/// </summary>
|
||||
rearLeftDisplay,
|
||||
/// <summary>
|
||||
/// Rear right display, used for rooms with multiple displays
|
||||
/// </summary>
|
||||
rearRightDisplay,
|
||||
/// <summary>
|
||||
/// Auxiliary display 1, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay1,
|
||||
/// <summary>
|
||||
/// Auxiliary display 2, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay2,
|
||||
/// <summary>
|
||||
/// Auxiliary display 3, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay3,
|
||||
/// <summary>
|
||||
/// Auxiliary display 4, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay4,
|
||||
/// <summary>
|
||||
/// Auxiliary display 5, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay5,
|
||||
/// <summary>
|
||||
/// Auxiliary display 6, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay6,
|
||||
/// <summary>
|
||||
/// Auxiliary display 7, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay7,
|
||||
/// <summary>
|
||||
/// Auxiliary display 8, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay8,
|
||||
/// <summary>
|
||||
/// Auxiliary display 9, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay9,
|
||||
/// <summary>
|
||||
/// Auxiliary display 10, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay10,
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
using Crestron.SimplSharp;
|
||||
using System.Timers;
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -20,7 +20,7 @@ namespace PepperDash.Essentials.Core
|
|||
/// Gets or sets the Feedback
|
||||
/// </summary>
|
||||
public BoolFeedback Feedback { get; private set; }
|
||||
CTimer Timer;
|
||||
Timer Timer;
|
||||
|
||||
bool _BoolValue;
|
||||
|
||||
|
|
@ -51,16 +51,22 @@ namespace PepperDash.Essentials.Core
|
|||
{
|
||||
_BoolValue = true;
|
||||
Feedback.FireUpdate();
|
||||
Timer = new CTimer(o =>
|
||||
Timer = new Timer(TimeoutMs) { AutoReset = false };
|
||||
Timer.Elapsed += (s, e) =>
|
||||
{
|
||||
_BoolValue = false;
|
||||
Feedback.FireUpdate();
|
||||
Timer = null;
|
||||
}, TimeoutMs);
|
||||
};
|
||||
Timer.Start();
|
||||
}
|
||||
// Timer is running, if retrigger is set, reset it.
|
||||
else if (CanRetrigger)
|
||||
Timer.Reset(TimeoutMs);
|
||||
{
|
||||
Timer.Stop();
|
||||
Timer.Interval = TimeoutMs;
|
||||
Timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -69,7 +75,11 @@ namespace PepperDash.Essentials.Core
|
|||
public void Cancel()
|
||||
{
|
||||
if (Timer != null)
|
||||
Timer.Reset(0);
|
||||
{
|
||||
Timer.Stop();
|
||||
Timer.Interval = 1;
|
||||
Timer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using System.Timers;
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -21,7 +20,7 @@ namespace PepperDash.Essentials.Core;
|
|||
/// Gets the Feedback
|
||||
/// </summary>
|
||||
public BoolFeedback Feedback { get; private set; }
|
||||
CTimer Timer;
|
||||
Timer Timer;
|
||||
|
||||
/// <summary>
|
||||
/// When set to true, will cause Feedback to go high, and cancel the timer.
|
||||
|
|
@ -49,7 +48,11 @@ namespace PepperDash.Essentials.Core;
|
|||
else
|
||||
{
|
||||
if (Timer == null)
|
||||
Timer = new CTimer(o => ClearFeedback(), TimeoutMs);
|
||||
{
|
||||
Timer = new Timer(TimeoutMs) { AutoReset = false };
|
||||
Timer.Elapsed += (s, e) => ClearFeedback();
|
||||
Timer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using Timer = System.Timers.Timer;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronIO;
|
||||
|
|
@ -62,7 +63,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||
|
||||
private Event _currentMeeting;
|
||||
private RoomSchedule _currentSchedule;
|
||||
private CTimer _dailyTimeRequestTimer;
|
||||
private Timer _dailyTimeRequestTimer;
|
||||
private StatusMonitorCollection _errorMessageRollUp;
|
||||
|
||||
private FusionRoomGuids _guids;
|
||||
|
|
@ -70,9 +71,9 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||
private bool _isRegisteredForSchedulePushNotifications;
|
||||
private Event _nextMeeting;
|
||||
|
||||
private CTimer _pollTimer;
|
||||
private Timer _pollTimer;
|
||||
|
||||
private CTimer _pushNotificationTimer;
|
||||
private Timer _pushNotificationTimer;
|
||||
|
||||
private string _roomOccupancyRemoteString;
|
||||
|
||||
|
|
@ -729,15 +730,15 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||
RequestLocalDateTime(null);
|
||||
|
||||
// Setup timer to request time daily
|
||||
if (_dailyTimeRequestTimer != null && !_dailyTimeRequestTimer.Disposed)
|
||||
if (_dailyTimeRequestTimer != null)
|
||||
{
|
||||
_dailyTimeRequestTimer.Stop();
|
||||
_dailyTimeRequestTimer.Dispose();
|
||||
}
|
||||
|
||||
_dailyTimeRequestTimer = new CTimer(RequestLocalDateTime, null, 86400000, 86400000);
|
||||
|
||||
_dailyTimeRequestTimer.Reset(86400000, 86400000);
|
||||
_dailyTimeRequestTimer = new Timer(86400000) { AutoReset = true };
|
||||
_dailyTimeRequestTimer.Elapsed += (s, e) => RequestLocalDateTime(null);
|
||||
_dailyTimeRequestTimer.Start();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -950,25 +951,25 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||
{
|
||||
case 1:
|
||||
_isRegisteredForSchedulePushNotifications = true;
|
||||
if (_pollTimer != null && !_pollTimer.Disposed)
|
||||
if (_pollTimer != null)
|
||||
{
|
||||
_pollTimer.Stop();
|
||||
_pollTimer.Dispose();
|
||||
}
|
||||
_pushNotificationTimer = new CTimer(RequestFullRoomSchedule, null,
|
||||
PushNotificationTimeout, PushNotificationTimeout);
|
||||
_pushNotificationTimer.Reset(PushNotificationTimeout, PushNotificationTimeout);
|
||||
_pushNotificationTimer = new Timer(PushNotificationTimeout) { AutoReset = true };
|
||||
_pushNotificationTimer.Elapsed += (s, e) => RequestFullRoomSchedule(null);
|
||||
_pushNotificationTimer.Start();
|
||||
break;
|
||||
case 0:
|
||||
_isRegisteredForSchedulePushNotifications = false;
|
||||
if (_pushNotificationTimer != null && !_pushNotificationTimer.Disposed)
|
||||
if (_pushNotificationTimer != null)
|
||||
{
|
||||
_pushNotificationTimer.Stop();
|
||||
_pushNotificationTimer.Dispose();
|
||||
}
|
||||
_pollTimer = new CTimer(RequestFullRoomSchedule, null, SchedulePollInterval,
|
||||
SchedulePollInterval);
|
||||
_pollTimer.Reset(SchedulePollInterval, SchedulePollInterval);
|
||||
_pollTimer = new Timer(SchedulePollInterval) { AutoReset = true };
|
||||
_pollTimer.Elapsed += (s, e) => RequestFullRoomSchedule(null);
|
||||
_pollTimer.Start();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1121,7 +1122,10 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||
|
||||
if (action.OuterXml.IndexOf("RequestSchedule", StringComparison.Ordinal) > -1)
|
||||
{
|
||||
_pushNotificationTimer.Reset(PushNotificationTimeout, PushNotificationTimeout);
|
||||
_pushNotificationTimer.Stop();
|
||||
_pushNotificationTimer.Interval = PushNotificationTimeout;
|
||||
_pushNotificationTimer.Start();
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "Received push notification for schedule change");
|
||||
}
|
||||
}
|
||||
else // Not a push notification
|
||||
|
|
@ -1177,7 +1181,9 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||
|
||||
if (!_isRegisteredForSchedulePushNotifications)
|
||||
{
|
||||
_pollTimer.Reset(SchedulePollInterval, SchedulePollInterval);
|
||||
_pollTimer.Stop();
|
||||
_pollTimer.Interval = SchedulePollInterval;
|
||||
_pollTimer.Start();
|
||||
}
|
||||
|
||||
// Fire Schedule Change Event
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the contract for ILogStrings
|
||||
/// </summary>
|
||||
public interface ILogStrings : IKeyed
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a class that is capable of logging a string
|
||||
/// </summary>
|
||||
void SendToLog(IKeyed device, string logMessage);
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the contract for ILogStringsWithLevel
|
||||
/// </summary>
|
||||
public interface ILogStringsWithLevel : IKeyed
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a class that is capable of logging a string with an int level
|
||||
/// </summary>
|
||||
void SendToLog(IKeyed device, Debug.ErrorLogLevel level, string logMessage);
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ using Crestron.SimplSharpPro;
|
|||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Timers;
|
||||
|
||||
using PepperDash.Core;
|
||||
|
||||
|
|
@ -84,10 +85,8 @@ namespace PepperDash.Essentials.Core
|
|||
|
||||
long WarningTime;
|
||||
long ErrorTime;
|
||||
CTimer WarningTimer;
|
||||
CTimer ErrorTimer;
|
||||
|
||||
/// <summary>
|
||||
Timer WarningTimer;
|
||||
Timer ErrorTimer;
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="parent">parent device</param>
|
||||
|
|
@ -155,8 +154,18 @@ namespace PepperDash.Essentials.Core
|
|||
/// </summary>
|
||||
protected void StartErrorTimers()
|
||||
{
|
||||
if (WarningTimer == null) WarningTimer = new CTimer(o => { Status = MonitorStatus.InWarning; }, WarningTime);
|
||||
if (ErrorTimer == null) ErrorTimer = new CTimer(o => { Status = MonitorStatus.InError; }, ErrorTime);
|
||||
if (WarningTimer == null)
|
||||
{
|
||||
WarningTimer = new Timer(WarningTime) { AutoReset = false };
|
||||
WarningTimer.Elapsed += (s, e) => { Status = MonitorStatus.InWarning; };
|
||||
WarningTimer.Start();
|
||||
}
|
||||
if (ErrorTimer == null)
|
||||
{
|
||||
ErrorTimer = new Timer(ErrorTime) { AutoReset = false };
|
||||
ErrorTimer.Elapsed += (s, e) => { Status = MonitorStatus.InError; };
|
||||
ErrorTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -176,10 +185,17 @@ namespace PepperDash.Essentials.Core
|
|||
protected void ResetErrorTimers()
|
||||
{
|
||||
if (WarningTimer != null)
|
||||
WarningTimer.Reset(WarningTime, WarningTime);
|
||||
if (ErrorTimer != null)
|
||||
ErrorTimer.Reset(ErrorTime, ErrorTime);
|
||||
|
||||
{
|
||||
WarningTimer.Stop();
|
||||
WarningTimer.Interval = WarningTime;
|
||||
WarningTimer.Start();
|
||||
}
|
||||
if (ErrorTimer != null)
|
||||
{
|
||||
ErrorTimer.Stop();
|
||||
ErrorTimer.Interval = ErrorTime;
|
||||
ErrorTimer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ using Newtonsoft.Json.Converters;
|
|||
using PepperDash.Essentials.Core.Bridges;
|
||||
using Serilog.Events;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Monitoring;
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ namespace PepperDash.Essentials.Core.Monitoring;
|
|||
public class SystemMonitorController : EssentialsBridgeableDevice
|
||||
{
|
||||
private const long UptimePollTime = 300000;
|
||||
private CTimer _uptimePollTimer;
|
||||
private Timer _uptimePollTimer;
|
||||
|
||||
private string _uptime;
|
||||
private string _lastStart;
|
||||
|
|
@ -147,7 +148,10 @@ public class SystemMonitorController : EssentialsBridgeableDevice
|
|||
CreateEthernetStatusFeedbacks();
|
||||
UpdateEthernetStatusFeeedbacks();
|
||||
|
||||
_uptimePollTimer = new CTimer(PollUptime, null, 0, UptimePollTime);
|
||||
_uptimePollTimer = new Timer(UptimePollTime) { AutoReset = true };
|
||||
_uptimePollTimer.Elapsed += (s, e) => PollUptime(null);
|
||||
_uptimePollTimer.Start();
|
||||
PollUptime(null);
|
||||
|
||||
SystemMonitor.ProgramChange += SystemMonitor_ProgramChange;
|
||||
SystemMonitor.TimeZoneInformation.TimeZoneChange += TimeZoneInformation_TimeZoneChange;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using System.Timers;
|
||||
|
||||
using PepperDash.Core;
|
||||
|
||||
|
|
@ -15,15 +15,30 @@ namespace PepperDash.Essentials.Core;
|
|||
/// </summary>
|
||||
public class ActionIncrementer
|
||||
{
|
||||
/// <summary>
|
||||
/// The amount to change the value by each increment
|
||||
/// </summary>
|
||||
public int ChangeAmount { get; set; }
|
||||
/// <summary>
|
||||
/// The maximum value the incrementer can reach
|
||||
/// </summary>
|
||||
public int MaxValue { get; set; }
|
||||
/// <summary>
|
||||
/// The minimum value the incrementer can reach
|
||||
/// </summary>
|
||||
public int MinValue { get; set; }
|
||||
/// <summary>
|
||||
/// The delay before the incrementer starts repeating
|
||||
/// </summary>
|
||||
public uint RepeatDelay { get; set; }
|
||||
/// <summary>
|
||||
/// The time interval between each repeat
|
||||
/// </summary>
|
||||
public uint RepeatTime { get; set; }
|
||||
|
||||
Action<int> SetAction;
|
||||
Func<int> GetFunc;
|
||||
CTimer Timer;
|
||||
Timer Timer;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
|
@ -89,7 +104,20 @@ public class ActionIncrementer
|
|||
if (atLimit) // Don't go past end
|
||||
Stop();
|
||||
else if (Timer == null) // Only enter the timer if it's not already running
|
||||
Timer = new CTimer(o => { Go(change); }, null, RepeatDelay, RepeatTime);
|
||||
{
|
||||
Timer = new Timer(RepeatDelay) { AutoReset = false };
|
||||
Timer.Elapsed += (s, e) =>
|
||||
{
|
||||
Go(change);
|
||||
if (Timer != null)
|
||||
{
|
||||
Timer.Interval = RepeatTime;
|
||||
Timer.AutoReset = true;
|
||||
Timer.Start();
|
||||
}
|
||||
};
|
||||
Timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using System.Timers;
|
||||
using Crestron.SimplSharpPro;
|
||||
|
||||
using PepperDash.Core;
|
||||
|
|
@ -16,14 +16,39 @@ namespace PepperDash.Essentials.Core;
|
|||
public class UshortSigIncrementer
|
||||
{
|
||||
UShortInputSig TheSig;
|
||||
|
||||
/// <summary>
|
||||
/// Amount to change the signal on each step
|
||||
/// </summary>
|
||||
public ushort ChangeAmount { get; set; }
|
||||
/// <summary>
|
||||
/// Maximum value to ramp to
|
||||
/// </summary>
|
||||
public int MaxValue { get; set; }
|
||||
/// <summary>
|
||||
/// Minimum value to ramp to
|
||||
/// </summary>
|
||||
public int MinValue { get; set; }
|
||||
/// <summary>
|
||||
/// The delay before the incrementer starts repeating
|
||||
/// </summary>
|
||||
public uint RepeatDelay { get; set; }
|
||||
/// <summary>
|
||||
/// The time interval between each repeat
|
||||
/// </summary>
|
||||
public uint RepeatTime { get; set; }
|
||||
bool SignedMode;
|
||||
CTimer Timer;
|
||||
Timer Timer;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="sig"></param>
|
||||
/// <param name="changeAmount"></param>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
/// <param name="repeatDelay"></param>
|
||||
/// <param name="repeatTime"></param>
|
||||
public UshortSigIncrementer(UShortInputSig sig, ushort changeAmount, int minValue, int maxValue, uint repeatDelay, uint repeatTime)
|
||||
{
|
||||
TheSig = sig;
|
||||
|
|
@ -37,12 +62,19 @@ public class UshortSigIncrementer
|
|||
Debug.LogMessage(LogEventLevel.Debug, "UshortSigIncrementer has signed values that exceed range of -32768, 32767");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts incrementing cycle
|
||||
/// </summary>
|
||||
|
||||
public void StartUp()
|
||||
{
|
||||
if (Timer != null) return;
|
||||
Go(ChangeAmount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts decrementing cycle
|
||||
/// </summary>
|
||||
public void StartDown()
|
||||
{
|
||||
if (Timer != null) return;
|
||||
|
|
@ -64,7 +96,20 @@ public class UshortSigIncrementer
|
|||
if (atLimit) // Don't go past end
|
||||
Stop();
|
||||
else if (Timer == null) // Only enter the timer if it's not already running
|
||||
Timer = new CTimer(o => { Go(change); }, null, RepeatDelay, RepeatTime);
|
||||
{
|
||||
Timer = new Timer(RepeatDelay) { AutoReset = false };
|
||||
Timer.Elapsed += (s, e) =>
|
||||
{
|
||||
Go(change);
|
||||
if (Timer != null)
|
||||
{
|
||||
Timer.Interval = RepeatTime;
|
||||
Timer.AutoReset = true;
|
||||
Timer.Start();
|
||||
}
|
||||
};
|
||||
Timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckLevel(int levelIn, out int levelOut)
|
||||
|
|
@ -85,6 +130,9 @@ public class UshortSigIncrementer
|
|||
return IsAtLimit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops incrementing/decrementing cycle
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
if (Timer != null)
|
||||
|
|
@ -92,6 +140,11 @@ public class UshortSigIncrementer
|
|||
Timer = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value of the signal
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
|
||||
void SetValue(ushort value)
|
||||
{
|
||||
//CrestronConsole.PrintLine("Increment level:{0} / {1}", value, (short)value);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
using Crestron.SimplSharp;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Core.Logging;
|
||||
using Serilog.Events;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
|
|
@ -73,7 +74,7 @@ public class EssentialsRoomCombiner : EssentialsDevice, IEssentialsRoomCombiner
|
|||
}
|
||||
}
|
||||
|
||||
private CTimer _scenarioChangeDebounceTimer;
|
||||
private Timer _scenarioChangeDebounceTimer;
|
||||
|
||||
private int _scenarioChangeDebounceTimeSeconds = 10; // default to 10s
|
||||
|
||||
|
|
@ -204,18 +205,22 @@ public class EssentialsRoomCombiner : EssentialsDevice, IEssentialsRoomCombiner
|
|||
|
||||
if (_scenarioChangeDebounceTimer == null)
|
||||
{
|
||||
_scenarioChangeDebounceTimer = new CTimer((o) => DetermineRoomCombinationScenario(), time);
|
||||
_scenarioChangeDebounceTimer = new Timer(time) { AutoReset = false };
|
||||
_scenarioChangeDebounceTimer.Elapsed += async (s, e) => await DetermineRoomCombinationScenario();
|
||||
_scenarioChangeDebounceTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
_scenarioChangeDebounceTimer.Reset(time);
|
||||
_scenarioChangeDebounceTimer.Stop();
|
||||
_scenarioChangeDebounceTimer.Interval = time;
|
||||
_scenarioChangeDebounceTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the current room combination scenario based on the state of the partition sensors
|
||||
/// </summary>
|
||||
private void DetermineRoomCombinationScenario()
|
||||
private async Task DetermineRoomCombinationScenario()
|
||||
{
|
||||
if (_scenarioChangeDebounceTimer != null)
|
||||
{
|
||||
|
|
@ -250,7 +255,7 @@ public class EssentialsRoomCombiner : EssentialsDevice, IEssentialsRoomCombiner
|
|||
if (currentScenario != null)
|
||||
{
|
||||
this.LogInformation("Found combination Scenario {scenarioKey}", currentScenario.Key);
|
||||
ChangeScenario(currentScenario);
|
||||
await ChangeScenario(currentScenario);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,18 +24,12 @@ public class EssentialsNDisplayRoomPropertiesConfig : EssentialsConferenceRoomPr
|
|||
[JsonProperty("defaultVideoBehavior")]
|
||||
public string DefaultVideoBehavior { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Displays
|
||||
/// </summary>
|
||||
[JsonProperty("displays")]
|
||||
public Dictionary<eSourceListItemDestinationTypes, DisplayItem> Displays { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public EssentialsNDisplayRoomPropertiesConfig()
|
||||
{
|
||||
Displays = new Dictionary<eSourceListItemDestinationTypes, DisplayItem>();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,30 +1,56 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using System.Timers;
|
||||
|
||||
using PepperDash.Core;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// A class that represents a countdown timer with feedbacks for time remaining, percent, and seconds
|
||||
/// </summary>
|
||||
public class SecondsCountdownTimer: IKeyed
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the timer starts.
|
||||
/// </summary>
|
||||
public event EventHandler<EventArgs> HasStarted;
|
||||
/// <summary>
|
||||
/// Event triggered when the timer finishes.
|
||||
/// </summary>
|
||||
public event EventHandler<EventArgs> HasFinished;
|
||||
/// <summary>
|
||||
/// Event triggered when the timer is cancelled.
|
||||
/// </summary>
|
||||
public event EventHandler<EventArgs> WasCancelled;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Key { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the timer is currently running
|
||||
/// </summary>
|
||||
public BoolFeedback IsRunningFeedback { get; private set; }
|
||||
bool _isRunning;
|
||||
|
||||
/// <summary>
|
||||
/// Feedback for the percentage of time remaining
|
||||
/// </summary>
|
||||
public IntFeedback PercentFeedback { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Feedback for the time remaining in a string format
|
||||
// </summary>
|
||||
public StringFeedback TimeRemainingFeedback { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Feedback for the time remaining in seconds
|
||||
/// </summary>
|
||||
public IntFeedback SecondsRemainingFeedback { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// When true, the timer will count down immediately upon calling Start. When false, the timer will count up, and when Finish is called, it will stop counting and fire the HasFinished event.
|
||||
/// </summary>
|
||||
public bool CountsDown { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -32,10 +58,17 @@ public class SecondsCountdownTimer: IKeyed
|
|||
/// </summary>
|
||||
public int SecondsToCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time at which the timer was started. Used to calculate percent and time remaining. Will be DateTime.MinValue if the timer is not currently running.
|
||||
/// </summary>
|
||||
public DateTime StartTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time at which the timer will finish counting down. Used to calculate percent and time remaining. Will be DateTime.MinValue if the timer is not currently running.
|
||||
/// </summary>
|
||||
public DateTime FinishTime { get; private set; }
|
||||
|
||||
private CTimer _secondTimer;
|
||||
private Timer _secondTimer;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
|
|
@ -88,7 +121,10 @@ public class SecondsCountdownTimer: IKeyed
|
|||
|
||||
if (_secondTimer != null)
|
||||
_secondTimer.Stop();
|
||||
_secondTimer = new CTimer(SecondElapsedTimerCallback, null, 0, 1000);
|
||||
_secondTimer = new Timer(1000) { AutoReset = true };
|
||||
_secondTimer.Elapsed += (s, e) => SecondElapsedTimerCallback(null);
|
||||
_secondTimer.Start();
|
||||
SecondElapsedTimerCallback(null);
|
||||
_isRunning = true;
|
||||
IsRunningFeedback.FireUpdate();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Crestron.SimplSharp;
|
||||
using System.Timers;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using Newtonsoft.Json;
|
||||
|
|
@ -17,9 +17,14 @@ public class RetriggerableTimer : EssentialsDevice
|
|||
{
|
||||
private RetriggerableTimerPropertiesConfig _propertiesConfig;
|
||||
|
||||
private CTimer _timer;
|
||||
private Timer _timer;
|
||||
private long _timerIntervalMs;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for RetriggerableTimer
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="config"></param>
|
||||
public RetriggerableTimer(string key, DeviceConfig config)
|
||||
: base(key, config.Name)
|
||||
{
|
||||
|
|
@ -32,6 +37,7 @@ public class RetriggerableTimer : EssentialsDevice
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
if (_propertiesConfig.StartTimerOnActivation)
|
||||
|
|
@ -53,14 +59,26 @@ public class RetriggerableTimer : EssentialsDevice
|
|||
_timer = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts the timer with the interval specified in config. When the timer elapses, it executes the action specified in config for the Elapsed event. If the timer is already running, it will reset and start again.
|
||||
/// When the timer is stopped, it executes the action specified in config for the Stopped event.
|
||||
/// </summary>
|
||||
public void StartTimer()
|
||||
{
|
||||
CleanUpTimer();
|
||||
Debug.LogMessage(LogEventLevel.Information, this, "Starting Timer");
|
||||
|
||||
_timer = new CTimer(TimerElapsedCallback, GetActionFromConfig(eRetriggerableTimerEvents.Elapsed), _timerIntervalMs, _timerIntervalMs);
|
||||
var action = GetActionFromConfig(eRetriggerableTimerEvents.Elapsed);
|
||||
_timer = new Timer(_timerIntervalMs) { AutoReset = true };
|
||||
_timer.Elapsed += (s, e) => TimerElapsedCallback(action);
|
||||
_timer.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the timer. If the timer is stopped before it elapses, it will execute the action specified in config for the Stopped event. If the timer is not running, this method does nothing.
|
||||
/// If the timer is running, it will stop the timer and execute the Stopped action from config. If the timer is not running, it will do nothing.
|
||||
/// If the timer is running and the Stopped action is not specified in config, it will stop the timer and do nothing else. If the timer is running and the Stopped action is specified in config, it will stop the timer and execute the action. If the timer is not running, it will do nothing regardless
|
||||
/// </summary>
|
||||
public void StopTimer()
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, this, "Stopping Timer");
|
||||
|
|
@ -81,7 +99,7 @@ public class RetriggerableTimer : EssentialsDevice
|
|||
/// <summary>
|
||||
/// Executes the Elapsed action from confing when the timer elapses
|
||||
/// </summary>
|
||||
/// <param name="o"></param>
|
||||
/// <param name="action">The action to execute when the timer elapses</param>
|
||||
private void TimerElapsedCallback(object action)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Timer Elapsed. Executing Action");
|
||||
|
|
@ -127,15 +145,29 @@ public class RetriggerableTimer : EssentialsDevice
|
|||
/// </summary>
|
||||
public class RetriggerableTimerPropertiesConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// When true, the timer will start immediately upon activation. When false, the timer will not start until StartTimer is called.
|
||||
/// </summary>
|
||||
[JsonProperty("startTimerOnActivation")]
|
||||
public bool StartTimerOnActivation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The interval at which the timer elapses, in milliseconds. This is required and must be greater than 0. If this value is not set or is less than or equal to 0, the timer will not start and an error will be logged.
|
||||
/// </summary>
|
||||
[JsonProperty("timerIntervalMs")]
|
||||
public long TimerIntervalMs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The actions to execute when timer events occur. The key is the type of event, and the value is the action to execute when that event occurs.
|
||||
/// This is required and must contain at least an action for the Elapsed event.
|
||||
/// If an action for the Stopped event is not included, then when the timer is stopped, it will simply stop without executing any action.
|
||||
/// </summary>
|
||||
[JsonProperty("events")]
|
||||
public Dictionary<eRetriggerableTimerEvents, DeviceActionWrapper> Events { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public RetriggerableTimerPropertiesConfig()
|
||||
{
|
||||
Events = new Dictionary<eRetriggerableTimerEvents, DeviceActionWrapper>();
|
||||
|
|
@ -147,7 +179,14 @@ public class RetriggerableTimerPropertiesConfig
|
|||
/// </summary>
|
||||
public enum eRetriggerableTimerEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// Elapsed event state
|
||||
/// </summary>
|
||||
Elapsed,
|
||||
|
||||
/// <summary>
|
||||
/// Stopped event state
|
||||
/// </summary>
|
||||
Stopped,
|
||||
}
|
||||
|
||||
|
|
@ -156,11 +195,16 @@ public enum eRetriggerableTimerEvents
|
|||
/// </summary>
|
||||
public class RetriggerableTimerFactory : EssentialsDeviceFactory<RetriggerableTimer>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor for factory
|
||||
///
|
||||
/// </summary>
|
||||
public RetriggerableTimerFactory()
|
||||
{
|
||||
TypeNames = new List<string>() { "retriggerabletimer" };
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new RetriggerableTimer Device");
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using System.Timers;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Touchpanels.Keyboards;
|
||||
|
||||
/// <summary>
|
||||
/// Controller for the Habanero keyboard. This class handles all interaction with the keyboard, including showing/hiding, shift states, and key presses. It exposes a KeyPress event for single key presses, and an OutputFeedback string that contains the full text of what's been entered on the keyboard.
|
||||
/// </summary>
|
||||
public class HabaneroKeyboardController
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -12,29 +15,57 @@ public class HabaneroKeyboardController
|
|||
/// </summary>
|
||||
public event EventHandler<KeyboardControllerPressEventArgs> KeyPress;
|
||||
|
||||
/// <summary>
|
||||
/// The BasicTriList that the keyboard is connected to. This is used for all interaction with the keyboard, including showing/hiding, setting button text/visibility, and handling button presses.
|
||||
/// </summary>
|
||||
public BasicTriList TriList { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Feedback for the current text entered on the keyboard. This is updated whenever a key is pressed, and can be used to get the full string of what's been entered on the keyboard.
|
||||
/// </summary>
|
||||
public StringFeedback OutputFeedback { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the keyboard is currently visible. This is updated when Show and Hide are called, and can be used to determine the current visibility state of the keyboard.
|
||||
/// </summary>
|
||||
public bool IsVisible { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The string displayed on the ".com" button.
|
||||
/// </summary>
|
||||
public string DotComButtonString { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The text displayed on the "Go" button.
|
||||
/// </summary>
|
||||
public string GoButtonText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The text displayed on the secondary button.
|
||||
/// </summary>
|
||||
public string SecondaryButtonText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the "Go" button is visible.
|
||||
/// </summary>
|
||||
public bool GoButtonVisible { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the secondary button is visible.
|
||||
/// </summary>
|
||||
public bool SecondaryButtonVisible { get; set; }
|
||||
|
||||
int ShiftMode = 0;
|
||||
|
||||
|
||||
StringBuilder Output;
|
||||
|
||||
/// <summary>
|
||||
/// An action that is run when the keyboard is hidden, either by calling the Hide method or by pressing the close button on the keyboard. This can be used to perform any necessary cleanup or state updates when the keyboard is dismissed.
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
public Action HideAction { get; set; }
|
||||
|
||||
CTimer BackspaceTimer;
|
||||
Timer BackspaceTimer;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
|
@ -88,8 +119,8 @@ public class HabaneroKeyboardController
|
|||
TriList.SetSigTrueAction(2947, () => Press('.'));
|
||||
TriList.SetSigTrueAction(2948, () => Press('@'));
|
||||
TriList.SetSigTrueAction(2949, () => Press(' '));
|
||||
TriList.SetSigHeldAction(2950, 500, StartBackspaceRepeat, StopBackspaceRepeat, Backspace);
|
||||
//TriList.SetSigTrueAction(2950, Backspace);
|
||||
TriList.SetSigHeldAction(2950, 500, StartBackspaceRepeat, StopBackspaceRepeat, Backspace);
|
||||
//TriList.SetSigTrueAction(2950, Backspace);
|
||||
TriList.SetSigTrueAction(2951, Shift);
|
||||
TriList.SetSigTrueAction(2952, NumShift);
|
||||
TriList.SetSigTrueAction(2953, Clear);
|
||||
|
|
@ -117,7 +148,7 @@ public class HabaneroKeyboardController
|
|||
TriList.ClearBoolSigAction(i);
|
||||
|
||||
// run attached actions
|
||||
if(HideAction != null)
|
||||
if (HideAction != null)
|
||||
HideAction();
|
||||
|
||||
TriList.SetBool(KeyboardVisible, false);
|
||||
|
|
@ -205,28 +236,31 @@ public class HabaneroKeyboardController
|
|||
char Y(int i) { return new char[] { 'y', 'Y', '6', '^' }[i]; }
|
||||
char Z(int i) { return new char[] { 'z', 'Z', ',', ',' }[i]; }
|
||||
|
||||
/// <summary>
|
||||
/// Does what it says
|
||||
/// </summary>
|
||||
void StartBackspaceRepeat()
|
||||
{
|
||||
if (BackspaceTimer == null)
|
||||
{
|
||||
BackspaceTimer = new CTimer(o => Backspace(), null, 0, 175);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Does what it says
|
||||
/// </summary>
|
||||
void StartBackspaceRepeat()
|
||||
{
|
||||
if (BackspaceTimer == null)
|
||||
{
|
||||
BackspaceTimer = new Timer(175) { AutoReset = true };
|
||||
BackspaceTimer.Elapsed += (s, e) => Backspace();
|
||||
BackspaceTimer.Start();
|
||||
Backspace();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does what it says
|
||||
/// </summary>
|
||||
void StopBackspaceRepeat()
|
||||
{
|
||||
if (BackspaceTimer != null)
|
||||
{
|
||||
BackspaceTimer.Stop();
|
||||
BackspaceTimer = null;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Does what it says
|
||||
/// </summary>
|
||||
void StopBackspaceRepeat()
|
||||
{
|
||||
if (BackspaceTimer != null)
|
||||
{
|
||||
BackspaceTimer.Stop();
|
||||
BackspaceTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
void Backspace()
|
||||
{
|
||||
|
|
@ -384,7 +418,7 @@ public class HabaneroKeyboardController
|
|||
/// <summary>
|
||||
/// 2904
|
||||
/// </summary>
|
||||
public const uint SecondaryButtonTextJoin = 2904;
|
||||
public const uint SecondaryButtonTextJoin = 2904;
|
||||
/// <summary>
|
||||
/// 2905
|
||||
/// </summary>
|
||||
|
|
@ -413,21 +447,58 @@ public class HabaneroKeyboardController
|
|||
/// </summary>
|
||||
public class KeyboardControllerPressEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The text of the key that was pressed. This will be null if a special key (backspace, clear, go, secondary) was pressed, in which case the SpecialKey property should be checked to determine which key was pressed.
|
||||
/// </summary>
|
||||
public string Text { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// If a special key (backspace, clear, go, secondary) was pressed, this property indicates which key it was. If a regular key was pressed, this will be KeyboardSpecialKey.None, and the Text property should be checked for the value of the key press.
|
||||
/// </summary>
|
||||
public KeyboardSpecialKey SpecialKey { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for regular key presses
|
||||
/// </summary>
|
||||
public KeyboardControllerPressEventArgs(string text)
|
||||
{
|
||||
Text = text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for special key presses
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
public KeyboardControllerPressEventArgs(KeyboardSpecialKey key)
|
||||
{
|
||||
SpecialKey = key;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An enum representing special keys on the keyboard that don't have text values, such as backspace, clear, go, and the secondary button. The None value is used for regular key presses that do have text values, and should not be used for special key presses.
|
||||
/// </summary>
|
||||
public enum KeyboardSpecialKey
|
||||
{
|
||||
None = 0, Backspace, Clear, GoButton, SecondaryButton
|
||||
/// <summary>
|
||||
/// Indicates that a regular key with a text value was pressed, rather than a special key. When this value is set, the Text property of the KeyboardControllerPressEventArgs should be checked to get the value of the key press.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the backspace key was pressed.
|
||||
/// </summary>
|
||||
Backspace,
|
||||
/// <summary>
|
||||
/// Indicates that the clear key was pressed.
|
||||
/// </summary>
|
||||
Clear,
|
||||
/// <summary>
|
||||
/// Indicates that the go button was pressed.
|
||||
/// </summary>
|
||||
GoButton,
|
||||
/// <summary>
|
||||
/// Indicates that the secondary button was pressed.
|
||||
/// </summary>
|
||||
SecondaryButton
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
using System;
|
||||
using Crestron.SimplSharp;
|
||||
using System.Timers;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ namespace PepperDash.Essentials.Core;
|
|||
/// <returns></returns>
|
||||
public static BoolOutputSig SetSigHeldAction(this BoolOutputSig sig, uint heldMs, Action heldAction, Action holdReleasedAction, Action releaseAction)
|
||||
{
|
||||
CTimer heldTimer = null;
|
||||
Timer heldTimer = null;
|
||||
bool wasHeld = false;
|
||||
return sig.SetBoolSigAction(press =>
|
||||
{
|
||||
|
|
@ -92,7 +92,8 @@ namespace PepperDash.Essentials.Core;
|
|||
{
|
||||
wasHeld = false;
|
||||
// Could insert a pressed action here
|
||||
heldTimer = new CTimer(o =>
|
||||
heldTimer = new Timer(heldMs) { AutoReset = false };
|
||||
heldTimer.Elapsed += (s, e) =>
|
||||
{
|
||||
// if still held and there's an action
|
||||
if (sig.BoolValue && heldAction != null)
|
||||
|
|
@ -101,7 +102,8 @@ namespace PepperDash.Essentials.Core;
|
|||
// Hold action here
|
||||
heldAction();
|
||||
}
|
||||
}, heldMs);
|
||||
};
|
||||
heldTimer.Start();
|
||||
}
|
||||
else if (!press && !wasHeld) // released, no hold
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue