Skip to content

Commit

Permalink
fix: xio director domain
Browse files Browse the repository at this point in the history
- adds a config value and a for loop to define the number of domains and create them in the xio constructor
  • Loading branch information
ngenovese11 committed Oct 16, 2024
1 parent a11e3fb commit 670b5c9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Binary file added .DS_Store
Binary file not shown.
19 changes: 17 additions & 2 deletions src/NvxEpi/Devices/NvxXioDirector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,34 @@
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, 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();
Expand Down
3 changes: 2 additions & 1 deletion src/NvxEpi/Factories/NvxDirectorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Newtonsoft.Json;
using NvxEpi.Devices;
using NvxEpi.Features.Config;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;

Expand Down Expand Up @@ -34,6 +35,6 @@ public override EssentialsDevice BuildDevice(DeviceConfig dc)
};

xio.RegisterWithLogging(dc.Key);
return new NvxXioDirector(dc.Key, dc.Name, xio);
return new NvxXioDirector(dc, xio);
}
}
1 change: 1 addition & 0 deletions src/NvxEpi/Features/Config/NvxDirectorConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ namespace NvxEpi.Features.Config;
public class NvxDirectorConfig
{
public ControlPropertiesConfig Control { get; set; }
public int NumberOfDomains { get; set; }
}

0 comments on commit 670b5c9

Please sign in to comment.