- demystifyied dataset - matched filter - timing sync (whole sig, not symbol based) - EQ is worse, I guess due to symbol timing recovery Pulsef: - can be used as matched filter now, the only thing I really changed was the sampling behavior - before it assumed that the input is always fsym, now it can be anything... fdac is output frequency for both methods
182 lines
5.8 KiB
Matlab
182 lines
5.8 KiB
Matlab
classdef Moveit_wrapper < handle
|
|
%
|
|
|
|
properties(Access=public)
|
|
moveit_function_name
|
|
para
|
|
state = struct()
|
|
comment
|
|
end
|
|
|
|
methods (Access=public)
|
|
function obj = Moveit_wrapper(moveit_function_name,options)
|
|
%
|
|
|
|
arguments
|
|
moveit_function_name
|
|
options.para
|
|
end
|
|
|
|
obj.moveit_function_name = moveit_function_name;
|
|
fn = fieldnames(options);
|
|
for n = 1:numel(fn)
|
|
try
|
|
obj.(fn{n}) = options.(fn{n});
|
|
end
|
|
end
|
|
|
|
% Ensure the function exists
|
|
if ~exist(obj.moveit_function_name, 'file')
|
|
error('Function "%s" does not exist. The move-it module must be on path for Matlab, otherwise the wrapper can not call it...', obj.moveit_function_name);
|
|
end
|
|
|
|
% Step 1: Get default parameters by calling moveit module
|
|
if isempty(obj.para)
|
|
global loop;
|
|
loop = 0; % Request parameter structure
|
|
[obj.para, obj.comment] = feval(obj.moveit_function_name);
|
|
end
|
|
|
|
end
|
|
|
|
function signal_out = process(obj,signal_in)
|
|
|
|
arguments
|
|
obj
|
|
signal_in = []
|
|
|
|
end
|
|
|
|
isSignalClass = 0;
|
|
if isa(signal_in,"Signal")
|
|
signalclass_out = signal_in;
|
|
signal_in = signal_in.signal;
|
|
isSignalClass = 1;
|
|
end
|
|
|
|
signal_in = signal_in.';
|
|
|
|
% INIT MOVEIT
|
|
global loop;
|
|
loop = 0;
|
|
signal_init = obj.moveit_init(signal_in);
|
|
|
|
% RUN MOVEIT
|
|
global loop;
|
|
loop = 1;
|
|
|
|
signal_out = obj.moveit_simulation_computation(signal_in);
|
|
|
|
if isSignalClass
|
|
% append to logbook
|
|
signalclass_out.signal = signal_out;
|
|
signal_out=signalclass_out;
|
|
lbdesc = ['Logbookentry'];
|
|
signal_out = signal_out.logbookentry(lbdesc);
|
|
end
|
|
|
|
end
|
|
|
|
function open_settings(obj)
|
|
% Opens a settings dialog for modifying Moveit parameters with appropriate input types.
|
|
% Inserts separators when the level value changes.
|
|
|
|
fieldNames = fieldnames(obj.para);
|
|
settingsCell = {};
|
|
previousLevel = -inf; % Track previous level for separators
|
|
|
|
% Create input arguments for settingsdlg
|
|
for i = 1:numel(fieldNames)
|
|
fieldName = fieldNames{i};
|
|
value = obj.para.(fieldName);
|
|
|
|
% Get description from comment structure if available
|
|
if isfield(obj.comment, fieldName)
|
|
description = obj.comment.(fieldName);
|
|
else
|
|
description = fieldName; % Default to field name if no description
|
|
end
|
|
|
|
% Get level for this parameter
|
|
if isfield(obj.comment.level, fieldName)
|
|
currentLevel = obj.comment.level.(fieldName);
|
|
else
|
|
currentLevel = 1; % Default level
|
|
end
|
|
|
|
% Insert separator if the level changes
|
|
if currentLevel ~= previousLevel
|
|
settingsCell{end+1} = 'separator';
|
|
settingsCell{end+1} = ['Level ', num2str(currentLevel)];
|
|
end
|
|
previousLevel = currentLevel;
|
|
|
|
% Determine input type from obj.comment.type
|
|
if 1
|
|
inputType = obj.comment.type.(fieldName);
|
|
else
|
|
inputType = 'number'; % Default type
|
|
end
|
|
|
|
% Add field description
|
|
settingsCell{end+1} = {description; fieldName};
|
|
|
|
% Define the input type
|
|
if strcmp(inputType, 'boolean')
|
|
% Checkbox input
|
|
settingsCell{end+1} = logical(value); % Enable checkbox
|
|
elseif contains(inputType, '|')
|
|
% Dropdown selection (options separated by '|')
|
|
dropdownOptions = strsplit(inputType, '|');
|
|
settingsCell{end+1} = dropdownOptions;
|
|
else
|
|
% Default: Numeric input
|
|
settingsCell{end+1} = value;
|
|
end
|
|
end
|
|
|
|
% Open settings dialog
|
|
[newValues, button] = settingsdlg(...
|
|
'title', ['Settings: ', obj.moveit_function_name], ...
|
|
'description', ['Adjust parameters for ', obj.moveit_function_name], ...
|
|
settingsCell{:} ...
|
|
);
|
|
|
|
% Update obj.para with new values only if "OK" was pressed
|
|
if strcmp(button, 'OK')
|
|
fieldNames = fieldnames(newValues);
|
|
for i = 1:numel(fieldNames)
|
|
if fieldNames{i}
|
|
|
|
end
|
|
obj.para.(fieldNames{i}) = newValues.(fieldNames{i});
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
|
|
methods (Access=private)
|
|
|
|
function data_out = moveit_init(obj,data_in)
|
|
arguments(Input)
|
|
obj
|
|
data_in double
|
|
end
|
|
% Step 2: Initialize the function
|
|
[data_out, obj.state] = feval(obj.moveit_function_name, data_in, obj.state, obj.para);
|
|
end
|
|
|
|
function data_out = moveit_simulation_computation(obj,data_in)
|
|
arguments(Input)
|
|
obj
|
|
data_in double
|
|
end
|
|
% Step 3: Process input signal
|
|
[data_out, obj.state] = feval(obj.moveit_function_name, data_in, obj.state, obj.para);
|
|
end
|
|
|
|
end
|
|
end
|