1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
## Copyright (C) 2018 John Donoghue <john.donoghue@ieee.org>
##
## This program is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
## -*- texinfo -*-
## @deftypefn {} {@var{count} =} getSharedResourceProperty (@var{ar}, @var{resource}, @var{property})
## Get the value of a property from a given resource.
##
## @subsubheading Inputs
## @var{ar} - connected arduino object
##
## @var{resource} - name of resource to get property for.
##
## @var{property} - name of property from the resource.
##
## @subsubheading Outputs
## @var{propvalue} - value of the property
##
## @seealso{getResourceCount, setSharedResourceProperty}
## @end deftypefn
function retval = getSharedResourceProperty (ar, resource, propname)
if nargin != 3
print_usage ();
endif
if !ischar(resource)
error ("getSharedResourceProperty: expects resource name");
endif
if !ischar(propname)
error ("getSharedResourceProperty: expects resource property name");
endif
resinfo = ar.get_resource(resource);
retval = resinfo.props.(tolower(propname));
endfunction
%!test
%! ar = arduino();
%! assert(!isempty(ar));
%! setSharedResourceProperty(ar, "notusedname", "propname", 16);
%! assert(getSharedResourceProperty(ar,"notusedname", "propname"), 16);
|