111 lines
3.5 KiB
Matlab
111 lines
3.5 KiB
Matlab
function output = dsp_runid(run_id, options)
|
|
|
|
arguments
|
|
run_id
|
|
options.append_to_db = 0;
|
|
options.max_occurences = 4;
|
|
options.parameters = struct();
|
|
options.database_type
|
|
options.dataBase
|
|
options.load_file_path = struct();
|
|
options.storage_path
|
|
options.mode
|
|
end
|
|
|
|
try
|
|
output = initializeOutput();
|
|
database = [];
|
|
|
|
if options.mode == "load_run_id" || options.append_to_db
|
|
database = DBHandler("dataBase", [options.dataBase], "type", options.database_type, ...
|
|
'user', "silas", 'password', "silas", 'server', "134.245.243.254");
|
|
end
|
|
|
|
if options.mode == "load_run_id"
|
|
dspInput = preprocessRunId(run_id, database, options);
|
|
elseif options.mode == "load_files"
|
|
dspInput = loadDspInputFromFiles(run_id, options);
|
|
else
|
|
error('dsp_runid:UnsupportedMode', 'Mode "%s" is not supported by the refactored dsp_runid path.', options.mode);
|
|
end
|
|
|
|
options.max_occurences = min(options.max_occurences, length(dspInput.Scpe_cell));
|
|
for r = 1:options.max_occurences
|
|
scopeOutput = dsp_scope_signal(dspInput.Scpe_cell{r}, dspInput.Symbols, dspInput.Tx_bits, ...
|
|
"fsym", dspInput.fsym, ...
|
|
"M", dspInput.M, ...
|
|
"duob_mode", dspInput.duob_mode, ...
|
|
"parameters", options.parameters);
|
|
|
|
output.ffe_package{r} = scopeOutput.ffe_package;
|
|
output.dfe_package{r} = scopeOutput.dfe_package;
|
|
output.mlse_package{r} = scopeOutput.mlse_package;
|
|
output.vnle_package{r} = scopeOutput.vnle_package;
|
|
output.dbtgt_package{r} = scopeOutput.dbtgt_package;
|
|
output.dbenc_package{r} = scopeOutput.dbenc_package;
|
|
output.mlmlse_package{r} = scopeOutput.mlmlse_package;
|
|
|
|
if options.append_to_db
|
|
appendScopeOutputToDatabase(database, run_id, scopeOutput);
|
|
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 dspInput = loadDspInputFromFiles(run_id, options)
|
|
%#ok<INUSD>
|
|
Tx_bits = load(options.load_file_path.tx_bits_path);
|
|
Symbols = load(options.load_file_path.tx_symbols_path);
|
|
Scpe_sig_raw = load(options.load_file_path.rx_raw_path);
|
|
|
|
Tx_bits = Tx_bits.Bits;
|
|
Symbols = Symbols.Symbols;
|
|
Scpe_sig_raw = Scpe_sig_raw.Scpe_sig_raw;
|
|
|
|
fsym = Symbols.fs;
|
|
M = Symbols.logbook.ModifierCopy{1}.M;
|
|
duob_mode = Symbols.logbook.ModifierCopy{1}.duobinary_mode;
|
|
|
|
Scpe_sig_resampled = Scpe_sig_raw.resample("fs_in", Scpe_sig_raw.fs, "fs_out", 2*fsym);
|
|
[~, Scpe_cell, ~, found_sync] = Scpe_sig_resampled.tsynch("reference", Symbols, "fs_ref", fsym, "debug_plots", 1);
|
|
|
|
dspInput = struct();
|
|
dspInput.run_id = run_id;
|
|
dspInput.dataTable = table();
|
|
dspInput.Tx_bits = Tx_bits;
|
|
dspInput.Symbols = Symbols;
|
|
dspInput.Scpe_cell = Scpe_cell;
|
|
dspInput.found_sync = found_sync;
|
|
dspInput.fsym = fsym;
|
|
dspInput.M = M;
|
|
dspInput.duob_mode = duob_mode;
|
|
end
|
|
|
|
function appendScopeOutputToDatabase(database, run_id, scopeOutput)
|
|
packageNames = fieldnames(scopeOutput);
|
|
|
|
for i = 1:numel(packageNames)
|
|
package = scopeOutput.(packageNames{i});
|
|
if isempty(package)
|
|
continue
|
|
end
|
|
|
|
database.addProcessingResult(run_id, package.metrics, package.config);
|
|
end
|
|
end
|