|
52 | 52 | 'Block::openDataArray', id_or_name, @nix.DataArray);
|
53 | 53 | end;
|
54 | 54 |
|
55 |
| - %-- As "datatype" provide one of the nix.DataTypes. Alternatively |
56 |
| - %-- a string stating one of the datatypes supported by nix can be provided. |
57 | 55 | function da = create_data_array(obj, name, nixtype, datatype, shape)
|
58 |
| - handle = nix_mx('Block::createDataArray', obj.nix_handle, ... |
59 |
| - name, nixtype, datatype, shape); |
60 |
| - da = nix.DataArray(handle); |
| 56 | + errorStruct.identifier = 'Block:unsupportedDataType'; |
| 57 | + if(~isa(datatype, 'nix.DataType')) |
| 58 | + errorStruct.message = 'Please provide a valid nix.DataType'; |
| 59 | + error(errorStruct); |
| 60 | + elseif(isequal(datatype, nix.DataType.String)) |
| 61 | + errorStruct.message = 'Writing Strings to DataArrays is not supported as of yet.'; |
| 62 | + error(errorStruct); |
| 63 | + else |
| 64 | + handle = nix_mx('Block::createDataArray', obj.nix_handle, ... |
| 65 | + name, nixtype, lower(datatype.char), shape); |
| 66 | + da = nix.DataArray(handle); |
| 67 | + end; |
61 | 68 | end
|
62 | 69 |
|
63 | 70 | function da = create_data_array_from_data(obj, name, nixtype, data)
|
64 |
| - shape = size(data); |
65 |
| - dtype = class(data); |
66 |
| - |
| 71 | + errorStruct.identifier = 'Block:unsupportedDataType'; |
| 72 | + if(ischar(data)) |
| 73 | + errorStruct.message = 'Writing Strings to DataArrays is not supported as of yet.'; |
| 74 | + error(errorStruct); |
| 75 | + elseif(islogical(data)) |
| 76 | + dtype = nix.DataType.Bool; |
| 77 | + elseif(isnumeric(data)) |
| 78 | + dtype = nix.DataType.Double; |
| 79 | + else |
| 80 | + errorStruct.message = 'DataType of provided data is not supported.'; |
| 81 | + error(errorStruct); |
| 82 | + end; |
| 83 | + |
| 84 | + shape = size(data); |
67 | 85 | da = obj.create_data_array(name, nixtype, dtype, shape);
|
68 | 86 | da.write_all(data);
|
69 | 87 | end
|
|
137 | 155 | 'Block::openMultiTag', id_or_name, @nix.MultiTag);
|
138 | 156 | end;
|
139 | 157 |
|
140 |
| - %-- creating a multitag requires an already existing data array |
| 158 | + %-- Creating a multitag requires an already existing data array |
141 | 159 | function multitag = create_multi_tag(obj, name, type, add_data_array)
|
142 | 160 | if(strcmp(class(add_data_array), 'nix.DataArray'))
|
143 | 161 | addID = add_data_array.id;
|
|
153 | 171 | delCheck = nix.Utils.delete_entity(obj, ...
|
154 | 172 | del, 'nix.MultiTag', 'Block::deleteMultiTag');
|
155 | 173 | end;
|
156 |
| - end; |
157 | 174 |
|
| 175 | + end; |
158 | 176 | end
|
0 commit comments