QScxmlStateMachine¶
The
QScxmlStateMachineclass provides an interface to the state machines created from SCXML files. More…

Synopsis¶
Functions¶
def
activeStateNames([compress=true])def
cancelDelayedEvent(sendId)def
connectToEvent(scxmlEventSpec, receiver, method[, type=Qt.AutoConnection])def
connectToState(scxmlStateName, receiver, method[, type=Qt.AutoConnection])def
dataModel()def
initialValues()def
invokedServices()def
isActive(scxmlStateName)def
isActive(stateIndex)def
isDispatchableTarget(target)def
isInitialized()def
isInvoked()def
isRunning()def
loader()def
name()def
parseErrors()def
sessionId()def
setDataModel(model)def
setInitialValues(initialValues)def
setLoader(loader)def
setRunning(running)def
setTableData(tableData)def
stateNames([compress=true])def
submitEvent(event)def
submitEvent(eventName)def
submitEvent(eventName, data)def
tableData()
Slots¶
Signals¶
def
dataModelChanged(model)def
finished()def
initialValuesChanged(initialValues)def
initializedChanged(initialized)def
invokedServicesChanged(invokedServices)def
loaderChanged(loader)def
log(label, msg)def
reachedStableState()def
runningChanged(running)def
tableDataChanged(tableData)
Static functions¶
Detailed Description¶
QScxmlStateMachineis an implementation of the State Chart XML (SCXML) .All states that are defined in the SCXML file are accessible as properties of
QScxmlStateMachine. These properties are boolean values and indicate whether the state is active or inactive.Note
The
QScxmlStateMachineneeds aQEventLoopto work correctly. The event loop is used to implement thedelayattribute for events and to schedule the processing of a state machine when events are received from nested (or parent) state machines.
- class PySide2.QtScxml.QScxmlStateMachine(metaObject[, parent=None])¶
- Parameters:
parent –
PySide2.QtCore.QObjectmetaObject –
PySide2.QtCore.QMetaObject
- PySide2.QtScxml.QScxmlStateMachine.activeStateNames([compress=true])¶
- Parameters:
compress – bool
- Return type:
list of strings
Retrieves a list of state names of all active states.
When a state is active, all its parent states are active by definition. When
compressistrue(the default), the parent states will be filtered out and only the leaf states will be returned. When it isfalse, the full list of active states will be returned.
- PySide2.QtScxml.QScxmlStateMachine.cancelDelayedEvent(sendId)¶
- Parameters:
sendId – str
Cancels a delayed event with the specified
sendId.
- PySide2.QtScxml.QScxmlStateMachine.connectToEvent(scxmlEventSpec, receiver, method[, type=Qt.AutoConnection])¶
- Parameters:
scxmlEventSpec – str
receiver –
PySide2.QtCore.QObjectmethod – str
type –
ConnectionType
- Return type:
- PySide2.QtScxml.QScxmlStateMachine.connectToState(scxmlStateName, receiver, method[, type=Qt.AutoConnection])¶
- Parameters:
scxmlStateName – str
receiver –
PySide2.QtCore.QObjectmethod – str
type –
ConnectionType
- Return type:
- PySide2.QtScxml.QScxmlStateMachine.dataModel()¶
- Return type:
This property holds The data model to be used for this state machine..
SCXML data models are described in SCXML Specification - 5 Data Model and Data Manipulation . For more information about supported data models, see SCXML Compliance .
Changing the data model when the state machine has been
initializedis not specified in the SCXML standard and leads to undefined behavior.
- PySide2.QtScxml.QScxmlStateMachine.dataModelChanged(model)¶
- Parameters:
model –
PySide2.QtScxml.QScxmlDataModel
- PySide2.QtScxml.QScxmlStateMachine.finished()¶
- static PySide2.QtScxml.QScxmlStateMachine.fromData(data[, fileName=""])¶
- Parameters:
data –
PySide2.QtCore.QIODevicefileName – str
- Return type:
Creates a state machine by reading from the
QIODevicespecified bydata.This method will always return a state machine. If errors occur while reading the SCXML file,
fileName, the state machine cannot be started. The errors can be retrieved by calling theparseErrors()method.See also
- static PySide2.QtScxml.QScxmlStateMachine.fromFile(fileName)¶
- Parameters:
fileName – str
- Return type:
Creates a state machine from the SCXML file specified by
fileName.This method will always return a state machine. If errors occur while reading the SCXML file, the state machine cannot be started. The errors can be retrieved by calling the
parseErrors()method.See also
- PySide2.QtScxml.QScxmlStateMachine.init()¶
- Return type:
bool
Initializes the state machine.
State machine initialization consists of calling
setup(), setting the initial values for<data>elements, and executing any<script>tags of the<scxml>tag. The initial data values are taken from theinitialValuesproperty.Returns
falseif parse errors occur or if any of the initialization steps fail. Returnstrueotherwise.
- PySide2.QtScxml.QScxmlStateMachine.initialValues()¶
- Return type:
This property holds The initial values to be used for setting up the data model..
See also
- PySide2.QtScxml.QScxmlStateMachine.initialValuesChanged(initialValues)¶
- Parameters:
initialValues –
- PySide2.QtScxml.QScxmlStateMachine.initializedChanged(initialized)¶
- Parameters:
initialized – bool
- PySide2.QtScxml.QScxmlStateMachine.invokedServices()¶
- Return type:
This property holds A list of SCXML services that were invoked from the main state machine (possibly recursively)..
- PySide2.QtScxml.QScxmlStateMachine.invokedServicesChanged(invokedServices)¶
- Parameters:
invokedServices –
- PySide2.QtScxml.QScxmlStateMachine.isActive(scxmlStateName)¶
- Parameters:
scxmlStateName – str
- Return type:
bool
- PySide2.QtScxml.QScxmlStateMachine.isActive(stateIndex)
- Parameters:
stateIndex – int
- Return type:
bool
Returns
trueif the state with the IDstateIndexis active.This method is part of the interface to the compiled representation of SCXML state machines. It should only be used internally and by state machines compiled from SCXML documents.
- PySide2.QtScxml.QScxmlStateMachine.isDispatchableTarget(target)¶
- Parameters:
target – str
- Return type:
bool
Returns
trueif a message totargetcan be dispatched by this state machine.Valid targets are:
#_parentfor the parent state machine if the current state machine is started by<invoke>#_internalfor the current state machine#_scxml_sessionid, wheresessionidis the session ID of the current state machine#_servicename, whereservicenameis the ID or name of a service started with<invoke>by this state machine
- PySide2.QtScxml.QScxmlStateMachine.isInitialized()¶
- Return type:
bool
This property holds Whether the state machine has been initialized..
It is
trueif the state machine has been initialized,falseotherwise.See also
- PySide2.QtScxml.QScxmlStateMachine.isInvoked()¶
- Return type:
bool
This property holds Whether the state machine was invoked from an outer state machine..
truewhen the state machine was started as a service with the<invoke>element,falseotherwise.
- PySide2.QtScxml.QScxmlStateMachine.isRunning()¶
- Return type:
bool
This property holds the running state of this state machine.
See also
- PySide2.QtScxml.QScxmlStateMachine.loader()¶
- Return type:
This property holds The loader that is currently used to resolve and load URIs for the state machine..
- PySide2.QtScxml.QScxmlStateMachine.loaderChanged(loader)¶
- Parameters:
- PySide2.QtScxml.QScxmlStateMachine.log(label, msg)¶
- Parameters:
label – str
msg – str
- PySide2.QtScxml.QScxmlStateMachine.name()¶
- Return type:
str
This property holds The name of the state machine as set by the name attribute of the
<scxml>tag..
- PySide2.QtScxml.QScxmlStateMachine.parseErrors()¶
- Return type:
This property holds The list of parse errors that occurred while creating a state machine from an SCXML file..
- PySide2.QtScxml.QScxmlStateMachine.reachedStableState()¶
- PySide2.QtScxml.QScxmlStateMachine.runningChanged(running)¶
- Parameters:
running – bool
- PySide2.QtScxml.QScxmlStateMachine.sessionId()¶
- Return type:
str
This property holds The session ID of the current state machine..
The session ID is used for message routing between parent and child state machines. If a state machine is started by an
<invoke>element, any event it sends will have theinvokeidfield set to the session ID. The state machine will use the origin of an event (which is set by the target or targetexpr attribute in a<send>element) to dispatch messages to the correct child state machine.See also
- PySide2.QtScxml.QScxmlStateMachine.setDataModel(model)¶
- Parameters:
model –
PySide2.QtScxml.QScxmlDataModel
This property holds The data model to be used for this state machine..
SCXML data models are described in SCXML Specification - 5 Data Model and Data Manipulation . For more information about supported data models, see SCXML Compliance .
Changing the data model when the state machine has been
initializedis not specified in the SCXML standard and leads to undefined behavior.
- PySide2.QtScxml.QScxmlStateMachine.setInitialValues(initialValues)¶
- Parameters:
initialValues –
This property holds The initial values to be used for setting up the data model..
See also
- PySide2.QtScxml.QScxmlStateMachine.setLoader(loader)¶
- Parameters:
This property holds The loader that is currently used to resolve and load URIs for the state machine..
- PySide2.QtScxml.QScxmlStateMachine.setRunning(running)¶
- Parameters:
running – bool
This property holds the running state of this state machine.
See also
- PySide2.QtScxml.QScxmlStateMachine.setTableData(tableData)¶
- Parameters:
tableData –
PySide2.QtScxml.QScxmlTableData
This property holds The table data that is used when generating C++ from an SCXML file..
The class implementing the state machine will use this property to assign the generated table data. The state machine does not assume ownership of the table data.
- PySide2.QtScxml.QScxmlStateMachine.start()¶
Starts this state machine. The machine will reset its configuration and transition to the initial state. When a final top-level state is entered, the machine will emit the
finished()signal.Note
A state machine will not run without a running event loop, such as the main application event loop started with
exec()orexec().See also
- PySide2.QtScxml.QScxmlStateMachine.stateNames([compress=true])¶
- Parameters:
compress – bool
- Return type:
list of strings
Retrieves a list of state names of all states.
When
compressistrue(the default), the states that contain child states will be filtered out and only the leaf states will be returned. When it isfalse, the full list of all states will be returned.The returned list does not contain the states of possible nested state machines.
Note
The order of the state names in the list is the order in which the states occurred in the SCXML document.
- PySide2.QtScxml.QScxmlStateMachine.stop()¶
Stops this state machine. The machine will not execute any further state transitions. Its
runningproperty is set tofalse.See also
- PySide2.QtScxml.QScxmlStateMachine.submitEvent(event)¶
- Parameters:
event –
PySide2.QtScxml.QScxmlEvent
Submits the SCXML event
eventto the internal or external event queue depending on the priority of the event.When a delay is set, the event will be queued for delivery after the timeout has passed. The state machine takes ownership of
eventand deletes it after processing.
- PySide2.QtScxml.QScxmlStateMachine.submitEvent(eventName)
- Parameters:
eventName – str
- PySide2.QtScxml.QScxmlStateMachine.submitEvent(eventName, data)
- Parameters:
eventName – str
data – object
A utility method to create and submit an external event with the specified
eventNameas the name anddataas the payload data.
- PySide2.QtScxml.QScxmlStateMachine.tableData()¶
- Return type:
This property holds The table data that is used when generating C++ from an SCXML file..
The class implementing the state machine will use this property to assign the generated table data. The state machine does not assume ownership of the table data.
- PySide2.QtScxml.QScxmlStateMachine.tableDataChanged(tableData)¶
- Parameters:
tableData –
PySide2.QtScxml.QScxmlTableData
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.