diff --git a/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs b/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs
index a169cab1..6856be6e 100644
--- a/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs
+++ b/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs
@@ -12,24 +12,16 @@ namespace PepperDash.Essentials.Core.CrestronIO
///
/// Represents a generic device controlled by relays
///
- public class GenericRelayDevice : Device
+ public class GenericRelayDevice : Device, ISwitchedOutput
{
public Relay RelayOutput { get; private set; }
- public BoolFeedback RelayStateFeedback { get; private set; }
-
- Func 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(() => 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
}
}
\ No newline at end of file
diff --git a/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/ISwitchedOutput.cs b/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/ISwitchedOutput.cs
new file mode 100644
index 00000000..09e5434a
--- /dev/null
+++ b/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/ISwitchedOutput.cs
@@ -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
+{
+ ///
+ /// Describes an output capable of switching on and off
+ ///
+ public interface ISwitchedOutput
+ {
+ BoolFeedback OutputIsOnFeedback {get;}
+
+ void On();
+ void Off();
+ }
+
+ public interface ISwitchedOutputCollection
+ {
+ Dictionary SwitchedOutputs { get; }
+ }
+}
\ No newline at end of file
diff --git a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
index 7a7e5c9f..d3b35297 100644
--- a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
+++ b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
@@ -109,6 +109,7 @@
+
@@ -183,6 +184,7 @@
+
diff --git a/Essentials Core/PepperDashEssentialsBase/Shades/Shade Interfaces.cs b/Essentials Core/PepperDashEssentialsBase/Shades/Shade Interfaces.cs
index 35c0b97f..57a8db23 100644
--- a/Essentials Core/PepperDashEssentialsBase/Shades/Shade Interfaces.cs
+++ b/Essentials Core/PepperDashEssentialsBase/Shades/Shade Interfaces.cs
@@ -16,8 +16,8 @@ namespace PepperDash.Essentials.Core.Shades
///
public interface iShadesRaiseLower
{
- void Raise();
- void Lower();
+ void Open();
void Stop();
+ void Close();
}
}
\ No newline at end of file
diff --git a/Essentials Core/PepperDashEssentialsBase/Shades/ShadeBase.cs b/Essentials Core/PepperDashEssentialsBase/Shades/ShadeBase.cs
new file mode 100644
index 00000000..3f3e23bb
--- /dev/null
+++ b/Essentials Core/PepperDashEssentialsBase/Shades/ShadeBase.cs
@@ -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
+ }
+}
\ No newline at end of file
diff --git a/Essentials Core/PepperDashEssentialsBase/Shades/ShadeController.cs b/Essentials Core/PepperDashEssentialsBase/Shades/ShadeController.cs
index db538fec..c5596dc2 100644
--- a/Essentials Core/PepperDashEssentialsBase/Shades/ShadeController.cs
+++ b/Essentials Core/PepperDashEssentialsBase/Shades/ShadeController.cs
@@ -10,24 +10,14 @@ namespace PepperDash.Essentials.Core.Shades
{
public class ShadeController : Device, IShades
{
- public List IShades.Shades { get; private set; }
+ public List 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();
}
- #region iShadesRaiseLower Members
-
- public void iShadesRaiseLower.Raise();
- public void iShadesRaiseLower.Lower();
- public void iShadesRaiseLower.Stop();
-
- #endregion
}
+
}
\ No newline at end of file
diff --git a/Essentials Devices Common/Essentials Devices Common/Environment/Crestron Lighting/Din8sw8.cs b/Essentials Devices Common/Essentials Devices Common/Environment/Crestron Lighting/Din8sw8.cs
index 11339513..0731dd12 100644
--- a/Essentials Devices Common/Essentials Devices Common/Environment/Crestron Lighting/Din8sw8.cs
+++ b/Essentials Devices Common/Essentials Devices Common/Environment/Crestron Lighting/Din8sw8.cs
@@ -4,24 +4,70 @@ using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
+using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.Lighting;
using PepperDash.Core;
+using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.CrestronIO;
namespace PepperDash.Essentials.Devices.Common.Environment.Lighting
{
- public class Din8sw8Controller : Device
+ public class Din8sw8Controller : Device, ISwitchedOutputCollection
{
// Need to figure out some sort of interface to make these switched outputs behave like processor relays so they can be used interchangably
public Din8Sw8 SwitchModule { get; private set; }
+
+ ///
+ /// Collection of generic switched outputs
+ ///
+ public Dictionary SwitchedOutputs;
public Din8sw8Controller(string key, string cresnetId)
: base(key)
{
-
+ SwitchedOutputs = new Dictionary();
+
+ PopulateDictionary();
}
+ ///
+ /// Populates the generic collection with the loads from the Crestron collection
+ ///
+ void PopulateDictionary()
+ {
+ foreach (var item in SwitchModule.SwitchedLoads)
+ {
+ SwitchedOutputs.Add(item.Number, new Din8sw8Output(item));
+ }
+ }
+ }
+
+ ///
+ /// Wrapper class to
+ ///
+ public class Din8sw8Output : ISwitchedOutput
+ {
+ SwitchedLoadWithOverrideParameter SwitchedOutput;
+
+ public BoolFeedback OutputIsOnFeedback { get; protected set; }
+
+ public Din8sw8Output(SwitchedLoadWithOverrideParameter switchedOutput)
+ {
+ SwitchedOutput = switchedOutput;
+
+ OutputIsOnFeedback = new BoolFeedback(new Func(() => SwitchedOutput.IsOn));
+ }
+
+ public void On()
+ {
+ SwitchedOutput.FullOn();
+ }
+
+ public void Off()
+ {
+ SwitchedOutput.FullOff();
+ }
}
}
\ No newline at end of file
diff --git a/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs b/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs
index 98814172..a98732a7 100644
--- a/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs
+++ b/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs
@@ -5,29 +5,91 @@ using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
+using PepperDash.Essentials.Core;
+using PepperDash.Essentials.Core.CrestronIO;
using PepperDash.Essentials.Core.Shades;
namespace PepperDash.Essentials.Devices.Common.Environment.Somfy
{
+ ///
+ /// Controls a single shade using three relays
+ ///
public class RelayControlledShade : ShadeBase
{
+ ISwitchedOutput OpenRelay;
+ ISwitchedOutput StopRelay;
+ ISwitchedOutput CloseRelay;
+
+ int RelayPulseTime;
public RelayControlledShade(string key, string name, RelayControlledShadeConfigProperties props)
: base(key, name)
{
+ RelayPulseTime = props.RelayPulseTime;
+ //Create ISwitchedOutput objects based on props
+ OpenRelay = GetSwitchedOutputFromDevice(props.Relays.Open);
+ StopRelay = GetSwitchedOutputFromDevice(props.Relays.Stop);
+ CloseRelay = GetSwitchedOutputFromDevice(props.Relays.Close);
}
-
- public void Raise()
+ public override void Open()
{
+ StopRelay.Off();
+ CloseRelay.Off();
+ OpenRelay.On();
+ }
+
+ public override void Stop()
+ {
+ OpenRelay.Off();
+ CloseRelay.Off();
+
+ StopRelay.On();
+ CTimer stopTimer = new CTimer(new CTimerCallbackFunction((o) => StopRelay.Off()), RelayPulseTime);
+ }
+
+ public override void Close()
+ {
+ OpenRelay.Off();
+ StopRelay.Off();
+
+ CloseRelay.On();
+ }
+
+ ///
+ /// Attempts to get the port on teh specified device from config
+ ///
+ ///
+ ///
+ ISwitchedOutput GetSwitchedOutputFromDevice(IOPortConfig relayConfig)
+ {
+ var portDevice = DeviceManager.GetDeviceForKey(relayConfig.PortDeviceKey);
+
+ if (portDevice != null)
+ {
+ return (portDevice as ISwitchedOutputCollection).SwitchedOutputs[relayConfig.PortNumber];
+ }
+ else
+ {
+ Debug.Console(1, this, "Error: Unable to get relay on port '{0}' from device with key '{1}'", relayConfig.PortNumber, relayConfig.PortDeviceKey);
+ return null;
+ }
}
}
public class RelayControlledShadeConfigProperties
{
+ public int RelayPulseTime { get; set; }
+ public ShadeRelaysConfig Relays { get; set; }
+ public class ShadeRelaysConfig
+ {
+ public IOPortConfig Open { get; set; }
+ public IOPortConfig Stop { get; set; }
+ public IOPortConfig Close { get; set; }
+ }
}
}
\ No newline at end of file
diff --git a/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs b/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs
index da03420d..f9c36b6f 100644
--- a/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs
+++ b/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs
@@ -302,6 +302,8 @@ namespace PepperDash.Essentials.Devices.Common
}
+
+
return null;
}
}