Added bridge.AddJoinMap(Key, joinMap); to each LinkToApi method

This commit is contained in:
Trevor Payne 2020-05-08 10:46:23 -05:00
parent 35effa5e82
commit 04e159c1d1
22 changed files with 1620 additions and 1586 deletions

View file

@ -1,11 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.Bridges namespace PepperDash.Essentials.Core.Bridges
{ {
public class AirMediaControllerJoinMap : JoinMapBaseAdvanced public class AirMediaControllerJoinMap : JoinMapBaseAdvanced
{ {
@ -62,5 +62,5 @@ namespace PepperDash.Essentials.Core.Bridges
{ {
} }
} }
} }

View file

@ -1,10 +1,10 @@
using System.Linq; using System.Linq;
using Crestron.SimplSharp.Reflection; using Crestron.SimplSharp.Reflection;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.Bridges namespace PepperDash.Essentials.Core.Bridges
{ {
public class C2nRthsControllerJoinMap : JoinMapBaseAdvanced public class C2nRthsControllerJoinMap : JoinMapBaseAdvanced
{ {
[JoinName("IsOnline")] [JoinName("IsOnline")]
public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
@ -29,6 +29,6 @@ namespace PepperDash.Essentials.Core.Bridges
public C2nRthsControllerJoinMap(uint joinStart) public C2nRthsControllerJoinMap(uint joinStart)
: base(joinStart, typeof(C2nRthsControllerJoinMap)) : base(joinStart, typeof(C2nRthsControllerJoinMap))
{ {
} }
} }
} }

View file

@ -1,15 +1,15 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.Bridges namespace PepperDash.Essentials.Core.Bridges
{ {
public class DmpsAudioOutputControllerJoinMap : JoinMapBaseAdvanced public class DmpsAudioOutputControllerJoinMap : JoinMapBaseAdvanced
{ {
[JoinName("MasterVolumeLevel")] [JoinName("MasterVolumeLevel")]
public JoinDataComplete MasterVolumeLevel = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, public JoinDataComplete MasterVolumeLevel = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
new JoinMetadata() { Label = "Master Volume Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); new JoinMetadata() { Label = "Master Volume Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog });
@ -95,6 +95,6 @@ namespace PepperDash.Essentials.Core.Bridges
public DmpsAudioOutputControllerJoinMap(uint joinStart) public DmpsAudioOutputControllerJoinMap(uint joinStart)
: base(joinStart, typeof(DmpsAudioOutputControllerJoinMap)) : base(joinStart, typeof(DmpsAudioOutputControllerJoinMap))
{ {
} }
} }
} }

View file

