Messages in State Machines
Messages are useful for modeling asynchronous operations in state machines. This example has two key components: a sender and a receiver. The sender chart generates messages at random intervals, which are queued and processed by the receiver at a different rate.
The sender component generates messages in the state Create_and_Send. Messages can also carry data, which can be used to make decisions or perform actions. These generated messages are transmitted through message lines in Simulink®. and held in a queue at the input of the receiver. The receiver starts in the ready state. It checks to see if a message exists in its queue. Once a message is available, it goes from ready to processing. The receiver stays in the processing state for a fixed period before going back to ready.
There are a couple of points to note: a message gets destroyed after it is used. So after a message has been used in a transition, the top message in the queue stays valid till the end of the time step, and then gets destroyed. The next time this transition is evaluated, it will check if a new message exists in the queue. The receiver chart also shows an example of how to use message data to perform an action.
In this example, the receiver processes messages when it is ready, which can be asynchronous with respect to the sender. To visualize the life of a message, use the message viewer block from the Stateflow® block library.
Published: 31 Aug 2015
Featured Product
Stateflow
Up Next:
Related Videos:
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)