Skip to content

Commit

Permalink
feat: update Essentials version and use new base classes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-welker committed Mar 27, 2024
1 parent ee101c6 commit a2e78f3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 33 deletions.
15 changes: 7 additions & 8 deletions src/NvxEpi/Features/Routing/NvxGlobalRouter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ private NvxGlobalRouter()
#if SERIES4
AddPostActivationAction(BuildMatrixRouting);

InputSlots = new Dictionary<string, IRoutingInputSlot>();
OutputSlots = new Dictionary<string, IRoutingOutputSlot>();
InputSlots = new Dictionary<string, RoutingInputSlotBase>();
OutputSlots = new Dictionary<string, RoutingOutputSlotBase>();
#endif
}

Expand Down Expand Up @@ -102,9 +102,9 @@ public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType
}

#if SERIES4
public Dictionary<string, IRoutingInputSlot> InputSlots { get; private set; }
public Dictionary<string, RoutingInputSlotBase> InputSlots { get; private set; }

public Dictionary<string, IRoutingOutputSlot> OutputSlots { get; private set; }
public Dictionary<string, RoutingOutputSlotBase> OutputSlots { get; private set; }

private void BuildMatrixRouting()
{
Expand All @@ -117,7 +117,7 @@ private void BuildMatrixRouting()
{
return new NvxMatrixInput(t);
})
.ToDictionary(i => i.Key, i => i as IRoutingInputSlot);
.ToDictionary(i => i.Key, i => i as RoutingInputSlotBase);

var transmitters = DeviceManager.AllDevices
.OfType<NvxBaseDevice>()
Expand All @@ -134,13 +134,12 @@ private void BuildMatrixRouting()
Debug.Console(0, this, $"Getting NvxMatrixOutput for {t.Key}");

return new NvxMatrixOutput(t);
}).ToDictionary(t => t.Key, t => t as IRoutingOutputSlot);
}).ToDictionary(t => t.Key, t => t as RoutingOutputSlotBase);

}
catch (Exception ex)
{
Debug.Console(0, this, $"Exception building MatrixRouting: {ex}:{ex.Message}");
Debug.Console(2, this, $"Exception building MatrixRouting: {ex.StackTrace}");
Debug.LogMessage(ex, "Exception building MatrixRouting: {message}", this, ex.Message);
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/NvxEpi/Features/Routing/NvxMatrixInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

namespace NvxEpi.Features.Routing
{
public class NvxMatrixInput : IRoutingInputSlot
public class NvxMatrixInput : RoutingInputSlotBase
{
private readonly NvxBaseDevice _device;

public NvxMatrixInput(NvxBaseDevice device)
public NvxMatrixInput(NvxBaseDevice device):base()
{
_device = device;

Expand All @@ -24,20 +24,20 @@ public NvxMatrixInput(NvxBaseDevice device)
}
}

public string TxDeviceKey => _device.Key;
public override string TxDeviceKey => _device.Key;

public int SlotNumber => _device.DeviceId;
public override int SlotNumber => _device.DeviceId;

public eRoutingSignalType SupportedSignalTypes => eRoutingSignalType.AudioVideo | eRoutingSignalType.UsbInput | eRoutingSignalType.UsbOutput | eRoutingSignalType.SecondaryAudio;
public override eRoutingSignalType SupportedSignalTypes => eRoutingSignalType.AudioVideo | eRoutingSignalType.UsbInput | eRoutingSignalType.UsbOutput | eRoutingSignalType.SecondaryAudio;

public string Name => _device.Name;
public override string Name => _device.Name;

public BoolFeedback IsOnline => _device.IsOnline;
public override BoolFeedback IsOnline => _device.IsOnline;

public bool VideoSyncDetected => _device is IHdmiInput inputDevice ? inputDevice.SyncDetected.Any(fb => fb.Value.BoolValue) : false;
public override bool VideoSyncDetected => _device is IHdmiInput inputDevice ? inputDevice.SyncDetected.Any(fb => fb.Value.BoolValue) : false;

public string Key => $"{_device.Key}-matrixInput";
public override string Key => $"{_device.Key}-matrixInput";

public event EventHandler VideoSyncChanged;
public override event EventHandler VideoSyncChanged;
}
}
28 changes: 13 additions & 15 deletions src/NvxEpi/Features/Routing/NvxMatrixOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@

namespace NvxEpi.Features.Routing
{
public class NvxMatrixOutput : IRoutingOutputSlot
public class NvxMatrixOutput : RoutingOutputSlotBase
{
private readonly NvxBaseDevice _device;

public NvxMatrixOutput(NvxBaseDevice device)
public NvxMatrixOutput(NvxBaseDevice device):base()
{
try
{
_device = device;

var parent = NvxGlobalRouter.Instance;

Debug.Console(0, this, $"Device is null: {_device == null}");
var parent = NvxGlobalRouter.Instance;

_device.CurrentStreamId.OutputChange += (o, a) =>
{
Expand All @@ -43,13 +41,13 @@ public NvxMatrixOutput(NvxBaseDevice device)
};
} catch (Exception ex)
{
Debug.Console(0, this, $"Exception creating NvxMatrixOutput: {ex.Message}");
Debug.LogMessage(ex, "Exception creating NvxMatrixOuput {ex}", this, ex.Message);
}
}

public string RxDeviceKey => _device.Key;
public override string RxDeviceKey => _device.Key;

private readonly Dictionary<eRoutingSignalType, IRoutingInputSlot> currentRoutes = new Dictionary<eRoutingSignalType, IRoutingInputSlot>
private readonly Dictionary<eRoutingSignalType, RoutingInputSlotBase> currentRoutes = new Dictionary<eRoutingSignalType, RoutingInputSlotBase>
{
{eRoutingSignalType.Audio, null },
{eRoutingSignalType.Video, null },
Expand All @@ -60,7 +58,7 @@ public NvxMatrixOutput(NvxBaseDevice device)

public IStreamWithHardware Device => _device;

private void SetInputRoute(eRoutingSignalType type, IRoutingInputSlot input)
private void SetInputRoute(eRoutingSignalType type, RoutingInputSlotBase input)
{
if (currentRoutes.ContainsKey(type))
{
Expand All @@ -76,16 +74,16 @@ private void SetInputRoute(eRoutingSignalType type, IRoutingInputSlot input)
OutputSlotChanged?.Invoke(this, new EventArgs());
}

public Dictionary<eRoutingSignalType, IRoutingInputSlot> CurrentRoutes => currentRoutes;
public override Dictionary<eRoutingSignalType, RoutingInputSlotBase> CurrentRoutes => currentRoutes;

public int SlotNumber => _device.DeviceId;
public override int SlotNumber => _device.DeviceId;

public eRoutingSignalType SupportedSignalTypes => eRoutingSignalType.AudioVideo | eRoutingSignalType.UsbInput | eRoutingSignalType.UsbOutput | eRoutingSignalType.SecondaryAudio;
public override eRoutingSignalType SupportedSignalTypes => eRoutingSignalType.AudioVideo | eRoutingSignalType.UsbInput | eRoutingSignalType.UsbOutput | eRoutingSignalType.SecondaryAudio;

public string Name => _device.Name;
public override string Name => _device.Name;

public string Key => $"{_device.Key}-matrixInput";
public override string Key => $"{_device.Key}-matrixInput";

public event EventHandler OutputSlotChanged;
public override event EventHandler OutputSlotChanged;
}
}

0 comments on commit a2e78f3

Please sign in to comment.