@ -67,6 +67,8 @@ namespace PepperDash.Essentials.Core
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<IBasicCommunicationJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<IBasicCommunicationJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (CommPort == null) if (CommPort == null)
{ {
Debug.Console(1, this, "Unable to link device '{0}'. CommPort is null", Key); Debug.Console(1, this, "Unable to link device '{0}'. CommPort is null", Key);

View file

@ -1,64 +1,65 @@
using System.Collections.Generic; using System.Collections.Generic;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.GeneralIO; using Crestron.SimplSharpPro.GeneralIO;
using Newtonsoft.Json; using Newtonsoft.Json;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.Core.CrestronIO namespace PepperDash.Essentials.Core.CrestronIO
{ {
[Description("Wrapper class for the C2N-RTHS sensor")] [Description("Wrapper class for the C2N-RTHS sensor")]
public class C2nRthsController : CrestronGenericBridgeableBaseDevice public class C2nRthsController : CrestronGenericBridgeableBaseDevice
{ {
private readonly C2nRths _device; private readonly C2nRths _device;
public IntFeedback TemperatureFeedback { get; private set; } public IntFeedback TemperatureFeedback { get; private set; }
public IntFeedback HumidityFeedback { get; private set; } public IntFeedback HumidityFeedback { get; private set; }
public C2nRthsController(string key, string name, GenericBase hardware) : base(key, name, hardware) public C2nRthsController(string key, string name, GenericBase hardware) : base(key, name, hardware)
{
_device = hardware as C2nRths;
TemperatureFeedback = new IntFeedback(() => _device.TemperatureFeedback.UShortValue);
HumidityFeedback = new IntFeedback(() => _device.HumidityFeedback.UShortValue);
if (_device != null) _device.BaseEvent += DeviceOnBaseEvent;
}
private void DeviceOnBaseEvent(GenericBase device, BaseEventArgs args)
{
switch (args.EventId)
{
case C2nRths.TemperatureFeedbackEventId:
TemperatureFeedback.FireUpdate();
break;
case C2nRths.HumidityFeedbackEventId:
HumidityFeedback.FireUpdate();
break;
}
}
public void SetTemperatureFormat(bool setToC)
{
_device.TemperatureFormat.BoolValue = setToC;
}
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{ {
var joinMap = new C2nRthsControllerJoinMap(joinStart); _device = hardware as C2nRths;
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); TemperatureFeedback = new IntFeedback(() => _device.TemperatureFeedback.UShortValue);
HumidityFeedback = new IntFeedback(() => _device.HumidityFeedback.UShortValue);
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<C2nRthsControllerJoinMap>(joinMapSerialized); if (_device != null) _device.BaseEvent += DeviceOnBaseEvent;
}
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); private void DeviceOnBaseEvent(GenericBase device, BaseEventArgs args)
{
switch (args.EventId)
{
case C2nRths.TemperatureFeedbackEventId:
TemperatureFeedback.FireUpdate();
break;
case C2nRths.HumidityFeedbackEventId:
HumidityFeedback.FireUpdate();
break;
}
}
public void SetTemperatureFormat(bool setToC)
{
_device.TemperatureFormat.BoolValue = setToC;
}
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
var joinMap = new C2nRthsControllerJoinMap(joinStart);
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<C2nRthsControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
trilist.SetBoolSigAction(joinMap.TemperatureFormat.JoinNumber, SetTemperatureFormat); trilist.SetBoolSigAction(joinMap.TemperatureFormat.JoinNumber, SetTemperatureFormat);
@ -67,25 +68,25 @@ namespace PepperDash.Essentials.Core.CrestronIO
TemperatureFeedback.LinkInputSig(trilist.UShortInput[joinMap.Temperature.JoinNumber]); TemperatureFeedback.LinkInputSig(trilist.UShortInput[joinMap.Temperature.JoinNumber]);
HumidityFeedback.LinkInputSig(trilist.UShortInput[joinMap.Humidity.JoinNumber]); HumidityFeedback.LinkInputSig(trilist.UShortInput[joinMap.Humidity.JoinNumber]);
trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name; trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name;
} }
} }
public class C2nRthsControllerFactory : EssentialsDeviceFactory<C2nRthsController> public class C2nRthsControllerFactory : EssentialsDeviceFactory<C2nRthsController>
{ {
public C2nRthsControllerFactory() public C2nRthsControllerFactory()
{ {
TypeNames = new List<string>() { "c2nrths" }; TypeNames = new List<string>() { "c2nrths" };
} }
public override EssentialsDevice BuildDevice(DeviceConfig dc) public override EssentialsDevice BuildDevice(DeviceConfig dc)
{ {
Debug.Console(1, "Factory Attempting to create new C2N-RTHS Device"); Debug.Console(1, "Factory Attempting to create new C2N-RTHS Device");
var control = CommFactory.GetControlPropertiesConfig(dc); var control = CommFactory.GetControlPropertiesConfig(dc);
var cresnetId = control.CresnetIdInt; var cresnetId = control.CresnetIdInt;
return new C2nRthsController(dc.Key, dc.Name, new C2nRths(cresnetId, Global.ControlSystem)); return new C2nRthsController(dc.Key, dc.Name, new C2nRths(cresnetId, Global.ControlSystem));
} }
} }
} }

View file

@ -50,7 +50,9 @@ namespace PepperDash.Essentials.Core.CrestronIO
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<IDigitalInputJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<IDigitalInputJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
try try
{ {

View file

@ -76,7 +76,9 @@ namespace PepperDash.Essentials.Core.CrestronIO
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<GenericRelayControllerJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<GenericRelayControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (RelayOutput == null) if (RelayOutput == null)
{ {

View file

@ -116,7 +116,9 @@ namespace PepperDash.Essentials.Core.CrestronIO
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<StatusSignControllerJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<StatusSignControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View file

@ -126,7 +126,9 @@ namespace PepperDash.Essentials.Core
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<DisplayControllerJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<DisplayControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to Display: {0}", displayDevice.Name); Debug.Console(0, "Linking to Display: {0}", displayDevice.Name);

View file

@ -78,7 +78,9 @@ namespace PepperDash.Essentials.Core.Lighting
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<GenericLightingJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<GenericLightingJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View file

@ -207,7 +207,9 @@ namespace PepperDash.Essentials.Core.Monitoring
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<SystemMonitorJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<SystemMonitorJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(2, this, "Linking API starting at join: {0}", joinStart); Debug.Console(2, this, "Linking API starting at join: {0}", joinStart);

View file

@ -110,6 +110,8 @@ namespace PepperDash.Essentials.DM.AirMedia
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<AirMediaControllerJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<AirMediaControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to Airmedia: {0}", Name); Debug.Console(0, "Linking to Airmedia: {0}", Name);

View file

@ -580,7 +580,7 @@ namespace PepperDash.Essentials.DM {
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<DmBladeChassisControllerJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<DmBladeChassisControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View file

@ -109,8 +109,9 @@ namespace PepperDash.Essentials.DM
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<DmpsAudioOutputControllerJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<DmpsAudioOutputControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View file

@ -161,7 +161,9 @@ namespace PepperDash.Essentials.DM
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<DmpsRoutingControllerJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<DmpsRoutingControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View file

@ -228,7 +228,9 @@ namespace PepperDash.Essentials.DM
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<HdMdxxxCEControllerJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<HdMdxxxCEControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View file

@ -44,7 +44,9 @@ namespace PepperDash.Essentials.DM
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<DmRmcControllerJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<DmRmcControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
Debug.Console(1, rmc, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, rmc, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View file

@ -181,6 +181,8 @@ namespace PepperDash.Essentials.DM
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<DmTxControllerJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<DmTxControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
if (tx.Hardware is DmHDBasedTEndPoint) if (tx.Hardware is DmHDBasedTEndPoint)
{ {
Debug.Console(1, tx, "No properties to link. Skipping device {0}", tx.Name); Debug.Console(1, tx, "No properties to link. Skipping device {0}", tx.Name);

View file

@ -265,7 +265,9 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<GlsOccupancySensorBaseJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<GlsOccupancySensorBaseJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
Debug.Console(1, occController, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, occController, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));

View file

@ -379,6 +379,8 @@ namespace PepperDash.Essentials.Devices.Common
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<SetTopBoxControllerJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<SetTopBoxControllerJoinMap>(joinMapSerialized);
bridge.AddJoinMap(Key, joinMap);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to Display: {0}", Name); Debug.Console(0, "Linking to Display: {0}", Name);

View file

@ -1,184 +1,186 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using Newtonsoft.Json; using Newtonsoft.Json;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Core.Routing; using PepperDash.Essentials.Core.Routing;
namespace PepperDash.Essentials.Devices.Common namespace PepperDash.Essentials.Devices.Common
{ {
public class AppleTV : EssentialsBridgeableDevice, IDPad, ITransport, IUiDisplayInfo, IRoutingOutputs public class AppleTV : EssentialsBridgeableDevice, IDPad, ITransport, IUiDisplayInfo, IRoutingOutputs
{ {
public IrOutputPortController IrPort { get; private set; } public IrOutputPortController IrPort { get; private set; }
public const string StandardDriverName = "Apple AppleTV-v2.ir"; public const string StandardDriverName = "Apple AppleTV-v2.ir";
public uint DisplayUiType { get { return DisplayUiConstants.TypeAppleTv; } } public uint DisplayUiType { get { return DisplayUiConstants.TypeAppleTv; } }
public AppleTV(string key, string name, IrOutputPortController portCont) public AppleTV(string key, string name, IrOutputPortController portCont)
: base(key, name) : base(key, name)
{ {
IrPort = portCont; IrPort = portCont;
DeviceManager.AddDevice(portCont); DeviceManager.AddDevice(portCont);
HdmiOut = new RoutingOutputPort(RoutingPortNames.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, HdmiOut = new RoutingOutputPort(RoutingPortNames.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Hdmi, null, this); eRoutingPortConnectionType.Hdmi, null, this);
AnyAudioOut = new RoutingOutputPort(RoutingPortNames.AnyAudioOut, eRoutingSignalType.Audio, AnyAudioOut = new RoutingOutputPort(RoutingPortNames.AnyAudioOut, eRoutingSignalType.Audio,
eRoutingPortConnectionType.DigitalAudio, null, this); eRoutingPortConnectionType.DigitalAudio, null, this);
OutputPorts = new RoutingPortCollection<RoutingOutputPort> { HdmiOut, AnyAudioOut }; OutputPorts = new RoutingPortCollection<RoutingOutputPort> { HdmiOut, AnyAudioOut };
} }
#region IDPad Members #region IDPad Members
public void Up(bool pressRelease) public void Up(bool pressRelease)
{ {
IrPort.PressRelease("+", pressRelease); IrPort.PressRelease("+", pressRelease);
} }
public void Down(bool pressRelease) public void Down(bool pressRelease)
{ {
IrPort.PressRelease("-", pressRelease); IrPort.PressRelease("-", pressRelease);
} }
public void Left(bool pressRelease) public void Left(bool pressRelease)
{ {
IrPort.PressRelease(IROutputStandardCommands.IROut_TRACK_MINUS, pressRelease); IrPort.PressRelease(IROutputStandardCommands.IROut_TRACK_MINUS, pressRelease);
} }
public void Right(bool pressRelease) public void Right(bool pressRelease)
{ {
IrPort.PressRelease(IROutputStandardCommands.IROut_TRACK_PLUS, pressRelease); IrPort.PressRelease(IROutputStandardCommands.IROut_TRACK_PLUS, pressRelease);
} }
public void Select(bool pressRelease) public void Select(bool pressRelease)
{ {
IrPort.PressRelease(IROutputStandardCommands.IROut_ENTER, pressRelease); IrPort.PressRelease(IROutputStandardCommands.IROut_ENTER, pressRelease);
} }
public void Menu(bool pressRelease) public void Menu(bool pressRelease)
{ {
IrPort.PressRelease("Menu", pressRelease); IrPort.PressRelease("Menu", pressRelease);
} }
public void Exit(bool pressRelease) public void Exit(bool pressRelease)
{ {
} }
#endregion #endregion
#region ITransport Members #region ITransport Members
public void Play(bool pressRelease) public void Play(bool pressRelease)
{ {
IrPort.PressRelease("PLAY/PAUSE", pressRelease); IrPort.PressRelease("PLAY/PAUSE", pressRelease);
} }
public void Pause(bool pressRelease) public void Pause(bool pressRelease)
{ {
IrPort.PressRelease("PLAY/PAUSE", pressRelease); IrPort.PressRelease("PLAY/PAUSE", pressRelease);
} }
/// <summary> /// <summary>
/// Not implemented /// Not implemented
/// </summary> /// </summary>
/// <param name="pressRelease"></param> /// <param name="pressRelease"></param>
public void Rewind(bool pressRelease) public void Rewind(bool pressRelease)
{ {
} }
/// <summary> /// <summary>
/// Not implemented /// Not implemented
/// </summary> /// </summary>
/// <param name="pressRelease"></param> /// <param name="pressRelease"></param>
public void FFwd(bool pressRelease) public void FFwd(bool pressRelease)
{ {
} }
/// <summary> /// <summary>
/// Not implemented /// Not implemented
/// </summary> /// </summary>
/// <param name="pressRelease"></param> /// <param name="pressRelease"></param>
public void ChapMinus(bool pressRelease) public void ChapMinus(bool pressRelease)
{ {
} }
/// <summary> /// <summary>
/// Not implemented /// Not implemented
/// </summary> /// </summary>
/// <param name="pressRelease"></param> /// <param name="pressRelease"></param>
public void ChapPlus(bool pressRelease) public void ChapPlus(bool pressRelease)
{ {
} }
/// <summary> /// <summary>
/// Not implemented /// Not implemented
/// </summary> /// </summary>
/// <param name="pressRelease"></param> /// <param name="pressRelease"></param>
public void Stop(bool pressRelease) public void Stop(bool pressRelease)
{ {
} }
/// <summary> /// <summary>
/// Not implemented /// Not implemented
/// </summary> /// </summary>
/// <param name="pressRelease"></param> /// <param name="pressRelease"></param>
public void Record(bool pressRelease) public void Record(bool pressRelease)
{ {
} }
#endregion #endregion
#region IRoutingOutputs Members #region IRoutingOutputs Members
public RoutingOutputPort HdmiOut { get; private set; } public RoutingOutputPort HdmiOut { get; private set; }
public RoutingOutputPort AnyAudioOut { get; private set; } public RoutingOutputPort AnyAudioOut { get; private set; }
public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; } public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
#endregion #endregion
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{ {
var joinMap = new AppleTvJoinMap(joinStart); var joinMap = new AppleTvJoinMap(joinStart);
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<AppleTvJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<AppleTvJoinMap>(joinMapSerialized);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); bridge.AddJoinMap(Key, joinMap);
Debug.Console(0, "Linking to Bridge Type {0}", GetType().Name);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to Bridge Type {0}", GetType().Name);
trilist.SetBoolSigAction(joinMap.UpArrow.JoinNumber, Up); trilist.SetBoolSigAction(joinMap.UpArrow.JoinNumber, Up);
trilist.SetBoolSigAction(joinMap.DnArrow.JoinNumber, Down); trilist.SetBoolSigAction(joinMap.DnArrow.JoinNumber, Down);
trilist.SetBoolSigAction(joinMap.LeftArrow.JoinNumber, Left); trilist.SetBoolSigAction(joinMap.LeftArrow.JoinNumber, Left);
trilist.SetBoolSigAction(joinMap.RightArrow.JoinNumber, Right); trilist.SetBoolSigAction(joinMap.RightArrow.JoinNumber, Right);
trilist.SetBoolSigAction(joinMap.Select.JoinNumber, Select); trilist.SetBoolSigAction(joinMap.Select.JoinNumber, Select);
trilist.SetBoolSigAction(joinMap.Menu.JoinNumber, Menu); trilist.SetBoolSigAction(joinMap.Menu.JoinNumber, Menu);
trilist.SetBoolSigAction(joinMap.PlayPause.JoinNumber, Play); trilist.SetBoolSigAction(joinMap.PlayPause.JoinNumber, Play);
} }
} }
public class AppleTVFactory : EssentialsDeviceFactory<AppleTV> public class AppleTVFactory : EssentialsDeviceFactory<AppleTV>
{ {
public AppleTVFactory() public AppleTVFactory()
{ {
TypeNames = new List<string>() { "appletv" }; TypeNames = new List<string>() { "appletv" };
} }
public override EssentialsDevice BuildDevice(DeviceConfig dc) public override EssentialsDevice BuildDevice(DeviceConfig dc)
{ {
Debug.Console(1, "Factory Attempting to create new AppleTV Device"); Debug.Console(1, "Factory Attempting to create new AppleTV Device");
var irCont = IRPortHelper.GetIrOutputPortController(dc); var irCont = IRPortHelper.GetIrOutputPortController(dc);
return new AppleTV(dc.Key, dc.Name, irCont); return new AppleTV(dc.Key, dc.Name, irCont);
} }
} }
} }