QScxmlStateMachine

The QScxmlStateMachine class provides an interface to the state machines created from SCXML files. More

Inheritance diagram of PySide6.QtScxml.QScxmlStateMachine

Synopsis

Functions

Static functions

Detailed Description

QScxmlStateMachine is 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 QScxmlStateMachine needs a QEventLoop to work correctly. The event loop is used to implement the delay attribute for events and to schedule the processing of a state machine when events are received from nested (or parent) state machines.

class PySide6.QtScxml.QScxmlStateMachine(metaObject[, parent=None])
Parameters
PySide6.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 compress is true (the default), the parent states will be filtered out and only the leaf states will be returned. When it is false, the full list of active states will be returned.

PySide6.QtScxml.QScxmlStateMachine.cancelDelayedEvent(sendId)
Parameters

sendId – str

Cancels a delayed event with the specified sendId.

PySide6.QtScxml.QScxmlStateMachine.connectToEvent(scxmlEventSpec, receiver, method[, type=Qt.AutoConnection])
Parameters
Return type

PySide6.QtCore.QMetaObject.Connection

Creates a connection of the specified type from the event specified by scxmlEventSpec to the method in the receiver object. The receiver’s method may take a QScxmlEvent as a parameter. For example:

void mySlot(const QScxmlEvent &event);

In contrast to event specifications in SCXML documents, spaces are not allowed in the scxmlEventSpec here. In order to connect to multiple events with different prefixes, has to be called multiple times.

Returns a handle to the connection, which can be used later to disconnect.

PySide6.QtScxml.QScxmlStateMachine.connectToState(scxmlStateName, receiver, method[, type=Qt.AutoConnection])
Parameters
Return type

PySide6.QtCore.QMetaObject.Connection

Creates a connection of the given type from the state identified by scxmlStateName to the method in the receiver object. The receiver’s method may take a boolean argument that indicates whether the state connected became active or inactive. For example:

void mySlot(bool active);

Returns a handle to the connection, which can be used later to disconnect.

PySide6.QtScxml.QScxmlStateMachine.dataModel()
Return type

PySide6.QtScxml.QScxmlDataModel

Returns the data model used by the state machine.

See also

setDataModel()

PySide6.QtScxml.QScxmlStateMachine.dataModelChanged(model)
Parameters

modelPySide6.QtScxml.QScxmlDataModel

PySide6.QtScxml.QScxmlStateMachine.finished()
static PySide6.QtScxml.QScxmlStateMachine.fromData(data[, fileName=""])
Parameters
Return type

PySide6.QtScxml.QScxmlStateMachine

Creates a state machine by reading from the QIODevice specified by data.

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 the parseErrors() method.

See also

parseErrors()

static PySide6.QtScxml.QScxmlStateMachine.fromFile(fileName)
Parameters

fileName – str

Return type

PySide6.QtScxml.QScxmlStateMachine

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

parseErrors()

PySide6.QtScxml.QScxmlStateMachine.init()
Return type

bool

Initializes the state machine.

State machine initialization consists of calling , setting the initial values for <data> elements, and executing any <script> tags of the <scxml> tag. The initial data values are taken from the initialValues property.

Returns false if parse errors occur or if any of the initialization steps fail. Returns true otherwise.

PySide6.QtScxml.QScxmlStateMachine.initialValues()
Return type

PySide6.QtScxml.QScxmlStateMachine.initialValuesChanged(initialValues)
Parameters

initialValues

PySide6.QtScxml.QScxmlStateMachine.initializedChanged(initialized)
Parameters

initialized – bool

PySide6.QtScxml.QScxmlStateMachine.invokedServices()
Return type

PySide6.QtScxml.QScxmlStateMachine.invokedServicesChanged(invokedServices)
Parameters

invokedServices

PySide6.QtScxml.QScxmlStateMachine.isActive(scxmlStateName)
Parameters

scxmlStateName – str

Return type

bool

PySide6.QtScxml.QScxmlStateMachine.isActive(stateIndex)
Parameters

stateIndex – int

Return type

bool

Returns true if the state with the ID stateIndex is 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.

PySide6.QtScxml.QScxmlStateMachine.isDispatchableTarget(target)
Parameters

target – str

Return type

bool

Returns true if a message to target can be dispatched by this state machine.

Valid targets are:

  • #_parent for the parent state machine if the current state machine is started by <invoke>

  • #_internal for the current state machine

  • #_scxml_sessionid, where sessionid is the session ID of the current state machine

  • #_servicename, where servicename is the ID or name of a service started with <invoke> by this state machine

PySide6.QtScxml.QScxmlStateMachine.isInitialized()
Return type

bool

PySide6.QtScxml.QScxmlStateMachine.isInvoked()
Return type

bool

PySide6.QtScxml.QScxmlStateMachine.isRunning()
Return type

bool

Returns true if the state machine is running, false otherwise.

PySide6.QtScxml.QScxmlStateMachine.loader()
Return type

PySide6.QtScxml.QScxmlCompiler.Loader

See also

setLoader()

PySide6.QtScxml.QScxmlStateMachine.loaderChanged(loader)
Parameters

loaderPySide6.QtScxml.QScxmlCompiler.Loader

PySide6.QtScxml.QScxmlStateMachine.log(label, msg)
Parameters
  • label – str

  • msg – str

PySide6.QtScxml.QScxmlStateMachine.name()
Return type

str

PySide6.QtScxml.QScxmlStateMachine.parseErrors()
Return type

PySide6.QtScxml.QScxmlStateMachine.reachedStableState()
PySide6.QtScxml.QScxmlStateMachine.runningChanged(running)
Parameters

running – bool

PySide6.QtScxml.QScxmlStateMachine.sessionId()
Return type

str

PySide6.QtScxml.QScxmlStateMachine.setDataModel(model)
Parameters

modelPySide6.QtScxml.QScxmlDataModel

Sets the data model for this state machine to model. There is a 1:1 relation between state machines and models. After setting the model once you cannot change it anymore. Any further attempts to set the model using this method will be ignored.

See also

dataModel()

PySide6.QtScxml.QScxmlStateMachine.setInitialValues(initialValues)
Parameters

initialValues

See also

initialValues()

PySide6.QtScxml.QScxmlStateMachine.setLoader(loader)
Parameters

loaderPySide6.QtScxml.QScxmlCompiler.Loader

See also

loader()

PySide6.QtScxml.QScxmlStateMachine.setRunning(running)
Parameters

running – bool

Starts the state machine if running is true, or stops it otherwise.

PySide6.QtScxml.QScxmlStateMachine.setTableData(tableData)
Parameters

tableDataPySide6.QtScxml.QScxmlTableData

See also

tableData()

PySide6.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 signal.

Note

A state machine will not run without a running event loop, such as the main application event loop started with exec() or exec() .

PySide6.QtScxml.QScxmlStateMachine.stateNames([compress=true])
Parameters

compress – bool

Return type

list of strings

Retrieves a list of state names of all states.

When compress is true (the default), the states that contain child states will be filtered out and only the leaf states will be returned. When it is false, 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.

PySide6.QtScxml.QScxmlStateMachine.stop()

Stops this state machine. The machine will not execute any further state transitions. Its running property is set to false.

PySide6.QtScxml.QScxmlStateMachine.submitEvent(event)
Parameters

eventPySide6.QtScxml.QScxmlEvent

Submits the SCXML event event to 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 event and deletes it after processing.

PySide6.QtScxml.QScxmlStateMachine.submitEvent(eventName)
Parameters

eventName – str

PySide6.QtScxml.QScxmlStateMachine.submitEvent(eventName, data)
Parameters
  • eventName – str

  • data – object

A utility method to create and submit an external event with the specified eventName as the name and data as the payload data.

PySide6.QtScxml.QScxmlStateMachine.tableData()
Return type

PySide6.QtScxml.QScxmlTableData

See also

setTableData()

PySide6.QtScxml.QScxmlStateMachine.tableDataChanged(tableData)
Parameters

tableDataPySide6.QtScxml.QScxmlTableData