📄 tdclient.m
字号:
if ischar(varargin{2}), varargin{2} = str2double(varargin{2}); end
if ischar(varargin{3}), varargin{3} = str2double(varargin{3}); end
if nargin > 4 && ...
ischar(varargin{5})
eval(['varargin{5} = [' strrep(varargin{5},'#',',') '];']);
end
if nargin > 5
if ischar(varargin{6})
varargin{6} = str2double(varargin{6});
end
if isnumeric(varargin{6}) && ...
varargin{6} ~= 0
tddolocal = fix(min(max(varargin{6}, 1), 2));
else
tddolocal = 0;
end
end
charout = 1;
else
charout = 0;
end
fromspm = 0;
if isstruct(varargin{1}) && ...
isfield(varargin{1}, 'dat')
fromspm = 1;
tdata = varargin{1}.dat;
if ~iscell(tdata)
error( ...
'BVQXtools:BadArgument',...
'Bad argument.' ...
);
end
tdat = tdata(:,size(tdata,2));
tdats = size(tdat,1);
tci = zeros(tdats,3);
tke = cell(1,tdats);
tze = cell(1,tdats);
for tc = 1:tdats
[tci(tc,1:3)] = round([tdat{tc}(1), tdat{tc}(2), tdat{tc}(3)]);
tke{tc} = sprintf('%.0f', tdata{tc,4});
tze{tc} = strrep(sprintf('%.4f', tdata{tc,9}), '.', tddecimal);
end
varargin{1} = tci;
end
if ~isnumeric(varargin{1})
error( ...
'BVQXtools:BadArgument',...
'Bad argument.' ...
);
end
if length(varargin{1}) < 3
coords = [varargin{1:3}];
if nargin > 3
ikind = varargin{4};
else
ikind = 2;
end
if nargin > 4
isize = varargin{5};
else
isize = 7;
end
else
coords = varargin{1};
if nargin > 1
ikind = varargin{2};
else
ikind = 2;
end
if nargin > 2
isize = varargin{3};
else
isize = 7;
end
end
if ischar(ikind)
if isfield(kinds,lower(ikind))
ikind = kinds.(lower(ikind));
else
ikind = 2;
end
end
if ischar(isize)
isize = [7, 5];
eval(['isize = [' strrep(isize,'#',',') '];'], '');
end
if (ikind < 1 || ikind > 5) && ...
ikind ~= -5
ikind = 2;
end
if ~isnumeric(isize)
isize = 7;
end
if mod(isize(1),2) ~= 1 && ...
ikind ~= 5 && ...
ikind ~= -5
isize(1) = isize(1) + 1;
end
if isize < 3
isize = 3;
end
if isize > 11
isize = 11;
end
numcoords = size(coords, 1);
if ~tdsilent
fprintf(1, ' -> progress: 0%%');
end
tdreplya = cell(1, numcoords);
for rc = 1:numcoords
if ikind > 0 && ikind < 3
command = sprintf('%d,%d,%d,%d', ikind(1), coords(rc,1:3));
elseif ikind == 3 || ((ikind == 5 || ikind == -1) && isize(1) == fix(isize(1)))
command = sprintf('3:%d,%d,%d,%d', isize(1), coords(rc,1:3));
elseif (ikind == 5 || ikind == -5)
command = sprintf('5:%.2f,%d,%d,%d', isize(1), coords(rc,1:3));
end
if tddolocal == 0
if ikind >= 1 && ikind <=3
[st,tdreply] = i_tdclient([cmdpre command]);
else
st = 1;
tdreply = '* (type NGM not available -> network processing)';
end
else
if ikind == 2
st = 0;
if tddolocal == 1
tdreply = tdlocal(ikind(1), ...
coords(rc, 1), coords(rc, 2), coords(rc, 3));
else
tdreply = tdlocal2(ikind(1), ...
coords(rc, 1), coords(rc, 2), coords(rc, 3));
end
elseif ikind == 3 || ...
ikind == 5 || ...
ikind == -5
st = 0;
if tddolocal == 1
tdreply = tdlocal(ikind(1), ...
coords(rc, 1), coords(rc, 2), coords(rc, 3), isize);
else
tdreply = tdlocal2(ikind(1), ...
coords(rc, 1), coords(rc, 2), coords(rc, 3), isize);
end
else
st = 1;
tdreply = '* (type SPMap not available -> local processing)';
end
end
if ikind == 3 || ...
ikind == 5
tdreplyc = splittocell(tdreply,':',0);
tdreply = '';
for cc = 2:2:length(tdreplyc)
tdreplys = [tdreplyc{cc-1} ': ' tdreplyc{cc}];
myindent = indent;
if cc == 2
myindent(1:length(command)) = command(1:end);
end
tdreply = [tdreply myindent tdreplys lfc];
end
tdreplya{rc} = tdreply;
elseif ikind == -5
if length(tdforsep) > 0
tdforsep = tdforsep(1);
else
tdforsep = ';';
end
lformat(1:length(find(tdformat==tdforsep))) = tdforsep;
if fromspm
sformat(1:7) = tdforsep;
tdreplyr = sprintf('%d%s%d%s%d%s%s%s%s%s%s%s%s%s%s%s%s', ...
coords(rc,1), tdforsep, ...
coords(rc,2), tdforsep, ...
coords(rc,3), tdforsep, ...
'rngm', tdforsep, ...
sprintf('%d:', isize), tdforsep, ...
tke{rc}, tdforsep, ...
tze{rc}, tdforsep, ...
lformat, lfc ...
);
else
sformat(1:5) = tdforsep;
tdreplyr = sprintf('%d%s%d%s%d%s%s%s%s%s%s%s%s', ...
coords(rc,1), tdforsep, ...
coords(rc,2), tdforsep, ...
coords(rc,3), tdforsep, ...
'rngm', tdforsep, ...
sprintf('%d:', isize), tdforsep, ...
lformat, lfc ...
);
end
if iscell(tdreply)
for cc = 1:length(tdreply)
myformat = tdformat;
myformat = strrep(myformat, '$xc', ...
sprintf('%d',tdreply{cc}{1}(1)));
myformat = strrep(myformat, '$yc', ...
sprintf('%d',tdreply{cc}{1}(2)));
myformat = strrep(myformat, '$zc', ...
sprintf('%d',tdreply{cc}{1}(3)));
myformat = strrep(myformat, '$xd', ...
sprintf('%d',tdreply{cc}{2}(1)));
myformat = strrep(myformat, '$yd', ...
sprintf('%d',tdreply{cc}{2}(2)));
myformat = strrep(myformat, '$zd', ...
sprintf('%d',tdreply{cc}{2}(3)));
myformat = strrep(myformat, '$diff', ...
strrep(sprintf('%d', ...
tdreply{cc}{3}(1)),'.',tddecimal));
myformat = strrep(myformat, '$t1', ...
tdreply{cc}{4}{1});
myformat = strrep(myformat, '$t2', ...
tdreply{cc}{4}{2});
myformat = strrep(myformat, '$t3', ...
tdreply{cc}{4}{3});
myformat = strrep(myformat, '$t4', ...
tdreply{cc}{4}{4});
myformat = strrep(myformat, '$t5', ...
tdreply{cc}{4}{5});
tdreplyr = [tdreplyr sformat myformat lfc];
end
end
if all(tdforxln == 1)
tdreplya{rc} = [tdreplyr sformat lformat lfc];
else
tdreplya{rc} = tdreplyr(1:(end-length(lfc)));
end
else
command = [command ':'];
myindent = indent;
myindent(1:length(command)) = command;
tdreplya{rc} = [myindent tdreply];
end
if ~tdsilent, fprintf(1,'\b\b\b\b%3d%%',floor(100*rc/numcoords)); end
end
if ~tdsilent
fprintf(1,'\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b');
fprintf(1,' ');
fprintf(1,'\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \b');
end
if rc == 1 && fromspm == 0
tdreply = tdreplya{1};
else
tdreply = tdreplya;
end
if charout, tdreply = char(tdreply); end
end
% internal functions
function [status, result] = i_tdclient(arguments)
persistent tdclient_binlocation;
if ~ischar(tdclient_binlocation)
tdclient_binlocation = bvqxtools_path('bin');
if ispc
tdclient_binlocation = ['"' tdclient_binlocation '\tdclient.exe"'];
else
tdclient_binlocation = [tdclient_binlocation '/tdclient'];
end
end
[status, result] = system([tdclient_binlocation ' ' arguments]);
result(result < 32) = [];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -