|
30 | 30 | end
|
31 | 31 |
|
32 | 32 | function [] = set.values(obj, val)
|
33 |
| - |
34 |
| - %-- when an update occurs, check, if the datatype of the |
35 |
| - %-- data within a normal array is consistent with the |
36 |
| - %-- datatype of the property |
37 |
| - checkDType = obj.datatype; |
38 |
| - if(~iscell(val) && ~isstruct(val) && ~isempty(val)) |
39 |
| - checkDType = strrep(strrep(class(val),'char','string'),'logical','bool'); |
40 |
| - %-- convert any values to cell array |
41 |
| - val = num2cell(val); |
42 |
| - elseif (iscell(val) && ~isstruct(val{1})) |
43 |
| - checkDType = strrep(strrep(class(val{1}),'char','string'),'logical','bool'); |
44 |
| - end; |
45 |
| - |
46 |
| - if(isempty(find(strcmpi(checkDType, obj.datatype),1))) |
47 |
| - error('Values do not match property data type!'); |
48 |
| - end; |
49 |
| - |
50 |
| - nix_mx('Property::updateValues', obj.nix_handle, val); |
| 33 | + values = val; |
| 34 | + if (~iscell(values)) |
| 35 | + values = num2cell(val); |
| 36 | + end |
| 37 | + |
| 38 | + for i = 1:length(values) |
| 39 | + if (isstruct(values{i})) |
| 40 | + curr = values{i}.value; |
| 41 | + else |
| 42 | + curr = values{i}; |
| 43 | + end |
| 44 | + |
| 45 | + if (~strcmpi(class(curr), obj.datatype)) |
| 46 | + error('Values do not match property data type!'); |
| 47 | + end |
| 48 | + end |
| 49 | + |
| 50 | + nix_mx('Property::updateValues', obj.nix_handle, values); |
51 | 51 | obj.valuesCache.lastUpdate = 0;
|
52 | 52 |
|
53 | 53 | dispStr = 'Note: nix only supports updating the actual value at the moment.';
|
54 | 54 | dispStr = [dispStr, char(10), 'Attributes like uncertainty or checksum cannot be set at the moment.'];
|
55 | 55 | disp(dispStr);
|
56 |
| - |
57 |
| - %-- TODO: clearing existing values using obj.values = '' works, |
58 |
| - %-- but is a hack. Refactor in good time. |
59 | 56 | end
|
60 | 57 | end
|
61 | 58 |
|
|
0 commit comments