function cases = load_power(cases, case_ids, controller_ids)
%loads the power of the cases
cases.t = 31200:.5:42000;
for iC = 1:length(case_ids)
for iiC = 1:length(controller_ids)
    try
        switch case_ids(iC)
            case 1
                idx_load = ...
                    find(cases.HKN_00_to_03.types == controller_ids(iiC));
                power = readmatrix([cases.HKN_00_to_03.paths_to{idx_load}, ...
                    'powerGenerator']);
            case 2
                idx_load = ...
                    find(cases.HKN_06_to_09.types == controller_ids(iiC));
                power = readmatrix([cases.HKN_06_to_09.paths_to{idx_load}, ...
                    'powerGenerator']);
            case 3
                idx_load = ...
                    find(cases.HKN_12_to_15.types == controller_ids(iiC));
                power = readmatrix([cases.HKN_12_to_15.paths_to{idx_load}, ...
                    'powerGenerator']);
            otherwise
                error("Case doesn't exist, only 1 to 3")
        end
        
    catch
        warning(['Loading of case ' num2str(case_ids(iC)) ...
            ', controller nr ' num2str(controller_ids(iiC)) ' failed.'])
        continue;
    end
    t_tmp = power(:,2);
    % Convert to MW and remove air density error
    power = reshape(power(t_tmp>=31200,4) , 10, [])' ./ (1.225 * 10^6);

    if t_tmp(end)<42000
        warning(['Power data of case ' num2str(case_ids(iC)) ...
            ', controller nr ' num2str(controller_ids(iiC)) ' is ' ...
            num2str(42000 - t_tmp(end)) ...
            ' s too short. Adding constant values for the remaining time.'])
        power = [power; repmat(power(end,:), ...
            length(cases.t) - length(t_tmp(t_tmp>=31200))/10,1)];
    end

    cases.power{case_ids(iC), controller_ids(iiC)} = power;
end

end

