mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-26 10:54:59 +00:00
Compare commits
20 Commits
2.0.0-alph
...
2.0.0-alph
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e736ae519 | ||
|
|
0067e11d3d | ||
|
|
7942c91f73 | ||
|
|
e1638762a1 | ||
|
|
3566400379 | ||
|
|
dde85f39a2 | ||
|
|
735433f660 | ||
|
|
734149960b | ||
|
|
cb16f2a505 | ||
|
|
cb9eb5dafa | ||
|
|
eb955aa014 | ||
|
|
2d9ffca78e | ||
|
|
98f1a09c25 | ||
|
|
a11ad421f0 | ||
|
|
8878ff7ddd | ||
|
|
7e4b5f984f | ||
|
|
64ab315142 | ||
|
|
c47a93f4d0 | ||
|
|
01862ab9aa | ||
|
|
8ec6fa785e |
@@ -1,15 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.Net.Http;
|
||||
using Crestron.SimplSharp.Net.Http;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Core.DebugThings;
|
||||
using System;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
[Obsolete("Please use the builtin HttpClient class instead: https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines")]
|
||||
[Obsolete("Please use the builtin HttpClient class instead: https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines")]
|
||||
public class GenericHttpClient : Device, IBasicCommunication
|
||||
{
|
||||
public HttpClient Client;
|
||||
|
||||
@@ -23,7 +23,10 @@ namespace PepperDash.Essentials.Core.Config
|
||||
public Dictionary<string, Dictionary<string, SourceListItem>> SourceLists { get; set; }
|
||||
|
||||
[JsonProperty("destinationLists")]
|
||||
public Dictionary<string, Dictionary<string,DestinationListItem>> DestinationLists { get; set; }
|
||||
public Dictionary<string, Dictionary<string, DestinationListItem>> DestinationLists { get; set; }
|
||||
|
||||
[JsonProperty("levelControlLists")]
|
||||
public Dictionary<string, Dictionary<string, LevelControlListItem>> LevelControlLists { get; set; }
|
||||
|
||||
[JsonProperty("tieLines")]
|
||||
public List<TieLineConfig> TieLines { get; set; }
|
||||
@@ -37,6 +40,7 @@ namespace PepperDash.Essentials.Core.Config
|
||||
Devices = new List<DeviceConfig>();
|
||||
SourceLists = new Dictionary<string, Dictionary<string, SourceListItem>>();
|
||||
DestinationLists = new Dictionary<string, Dictionary<string, DestinationListItem>>();
|
||||
LevelControlLists = new Dictionary<string, Dictionary<string, LevelControlListItem>>();
|
||||
TieLines = new List<TieLineConfig>();
|
||||
JoinMaps = new Dictionary<string, JObject>();
|
||||
}
|
||||
@@ -55,8 +59,8 @@ namespace PepperDash.Essentials.Core.Config
|
||||
/// <summary>
|
||||
/// Retrieves a DestinationListItem based on the key
|
||||
/// </summary>
|
||||
/// <param name="key">key of the item to retrieve</param>
|
||||
/// <returns>DestinationListItem if the key exists, null otherwise</returns>
|
||||
/// <param name="key">key of the list to retrieve</param>
|
||||
/// <returns>DestinationList if the key exists, null otherwise</returns>
|
||||
public Dictionary<string, DestinationListItem> GetDestinationListForKey(string key)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key) || !DestinationLists.ContainsKey(key))
|
||||
@@ -67,6 +71,19 @@ namespace PepperDash.Essentials.Core.Config
|
||||
return DestinationLists[key];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a LevelControlList based on the key
|
||||
/// </summary>
|
||||
/// <param name="key">key of the list to retrieve</param>
|
||||
/// <returns>LevelControlList if the key exists, null otherwise</returns>
|
||||
public Dictionary<string, LevelControlListItem> GetLevelControlListForKey(string key)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key) || !LevelControlLists.ContainsKey(key))
|
||||
return null;
|
||||
|
||||
return LevelControlLists[key];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks Devices for an item with a Key that matches and returns it if found. Otherwise, retunes null
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public class LevelControlListItem
|
||||
{
|
||||
[JsonProperty("deviceKey")]
|
||||
public string DeviceKey { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public IBasicVolumeWithFeedback LevelControl
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_levelControl == null)
|
||||
_levelControl = DeviceManager.GetDeviceForKey(DeviceKey) as IBasicVolumeWithFeedback;
|
||||
return _levelControl;
|
||||
}
|
||||
}
|
||||
IBasicVolumeWithFeedback _levelControl;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name from the device if it implements IKeyName or else returns the Name property
|
||||
/// </summary>
|
||||
[JsonProperty("preferredName")]
|
||||
public string PreferredName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Name)) return Name;
|
||||
else
|
||||
{
|
||||
if (LevelControl is IKeyName namedLevelControl)
|
||||
{
|
||||
if (namedLevelControl == null)
|
||||
return "---";
|
||||
return namedLevelControl.Name;
|
||||
}
|
||||
else return "---";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A name that will override the items's name on the UI
|
||||
/// </summary>
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the item should be included in the user accessible list
|
||||
/// </summary>
|
||||
[JsonProperty("includeInUserList")]
|
||||
public bool IncludeInUserList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to specify the order of the items in the source list when displayed
|
||||
/// </summary>
|
||||
[JsonProperty("order")]
|
||||
public int Order { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the item is a level, mute , or both
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||
public eLevelControlType Type { get; set; }
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum eLevelControlType
|
||||
{
|
||||
Level = 0,
|
||||
Mute = 1,
|
||||
LevelAndMute = Level | Mute,
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
@@ -17,7 +18,7 @@ namespace PepperDash.Essentials.Core
|
||||
{
|
||||
private IPartitionStateProvider _partitionSensor;
|
||||
|
||||
private bool isInAutoMode;
|
||||
public bool IsInAutoMode { get; private set; }
|
||||
|
||||
private bool _partitionPresent;
|
||||
|
||||
@@ -64,7 +65,7 @@ namespace PepperDash.Essentials.Core
|
||||
SetManualMode();
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
SetManualMode();
|
||||
}
|
||||
@@ -74,7 +75,7 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
void PartitionPresentFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||
{
|
||||
if (isInAutoMode)
|
||||
if (IsInAutoMode)
|
||||
{
|
||||
PartitionPresentFeedback.FireUpdate();
|
||||
}
|
||||
@@ -86,7 +87,7 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public void SetAutoMode()
|
||||
{
|
||||
isInAutoMode = true;
|
||||
IsInAutoMode = true;
|
||||
if (PartitionPresentFeedback != null)
|
||||
{
|
||||
PartitionPresentFeedback.SetValueFunc(() => _partitionSensor.PartitionPresentFeedback.BoolValue);
|
||||
@@ -98,13 +99,14 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
if (_partitionSensor != null)
|
||||
{
|
||||
_partitionSensor.PartitionPresentFeedback.OutputChange -= PartitionPresentFeedback_OutputChange;
|
||||
_partitionSensor.PartitionPresentFeedback.OutputChange += PartitionPresentFeedback_OutputChange;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetManualMode()
|
||||
{
|
||||
isInAutoMode = false;
|
||||
IsInAutoMode = false;
|
||||
if (PartitionPresentFeedback != null)
|
||||
{
|
||||
PartitionPresentFeedback.SetValueFunc(() => _partitionPresent);
|
||||
@@ -123,7 +125,7 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public void SetPartitionStatePresent()
|
||||
{
|
||||
if (!isInAutoMode)
|
||||
if (!IsInAutoMode)
|
||||
{
|
||||
PartitionPresent = true;
|
||||
PartitionPresentFeedback.FireUpdate();
|
||||
@@ -132,7 +134,7 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public void SetPartitionStateNotPresent()
|
||||
{
|
||||
if (!isInAutoMode)
|
||||
if (!IsInAutoMode)
|
||||
{
|
||||
PartitionPresent = false;
|
||||
PartitionPresentFeedback.FireUpdate();
|
||||
@@ -141,7 +143,10 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public void ToggglePartitionState()
|
||||
{
|
||||
if (!isInAutoMode)
|
||||
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, $"Toggling Partition State for {Key}", this);
|
||||
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, $"IsInAutoMode: {IsInAutoMode}", this);
|
||||
|
||||
if (!IsInAutoMode)
|
||||
{
|
||||
PartitionPresent = !PartitionPresent;
|
||||
PartitionPresentFeedback.FireUpdate();
|
||||
|
||||
@@ -24,6 +24,9 @@ namespace PepperDash.Essentials.Core
|
||||
[JsonProperty("adjacentRoomKeys")]
|
||||
List<string> AdjacentRoomKeys { get; }
|
||||
|
||||
[JsonProperty("isInAutoMode")]
|
||||
bool IsInAutoMode { get; }
|
||||
|
||||
void SetPartitionStatePresent();
|
||||
|
||||
void SetPartitionStateNotPresent();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.20.42" />
|
||||
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-402" />
|
||||
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-407" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Crestron\CrestronGenericBaseDevice.cs.orig" />
|
||||
|
||||
@@ -137,7 +137,11 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
void StartDebounceTimer()
|
||||
{
|
||||
var time = _scenarioChangeDebounceTimeSeconds * 1000;
|
||||
// default to 500ms for manual mode
|
||||
var time = 500;
|
||||
|
||||
// if in auto mode, debounce the scenario change
|
||||
if(IsInAutoMode) time = _scenarioChangeDebounceTimeSeconds * 1000;
|
||||
|
||||
if (_scenarioChangeDebounceTimer == null)
|
||||
{
|
||||
@@ -211,7 +215,7 @@ namespace PepperDash.Essentials.Core
|
||||
{
|
||||
_currentScenario.Activate();
|
||||
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Current Scenario: {0}", _currentScenario.Name);
|
||||
Debug.LogMessage(LogEventLevel.Debug, $"Current Scenario: {_currentScenario.Name}", this);
|
||||
}
|
||||
|
||||
var handler = RoomCombinationScenarioChanged;
|
||||
@@ -246,7 +250,7 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public void TogglePartitionState(string partitionKey)
|
||||
{
|
||||
var partition = Partitions.FirstOrDefault((p) => p.Key.Equals(partitionKey)) as IPartitionController;
|
||||
var partition = Partitions.FirstOrDefault((p) => p.Key.Equals(partitionKey));
|
||||
|
||||
if (partition != null)
|
||||
{
|
||||
|
||||
@@ -198,6 +198,9 @@ namespace PepperDash.Essentials.Room.Config
|
||||
public string SourceListKey { get; set; }
|
||||
[JsonProperty("destinationListKey")]
|
||||
public string DestinationListKey { get; set; }
|
||||
[JsonProperty("levelControlListKey")]
|
||||
public string LevelControlListKey { get; set; }
|
||||
|
||||
[JsonProperty("defaultSourceItem")]
|
||||
public string DefaultSourceItem { get; set; }
|
||||
/// <summary>
|
||||
|
||||
@@ -59,28 +59,81 @@ namespace PepperDash.Essentials.Core
|
||||
/// </summary>
|
||||
public IMobileControlRoomMessenger MobileControlRoomBridge { get; private set; }
|
||||
|
||||
protected const string _defaultListKey = "default";
|
||||
|
||||
/// <summary>
|
||||
/// The config name of the source list
|
||||
/// </summary>
|
||||
///
|
||||
protected string _SourceListKey;
|
||||
private string _sourceListKey;
|
||||
public string SourceListKey {
|
||||
get
|
||||
{
|
||||
return _SourceListKey;
|
||||
}
|
||||
private set
|
||||
{
|
||||
if (value != _SourceListKey)
|
||||
if(string.IsNullOrEmpty(_sourceListKey))
|
||||
{
|
||||
_SourceListKey = value;
|
||||
return _defaultListKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _sourceListKey;
|
||||
}
|
||||
}
|
||||
protected set
|
||||
{
|
||||
if (value != _sourceListKey)
|
||||
{
|
||||
_sourceListKey = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string DestinationListKey { get; private set; }
|
||||
private string _destinationListKey;
|
||||
public string DestinationListKey
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_destinationListKey))
|
||||
{
|
||||
return _defaultListKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _destinationListKey;
|
||||
}
|
||||
}
|
||||
protected set
|
||||
{
|
||||
if (value != _destinationListKey)
|
||||
{
|
||||
_destinationListKey = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _levelControlListKey;
|
||||
public string LevelControlListKey
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_levelControlListKey))
|
||||
{
|
||||
return _defaultListKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _destinationListKey;
|
||||
}
|
||||
}
|
||||
protected set
|
||||
{
|
||||
if (value != _levelControlListKey)
|
||||
{
|
||||
_levelControlListKey = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected const string _defaultSourceListKey = "default";
|
||||
|
||||
/// <summary>
|
||||
/// Timer used for informing the UIs of a shutdown
|
||||
@@ -141,6 +194,7 @@ namespace PepperDash.Essentials.Core
|
||||
if (!ShutdownPromptTimer.IsRunningFeedback.BoolValue)
|
||||
ShutdownType = eShutdownType.None;
|
||||
};
|
||||
|
||||
ShutdownPromptTimer.HasFinished += (o, a) => Shutdown(); // Shutdown is triggered
|
||||
|
||||
ShutdownPromptSeconds = 60;
|
||||
@@ -191,7 +245,7 @@ namespace PepperDash.Essentials.Core
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceListKey = _defaultSourceListKey;
|
||||
sourceListKey = _defaultListKey;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
string DestinationListKey { get; }
|
||||
|
||||
string LevelControlListKey { get; }
|
||||
|
||||
SecondsCountdownTimer ShutdownPromptTimer { get; }
|
||||
int ShutdownPromptSeconds { get; }
|
||||
int ShutdownVacancySeconds { get; }
|
||||
|
||||
@@ -159,4 +159,13 @@ namespace PepperDash.Essentials.Core
|
||||
Core.Privacy.MicrophonePrivacyController MicrophonePrivacy { get; }
|
||||
}
|
||||
|
||||
public interface IHasAccessoryDevices : IKeyName
|
||||
{
|
||||
List<string> AccessoryDeviceKeys { get; }
|
||||
}
|
||||
|
||||
public interface IHasCiscoNavigatorTouchpanel
|
||||
{
|
||||
string CiscoNavigatorTouchpanelKey { get; }
|
||||
}
|
||||
}
|
||||
@@ -52,8 +52,8 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
var timeSpan = FinishTime - DateTime.Now;
|
||||
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this,
|
||||
"timeSpan.Minutes == {0}, timeSpan.Seconds == {1}, timeSpan.TotalSeconds == {2}",
|
||||
Debug.LogMessage(LogEventLevel.Verbose,
|
||||
"timeSpan.Minutes == {0}, timeSpan.Seconds == {1}, timeSpan.TotalSeconds == {2}", this,
|
||||
timeSpan.Minutes, timeSpan.Seconds, timeSpan.TotalSeconds);
|
||||
|
||||
if (Math.Floor(timeSpan.TotalSeconds) < 60 && Math.Floor(timeSpan.TotalSeconds) >= 0) //ignore milliseconds
|
||||
@@ -103,6 +103,7 @@ namespace PepperDash.Essentials.Core
|
||||
public void Reset()
|
||||
{
|
||||
_isRunning = false;
|
||||
IsRunningFeedback.FireUpdate();
|
||||
Start();
|
||||
}
|
||||
|
||||
@@ -133,7 +134,11 @@ namespace PepperDash.Essentials.Core
|
||||
void StopHelper()
|
||||
{
|
||||
if (_secondTimer != null)
|
||||
{
|
||||
_secondTimer.Stop();
|
||||
_secondTimer = null;
|
||||
}
|
||||
|
||||
_isRunning = false;
|
||||
IsRunningFeedback.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;
|
||||
@@ -120,7 +121,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays
|
||||
// Fake cool-down cycle
|
||||
CooldownTimer = new CTimer(o =>
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "Cooldown timer ending");
|
||||
Debug.LogMessage(LogEventLevel.Verbose, "Cooldown timer ending", this);
|
||||
_IsCoolingDown = false;
|
||||
IsCoolingDownFeedback.InvokeFireUpdate();
|
||||
_PowerIsOn = false;
|
||||
@@ -141,10 +142,10 @@ namespace PepperDash.Essentials.Devices.Common.Displays
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "ExecuteSwitch: {0}", selector);
|
||||
|
||||
if (!_PowerIsOn)
|
||||
{
|
||||
PowerOn();
|
||||
}
|
||||
if (!_PowerIsOn)
|
||||
{
|
||||
PowerOn();
|
||||
}
|
||||
|
||||
if (!Inputs.Items.TryGetValue(selector.ToString(), out var input))
|
||||
return;
|
||||
@@ -152,32 +153,6 @@ namespace PepperDash.Essentials.Devices.Common.Displays
|
||||
input.Select();
|
||||
}
|
||||
|
||||
public void SetInput(string selector)
|
||||
{
|
||||
ISelectableItem currentInput = null;
|
||||
|
||||
try
|
||||
{
|
||||
currentInput = Inputs.Items.SingleOrDefault(Inputs => Inputs.Value.IsSelected).Value;
|
||||
}
|
||||
catch { }
|
||||
|
||||
|
||||
if (currentInput != null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "SetInput: {0}", selector);
|
||||
currentInput.IsSelected = false;
|
||||
}
|
||||
|
||||
if (!Inputs.Items.TryGetValue(selector, out var input))
|
||||
return;
|
||||
|
||||
input.IsSelected = true;
|
||||
|
||||
Inputs.CurrentItem = selector;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region IBasicVolumeWithFeedback Members
|
||||
|
||||
@@ -251,4 +226,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,12 @@ namespace PepperDash.Essentials.Devices.Common.Displays
|
||||
|
||||
public void Select()
|
||||
{
|
||||
_parent.SetInput(Key);
|
||||
if (!_parent.PowerIsOnFeedback.BoolValue) _parent.PowerOn();
|
||||
|
||||
foreach(var input in _parent.Inputs.Items)
|
||||
{
|
||||
input.Value.IsSelected = input.Key == this.Key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.20.42" />
|
||||
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-402" />
|
||||
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-407" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -47,7 +47,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Crestron.SimplSharp.SDK.Program" Version="2.20.42" />
|
||||
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-402" />
|
||||
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-407" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj" />
|
||||
|
||||
Reference in New Issue
Block a user