urbiGetDevicesFields

PURPOSE ^

Read multiple device fields or variables value at the same time

SYNOPSIS ^

function [V, time] = urbiGetDevicesFields(con, listDevicesFields)

DESCRIPTION ^

 Read multiple device fields or  variables value at the same time
 The result of this function is a vector V with the values in the same
 order as in the argument list 
 e.g. V = getDevicesFields(aibo, {'headPan.val','myVariable.val'});

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [V, time] = urbiGetDevicesFields(con, listDevicesFields)
0002 % Read multiple device fields or  variables value at the same time
0003 % The result of this function is a vector V with the values in the same
0004 % order as in the argument list
0005 % e.g. V = getDevicesFields(aibo, {'headPan.val','myVariable.val'});
0006 
0007 urbiClearConnection(con) ;
0008 tag_base = 'dgfstag';
0009 tag_base_size = size(tag_base, 2);
0010 
0011 n = size(listDevicesFields, 2);
0012 V = zeros(1, n);
0013 cmd = [];
0014 % Compose the command string
0015 for i=1:n
0016     tag{i} = [tag_base num2str(i)];
0017     cmd = [cmd ' & ' tag{i} ':' listDevicesFields{i} ];
0018 end;
0019 cmd = cmd(4:size(cmd, 2));
0020 % Send the command
0021 urbiSend(con, [cmd ';']);
0022 % Retrieve the results
0023 for i=1:n
0024     o_tag = '';
0025     while ~strncmp (o_tag, tag_base, tag_base_size)
0026         r = pnet(con, 'readline', 'noblock');
0027         while isempty(r)
0028             r = pnet(con, 'readline', 'noblock');
0029         end;
0030         ans_string = strread (r, '%s');
0031         [timeStamp, o_tag] = strread(ans_string{1}, '[%u:%s]', 'whitespace', ']');
0032         o_tag = char(o_tag);
0033     end;
0034     index = str2num(o_tag(tag_base_size + 1:size(o_tag, 2)));
0035     V(index) = str2num(ans_string{2});
0036 end;
0037 time = timeStamp;

Generated on Tue 20-Dec-2005 19:05:34 by m2html © 2003