StateMachine

This module defines the state machine for the Productions

class DIRAC.ProductionSystem.Utilities.StateMachine.ProductionsStateMachine(state)

Bases: StateMachine

Production Management System implementation of the state machine

__init__(state)

c’tor Defines the state machine transactions

getNextState(candidateState)

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.

Examples

>>> sm0.getNextState( None )
    S_OK( None )
>>> sm0.getNextState( 'NextState' )
    S_OK( 'NextState' )
Parameters

candidateState (str) – name of the next state

Returns

S_OK( nextState ) || S_ERROR

getStates()

Returns all possible states in the state map

Examples

>>> sm0.getStates()
    [ 'Nirvana' ]
Returns

list( stateNames )

levelOfState(state)

Given a state name, it returns its level ( integer ), which defines the hierarchy.

>>> sm0.levelOfState( 'Nirvana' )
    100
>>> sm0.levelOfState( 'AnotherState' )
    -1
Parameters

state (str) – name of the state, it should be on <self.states> key set

Returns

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.

Examples

>>> sm0.setState(None)['OK']
    True
>>> sm0.setState('Nirvana')['OK']
    True
>>> sm0.setState('AnotherState')['OK']
    False
Parameters

state (None or str) – state which will be set as current state of the StateMachine

Returns

S_OK || S_ERROR