This module defines the state machine for the Productions
- class DIRAC.ProductionSystem.Utilities.StateMachine.ProductionsStateMachine(state)¶
Production Management System implementation of the state machine
c’tor Defines the state machine transactions
Method that gets the next state, given the proposed transition to candidateState. If candidateState is not on the state map <self.states>, it is rejected. If it is not the case, we have two options: if <self.state> is None, then the next state will be <candidateState>. Otherwise, the current state is using its own transition rule to decide.
>>> sm0.getNextState( None ) S_OK( None ) >>> sm0.getNextState( 'NextState' ) S_OK( 'NextState' )
candidateState (str) – name of the next state
S_OK( nextState ) || S_ERROR
Returns all possible states in the state map
>>> sm0.getStates() [ 'Nirvana' ]
list( stateNames )
Given a state name, it returns its level ( integer ), which defines the hierarchy.
>>> sm0.levelOfState( 'Nirvana' ) 100 >>> sm0.levelOfState( 'AnotherState' ) -1
state (str) – name of the state, it should be on <self.states> key set
int || -1 ( if not in <self.states> )
- setState(candidateState, noWarn=False)¶
- Makes sure the state is either None or known to the machine, and that it is a valid state to move into.
Final states are also checked.
>>> sm0.setState(None)['OK'] True >>> sm0.setState('Nirvana')['OK'] True >>> sm0.setState('AnotherState')['OK'] False
state (None or str) – state which will be set as current state of the StateMachine
S_OK || S_ERROR