mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 12:15:01 +00:00
fix(wip): refactors SetupInputs() and SetupOutputs() to handle io types
This commit is contained in:
@@ -21,8 +21,6 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
{
|
{
|
||||||
|
|
||||||
private readonly HdPsXxx _chassis;
|
private readonly HdPsXxx _chassis;
|
||||||
private readonly HdPs401 _chassis401;
|
|
||||||
private readonly HdPs621 _chassis621;
|
|
||||||
|
|
||||||
public RoutingPortCollection<RoutingInputPort> InputPorts { get; private set; }
|
public RoutingPortCollection<RoutingInputPort> InputPorts { get; private set; }
|
||||||
public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
|
public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
|
||||||
@@ -63,33 +61,35 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputPorts = new RoutingPortCollection<RoutingInputPort>();
|
InputPorts = new RoutingPortCollection<RoutingInputPort>();
|
||||||
InputNameFeedbacks = new FeedbackCollection<StringFeedback>();
|
InputNameFeedbacks = new FeedbackCollection<StringFeedback>();
|
||||||
InputHdcpEnableFeedback = new FeedbackCollection<BoolFeedback>();
|
InputHdcpEnableFeedback = new FeedbackCollection<BoolFeedback>();
|
||||||
InputNames = new Dictionary<uint, string>();
|
InputNames = new Dictionary<uint, string>();
|
||||||
//InputNames = props.Inputs;
|
|
||||||
|
|
||||||
OutputPorts = new RoutingPortCollection<RoutingOutputPort>();
|
OutputPorts = new RoutingPortCollection<RoutingOutputPort>();
|
||||||
OutputNameFeedbacks = new FeedbackCollection<StringFeedback>();
|
OutputNameFeedbacks = new FeedbackCollection<StringFeedback>();
|
||||||
OutputRouteNameFeedback = new FeedbackCollection<StringFeedback>();
|
OutputRouteNameFeedback = new FeedbackCollection<StringFeedback>();
|
||||||
OutputNames = new Dictionary<uint, string>();
|
OutputNames = new Dictionary<uint, string>();
|
||||||
//OutputNames = props.Outputs;
|
|
||||||
|
|
||||||
VideoInputSyncFeedbacks = new FeedbackCollection<BoolFeedback>();
|
VideoInputSyncFeedbacks = new FeedbackCollection<BoolFeedback>();
|
||||||
VideoOutputRouteFeedbacks = new FeedbackCollection<IntFeedback>();
|
VideoOutputRouteFeedbacks = new FeedbackCollection<IntFeedback>();
|
||||||
|
|
||||||
if (_chassis.NumberOfOutputs == 1)
|
if (_chassis.NumberOfOutputs == 1)
|
||||||
{
|
{
|
||||||
if (_chassis is HdPs401)
|
//if (_chassis is HdPs401)
|
||||||
_chassis401 = _chassis as HdPs401;
|
// _chassis401 = _chassis as HdPs401;
|
||||||
if (_chassis is HdPs621)
|
//if (_chassis is HdPs621)
|
||||||
_chassis621 = _chassis as HdPs621;
|
// _chassis621 = _chassis as HdPs621;
|
||||||
|
|
||||||
AutoRouteFeedback = new BoolFeedback(() => _chassis401.PriorityRouteOnFeedback.BoolValue);
|
AutoRouteFeedback = new BoolFeedback(() => _chassis.PriorityRouteOnFeedback.BoolValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupInputs(props.Inputs);
|
|
||||||
SetupOutputs(props.Outputs);
|
InputNames = props.Inputs;
|
||||||
|
SetupInputs(InputNames);
|
||||||
|
|
||||||
|
OutputNames = props.Outputs;
|
||||||
|
SetupOutputs(OutputNames);
|
||||||
|
|
||||||
AddPostActivationAction(AddFeedbackCollecitons);
|
AddPostActivationAction(AddFeedbackCollecitons);
|
||||||
}
|
}
|
||||||
@@ -106,35 +106,49 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
{
|
{
|
||||||
Debug.Console(1, this, "props.Input[{0}]: {1}", kvp.Key, kvp.Value);
|
Debug.Console(1, this, "props.Input[{0}]: {1}", kvp.Key, kvp.Value);
|
||||||
}
|
}
|
||||||
InputNames = dict;
|
|
||||||
|
|
||||||
for (uint i = 1; i <= _chassis.NumberOfInputs; i++)
|
foreach (var item in _chassis.HdmiInputs)
|
||||||
{
|
{
|
||||||
var index = i;
|
var input = item;
|
||||||
var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("Input {0}", index) : InputNames[index];
|
var index = item.Number;
|
||||||
var input = _chassis.Inputs[index];
|
var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("HDMI Input {0}", index) : InputNames[index];
|
||||||
var hdmiInput = _chassis.HdmiInputs[index];
|
|
||||||
var dmLiteInput = _chassis.DmLiteInputs[index];
|
|
||||||
|
|
||||||
InputNameFeedbacks.Add(new StringFeedback(name, () => 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)
|
var port = new RoutingInputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this)
|
||||||
{
|
{
|
||||||
FeedbackMatchObject = input
|
FeedbackMatchObject = input
|
||||||
};
|
};
|
||||||
InputPorts.Add(port);
|
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));
|
VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
_chassis.DMInputChange += _chassis_InputChange;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// output setup
|
// output setup
|
||||||
@@ -149,20 +163,14 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
{
|
{
|
||||||
Debug.Console(1, this, "props.Output[{0}]: {1}", kvp.Key, kvp.Value);
|
Debug.Console(1, this, "props.Output[{0}]: {1}", kvp.Key, kvp.Value);
|
||||||
}
|
}
|
||||||
OutputNames = dict;
|
|
||||||
|
|
||||||
for (uint i = 1; i <= _chassis.NumberOfOutputs; i++)
|
foreach (var item in _chassis.HdmiDmLiteOutputs)
|
||||||
{
|
{
|
||||||
var index = i;
|
var output = item;
|
||||||
|
var index = item.Number;
|
||||||
|
|
||||||
var name = string.IsNullOrEmpty(OutputNames[index]) ? string.Format("Output {0}", index) : OutputNames[index];
|
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;
|
output.Name.StringValue = name;
|
||||||
hdmiDmLiteOutput.Name.StringValue = name;
|
|
||||||
|
|
||||||
var port = new RoutingOutputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this)
|
var port = new RoutingOutputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this)
|
||||||
{
|
{
|
||||||
@@ -206,10 +214,6 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
|
|
||||||
_chassis.OnlineStatusChange += _chassis_OnlineStatusChange;
|
_chassis.OnlineStatusChange += _chassis_OnlineStatusChange;
|
||||||
|
|
||||||
if (_chassis401 != null) LinkChassis401ToApi(trilist, joinMap);
|
|
||||||
|
|
||||||
if (_chassis621 != null) LinkChassis621ToApi(trilist, joinMap);
|
|
||||||
|
|
||||||
LinkChassisInputsToApi(trilist, joinMap);
|
LinkChassisInputsToApi(trilist, joinMap);
|
||||||
LinkChassisOutputsToApi(trilist, joinMap);
|
LinkChassisOutputsToApi(trilist, joinMap);
|
||||||
|
|
||||||
@@ -252,36 +256,17 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
var indexWithOffset = output - 1;
|
var indexWithOffset = output - 1;
|
||||||
|
|
||||||
trilist.SetUShortSigAction(joinMap.OutputRoute.JoinNumber + indexWithOffset, (a) =>
|
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]);
|
OutputNameFeedbacks[outputName].LinkInputSig(trilist.StringInput[joinMap.OutputName.JoinNumber + indexWithOffset]);
|
||||||
OutputRouteNameFeedback[outputName].LinkInputSig(trilist.StringInput[joinMap.OutputRoutedName.JoinNumber + indexWithOffset]);
|
OutputRouteNameFeedback[outputName].LinkInputSig(trilist.StringInput[joinMap.OutputRoutedName.JoinNumber + indexWithOffset]);
|
||||||
|
|
||||||
VideoOutputRouteFeedbacks[outputName].LinkInputSig(trilist.UShortInput[joinMap.OutputRoute.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]);
|
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
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -359,17 +344,9 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void EnableAutoRoute()
|
public void EnableAutoRoute()
|
||||||
{
|
{
|
||||||
if (_chassis.NumberOfInputs != 1) return;
|
if (_chassis.NumberOfInputs == 1) return;
|
||||||
|
|
||||||
if (_chassis401 != null)
|
_chassis.AutoRouteOn();
|
||||||
{
|
|
||||||
_chassis401.AutoRouteOn();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_chassis621 != null)
|
|
||||||
{
|
|
||||||
_chassis621.AutoRouteOn();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -378,20 +355,12 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void DisableAutoRoute()
|
public void DisableAutoRoute()
|
||||||
{
|
{
|
||||||
if (_chassis.NumberOfInputs != 1) return;
|
if (_chassis.NumberOfInputs == 1) return;
|
||||||
|
|
||||||
if (_chassis401 != null)
|
_chassis.AutoRouteOff();
|
||||||
{
|
|
||||||
_chassis401.AutoRouteOff();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_chassis621 != null)
|
|
||||||
{
|
|
||||||
_chassis621.AutoRouteOff();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Events
|
#region Events
|
||||||
|
|
||||||
|
|
||||||
// _chassis online/offline event
|
// _chassis online/offline event
|
||||||
@@ -417,31 +386,31 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
switch (eventId)
|
switch (eventId)
|
||||||
{
|
{
|
||||||
case DMInputEventIds.VideoDetectedEventId:
|
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.InputNameFeedbackEventId:
|
||||||
case DMInputEventIds.InputNameEventId:
|
case DMInputEventIds.InputNameEventId:
|
||||||
case DMInputEventIds.NameFeedbackEventId:
|
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 input = args.Number;
|
||||||
var name = _chassis.HdmiInputs[input].NameFeedback.StringValue;
|
var name = _chassis.HdmiInputs[input].NameFeedback.StringValue;
|
||||||
|
|
||||||
Debug.Console(1, this, "Input {0} Name {1}", input, name);
|
Debug.Console(1, this, "Input {0} Name {1}", input, name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Uhandled DM Input Event ID {0}", eventId);
|
Debug.Console(1, this, "Uhandled DM Input Event ID {0}", eventId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,7 +462,7 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add feedback colleciton arrays to feedback collections
|
/// Add feedback collection arrays to feedback collections
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="feedbackCollections">BoolFeedback[] arrays</param>
|
/// <param name="feedbackCollections">BoolFeedback[] arrays</param>
|
||||||
public void AddCollectionsToList(params FeedbackCollection<BoolFeedback>[] feedbackCollections)
|
public void AddCollectionsToList(params FeedbackCollection<BoolFeedback>[] feedbackCollections)
|
||||||
@@ -587,10 +556,10 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void AddFeedbackCollecitons()
|
public void AddFeedbackCollecitons()
|
||||||
{
|
{
|
||||||
AddFeedbackToList(DeviceNameFeedback);
|
//AddFeedbackToList(DeviceNameFeedback);
|
||||||
AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback);
|
//AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback);
|
||||||
AddCollectionsToList(VideoOutputRouteFeedbacks);
|
//AddCollectionsToList(VideoOutputRouteFeedbacks);
|
||||||
AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedback);
|
//AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -608,7 +577,11 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
}
|
}
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
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());
|
var props = JsonConvert.DeserializeObject<HdPsXxxPropertiesConfig>(dc.Properties.ToString());
|
||||||
if (props == null)
|
if (props == null)
|
||||||
@@ -617,12 +590,7 @@ namespace PepperDash_Essentials_DM.Chassis
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var key = dc.Key;
|
var ipid = props.Control.IpIdInt;
|
||||||
var name = dc.Name;
|
|
||||||
var type = dc.Type.ToLower();
|
|
||||||
var control = props.Control;
|
|
||||||
var ipid = control.IpIdInt;
|
|
||||||
//var address = control.TcpSshProperties.Address;
|
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user