Skip to content

Commit e256332

Browse files
committed
Added ability to reset the current protocol
1 parent 5112941 commit e256332

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

src/main/matlab/+symphonyui/+app/AcquisitionService.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,16 @@ function requestStop(obj)
127127
s = obj.session.controller.state;
128128
end
129129

130+
function resetProtocol(obj)
131+
constructor = str2func(class(obj.session.protocol));
132+
protocol = constructor();
133+
protocol.setRig(obj.session.rig);
134+
protocol.setPersistor(obj.session.persistor);
135+
obj.session.protocol.close();
136+
obj.session.protocol = protocol;
137+
notify(obj, 'SelectedProtocol');
138+
end
139+
130140
function p = getAvailableProtocolPresets(obj)
131141
presets = obj.session.presets.protocolPresets;
132142
p = presets.keys;

src/main/matlab/+symphonyui/+ui/+presenters/MainPresenter.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ function bind(obj)
9595
obj.addListener(v, 'Record', @obj.onViewSelectedRecord);
9696
obj.addListener(v, 'Pause', @obj.onViewSelectedPause);
9797
obj.addListener(v, 'Stop', @obj.onViewSelectedStop);
98+
obj.addListener(v, 'ResetProtocol', @obj.onViewSelectedResetProtocol);
9899
obj.addListener(v, 'ShowProtocolPresets', @obj.onViewSelectedShowProtocolPresets);
99100
obj.addListener(v, 'InitializeRig', @obj.onViewSelectedInitializeRig);
100101
obj.addListener(v, 'ShowDevices', @obj.onViewSelectedShowDevices);
@@ -484,6 +485,7 @@ function updateStateOfControls(obj)
484485
enableRecord = isValid && hasEpochGroup && (isRecordingPaused || isStopped);
485486
enablePause = ~isPausing && ~isViewingPaused && ~isRecordingPaused && ~isStopping && ~isStopped;
486487
enableStop = ~isStopping && ~isStopped;
488+
enableResetProtocol = isStopped;
487489
enableInitializeRig = isStopped;
488490
enableShowDevices = isStopped;
489491

@@ -508,11 +510,22 @@ function updateStateOfControls(obj)
508510
obj.view.enableRecord(enableRecord);
509511
obj.view.enablePause(enablePause);
510512
obj.view.enableStop(enableStop);
513+
obj.view.enableResetProtocol(enableResetProtocol);
511514
obj.view.enableInitializeRig(enableInitializeRig);
512515
obj.view.enableShowDevices(enableShowDevices);
513516
obj.view.setStatus(status);
514517
end
515518

519+
function onViewSelectedResetProtocol(obj, ~, ~)
520+
try
521+
obj.acquisitionService.resetProtocol();
522+
catch x
523+
obj.log.debug(x.message, x);
524+
obj.view.showError(x.message);
525+
return;
526+
end
527+
end
528+
516529
function onViewSelectedShowProtocolPresets(obj, ~, ~)
517530
obj.showProtocolPresets();
518531
end

src/main/matlab/+symphonyui/+ui/+views/MainView.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Record
1717
Pause
1818
Stop
19+
ResetProtocol
1920
ShowProtocolPresets
2021
InitializeRig
2122
ShowDevices
@@ -109,10 +110,13 @@ function createUi(obj)
109110
obj.acquireMenu.stop = uimenu(obj.acquireMenu.root, ...
110111
'Label', 'Stop', ...
111112
'Callback', @(h,d)notify(obj, 'Stop'));
113+
obj.acquireMenu.resetProtocol = uimenu(obj.acquireMenu.root, ...
114+
'Label', 'Reset Protocol', ...
115+
'Separator', 'on', ...
116+
'Callback', @(h,d)notify(obj, 'ResetProtocol'));
112117
obj.acquireMenu.protocolPresets = uimenu(obj.acquireMenu.root, ...
113118
'Label', 'Protocol Presets', ...
114119
'Accelerator', 'P', ...
115-
'Separator', 'on', ...
116120
'Callback', @(h,d)notify(obj, 'ShowProtocolPresets'));
117121

118122
% Configure menu.
@@ -384,6 +388,10 @@ function enableStop(obj, tf)
384388
set(obj.acquireMenu.stop, 'Enable', enable);
385389
set(obj.stopButton, 'Enable', enable);
386390
end
391+
392+
function enableResetProtocol(obj, tf)
393+
set(obj.acquireMenu.resetProtocol, 'Enable', appbox.onOff(tf));
394+
end
387395

388396
function enableInitializeRig(obj, tf)
389397
set(obj.configureMenu.initializeRig, 'Enable', appbox.onOff(tf));

0 commit comments

Comments
 (0)