Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nvx 760 #121

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Binary file added .DS_Store
Binary file not shown.
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,32 @@ MigrationBackup/
.ionide/
*.projectinfo
*.projectinfo~Stashed changes
*.yml
*.sln

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
Expand Down
6 changes: 3 additions & 3 deletions src/NvxEpi/Devices/Nvx35x.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingS
Debug.Console(1,
this,
"Executing switch : '{0}' | '{1}' | '{2}'",
inputSelector.ToString(),
outputSelector.ToString(),
inputSelector?.ToString() ?? "{null}",
outputSelector?.ToString() ?? "{null}",
signalType.ToString());

switcher.HandleSwitch(inputSelector, signalType);
}
catch (Exception ex)
{
Debug.Console(1, this, "Error executing switch! : {0}", ex.Message);
Debug.Console(1, this, "Error executing switch!: {0}", ex);
}
}

Expand Down
18 changes: 10 additions & 8 deletions src/NvxEpi/Devices/Nvx36X.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using NvxEpi.Features.Audio;
using NvxEpi.Features.AutomaticRouting;
using NvxEpi.Features.Config;
using NvxEpi.Features.Hdmi.Input;
using NvxEpi.Features.Hdmi.Output;
using NvxEpi.Features.Streams.Usb;

Expand All @@ -22,12 +21,9 @@
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using Feedback = PepperDash.Essentials.Core.Feedback;

using HdmiInput = NvxEpi.Features.Hdmi.Input.HdmiInput;

using NvxEpi.McMessengers;
using System.Collections.Generic;
using System.Runtime.InteropServices.WindowsRuntime;
using NvxEpi.Extensions;
Expand Down Expand Up @@ -67,7 +63,13 @@ public override bool CustomActivate()
{
var result = base.CustomActivate();

_audio = new Nvx36XAudio((DmNvx36x) Hardware, this);
if(Hardware is DmNvx36x nvx36x)
{
_audio = new Nvx36XAudio(nvx36x, this);
} else if(Hardware is DmNvxE760x nvxE760x) {
_audio = new NvxE760xAudio(nvxE760x, this);
}

_usbStream = UsbStream.GetUsbStream(this, _config.Usb);
_hdmiInputs = new HdmiInput(this);
_hdmiOutput = new VideowallModeOutput(this);
Expand Down Expand Up @@ -213,15 +215,15 @@ public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingS
Debug.Console(1,
this,
"Executing switch : '{0}' | '{1}' | '{2}'",
inputSelector.ToString(),
outputSelector.ToString(),
inputSelector?.ToString() ?? "{null}",
outputSelector?.ToString() ?? "{null}",
signalType.ToString());

switcher.HandleSwitch(inputSelector, signalType);
}
catch (Exception ex)
{
Debug.Console(1, this, "Error executing switch! : {0}", ex.Message);
Debug.Console(1, this, "Error executing switch!: {0}", ex);
}
}

Expand Down
48 changes: 28 additions & 20 deletions src/NvxEpi/Devices/NvxBaseDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,40 +102,48 @@ private void SetDeviceName()

public override bool CustomActivate()
{
Debug.Console(1, this, "Activating...");
DeviceMode = DeviceModeFeedback.GetFeedback(Hardware);
try
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "Activating...", this);

Feedbacks.AddRange(new Feedback[]
{
DeviceMode = DeviceModeFeedback.GetFeedback(Hardware);

Feedbacks.AddRange(new Feedback[]
{
IsOnline,
new IntFeedback("DeviceId", () => DeviceId),
new IntFeedback("DeviceId", () => DeviceId),
DeviceNameFeedback.GetFeedback(Name),
DeviceIpFeedback.GetFeedback(Hardware),
DeviceHostnameFeedback.GetFeedback(Hardware),
DeviceModeNameFeedback.GetFeedback(Hardware),
DanteInputFeedback.GetFeedback(Hardware),
DanteInputValueFeedback.GetFeedback(Hardware),
DeviceMode
});
});

