DDD领域驱动设计批评文集>>《软件方法》强化自测题集>>《软件方法》各章合集>>本文只提供字幕文件!步骤1:在SparxSystems官网下载教学视频和案例模型https://sparxsystems.com/resources/webinar/release/ea152/simulation/matlab/introduction/matlab-digital.mp4https://sparxsystems.com/resources/webinar/release/ea152/simulation/matlab/introduction/matlab-digital.feaphttps://sparxsystems.com/resources/webinar/release/ea152/simulation/matlab/introduction/index.html步骤2:在UMLChina下载字幕文件 http://www.umlchina.com/tools/matlab-digital.srt字幕文件内容由UMLChina记录并翻译步骤3: 把字幕文件matlab-digital.srt和视频文件matlab-digital.mp4放在同一文件夹下步骤4:用支持字幕的播放器播放视频,例如VLC Player,不要用Windows自带的播放器。000:00:00,010 --> 00:00:00,462Hello<br>大家好 100:00:00,462 --> 00:00:02,951this is Dermot O'Bryan from SparxSystems<br>我是SparxSystems的Dermot O'Bryan 200:00:02,951 --> 00:00:04,308in this demonstration<br>在这个演示中【本中英字幕由UMLChina整理翻译】 300:00:04,308 --> 00:00:10,870we will run over using the latest SysML options for simulating a digital electronic example in Simulink.<br>我们演示使用最新的SysML选项来仿真一个Simulink中的数字电路的例子。 400:00:11,210 --> 00:00:18,612We'll use the new SysPhS modeling to reference components that are defined in Simulink. <br>我们将使用新的SysPhS建模来引用Simulink中已定义的组件。 500:00:18,612 --> 00:00:23,136For a quick overview of this topic, we'll firstly have a broad look at setting up a digital model for Simulink, <br>为了快速了解本主题的概要,我们首先大致看看如何为Simulink设置一个数字模型, 600:00:23,136 --> 00:00:28,894then we'll look at using SysPhS patterns for creating predefined Simulink blocks. <br>然后使用SysPhS模式来创建预定义的Simulink块。 700:00:28,894 --> 00:00:31,567In this exercise, we will use some predefined Simulink components, <br>在这个练习中,我们将使用一些预定义的Simulink组件, 800:00:31,567 --> 00:00:37,325 so we'll look at how to model complex Simulink components in Enterprise Architect using SysPhS, <br>因此,我们会看看如何在Enterprise Architect使用SysPhS建模复杂的Simulink组件。 900:00:37,325 --> 00:00:41,437then we will generate our Simulink model and run a simulation from this, <br>然后,我们生成Simulink模型,运行它的仿真, 1000:00:41,437 --> 00:00:42,054and finally<br>最后 1100:00:42,054 --> 00:00:46,990we're looking to options for debugging any issue in the generated Simulink script <br>我们来看看调试所生成的Simulink脚本中问题的选项。 1200:00:47,420 --> 00:00:48,295for this example<br>本例中 1300:00:48,295 --> 00:00:52,014we are modeling a simple binary counter using flip flops<br>我们建模一个使用触发器的简单的二进制计数器 1400:00:52,014 --> 00:00:56,828but we will use it to provide a number of divisions of a clock frequency<br>但我们用它来提供时钟分频 1500:00:56,828 --> 00:00:59,891this type of frequency division was common inside<br>通俗一点说,这种类型的分频 1600:00:59,891 --> 00:01:06,236an early microprocessor where we had options for setting fast and slow clock speeds for the processor<br>在早期的微处理器很常见,可以用于设置处理器的时钟速度快慢 1700:01:06,236 --> 00:01:16,300so all we use is a digital square wave clock as an input and see how in our simulation in Simulink. <br>因此,我们使用一个数字方波时钟作为输入,看看Simulink中的仿真。 1800:01:16,300 --> 00:01:18,270the frequency output from each of the flip flops in the series hieressing the initial clock frequency <br>序列中每个触发器频率输出继承初始的时钟频率 1900:01:18,810 --> 00:01:21,810before we start creating diagrams and elements<br>在开始创建图形和元素之前 2000:01:21,810 --> 00:01:22,810we first of all<br>我们首先 2100:01:22,810 --> 00:01:24,610set our perspective to SysML <br>设置SysML的perspective 2200:01:25,020 --> 00:01:32,950this opens the model wizard. from this we can access some SysPhS foundation packages that we need to reference in the model <br>这里打开建模指南。从这里,我们可以访问一些需要在模型中引用的SysPhS基础包 2300:01:33,970 --> 00:01:36,820it is best to create a package to hold both<br>最好创建一个包来容纳它们 2400:01:37,120 --> 00:01:41,114Then select SysPhS and load the two libraries into the package in the browser <br>然后选择SysPhS,加载两个库到项目浏览器中的包 2500:01:41,114 --> 00:01:41,780 2600:01:42,900 --> 00:01:45,480now let's create a block definition diagram <br>现在,创建一个块定义图 2700:01:49,320 --> 00:01:54,223for the simulation we need to set up a reference to the SysPhS library<br>为了仿真,需要设置到SysPhS库的引用 2800:01:54,223 --> 00:01:57,410so we drag this library package onto the diagram <br>因此,把这个库的包拖到图上【本中英字幕由UMLChina整理翻译】 2900:01:57,770 --> 00:02:02,630we first set the package boundary on the block definition diagram to selectable <br>我们首先设置块定义图的包边界为selectable 3000:02:05,380 --> 00:02:07,610then from the package toolbox <br>然后,从包的工具箱 3100:02:08,720 --> 00:02:13,260we can create an import connector to reference the SysPhS packages <br>我们可以创建一个import连接器来引用该SysPhS包 3200:02:18,450 --> 00:02:20,684in terms of blocks for our model<br>针对模型中的块 3300:02:20,684 --> 00:02:22,696let's start with a simplest<br>我们先从最简单的开始 3400:02:22,696 --> 00:02:28,730there is a SysPhS block for a Simulink constant that we use for setting a logical true state <br>这是一个SysPhS块,表达一个用于设置逻辑真状态的Simulink常数 3500:02:29,010 --> 00:02:31,670this can be accessed from the SysPhS patterns <br>这可以从SysPhS模式访问 3600:02:37,860 --> 00:02:41,070And the Sources and sinks, and the Constant <br>选Sources and sinks和Constant 3700:02:46,500 --> 00:02:51,050now all we want is a logical clock to get a digital pulse signal <br>现在我们需要一个逻辑时钟,以获得一个数字脉冲信号 3800:02:51,560 --> 00:02:55,860we select the SysPhS toolbox and drag on a Simulink Block <br>我们选择SysPhS工具箱,拖上来一个Simulink Block 3900:02:57,230 --> 00:03:00,090then we need to create another block for our flip flop <br>然后,需要为触发器创建另一个块 4000:03:05,360 --> 00:03:08,740All we want is a reference to a Simulink digital clock <br>需要引用到Simulink的数字时钟 4100:03:09,020 --> 00:03:12,770so let's get the correct Simulink path for a digital clock <br>因此,先要取得正确的Simulink数字时钟路径 4200:03:13,130 --> 00:03:15,470this being a Simulink component<br>既然这是一个Simulink组件 4300:03:15,470 --> 00:03:18,280we find it in the Simulink Library Browser <br>可以在Simulink Library Browser里找 4400:03:18,590 --> 00:03:22,224you can see this under the Simulink Extras/Flip Flops <br>在Simulink Extras/Flip Flops下面 4500:03:22,224 --> 00:03:22,830 4600:03:23,570 --> 00:03:27,371we open the parameters dialogue and work out the path<br>打开参数对话框,找到其路径 4700:03:27,371 --> 00:03:30,630this can be accessed using CTRL+L <br>可以用CTRL+L来访问 4800:03:36,550 --> 00:03:37,515in this case<br>本例中 4900:03:37,515 --> 00:03:42,344it is simulink_extras/Flip Flops/Clock<br>就是simulink_extras/Flip Flops/Clock 5000:03:42,344 --> 00:03:43,310 5100:03:44,020 --> 00:03:47,450then we input that in the block in the SimulinkBlock name <br>然后我们把它输入到SimulinkBlock的名称中 5200:03:59,320 --> 00:04:04,302the earlier clock component that we need to use is also predefined in Simulink<br>之前需要使用的时钟组件也是在Simulink中预定义 5300:04:04,302 --> 00:04:05,797that is a flip flop<br>是一个触发器 5400:04:05,797 --> 00:04:06,296 5500:04:06,296 --> 00:04:08,040Again, we get the path from Simulink <br>一样,我们从Simulink获得路径 5600:04:08,450 --> 00:04:14,330replaces in the name field on the flip flop block under the hitting SimulinkBlock <br>替换当前所点击的SimulinkBlock的名称栏 5700:04:20,820 --> 00:04:28,435the Simulink digital clock has one key parameter that we need to define as a PhS constant on the block<br> Simulink数字时钟有一个关键参数,我们需要定义为块上的PhS常数 5800:04:28,435 --> 00:04:30,720this is period and it's of type time<br>该参数是时间周期,类型是时间 5900:04:30,720 --> 00:04:32,750which is in seconds<br>以秒为单位 6000:04:32,750 --> 00:04:34,781for this, we drag from the SysPhS toolbox a Simulink Parameter<br>因此,我们从SysPhS工具箱拖上来一个Simulink Parameter 6100:04:34,781 --> 00:04:36,558 6200:04:36,558 --> 00:04:37,320we name it Period<br>命名为Period 6300:04:41,360 --> 00:04:42,994for the Period's type which is time <br>因为Period的类型为时间 6400:04:42,994 --> 00:04:49,260use CTRL+L to set the classifier to Time in the SysPhS library <br>使用CTRL+L设置类元为SysPhS库中的Time 6500:04:55,320 --> 00:04:58,860for the time we can set this as a constant to 2<br>时间可以设置为一个常数2 6600:04:58,860 --> 00:04:59,618 6700:04:59,618 --> 00:05:00,630for example half a HZ<br>例如,半HZ 6800:05:00,630 --> 00:05:02,400a period of 2 seconds<br>2秒的周期 6900:05:02,400 --> 00:05:05,940the first second is true the next second false or 0 <br>第1秒为真,下一秒为假或0 7000:05:06,220 --> 00:05:08,178it also needs an output port<br>也需要一个输出端口 7100:05:08,178 --> 00:05:12,340this will need to be a port of type BooleanOutSignalElement <br>端口类型为BooleanOutSignalElement 7200:05:12,620 --> 00:05:16,030so we drag this from our package reference under the block <br>因此,我们从引用的包中把这个拖到块的下方 7300:05:21,690 --> 00:05:23,760then we name it as y <br>命名为y 7400:05:26,990 --> 00:05:36,568for the flip flop in Simulink, it has ports J K Q and CLK, so we need to set them up. <br> Simulink中的触发器有端口J、K、Q和CLK,因此我们需要设置它们 7500:05:36,568 --> 00:05:42,617note that these are Simulink components. these differ to the Modelica code world in that these ports are not identified by a name<br>注意,这是Simulink组件,和Modelica的代码有所不同,这些端口不是通过名称来标识 7600:05:42,617 --> 00:05:45,390rather a simply referenced by an array <br>而是通过array简单引用 7700:05:45,670 --> 00:05:56,632hence the ordering of the creation of these is critical. <br>the ordering in the Simulink array is from top to bottom for the inputs and top to bottom to the outputs<br>因此,创建的次序至关重要。Simulink array的次序,对输入是自顶而下,输出也是自顶而下 7800:05:56,632 --> 00:05:58,915so for your inputs to the J K flip flop<br>因此对于到J、K的输入 7900:05:58,915 --> 00:06:01,199it's critical that we start with J<br>要从J开始 8000:06:01,199 --> 00:06:01,884Then do CLK<br>然后是CLK 8100:06:01,884 --> 00:06:02,570then do K <br>然后是K 8200:06:02,950 --> 00:06:08,679these are nonetheless shown in alphabetical order on the block. <br>尽管在块上是以字母顺序显示。 8300:06:08,679 --> 00:06:14,000we drag on the input ports. This is a BooleanInSignal and then name them to match these ports on the Simulink component <br>我们拖上来BooleanInSignal输入端口,让它的命名匹配Simulink组件的端口 8400:06:48,180 --> 00:06:52,650then we do the same for output ports using BooleanOutSignal<br>同样,用BooleanOutSignal对输出端口做同样的事情 8500:06:52,930 --> 00:06:53,561 8600:06:53,561 --> 00:06:55,456Again, this is ordered by q<br>同样,顺序是q 8700:06:55,456 --> 00:06:56,720then qn <br>然后 qn 8800:07:19,760 --> 00:07:21,085in this section<br>在这一节 8900:07:21,085 --> 00:07:25,060we will create the main block that will contain the IBD diagram <br>我们将创建包含IBD图的块 9000:07:25,340 --> 00:07:30,830this new diagram is where we connect these ports as parts to form our flip flop counter <br>在这个新图中,我们把这些端口当成部件连接起来,形成触发器计数器 9100:07:31,420 --> 00:07:34,260now let's create a block for the binary counter <br>现在来创建二进制计数器的块 9200:07:34,940 --> 00:07:38,920then we created a child diagram on this block called Counter <br>然后在这个块上面创建一张子图,称为Counter 9300:07:45,340 --> 00:07:49,230on which we then drag on our blocks as components <br>然后把我们的块作为组件拖上去 9400:07:49,640 --> 00:07:50,176 9500:07:50,176 --> 00:07:54,470for this, it's recommended to use the all option in the Paste dialogue <br>为此,推荐在Paste对话框中使用all选项 9600:08:00,340 --> 00:08:02,570to display these in the compartments <br>为了以分栏方式显示 9700:08:02,850 --> 00:08:04,588we delete the properties<br>我们删除属性 9800:08:04,588 --> 00:08:07,320the first is the clock period property <br>首先是时钟周期属性 9900:08:08,080 --> 00:08:09,870to keep the diagram clear<br>为了保持图形清爽 10000:08:09,870 --> 00:08:15,914we order the diagram properties to not show the port classifiers and the property types<br>我们设置图形的属性为不显示端口的类元和属性的类型 10100:08:15,914 --> 00:08:18,600this gives a simpler view of just the port name <br>只保留端口名称,看起来更简洁 10200:08:25,150 --> 00:08:26,717for our Constant part<br>对于Constant部件 10300:08:26,717 --> 00:08:31,420this needs to pass a logical 1 or true state to our j and k port <br>需要传送一个逻辑1或真给j和k端口 10400:08:31,940 --> 00:08:34,490we will set an appropriate name for this <br>给这个起一个恰当的名字 10500:08:34,890 --> 00:08:34,891 10600:08:34,891 --> 00:08:37,600we also give the clock a more meaningful name <br>也给时钟一个更有意义的名字 10700:08:42,370 --> 00:08:45,400Then we create four parts of time flip flop <br>然后,创建4个时间触发器部件 10800:09:00,790 --> 00:09:04,500let's name these as Flip Flop 1 to 4 <br>命名为Flip Flop 1到4 10900:09:14,510 --> 00:09:16,320now we reorganize the ports<br>现在,重新组织端口 11000:09:16,320 --> 00:09:18,810placing the outgoing ports on the right <br>把输出端口放在右侧 11100:09:25,130 --> 00:09:30,687then we need to set our connectors between the relevant ports to fit our proposed model<br>然后我们需要设置相关端口之间的连接器,以匹配我们的模型 11200:09:30,687 --> 00:09:35,390the first is from the Clck output to the clock port on the first flip flop <br>第一个,从Clck输出到第一个触发器的时钟端口 11300:09:35,670 --> 00:09:41,510the subsequent flip flops are connected from the q to the proceeding clock import <br>随后的触发器从q连接到后续的时钟输入 11400:09:44,640 --> 00:09:51,330then we set the j and k ports to true by connecting this to the BoolTrue part <br>然后,通过把这个连接到BoolTrue部件,我们设置j和k端口为真 11500:10:00,730 --> 00:10:01,072OK 11600:10:01,072 --> 00:10:03,810that completes our IBD setup <br>这样就完成了IBD的设置 11700:10:04,480 --> 00:10:06,810let's now configure our simulation <br>现在来配置仿真 11800:10:07,090 --> 00:10:09,903we go back to the block definition diagram<br>回到块定义图 11900:10:09,903 --> 00:10:13,890we see that we have a Counter block populated with the new parts <br>我们看到,Counter块添加了新的部件 12000:10:14,260 --> 00:10:15,428 12100:10:15,428 --> 00:10:19,870for the simulation, we start by creating an artifact of type SysMLSim Configuration <br>首先,创建一个artifact,类型为SysMLSim Configuration 12200:10:20,390 --> 00:10:24,440double clicking on this opens up the simulation configuration <br>双击这个,打开仿真配置 12300:10:25,200 --> 00:10:26,280on opening this<br>打开这个 12400:10:26,280 --> 00:10:29,250we firstly select the package to simulate <br>首先选择要仿真的包 12500:10:31,770 --> 00:10:34,600ensure the Simulink library is referenced <br>确保Simulink库已被引用【本中英字幕由UMLChina整理翻译】 12600:10:35,600 --> 00:10:41,650set the parent block for the SysML model that we're simulating, in this case is the counter block <br>设置正在仿真的SysML模型(本例为Counter块)的父块 12700:10:41,930 --> 00:10:44,800we set this a SysMLSimModel <br>把这个设为SysMLSimModel 12800:10:45,460 --> 00:10:51,570now we see the list of properties available to plot, so we can select which of these we want to use <br>现在可以看到可用于绘图的属性列表,我们可以选择要用到的 12900:10:59,110 --> 00:11:01,240now we can run the simulation <br>现在运行仿真 13000:11:01,560 --> 00:11:03,810the plot in Simulink is complex <br> Simulink的图很复杂 13100:11:04,710 --> 00:11:06,950so let's simplify this <br>我们来简化一下 13200:11:07,230 --> 00:11:10,657in order to open the generated model in Simulink<br>为了在Simulink中打开所生成模型 13300:11:10,657 --> 00:11:11,800 13400:11:11,800 --> 00:11:12,485 13500:11:12,485 --> 00:11:13,400we access the EA generator and select file <br>我们访问EA生成器,选择文件 13600:11:19,200 --> 00:11:22,862here we can see the component that we created in the SysML model<br>这里我们可以看到在SysML模型中创建的组件 13700:11:22,862 --> 00:11:23,293 13800:11:23,293 --> 00:11:23,508 13900:11:23,508 --> 00:11:23,939 14000:11:23,939 --> 00:11:28,463is shown in the Simulink format along with the connectivity that we set up in our SysML model<br>以及我们在SysML模型中设置的连接,以Simulink格式展示 14100:11:28,463 --> 00:11:28,894 14200:11:28,894 --> 00:11:29,110 14300:11:29,590 --> 00:11:33,340we can run this and view the plot and change all we want to view <br>我们可以运行这个,查看图表,改变想看的内容 14400:11:39,950 --> 00:11:42,750we start with the output of Flip Flop 1<br>从Flip Flop 1的输出开始 14500:11:43,030 --> 00:11:45,001then select the last output<br>然后选择最后一个输出 14600:11:45,001 --> 00:11:46,410which is q 4 <br>即q 4 14700:11:47,170 --> 00:11:48,638with each q enabled<br>对于每个有效的q 14800:11:48,638 --> 00:11:54,270we see the simulation of the clock frequency being heard for each flip flop that is passed through <br>我们看到仿真,时钟频率被每个所通过的触发器接收到 14900:12:00,960 --> 00:12:03,041when doing a complex SysML model<br>当做一个复杂的SysML模型时 15000:12:03,041 --> 00:12:06,070there are bound to be issues with generation of the plot <br>图表的生成多半会出现问题 15100:12:06,400 --> 00:12:07,259so on that note<br>因此,这个地方 15200:12:07,259 --> 00:12:12,415let's have a look at the debugging an issue resolution when generating the Simulink<br>我们来看看如何调试并解决生成Simulink时出现的问题 15300:12:12,415 --> 00:12:12,630 15400:12:12,980 --> 00:12:13,460firstly<br>首先 15500:12:13,460 --> 00:12:14,902we set up an error<br>我们设置一个错误 15600:12:14,902 --> 00:12:19,710we do this by sending our wrong connectors to the block not to the port <br>我们把连接器连向块,而不是端口 15700:12:28,630 --> 00:12:28,863now<br>现在 15800:12:28,863 --> 00:12:30,500when we run the simulation<br>我们运行仿真时 15900:12:30,500 --> 00:12:34,240we can see that there is an error created in the code build, this is viewed in the System Output. <br>可以看到,构建代码时有一个错误,可以在System Output那里查看 16000:12:35,060 --> 00:12:38,919if we go to the SysML Simulation in the System Output <br> 如果我们去往System Output中的SysML Simulation 16100:12:38,919 --> 00:12:39,600 16200:12:39,600 --> 00:12:39,827 16300:12:39,827 --> 00:12:40,962 16400:12:40,962 --> 00:12:43,460we see the error that it is generated <br>可以看到生成的错误 16500:12:43,820 --> 00:12:45,447we double click on this<br>双击这个 16600:12:45,447 --> 00:12:49,110it opens a configuration at the port where the issue occurred <br>打开一个发生问题的端口的配置 16700:12:49,440 --> 00:12:50,225in this case<br>本例中 16800:12:50,225 --> 00:12:54,150we see that the clock is the part where the issue is <br>Clock是出问题的部件 16900:12:55,010 --> 00:13:00,370an alternative issue checking method is to open the generator script file directly in Simulink <br>另一个检查问题的方法是,直接在Simulink中打开生成器脚本文件 17000:13:03,960 --> 00:13:06,770then view the diagram and check the connection <br>然后观察图形,检查连接 17100:13:07,160 --> 00:13:13,540then you can run the simulation and view the error and see there is a connector issue <br>然后,运行仿真,观察错误,可以看到是连接器问题 17200:13:20,970 --> 00:13:22,267given this feedback<br>得到了这个反馈 17300:13:22,267 --> 00:13:25,080we can now do a simple correction of the model <br>就可以对模型做简单的修正 17400:13:36,660 --> 00:13:36,906OK 17500:13:36,906 --> 00:13:38,137 17600:13:38,137 --> 00:13:41,830so in conclusion, let's run over what we have covered in this demonstration <br>最后,归纳一下本演示的内容 17700:13:42,110 --> 00:13:50,520this includes setting up a digital logical model of Simulink by using SysPhS patterns for creating predefined Simulink blocks <br>包括:通过使用创建预定义Simulink块的SysPhS模式,来设置Simulink数字逻辑模型 17800:13:51,360 --> 00:13:55,180modeling other complex Simulink components using SysPhS <br>使用SysPhS建模其他复杂Simulink组件 17900:13:55,500 --> 00:14:05,550generating a Simulink model then simulating and viewing this in Simulink. <br>running over how to debug an issue and viewing the generated model in Simulink. <br>生成Simulink模型,仿真,在Simulink中查看,调试问题,<br>在Simulink中查看所生成模型 18000:14:06,270 --> 00:14:09,817although we have focused on using MATLAB Simulink<br>虽然我们聚焦于MATLAB Simulink 18100:14:09,817 --> 00:14:15,020please note that a Simulink scenario can be replicated using SysPhS for Modelica <br>但是,使用SysPhS for Modelica,Simulink的场景也可以照搬到Modelica 18200:14:15,920 --> 00:14:23,350hopefully this gives you a good starting point for getting familiar with the integration and simulation with MATLAB Simulink <br>希望这个演示能作为你熟悉与MATLAB Simulink集成和仿真的一个好起点 18300:14:23,630 --> 00:14:26,942this is all being part of the new SysML SysPhS features available in the Enterprise Architect 15.2<br>这都是Enterprise Architect 15.2新的SysML SysPhS特性的一部分 18400:14:26,942 --> 00:14:27,218 18500:14:27,218 --> 00:14:28,047 18600:14:28,047 --> 00:14:28,875 18700:14:28,875 --> 00:14:39,090for more information on this, see sparxsystems.com/ea152<br>更多信息,参见sparxsystems.com/ea152【本中英字幕由UMLChina整理翻译】[19:30上课]11月7-11月11日晚剔除伪创新的领域驱动设计-网络公开课 [19:30上课]11月14-18晚软件需求设计方法学全程实例剖析网课 [新增架构师专用集锦AD-001]28套UML+EA和StarUML的建模示范视频-全程字幕(20221006更新) 《软件方法》书中自测题-题目全文+分卷自测(1-8章)16套111题《软件方法》强化自测题集110题CTO也糊涂的常用术语:功能模块、业务架构、用户需求……[20210217更新]如何选择UMLChina服务作者微信:umlchina2