mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-12 19:24:53 +00:00
Compare commits
2 Commits
hotfix/114
...
1.15.3-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08af6370a6 | ||
|
|
97c0bddb48 |
@@ -17,12 +17,10 @@ using PepperDash_Essentials_DM.Config;
|
||||
namespace PepperDash_Essentials_DM.Chassis
|
||||
{
|
||||
[Description("Wrapper class for all HdPsXxx switchers")]
|
||||
public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IHasFeedback
|
||||
public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, ICec, IHasHdmiInHdcp, IHasFeedback
|
||||
{
|
||||
|
||||
private readonly HdPsXxx _chassis;
|
||||
private readonly HdPs401 _chassis401;
|
||||
private readonly HdPs621 _chassis621;
|
||||
|
||||
public RoutingPortCollection<RoutingInputPort> InputPorts { get; private set; }
|
||||
public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
|
||||
@@ -63,35 +61,29 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
return;
|
||||
}
|
||||
|
||||
InputPorts = new RoutingPortCollection<RoutingInputPort>();
|
||||
InputPorts = new RoutingPortCollection<RoutingInputPort>();
|
||||
InputNameFeedbacks = new FeedbackCollection<StringFeedback>();
|
||||
InputHdcpEnableFeedback = new FeedbackCollection<BoolFeedback>();
|
||||
InputNames = new Dictionary<uint, string>();
|
||||
//InputNames = props.Inputs;
|
||||
InputNames = new Dictionary<uint, string>();
|
||||
|
||||
OutputPorts = new RoutingPortCollection<RoutingOutputPort>();
|
||||
OutputNameFeedbacks = new FeedbackCollection<StringFeedback>();
|
||||
OutputRouteNameFeedback = new FeedbackCollection<StringFeedback>();
|
||||
OutputNames = new Dictionary<uint, string>();
|
||||
//OutputNames = props.Outputs;
|
||||
|
||||
VideoInputSyncFeedbacks = new FeedbackCollection<BoolFeedback>();
|
||||
VideoOutputRouteFeedbacks = new FeedbackCollection<IntFeedback>();
|
||||
|
||||
if (_chassis.NumberOfOutputs == 1)
|
||||
{
|
||||
if (_chassis is HdPs401)
|
||||
_chassis401 = _chassis as HdPs401;
|
||||
if (_chassis is HdPs621)
|
||||
_chassis621 = _chassis as HdPs621;
|
||||
AutoRouteFeedback = new BoolFeedback(() => _chassis.PriorityRouteOnFeedback.BoolValue);
|
||||
|
||||
AutoRouteFeedback = new BoolFeedback(() => _chassis401.PriorityRouteOnFeedback.BoolValue);
|
||||
}
|
||||
InputNames = props.Inputs;
|
||||
SetupInputs(InputNames);
|
||||
|
||||
SetupInputs(props.Inputs);
|
||||
SetupOutputs(props.Outputs);
|
||||
OutputNames = props.Outputs;
|
||||
SetupOutputs(OutputNames);
|
||||
|
||||
AddPostActivationAction(AddFeedbackCollecitons);
|
||||
//AddPostActivationAction();
|
||||
}
|
||||
|
||||
// input setup
|
||||
@@ -106,35 +98,63 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
{
|
||||
Debug.Console(1, this, "props.Input[{0}]: {1}", kvp.Key, kvp.Value);
|
||||
}
|
||||
InputNames = dict;
|
||||
|
||||
for (uint i = 1; i <= _chassis.NumberOfInputs; i++)
|
||||
// TODO [ ] testing
|
||||
var hdmiKeys = _chassis.HdmiInputs.Keys;
|
||||
foreach (var key in hdmiKeys)
|
||||
{
|
||||
var index = i;
|
||||
var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("Input {0}", index) : InputNames[index];
|
||||
var input = _chassis.Inputs[index];
|
||||
var hdmiInput = _chassis.HdmiInputs[index];
|
||||
var dmLiteInput = _chassis.DmLiteInputs[index];
|
||||
Debug.Console(0, this, "HDMI Input key-'{0}'", key);
|
||||
}
|
||||
|
||||
var dmKeys = _chassis.DmLiteInputs.Keys;
|
||||
foreach (var key in dmKeys)
|
||||
{
|
||||
Debug.Console(0, this, "DM Input key-'{0}'", key);
|
||||
}
|
||||
|
||||
|
||||
foreach (var item in _chassis.HdmiInputs)
|
||||
{
|
||||
var input = item;
|
||||
var index = item.Number;
|
||||
var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("HDMI Input {0}", index) : InputNames[index];
|
||||
|
||||
InputNameFeedbacks.Add(new StringFeedback(name, () => InputNames[index]));
|
||||
|
||||
// TODO [ ] verify which input type is needed
|
||||
input.Name.StringValue = name;
|
||||
hdmiInput.Name.StringValue = name;
|
||||
dmLiteInput.Name.StringValue = name;
|
||||
|
||||
var port = new RoutingInputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this)
|
||||
{
|
||||
FeedbackMatchObject = input
|
||||
};
|
||||
InputPorts.Add(port);
|
||||
|
||||
InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => hdmiInput.InputPort.HdcpSupportOnFeedback.BoolValue));
|
||||
InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue));
|
||||
|
||||
VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue));
|
||||
}
|
||||
|
||||
foreach (var item in _chassis.DmLiteInputs)
|
||||
{
|
||||
var input = item;
|
||||
var index = item.Number;
|
||||
|
||||
var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("DM Input {0}", index) : InputNames[index];
|
||||
input.Name.StringValue = name;
|
||||
|
||||
InputNameFeedbacks.Add(new StringFeedback(name, () => InputNames[index]));
|
||||
|
||||
var port = new RoutingInputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this)
|
||||
{
|
||||
FeedbackMatchObject = input
|
||||
};
|
||||
InputPorts.Add(port);
|
||||
|
||||
|
||||
InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue));
|
||||
|
||||
VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue));
|
||||
}
|
||||
|
||||
_chassis.DMInputChange += _chassis_InputChange;
|
||||
_chassis.DMInputChange += _chassis_InputChange;
|
||||
}
|
||||
|
||||
// output setup
|
||||
@@ -149,20 +169,22 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
{
|
||||
Debug.Console(1, this, "props.Output[{0}]: {1}", kvp.Key, kvp.Value);
|
||||
}
|
||||
OutputNames = dict;
|
||||
|
||||
for (uint i = 1; i <= _chassis.NumberOfOutputs; i++)
|
||||
|
||||
// TODO [ ] testing
|
||||
var keys = _chassis.HdmiDmLiteOutputs.Keys;
|
||||
foreach (var key in keys)
|
||||
{
|
||||
var index = i;
|
||||
Debug.Console(0, this, "HdmiDmLite Output key-'{0}'", key);
|
||||
}
|
||||
|
||||
foreach (var item in _chassis.HdmiDmLiteOutputs)
|
||||
{
|
||||
var output = item;
|
||||
var index = item.Number;
|
||||
|
||||
var name = string.IsNullOrEmpty(OutputNames[index]) ? string.Format("Output {0}", index) : OutputNames[index];
|
||||
var output = _chassis.Outputs[index];
|
||||
var hdmiDmLiteOutput = _chassis.HdmiDmLiteOutputs[index];
|
||||
|
||||
OutputNameFeedbacks.Add(new StringFeedback(name, () => OutputNames[index]));
|
||||
|
||||
// TODO [ ] verify which output type is needed
|
||||
output.Name.StringValue = name;
|
||||
hdmiDmLiteOutput.Name.StringValue = name;
|
||||
|
||||
var port = new RoutingOutputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this)
|
||||
{
|
||||
@@ -174,7 +196,7 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
|
||||
VideoOutputRouteFeedbacks.Add(new IntFeedback(name, () => output.VideoOutFeedback == null ? 0 : (int)output.VideoOutFeedback.Number));
|
||||
}
|
||||
|
||||
|
||||
_chassis.DMOutputChange += _chassis_OutputChange;
|
||||
}
|
||||
|
||||
@@ -206,10 +228,6 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
|
||||
_chassis.OnlineStatusChange += _chassis_OnlineStatusChange;
|
||||
|
||||
if (_chassis401 != null) LinkChassis401ToApi(trilist, joinMap);
|
||||
|
||||
if (_chassis621 != null) LinkChassis621ToApi(trilist, joinMap);
|
||||
|
||||
LinkChassisInputsToApi(trilist, joinMap);
|
||||
LinkChassisOutputsToApi(trilist, joinMap);
|
||||
|
||||
@@ -252,38 +270,19 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
var indexWithOffset = output - 1;
|
||||
|
||||
trilist.SetUShortSigAction(joinMap.OutputRoute.JoinNumber + indexWithOffset, (a) =>
|
||||
ExecuteNumericSwitch(a, (ushort) output, eRoutingSignalType.AudioVideo));
|
||||
ExecuteNumericSwitch(a, (ushort)output, eRoutingSignalType.AudioVideo));
|
||||
|
||||
OutputNameFeedbacks[outputName].LinkInputSig(trilist.StringInput[joinMap.OutputName.JoinNumber + indexWithOffset]);
|
||||
OutputRouteNameFeedback[outputName].LinkInputSig(trilist.StringInput[joinMap.OutputRoutedName.JoinNumber + indexWithOffset]);
|
||||
|
||||
VideoOutputRouteFeedbacks[outputName].LinkInputSig(trilist.UShortInput[joinMap.OutputRoute.JoinNumber + indexWithOffset]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// links HdPs401 chassis to API
|
||||
private void LinkChassis401ToApi(BasicTriList trilist, HdPsXxxControllerJoinMap joinMap)
|
||||
{
|
||||
trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis401.AutoRouteOn());
|
||||
trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis401.AutoRouteOff());
|
||||
|
||||
AutoRouteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]);
|
||||
}
|
||||
|
||||
|
||||
// links HdPs621 chassis to API
|
||||
private void LinkChassis621ToApi(BasicTriList trilist, HdPsXxxControllerJoinMap joinMap)
|
||||
{
|
||||
trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis621.AutoRouteOn());
|
||||
trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis621.AutoRouteOff());
|
||||
|
||||
AutoRouteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Executes a device switch using objects
|
||||
@@ -359,17 +358,9 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
/// </summary>
|
||||
public void EnableAutoRoute()
|
||||
{
|
||||
if (_chassis.NumberOfInputs != 1) return;
|
||||
if (_chassis.NumberOfInputs == 1) return;
|
||||
|
||||
if (_chassis401 != null)
|
||||
{
|
||||
_chassis401.AutoRouteOn();
|
||||
}
|
||||
|
||||
if (_chassis621 != null)
|
||||
{
|
||||
_chassis621.AutoRouteOn();
|
||||
}
|
||||
_chassis.AutoRouteOn();
|
||||
}
|
||||
|
||||
|
||||
@@ -378,20 +369,12 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
/// </summary>
|
||||
public void DisableAutoRoute()
|
||||
{
|
||||
if (_chassis.NumberOfInputs != 1) return;
|
||||
if (_chassis.NumberOfInputs == 1) return;
|
||||
|
||||
if (_chassis401 != null)
|
||||
{
|
||||
_chassis401.AutoRouteOff();
|
||||
}
|
||||
|
||||
if (_chassis621 != null)
|
||||
{
|
||||
_chassis621.AutoRouteOff();
|
||||
}
|
||||
_chassis.AutoRouteOff();
|
||||
}
|
||||
|
||||
#region Events
|
||||
#region Events
|
||||
|
||||
|
||||
// _chassis online/offline event
|
||||
@@ -417,31 +400,31 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
switch (eventId)
|
||||
{
|
||||
case DMInputEventIds.VideoDetectedEventId:
|
||||
{
|
||||
Debug.Console(1, this, "Event ID {0}: Updating VideoInputSyncFeedbacks", eventId);
|
||||
foreach (var item in VideoInputSyncFeedbacks)
|
||||
{
|
||||
item.FireUpdate();
|
||||
Debug.Console(1, this, "Event ID {0}: Updating VideoInputSyncFeedbacks", eventId);
|
||||
foreach (var item in VideoInputSyncFeedbacks)
|
||||
{
|
||||
item.FireUpdate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DMInputEventIds.InputNameFeedbackEventId:
|
||||
case DMInputEventIds.InputNameEventId:
|
||||
case DMInputEventIds.NameFeedbackEventId:
|
||||
{
|
||||
Debug.Console(1, this, "Event ID {0}: Updating name feedbacks", eventId);
|
||||
{
|
||||
Debug.Console(1, this, "Event ID {0}: Updating name feedbacks", eventId);
|
||||
|
||||
var input = args.Number;
|
||||
var name = _chassis.HdmiInputs[input].NameFeedback.StringValue;
|
||||
var input = args.Number;
|
||||
var name = _chassis.HdmiInputs[input].NameFeedback.StringValue;
|
||||
|
||||
Debug.Console(1, this, "Input {0} Name {1}", input, name);
|
||||
break;
|
||||
}
|
||||
Debug.Console(1, this, "Input {0} Name {1}", input, name);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
Debug.Console(1, this, "Uhandled DM Input Event ID {0}", eventId);
|
||||
break;
|
||||
}
|
||||
{
|
||||
Debug.Console(1, this, "Uhandled DM Input Event ID {0}", eventId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -486,115 +469,7 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region FeedbacksAndFeedbackCollections
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add feedback colleciton arrays to feedback collections
|
||||
/// </summary>
|
||||
/// <param name="feedbackCollections">BoolFeedback[] arrays</param>
|
||||
public void AddCollectionsToList(params FeedbackCollection<BoolFeedback>[] feedbackCollections)
|
||||
{
|
||||
foreach (var item in feedbackCollections.SelectMany(feedbackCollection => feedbackCollections))
|
||||
{
|
||||
AddCollectionsToList(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add feedback colleciton arrays to feedback collections
|
||||
/// </summary>
|
||||
/// <param name="feedbackCollections">IntFeedback[] arrays</param>
|
||||
public void AddCollectionsToList(params FeedbackCollection<IntFeedback>[] feedbackCollections)
|
||||
{
|
||||
foreach (var item in feedbackCollections.SelectMany(feedbackCollection => feedbackCollections))
|
||||
{
|
||||
AddCollectionsToList(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add feedback colleciton arrays to feedback collections
|
||||
/// </summary>
|
||||
/// <param name="feedbackCollections">StringFeedback[] arrays</param>
|
||||
public void AddCollectionsToList(params FeedbackCollection<StringFeedback>[] feedbackCollections)
|
||||
{
|
||||
foreach (var item in feedbackCollections.SelectMany(feedbackCollection => feedbackCollections))
|
||||
{
|
||||
AddCollectionsToList(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds feedback colleciton to feedback collections
|
||||
/// </summary>
|
||||
/// <param name="feedbackCollection">BoolFeedback</param>
|
||||
public void AddCollectionToList(FeedbackCollection<BoolFeedback> feedbackCollection)
|
||||
{
|
||||
foreach (var item in feedbackCollection.Where(item => item != null))
|
||||
{
|
||||
AddFeedbackToList(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds feedback colleciton to feedback collections
|
||||
/// </summary>
|
||||
/// <param name="feedbackCollection">IntFeedback</param>
|
||||
public void AddCollectionToList(FeedbackCollection<IntFeedback> feedbackCollection)
|
||||
{
|
||||
foreach (var item in feedbackCollection.Where(item => item != null))
|
||||
{
|
||||
AddFeedbackToList(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds feedback colleciton to feedback collections
|
||||
/// </summary>
|
||||
/// <param name="feedbackCollection">StringFeedback</param>
|
||||
public void AddCollectionToList(FeedbackCollection<StringFeedback> feedbackCollection)
|
||||
{
|
||||
foreach (var item in feedbackCollection.Where(item => item != null))
|
||||
{
|
||||
AddFeedbackToList(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds individual feedbacks to feedback collection
|
||||
/// </summary>
|
||||
/// <param name="fb">Feedback</param>
|
||||
public void AddFeedbackToList(PepperDash.Essentials.Core.Feedback fb)
|
||||
{
|
||||
if (fb == null || Feedbacks.Contains(fb)) return;
|
||||
|
||||
Feedbacks.Add(fb);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds provided feedbacks to feedback collection list
|
||||
/// </summary>
|
||||
public void AddFeedbackCollecitons()
|
||||
{
|
||||
AddFeedbackToList(DeviceNameFeedback);
|
||||
AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback);
|
||||
AddCollectionsToList(VideoOutputRouteFeedbacks);
|
||||
AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedback);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
#region Factory
|
||||
@@ -608,7 +483,11 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
}
|
||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||
{
|
||||
Debug.Console(1, "Factory Attempting to create new HD-PSXxx device");
|
||||
var key = dc.Key;
|
||||
var name = dc.Name;
|
||||
var type = dc.Type.ToLower();
|
||||
|
||||
Debug.Console(1, "Factory Attempting to create new {0} device", type);
|
||||
|
||||
var props = JsonConvert.DeserializeObject<HdPsXxxPropertiesConfig>(dc.Properties.ToString());
|
||||
if (props == null)
|
||||
@@ -617,12 +496,7 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
return null;
|
||||
}
|
||||
|
||||
var key = dc.Key;
|
||||
var name = dc.Name;
|
||||
var type = dc.Type.ToLower();
|
||||
var control = props.Control;
|
||||
var ipid = control.IpIdInt;
|
||||
//var address = control.TcpSshProperties.Address;
|
||||
var ipid = props.Control.IpIdInt;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@@ -653,5 +527,17 @@ namespace PepperDash_Essentials_DM.Chassis
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
// TODO [ ] Implement CEC control
|
||||
// return _chassis.HdmiDmLiteOutputs[0].DmLiteOutput.DmLiteOutputPort.StreamCec;
|
||||
public Cec StreamCec { get; private set; }
|
||||
|
||||
public IntFeedback HdmiInHdcpStateFeedback { get; private set; }
|
||||
public void SetHdmiInHdcpState(eHdcpCapabilityType hdcpState)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public eHdcpCapabilityType HdmiInHdcpCapability { get; private set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user