mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-31 05:14:51 +00:00
Started DmpsRoutingController
This commit is contained in:
@@ -21,8 +21,8 @@ namespace PepperDash.Essentials.DM
|
||||
/// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions
|
||||
///
|
||||
/// </summary>
|
||||
public class DmChassisController : CrestronGenericBaseDevice, IRoutingInputsOutputs, IRouting, IHasFeedback//, ICardPortsDevice
|
||||
{
|
||||
public class DmChassisController : CrestronGenericBaseDevice, IRoutingInputsOutputs, IRouting, IHasFeedback
|
||||
{
|
||||
public DmMDMnxn Chassis { get; private set; }
|
||||
|
||||
// Feedbacks for EssentialDM
|
||||
@@ -117,82 +117,6 @@ namespace PepperDash.Essentials.DM
|
||||
controller.InputNames = properties.InputNames;
|
||||
controller.OutputNames = properties.OutputNames;
|
||||
return controller;
|
||||
|
||||
|
||||
//DmChassisController controller = null;
|
||||
|
||||
//if (type == "dmmd8x8")
|
||||
//{
|
||||
// controller = new DmChassisController(key, name, new DmMd8x8(ipid, Global.ControlSystem));
|
||||
|
||||
// // add the cards and port names
|
||||
// foreach (var kvp in properties.InputSlots)
|
||||
// controller.AddInputCard(kvp.Value, kvp.Key);
|
||||
// foreach (var kvp in properties.OutputSlots)
|
||||
// {
|
||||
// controller.AddOutputCard(kvp.Value, kvp.Key);
|
||||
|
||||
// }
|
||||
|
||||
// foreach (var kvp in properties.VolumeControls)
|
||||
// {
|
||||
// // get the card
|
||||
// // check it for an audio-compatible type
|
||||
// // make a something-something that will make it work
|
||||
// // retire to mountain village
|
||||
// var outNum = kvp.Key;
|
||||
// var card = controller.Chassis.Outputs[outNum].Card;
|
||||
// Audio.Output audio = null;
|
||||
// if (card is DmcHdo)
|
||||
// audio = (card as DmcHdo).Audio;
|
||||
// else if (card is Dmc4kHdo)
|
||||
// audio = (card as Dmc4kHdo).Audio;
|
||||
// if (audio == null)
|
||||
// continue;
|
||||
// // wire up the audio to something here...
|
||||
// controller.AddVolumeControl(outNum, audio);
|
||||
// }
|
||||
|
||||
// controller.InputNames = properties.InputNames;
|
||||
// controller.OutputNames = properties.OutputNames;
|
||||
// return controller;
|
||||
//}
|
||||
//else if (type == "dmmd16x16")
|
||||
//{
|
||||
// controller = new DmChassisController(key, name, new DmMd16x16(ipid, Global.ControlSystem));
|
||||
|
||||
// // add the cards and port names
|
||||
// foreach (var kvp in properties.InputSlots)
|
||||
// controller.AddInputCard(kvp.Value, kvp.Key);
|
||||
// foreach (var kvp in properties.OutputSlots)
|
||||
// {
|
||||
// controller.AddOutputCard(kvp.Value, kvp.Key);
|
||||
|
||||
// }
|
||||
|
||||
// foreach (var kvp in properties.VolumeControls)
|
||||
// {
|
||||
// // get the card
|
||||
// // check it for an audio-compatible type
|
||||
// // make a something-something that will make it work
|
||||
// // retire to mountain village
|
||||
// var outNum = kvp.Key;
|
||||
// var card = controller.Chassis.Outputs[outNum].Card;
|
||||
// Audio.Output audio = null;
|
||||
// if (card is DmcHdo)
|
||||
// audio = (card as DmcHdo).Audio;
|
||||
// else if (card is Dmc4kHdo)
|
||||
// audio = (card as Dmc4kHdo).Audio;
|
||||
// if (audio == null)
|
||||
// continue;
|
||||
// // wire up the audio to something here...
|
||||
// controller.AddVolumeControl(outNum, audio);
|
||||
// }
|
||||
|
||||
// controller.InputNames = properties.InputNames;
|
||||
// controller.OutputNames = properties.OutputNames;
|
||||
// return controller;
|
||||
//}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints.Receivers;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
using PepperDash.Essentials.DM.Config;
|
||||
|
||||
namespace PepperDash.Essentials.DM
|
||||
{
|
||||
public class DmpsRoutingController : Device, IRoutingInputsOutputs, IRouting, IHasFeedback
|
||||
{
|
||||
public CrestronControlSystem Dmps { get; set; }
|
||||
public ISystemControl SystemControl { get; private set; }
|
||||
|
||||
// Feedbacks for EssentialDM
|
||||
public Dictionary<uint, IntFeedback> VideoOutputFeedbacks { get; private set; }
|
||||
public Dictionary<uint, IntFeedback> AudioOutputFeedbacks { get; private set; }
|
||||
public Dictionary<uint, BoolFeedback> VideoInputSyncFeedbacks { get; private set; }
|
||||
public Dictionary<uint, BoolFeedback> InputEndpointOnlineFeedbacks { get; private set; }
|
||||
public Dictionary<uint, BoolFeedback> OutputEndpointOnlineFeedbacks { get; private set; }
|
||||
public Dictionary<uint, StringFeedback> InputNameFeedbacks { get; private set; }
|
||||
public Dictionary<uint, StringFeedback> OutputNameFeedbacks { get; private set; }
|
||||
public Dictionary<uint, StringFeedback> OutputVideoRouteNameFeedbacks { get; private set; }
|
||||
public Dictionary<uint, StringFeedback> OutputAudioRouteNameFeedbacks { get; private set; }
|
||||
|
||||
// Need a couple Lists of generic Backplane ports
|
||||
public RoutingPortCollection<RoutingInputPort> InputPorts { get; private set; }
|
||||
public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
|
||||
|
||||
public Dictionary<uint, string> TxDictionary { get; set; }
|
||||
public Dictionary<uint, string> RxDictionary { get; set; }
|
||||
|
||||
public Dictionary<uint, string> InputNames { get; set; }
|
||||
public Dictionary<uint, string> OutputNames { get; set; }
|
||||
public Dictionary<uint, DmCardAudioOutputController> VolumeControls { get; private set; }
|
||||
|
||||
public const int RouteOffTime = 500;
|
||||
Dictionary<PortNumberType, CTimer> RouteOffTimers = new Dictionary<PortNumberType, CTimer>();
|
||||
|
||||
public static DmpsRoutingController GetDmpsRoutingController(string key, string name,
|
||||
string type, DmpsRoutingPropertiesConfig properties)
|
||||
{
|
||||
try
|
||||
{
|
||||
ISystemControl systemControl = null;
|
||||
|
||||
type = type.ToLower();
|
||||
|
||||
systemControl = Global.ControlSystem.SystemControl as ISystemControl;
|
||||
|
||||
if (systemControl == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var controller = new DmpsRoutingController(key, name, systemControl);
|
||||
|
||||
controller.InputNames = properties.InputNames;
|
||||
controller.OutputNames = properties.OutputNames;
|
||||
|
||||
return controller;
|
||||
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.Console(0, "Error getting DMPS Controller:\r{0}", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="chassis"></param>
|
||||
public DmpsRoutingController(string key, string name, ISystemControl systemControl)
|
||||
: base(key, name)
|
||||
{
|
||||
Dmps = Global.ControlSystem;
|
||||
|
||||
SystemControl = systemControl;
|
||||
InputPorts = new RoutingPortCollection<RoutingInputPort>();
|
||||
OutputPorts = new RoutingPortCollection<RoutingOutputPort>();
|
||||
VolumeControls = new Dictionary<uint, DmCardAudioOutputController>();
|
||||
TxDictionary = new Dictionary<uint, string>();
|
||||
RxDictionary = new Dictionary<uint, string>();
|
||||
|
||||
VideoOutputFeedbacks = new Dictionary<uint, IntFeedback>();
|
||||
AudioOutputFeedbacks = new Dictionary<uint, IntFeedback>();
|
||||
VideoInputSyncFeedbacks = new Dictionary<uint, BoolFeedback>();
|
||||
InputNameFeedbacks = new Dictionary<uint, StringFeedback>();
|
||||
OutputNameFeedbacks = new Dictionary<uint, StringFeedback>();
|
||||
OutputVideoRouteNameFeedbacks = new Dictionary<uint, StringFeedback>();
|
||||
OutputAudioRouteNameFeedbacks = new Dictionary<uint, StringFeedback>();
|
||||
InputEndpointOnlineFeedbacks = new Dictionary<uint, BoolFeedback>();
|
||||
OutputEndpointOnlineFeedbacks = new Dictionary<uint, BoolFeedback>();
|
||||
|
||||
Dmps.DMInputChange += new DMInputEventHandler(Dmps_DMInputChange);
|
||||
Dmps.DMOutputChange +=new DMOutputEventHandler(Dmps_DMOutputChange);
|
||||
}
|
||||
|
||||
void Dmps_DMInputChange(Switch device, DMInputEventArgs args)
|
||||
{
|
||||
//Debug.Console(2, this, "DMSwitch:{0} Input:{1} Event:{2}'", this.Name, args.Number, args.EventId.ToString());
|
||||
|
||||
switch (args.EventId)
|
||||
{
|
||||
case (DMInputEventIds.OnlineFeedbackEventId):
|
||||
{
|
||||
Debug.Console(2, this, "DMINput OnlineFeedbackEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback);
|
||||
InputEndpointOnlineFeedbacks[args.Number].FireUpdate();
|
||||
break;
|
||||
}
|
||||
case (DMInputEventIds.VideoDetectedEventId):
|
||||
{
|
||||
Debug.Console(2, this, "DM Input {0} VideoDetectedEventId", args.Number);
|
||||
VideoInputSyncFeedbacks[args.Number].FireUpdate();
|
||||
break;
|
||||
}
|
||||
case (DMInputEventIds.InputNameEventId):
|
||||
{
|
||||
Debug.Console(2, this, "DM Input {0} NameFeedbackEventId", args.Number);
|
||||
InputNameFeedbacks[args.Number].FireUpdate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
///
|
||||
/// </summary>
|
||||
void Dmps_DMOutputChange(Switch device, DMOutputEventArgs args)
|
||||
{
|
||||
var output = args.Number;
|
||||
if (args.EventId == DMOutputEventIds.VolumeEventId &&
|
||||
VolumeControls.ContainsKey(output))
|
||||
{
|
||||
VolumeControls[args.Number].VolumeEventFromChassis();
|
||||
}
|
||||
else if (args.EventId == DMOutputEventIds.OnlineFeedbackEventId)
|
||||
{
|
||||
OutputEndpointOnlineFeedbacks[output].FireUpdate();
|
||||
}
|
||||
else if (args.EventId == DMOutputEventIds.VideoOutEventId)
|
||||
{
|
||||
if (Dmps.SwitcherOutputs[output].VideoOutFeedback != null)
|
||||
{
|
||||
Debug.Console(2, this, "DMSwitchVideo:{0} Routed Input:{1} Output:{2}'", this.Name, Chassis.Outputs[output].VideoOutFeedback.Number, output);
|
||||
}
|
||||
if (VideoOutputFeedbacks.ContainsKey(output))
|
||||
{
|
||||
VideoOutputFeedbacks[output].FireUpdate();
|
||||
|
||||
}
|
||||
if (OutputVideoRouteNameFeedbacks.ContainsKey(output))
|
||||
{
|
||||
OutputVideoRouteNameFeedbacks[output].FireUpdate();
|
||||
}
|
||||
}
|
||||
else if (args.EventId == DMOutputEventIds.AudioOutEventId)
|
||||
{
|
||||
if (Dmps.SwitcherOutputsoutput].AudioOutFeedback != null)
|
||||
{
|
||||
Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", this.Name, Chassis.Outputs[output].AudioOutFeedback.Number, output);
|
||||
}
|
||||
if (AudioOutputFeedbacks.ContainsKey(output))
|
||||
{
|
||||
AudioOutputFeedbacks[output].FireUpdate();
|
||||
}
|
||||
}
|
||||
else if (args.EventId == DMOutputEventIds.OutputNameEventId)
|
||||
{
|
||||
Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output);
|
||||
OutputNameFeedbacks[output].FireUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.DM.Cards;
|
||||
|
||||
namespace PepperDash.Essentials.DM.Config
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the "properties" property of a DM device config
|
||||
/// </summary>
|
||||
public class DmpsRoutingPropertiesConfig
|
||||
{
|
||||
[JsonProperty("inputNames")]
|
||||
public Dictionary<uint, string> InputNames { get; set; }
|
||||
|
||||
[JsonProperty("outputNames")]
|
||||
public Dictionary<uint, string> OutputNames { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -97,7 +97,9 @@
|
||||
<Compile Include="Cards REMOVE\DmInputCardBase.cs" />
|
||||
<Compile Include="Chassis\DmCardAudioOutput.cs" />
|
||||
<Compile Include="Chassis\DmChassisController.cs" />
|
||||
<Compile Include="Chassis\DmpsRoutingController.cs" />
|
||||
<Compile Include="Chassis\HdMdNxM4kEController.cs" />
|
||||
<Compile Include="Config\DmpsChassisConfig.cs" />
|
||||
<Compile Include="Config\DmRmcConfig.cs" />
|
||||
<Compile Include="Config\DmTxConfig.cs" />
|
||||
<Compile Include="Config\DMChassisConfig.cs" />
|
||||
|
||||
Reference in New Issue
Block a user