moves bridgeBase and IBridge/IBridgeAdvanced

This commit is contained in:
Andrew Welker
2020-04-13 16:01:19 -06:00
parent 3b2b69de1b
commit 31244e4294
2 changed files with 406 additions and 411 deletions

View File

@@ -1,24 +1,18 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using Crestron.SimplSharp.Reflection;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.EthernetCommunication; using Crestron.SimplSharpPro.EthernetCommunication;
using Newtonsoft.Json; using Newtonsoft.Json;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Lighting; using PepperDash.Essentials.Core.Lighting;
using PepperDash.Essentials.Core.Devices;
using PepperDash.Essentials.Devices.Common;
using PepperDash.Essentials.Devices.Common.Cameras;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.CrestronIO; using PepperDash.Essentials.Core.CrestronIO;
using PepperDash.Essentials.DM;
//using PepperDash.Essentials.Devices.Common.Cameras; //using PepperDash.Essentials.Devices.Common.Cameras;
namespace PepperDash.Essentials.Bridges namespace PepperDash.Essentials.Core.Bridges
{ {
/// <summary> /// <summary>
/// Helper methods for bridges /// Helper methods for bridges
@@ -27,12 +21,9 @@ namespace PepperDash.Essentials.Bridges
{ {
public static void PrintJoinMap(string command) public static void PrintJoinMap(string command)
{ {
string bridgeKey = "";
string deviceKey = "";
var targets = command.Split(' '); var targets = command.Split(' ');
bridgeKey = targets[0].Trim(); var bridgeKey = targets[0].Trim();
var bridge = DeviceManager.GetDeviceForKey(bridgeKey) as EiscApi; var bridge = DeviceManager.GetDeviceForKey(bridgeKey) as EiscApi;
@@ -44,13 +35,10 @@ namespace PepperDash.Essentials.Bridges
if (targets.Length > 1) if (targets.Length > 1)
{ {
deviceKey = targets[1].Trim(); var deviceKey = targets[1].Trim();
if (!string.IsNullOrEmpty(deviceKey)) if (string.IsNullOrEmpty(deviceKey)) return;
{
bridge.PrintJoinMapForDevice(deviceKey); bridge.PrintJoinMapForDevice(deviceKey);
return;
}
} }
else else
{ {
@@ -63,24 +51,23 @@ namespace PepperDash.Essentials.Bridges
/// <summary> /// <summary>
/// Base class for all bridge class variants /// Base class for all bridge class variants
/// </summary> /// </summary>
public class BridgeBase : Device public class BridgeBase : EssentialsDevice
{ {
public BridgeApi Api { get; private set; } public BridgeApi Api { get; protected set; }
public BridgeBase(string key) : public BridgeBase(string key) :
base(key) base(key)
{ {
} }
} }
/// <summary> /// <summary>
/// Base class for bridge API variants /// Base class for bridge API variants
/// </summary> /// </summary>
public abstract class BridgeApi : Device public abstract class BridgeApi : EssentialsDevice
{ {
public BridgeApi(string key) : protected BridgeApi(string key) :
base(key) base(key)
{ {
@@ -107,7 +94,7 @@ namespace PepperDash.Essentials.Bridges
Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem); Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem);
Eisc.SigChange += new Crestron.SimplSharpPro.DeviceSupport.SigEventHandler(Eisc_SigChange); Eisc.SigChange += Eisc_SigChange;
Eisc.Register(); Eisc.Register();
@@ -119,122 +106,134 @@ namespace PepperDash.Essentials.Bridges
{ {
var device = DeviceManager.GetDeviceForKey(d.DeviceKey); var device = DeviceManager.GetDeviceForKey(d.DeviceKey);
if (device != null) if (device == null) continue;
{
Debug.Console(1, this, "Linking Device: '{0}'", device.Key); Debug.Console(1, this, "Linking Device: '{0}'", device.Key);
if (device.GetType().GetCType().IsAssignableFrom(typeof (IBridge)))
{
var bridge = device as IBridge;
if (device is IBridge) // Check for this first to allow bridges in plugins to override existing bridges that apply to the same type. if (bridge != null) bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
{
(device as IBridge).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue; continue;
} }
else if (device is IBridgeAdvanced)
if (device.GetType().GetCType().IsAssignableFrom(typeof (IBridgeAdvanced)))
{ {
Debug.Console(2, this, "'{0}' is IBridgeAdvanced", device.Key); var bridge = device as IBridgeAdvanced;
(device as IBridgeAdvanced).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); if (bridge != null) bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this);
}
else if (device is PepperDash.Essentials.Core.Monitoring.SystemMonitorController)
{
(device as PepperDash.Essentials.Core.Monitoring.SystemMonitorController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is GenericComm)
{
(device as GenericComm).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is CameraBase)
{
(device as CameraBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this);
continue;
}
else if (device is PepperDash.Essentials.Core.DisplayBase)
{
(device as DisplayBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is DmChassisController)
{
(device as DmChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is DmBladeChassisController)
{
(device as DmBladeChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is DmpsRoutingController)
{
(device as DmpsRoutingController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is DmpsAudioOutputController)
{
(device as DmpsAudioOutputController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is DmTxControllerBase)
{
(device as DmTxControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is DmRmcControllerBase)
{
(device as DmRmcControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is GenericRelayDevice)
{
(device as GenericRelayDevice).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is IRSetTopBoxBase)
{
(device as IRSetTopBoxBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is IDigitalInput)
{
(device as IDigitalInput).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is AppleTV)
{
(device as AppleTV).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is HdMdxxxCEController)
{
(device as HdMdxxxCEController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is LightingBase)
{
(device as LightingBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is DigitalLogger)
{
(device as DigitalLogger).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is PepperDash.Essentials.Devices.Common.Occupancy.GlsOccupancySensorBaseController)
{
(device as PepperDash.Essentials.Devices.Common.Occupancy.GlsOccupancySensorBaseController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is StatusSignController)
{
(device as StatusSignController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is C2nRthsController)
{
(device as C2nRthsController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
} }
//if (device is IBridge) // Check for this first to allow bridges in plugins to override existing bridges that apply to the same type.
//{
// (device as IBridge).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is IBridgeAdvanced)
//{
// Debug.Console(2, this, "'{0}' is IBridgeAdvanced", device.Key);
// (device as IBridgeAdvanced).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this);
//}
//else if (device is PepperDash.Essentials.Core.Monitoring.SystemMonitorController)
//{
// (device as PepperDash.Essentials.Core.Monitoring.SystemMonitorController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is GenericComm)
//{
// (device as GenericComm).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is CameraBase)
//{
// (device as CameraBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this);
// continue;
//}
//else if (device is PepperDash.Essentials.Core.DisplayBase)
//{
// (device as DisplayBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is DmChassisController)
//{
// (device as DmChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is DmBladeChassisController)
//{
// (device as DmBladeChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is DmpsRoutingController)
//{
// (device as DmpsRoutingController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is DmpsAudioOutputController)
//{
// (device as DmpsAudioOutputController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is DmTxControllerBase)
//{
// (device as DmTxControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is DmRmcControllerBase)
//{
// (device as DmRmcControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is GenericRelayDevice)
//{
// (device as GenericRelayDevice).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is IRSetTopBoxBase)
//{
// (device as IRSetTopBoxBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is IDigitalInput)
//{
// (device as IDigitalInput).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is AppleTV)
//{
// (device as AppleTV).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is HdMdxxxCEController)
//{
// (device as HdMdxxxCEController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is LightingBase)
//{
// (device as LightingBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is DigitalLogger)
//{
// (device as DigitalLogger).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is PepperDash.Essentials.Devices.Common.Occupancy.GlsOccupancySensorBaseController)
//{
// (device as PepperDash.Essentials.Devices.Common.Occupancy.GlsOccupancySensorBaseController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is StatusSignController)
//{
// (device as StatusSignController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is C2nRthsController)
//{
// (device as C2nRthsController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
} }
Debug.Console(1, this, "Devices Linked."); Debug.Console(1, this, "Devices Linked.");

View File

@@ -1,11 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
namespace PepperDash.Essentials.Bridges namespace PepperDash.Essentials.Core.Bridges
{ {
/// <summary> /// <summary>
/// Defines a device that uses the legacy JoinMapBase for its join map /// Defines a device that uses the legacy JoinMapBase for its join map