mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 20:54:55 +00:00
Merge pull request #484 from PepperDash/feature/device-info
Add Device Info interfaces and retrievals
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
namespace PepperDash.Essentials.Core.DeviceInfo
|
||||||
|
{
|
||||||
|
public class DeviceInfo
|
||||||
|
{
|
||||||
|
public string HostName { get; set; }
|
||||||
|
public string IpAddress { get; set; }
|
||||||
|
public string MacAddress { get; set; }
|
||||||
|
public string SerialNumber { get; set; }
|
||||||
|
public string FirmwareVersion { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.DeviceInfo
|
||||||
|
{
|
||||||
|
public class DeviceInfoEventArgs:EventArgs
|
||||||
|
{
|
||||||
|
public DeviceInfo DeviceInfo { get; set; }
|
||||||
|
|
||||||
|
public DeviceInfoEventArgs()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceInfoEventArgs(DeviceInfo devInfo)
|
||||||
|
{
|
||||||
|
DeviceInfo = devInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using PepperDash.Core;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.DeviceInfo
|
||||||
|
{
|
||||||
|
public interface IDeviceInfoProvider:IKeyed
|
||||||
|
{
|
||||||
|
DeviceInfo DeviceInfo { get; }
|
||||||
|
|
||||||
|
event DeviceInfoChangeHandler DeviceInfoChanged;
|
||||||
|
|
||||||
|
void UpdateDeviceInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void DeviceInfoChangeHandler(IKeyed device, DeviceInfoEventArgs args);
|
||||||
|
}
|
||||||
@@ -183,6 +183,9 @@
|
|||||||
<Compile Include="Crestron IO\Relay\GenericRelayDevice.cs" />
|
<Compile Include="Crestron IO\Relay\GenericRelayDevice.cs" />
|
||||||
<Compile Include="Crestron IO\Relay\ISwitchedOutput.cs" />
|
<Compile Include="Crestron IO\Relay\ISwitchedOutput.cs" />
|
||||||
<Compile Include="Crestron IO\StatusSign\StatusSignController.cs" />
|
<Compile Include="Crestron IO\StatusSign\StatusSignController.cs" />
|
||||||
|
<Compile Include="Device Info\DeviceInfo.cs" />
|
||||||
|
<Compile Include="Device Info\DeviceInfoEventArgs.cs" />
|
||||||
|
<Compile Include="Device Info\IDeviceInfoProvider.cs" />
|
||||||
<Compile Include="Devices\CodecInterfaces.cs" />
|
<Compile Include="Devices\CodecInterfaces.cs" />
|
||||||
<Compile Include="Devices\CrestronProcessor.cs" />
|
<Compile Include="Devices\CrestronProcessor.cs" />
|
||||||
<Compile Include="Devices\DeviceApiBase.cs" />
|
<Compile Include="Devices\DeviceApiBase.cs" />
|
||||||
|
|||||||
@@ -774,10 +774,15 @@ namespace PepperDash.Essentials.DM
|
|||||||
{
|
{
|
||||||
var portKey = string.Format("{0}--{1}", cardName, portName);
|
var portKey = string.Format("{0}--{1}", cardName, portName);
|
||||||
Debug.Console(2, this, "Adding output port '{0}'", portKey);
|
Debug.Console(2, this, "Adding output port '{0}'", portKey);
|
||||||
OutputPorts.Add(new RoutingOutputPort(portKey, sigType, portType, selector, this)
|
|
||||||
|
var outputPort = new RoutingOutputPort(portKey, sigType, portType, selector, this);
|
||||||
|
|
||||||
|
if (portName.IndexOf("Loop", StringComparison.InvariantCultureIgnoreCase) < 0)
|
||||||
{
|
{
|
||||||
FeedbackMatchObject = Chassis.Outputs[(uint)selector]
|
outputPort.FeedbackMatchObject = Chassis.Outputs[(uint) selector];
|
||||||
});
|
}
|
||||||
|
|
||||||
|
OutputPorts.Add(outputPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -787,11 +792,12 @@ namespace PepperDash.Essentials.DM
|
|||||||
{
|
{
|
||||||
var portKey = string.Format("{0}--{1}", cardName, portName);
|
var portKey = string.Format("{0}--{1}", cardName, portName);
|
||||||
Debug.Console(2, this, "Adding output port '{0}'", portKey);
|
Debug.Console(2, this, "Adding output port '{0}'", portKey);
|
||||||
var outputPort = new RoutingOutputPort(portKey, sigType, portType, selector, this)
|
var outputPort = new RoutingOutputPort(portKey, sigType, portType, selector, this);
|
||||||
{
|
|
||||||
FeedbackMatchObject = Chassis.Outputs[(uint)selector]
|
|
||||||
}; ;
|
|
||||||
|
|
||||||
|
if (portName.IndexOf("Loop", StringComparison.InvariantCultureIgnoreCase) < 0)
|
||||||
|
{
|
||||||
|
outputPort.FeedbackMatchObject = Chassis.Outputs[(uint)selector];
|
||||||
|
}
|
||||||
if (cecPort != null)
|
if (cecPort != null)
|
||||||
outputPort.Port = cecPort;
|
outputPort.Port = cecPort;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
@@ -15,14 +16,18 @@ using PepperDash.Core;
|
|||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
using PepperDash.Essentials.Core.DeviceInfo;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.DM.Endpoints.DGEs
|
namespace PepperDash.Essentials.DM.Endpoints.DGEs
|
||||||
{
|
{
|
||||||
[Description("Wrapper class for DGE-100")]
|
[Description("Wrapper class for DGE-100")]
|
||||||
public class Dge100Controller : CrestronGenericBaseDevice, IComPorts, IIROutputPorts, IHasBasicTriListWithSmartObject, ICec
|
public class Dge100Controller : CrestronGenericBaseDevice, IComPorts, IIROutputPorts, IHasBasicTriListWithSmartObject, ICec, IDeviceInfoProvider
|
||||||
{
|
{
|
||||||
|
private const int CtpPort = 41795;
|
||||||
private readonly Dge100 _dge;
|
private readonly Dge100 _dge;
|
||||||
|
|
||||||
|
private readonly TsxCcsUcCodec100EthernetReservedSigs _dgeEthernetInfo;
|
||||||
|
|
||||||
public BasicTriListWithSmartObject Panel { get { return _dge; } }
|
public BasicTriListWithSmartObject Panel { get { return _dge; } }
|
||||||
|
|
||||||
private DeviceConfig _dc;
|
private DeviceConfig _dc;
|
||||||
@@ -33,6 +38,13 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs
|
|||||||
:base(key, name, device)
|
:base(key, name, device)
|
||||||
{
|
{
|
||||||
_dge = device;
|
_dge = device;
|
||||||
|
_dgeEthernetInfo = _dge.ExtenderEthernetReservedSigs;
|
||||||
|
_dgeEthernetInfo.DeviceExtenderSigChange += (extender, args) => UpdateDeviceInfo();
|
||||||
|
_dgeEthernetInfo.Use();
|
||||||
|
|
||||||
|
DeviceInfo = new DeviceInfo();
|
||||||
|
|
||||||
|
_dge.OnlineStatusChange += (currentDevice, args) => { if (args.DeviceOnLine) UpdateDeviceInfo(); };
|
||||||
|
|
||||||
_dc = dc;
|
_dc = dc;
|
||||||
|
|
||||||
@@ -71,6 +83,84 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs
|
|||||||
public Cec StreamCec { get { return _dge.HdmiOut.StreamCec; } }
|
public Cec StreamCec { get { return _dge.HdmiOut.StreamCec; } }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Implementation of IDeviceInfoProvider
|
||||||
|
|
||||||
|
public DeviceInfo DeviceInfo { get; private set; }
|
||||||
|
|
||||||
|
public event DeviceInfoChangeHandler DeviceInfoChanged;
|
||||||
|
|
||||||
|
public void UpdateDeviceInfo()
|
||||||
|
{
|
||||||
|
DeviceInfo.IpAddress = _dgeEthernetInfo.IpAddressFeedback.StringValue;
|
||||||
|
DeviceInfo.MacAddress = _dgeEthernetInfo.MacAddressFeedback.StringValue;
|
||||||
|
|
||||||
|
GetFirmwareAndSerialInfo();
|
||||||
|
|
||||||
|
OnDeviceInfoChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetFirmwareAndSerialInfo()
|
||||||
|
{
|
||||||
|
if (String.IsNullOrEmpty(_dgeEthernetInfo.IpAddressFeedback.StringValue))
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "IP Address information not yet received. No device is online");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var tcpClient = new GenericTcpIpClient("", _dgeEthernetInfo.IpAddressFeedback.StringValue, CtpPort, 1024){AutoReconnect = false};
|
||||||
|
|
||||||
|
var gather = new CommunicationGather(tcpClient, "\r\n\r\n");
|
||||||
|
|
||||||
|
tcpClient.ConnectionChange += (sender, args) =>
|
||||||
|
{
|
||||||
|
if (!args.Client.IsConnected)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
args.Client.SendText("ver\r\n");
|
||||||
|
};
|
||||||
|
|
||||||
|
gather.LineReceived += (sender, args) =>
|
||||||
|
{
|
||||||
|
if (args.Text.ToLower().Contains("host"))
|
||||||
|
{
|
||||||
|
DeviceInfo.HostName = args.Text.Split(';')[1].Trim();
|
||||||
|
|
||||||
|
tcpClient.Disconnect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//ignore console prompt
|
||||||
|
if (args.Text.ToLower().Contains(">"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!args.Text.ToLower().Contains("dge"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceInfo.SerialNumber = args.Text.Split('[')[1].Split(' ')[4].Replace("#", "");
|
||||||
|
DeviceInfo.FirmwareVersion = args.Text.Split('[')[1].Split(' ')[1];
|
||||||
|
|
||||||
|
tcpClient.SendText("host\r\n");
|
||||||
|
};
|
||||||
|
|
||||||
|
tcpClient.Connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDeviceInfoChange()
|
||||||
|
{
|
||||||
|
var handler = DeviceInfoChanged;
|
||||||
|
|
||||||
|
if (handler == null) return;
|
||||||
|
|
||||||
|
handler(this, new DeviceInfoEventArgs(DeviceInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Dge100ControllerFactory : EssentialsDeviceFactory<Dge100Controller>
|
public class Dge100ControllerFactory : EssentialsDeviceFactory<Dge100Controller>
|
||||||
|
|||||||
@@ -8,14 +8,16 @@ using Newtonsoft.Json;
|
|||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
using PepperDash.Essentials.Core.DeviceInfo;
|
||||||
using PepperDash.Essentials.DM.Config;
|
using PepperDash.Essentials.DM.Config;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.DM
|
namespace PepperDash.Essentials.DM
|
||||||
{
|
{
|
||||||
[Description("Wrapper class for all DM-RMC variants")]
|
[Description("Wrapper class for all DM-RMC variants")]
|
||||||
public abstract class DmRmcControllerBase : CrestronGenericBridgeableBaseDevice
|
public abstract class DmRmcControllerBase : CrestronGenericBridgeableBaseDevice, IDeviceInfoProvider
|
||||||
{
|
{
|
||||||
|
private const int CtpPort = 41795;
|
||||||
private readonly EndpointReceiverBase _rmc; //kept here just in case. Only property or method on this class that's not device-specific is the DMOutput that it's attached to.
|
private readonly EndpointReceiverBase _rmc; //kept here just in case. Only property or method on this class that's not device-specific is the DMOutput that it's attached to.
|
||||||
|
|
||||||
public StringFeedback VideoOutputResolutionFeedback { get; protected set; }
|
public StringFeedback VideoOutputResolutionFeedback { get; protected set; }
|
||||||
@@ -32,6 +34,10 @@ namespace PepperDash.Essentials.DM
|
|||||||
PreventRegistration = _rmc.DMOutput != null;
|
PreventRegistration = _rmc.DMOutput != null;
|
||||||
|
|
||||||
AddToFeedbackList(VideoOutputResolutionFeedback, EdidManufacturerFeedback, EdidSerialNumberFeedback, EdidNameFeedback, EdidPreferredTimingFeedback);
|
AddToFeedbackList(VideoOutputResolutionFeedback, EdidManufacturerFeedback, EdidSerialNumberFeedback, EdidNameFeedback, EdidPreferredTimingFeedback);
|
||||||
|
|
||||||
|
DeviceInfo = new DeviceInfo();
|
||||||
|
|
||||||
|
_rmc.OnlineStatusChange += (currentDevice, args) => { if (args.DeviceOnLine) UpdateDeviceInfo(); };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void LinkDmRmcToApi(DmRmcControllerBase rmc, BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
protected void LinkDmRmcToApi(DmRmcControllerBase rmc, BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
||||||
@@ -79,7 +85,106 @@ namespace PepperDash.Essentials.DM
|
|||||||
|
|
||||||
trilist.SetUShortSigAction(joinMap.AudioVideoSource.JoinNumber, a => routing.ExecuteNumericSwitch(a, 1, eRoutingSignalType.AudioVideo));
|
trilist.SetUShortSigAction(joinMap.AudioVideoSource.JoinNumber, a => routing.ExecuteNumericSwitch(a, 1, eRoutingSignalType.AudioVideo));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
#region Implementation of IDeviceInfoProvider
|
||||||
|
|
||||||
|
public DeviceInfo DeviceInfo { get; private set; }
|
||||||
|
public event DeviceInfoChangeHandler DeviceInfoChanged;
|
||||||
|
|
||||||
|
public void UpdateDeviceInfo()
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Updating Device Info");
|
||||||
|
|
||||||
|
if (_rmc.ConnectedIpList.Count == 0)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "IP Address information not yet received. No device is online");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceInfo.IpAddress = _rmc.ConnectedIpList[0].DeviceIpAddress;
|
||||||
|
|
||||||
|
foreach (var ip in _rmc.ConnectedIpList)
|
||||||
|
{
|
||||||
|
Debug.Console(0, this, "Connected IP Address: {0}", ip.DeviceIpAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
GetFirmwareAndSerialInfo();
|
||||||
|
|
||||||
|
OnDeviceInfoChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetFirmwareAndSerialInfo()
|
||||||
|
{
|
||||||
|
var tcpClient = new GenericTcpIpClient(String.Format("{0}-devInfoSocket", Key), _rmc.ConnectedIpList[0].DeviceIpAddress, CtpPort, 1024)
|
||||||
|
{
|
||||||
|
AutoReconnect = false,
|
||||||
|
};
|
||||||
|
|
||||||
|
var gather = new CommunicationGather(tcpClient, "\r\n\r\n");
|
||||||
|
|
||||||
|
tcpClient.ConnectionChange += (sender, args) =>
|
||||||
|
{
|
||||||
|
if (!args.Client.IsConnected)
|
||||||
|
{
|
||||||
|
OnDeviceInfoChange();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
args.Client.SendText("ver\r\n");
|
||||||
|
};
|
||||||
|
|
||||||
|
gather.LineReceived += (sender, args) =>
|
||||||
|
{
|
||||||
|
//ignore console prompt
|
||||||
|
if (args.Text.ToLower().Contains(">"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (args.Text.ToLower().Contains("host"))
|
||||||
|
{
|
||||||
|
DeviceInfo.HostName = args.Text.Split(':')[1].Trim();
|
||||||
|
|
||||||
|
tcpClient.SendText("maca\r\n");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.Text.ToLower().Contains("mac"))
|
||||||
|
{
|
||||||
|
DeviceInfo.MacAddress = args.Text.Split(':')[1].Trim().Replace(" ", ":");
|
||||||
|
|
||||||
|
tcpClient.Disconnect();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!args.Text.ToLower().Contains("rmc"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceInfo.SerialNumber = args.Text.Split('[')[1].Split(' ')[4].Replace("#", "");
|
||||||
|
DeviceInfo.FirmwareVersion = args.Text.Split('[')[1].Split(' ')[1];
|
||||||
|
|
||||||
|
tcpClient.SendText("host\r\n");
|
||||||
|
};
|
||||||
|
|
||||||
|
tcpClient.Connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDeviceInfoChange()
|
||||||
|
{
|
||||||
|
var handler = DeviceInfoChanged;
|
||||||
|
|
||||||
|
if (handler == null) return;
|
||||||
|
|
||||||
|
handler(this, new DeviceInfoEventArgs(DeviceInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
public abstract class DmHdBaseTControllerBase : CrestronGenericBaseDevice
|
public abstract class DmHdBaseTControllerBase : CrestronGenericBaseDevice
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user