Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to verif/ validate a state machine ? #264

Closed
hwerbi opened this issue Jul 10, 2020 · 1 comment
Closed

Is there a way to verif/ validate a state machine ? #264

hwerbi opened this issue Jul 10, 2020 · 1 comment

Comments

@hwerbi
Copy link

hwerbi commented Jul 10, 2020

Python State Machine version: 0.8.0
Python version: 3.7
Operating System: windows 10

Description

I created a state machine for a system and now I would like to validate the state machine. Something like to proof that the state machine does not contain a block senario, if it's ambiguous? Is it deterministic?
Or even to test some LTL formule on it ?

Is there a way to do this ? with python, model cheker ?

@fgmacedo
Copy link
Owner

fgmacedo commented Aug 8, 2020

@hwerbi , we've implemented a few checks built-in:

  • Are there states defined?
  • Are there transitions defined?
  • Is there one and only one initial state?
  • Is the statemachine graph a single component? (Is there any disconected sub-graph? Unheachable states?)

Other tests can be performed the same way, please see

def check(self):
if not self.states:
raise InvalidDefinition(_('There are no states.'))
if not self.transitions:
raise InvalidDefinition(_('There are no transitions.'))
initials = [s for s in self.states if s.initial]
if len(initials) != 1:
raise InvalidDefinition(_('There should be one and only one initial state. '
'Your currently have these: {!r}'.format(initials)))
self.initial_state = initials[0]
disconnected_states = self._disconnected_states(self.initial_state)
if (disconnected_states):
raise InvalidDefinition(_('There are unreachable states. '
'The statemachine graph should have a single component. '
'Disconnected states: [{}]'.format(disconnected_states)))
if self.current_state_value is None:
if self.start_value:
self.current_state_value = self.start_value
else:
self.current_state_value = self.initial_state.value

Let me know if I can help with something, feel free to reopen the issue.

@fgmacedo fgmacedo closed this as completed Aug 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants