Skip to Content
建立嵌入式系統--傑出軟體的設計模式
book

建立嵌入式系統--傑出軟體的設計模式

by Elecia White
October 2012
Intermediate to advanced
328 pages
7h 19m
Chinese
GoTop Information, Inc.
Content preview from 建立嵌入式系統--傑出軟體的設計模式
管理活動流程
|
117
NextState:
Current.Exit();
if (Current is Red) Current = Green;
if (Current is Yellow) Current = Red;
if (Current is Green) Current = Yellow;
Current.Enter();
}
系統不需要使用 switch 命令,能夠以相同的方式處理各種狀態,讓物件負責各種情況下
對應的工作。
表格驅動式狀態機
雖然流程圖與狀態圖對於理解狀態機十分方便,表格是另一種記錄與完整定義狀態機更
簡單的方式。
在圖 5-4 的範例表格中,每個狀態對應到一列,對應到一個動作與多個事件,動作欄說
明了該狀態應該發生的行為(也就是該顯示的燈光顏色),其他欄位則說明了系統處於該
列狀態,收到特定事件時該轉移的目標狀態。通常,轉移單單只要轉移到新的狀態(並
執行新狀態對應的動作)。
紅燈 紅燈 綠燈 紅燈 紅燈
黃燈 黃燈 紅燈 黃燈 紅燈
綠燈 綠燈 綠燈 黃燈 綠燈
狀態 動作 事件
目前狀態
「前進」事件
新的目前狀態
=
綠燈
表格資料狀態機引擎
燈色 前進 停止 時間到
5-4 以表格呈現的狀態機
過去開發某個兒童玩具時,系統包含超過 30 個的按鈕(字母、音量、控
制等等),像上圖中的表格幫助團隊找出流程圖中未處理的事件,即使某
些按鈕在特定狀態下不該有作用,使用者仍然可能按下這些按鈕,因此,
這樣的表格有助於實作與文件,對於玩具使用的設計上十分重要。
118
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

面向对象的思考过程(原书第5版)

面向对象的思考过程(原书第5版)

马特 魏斯费尔德
優雅的SciPy|Python科學研究的美學

優雅的SciPy|Python科學研究的美學

Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow

Publisher Resources

ISBN: 9789862765784