Changes to CrestronGenericBridgeableBaseDevice and CrestronGenericBaseDevice to allow it to take a func<DeviceConfig, GenericBase> in an overloaded constructor

Addresses #292
This commit is contained in:
Trevor Payne
2020-06-30 14:46:46 -05:00
parent f6286cb5c1
commit 495bf70d3a
2 changed files with 28 additions and 2 deletions

View File

@@ -18,7 +18,8 @@ namespace PepperDash.Essentials.Core.CrestronIO
public IntFeedback TemperatureFeedback { get; private set; }
public IntFeedback HumidityFeedback { get; private set; }
public C2nRthsController(string key, string name, GenericBase hardware) : base(key, name, hardware)
public C2nRthsController(string key, string name, GenericBase hardware)
: base(key, name, hardware)
{
_device = hardware as C2nRths;

View File

@@ -1,7 +1,9 @@
using System.Linq;
using System;
using System.Linq;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Core.JsonStandardObjects;
using PepperDash.Essentials.Core.Bridges;
namespace PepperDash.Essentials.Core
@@ -42,6 +44,24 @@ namespace PepperDash.Essentials.Core
CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, hardware, 120000, 300000);
}
protected CrestronGenericBaseDevice(string key, string name)
: base(key, name)
{
Feedbacks = new FeedbackCollection<Feedback>();
}
protected void RegisterCrestronGenericBase(GenericBase hardware)
{
Hardware = hardware;
IsOnline = new BoolFeedback("IsOnlineFeedback", () => Hardware.IsOnline);
IsRegistered = new BoolFeedback("IsRegistered", () => Hardware.Registered);
IpConnectionsText = new StringFeedback("IpConnectionsText", () => Hardware.ConnectedIpList != null ? string.Join(",", Hardware.ConnectedIpList.Select(cip => cip.DeviceIpAddress).ToArray()) : string.Empty);
AddToFeedbackList(IsOnline, IpConnectionsText);
CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, hardware, 120000, 300000);
}
/// <summary>
/// Make sure that overriding classes call this!
/// Registers the Crestron device, connects up to the base events, starts communication monitor
@@ -135,6 +155,11 @@ namespace PepperDash.Essentials.Core
{
}
protected CrestronGenericBridgeableBaseDevice(string key, string name)
: base(key, name)
{
}
public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge);
}