Thread Subject: Update Subsystem MaskDisplay from a Library with Subversion Info

Subject: Update Subsystem MaskDisplay from a Library with Subversion Info

From: Juan Manuel Romero Martin

Date: 9 Jul, 2007 11:05:55

Message: 1 of 1

Hello everybody,

I am trying to create a Model Block to show the version control info obtained from subversion. I know that under windows we can not use the “customverctr.m” to use subversion with the default Model Info Block. In addition I download PushOk SVNSCC (www.pushok.com) but it doesn’t work. That is the reason why I am trying to development my own SVN-Model Info.

My idea, as I said before is create a Subsystem, called SVN-Model Indo which I can place in any Model and it recognized the file of the Model and ask subversion for the pertinent information and display it as a Mask Display. I got to work it for individual Models, but when I place then individual models inside a library I start getting very weird behaviour. I know that the main problem is that I can not modify a SVN-Model Info block inside the model inside the library. But I break the link setting the LinkStatus to ‘none’. However it still gives me very weird behaviour.

So please if anyone could help me I will be very very grateful.

Thanks in advances.
Juan Romero

An illustration of my “suppose” library can be found here <http://www.di3d.eu/svn.jpg>.

PD: Is there anything in Matlab/Simulink like “this” in c++ to refer to the actual instance?

[SVN-MODEL BLOCK CODE]

< LoadFnc >
set_ModelInfo(gcb)
disp(['LoadFcn was called at ' DATESTR(now)])

< OpenFnc >
set_ModelInfo(gcb)
disp(['OpenFcn was called at ' DATESTR(now)])

[set_ModelInfo Function]
 
function set_ModelInfo(ablock)
    
    clc
      
    % get the model filename
    fullpath = gcs;
    cut = strfind(fullpath,'/');
    
    % Get the SVN Info of the actual block file.
    [o,out] = system(['svn info ' fullpath(cut(1)+1:end) '.mdl']);
  
    % Convert the System output in different lines
    result = getlines(out);

    newMask='';
    for i=1:length(result)
        newMask = [newMask '\n ' result{i} ];
    end

       
    % Breaking the Link to the reference Block
    
    % [JMRM]
    % I dont have a clue why i have to do that to make that this script
    % works when the block is in a library

    if strcmp(get_param(get_param(gcb,'Parent'),'LinkStatus'),'none')==0
        set_param(get_param(gcb,'Parent'),'LinkStatus','none');
    end
    
    set_param(bdroot,'Lock','off')
    set_param(gcb,'MaskSelfModifiable','on')
    
    
    % Breaking the Link to the reference Block
    if strcmp(get_param(get_param(gcb,'Parent'),'LinkStatus'),'none')==0
        set_param(get_param(gcb,'Parent'),'LinkStatus','none');
    end
    
    % Set the CM Info in the SVN-Model Info Blocks
    set_param(gcb,'Mask','on','MaskDisplay', ['fprintf(''' newMask ''')']);
    
    % Change The color of the SVN Model Info Block to see that it has been
    % changed visually.
    set_param(gcb,'BackgroundColor',sprintf('[%f,%f,%f]',rand(1,1)*1.3,rand(1,1)*1.3,rand(1,1)*1.3));
    
    % Disable Again the MakeSelfModifiable
    set_param(gcb,'MaskSelfModifiable','off');
    
    % Lock Again the Library
    set_param(bdroot,'Lock','on');
    
end

[getlines Function]

function result = getlines(aString)
 
   % Get the Numbers of lines
   lines = regexp(aString,'\n');
   
   % Get Each Line.
   for i=1: (length(lines)-1)
      result{i} = aString( lines(i)+1 : lines(i+1)-1 );
   end
 
end

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com