Commit fbe5c9a6 authored by Simone Liuzzo's avatar Simone Liuzzo
Browse files

repaired qaudrupole device name assignment in presence of QF8D splitted

parent d6b66abc
......@@ -122,8 +122,28 @@ end
function mach=adddevicenames(mach)
fprintf('Add device names...\n');
ind=atgetcells(mach,'Class','Quadrupole');
mach(ind)=atsetfieldvalues(mach(ind),'Device',ebs.qpname(1:sum(ind)));
ind = find(atgetcells(mach,'Class','Quadrupole') | atgetcells(mach,'FamName','Q[FDIJ]\w*'))';
mach(ind)=atsetfieldvalues(mach(ind),'Device',''); % initialize Device field to empty
firstsliceQF8D=diff(ind)~=1;% some QF8D are splitted, name first slice only!
indi=[ind(firstsliceQF8D) ind(end)]; % real number of Quads (removing overcount for splitted elements)
mach(indi)=atsetfieldvalues(mach(indi),'Device',ebs.qpname(1:length(indi)));
mach(ind(end:-1:1)) = nameunamedaslastnamed(mach(ind(end:-1:1)));
function r=nameunamedaslastnamed(r)
% name devices without a name with the name of the last device
% with a name
lastname = '';
for ii=1:length(r)
if ~isempty(r{ii}.Device)
lastname = r{ii}.Device;
else
r{ii}.Device = lastname;
end
end
end
ind=find(atgetcells(mach,'FamName','DQ\w*'))';
firstslicedq=diff(ind)~=2;% some DQ are splitted, name first slice
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment