% loop_records.m % === Prepare base configuration === % databasePath = 'C:\Users\sioe\Documents\MATLAB\imdd_simulation\projects\ECOC_2025\'; local = 1; if local databasePath = 'C:\Users\sioe\Documents\MATLAB\imdd_simulation\projects\ECOC_2025\'; savePath = 'Z:\2025\ECOC Silas\ecoc_2025\'; else databasePath = 'C:\Users\sioe\Documents\MATLAB\imdd_simulation\projects\ECOC_2025\'; savePath = 'Z:\2025\ECOC Silas\ecoc_2025\'; end database_name = 'ecoc2025_loops.db'; db = DBHandler("pathToDB", [databasePath, database_name]); conf = db.tables.Configurations; % conf = db.tables.Configurations; if ~exist('confPrev','var') confPrev = conf; end awg_upload_required = 1; %still uploads every first round subimt_DSP = 1; recordlen = 1000000; sequence_order = 17; n_recording = 1; % Or any number you want conf=rmfield(conf,"interference_attenuation"); conf=rmfield(conf,"symbolrate"); conf=rmfield(conf,"pam_level"); % Define vector parameters directly in conf: conf.unique_elab_id = "20250408-842b0a3078172b48dd032795226fbe683190afc4"; conf.db_mode = db_mode.no_db; conf.pulsef_alpha = 0.2; conf.v_bias = 2.65; conf.v_awg = 0.85; conf.precomp_amp = -64; %-64 conf.wavelength = 1310; conf.laser_power = 11; conf.fiber_length = 0; conf.pd_in_desired = 9; conf.is_mpi = true; conf.signal_attenuation = 0; conf.interference_path_length = 20; %m conf.interference_attenuation = 10;%[0:2:30,40]; conf.pam_level = 4;%[2,4,6,8]; conf.symbolrate = [112].*1e9; conf.pam_source = []; if conf.is_mpi current_folder = ['test_mpi_opti_',num2str(conf.interference_path_length),'m_pam',num2str(conf.pam_level)]; else current_folder = 'testing'; end % Init empty loop id loop_id = []; % === Detect vector fields automatically === paramNames = fieldnames(conf); vectorParams = struct(); scalarConf = conf; parallel_dsp = false; max_occurences = 1; for i = 1:numel(paramNames) thisName = paramNames{i}; thisValue = conf.(thisName); if isnumeric(thisValue) && numel(thisValue) > 1 vectorParams.(thisName) = thisValue; parallel_dsp = true; max_occurences = 10; else scalarConf.(thisName) = thisValue; end end vectorFieldNames = fieldnames(vectorParams); if isempty(vectorFieldNames) % No vector parameters, single run fprintf('Running single measurement (no parameter sweep)\n'); confRequest = scalarConf; confRequest.bitrate = confRequest.symbolrate * floor(log2(confRequest.pam_level) * 10) / 10; measure_run_script else % Vector parameters found, run parameter sweep vectorValues = struct2cell(vectorParams); nParams = numel(vectorValues); grid = cell(1, nParams); [grid{:}] = ndgrid(vectorValues{:}); totalRuns = numel(grid{1}); fprintf('Total runs: %d\n', totalRuns); for runIdx = 1:totalRuns confRequest = scalarConf; paramDisplayCell = cell(1, nParams); for vIdx = 1:nParams fieldName = vectorFieldNames{vIdx}; paramValue = grid{vIdx}(runIdx); confRequest.(fieldName) = paramValue; if isnumeric(paramValue) paramDisplayCell{vIdx} = sprintf('%s = %.4g', fieldName, paramValue); else paramDisplayCell{vIdx} = sprintf('%s = %s', fieldName, char(paramValue)); end end fprintf('Running measurement: %s ---> %d of %d done \n ', strjoin(paramDisplayCell, ', '),runIdx, totalRuns); if confRequest.pam_level == 2 confRequest.symbolrate = 112e9; elseif confRequest.pam_level == 4 confRequest.symbolrate = 112e9; elseif confRequest.pam_level == 6 confRequest.symbolrate = 96e9; elseif confRequest.pam_level == 8 confRequest.symbolrate = 72e9; end confRequest.bitrate = confRequest.symbolrate * floor(log2(confRequest.pam_level) * 10) / 10; % measure_run("config",confRun,"parallel",parallel_dsp,"max_occurences",max_occurences); measure_run_script; end end disp('- LOOP FINISHED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ') fprintf('\n')