restructure and organize
This commit is contained in:
106
Functions/EQ_blocks/dsp_runid.m
Normal file
106
Functions/EQ_blocks/dsp_runid.m
Normal file
@@ -0,0 +1,106 @@
|
||||
function output = dsp_runid(run_id, options)
|
||||
|
||||
arguments
|
||||
run_id
|
||||
options.append_to_db = 0;
|
||||
options.max_occurences = 4;
|
||||
options.userParameters = struct();
|
||||
options.database_type
|
||||
options.dataBase
|
||||
options.server = "134.245.243.254";
|
||||
options.port = 3306;
|
||||
options.user = "silas";
|
||||
options.password = "silas";
|
||||
options.load_file_path = struct();
|
||||
options.storage_path
|
||||
options.mode
|
||||
options.recipe = @dsp_scope_signal;
|
||||
options.debug_plots (1,1) logical = false;
|
||||
end
|
||||
|
||||
try
|
||||
output = initializeOutput();
|
||||
database = [];
|
||||
inputSource = normalizeDspInputSource(options.mode);
|
||||
|
||||
if inputSource == "run_id" || options.append_to_db
|
||||
database = DBHandler("dataBase", [options.dataBase], "type", options.database_type, ...
|
||||
"user", options.user, "password", options.password, ...
|
||||
"server", options.server, "port", options.port);
|
||||
end
|
||||
|
||||
switch inputSource
|
||||
case "run_id"
|
||||
dspInput = loadDspInputFromRunId(run_id, database, options);
|
||||
case "file_paths"
|
||||
dspInput = loadDspInputFromFilePaths(run_id, options);
|
||||
end
|
||||
|
||||
options.max_occurences = min(options.max_occurences, length(dspInput.Scpe_cell));
|
||||
for r = 1:options.max_occurences
|
||||
|
||||
%%%%%%%% CORE EQUALIZATION CALL (Scpe, Symbols, Bits, 'Options') %%%%%%%
|
||||
|
||||
dspOutput = options.recipe(dspInput.Scpe_cell{r}, dspInput.Symbols, dspInput.Tx_bits, ...
|
||||
"fsym", dspInput.fsym, ...
|
||||
"M", dspInput.M, ...
|
||||
"duob_mode", dspInput.duob_mode, ...
|
||||
"dataTable", dspInput.dataTable, ...
|
||||
"userParameters", options.userParameters, ...
|
||||
"debug_plots", options.debug_plots);
|
||||
|
||||
%%%%%%%% CORE EQUALIZATION CALL %%%%%%%
|
||||
|
||||
fieldNames = fieldnames(dspOutput);
|
||||
for fieldIdx = 1:numel(fieldNames)
|
||||
fieldName = fieldNames{fieldIdx};
|
||||
output.(fieldName){r} = dspOutput.(fieldName);
|
||||
end
|
||||
if options.append_to_db
|
||||
appendDspOutputToDatabase(database, run_id, dspOutput);
|
||||
end
|
||||
end
|
||||
|
||||
catch ME
|
||||
save('workerError.mat', 'ME');
|
||||
rethrow(ME);
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function output = initializeOutput()
|
||||
output.ffe_package = {};
|
||||
output.dfe_package = {};
|
||||
output.mlse_package = {};
|
||||
output.vnle_package = {};
|
||||
output.dbtgt_package = {};
|
||||
output.dbenc_package = {};
|
||||
output.mlmlse_package = {};
|
||||
end
|
||||
|
||||
function inputSource = normalizeDspInputSource(mode)
|
||||
mode = string(mode);
|
||||
|
||||
switch mode
|
||||
case {"load_run_id", "run_id"}
|
||||
inputSource = "run_id";
|
||||
case {"load_files", "file_paths"}
|
||||
inputSource = "file_paths";
|
||||
otherwise
|
||||
error('dsp_runid:UnsupportedMode', ...
|
||||
'Mode "%s" is not supported. Use "run_id" or "file_paths".', mode);
|
||||
end
|
||||
end
|
||||
|
||||
function appendDspOutputToDatabase(database, run_id, dspOutput)
|
||||
packageNames = fieldnames(dspOutput);
|
||||
|
||||
for i = 1:numel(packageNames)
|
||||
package = dspOutput.(packageNames{i});
|
||||
if isempty(package)
|
||||
continue
|
||||
end
|
||||
|
||||
database.addProcessingResult(run_id, package.metrics, package.config);
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user