1010namespace OpenEphys . Onix1
1111{
1212 /// <summary>
13- /// Configures an ONIX RHS 2116 Trigger device.
13+ /// Configures an Rhs2116 trigger device.
1414 /// </summary>
1515 /// <remarks>
16- /// The RHS2116 Trigger device generates triggers for Intan RHS2116 bioamplifier and stimulator chip(s)
17- /// either from a remote source via external SYNC pin or locally via GPIO or TRIGGER register. This
18- /// device can be used to synchronize stimulus application and recovery across chips.
16+ /// The Rhs2116 Trigger device generates triggers for Intan Rhs2116 bioamplifier and stimulator chip(s)
17+ /// either from a remote source via external SYNC pin or locally via GPIO or TRIGGER register. This device
18+ /// can be used to synchronize stimulus application and recovery across chips. This configuration operator
19+ /// can be linked to a data IO operator, such as <see cref="Rhs2116TriggerData"/>, using a shared
20+ /// <c>DeviceName</c>.
1921 /// </remarks>
2022 [ Editor ( "OpenEphys.Onix1.Design.Rhs2116StimulusSequenceEditor, OpenEphys.Onix1.Design" , typeof ( ComponentEditor ) ) ]
2123 public class ConfigureRhs2116Trigger : SingleDeviceFactory
2224 {
2325 readonly BehaviorSubject < Rhs2116StimulusSequencePair > stimulusSequence = new ( new Rhs2116StimulusSequencePair ( ) ) ;
26+ readonly BehaviorSubject < bool > triggerArmed = new ( true ) ;
2427
2528 /// <summary>
2629 /// Initializes a new instance of the <see cref="ConfigureRhs2116Trigger"/> class.
@@ -30,6 +33,19 @@ public ConfigureRhs2116Trigger()
3033 {
3134 }
3235
36+ /// <summary>
37+ /// Gets or sets the device enable state.
38+ /// </summary>
39+ /// <remarks>
40+ /// If set to true, a <see cref="Rhs2116TriggerData"/> instance that is linked to this configuration
41+ /// will produce data. If set to false, it will not produce data. Note that this does not affect the
42+ /// ability of the device to trigger stimuli, but only affects if trigger event information is
43+ /// streamed back from the device. To disable the trigger see the <see cref="Armed"/> property.
44+ /// </remarks>
45+ [ Category ( ConfigurationCategory ) ]
46+ [ Description ( "Specifies whether the stimulus trigger device will stream stimulus delivery information." ) ]
47+ public bool Enable { get ; set ; } = true ;
48+
3349 /// <summary>
3450 /// Gets or sets the trigger source.
3551 /// </summary>
@@ -52,6 +68,21 @@ public ConfigureRhs2116Trigger()
5268 [ Description ( "Defines the channel configuration" ) ]
5369 public Rhs2116ProbeGroup ProbeGroup { get ; set ; } = new ( ) ;
5470
71+ /// <summary>
72+ /// Gets or sets if trigger is armed.
73+ /// </summary>
74+ /// <remarks>
75+ /// If true, this device will respect triggers from the selected <see cref="TriggerSource"/>.
76+ /// Otherwise, triggers will be ignored.
77+ /// </remarks>
78+ [ Category ( AcquisitionCategory ) ]
79+ [ Description ( "If true, respect triggers. Otherwise, triggers will not be applied." ) ]
80+ public bool Armed
81+ {
82+ get => triggerArmed . Value ;
83+ set => triggerArmed . OnNext ( value ) ;
84+ }
85+
5586 /// <summary>
5687 /// Gets or sets a string defining the <see cref="ProbeGroup"/> in Base64.
5788 /// </summary>
@@ -88,7 +119,7 @@ public Rhs2116StimulusSequencePair StimulusSequence
88119 }
89120
90121 /// <summary>
91- /// Configures an RHS2116 Trigger device.
122+ /// Configures an Rhs2116 Trigger device.
92123 /// </summary>
93124 /// <remarks>
94125 /// This will schedule configuration actions to be applied by a <see cref="StartAcquisition"/> node
@@ -97,10 +128,11 @@ public Rhs2116StimulusSequencePair StimulusSequence
97128 /// <param name="source">A sequence of <see cref="ContextTask"/> that holds all configuration actions.</param>
98129 /// <returns>
99130 /// The original sequence with the side effect of an additional configuration action to configure
100- /// aN RHS2116 Trigger device.
131+ /// aN Rhs2116 Trigger device.
101132 /// </returns>
102133 public override IObservable < ContextTask > Process ( IObservable < ContextTask > source )
103134 {
135+ var enable = Enable ;
104136 var triggerSource = TriggerSource ;
105137 var deviceName = DeviceName ;
106138 var deviceAddress = DeviceAddress ;
@@ -113,6 +145,7 @@ public override IObservable<ContextTask> Process(IObservable<ContextTask> source
113145 var rhs2116B = context . GetDeviceContext ( rhs2116BAddress , typeof ( Rhs2116 ) ) ;
114146
115147 var device = context . GetDeviceContext ( deviceAddress , DeviceType ) ;
148+ device . WriteRegister ( Rhs2116Trigger . ENABLE , enable ? 1u : 0u ) ;
116149 device . WriteRegister ( Rhs2116Trigger . TRIGGERSOURCE , ( uint ) triggerSource ) ;
117150
118151 static void WriteStimulusSequence ( DeviceContext device , Rhs2116StimulusSequence sequence )
@@ -164,6 +197,10 @@ static void WriteStimulusSequence(DeviceContext device, Rhs2116StimulusSequence
164197 WriteStimulusSequence ( rhs2116A , newValue . StimulusSequenceA ) ;
165198 WriteStimulusSequence ( rhs2116B , newValue . StimulusSequenceB ) ;
166199 } ) ,
200+ triggerArmed . SubscribeSafe ( observer , newValue =>
201+ {
202+ device . WriteRegister ( Rhs2116Trigger . TRIGGERARMED , newValue ? 1u : 0u ) ;
203+ } ) ,
167204 DeviceManager . RegisterDevice ( deviceName , device , DeviceType ) ) ;
168205 } ) ;
169206 }
@@ -174,9 +211,11 @@ static class Rhs2116Trigger
174211 public const int ID = 32 ;
175212
176213 // managed registers
177- public const uint ENABLE = 0 ; // Writes and reads to ENABLE are ignored without error
214+ public const uint ENABLE = 0 ; // Enable or disable the trigger event datastream
178215 public const uint TRIGGERSOURCE = 1 ; // The LSB is used to determine the trigger source
179216 public const uint TRIGGER = 2 ; // Writing 0x1 to this register will trigger a stimulation sequence if the TRIGGERSOURCE is set to 0.
217+ public const uint TRIGGERARMED = 3 ; // 0x0: Ignore all trigger inputs regardless of TRIGGERSOURCE.
218+ // 0x1: Respect the trigger input specified by TRIGGERSOURCE
180219
181220 internal class NameConverter : DeviceNameConverter
182221 {
0 commit comments