Skip to content

Commit 5112941

Browse files
committed
Only selecting protocols and setting protocol settings if they are different
1 parent ad1e071 commit 5112941

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
end
3434

3535
function selectProtocol(obj, className)
36+
if strcmp(className, class(obj.session.protocol))
37+
return;
38+
end
3639
if ~isempty(className) && ~any(strcmp(className, obj.getAvailableProtocols()))
3740
error([className ' is not an available protocol']);
3841
end
@@ -75,12 +78,18 @@ function selectProtocol(obj, className)
7578
end
7679

7780
function setProtocolProperty(obj, name, value)
81+
if isequal(value, obj.session.protocol.getProperty(name))
82+
return;
83+
end
7884
obj.session.protocol.setProperty(name, value);
7985
obj.session.protocol.closeFigures();
8086
notify(obj, 'SetProtocolProperties');
8187
end
8288

8389
function setProtocolProperties(obj, map)
90+
if isequal(map, obj.session.protocol.getProperties())
91+
return;
92+
end
8493
obj.session.protocol.setProperties(map);
8594
obj.session.protocol.closeFigures();
8695
notify(obj, 'SetProtocolProperties');
@@ -138,12 +147,8 @@ function applyProtocolPreset(obj, name)
138147
error([name ' is not an available protocol preset']);
139148
end
140149
preset = presets(name);
141-
if ~strcmp(preset.protocolId, class(obj.session.protocol))
142-
obj.selectProtocol(preset.protocolId);
143-
end
144-
if ~isequal(preset.propertyMap, obj.session.protocol.getProperties())
145-
obj.setProtocolProperties(preset.propertyMap);
146-
end
150+
obj.selectProtocol(preset.protocolId);
151+
obj.setProtocolProperties(preset.propertyMap);
147152
end
148153

149154
function p = addProtocolPreset(obj, name)

src/main/matlab/+symphonyui/+core/Protocol.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ function setProperties(obj, map)
7474
end
7575
end
7676

77+
function v = getProperty(obj, name)
78+
descriptor = obj.getPropertyDescriptor(name);
79+
v = descriptor.value;
80+
end
81+
7782
function setProperty(obj, name, value)
7883
mpo = findprop(obj, name);
7984
if isempty(mpo) || ~strcmp(mpo.SetAccess, 'public')

0 commit comments

Comments
 (0)