mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-10 02:05:08 +00:00
Refactored method names for better consistency. Built out Din8sw8 and Din8sw8Output classes. Added logic for RelayControlledShade class to operate relays based on open/close/stop method calls
This commit is contained in:
@@ -12,24 +12,16 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
/// <summary>
|
||||
/// Represents a generic device controlled by relays
|
||||
/// </summary>
|
||||
public class GenericRelayDevice : Device
|
||||
public class GenericRelayDevice : Device, ISwitchedOutput
|
||||
{
|
||||
public Relay RelayOutput { get; private set; }
|
||||
|
||||
public BoolFeedback RelayStateFeedback { get; private set; }
|
||||
|
||||
Func<bool> RelayStateFeedbackFunc
|
||||
{
|
||||
get
|
||||
{
|
||||
return () => RelayOutput.State;
|
||||
}
|
||||
}
|
||||
public BoolFeedback OutputIsOnFeedback { get; private set; }
|
||||
|
||||
public GenericRelayDevice(string key, Relay relay):
|
||||
base(key)
|
||||
{
|
||||
RelayStateFeedback = new BoolFeedback(RelayStateFeedbackFunc);
|
||||
OutputIsOnFeedback = new BoolFeedback(new Func<bool>(() => RelayOutput.State));
|
||||
|
||||
if (relay.AvailableForUse)
|
||||
RelayOutput = relay;
|
||||
@@ -39,7 +31,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
|
||||
void RelayOutput_StateChange(Relay relay, RelayEventArgs args)
|
||||
{
|
||||
RelayStateFeedback.FireUpdate();
|
||||
OutputIsOnFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
public void OpenRelay()
|
||||
@@ -59,5 +51,19 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
else
|
||||
CloseRelay();
|
||||
}
|
||||
|
||||
#region ISwitchedOutput Members
|
||||
|
||||
void ISwitchedOutput.On()
|
||||
{
|
||||
CloseRelay();
|
||||
}
|
||||
|
||||
void ISwitchedOutput.Off()
|
||||
{
|
||||
OpenRelay();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core.CrestronIO
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes an output capable of switching on and off
|
||||
/// </summary>
|
||||
public interface ISwitchedOutput
|
||||
{
|
||||
BoolFeedback OutputIsOnFeedback {get;}
|
||||
|
||||
void On();
|
||||
void Off();
|
||||
}
|
||||
|
||||
public interface ISwitchedOutputCollection
|
||||
{
|
||||
Dictionary<uint, ISwitchedOutput> SwitchedOutputs { get; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user