|
151 | 151 | obj.Time = net.origin('t'); |
152 | 152 | obj.Events.expStart = net.origin('expStart'); |
153 | 153 | obj.Events.newTrial = net.origin('newTrial'); |
| 154 | + obj.Events.expStop = net.origin('expStop'); |
154 | 155 | obj.Inputs.wheel = net.origin('wheel'); |
155 | 156 | obj.Inputs.wheelMM = obj.Inputs.wheel.map(@... |
156 | 157 | (x)obj.Wheel.MillimetresFactor*(x-obj.Wheel.ZeroOffset)).skipRepeats(); |
|
170 | 171 | globalPars, allCondPars, advanceTrial); |
171 | 172 | obj.Events.trialNum = obj.Events.newTrial.scan(@plus, 0); % track trial number |
172 | 173 | lastTrialOver = then(~hasNext, true); |
| 174 | +% obj.Events.expStop = then(~hasNext, true); |
173 | 175 | % run experiment definition |
174 | 176 | if ischar(paramStruct.defFunction) |
175 | 177 | expDefFun = fileFunction(paramStruct.defFunction); |
|
181 | 183 | fprintf('takes %i args\n', nargout(expDefFun)); |
182 | 184 | expDefFun(obj.Time, obj.Events, obj.Params, obj.Visual, obj.Inputs,... |
183 | 185 | obj.Outputs, obj.Audio); |
184 | | - obj.Events.expStop = iff(isfield(obj.Events, 'expStop'),... |
185 | | - @()merge(obj.Events.expStop, lastTrialOver), lastTrialOver); |
186 | 186 | % listeners |
187 | 187 | obj.Listeners = [ |
188 | 188 | obj.Events.expStart.map(true).into(advanceTrial) %expStart signals advance |
189 | 189 | obj.Events.endTrial.into(advanceTrial) %endTrial signals advance |
190 | 190 | advanceTrial.map(true).keepWhen(hasNext).into(obj.Events.newTrial) %newTrial if more |
191 | | - obj.Events.expStop.onValue(@(~)quit(obj))]; |
| 191 | + lastTrialOver.into(obj.Events.expStop) %newTrial if more |
| 192 | + onValue(obj.Events.expStop, @(~)quit(obj));]; |
| 193 | +% obj.Events.trialNum.onValue(fun.partial(@fprintf, 'trial %i started\n'))]; |
192 | 194 | % initialise the parameter signals |
193 | 195 | globalPars.post(rmfield(globalStruct, 'defFunction')); |
194 | 196 | allCondPars.post(allCondStruct); |
@@ -405,7 +407,7 @@ function log(obj, field, value) |
405 | 407 |
|
406 | 408 | function quit(obj, immediately) |
407 | 409 | if isempty(obj.Events.expStop.Node.CurrValue) |
408 | | - obj.Events.expStop = net.origin('expStop').post(true); |
| 410 | + obj.Events.expStop.post(true); |
409 | 411 | end |
410 | 412 | %stop delay timers. todo: need to use a less global tag |
411 | 413 | tmrs = timerfind('Tag', 'sig.delay'); |
|
0 commit comments