|
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)
|
|
66 | 73 | %-- 1D data arrays created with this function.
|
67 | 74 | %-- e.g. size([1 2 3]) returns shape [1 3], which would not
|
68 | 75 | %-- be accepted when trying to add an alias range dimension.
|
69 |
| - %-- TODO Remove this when a cleverer solution presents itself. |
70 | 76 | if(size(data, 1) == 1)
|
71 | 77 | shape = size(data, 2);
|
72 | 78 | end;
|
73 |
| - dtype = class(data); |
74 |
| - |
| 79 | + |
| 80 | + errorStruct.identifier = 'Block:unsupportedDataType'; |
| 81 | + if(ischar(data)) |
| 82 | + errorStruct.message = 'Writing Strings to DataArrays is not supported as of yet.'; |
| 83 | + error(errorStruct); |
| 84 | + elseif(islogical(data)) |
| 85 | + dtype = nix.DataType.Bool; |
| 86 | + elseif(isnumeric(data)) |
| 87 | + dtype = nix.DataType.Double; |
| 88 | + else |
| 89 | + errorStruct.message = 'DataType of provided data is not supported.'; |
| 90 | + error(errorStruct); |
| 91 | + end; |
| 92 | + |
75 | 93 | da = obj.create_data_array(name, nixtype, dtype, shape);
|
76 | 94 | da.write_all(data);
|
77 | 95 | end
|
|
145 | 163 | 'Block::openMultiTag', id_or_name, @nix.MultiTag);
|
146 | 164 | end;
|
147 | 165 |
|
148 |
| - %-- creating a multitag requires an already existing data array |
| 166 | + %-- Creating a multitag requires an already existing data array |
149 | 167 | function multitag = create_multi_tag(obj, name, type, add_data_array)
|
150 | 168 | if(strcmp(class(add_data_array), 'nix.DataArray'))
|
151 | 169 | addID = add_data_array.id;
|
|
161 | 179 | delCheck = nix.Utils.delete_entity(obj, ...
|
162 | 180 | del, 'nix.MultiTag', 'Block::deleteMultiTag');
|
163 | 181 | end;
|
164 |
| - end; |
165 | 182 |
|
| 183 | + end; |
166 | 184 | end
|
0 commit comments