Main Content

状态和转移的语法

通过使用动作和条件来表达图行为

通过指定状态转移时间以及动作执行时间来控制 Stateflow® 图的执行。通过广播事件同步状态执行。检测数据值的变化,并检查在图执行期间有哪些状态为活动状态。

模块

全部展开

Chart用有限状态机实现控制逻辑
State Transition TableRepresent modal logic in tabular format
Truth TableRepresent logical decision-making behavior with conditions, decisions, and actions

Stateflow 语法

全部展开

更改检测

hasChanged检测自上一时间步以来的数据更改
hasChangedFrom检测从指定值以来的数据变化
hasChangedTo检测到指定值时的数据变化
change当数据更改值时生成隐式事件

边沿检测

crossing检测自上一时间步以来数据中的上升沿或下降沿
fallingDetect falling edge in data since last time step
rising检测自上一时间步以来数据中的上升沿

消息活动

sendBroadcast message or event
receiveExtract message from queue
discardDiscard message
forward转发消息
isvalidDetermine if message is valid
lengthDetermine length of message queue

状态活动

in检查状态活动
enter当状态变为激活时生成隐式事件
exit当状态变为非激活时生成隐式事件

数据类型转换

booleanConvert numeric value to Boolean value
ascii2str将类型为 uint8 的数组转换为字符串
str2ascii将字符串转换为 uint8 类型的数组
str2double将字符串转换为双精度值
string将值转换为字符串
tostring将值转换为字符串
typeType of Stateflow data object

字符串创建和串联

blanksCharacter array of spaces
plusConcatenate strings
strcpy字符串赋值
strcat串联字符串

字符串数据的属性

isletterDetermine which characters are letters
isspaceDetermine which characters are spaces
isstringDetermine if input is string
strlen确定字符串的长度
strlengthDetermine length of string

查找和替换子字符串

containsDetermine if string contains substring
startsWithDetermine if string starts with substring
endsWithDetermine if string ends with substring
strfindFind substring within a string
extractAfterExtract substring after position
extractBeforeExtract substring before position
substr从字符串中提取子字符串
replaceFind and replace substrings
replaceBetweenReplace substrings between start and end points
strrepFind and replace substrings
eraseDelete substrings within strings
eraseBetweenDelete substring between start and end points
insertAfterInsert string after substring
insertBeforeInsert string before substring

编辑字符串数据

lowerConvert string to lowercase
upperConvert a string to uppercase
reverseReverse order of characters in strings
stripRemove leading and trailing characters from string
strtrimRemove leading and trailing white space from string

比较字符串数据

matchesDetermine if two strings match
strcmpCompare strings (case sensitive)
strcmpiCompare strings (case insensitive)
strncmpCompare first N characters of strings (case sensitive)
strncmpiCompare first N characters of strings (case insensitive)

时序逻辑

after在事件广播或指定时间后执行图
at在事件广播时或指定时间执行图
before在事件广播或指定时间之前执行图
every按固定间隔执行图
duration条件有效期间的时间长度
elapsed自状态激活以来的时间
count条件有效期间的图执行次数
temporalCount事件数、图执行次数或自状态激活以来的时间

主题