High Speed Auswertung und Database code

This commit is contained in:
sioe
2024-11-13 10:49:49 +01:00
parent ca769f2b3d
commit 553ed19b9f
20 changed files with 2931 additions and 66 deletions

View File

@@ -125,77 +125,79 @@ classdef DataStorage < handle
lin_idx = obj.getIndicesByPhys(varargin);
errcnt = 0;
for i=1:numel(lin_idx)
tmp = obj.sto.(storageVarName){lin_idx(i)};
if ~isempty(tmp)
if isa(tmp,'Signal') || isa(tmp,'struct') || isa(tmp,'Exfo_laser') || isa(tmp,'DC_supply')
tmp = obj.sto.(storageVarName){lin_idx(i)};
if ~isempty(tmp)
if isa(tmp,'double')
value(i) = tmp ;
elseif isa(tmp,'Signal') || isa(tmp,'struct') || isa(tmp,'Exfo_laser') || isa(tmp,'DC_supply')
if i == 1
value = {};
end
value{i} = tmp ;
elseif isa(tmp,'cell')
if isa(tmp{1},'Signal')
if i == 1
value = {};
end
value{i} = tmp{1} ;
else
value{i} = tmp{1} ;
end
else
try
if i == 1
value = {};
end
value{i} = tmp ;
catch
% value(i,:) = tmp(1:size(value,2)) ;
elseif isa(tmp,'cell')
if isa(tmp{1},'Signal')
if i == 1
value = {};
end
value{i} = tmp{1} ;
else
value{i} = tmp{1} ;
end
if size(value,2) < size(tmp,2)
else
try
if i == 1
value = {};
end
value{i} = tmp ;
catch
% value(i,:) = tmp(1:size(value,2)) ;
if size(value,2) < size(tmp,2)
diff = size(tmp,2) - size(value,2);
value(:,end+1:end+diff) = NaN(size(value,1),diff);
value(i,:) = tmp ;
diff = size(tmp,2) - size(value,2);
value(:,end+1:end+diff) = NaN(size(value,1),diff);
value(i,:) = tmp ;
elseif size(value,2) > size(tmp,2)
elseif size(value,2) > size(tmp,2)
diff = size(value,2) - size(tmp,2);
tmp(:,end+1:end+diff) = NaN(1,diff);
value(i,:) = tmp ;
end
diff = size(value,2) - size(tmp,2);
tmp(:,end+1:end+diff) = NaN(1,diff);
value(i,:) = tmp ;
end
end
else
errcnt = errcnt+1;
if errcnt < 3
end
else
errcnt = errcnt+1;
if errcnt < 3
%get back the n-dimensional subiondices...
[sub{1:length(size(obj.sto.(storageVarName)))}] = ind2sub(size(obj.sto.(storageVarName)),lin_idx(i));
%get back the physical representaion
%get back the physical representaion
word = [];
for phys_idx = 1:numel(obj.fn)
parametername = obj.fn(phys_idx);
word = [word,char(parametername),': ', num2str(obj.parameter.(parametername).getPhysForIndex(sub{phys_idx})),' ;'];
end
% warning(['Requested Data is not in Warehouse ', word]);
elseif errcnt == 3
% warning(['... ', word]);
end
end
if errcnt > 2
% warning([num2str(errcnt),' requested datapoint(s) not in warehouse.']);
% warning(['Requested Data is not in Warehouse ', word]);
elseif errcnt == 3
% warning(['... ', word]);
end
end
if errcnt > 2
% warning([num2str(errcnt),' requested datapoint(s) not in warehouse.']);
end
end
else
error('Wrong Request using ExampleWarehouse.getStoValue(*parameter set*). Give me all the Parameters! Please!')
@@ -259,7 +261,7 @@ classdef DataStorage < handle
end
% Mapping for single Index
function idx = getIndexByPhys(obj,fieldname,phys)
%map single phys to index
@@ -267,7 +269,70 @@ classdef DataStorage < handle
end
function phys_indices = getPhysIndicesByLinIndex(obj, lin_idx)
% Converts a linear index into the corresponding physical parameter values
% Inputs:
% - lin_idx: The linear index within the storage array
% Output:
% - phys_indices: A cell array containing the physical parameter values for each dimension
% Initialize output cell array
phys_indices = cell(1, numel(obj.fn));
% Convert linear index to subscript indices
[subscripts{1:numel(obj.dim)}] = ind2sub(obj.dim, lin_idx);
% Map subscripts to physical values for each parameter
for i = 1:numel(obj.fn)
param_name = obj.fn(i);
phys_indices{i} = obj.parameter.(param_name).getPhysForIndex(subscripts{i});
end
end
function [physStruct, stored_value] = getPhysAndValueByLinIndex(obj, storageVarName, lin_idx)
% Retrieves a structure with physical parameter values as fieldnames,
% their corresponding parameter names as values, and the stored value
% for a given linear index.
% Inputs:
% - storageVarName: Name of the storage variable in obj.sto
% - lin_idx: The linear index within the storage array
% Outputs:
% - physStruct: A structure with physical parameter values as fieldnames
% and parameter names as values
% - stored_value: The value stored at the given linear index in the
% specified storage variable
% Initialize an empty structure
physStruct = struct();
% Convert linear index to subscript indices
[subscripts{1:numel(obj.dim)}] = ind2sub(obj.dim, lin_idx);
% Map subscripts to physical values and parameter names for each dimension
for i = 1:numel(obj.fn)
param_name = obj.fn(i);
phys_value = obj.parameter.(param_name).getPhysForIndex(subscripts{i});
% Add to the structure with phys_value as the fieldname and param_name as the value
physStruct.(param_name) = phys_value;
end
% Retrieve the stored value at the given linear index
stored_value = obj.sto.(storageVarName){lin_idx};
end
function num_elements = getLastLinIndice(obj)
% Returns all possible linear indices for the data structure
% Output:
% - lin_indices: A column vector containing all linear indices for the storage array
% Calculate the total number of elements in the storage array
num_elements = prod(obj.dim);
end
end
end