mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 20:24:57 +00:00
create classes for all supported cards
This commit is contained in:
@@ -1,16 +1,24 @@
|
|||||||
using Crestron.SimplSharpPro;
|
using System;
|
||||||
using Crestron.SimplSharpProInternal;
|
using Crestron.SimplSharpProInternal;
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
|
|
||||||
namespace PepperDash_Essentials_Core.Crestron_IO.Cards
|
namespace PepperDash.Essentials.Core.CrestronIO.Cards
|
||||||
{
|
{
|
||||||
public class C3CardControllerBase:CrestronGenericBaseDevice
|
public class C3CardControllerBase:CrestronGenericBaseDevice
|
||||||
{
|
{
|
||||||
private C3Card _card;
|
private readonly C3Card _card;
|
||||||
|
|
||||||
public C3CardControllerBase(string key, string name, C3Card hardware) : base(key, name, hardware)
|
public C3CardControllerBase(string key, string name, C3Card hardware) : base(key, name, hardware)
|
||||||
{
|
{
|
||||||
_card = hardware;
|
_card = hardware;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Overrides of Object
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return String.Format("{0} {1}", Key, _card.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,7 @@
|
|||||||
using System;
|
using Crestron.SimplSharpPro;
|
||||||
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.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
|
public class C3Com3Controller:C3CardControllerBase, IComPorts
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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<Versiport> VersiPorts
|
||||||
|
{
|
||||||
|
get { return _card.VersiPorts; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int NumberOfVersiPorts
|
||||||
|
{
|
||||||
|
get { return _card.NumberOfVersiPorts; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<IROutputPort> IROutputPorts
|
||||||
|
{
|
||||||
|
get { return _card.IROutputPorts; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int NumberOfIROutputPorts
|
||||||
|
{
|
||||||
|
get { return _card.NumberOfIROutputPorts; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<Relay> RelayPorts
|
||||||
|
{
|
||||||
|
get { return _card.RelayPorts; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int NumberOfRelayPorts
|
||||||
|
{
|
||||||
|
get { return _card.NumberOfRelayPorts; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<Relay> RelayPorts
|
||||||
|
{
|
||||||
|
get { return _card.RelayPorts; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int NumberOfRelayPorts
|
||||||
|
{
|
||||||
|
get { return _card.NumberOfRelayPorts; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,31 +1,26 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
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.SimplSharpPro.ThreeSeriesCards;
|
||||||
using Crestron.SimplSharpProInternal;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
|
||||||
using PepperDash.Essentials.Core.Config;
|
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 string CardKeyTemplate = "{0}-card{1}";
|
||||||
|
private const uint CardSlot = 1;
|
||||||
private readonly CenCi31 _cardCage;
|
private readonly CenCi31 _cardCage;
|
||||||
private CenCi3Configuration _config;
|
private readonly CenCi31Configuration _config;
|
||||||
|
|
||||||
private Dictionary<string, Func<CenCi31, uint, C3CardControllerBase>> _cardDict;
|
private readonly Dictionary<string, Func<CenCi31, uint, C3CardControllerBase>> _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;
|
_cardCage = hardware;
|
||||||
_config = config.Properties.ToObject<CenCi3Configuration>();
|
|
||||||
|
_config = config;
|
||||||
|
|
||||||
_cardDict = new Dictionary<string, Func<CenCi31, uint, C3CardControllerBase>>
|
_cardDict = new Dictionary<string, Func<CenCi31, uint, C3CardControllerBase>>
|
||||||
{
|
{
|
||||||
@@ -37,29 +32,57 @@ namespace PepperDash_Essentials_Core.Crestron_IO.Cards
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GetCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GetCards()
|
private void GetCards()
|
||||||
{
|
{
|
||||||
foreach (var card in _config.Cards)
|
Func<CenCi31, uint, C3CardControllerBase> 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<CenCi31Controller>
|
||||||
|
{
|
||||||
|
public CenCi3ControllerFactory()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
TypeNames = new List<string> {"cenci31"};
|
||||||
|
}
|
||||||
|
#region Overrides of EssentialsDeviceFactory<CenCi31Controller>
|
||||||
|
|
||||||
|
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<CenCi31Configuration>();
|
||||||
|
|
||||||
|
return new CenCi31Controller(dc.Key, dc.Name, config, cardCage);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CenCi3Configuration
|
|
||||||
{
|
|
||||||
[JsonProperty("cards")]
|
|
||||||
public Dictionary<uint, string> Cards { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -74,6 +74,10 @@
|
|||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Remotes.dll</HintPath>
|
<HintPath>..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Remotes.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Crestron.SimplSharpPro.ThreeSeriesCards, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.ThreeSeriesCards.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Crestron.SimplSharpPro.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
|
<Reference Include="Crestron.SimplSharpPro.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll</HintPath>
|
<HintPath>..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll</HintPath>
|
||||||
@@ -156,6 +160,13 @@
|
|||||||
<Compile Include="Config\Essentials\EssentialsConfig.cs" />
|
<Compile Include="Config\Essentials\EssentialsConfig.cs" />
|
||||||
<Compile Include="Config\SourceDevicePropertiesConfigBase.cs" />
|
<Compile Include="Config\SourceDevicePropertiesConfigBase.cs" />
|
||||||
<Compile Include="Crestron IO\C2nRts\C2nRthsController.cs" />
|
<Compile Include="Crestron IO\C2nRts\C2nRthsController.cs" />
|
||||||
|
<Compile Include="Crestron IO\Cards\C3CardControllerBase.cs" />
|
||||||
|
<Compile Include="Crestron IO\Cards\C3Com3Controller.cs" />
|
||||||
|
<Compile Include="Crestron IO\Cards\C3Io16Controller.cs" />
|
||||||
|
<Compile Include="Crestron IO\Cards\C3Ir8Controller.cs" />
|
||||||
|
<Compile Include="Crestron IO\Cards\C3Ry16Controller.cs" />
|
||||||
|
<Compile Include="Crestron IO\Cards\C3Ry8Controller.cs" />
|
||||||
|
<Compile Include="Crestron IO\Cards\CenCi31Controller.cs" />
|
||||||
<Compile Include="Crestron IO\Inputs\CenIoDigIn104Controller.cs" />
|
<Compile Include="Crestron IO\Inputs\CenIoDigIn104Controller.cs" />
|
||||||
<Compile Include="Crestron IO\Inputs\GenericDigitalInputDevice.cs" />
|
<Compile Include="Crestron IO\Inputs\GenericDigitalInputDevice.cs" />
|
||||||
<Compile Include="Crestron IO\Inputs\GenericVersiportInputDevice.cs" />
|
<Compile Include="Crestron IO\Inputs\GenericVersiportInputDevice.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user