Skip to content

Commit debe53f

Browse files
committed
Add enable property to ConfigureHeadstage64OpticalStimulator
- Address review comments - Fix several typos
1 parent 63b3c01 commit debe53f

5 files changed

+44
-23
lines changed

OpenEphys.Onix1/ConfigureHeadstage64ElectricalStimulator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public ConfigureHeadstage64ElectricalStimulator()
3030
/// false, <see cref="Headstage64ElectricalStimulatorData"/> will not produce data.
3131
/// </remarks>
3232
[Category(ConfigurationCategory)]
33-
[Description("Specifies whether the digital IO device is enabled.")]
33+
[Description("Specifies whether the headstage-64 electrical stimulator will produce stimulus reports.")]
3434
public bool Enable { get; set; }
3535

3636
/// <summary>
@@ -68,7 +68,7 @@ static class Headstage64ElectricalStimulator
6868
public const double AbsMaxMicroAmps = 2500;
6969

7070
// managed registers
71-
public const uint ENABLE = 0; // Eanble stimulus report stream
71+
public const uint ENABLE = 0; // Enable stimulus report stream
7272
public const uint BIPHASIC = 1; // Biphasic pulse (0 = monophasic, 1 = biphasic; NB: currently ignored)
7373
public const uint CURRENT1 = 2; // Phase 1 current
7474
public const uint CURRENT2 = 3; // Phase 2 current

