Minor Fixes to CrestronGenericBaseDevice

Update StatusSignController constructor and factory to build device in PreActivation phase

Addresses #292
This commit is contained in:
Trevor Payne
2020-06-30 15:05:42 -05:00
parent f954043981
commit b694f7640a
2 changed files with 69 additions and 46 deletions

View File

@@ -12,13 +12,12 @@ using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.Core.CrestronIO
{
[Description("Wrapper class for the C2N-RTHS sensor")]
public class C2nRthsController : CrestronGenericBridgeableBaseDevice, IOnline
public class C2nRthsController : CrestronGenericBridgeableBaseDevice
{
private C2nRths _device;
public IntFeedback TemperatureFeedback { get; private set; }
public IntFeedback HumidityFeedback { get; private set; }
public BoolFeedback IsOnline { get; private set; }
public C2nRthsController(string key, Func<DeviceConfig, C2nRths> preActivationFunc,
DeviceConfig config)
@@ -33,18 +32,11 @@ namespace PepperDash.Essentials.Core.CrestronIO
TemperatureFeedback = new IntFeedback(() => _device.TemperatureFeedback.UShortValue);
HumidityFeedback = new IntFeedback(() => _device.HumidityFeedback.UShortValue);
IsOnline = new BoolFeedback(() => _device.IsOnline);
if (_device != null) _device.BaseEvent += DeviceOnBaseEvent;
if (_device != null) _device.OnlineStatusChange += _device_OnlineStatusChange;
});
}
void _device_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
{
IsOnline.FireUpdate();
}
private void DeviceOnBaseEvent(GenericBase device, BaseEventArgs args)
{
@@ -149,9 +141,6 @@ namespace PepperDash.Essentials.Core.CrestronIO
{
Debug.Console(1, "Factory Attempting to create new C2N-RTHS Device");
var control = CommFactory.GetControlPropertiesConfig(dc);
var cresnetId = control.CresnetIdInt;
return new C2nRthsController(dc.Key, GetC2nRthsDevice, dc);
}
}