_currentVideoStream = new CurrentVideoStream(this);
_currentSecondaryAudioStream = new CurrentSecondaryAudioStream(this);
_videoSwitcher = new VideoInputSwitcher(this);
_audioSwitcher = new AudioInputSwitcher(this);
_naxSwitcher = new NaxInputSwitcher(this);
_currentVideoStream = new CurrentVideoStream(this);
_currentSecondaryAudioStream = new CurrentSecondaryAudioStream(this);
_videoSwitcher = new VideoInputSwitcher(this);
_audioSwitcher = new AudioInputSwitcher(this);
_naxSwitcher = new NaxInputSwitcher(this);

RegisterForFeedback();
CommunicationMonitor.Start();
Hardware.Network.NetworkChange += (sender, args) => UpdateDeviceInfo();
RegisterForFeedback();
CommunicationMonitor.Start();
Hardware.Network.NetworkChange += (sender, args) => UpdateDeviceInfo();

_queue.Enqueue(new BuildNvxDeviceMessage(Key, Hardware));
_queue.Enqueue(new BuildNvxDeviceMessage(Key, Hardware));

if (IsTransmitter || Hardware == null) return base.CustomActivate();
if (Hardware.Control.ServerUrlFeedback.StringValue != string.Empty)
Hardware.Control.ServerUrl.StringValue = string.Empty;
Hardware.Control.ServerUrl.StringValue = DefaultMulticastRoute;
if (IsTransmitter || Hardware == null) return base.CustomActivate();
if (Hardware.Control.ServerUrlFeedback.StringValue != string.Empty)
Hardware.Control.ServerUrl.StringValue = string.Empty;
Hardware.Control.ServerUrl.StringValue = DefaultMulticastRoute;

return base.CustomActivate();
return base.CustomActivate();
} catch(Exception ex)
{
Debug.LogMessage(ex, "Exception in base custom activate", this);
return false;
}
}

protected void AddMcMessengers()
Expand Down
26 changes: 17 additions & 9 deletions src/NvxEpi/Devices/NvxD3X.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public override bool CustomActivate()
{
var hardware = base.Hardware as DmNvxD3x ?? throw new Exception("hardware built doesn't match");
Hardware = hardware;

var result = base.CustomActivate();

_hdmiOutput = new HdmiOutput(this);

Hardware.BaseEvent += (o, a) => {
Expand All @@ -55,7 +58,7 @@ public override bool CustomActivate()
RouteChanged?.Invoke(this, newRoute);
};

return base.CustomActivate();
return result;
}

public CrestronCollection<ComPort> ComPorts
Expand Down Expand Up @@ -111,20 +114,25 @@ public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingS
{
try
{
var switcher = outputSelector as IHandleInputSwitch ?? throw new NullReferenceException("outputSelector");
if (outputSelector is not IHandleInputSwitch switcher)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Error, "Unable to execute switch. OutputSelector is not IHandleInputSwitch {outputSelectorType}", this, outputSelector.ToString());
return;
}

Debug.Console(1,
this,
"Executing switch : '{0}' | '{1}' | '{2}'",
inputSelector.ToString(),
outputSelector.ToString(),
signalType.ToString());
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "Switching {input} to {output} type {type}", inputSelector, outputSelector, signalType.ToString());

if(inputSelector is null)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "Device is DmNvxD30. 'None' input not available", this);
return;
}

switcher.HandleSwitch(inputSelector, signalType);
}
catch (Exception ex)
{
Debug.Console(1, this, "Error executing switch! : {0}", ex.Message);
Debug.LogMessage(ex, "Error executing switch!", this);
}
}

Expand Down
61 changes: 42 additions & 19 deletions src/NvxEpi/Devices/NvxE3X.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,41 @@ public NvxE3X(DeviceConfig config, Func<DmNvxBaseClass> getHardware)

