{"id":8654,"date":"2017-06-23T09:00:12","date_gmt":"2017-06-23T13:00:12","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=8654"},"modified":"2017-06-29T14:09:10","modified_gmt":"2017-06-29T18:09:10","slug":"source-control-information-block","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2017\/06\/23\/source-control-information-block\/","title":{"rendered":"Source Control Information Block"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\n   <introduction><\/p>\n<p><i>Richard is Consulting Engineer at MathWorks focused on the Embedded Coder product for code generation, primarily in the Aerospace<br \/>\n            industry.<\/i><\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1016860-richard-ruff\">Richard&#8217;s<\/a> pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/60373-source-control-information-block\">Source Control Information Block<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/747266-gavin-walker\">Gavin Walker<\/a>.\n      <\/p>\n<p>   <\/introduction><\/p>\n<h3>Pick<a name=\"1\"><\/a><\/h3>\n<p>My pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/60373-source-control-information-block\">Source Control Information Block<\/a>.\n   <\/p>\n<p>Shipping with Simulink is the Model Info block in the Simulink\/Model-Wide Utilities library.  When placed in a model, this block allows the user to show information about the model such as when it was created, who created it, when was it modified,etc.  It also allows the user to show the Model Version.\n   <\/p>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/ModelPropertiesDialog.png\"> <\/p>\n<p>The problem with this is the Model Version is defined by the model&#8217;s Model Properties setting.  By default, this is 1.X, where X is incremented each time the model is saved.  Opening the Model Propeties dialog and enabling editing (uncheck the &#8220;Read Only&#8221; checkbox) you can see the command that is used: 1.%&lt;AutoIncrement:X&gt;.\n   <\/p>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/ModelPropertiesDialog.png\"> <\/p>\n<p>While this can be useful information, it falls short in a practical application where a Configuration Management tool such as SVN or Git is used.  In this case, the Model Version most likely will not match the version of the file in the repository.\n   <\/p>\n<p>This is where this MATLAB File Exchange entry in conjunction with Simulink Projects fills the gap.  <a title=\"https:\/\/www.mathworks.com\/help\/releases\/R2017a\/simulink\/ug\/what-are-simulink-projects.html (link no longer works)\">Simulink Projects<\/a> helps the user organize their work.  In addition, Simulink Projects works with <a title=\"https:\/\/www.mathworks.com\/help\/releases\/R2017a\/simulink\/ug\/about-source-control-with-projects.html (link no longer works)\">Configuration Management tools<\/a> for source control of the various models and files being used.\n   <\/p>\n<p>The Source Control Information Block leverages Simulink Projects integration with source control tools to allow the user to show the relevant information.  The screenshot below shows a comparison of the Model Info block and the Source Control Information block.\n   <\/p>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/ModelImage.png\"> <\/p>\n<p>The Source Control Information block provides important information that the Model Info block does not.  It shows the full file name of the model, not just the model name.  In addition, it shows the name of the project that contains the model, the source control revision and if the file has been modified compared to the source control repository.\n   <\/p>\n<p>The Source Control Information block File Exchange entry includes several files.  There is an example script that shows using the Source Control Information block, a Simulink Library that contains the block, a slblocks.m file that if on the MATLAB path will place the library in the Simulink Library Browser, and the <tt>getSourceControlStatusExample<\/tt> function that retrieves the information to be displayed.\n   <\/p>\n<p>I believe this entry provides capabilites that Simulink users have wanted for quite some time.  I would like to see Gavin enhance this by adding a mask that would allow the user to customize the information displayed, similar to what the Model Info block provides.  I would also like to see an enhancement to allow the user to customize the content, or at least guidance<br \/>\n      on how to customize the block.  This would allow the user to merge the information available in the Model Info block with the Source Control Information block.\n   <\/p>\n<h3>Comments<a name=\"10\"><\/a><\/h3>\n<p>Give it a try and let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=8654#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/60373-source-control-information-block\">comment and\/or rating<\/a> for Gavin.\n   <\/p>\n<p><script language=\"JavaScript\">\n<!--\n\n    function grabCode_ba5cec60e4a64f60b74028ecb6074e08() {\n        \/\/ Remember the title so we can use it in the new page\n        title = document.title;\n\n        \/\/ Break up these strings so that their presence\n        \/\/ in the Javascript doesn't mess up the search for\n        \/\/ the MATLAB code.\n        t1='ba5cec60e4a64f60b74028ecb6074e08 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\n        t2='##### ' + 'SOURCE END' + ' #####' + ' ba5cec60e4a64f60b74028ecb6074e08';\n    \n        b=document.getElementsByTagName('body')[0];\n        i1=b.innerHTML.indexOf(t1)+t1.length;\n        i2=b.innerHTML.indexOf(t2);\n \n        code_string = b.innerHTML.substring(i1, i2);\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\n\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \n        \/\/ in the XML parser.\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\n        \/\/ doesn't go ahead and substitute the less-than character. \n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\n\n        author = 'Richard Ruff';\n        copyright = 'Copyright 2017 The MathWorks, Inc.';\n\n        w = window.open();\n        d = w.document;\n        d.write('\n\n<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\n\n\\n');\n      \n      d.title = title + ' (MATLAB code)';\n      d.close();\n      }   \n      \n-->\n<\/script><\/p>\n<p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><a href=\"javascript:grabCode_ba5cec60e4a64f60b74028ecb6074e08()\"><span style=\"font-size: x-small;        font-style: italic;\">Get<br \/>\n            the MATLAB code<br \/>\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><\/p>\n<p>      Published with MATLAB&reg; R2017a<\/p>\n<\/div>\n<p><!--\nba5cec60e4a64f60b74028ecb6074e08 ##### SOURCE BEGIN #####\n%% Including source control information in a Simulink model\n%\n% _Richard is Consulting Engineer at MathWorks focused on the Embedded\n% Coder product for code generation, primarily in the Aerospace industry._\n% \n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1016860-richard-ruff\n% Richard's> pick this week is\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/60373-source-control-information-block\n% Source Control Information Block> by\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/747266-gavin-walker\n% Gavin Walker>.\n% \n%% Pick\n% My pick this week is\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/60373-source-control-information-block\n% Source Control Information Block>.\n%\n% Shipping with Simulink is the Model Info block in the Simulink\/Model-Wide\n% Utilities library.  When placed in a model, this block allows the user to\n% show information about the model such as when it was created, who created\n% it, when was it modified, etc.  It also allows the user to show the Model\n% Version.  \n%%\n% \n% <<ModelInfoBlockOptions.png>>\n% \n\n%%\n% The problem with this is the Model Version is defined by the model's Model \n% Properties setting.  By default, this is 1.X, where X is incremented each\n% time the model is saved.  Opening the Model Propeties dialog and enabling\n% editing (uncheck the \"Read Only\" checkbox) you can see the command that\n% is used: 1.%<AutoIncrement:X>.  \n%%\n% \n% <<ModelPropertiesDialog.png>>\n% \n\n%%\n% While this can be useful information, it falls short in a practical\n% application where a Configuration Management tool such as SVN or Git is\n% used.  In this case, the Model Version most likely will not match the\n% version of the file in the repository.\n%\n% This is where this MATLAB File Exchange entry in conjunction with\n% Simulink Projects fills the gap.  <https:\/\/www.mathworks.com\/help\/releases\/R2017a\/simulink\/ug\/what-are-simulink-projects.html \n% Simulink Projects> helps the user organize their work.  In addition, \n% Simulink Projects works with <https:\/\/www.mathworks.com\/help\/releases\/R2017a\/simulink\/ug\/about-source-control-with-projects.html \n% Configuration Management tools> for source control of the various models\n% and files being used.  \n%\n% The Source Control Information Block leverages Simulink Projects\n% integration with source control tools to allow the user to show the\n% relevant information.  The screenshot below shows a comparison of the\n% Model Info block and the Source Control Information block.\n%%\n% \n% <<ModelImage.png>>\n% \n\n%%\n% The Source Control Information block provides important information that\n% the Model Info block does not.  It shows the full file name of the model,\n% not just the model name.  In addition, it shows the name of the project\n% that contains the model, the source control revision and if the file has\n% been modified compared to the source control repository.  \n\n%%\n% The Source Control Information block File Exchange entry includes several\n% files.  There is an example script that shows using the Source Control\n% Information block, a Simulink Library that contains the block, a\n% slblocks.m file that if on the MATLAB path will place the library in the\n% Simulink Library Browser, and the |getSourceControlStatusExample| function\n% that retrieves the information to be displayed.\n\n%% \n% I believe this entry provides capabilites that Simulink users have wanted\n% for quite some time.  I would like to see Gavin enhance this by adding a\n% mask that would allow the user to customize the information displayed,\n% similar to what the Model Info block provides.  I would also like to see\n% an enhancement to allow the user to customize the content, or at least\n% guidance on how to customize the block.  This would allow the user to\n% merge the information available in the Model Info block with the Source\n% Control Information block.\n\n%% Comments\n% \n% Give it a try and let us know what you think\n% <https:\/\/blogs.mathworks.com\/pick\/?p=8654#respond here> or leave a\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/60373-source-control-information-block\n% comment and\/or rating> for Gavin.\n%\n \n\n##### SOURCE END ##### ba5cec60e4a64f60b74028ecb6074e08\n--><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/ModelPropertiesDialog.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>Richard is Consulting Engineer at MathWorks focused on the Embedded Coder product for code generation, primarily in the Aerospace<br \/>\n            industry.<br \/>\nRichard&#8217;s pick this week is Source&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2017\/06\/23\/source-control-information-block\/\">read more >><\/a><\/p>\n","protected":false},"author":131,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16,24],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8654"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/131"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=8654"}],"version-history":[{"count":7,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8654\/revisions"}],"predecessor-version":[{"id":8668,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8654\/revisions\/8668"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=8654"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=8654"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=8654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}