OpenEphys.Onix1/ConfigureHeadstage64OpticalStimulator.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
namespace OpenEphys.Onix1
55
{
66
/// <summary>
7-
/// Configures a headstage-64 dual-channel optical stimulator.
7+
/// Configures a headstage-64 optical stimulator.
88
/// </summary>
99
/// <remarks>
1010
/// This configuration operator can be linked to a data IO operator, such as <see
1111
/// cref="Headstage64OpticalStimulatorTrigger"/>, using a shared
1212
/// <c>DeviceName</c>.
1313
/// </remarks>
14-
[Description("Configures a headstage-64 dual-channel optical stimulator.")]
14+
[Description("Configures a headstage-64 optical stimulator.")]
1515
public class ConfigureHeadstage64OpticalStimulator : SingleDeviceFactory
1616
{
1717
/// <summary>
@@ -22,6 +22,17 @@ public ConfigureHeadstage64OpticalStimulator()
2222
{
2323
}
2424

25+
/// <summary>
26+
/// Gets or sets the data enable state.
27+
/// </summary>
28+
/// <remarks>
29+
/// If set to true, <see cref="Headstage64OpticalStimulatorData"/> will produce data. If set to
30+
/// false, <see cref="Headstage64OpticalStimulatorData"/> will not produce data.
31+
/// </remarks>
32+
[Category(ConfigurationCategory)]
33+
[Description("Specifies whether the headstage-64 optical stimulator will produce stimulus reports.")]
34+
public bool Enable { get; set; }
35+
2536
/// <summary>
2637
/// Configure a headstage-64 dual-channel optical stimulator.
2738
/// </summary>
@@ -37,10 +48,12 @@ public override IObservable<ContextTask> Process(IObservable<ContextTask> source
3748
{
3849
var deviceName = DeviceName;
3950
var deviceAddress = DeviceAddress;
51+
var enable = Enable;
4052
return source.ConfigureDevice(context =>
4153
{
4254
var device = context.GetDeviceContext(deviceAddress, DeviceType);
43-
device.WriteRegister(Headstage64OpticalStimulator.ENABLE, 0);
55+
device.WriteRegister(Headstage64OpticalStimulator.ENABLE, enable ? 1u : 0u);
56+
device.WriteRegister(Headstage64OpticalStimulator.STIMENABLE, 0u);
4457
return DeviceManager.RegisterDevice(deviceName, device, DeviceType);
4558
});
4659
}
@@ -55,7 +68,7 @@ static class Headstage64OpticalStimulator
5568
public const uint PotResistanceOhms = 100_000;
5669

5770
// managed registers
58-
public const uint NULLPARM = 0; // No command
71+
public const uint ENABLE = 0; // Enable stimulus report stream
5972
public const uint MAXCURRENT = 1; // Max LED/LD current, (0 to 255 = 800mA to 0 mA.See fig XX of CAT4016 datasheet)
6073
public const uint PULSEMASK = 2; // Bitmask determining which of the(up to 32) channels is affected by trigger
6174
public const uint PULSEDUR = 3; // Pulse duration, microseconds
@@ -65,7 +78,7 @@ static class Headstage64OpticalStimulator
6578
public const uint TRAINCOUNT = 7; // Number of bursts in train
6679
public const uint TRAINDELAY = 8; // Stimulus start delay, microseconds
6780
public const uint TRIGGER = 9; // Trigger stimulation (0 = off, 1 = deliver)
68-
public const uint ENABLE = 10; // 1: enables the stimulator, 0: stimulator ignores triggers (so that a common trigger can be used)
81+
public const uint STIMENABLE = 10; // 1: enables the stimulator, 0: stimulator ignores triggers (so that a common trigger can be used)
6982
public const uint RESTMASK = 11; // Bitmask determining the off state of the up to 32 current channels
7083
public const uint RESET = 12; // None If 1, Reset all parameters to default (not implemented)
7184
public const uint MINRHEOR = 13; // The series resistor between the potentiometer (rheostat) and RSET bin on the CAT4016

OpenEphys.Onix1/Headstage64ElectricalStimulatorDataFrame.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace OpenEphys.Onix1
55
{
66
/// <summary>
7-
/// A headstage-64 onboard electrical stimulator report.
7+
/// A headstage-64 electrical stimulus report.
88
/// </summary>
99
/// <remarks>
1010
/// These frames provide synchronized information about the stimulus timing, trigger source, and stimulus
@@ -15,7 +15,7 @@ public class Headstage64ElectricalStimulatorDataFrame : DataFrame
1515
/// <summary>
1616
/// Initializes a new instance of the <see cref="Headstage64ElectricalStimulatorDataFrame"/> class.
1717
/// </summary>
18-
/// <param name="frame">An ONI containing a headstage-64 onboard electrical stimulator report.</param>
18+
/// <param name="frame">An ONI frame containing a electrical stimulus report.</param>
1919
public unsafe Headstage64ElectricalStimulatorDataFrame(oni.Frame frame)
2020
: base(frame.Clock)
2121
{
@@ -87,12 +87,12 @@ public unsafe Headstage64ElectricalStimulatorDataFrame(oni.Frame frame)
8787
public uint PulsesPerBurst { get; }
8888

8989
/// <summary>
90-
/// Gets inter-burst interval duration in microseconds.
90+
/// Gets the inter-burst interval duration in microseconds.
9191
/// </summary>
9292
public uint InterBurstInterval { get; }
9393

9494
/// <summary>
95-
/// Gets the number of burst per train.
95+
/// Gets the number of bursts per train.
9696
/// </summary>
9797
public uint BurstsPerTrain { get; }
9898

OpenEphys.Onix1/Headstage64OpticalStimulatorDataFrame.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace OpenEphys.Onix1
44
{
55
/// <summary>
6-
/// A headstage-64 onboard optical stimulator report.
6+
/// A headstage-64 optical stimulus report.
77
/// </summary>
88
/// <remarks>
99
/// These frames provide synchronized information about the stimulus timing, trigger source, and stimulus
@@ -14,7 +14,7 @@ public class Headstage64OpticalStimulatorDataFrame : DataFrame
1414
/// <summary>
1515
/// Initializes a new instance of the <see cref="Headstage64OpticalStimulatorDataFrame"/> class.
1616
/// </summary>
17-
/// <param name="frame">An ONI containing a headstage-64 onboard optical stimulator report.</param>
17+
/// <param name="frame">An ONI frame containing a headstage-64 optical stimulus report.</param>
1818
public unsafe Headstage64OpticalStimulatorDataFrame(oni.Frame frame)
1919
: base(frame.Clock)
2020
{
@@ -80,12 +80,12 @@ public unsafe Headstage64OpticalStimulatorDataFrame(oni.Frame frame)
8080
public uint PulsesPerBurst { get; }
8181

8282
/// <summary>
83-
/// Gets inter-burst interval duration in milliseconds.
83+
/// Gets the inter-burst interval duration in milliseconds.
8484
/// </summary>
8585
public double InterBurstInterval { get; }
8686

8787
/// <summary>
88-
/// Gets the number of burst per train.
88+
/// Gets the number of bursts per train.
8989
/// </summary>
9090
public uint BurstsPerTrain { get; }
9191

OpenEphys.Onix1/Headstage64OpticalStimulatorTrigger.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,10 @@ static uint pulseFrequencyToRegister(double pulseHz, double pulseDuration)
245245
}
246246

247247
return new CompositeDisposable(
248-
enable.SubscribeSafe(observer, value => device.WriteRegister(Headstage64OpticalStimulator.ENABLE, value ? 1u : 0u)),
249-
maxCurrent.SubscribeSafe(observer, value => device.WriteRegister(Headstage64OpticalStimulator.MAXCURRENT, Headstage64OpticalStimulator.MilliampsToPotSetting(value))),
248+
enable.SubscribeSafe(observer, value =>
249+
device.WriteRegister(Headstage64OpticalStimulator.STIMENABLE, value ? 1u : 0u)),
250+
maxCurrent.SubscribeSafe(observer, value =>
251+
device.WriteRegister(Headstage64OpticalStimulator.MAXCURRENT, Headstage64OpticalStimulator.MilliampsToPotSetting(value))),
250252
channelOneCurrent.SubscribeSafe(observer, value =>
251253
{
252254
currentSourceMask = percentToPulseMask(0, value, currentSourceMask);
@@ -257,12 +259,18 @@ static uint pulseFrequencyToRegister(double pulseHz, double pulseDuration)
257259
currentSourceMask = percentToPulseMask(1, value, currentSourceMask);
258260
device.WriteRegister(Headstage64OpticalStimulator.PULSEMASK, currentSourceMask);
259261
}),
260-
pulseDuration.SubscribeSafe(observer, value => device.WriteRegister(Headstage64OpticalStimulator.PULSEDUR, pulseDurationToRegister(value, PulsesPerSecond))),
261-
pulsesPerSecond.SubscribeSafe(observer, value => device.WriteRegister(Headstage64OpticalStimulator.PULSEPERIOD, pulseFrequencyToRegister(value, PulseDuration))),
262-
pulsesPerBurst.SubscribeSafe(observer, value => device.WriteRegister(Headstage64OpticalStimulator.BURSTCOUNT, value)),
263-
interBurstInterval.SubscribeSafe(observer, value => device.WriteRegister(Headstage64OpticalStimulator.IBI, (uint)(1000 * value))),
264-
burstsPerTrain.SubscribeSafe(observer, value => device.WriteRegister(Headstage64OpticalStimulator.TRAINCOUNT, value)),
265-
delay.SubscribeSafe(observer, value => device.WriteRegister(Headstage64OpticalStimulator.TRAINDELAY, (uint)(1000 * value))),
262+
pulseDuration.SubscribeSafe(observer, value =>
263+
device.WriteRegister(Headstage64OpticalStimulator.PULSEDUR, pulseDurationToRegister(value, PulsesPerSecond))),
264+
pulsesPerSecond.SubscribeSafe(observer, value =>
265+
device.WriteRegister(Headstage64OpticalStimulator.PULSEPERIOD, pulseFrequencyToRegister(value, PulseDuration))),
266+
pulsesPerBurst.SubscribeSafe(observer, value =>
267+
device.WriteRegister(Headstage64OpticalStimulator.BURSTCOUNT, value)),
268+
interBurstInterval.SubscribeSafe(observer, value =>
269+
device.WriteRegister(Headstage64OpticalStimulator.IBI, (uint)(1000 * value))),
270+
burstsPerTrain.SubscribeSafe(observer, value =>
271+
device.WriteRegister(Headstage64OpticalStimulator.TRAINCOUNT, value)),
272+
delay.SubscribeSafe(observer, value =>
273+
device.WriteRegister(Headstage64OpticalStimulator.TRAINDELAY, (uint)(1000 * value))),
266274
source.SubscribeSafe(triggerObserver)
267275
);
268276
}));

0 commit comments

Comments
 (0)