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:
Neil Dorin
2018-05-03 10:23:30 -06:00
parent 33f0a1fe32
commit b44613b91f
9 changed files with 196 additions and 32 deletions

View File

@@ -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
}
}

View File

@@ -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; }
}
}

View File

@@ -109,6 +109,7 @@
<Compile Include="Crestron IO\Inputs\IDigitalInput.cs" />
<Compile Include="Crestron IO\IOPortConfig.cs" />
<Compile Include="Crestron IO\Relay\GenericRelayDevice.cs" />
<Compile Include="Crestron IO\Relay\ISwitchedOutput.cs" />
<Compile Include="Devices\CodecInterfaces.cs" />
<Compile Include="Global\JobTimer.cs" />
<Compile Include="Lighting\Lighting Interfaces.cs" />
@@ -183,6 +184,7 @@
<Compile Include="Routing\RoutingPortNames.cs" />
<Compile Include="Routing\TieLineConfig.cs" />
<Compile Include="Shades\Shade Interfaces.cs" />
<Compile Include="Shades\ShadeBase.cs" />
<Compile Include="Shades\ShadeController.cs" />
<Compile Include="SmartObjects\SmartObjectNumeric.cs" />
<Compile Include="SmartObjects\SmartObjectDynamicList.cs" />

View File

@@ -16,8 +16,8 @@ namespace PepperDash.Essentials.Core.Shades
/// </summary>
public interface iShadesRaiseLower
{
void Raise();
void Lower();
void Open();
void Stop();
void Close();
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core.CrestronIO;
namespace PepperDash.Essentials.Core.Shades
{
public abstract class ShadeBase : Device, iShadesRaiseLower
{
public ISwitchedOutput SwitchedOutput;
public ShadeBase(string key, string name)
: base(key, name)
{
}
#region iShadesRaiseLower Members
public abstract void Open();
public abstract void Stop();
public abstract void Close();
#endregion
}
}

View File

@@ -10,24 +10,14 @@ namespace PepperDash.Essentials.Core.Shades
{
public class ShadeController : Device, IShades
{
public List<ShadeBase> IShades.Shades { get; private set; }
public List<ShadeBase> Shades { get; private set; }
}
public abstract class ShadeBase : Device, iShadesRaiseLower
{
public ShadeBase(string key, string name)
public ShadeController(string key, string name)
: base(key, name)
{
Shades = new List<ShadeBase>();
}
#region iShadesRaiseLower Members
public void iShadesRaiseLower.Raise();
public void iShadesRaiseLower.Lower();
public void iShadesRaiseLower.Stop();
#endregion
}
}