mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 12:15:01 +00:00
Merge pull request #428 from PepperDash/feature/vc4-eisc
Add VirtualControlEiscClient
This commit is contained in:
@@ -327,7 +327,11 @@ namespace PepperDash.Essentials
|
|||||||
DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor"));
|
DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor"));
|
||||||
|
|
||||||
// Add global System Monitor device
|
// Add global System Monitor device
|
||||||
DeviceManager.AddDevice(new PepperDash.Essentials.Core.Monitoring.SystemMonitorController("systemMonitor"));
|
if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance)
|
||||||
|
{
|
||||||
|
DeviceManager.AddDevice(
|
||||||
|
new PepperDash.Essentials.Core.Monitoring.SystemMonitorController("systemMonitor"));
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var devConf in ConfigReader.ConfigObject.Devices)
|
foreach (var devConf in ConfigReader.ConfigObject.Devices)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.Reflection;
|
using Crestron.SimplSharp.Reflection;
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@@ -82,9 +84,9 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
|
|
||||||
protected Dictionary<string, JoinMapBaseAdvanced> JoinMaps { get; private set; }
|
protected Dictionary<string, JoinMapBaseAdvanced> JoinMaps { get; private set; }
|
||||||
|
|
||||||
public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; }
|
public BasicTriList Eisc { get; private set; }
|
||||||
|
|
||||||
public EiscApiAdvanced(DeviceConfig dc) :
|
public EiscApiAdvanced(DeviceConfig dc, BasicTriList eisc) :
|
||||||
base(dc.Key)
|
base(dc.Key)
|
||||||
{
|
{
|
||||||
JoinMaps = new Dictionary<string, JoinMapBaseAdvanced>();
|
JoinMaps = new Dictionary<string, JoinMapBaseAdvanced>();
|
||||||
@@ -92,44 +94,52 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
PropertiesConfig = dc.Properties.ToObject<EiscApiPropertiesConfig>();
|
PropertiesConfig = dc.Properties.ToObject<EiscApiPropertiesConfig>();
|
||||||
//PropertiesConfig = JsonConvert.DeserializeObject<EiscApiPropertiesConfig>(dc.Properties.ToString());
|
//PropertiesConfig = JsonConvert.DeserializeObject<EiscApiPropertiesConfig>(dc.Properties.ToString());
|
||||||
|
|
||||||
Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem);
|
Eisc = eisc;
|
||||||
|
|
||||||
Eisc.SigChange += Eisc_SigChange;
|
Eisc.SigChange += Eisc_SigChange;
|
||||||
|
|
||||||
AddPostActivationAction( () =>
|
AddPostActivationAction(LinkDevices);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LinkDevices()
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Linking Devices...");
|
||||||
|
|
||||||
|
foreach (var d in PropertiesConfig.Devices)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Linking Devices...");
|
var device = DeviceManager.GetDeviceForKey(d.DeviceKey);
|
||||||
|
|
||||||
foreach (var d in PropertiesConfig.Devices)
|
if (device == null)
|
||||||
{
|
{
|
||||||
var device = DeviceManager.GetDeviceForKey(d.DeviceKey);
|
continue;
|
||||||
|
|
||||||
if (device == null) continue;
|
|
||||||
|
|
||||||
Debug.Console(1, this, "Linking Device: '{0}'", device.Key);
|
|
||||||
|
|
||||||
if (!typeof (IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType()))
|
|
||||||
{
|
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Notice,
|
|
||||||
"{0} is not compatible with this bridge type. Please use 'eiscapi' instead, or updae the device.",
|
|
||||||
device.Key);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var bridge = device as IBridgeAdvanced;
|
|
||||||
if (bridge != null) bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var registerResult = Eisc.Register();
|
Debug.Console(1, this, "Linking Device: '{0}'", device.Key);
|
||||||
|
|
||||||
if (registerResult != eDeviceRegistrationUnRegistrationResponse.Success)
|
if (!typeof (IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType()))
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Registration result: {0}", registerResult);
|
Debug.Console(0, this, Debug.ErrorLogLevel.Notice,
|
||||||
return;
|
"{0} is not compatible with this bridge type. Please use 'eiscapi' instead, or updae the device.",
|
||||||
|
device.Key);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "EISC registration successful");
|
var bridge = device as IBridgeAdvanced;
|
||||||
});
|
if (bridge != null)
|
||||||
|
{
|
||||||
|
bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var registerResult = Eisc.Register();
|
||||||
|
|
||||||
|
if (registerResult != eDeviceRegistrationUnRegistrationResponse.Success)
|
||||||
|
{
|
||||||
|
Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Registration result: {0}", registerResult);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "EISC registration successful");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -152,7 +162,7 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prints all the join maps on this bridge
|
/// Prints all the join maps on this bridge
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void PrintJoinMaps()
|
public virtual void PrintJoinMaps()
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Join Maps for EISC IPID: {0}", Eisc.ID.ToString("X"));
|
Debug.Console(0, this, "Join Maps for EISC IPID: {0}", Eisc.ID.ToString("X"));
|
||||||
|
|
||||||
@@ -247,7 +257,7 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="currentDevice"></param>
|
/// <param name="currentDevice"></param>
|
||||||
/// <param name="args"></param>
|
/// <param name="args"></param>
|
||||||
void Eisc_SigChange(object currentDevice, SigEventArgs args)
|
protected void Eisc_SigChange(object currentDevice, SigEventArgs args)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -299,15 +309,34 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
{
|
{
|
||||||
public EiscApiAdvancedFactory()
|
public EiscApiAdvancedFactory()
|
||||||
{
|
{
|
||||||
TypeNames = new List<string> { "eiscapiadv", "eiscapiadvanced" };
|
TypeNames = new List<string> { "eiscapiadv", "eiscapiadvanced", "vceiscapiadv", "vceiscapiadvanced" };
|
||||||
}
|
}
|
||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new EiscApiAdvanced Device");
|
Debug.Console(1, "Factory Attempting to create new EiscApiAdvanced Device");
|
||||||
|
|
||||||
return new EiscApiAdvanced(dc);
|
var controlProperties = dc.Properties["control"].ToObject<ControlPropertiesConfig>();
|
||||||
|
|
||||||
|
switch (dc.Type)
|
||||||
|
{
|
||||||
|
case "eiscapiadv":
|
||||||
|
case "eiscapiadvanced":
|
||||||
|
{
|
||||||
|
var eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(controlProperties.IpIdInt,
|
||||||
|
controlProperties.TcpSshProperties.Address, Global.ControlSystem);
|
||||||
|
return new EiscApiAdvanced(dc, eisc);
|
||||||
|
}
|
||||||
|
case "vceiscapiadv":
|
||||||
|
case "vceiscapiadvanced":
|
||||||
|
{
|
||||||
|
var eisc = new VirtualControlEISCClient(controlProperties.IpIdInt, InitialParametersClass.RoomId,
|
||||||
|
Global.ControlSystem);
|
||||||
|
return new EiscApiAdvanced(dc, eisc);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
public static CrestronControlSystem ControlSystem { get; set; }
|
public static CrestronControlSystem ControlSystem { get; set; }
|
||||||
|
|
||||||
public static LicenseManager LicenseManager { get; set; }
|
public static eDevicePlatform Platform { get { return CrestronEnvironment.DevicePlatform; } }
|
||||||
|
|
||||||
public static Dictionary<short, EthernetAdapterInfo> EthernetAdapterInfoCollection {get; private set;}
|
public static Dictionary<short, EthernetAdapterInfo> EthernetAdapterInfoCollection { get; private set; }
|
||||||
|
|
||||||
|
public static LicenseManager LicenseManager { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The file path prefix to the folder containing configuration files
|
/// The file path prefix to the folder containing configuration files
|
||||||
@@ -163,8 +165,6 @@ namespace PepperDash.Essentials.Core
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static Global()
|
static Global()
|
||||||
{
|
{
|
||||||
// Fire up CrestronDataStoreStatic
|
// Fire up CrestronDataStoreStatic
|
||||||
@@ -174,87 +174,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
CrestronConsole.PrintLine("Error starting CrestronDataStoreStatic: {0}", err);
|
CrestronConsole.PrintLine("Error starting CrestronDataStoreStatic: {0}", err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetEthernetInformation();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Populates EthernetInformationCollection
|
|
||||||
/// </summary>
|
|
||||||
static void GetEthernetInformation()
|
|
||||||
{
|
|
||||||
|
|
||||||
EthernetAdapterInfoCollection = new Dictionary<short, EthernetAdapterInfo>();
|
|
||||||
|
|
||||||
EthernetAdapterType adapterType = EthernetAdapterType.EthernetUnknownAdapter;
|
|
||||||
|
|
||||||
List<EthernetAdapterType> adapters = new List<EthernetAdapterType>()
|
|
||||||
{ EthernetAdapterType.EthernetLANAdapter, EthernetAdapterType.EthernetLAN2Adapter, EthernetAdapterType.EthernetCSAdapter, EthernetAdapterType.EthernetWIFIAdapter };
|
|
||||||
|
|
||||||
foreach (var adapter in adapters)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
adapterType = EthernetAdapterType.EthernetLANAdapter;
|
|
||||||
|
|
||||||
var adapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(adapterType);
|
|
||||||
|
|
||||||
var adapterInfo = GetEthernetAdapterProperties(adapterId, adapterType);
|
|
||||||
|
|
||||||
EthernetAdapterInfoCollection.Add(adapterId, adapterInfo);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
if (e is System.ArgumentException)
|
|
||||||
{
|
|
||||||
Debug.Console(1, "Error: {0} not present", adapterType);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Console(1, "Error: {0}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static EthernetAdapterInfo GetEthernetAdapterProperties(short adapterId, EthernetAdapterType adapterType)
|
|
||||||
{
|
|
||||||
EthernetAdapterInfo adapterInfo = new EthernetAdapterInfo();
|
|
||||||
|
|
||||||
adapterInfo.Type = adapterType;
|
|
||||||
adapterInfo.DhcpIsOn = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, adapterId) == "on" ? true : false;
|
|
||||||
adapterInfo.Hostname = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, adapterId);
|
|
||||||
adapterInfo.MacAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterId);
|
|
||||||
adapterInfo.IpAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterId);
|
|
||||||
adapterInfo.Subnet = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterId);
|
|
||||||
adapterInfo.Gateway = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterId);
|
|
||||||
adapterInfo.Domain = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, adapterId);
|
|
||||||
|
|
||||||
string dns = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, adapterId);
|
|
||||||
if (dns.Contains(","))
|
|
||||||
{
|
|
||||||
string[] dnsList = dns.Split(',');
|
|
||||||
for (var i = 0; i < dnsList.Length; i++)
|
|
||||||
{
|
|
||||||
if (i == 0)
|
|
||||||
adapterInfo.Dns1 = !string.IsNullOrEmpty(dnsList[0]) ? dnsList[0] : "0.0.0.0";
|
|
||||||
if (i == 1)
|
|
||||||
adapterInfo.Dns2 = !string.IsNullOrEmpty(dnsList[1]) ? dnsList[1] : "0.0.0.0";
|
|
||||||
if (i == 2)
|
|
||||||
adapterInfo.Dns3 = !string.IsNullOrEmpty(dnsList[2]) ? dnsList[2] : "0.0.0.0";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
adapterInfo.Dns1 = !string.IsNullOrEmpty(dns) ? dns : "0.0.0.0";
|
|
||||||
adapterInfo.Dns2 = "0.0.0.0";
|
|
||||||
adapterInfo.Dns3 = "0.0.0.0";
|
|
||||||
}
|
|
||||||
|
|
||||||
return adapterInfo;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2097,6 +2097,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
|||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new Cisco Codec Device");
|
Debug.Console(1, "Factory Attempting to create new Cisco Codec Device");
|
||||||
|
|
||||||
var comm = CommFactory.CreateCommForDevice(dc);
|
var comm = CommFactory.CreateCommForDevice(dc);
|
||||||
return new VideoCodec.Cisco.CiscoSparkCodec(dc, comm);
|
return new VideoCodec.Cisco.CiscoSparkCodec(dc, comm);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user