Пример #1
0
	def setModel(self, model):
		"""Sets model for validator.

		Gives the validator a new model to validate. This function must be successfully called whenever the 
		model to be validated changes in any way."""
		self.__modelMutex.acquire()
		self.__model = model
		self.__queue = [model.getInitialState()]
		self.__routes = {str(self.__queue[0]): None}
		self.__modelMutex.release()
Пример #2
0
def analyseModel(model):
    for prop in model.getInitialState().getStateProps():
        if str(prop).endswith('SwitcherBase'):
            base_prop = prop
            break
    else:
        base_prop = None

    actions = set()
    states = set()
    sleepstates = set()
    transitions = set()
    stateprops = set()
    stateprop_combs = set()
    sleep_stateprop_combs = set()
    aw_stateprop_combs = set()

    def isSleepState():
        return base_prop in current_props

    def isActionWord(action):
        return str(action).find(':start_aw') != -1

    stack = [model.getInitialState()]

    while len(stack) > 0:
        state = stack.pop()
        current_props = frozenset(state.getStateProps())

        states.add(state)

        if isSleepState():
            sleepstates.add(state)

        for stateprop in current_props:
            stateprops.add(stateprop)

        stateprop_combs.add(current_props)

        if isSleepState():
            sleep_stateprop_combs.add(current_props)

        for transition in state.getOutTransitions():
            current_action = transition.getAction()

            actions.add(current_action)

            transitions.add(transition)

            if isActionWord(current_action):
                aw_stateprop_combs.add((current_action, current_props))

            if transition.getDestState() not in states:
                stack.append(transition.getDestState())

    result = {}
    result[ACTIONS] = len(actions)
    result[ACTIONWORDS] = len([a for a in actions if isActionWord(a)])
    result[STATES] = len(states)
    result[SLEEPSTATES] = len(sleepstates)
    result[TRANSITIONS] = len(transitions)
    result[STATEPROPOSITIONS] = len(stateprops)
    result[STATEPROPOSITION_COMBINATIONS] = len(stateprop_combs)
    result[SLEEPING_STATEPROPOSITION_COMBINATIONS] = len(sleep_stateprop_combs)
    result[ACTIONWORD_STATEPROPOSITION_COMBINATIONS] = len(aw_stateprop_combs)

    return result
Пример #3
0
def analyseModel(model):
    for prop in model.getInitialState().getStateProps():
        if str(prop).endswith('SwitcherBase'):
            base_prop = prop
            break
    else:
        base_prop = None

    actions = set()
    states = set()
    sleepstates = set()
    transitions = set()
    stateprops = set()
    stateprop_combs = set()
    sleep_stateprop_combs = set()
    aw_stateprop_combs = set()

    def isSleepState():
        return base_prop in current_props

    def isActionWord(action):
        return str(action).find(':start_aw') != -1

    stack = [model.getInitialState()]
        
    while len(stack) > 0:
        state = stack.pop()
        current_props = frozenset(state.getStateProps())

        states.add(state)

        if isSleepState():
            sleepstates.add(state)

        for stateprop in current_props:
            stateprops.add(stateprop)

        stateprop_combs.add(current_props)

        if isSleepState():
            sleep_stateprop_combs.add(current_props)

        for transition in state.getOutTransitions():
            current_action = transition.getAction()

            actions.add(current_action)

            transitions.add(transition)

            if isActionWord(current_action):
                aw_stateprop_combs.add((current_action, current_props))

            if transition.getDestState() not in states:
                stack.append(transition.getDestState())

    result = {}
    result[ACTIONS] = len(actions)
    result[ACTIONWORDS] = len([a for a in actions if isActionWord(a)])
    result[STATES] = len(states)
    result[SLEEPSTATES] = len(sleepstates)
    result[TRANSITIONS] = len(transitions)
    result[STATEPROPOSITIONS] = len(stateprops)
    result[STATEPROPOSITION_COMBINATIONS] = len(stateprop_combs)
    result[SLEEPING_STATEPROPOSITION_COMBINATIONS] = len(sleep_stateprop_combs)
    result[ACTIONWORD_STATEPROPOSITION_COMBINATIONS] = len(aw_stateprop_combs)

    return result