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

Chopper should check states before triggering command switches #86

Merged
merged 5 commits into from
Sep 1, 2016

Conversation

MichaelWedel
Copy link
Contributor

This fixes #84.

To test you could start the chopper (in the sense of setting a speed and a phase) and then issue a deinit-command. Like before, nothing happens. If you then issue stop, it should not go directly to the init-state as it did before.

This device needs unit tests at some point.

sm.process(0)
self.assertEqual(sm.state, 'bar')
self.assertEqual(sm.can('foo'), True)
self.assertEqual(sm.can('init'), True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably, these could use self.assertTrue() and self.assertFalse() respectively. Another alternative would be self.assertIs().

I don't really have a preference one way or the other, just something to consider.

self.assertIs() would have the benefit of testing for identity with True and False; all the other asserts will succeed even if the value is only "truthy" or "falsy" (1 == True, 0 == False, etc).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point, thanks. I used assertEqual so that you can see what it returns. It sounds like assertIs is the thing that really should be used here.

Michael Wedel added 5 commits September 1, 2016 14:37
StateMachine now has a method "can", which returns true if the state supplied as the argument is reachable from the current state. This is required for some of the chopper logic.

Refs #84.
The chopper commands like start, stop, unlock, etc. are now only executed if the state machine allows the transition to the desired state.

Refs #84.
@MikeHart85 MikeHart85 merged commit 5a72116 into master Sep 1, 2016
@MikeHart85 MikeHart85 deleted the 84_chopper_command_switches branch September 1, 2016 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix behavior of command switches
2 participants