mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-28 11:54:57 +00:00
Compare commits
9 Commits
2.0.0-alph
...
2.0.0-alph
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01862ab9aa | ||
|
|
8ec6fa785e | ||
|
|
bc67a4382b | ||
|
|
80b8cc6385 | ||
|
|
82f78bf068 | ||
|
|
d8d27949c3 | ||
|
|
fa9b493431 | ||
|
|
e5d5c90aa9 | ||
|
|
5fad706cd8 |
@@ -106,4 +106,11 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
||||
Action<string,string, JToken> Action { get; }
|
||||
}
|
||||
|
||||
public interface IMobileControlTouchpanelController : IKeyed
|
||||
{
|
||||
string DefaultRoomKey { get; }
|
||||
void SetAppUrl(string url);
|
||||
bool UseDirectServer { get; }
|
||||
bool ZoomRoomController { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a class that has warm up and cool down
|
||||
/// </summary>
|
||||
public interface IProjectorScreenLiftControl
|
||||
{
|
||||
void Raise();
|
||||
void Lower();
|
||||
BoolFeedback IsInUpPosition { get; }
|
||||
bool InUpPosition { get; }
|
||||
event EventHandler<EventArgs> PositionChanged;
|
||||
string DisplayDeviceKey { get; }
|
||||
eScreenLiftControlType Type { get; } // screen/lift
|
||||
}
|
||||
|
||||
public enum eScreenLiftControlType
|
||||
{
|
||||
lift,
|
||||
screen
|
||||
}
|
||||
}
|
||||
@@ -220,19 +220,5 @@ namespace PepperDash.Essentials.Core
|
||||
}
|
||||
|
||||
|
||||
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")]
|
||||
public class MockDisplayFactory : EssentialsDeviceFactory<MockDisplay>
|
||||
{
|
||||
public MockDisplayFactory()
|
||||
{
|
||||
TypeNames = new List<string>() { "mockdisplay" };
|
||||
}
|
||||
|
||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Mock Display Device");
|
||||
return new MockDisplay(dc.Key, dc.Name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -77,6 +77,34 @@ namespace PepperDash.Essentials.Core
|
||||
SecondsCountdownTimer ShutdownPromptTimer { get; }
|
||||
|
||||
void SetShutdownPromptSeconds(int seconds);
|
||||
|
||||
void StartShutdown(eShutdownType type);
|
||||
}
|
||||
|
||||
/// <summary""'""">
|
||||
/// Describes a room with a tech password
|
||||
/// </summary>
|
||||
public interface ITechPassword
|
||||
{
|
||||
event EventHandler<TechPasswordEventArgs> TechPasswordValidateResult;
|
||||
|
||||
event EventHandler<EventArgs> TechPasswordChanged;
|
||||
|
||||
int TechPasswordLength { get; }
|
||||
|
||||
void ValidateTechPassword(string password);
|
||||
|
||||
void SetTechPassword(string oldPassword, string newPassword);
|
||||
}
|
||||
|
||||
public class TechPasswordEventArgs : EventArgs
|
||||
{
|
||||
public bool IsValid { get; private set; }
|
||||
|
||||
public TechPasswordEventArgs(bool isValid)
|
||||
{
|
||||
IsValid = isValid;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace PepperDash.Essentials.Core
|
||||
public IntFeedback PercentFeedback { get; private set; }
|
||||
public StringFeedback TimeRemainingFeedback { get; private set; }
|
||||
|
||||
public IntFeedback SecondsRemainingFeedback { get; private set; }
|
||||
|
||||
public bool CountsDown { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -64,6 +66,8 @@ namespace PepperDash.Essentials.Core
|
||||
: String.Format("{0:00}:{1:00}", timeSpan.Minutes, timeSpan.Seconds);
|
||||
});
|
||||
|
||||
SecondsRemainingFeedback = new IntFeedback(() => (int)(FinishTime - DateTime.Now).TotalSeconds);
|
||||
|
||||
PercentFeedback =
|
||||
new IntFeedback(
|
||||
() =>
|
||||
@@ -144,6 +148,7 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
PercentFeedback.FireUpdate();
|
||||
TimeRemainingFeedback.FireUpdate();
|
||||
SecondsRemainingFeedback.FireUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Bridges;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
using Serilog.Events;
|
||||
@@ -251,4 +252,17 @@ namespace PepperDash.Essentials.Devices.Common.Displays
|
||||
|
||||
|
||||
}
|
||||
public class MockDisplayFactory : EssentialsDeviceFactory<MockDisplay>
|
||||
{
|
||||
public MockDisplayFactory()
|
||||
{
|
||||
TypeNames = new List<string>() { "mockdisplay" };
|
||||
}
|
||||
|
||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Mock Display Device");
|
||||
return new MockDisplay(dc.Key, dc.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,266 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Crestron.SimplSharp;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Core.CrestronIO;
|
||||
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||
using PepperDash.Essentials.Devices.Common;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Essentials.Devices.Common.Shades
|
||||
{
|
||||
/// <summary>
|
||||
/// Controls a single shade using three relays
|
||||
/// </summary>
|
||||
public class ScreenLiftController : EssentialsDevice, IProjectorScreenLiftControl
|
||||
{
|
||||
readonly ScreenLiftControllerConfigProperties Config;
|
||||
readonly ScreenLiftRelaysConfig RaiseRelayConfig;
|
||||
readonly ScreenLiftRelaysConfig LowerRelayConfig;
|
||||
readonly ScreenLiftRelaysConfig LatchedRelayConfig;
|
||||
|
||||
Displays.DisplayBase DisplayDevice;
|
||||
ISwitchedOutput RaiseRelay;
|
||||
ISwitchedOutput LowerRelay;
|
||||
ISwitchedOutput LatchedRelay;
|
||||
|
||||
public bool InUpPosition
|
||||
{
|
||||
get { return _isInUpPosition; }
|
||||
set
|
||||
{
|
||||
if (value == _isInUpPosition) return;
|
||||
_isInUpPosition = value;
|
||||
IsInUpPosition.FireUpdate();
|
||||
PositionChanged?.Invoke(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isInUpPosition { get; set; }
|
||||
public eScreenLiftControlType Type { get; private set; }
|
||||
public eScreenLiftControlMode Mode { get; private set; }
|
||||
|
||||
public string DisplayDeviceKey { get; private set; }
|
||||
public BoolFeedback IsInUpPosition { get; private set; }
|
||||
|
||||
public event EventHandler<EventArgs> PositionChanged;
|
||||
|
||||
public ScreenLiftController(string key, string name, ScreenLiftControllerConfigProperties config)
|
||||
: base(key, name)
|
||||
{
|
||||
Config = config;
|
||||
DisplayDeviceKey = Config.DisplayDeviceKey;
|
||||
Mode = Config.Mode;
|
||||
Type = Config.Type;
|
||||
|
||||
IsInUpPosition = new BoolFeedback(() => _isInUpPosition);
|
||||
|
||||
switch (Mode)
|
||||
{
|
||||
case eScreenLiftControlMode.momentary:
|
||||
{
|
||||
RaiseRelayConfig = Config.Relays["raise"];
|
||||
LowerRelayConfig = Config.Relays["lower"];
|
||||
break;
|
||||
}
|
||||
case eScreenLiftControlMode.latched:
|
||||
{
|
||||
LatchedRelayConfig = Config.Relays["latched"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void IsCoolingDownFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||
{
|
||||
if (!DisplayDevice.IsCoolingDownFeedback.BoolValue && Type == eScreenLiftControlType.lift)
|
||||
{
|
||||
Raise();
|
||||
return;
|
||||
}
|
||||
if (DisplayDevice.IsCoolingDownFeedback.BoolValue && Type == eScreenLiftControlType.screen)
|
||||
{
|
||||
Raise();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void IsWarmingUpFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||
{
|
||||
if (DisplayDevice.IsWarmingUpFeedback.BoolValue)
|
||||
{
|
||||
Lower();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
//Create ISwitchedOutput objects based on props
|
||||
switch (Mode)
|
||||
{
|
||||
case eScreenLiftControlMode.momentary:
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, $"Getting relays for {Mode}");
|
||||
RaiseRelay = GetSwitchedOutputFromDevice(RaiseRelayConfig.DeviceKey);
|
||||
LowerRelay = GetSwitchedOutputFromDevice(LowerRelayConfig.DeviceKey);
|
||||
break;
|
||||
}
|
||||
case eScreenLiftControlMode.latched:
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, $"Getting relays for {Mode}");
|
||||
LatchedRelay = GetSwitchedOutputFromDevice(LatchedRelayConfig.DeviceKey);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, $"Getting display with key {DisplayDeviceKey}");
|
||||
DisplayDevice = GetDisplayBaseFromDevice(DisplayDeviceKey);
|
||||
|
||||
if (DisplayDevice != null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, $"Subscribing to {DisplayDeviceKey} feedbacks");
|
||||
|
||||
DisplayDevice.IsWarmingUpFeedback.OutputChange += IsWarmingUpFeedback_OutputChange;
|
||||
DisplayDevice.IsCoolingDownFeedback.OutputChange += IsCoolingDownFeedback_OutputChange;
|
||||
}
|
||||
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
public void Raise()
|
||||
{
|
||||
if (RaiseRelay == null && LatchedRelay == null) return;
|
||||
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, $"Raising {Type}");
|
||||
|
||||
switch (Mode)
|
||||
{
|
||||
case eScreenLiftControlMode.momentary:
|
||||
{
|
||||
PulseOutput(RaiseRelay, RaiseRelayConfig.PulseTimeInMs);
|
||||
break;
|
||||
}
|
||||
case eScreenLiftControlMode.latched:
|
||||
{
|
||||
LatchedRelay.Off();
|
||||
break;
|
||||
}
|
||||
}
|
||||
InUpPosition = true;
|
||||
}
|
||||
|
||||
public void Lower()
|
||||
{
|
||||
if (LowerRelay == null && LatchedRelay == null) return;
|
||||
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, $"Lowering {Type}");
|
||||
|
||||
switch (Mode)
|
||||
{
|
||||
case eScreenLiftControlMode.momentary:
|
||||
{
|
||||
PulseOutput(LowerRelay, LowerRelayConfig.PulseTimeInMs);
|
||||
break;
|
||||
}
|
||||
case eScreenLiftControlMode.latched:
|
||||
{
|
||||
LatchedRelay.On();
|
||||
break;
|
||||
}
|
||||
}
|
||||
InUpPosition = false;
|
||||
}
|
||||
|
||||
void PulseOutput(ISwitchedOutput output, int pulseTime)
|
||||
{
|
||||
output.On();
|
||||
CTimer pulseTimer = new CTimer(new CTimerCallbackFunction((o) => output.Off()), pulseTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to get the port on teh specified device from config
|
||||
/// </summary>
|
||||
/// <param name="relayConfig"></param>
|
||||
/// <returns></returns>
|
||||
ISwitchedOutput GetSwitchedOutputFromDevice(string relayKey)
|
||||
{
|
||||
var portDevice = DeviceManager.GetDeviceForKey(relayKey);
|
||||
if (portDevice != null)
|
||||
{
|
||||
return (portDevice as ISwitchedOutput);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Error: Unable to get relay device with key '{0}'", relayKey);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Displays.DisplayBase GetDisplayBaseFromDevice(string displayKey)
|
||||
{
|
||||
var displayDevice = DeviceManager.GetDeviceForKey(displayKey);
|
||||
if (displayDevice != null)
|
||||
{
|
||||
return displayDevice as Displays.DisplayBase;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Error: Unable to get display device with key '{0}'", displayKey);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ScreenLiftControllerConfigProperties
|
||||
{
|
||||
[JsonProperty("displayDeviceKey")]
|
||||
public string DisplayDeviceKey { get; set; }
|
||||
|
||||
[JsonProperty("type")]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public eScreenLiftControlType Type { get; set; }
|
||||
|
||||
[JsonProperty("mode")]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public eScreenLiftControlMode Mode { get; set; }
|
||||
|
||||
[JsonProperty("relays")]
|
||||
public Dictionary<string,ScreenLiftRelaysConfig> Relays { get; set; }
|
||||
|
||||
}
|
||||
public class ScreenLiftRelaysConfig
|
||||
{
|
||||
[JsonProperty("deviceKey")]
|
||||
public string DeviceKey { get; set; }
|
||||
|
||||
[JsonProperty("pulseTimeInMs")]
|
||||
public int PulseTimeInMs { get; set; }
|
||||
}
|
||||
|
||||
public class ScreenLiftControllerFactory : EssentialsDeviceFactory<RelayControlledShade>
|
||||
{
|
||||
public ScreenLiftControllerFactory()
|
||||
{
|
||||
TypeNames = new List<string>() { "screenliftcontroller" };
|
||||
}
|
||||
|
||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Comm Device");
|
||||
var props = Newtonsoft.Json.JsonConvert.DeserializeObject<ScreenLiftControllerConfigProperties>(dc.Properties.ToString());
|
||||
|
||||
return new ScreenLiftController(dc.Key, dc.Name, props);
|
||||
}
|
||||
}
|
||||
|
||||
public enum eScreenLiftControlMode
|
||||
{
|
||||
momentary,
|
||||
latched
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user