mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-11 18:54:52 +00:00
Adds DmChassicControllerBridge. Created JoinMapBase base class
This commit is contained in:
@@ -11,6 +11,7 @@ using PepperDash.Core;
|
|||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Devices;
|
using PepperDash.Essentials.Core.Devices;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using PepperDash.Essentials.DM;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Bridges
|
namespace PepperDash.Essentials.Bridges
|
||||||
{
|
{
|
||||||
@@ -78,6 +79,10 @@ namespace PepperDash.Essentials.Bridges
|
|||||||
|
|
||||||
(device as GenericComm).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
(device as GenericComm).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
||||||
}
|
}
|
||||||
|
if (device is DmChassisController)
|
||||||
|
{
|
||||||
|
(device as DmChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
102
PepperDashEssentials/Bridges/DmChassisControllerBridge.cs
Normal file
102
PepperDashEssentials/Bridges/DmChassisControllerBridge.cs
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
|
||||||
|
using PepperDash.Core;
|
||||||
|
using PepperDash.Essentials.Core;
|
||||||
|
using PepperDash.Essentials.DM;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Bridges
|
||||||
|
{
|
||||||
|
public static class DmChassisControllerApiExtentions
|
||||||
|
{
|
||||||
|
public static void LinkToApi(this DmChassisController dmChassis, BasicTriList trilist, uint joinStart, string joinMapKey)
|
||||||
|
{
|
||||||
|
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DmChassisControllerJoinMap;
|
||||||
|
|
||||||
|
if (joinMap == null)
|
||||||
|
joinMap = new DmChassisControllerJoinMap();
|
||||||
|
|
||||||
|
joinMap.OffsetJoinNumbers(joinStart);
|
||||||
|
|
||||||
|
dmChassis.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
|
||||||
|
|
||||||
|
// Link up outputs
|
||||||
|
for (uint i = 1; i <= dmChassis.Chassis.NumberOfOutputs - 1; i++)
|
||||||
|
{
|
||||||
|
var ioSlot = i;
|
||||||
|
|
||||||
|
// Control
|
||||||
|
trilist.SetUShortSigAction(joinMap.OutputVideo + ioSlot, new Action<ushort>(o => dmChassis.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Video)));
|
||||||
|
trilist.SetUShortSigAction(joinMap.OutputAudio + ioSlot, new Action<ushort>(o => dmChassis.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Audio)));
|
||||||
|
|
||||||
|
// Feedback
|
||||||
|
dmChassis.VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo + ioSlot]);
|
||||||
|
dmChassis.AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio + ioSlot]);
|
||||||
|
|
||||||
|
dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]);
|
||||||
|
|
||||||
|
dmChassis.OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames + ioSlot]);
|
||||||
|
dmChassis.InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]);
|
||||||
|
dmChassis.OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames + ioSlot]);
|
||||||
|
dmChassis.OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentAudioInputNames + ioSlot]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class DmChassisControllerJoinMap : JoinMapBase
|
||||||
|
{
|
||||||
|
public uint IsOnline { get; set; }
|
||||||
|
public uint OutputVideo { get; set; }
|
||||||
|
public uint OutputAudio { get; set; }
|
||||||
|
public uint VideoSyncStatus { get; set; }
|
||||||
|
public uint InputNames { get; set; }
|
||||||
|
public uint OutputNames { get; set; }
|
||||||
|
public uint OutputCurrentVideoInputNames { get; set; }
|
||||||
|
public uint OutputCurrentAudioInputNames { get; set; }
|
||||||
|
public uint InputCurrentResolution { get; set; }
|
||||||
|
public uint HdcpSupport { get; set; }
|
||||||
|
public uint HdcpSupportCapability { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public DmChassisControllerJoinMap()
|
||||||
|
{
|
||||||
|
IsOnline = 11;
|
||||||
|
OutputVideo = 100; //101-299
|
||||||
|
OutputAudio = 300; //301-499
|
||||||
|
VideoSyncStatus = 100; //101-299
|
||||||
|
InputNames = 100; //101-299
|
||||||
|
OutputNames = 300; //301-499
|
||||||
|
OutputCurrentVideoInputNames = 2000; //2001-2199
|
||||||
|
OutputCurrentAudioInputNames = 2200; //2201-2399
|
||||||
|
InputCurrentResolution = 2400; // 2401-2599
|
||||||
|
HdcpSupport = 1000; //1001-1199
|
||||||
|
HdcpSupportCapability = 1200; //1201-1399
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OffsetJoinNumbers(uint joinStart)
|
||||||
|
{
|
||||||
|
var joinOffset = joinStart - 1;
|
||||||
|
|
||||||
|
IsOnline = IsOnline + joinOffset;
|
||||||
|
OutputVideo = OutputVideo + joinOffset;
|
||||||
|
OutputAudio = OutputAudio + joinOffset;
|
||||||
|
VideoSyncStatus = VideoSyncStatus + joinOffset;
|
||||||
|
InputNames = InputNames + joinOffset;
|
||||||
|
OutputNames = OutputNames + joinOffset;
|
||||||
|
OutputCurrentVideoInputNames = OutputCurrentVideoInputNames + joinOffset;
|
||||||
|
OutputCurrentAudioInputNames = OutputCurrentAudioInputNames + joinOffset;
|
||||||
|
InputCurrentResolution = InputCurrentResolution + joinOffset;
|
||||||
|
HdcpSupport = HdcpSupport + joinOffset;
|
||||||
|
HdcpSupportCapability = HdcpSupportCapability + joinOffset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,149 +1,131 @@
|
|||||||
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.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.DM;
|
|
||||||
|
namespace PepperDash.Essentials.Bridges
|
||||||
namespace PepperDash.Essentials.Bridges
|
{
|
||||||
{
|
public static class IBasicCommunicationApiExtensions
|
||||||
public static class IBasicCommunicationExtensions
|
{
|
||||||
{
|
public static void LinkToApi(this GenericComm comm, BasicTriList trilist, uint joinStart, string joinMapKey)
|
||||||
public static void LinkToApi(this GenericComm comm, BasicTriList trilist, uint joinStart, string joinMapKey)
|
{
|
||||||
{
|
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as IBasicCommunicationJoinMap;
|
||||||
var joinMap = GetJoinMapForDevice(joinMapKey);
|
|
||||||
|
if (joinMap == null)
|
||||||
if (joinMap == null)
|
joinMap = new IBasicCommunicationJoinMap();
|
||||||
joinMap = new IBasicCommunicationJoinMap();
|
|
||||||
|
joinMap.OffsetJoinNumbers(joinStart);
|
||||||
joinMap.OffsetJoinNumbers(joinStart);
|
|
||||||
|
if (comm.CommPort == null)
|
||||||
if (comm.CommPort == null)
|
{
|
||||||
{
|
Debug.Console(1, comm, "Unable to link device '{0}'. CommPort is null", comm.Key);
|
||||||
Debug.Console(1, comm, "Unable to link device '{0}'. CommPort is null", comm.Key);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
Debug.Console(1, comm, "Linking device '{0}' to Trilist '{1}'", comm.Key, trilist.ID);
|
||||||
Debug.Console(1, comm, "Linking device '{0}' to Trilist '{1}'", comm.Key, trilist.ID);
|
|
||||||
|
// this is a permanent event handler. This cannot be -= from event
|
||||||
// this is a permanent event handler. This cannot be -= from event
|
comm.CommPort.TextReceived += (s, a) => trilist.SetString(joinMap.TextReceived, a.Text);
|
||||||
comm.CommPort.TextReceived += (s, a) => trilist.SetString(joinMap.TextReceived, a.Text);
|
trilist.SetStringSigAction(joinMap.SendText, new Action<string>(s => comm.CommPort.SendText(s)));
|
||||||
trilist.SetStringSigAction(joinMap.SendText, new Action<string>(s => comm.CommPort.SendText(s)));
|
trilist.SetStringSigAction(joinMap.SetPortConfig + 1, new Action<string>(s => comm.SetPortConfig(s)));
|
||||||
trilist.SetStringSigAction(joinMap.SetPortConfig + 1, new Action<string>(s => comm.SetPortConfig(s)));
|
|
||||||
|
|
||||||
|
var sComm = comm.CommPort as ISocketStatus;
|
||||||
var sComm = comm.CommPort as ISocketStatus;
|
if (sComm != null)
|
||||||
if (sComm != null)
|
{
|
||||||
{
|
sComm.ConnectionChange += (s, a) =>
|
||||||
sComm.ConnectionChange += (s, a) =>
|
{
|
||||||
{
|
trilist.SetUshort(joinMap.Status, (ushort)(a.Client.ClientStatus));
|
||||||
trilist.SetUshort(joinMap.Status, (ushort)(a.Client.ClientStatus));
|
trilist.SetBool(joinMap.Connected, a.Client.ClientStatus ==
|
||||||
trilist.SetBool(joinMap.Connected, a.Client.ClientStatus ==
|
Crestron.SimplSharp.CrestronSockets.SocketStatus.SOCKET_STATUS_CONNECTED);
|
||||||
Crestron.SimplSharp.CrestronSockets.SocketStatus.SOCKET_STATUS_CONNECTED);
|
};
|
||||||
};
|
|
||||||
|
trilist.SetBoolSigAction(joinMap.Connect, new Action<bool>(b =>
|
||||||
trilist.SetBoolSigAction(joinMap.Connect, new Action<bool>(b =>
|
{
|
||||||
{
|
if (b)
|
||||||
if (b)
|
{
|
||||||
{
|
sComm.Connect();
|
||||||
sComm.Connect();
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
sComm.Disconnect();
|
||||||
sComm.Disconnect();
|
}
|
||||||
}
|
}));
|
||||||
}));
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attempts to get the join map from config
|
public class IBasicCommunicationJoinMap : JoinMapBase
|
||||||
/// </summary>
|
{
|
||||||
/// <param name="joinMapKey"></param>
|
// Default joins
|
||||||
/// <returns></returns>
|
public uint TextReceived { get; set; }
|
||||||
public static IBasicCommunicationJoinMap GetJoinMapForDevice(string joinMapKey)
|
public uint SendText { get; set; }
|
||||||
{
|
public uint SetPortConfig { get; set; }
|
||||||
if(!string.IsNullOrEmpty(joinMapKey))
|
public uint Connect { get; set; }
|
||||||
return null;
|
public uint Connected { get; set; }
|
||||||
|
public uint Status { get; set; }
|
||||||
// TODO: Get the join map from the ConfigReader.ConfigObject
|
|
||||||
|
public IBasicCommunicationJoinMap()
|
||||||
return null;
|
{
|
||||||
}
|
TextReceived = 1;
|
||||||
|
SendText = 1;
|
||||||
public class IBasicCommunicationJoinMap
|
SetPortConfig = 2;
|
||||||
{
|
Connect = 1;
|
||||||
// Default joins
|
Connected = 1;
|
||||||
public uint TextReceived { get; set; }
|
Status = 1;
|
||||||
public uint SendText { get; set; }
|
}
|
||||||
public uint SetPortConfig { get; set; }
|
|
||||||
public uint Connect { get; set; }
|
public override void OffsetJoinNumbers(uint joinStart)
|
||||||
public uint Connected { get; set; }
|
{
|
||||||
public uint Status { get; set; }
|
var joinOffset = joinStart - 1;
|
||||||
|
|
||||||
public IBasicCommunicationJoinMap()
|
TextReceived = TextReceived + joinOffset;
|
||||||
{
|
SendText = SendText + joinOffset;
|
||||||
TextReceived = 1;
|
SetPortConfig = SetPortConfig + joinOffset;
|
||||||
SendText = 1;
|
Connect = Connect + joinOffset;
|
||||||
SetPortConfig = 2;
|
Connected = Connected + joinOffset;
|
||||||
Connect = 1;
|
Status = Status + joinOffset;
|
||||||
Connected = 1;
|
}
|
||||||
Status = 1;
|
}
|
||||||
}
|
}
|
||||||
|
///// <summary>
|
||||||
/// <summary>
|
/////
|
||||||
/// Modifies all the join numbers by adding the offset. This should never be called twice
|
///// </summary>
|
||||||
/// </summary>
|
//public static class DmChassisControllerApiExtensions
|
||||||
/// <param name="joinStart"></param>
|
//{
|
||||||
public void OffsetJoinNumbers(uint joinStart)
|
// public static void LinkToApi(this PepperDash.Essentials.DM.DmChassisController chassis,
|
||||||
{
|
// BasicTriList trilist, Dictionary<string,uint> map, uint joinstart)
|
||||||
var joinOffset = joinStart - 1;
|
// {
|
||||||
|
// uint joinOffset = joinstart - 1;
|
||||||
TextReceived = TextReceived + joinOffset;
|
|
||||||
SendText = SendText + joinOffset;
|
// uint videoSelectOffset = 0 + joinOffset;
|
||||||
SetPortConfig = SetPortConfig + joinOffset;
|
// uint audioSelectOffset = 40 + joinOffset;
|
||||||
Connect = Connect + joinOffset;
|
|
||||||
Connected = Connected + joinOffset;
|
|
||||||
Status = Status + joinOffset;
|
// // loop chassis number of inupts
|
||||||
}
|
// for (uint i = 1; i <= chassis.Chassis.NumberOfOutputs; i++)
|
||||||
}
|
// {
|
||||||
}
|
// trilist.SetUShortSigAction(videoSelectOffset + i, new Action<ushort>(u => chassis.ExecuteSwitch(u, i, eRoutingSignalType.Video)));
|
||||||
///// <summary>
|
// trilist.SetUShortSigAction(audioSelectOffset + i, new Action<ushort>(u => chassis.ExecuteSwitch(u, i, eRoutingSignalType.Audio)));
|
||||||
/////
|
// }
|
||||||
///// </summary>
|
|
||||||
//public static class DmChassisControllerApiExtensions
|
// // wire up output change detection (try to add feedbacks or something to DMChassisController??
|
||||||
//{
|
|
||||||
// public static void LinkToApi(this PepperDash.Essentials.DM.DmChassisController chassis,
|
// // names?
|
||||||
// BasicTriList trilist, Dictionary<string,uint> map, uint joinstart)
|
|
||||||
// {
|
// // HDCP?
|
||||||
// uint joinOffset = joinstart - 1;
|
|
||||||
|
|
||||||
// uint videoSelectOffset = 0 + joinOffset;
|
// }
|
||||||
// uint audioSelectOffset = 40 + joinOffset;
|
//}
|
||||||
|
|
||||||
|
|
||||||
// // loop chassis number of inupts
|
|
||||||
// for (uint i = 1; i <= chassis.Chassis.NumberOfOutputs; i++)
|
|
||||||
// {
|
|
||||||
// trilist.SetUShortSigAction(videoSelectOffset + i, new Action<ushort>(u => chassis.ExecuteSwitch(u, i, eRoutingSignalType.Video)));
|
|
||||||
// trilist.SetUShortSigAction(audioSelectOffset + i, new Action<ushort>(u => chassis.ExecuteSwitch(u, i, eRoutingSignalType.Audio)));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // wire up output change detection (try to add feedbacks or something to DMChassisController??
|
|
||||||
|
|
||||||
// // names?
|
|
||||||
|
|
||||||
// // HDCP?
|
|
||||||
|
|
||||||
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
40
PepperDashEssentials/Bridges/JoinMapBase.cs
Normal file
40
PepperDashEssentials/Bridges/JoinMapBase.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Bridges
|
||||||
|
{
|
||||||
|
public static class JoinMapHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to get the join map from config
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="joinMapKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static JoinMapBase GetJoinMapForDevice(string joinMapKey)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(joinMapKey))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// FUTURE TODO: Get the join map from the ConfigReader.ConfigObject
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public abstract class JoinMapBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Modifies all the join numbers by adding the offset. This should never be called twice
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="joinStart"></param>
|
||||||
|
public abstract void OffsetJoinNumbers(uint joinStart);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -112,7 +112,9 @@
|
|||||||
<Compile Include="Audio\EssentialsVolumeLevelConfig.cs" />
|
<Compile Include="Audio\EssentialsVolumeLevelConfig.cs" />
|
||||||
<Compile Include="Bridges\BridgeBase.cs" />
|
<Compile Include="Bridges\BridgeBase.cs" />
|
||||||
<Compile Include="Bridges\BridgeFactory.cs" />
|
<Compile Include="Bridges\BridgeFactory.cs" />
|
||||||
<Compile Include="Bridges\IBasicCommunicationBridgeMap.cs" />
|
<Compile Include="Bridges\DmChassisControllerBridge.cs" />
|
||||||
|
<Compile Include="Bridges\IBasicCommunicationBridge.cs" />
|
||||||
|
<Compile Include="Bridges\JoinMapBase.cs" />
|
||||||
<Compile Include="Configuration ORIGINAL\Builders\TPConfig.cs" />
|
<Compile Include="Configuration ORIGINAL\Builders\TPConfig.cs" />
|
||||||
<Compile Include="Configuration ORIGINAL\Configuration.cs" />
|
<Compile Include="Configuration ORIGINAL\Configuration.cs" />
|
||||||
<Compile Include="Configuration ORIGINAL\ConfigurationHelpers.cs" />
|
<Compile Include="Configuration ORIGINAL\ConfigurationHelpers.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user