家伙在simu金宝applink上

金宝app基于模型的设计

总线对象和接口规格

A few recent comments on this blog have asked about bus objects. Blog readerKMR remarkedthat "bus objects are one of the most important parts of the whole bus concept: allowing you to lock down an interface." This week I introduce bus objects and how they can help avoid modeling errors.公交对象提供规格earlier post,我们看到虚拟总线信号不必包含有关其信号大小和数据类型的任何信息。该信息从图中的其他块(例如来源和港口)传播。这simplebusdemo.mdl不需要公交信号的规范,因为它是虚拟的。我们的公交信号的心理模型是一束彩虹色的电线,将源与目的地联系起来。我们经常将公共汽车称为信号包裹。simplebusdemo_diag.png如果您确实想锁定此总线的描述,则必须使用总线对象。如果公共汽车是彩虹彩色的电线,在我的心理模型中bus object电缆连接器at the end of that bundle. It defines all the pins and their exact configuration and asserts that only those types of signals may be connected. Check “Specify properties via bus object” and include the bus object name on the Bus Creator blocks to add the specification to your model. I’ll get to creating bus objects in the next section.与公交对象的公交创建者对话总线创建者使用总线对象进行错误检查。如果输入信号没有与总线对象中的元素相同的类型和尺寸,则simulink会出错。金宝app还有一个连接性诊断,可以检查总线对象中的元素名称不匹配。将诊断性转到警告或错误,以确保您的信号与块规范一致。制作公共汽车对象制作总线对象的最简单方法是直接来自您的图。金宝appsimulink.bus.createobject是一个函数,生成一个总线对象block you specify based on your diagram. Specify the bus creator or port that has the highest level in the hierarchy of the bus. Simulink.Bus.createObject recursively creates bus objects for buses that feed into the given block. For our example, the main_bus is specified by the simplebusdemo/Bus Creator (not Bus Creator1 or Bus Creator2).>> Simulink.Bus.createObject('simplebusdemo',,,,'simplebusdemo/Bus Creator');>>谁名称大小字节类属性ANS 1x1 272 struct Bus1 1x1 simulink.bus Bus2 1x1 simulin金宝appk.bus main_bus 1x1 simulink.bus.bus要查看总线对象,请使用BusEditor。(点击放大)MAIN_BUS的总线编辑器As of R2008a Simulink has a new bus editor, so unless you are using this release, your version will look different. The left pane shows all bus objects in the workspace. The selected node in the tree displays its children in the center pane, and on the right, you have the details for each selected element. The information about dimensions, datatype and signal name are all a part of the bus object. For hierarchical bus signals, the element datatype is the name of another bus. Looking at the main_bus, it has two signals, bus1 of type bus1, and bus2 of type bus2. The name and type do not have to match, but they do in this case. If you are happy with your bus objects, I recommend saving them to a MAT-file so you do not have to regenerate them every time. Some people prefer to generate an M-file and call that as part of their initialization routines, instead of loading the MAT-file. I have automatically generated this M-file during the call to Simulink.Bus.createObject. Given an output file name, Simulink.bus.createObject also outputs the code you need to make that bus object.>> Simulink.Bus.createObject('simplebusdemo',...'simplebusdemo/Bus Creator',,,,'SimpleBusdemo_busscript'); 行动中的公交规格如果我将常数输入信号更改为type type int8而不是Double Simulink,则在更新图(CTRL-D)期间会出现错误。金宝app
屏蔽“ SimpleBusdemo_bo_error/Bus creator1”的输入总线与Bus Object'Bus1'指定的总线与“ BUS1”在“块”对话框上不匹配。检测到以下错误:总线元素“常数”的“常数” BUS1'指定为数据类型'double',但传入信号具有“ INT8”的数据类型。
Bus creator with errorAs you can see, the bus object has locked down the specification for the signals fed into the bus creator. When something does not match Simulink reports an error.Bus objects can be specified on ports除了公共汽车的创建者外,还可以使用公交对象完全指定Inports和Outports。当在端口上使用总线对象时,您正在断言只有该端口的特殊类型的连接器。该端口可以是根级别的范围或外口,也可以是子系统上的端口。如果子系统在库中,则定义了其接口,并且库块的所有实例都必须匹配规范。带公交对象的外口对话框Getting back to the comment that “[bus objects] are one of the most important parts of the whole bus concept: allowing you to lock down an interface.” The concept of locking down an interface is important to developing reusable components as well as working with others on large modeling projects. This is a very powerful concept I have seen used in conjunction with an interface control document (ICD) to define the interface to a system. The document specifies the characteristics of the bus signals, and the bus object enforces that those characteristics are true. I have also seen a Simulink model specify the interface, with a script used to generate the ICD from the model. This makes the Simulink model the single source of truth. Your model will always be in sync with the specification if this is your workflow.Now it’s your turn您如何看待巴士对象?你使用它们吗?我仍然没有任何人自愿炫耀他们对模型的屏幕截图使用公交信号的使用。发表评论and then传一个电子邮件给我with the image. I will post it for you and we can all marvel at your work.
|
  • 打印
  • 发送电子邮件

评论

要发表评论,请单击这里登录您的数学帐户或创建一个新帐户。