Skip to content

Commit

Permalink
Merge pull request #359 from open-ephys/issue-352
Browse files Browse the repository at this point in the history
Hardcode ConfigureHeartbeat to enabled in ConfigureBreakoutBoard
  • Loading branch information
jonnew authored Oct 30, 2024
2 parents 634a54c + 0cfab09 commit a6c4f39
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
7 changes: 5 additions & 2 deletions OpenEphys.Onix1/ConfigureBreakoutBoard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ public class ConfigureBreakoutBoard : MultiDeviceFactory
/// <summary>
/// Gets or sets the heartbeat configuration.
/// </summary>
[TypeConverter(typeof(SingleDeviceFactoryConverter))]
/// <remarks>
/// This heartbeat is always enabled and beats at 100 Hz.
/// </remarks>
[TypeConverter(typeof(HeartbeatSingleDeviceFactoryConverter))]
[Description("Specifies the configuration for the heartbeat device in the ONIX breakout board.")]
[Category(DevicesCategory)]
public ConfigureHeartbeat Heartbeat { get; set; } = new();
public ConfigureHeartbeat Heartbeat { get; set; } = new ConfigureHeartbeat { Enable = true, BeatsPerSecond = 100 };

/// <summary>
/// Gets or sets the breakout board's analog IO configuration.
Expand Down
18 changes: 18 additions & 0 deletions OpenEphys.Onix1/ConfigureHeartbeat.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Subjects;
using Bonsai;
Expand Down Expand Up @@ -101,4 +102,21 @@ public NameConverter()
}
}
}

// NB: Can be used to remove Enable and BeatsPerSecond properties from MultiDeviceFactories that
// include a Heartbeat when having those options would cause confusion
internal class HeartbeatSingleDeviceFactoryConverter : SingleDeviceFactoryConverter
{
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
{
var properties = (from property in base.GetProperties(context, value, attributes).Cast<PropertyDescriptor>()
where !property.IsReadOnly &&
!(property.DisplayName == "Enable") &&
!(property.DisplayName == "BeatsPerSecond") &&
property.ComponentType != typeof(SingleDeviceFactory)
select property)
.ToArray();
return new PropertyDescriptorCollection(properties).Sort(properties.Select(p => p.Name).ToArray());
}
}
}

0 comments on commit a6c4f39

Please sign in to comment.