Commit 56cfadd3 authored by Jay Dubb's avatar Jay Dubb
Browse files

v1.28.4

-- When loading groupResults.mat and copying the procStream function call chain do error check against user function registry, and if error check fails for a function call, then search registry for closest match. This same thing is already being done when loading function call chain from processOpt*.cfg.

-- If user function definition changed detect that the date of the file or files is later than Registry.mat file and regenerate the registry thereby updating the registry definition of the function. This will help fix the problem where a user function definition changes but Registry.mat has the old deifnition so the error check of function call chain in groupResults.mat will pass and will NOT trigger a search for closet regditry match.
parent bec3976e
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -467,10 +467,12 @@ classdef FuncCallClass < handle
        % ----------------------------------------------------------------------------------
        function scorefinal = Compare(obj, obj2)           
            score = [];
            if ~strcmp(obj.name, obj2.name)
                score(end+1) = 0;
            else
            if strcmp(obj.name, obj2.name)
                score(end+1) = 0.50;
            elseif ~isempty(findstr(obj.name, obj2.name))
                score(end+1) = 0.30;
            else
                score(end+1) = 0;
            end
            score(end+1) = 0.16 * obj.argOut.Compare(obj2.argOut);
            score(end+1) = 0.16 * obj.argIn.Compare(obj2.argIn);
+23 −5
Original line number Diff line number Diff line
@@ -54,13 +54,31 @@ classdef ProcStreamClass < handle
                obj = ProcStreamClass();
            end
            
            kk=1;
            for ii = 1:length(obj2.fcalls)                
                obj.fcalls(ii) = FuncCallClass();
                obj.fcalls(ii).Copy(obj2.fcalls(ii), obj.reg);
                % If registry is empty, then add fcall entries unconditionally.
                % Otherwise only include those user function calls that exist in the registry.
                if ~isempty(obj.reg.GetUsageName(obj2.fcalls(ii)))
                    obj.fcalls(kk) = FuncCallClass(obj2.fcalls(ii), obj.reg);
                    kk = kk+1;
                else
                    fprintf('Entry \"%s\" not found in registry ...\n', obj2.fcalls(ii).GetName())
                    fprintf('  Searching registry for equivalent or similar entry\n')
                    temp = obj.reg.FindClosestMatch(obj2.fcalls(ii));
                    if ~isempty(temp)
                        fprintf('  Found similar entry: %s\n', temp.encodedStr);
                        obj.fcalls(kk) = FuncCallClass(temp, obj.reg);
                        kk = kk+1;
                    else
                        fprintf('  Found no similar entries. Discarding %s\n', section{ii})
                    end
                end            
            end
            
            % Delete any fcalls entries not ovewritten by the copy process
            obj.fcalls(ii+1:end) = [];
            if ~isempty(obj.fcalls)
                obj.fcalls(kk+1:end) = [];
            end
            
            obj.input.Copy(obj2.input);
            obj.output.Copy(obj2.output, filename);
+17 −0
Original line number Diff line number Diff line
@@ -385,5 +385,22 @@ classdef FuncRegClass < matlab.mixin.Copyable
            usagestr = obj.entries(idx).GetUsageStrDecorated(usageparam);
        end

        
        % ----------------------------------------------------------------------------------
        function lastdt = DateLastModified(obj)
            lastdt = datetime(1970,01,01);
            for ii = 1:length(obj.entries)
                for jj = 1:length(obj.userfuncdir)
                    file = dir([obj.userfuncdir{jj}, '/', obj.entries(ii).GetName(), '.m']);
                    if ~isempty(file)
                        if datetime(file.date) > lastdt
                            lastdt = datetime(file.date);
                        end
                        break;
                    end
                end
            end
        end
        
    end
end
+10 −4
Original line number Diff line number Diff line
@@ -433,11 +433,17 @@ classdef FuncRegEntryClass < matlab.mixin.Copyable
        % ----------------------------------------------------------------------------------
        function fcall = FindClosestMatch(obj, fcall0)
            fcall = FuncCallClass().empty();
            maxscore = 0;
            imaxscore = [];
            for ii = 1:size(obj.usageoptions,1)
                if fcall0.Compare(obj.usageoptions{ii,4}) > 50
                    fcall = FuncCallClass(obj.usageoptions{ii,4});
                    break;
                currscore = fcall0.Compare(obj.usageoptions{ii,4});
                if  currscore > maxscore && currscore > 50
                    maxscore = currscore;
                    imaxscore = ii;
                end
            end
            if ~isempty(imaxscore)
                fcall = FuncCallClass(obj.usageoptions{imaxscore,4});
            end            
        end
        
+23 −7
Original line number Diff line number Diff line
@@ -52,10 +52,12 @@ classdef RegistriesClass < handle
                    r = load(obj.filename, 'reg');
                    if isa(r.reg, 'RegistriesClass') && ~isempty(r.reg)
                        obj.Copy(r.reg);
                        if obj.IsValid()
                            return;
                        end
                    end
                end
            end

            obj.Load();
            
@@ -348,6 +350,20 @@ classdef RegistriesClass < handle
            obj.Reload(type);
        end
    
        
        % ----------------------------------------------------------------------------------
        function b = IsValid(obj)
            b = false;
            regfile = dir([obj.userfuncdir{1}, 'Registry.mat']);
            for ii = 1:length(obj.funcReg)
                if obj.funcReg(ii).DateLastModified() > datetime(regfile.date)
                    return;
                end
            end
            b = true;
        end
        
    end
        
end
Loading