public override bool CustomActivate()
{
var hardware = base.Hardware as DmNvxE3x ?? throw new Exception("hardware built doesn't match");
Hardware = hardware;
_hdmiInputs = new HdmiInput(this);
try
{
var hardware = base.Hardware as DmNvxE3x ?? throw new Exception("hardware built doesn't match");
Hardware = hardware;

var result = base.CustomActivate();

AddMcMessengers();
_hdmiInputs = new HdmiInput(this);

Hardware.BaseEvent += (o, a) => {
var newRoute = this.HandleBaseEvent(a);
AddMcMessengers();

if (newRoute == null)
if (Hardware == null)
{
return;
Debug.LogMessage(Serilog.Events.LogEventLevel.Warning, "Hardware is null", this);
return base.CustomActivate();
}

RouteChanged?.Invoke(this, newRoute);
};
Hardware.BaseEvent += (o, a) =>
{
var newRoute = this.HandleBaseEvent(a);

return base.CustomActivate();
if (newRoute == null)
{
return;
}

RouteChanged?.Invoke(this, newRoute);
};

return result;
} catch(Exception ex)
{
Debug.LogMessage(ex, "Exception activating device", this);
return false;
}
}

public CrestronCollection<ComPort> ComPorts
Expand Down Expand Up @@ -141,19 +158,25 @@ public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingS
{
try
{
var switcher = outputSelector as IHandleInputSwitch ?? throw new NullReferenceException("outputSelector");
Debug.Console(1,
this,
"Executing switch : '{0}' | '{1}' | '{2}'",
inputSelector.ToString(),
outputSelector.ToString(),
signalType.ToString());
if(outputSelector is not IHandleInputSwitch switcher)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Error, "Unable to execute switch. OutputSelector is not IHandleInputSwitch {outputSelectorType}", this, outputSelector.ToString());
return;
}

Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "Switching {input} to {output} type {type}", inputSelector, outputSelector, signalType.ToString());

if(inputSelector is null)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "Device is DmNvxE3x. 'None' input not available", this);
return;
}

switcher.HandleSwitch(inputSelector, signalType);
}
catch (Exception ex)
{
Debug.Console(1, this, "Error executing switch! : {0}", ex.Message);
Debug.LogMessage(ex, "Error executing switch!", this);
}
}

Expand Down
31 changes: 29 additions & 2 deletions src/NvxEpi/Devices/NvxXioDirector.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,47 @@
using System;
using Crestron.SimplSharpPro.DM.Streaming;
using NvxEpi.Abstractions.Hardware;
using NvxEpi.Features.Monitor;
using NvxEpi.Features.Config;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;

namespace NvxEpi.Devices;

public class NvxXioDirector : EssentialsDevice, INvxDirector, IOnline
public class NvxXioDirector : EssentialsDevice, INvxDirector, IOnline, ICommunicationMonitor
{
private readonly BoolFeedback _isOnline;
private readonly DmXioDirectorBase _hardware;
public StatusMonitorBase CommunicationMonitor { get; private set; }

public NvxXioDirector(string key, string name, DmXioDirectorBase hardware) : base(key, name)
public NvxXioDirector(DeviceConfig config, DmXioDirectorBase hardware) : base(config.Key, config.Name)
{
var props = config.Properties.ToObject<NvxDirectorConfig>();

for (var i = 1; i <= props.NumberOfDomains; i++)
{
if (hardware.Domain.Contains((uint)i))
{
continue;
}

var domain = new DmXioDirectorBase.DmXioDomain((uint)i, hardware);
Debug.Console(1, this, "Adding domain:{0}", domain.Id);
}

_hardware = hardware ?? throw new ArgumentNullException("hardware");
_isOnline = new BoolFeedback("BuildFeedbacks", () => _hardware.IsOnline);
_hardware.OnlineStatusChange += (device, args) => _isOnline.FireUpdate();

AddPreActivationAction(() => CommunicationMonitor = new NvxCommunicationMonitor(this, 10000, 30000, _hardware));
}

public override bool CustomActivate()
{
CommunicationMonitor.Start();

return base.CustomActivate();
}

public BoolFeedback IsOnline
Expand Down
Loading
Loading