diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3CardControllerBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3CardControllerBase.cs index cb9667cf..bfb81acd 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3CardControllerBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3CardControllerBase.cs @@ -1,16 +1,24 @@ -using Crestron.SimplSharpPro; +using System; using Crestron.SimplSharpProInternal; -using PepperDash.Essentials.Core; -namespace PepperDash_Essentials_Core.Crestron_IO.Cards +namespace PepperDash.Essentials.Core.CrestronIO.Cards { public class C3CardControllerBase:CrestronGenericBaseDevice { - private C3Card _card; + private readonly C3Card _card; public C3CardControllerBase(string key, string name, C3Card hardware) : base(key, name, hardware) { _card = hardware; } + + #region Overrides of Object + + public override string ToString() + { + return String.Format("{0} {1}", Key, _card.ToString()); + } + + #endregion } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Com3Controller.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Com3Controller.cs index 9e649a52..9658b2bb 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Com3Controller.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Com3Controller.cs @@ -1,15 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.ThreeSeriesCards; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -namespace PepperDash_Essentials_Core.Crestron_IO.Cards +namespace PepperDash.Essentials.Core.CrestronIO.Cards { public class C3Com3Controller:C3CardControllerBase, IComPorts { diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Io16Controller.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Io16Controller.cs new file mode 100644 index 00000000..bdf4742d --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Io16Controller.cs @@ -0,0 +1,29 @@ +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.ThreeSeriesCards; + +namespace PepperDash.Essentials.Core.CrestronIO.Cards +{ + public class C3Io16Controller:C3CardControllerBase,IIOPorts + { + private readonly C3io16 _card; + + public C3Io16Controller(string key, string name, C3io16 hardware) : base(key, name, hardware) + { + _card = hardware; + } + + #region Implementation of IIOPorts + + public CrestronCollection VersiPorts + { + get { return _card.VersiPorts; } + } + + public int NumberOfVersiPorts + { + get { return _card.NumberOfVersiPorts; } + } + + #endregion + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ir8Controller.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ir8Controller.cs new file mode 100644 index 00000000..c35d2038 --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ir8Controller.cs @@ -0,0 +1,29 @@ +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.ThreeSeriesCards; + +namespace PepperDash.Essentials.Core.CrestronIO.Cards +{ + public class C3Ir8Controller:C3CardControllerBase, IIROutputPorts + { + private readonly C3ir8 _card; + + public C3Ir8Controller(string key, string name, C3ir8 hardware) : base(key, name, hardware) + { + _card = hardware; + } + + #region Implementation of IIROutputPorts + + public CrestronCollection IROutputPorts + { + get { return _card.IROutputPorts; } + } + + public int NumberOfIROutputPorts + { + get { return _card.NumberOfIROutputPorts; } + } + + #endregion + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ry16Controller.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ry16Controller.cs new file mode 100644 index 00000000..a68ecaf0 --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ry16Controller.cs @@ -0,0 +1,29 @@ +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.ThreeSeriesCards; + +namespace PepperDash.Essentials.Core.CrestronIO.Cards +{ + public class C3Ry16Controller:C3CardControllerBase, IRelayPorts + { + private readonly C3ry16 _card; + + public C3Ry16Controller(string key, string name, C3ry16 hardware) : base(key, name, hardware) + { + _card = hardware; + } + + #region Implementation of IRelayPorts + + public CrestronCollection RelayPorts + { + get { return _card.RelayPorts; } + } + + public int NumberOfRelayPorts + { + get { return _card.NumberOfRelayPorts; } + } + + #endregion + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ry8Controller.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ry8Controller.cs new file mode 100644 index 00000000..158c04ca --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/C3Ry8Controller.cs @@ -0,0 +1,29 @@ +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.ThreeSeriesCards; + +namespace PepperDash.Essentials.Core.CrestronIO.Cards +{ + public class C3Ry8Controller:C3CardControllerBase, IRelayPorts + { + private readonly C3ry8 _card; + + public C3Ry8Controller(string key, string name, C3ry8 hardware) : base(key, name, hardware) + { + _card = hardware + } + + #region Implementation of IRelayPorts + + public CrestronCollection RelayPorts + { + get { return _card.RelayPorts; } + } + + public int NumberOfRelayPorts + { + get { return _card.NumberOfRelayPorts; } + } + + #endregion + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/CenCi31Controller.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/CenCi31Controller.cs index 0c16e876..ddd58e63 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/CenCi31Controller.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Cards/CenCi31Controller.cs @@ -1,31 +1,26 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.ThreeSeriesCards; -using Crestron.SimplSharpProInternal; using Newtonsoft.Json; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; +using PepperDash.Core; using PepperDash.Essentials.Core.Config; -namespace PepperDash_Essentials_Core.Crestron_IO.Cards +namespace PepperDash.Essentials.Core.CrestronIO.Cards { - public class CenCi31Controller :CrestronGenericBridgeableBaseDevice + public class CenCi31Controller : CrestronGenericBaseDevice { private const string CardKeyTemplate = "{0}-card{1}"; + private const uint CardSlot = 1; private readonly CenCi31 _cardCage; - private CenCi3Configuration _config; + private readonly CenCi31Configuration _config; - private Dictionary> _cardDict; + private readonly Dictionary> _cardDict; - public CenCi31Controller(string key, string name, DeviceConfig config, CenCi31 hardware) : base(key, name, hardware) + public CenCi31Controller(string key, string name, CenCi31Configuration config, CenCi31 hardware) : base(key, name, hardware) { _cardCage = hardware; - _config = config.Properties.ToObject(); + + _config = config; _cardDict = new Dictionary> { @@ -37,29 +32,57 @@ namespace PepperDash_Essentials_Core.Crestron_IO.Cards }, }; + GetCards(); } private void GetCards() { - foreach (var card in _config.Cards) + Func cardBuilder; + + if (String.IsNullOrEmpty(_config.Card)) { } + + if (!_cardDict.TryGetValue(_config.Card, out cardBuilder)) + { + Debug.Console(0, "Unable to find factory for 3-Series card type {0}.", _config.Card); + return; + } + + var device = cardBuilder(_cardCage, CardSlot); + + DeviceManager.AddDevice(device); } + } - #region Overrides of CrestronGenericBridgeableBaseDevice + public class CenCi31Configuration + { + [JsonProperty("card")] + public string Card { get; set; } + } - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + public class CenCi3ControllerFactory : EssentialsDeviceFactory + { + public CenCi3ControllerFactory() { - throw new NotImplementedException(); + TypeNames = new List {"cenci31"}; + } + #region Overrides of EssentialsDeviceFactory + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory attempting to build new CEN-CI-1"); + + var controlProperties = CommFactory.GetControlPropertiesConfig(dc); + var ipId = controlProperties.IpIdInt; + + var cardCage = new CenCi31(ipId, Global.ControlSystem); + var config = dc.Properties.ToObject(); + + return new CenCi31Controller(dc.Key, dc.Name, config, cardCage); } #endregion } - - public class CenCi3Configuration - { - [JsonProperty("cards")] - public Dictionary Cards { get; set; } - } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index 153b6ad5..bf59a449 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -74,6 +74,10 @@ False ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Remotes.dll + + False + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.ThreeSeriesCards.dll + False ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll @@ -156,6 +160,13 @@ + + + + + + +