{"id":6056,"date":"2015-06-19T09:00:19","date_gmt":"2015-06-19T13:00:19","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=6056"},"modified":"2015-06-18T08:38:09","modified_gmt":"2015-06-18T12:38:09","slug":"bus-object-bus-creator","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2015\/06\/19\/bus-object-bus-creator\/","title":{"rendered":"Bus Object Bus Creator"},"content":{"rendered":"\r\n\r\n<div class=\"content\"><p>Posted by <b>Richard Ruff<\/b> , June 19, 2015<\/p><p><em>Richard is an Application Engineer at MathWorks focused on the Embedded Coder product for code generation, primarily in the Aerospace industry.<\/em><\/p><p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1016860-richard-ruff\">Richard's<\/a> pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/50601-bus-object-bus-creator\">Bus Object Bus Creator<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/5005973-landon-wagner\">Landon Wagner<\/a>.<\/p><p><b>Pick<\/b><\/p><p>My pick this week is the Simulink library submission for automatically populating the input signal names to a bus creator for a specified bus object: <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/50601-bus-object-bus-creator\">Bus Object Bus Creator<\/a>.<\/p><p>Do you use bus objects in your Simulink models?  Do you spend a lot of time configuring the Bus Creator to match the desired Bus Object?  If so, this File Exchange entry is for you.<\/p><p>The description from the entry sums up the benefits nicely:<\/p><p><em>When working with bus object types in a design in order to employ strongly \"typed\" IO the collection of signals into a busCreator associated with a defined bus object type is tedious. After choosing the \"Bus:\" type in the busCreator \"Output data type\" the native busCreator does no further favors for you - the user must know or look up how many signals are in the bus type they wish to employ and set \"Number of inputs\" accordingly. Worse yet, the user must name the individual signals going into the busCreator with the signal names defined in the bus object type. This tool's job is to do that favor for you. (Note that the tool itself is just a masked busCreator running some callback scripts so the inclusion of this tool does not overtly stick out in a design.) Details can be found in BOBCreadme.txt but essentially the tool's mask provides the user with candidate bus object types (From the workspace.) to choose from and upon selection and application of a bus object type the tool provides a busCreator with the necessary number of inputs and with those inputs populated with NAMED stubbed signal lines. These names match the BusElement names in the chosen bus object type. From these named stubbed lines the underlying busCreator inherits the names for \"Signals in the bus.\" Again, this saves the user with having to know these signal names and fill them out themselves.<\/em><\/p><p>A basic example is shown here.  Below is a list of the Bus Objects defined in the MATLAB Workspace.<\/p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Richard\/main_BusObjectBusCreator\/main_BusObjectBusCreator_01.png\" alt=\"\"> <p>Inspecting the \"GuidanceBus\" in the Bus Editor, we can see the elements of the bus object: \"Ve\", \"Xe\", etc.<\/p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Richard\/main_BusObjectBusCreator\/main_BusObjectBusCreator_02.png\" alt=\"\"> <p>Opening the \"BusObjectBusCreator\" library, we see it contains a single block.<\/p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Richard\/main_BusObjectBusCreator\/main_BusObjectBusCreator_03.png\" alt=\"\"> <p>Adding this block to a model and opening the dialog, we can select from the dropdown list of available bus objects.  Once we apply the selection, we can see the block is updated to reflect the selected bus object.  The number of input ports is altered to reflect the number of elements in the bus and the signals feeding the inputs are labeled to match the bus elements.<\/p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Richard\/main_BusObjectBusCreator\/main_BusObjectBusCreator_04.png\" alt=\"\"> <p><b>Comments<\/b><\/p><p>Give it a try and let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=6056#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/50601-bus-object-bus-creator#comments\">comment<\/a> for Landon.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_a41832a6cbb24773a57d816bcca1809a() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='a41832a6cbb24773a57d816bcca1809a ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' a41832a6cbb24773a57d816bcca1809a';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2015 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_a41832a6cbb24773a57d816bcca1809a()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2015a<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2015a<br><\/p><\/div><!--\r\na41832a6cbb24773a57d816bcca1809a ##### SOURCE BEGIN #####\r\n%%\r\n% Posted by *Richard Ruff* , June 19, 2015\r\n%\r\n% _Richard is an Application Engineer at MathWorks focused on the Embedded\r\n% Coder product for code generation, primarily in the Aerospace industry._\r\n% \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1016860-richard-ruff\r\n% Richard's> pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/50601-bus-object-bus-creator Bus Object Bus Creator> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/5005973-landon-wagner\r\n% Landon Wagner>.\r\n% \r\n% *Pick*\r\n%\r\n% My pick this week is the Simulink library submission for automatically \r\n% populating the input signal names to a bus creator for a specified bus object:\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/50601-bus-object-bus-creator\r\n% Bus Object Bus Creator>.\r\n%\r\n% Do you use bus objects in your Simulink models?  Do you spend a lot of\r\n% time configuring the Bus Creator to match the desired Bus Object?  If so,\r\n% this File Exchange entry is for you.\r\n%\r\n% The description from the entry sums up the benefits nicely:\r\n%\r\n% _When working with bus object types in a design in order to employ\r\n% strongly \"typed\" IO the collection of signals into a busCreator\r\n% associated with a defined bus object type is tedious. After choosing the\r\n% \"Bus:\" type in the busCreator \"Output data type\" the native busCreator\r\n% does no further favors for you - the user must know or look up how many\r\n% signals are in the bus type they wish to employ and set \"Number of\r\n% inputs\" accordingly. Worse yet, the user must name the individual signals\r\n% going into the busCreator with the signal names defined in the bus object\r\n% type. This tool's job is to do that favor for you. (Note that the tool\r\n% itself is just a masked busCreator running some callback scripts so the\r\n% inclusion of this tool does not overtly stick out in a design.) Details\r\n% can be found in BOBCreadme.txt but essentially the tool's mask provides\r\n% the user with candidate bus object types (From the workspace.) to choose\r\n% from and upon selection and application of a bus object type the tool\r\n% provides a busCreator with the necessary number of inputs and with those\r\n% inputs populated with NAMED stubbed signal lines. These names match the\r\n% BusElement names in the chosen bus object type. From these named stubbed\r\n% lines the underlying busCreator inherits the names for \"Signals in the\r\n% bus.\" Again, this saves the user with having to know these signal names\r\n% and fill them out themselves._\r\n%\r\n% A basic example is shown here.  Below is a list of the Bus Objects\r\n% defined in the MATLAB Workspace.\r\n\r\nimshow('BusObjectBusCreator\\BusObjectList.png');\r\n\r\n%%\r\n% Inspecting the \"GuidanceBus\" in the Bus Editor, we can see the elements\r\n% of the bus object: \"Ve\", \"Xe\", etc.\r\n\r\nimshow('BusObjectBusCreator\\BusEditor.png');\r\n\r\n%%\r\n% Opening the \"BusObjectBusCreator\" library, we see it contains a single\r\n% block.  \r\n\r\nimshow('BusObjectBusCreator\\BusObjectBusCreatorLibrary.png');\r\n\r\n%%\r\n% Adding this block to a model and opening the dialog, we can select from\r\n% the dropdown list of available bus objects.  Once we apply the selection,\r\n% we can see the block is updated to reflect the selected bus object.  The\r\n% number of input ports is altered to reflect the number of elements in the\r\n% bus and the signals feeding the inputs are labeled to match the bus\r\n% elements.\r\n\r\nimshow('BusObjectBusCreator\\AutoConfiguredBusCreator.png');\r\n\r\n%%\r\n% *Comments*\r\n% \r\n% Give it a try and let us know what you think\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=6056#respond here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/50601-bus-object-bus-creator#comments\r\n% comment> for Landon.\r\n##### SOURCE END ##### a41832a6cbb24773a57d816bcca1809a\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Richard\/main_BusObjectBusCreator\/main_BusObjectBusCreator_01.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\n\r\nPosted by Richard Ruff , June 19, 2015Richard is an Application Engineer at MathWorks focused on the Embedded Coder product for code generation, primarily in the Aerospace industry.Richard's pick... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2015\/06\/19\/bus-object-bus-creator\/\">read more >><\/a><\/p>","protected":false},"author":36,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/6056"}],"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\/36"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=6056"}],"version-history":[{"count":4,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/6056\/revisions"}],"predecessor-version":[{"id":6060,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/6056\/revisions\/6060"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=6056"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=6056"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=6056"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}