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

Add emulator support #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ckarageorgkaneen
Copy link

  • Add Emulator object that emulates bpod hardware behavior and reference
    it in the BpodBase class
  • Modify bpod classes to accommodate emulator functionality
  • Add emulator examples to showcase its usage

@ckarageorgkaneen ckarageorgkaneen force-pushed the add-emulator-support branch 3 times, most recently from c84c302 to dbf3dc5 Compare September 13, 2020 10:27
Copy link

@oraby oraby left a comment

Choose a reason for hiding this comment

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

I've had a go through the code except for the actual emulator class, but I wanted to give some initial feedback first. Generally, I think the code is doing a good job where it basically satisfies what needs to be done, with the exception of few unrelated cosmetic changes.
I have wished though if the emulator was implemented as an instance of a BpodCOMProtocol() class, however that's not currently possible as the current Bpod classes design uses inheritance when at many times composition would have been IMO a better choice.

One last thought: I wonder whether it'll be simpler to replace emulator.enabled with simply having self._emulator either as Emulator() or None.

examples/emulator_examples/10_state_example.py Outdated Show resolved Hide resolved
examples/emulator_examples/10_state_example_2.py Outdated Show resolved Hide resolved
examples/emulator_examples/10_state_example_2.py Outdated Show resolved Hide resolved
examples/emulator_examples/10_state_example_2_unblock.py Outdated Show resolved Hide resolved
examples/emulator_examples/add_trial_events.py Outdated Show resolved Hide resolved
pybpodapi/bpod/bpod_base.py Outdated Show resolved Hide resolved
pybpodapi/bpod/bpod_base.py Outdated Show resolved Hide resolved
pybpodapi/bpod/bpod_base.py Outdated Show resolved Hide resolved
pybpodapi/bpod/bpod_base.py Outdated Show resolved Hide resolved
pybpodapi/bpod/emulator/emulator.py Outdated Show resolved Hide resolved
@ckarageorgkaneen
Copy link
Author

ckarageorgkaneen commented Sep 18, 2020

One last thought: I wonder whether it'll be simpler to replace emulator.enabled with simply having self._emulator either as Emulator() or None.

I agree.

Regarding CI:

If these tests will be part of CI, your aforementioned comments are true, and we 'll also have a problem with the threaded emulator examples, where I showcase the manual override functionality. But, these tests were intended to demonstrate emulator functionality in the spirit of the examples under the function_examples and state_machine_examples directories. All these are not unit tests.

All in all, I think that CI should not be configured to run these behavioral tests, but only unit tests, if they are added in the future (separate PR), which I totally recommend.

@ckarageorgkaneen ckarageorgkaneen force-pushed the add-emulator-support branch 10 times, most recently from 2e15db8 to e5a8fdb Compare September 19, 2020 21:15
Copy link

@oraby oraby left a comment

Choose a reason for hiding this comment

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

Generally LGTM, I've left few comments on the parts that I think still need addressing. But nothing major on my side.

pybpodapi/settings.py Outdated Show resolved Hide resolved
examples/emulator_settings.py Outdated Show resolved Hide resolved
# initialise the thread that will handle the stdin commands
self.stdin = NonBlockingStreamReader(sys.stdin) if settings.PYBPOD_API_ACCEPT_STDIN else None
#####################################################
self.__initialize_input_command_handler()
Copy link

Choose a reason for hiding this comment

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

If this is emulator mode, then this function would be called twice, once here and once in e652786#diff-c1bf0eb6016fc3d3327d1ee1ddb66991R75

Copy link
Author

@ckarageorgkaneen ckarageorgkaneen Dec 13, 2020

Choose a reason for hiding this comment

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

What do you mean? It's called once in __init__() and once inside open(), which is not called if emulator mode is enabled.

Copy link

Choose a reason for hiding this comment

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

yup, you are right

pybpodapi/bpod/bpod_base.py Outdated Show resolved Hide resolved
pybpodapi/bpod/emulator/emulator.py Outdated Show resolved Hide resolved
pybpodapi/bpod/emulator/emulator.py Show resolved Hide resolved
pybpodapi/bpod/emulator/emulator.py Outdated Show resolved Hide resolved
pybpodapi/bpod/emulator/emulator.py Outdated Show resolved Hide resolved
pybpodapi/bpod/emulator/emulator.py Outdated Show resolved Hide resolved
Copy link

@oraby oraby left a comment

Choose a reason for hiding this comment

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

One very simple change suggested, otherwise LGTM.
The only thing that I might also suggest, is to eventually squash together commits that are created then fixed in this PR into the same original initial commit.

# initialise the thread that will handle the stdin commands
self.stdin = NonBlockingStreamReader(sys.stdin) if settings.PYBPOD_API_ACCEPT_STDIN else None
#####################################################
self.__initialize_input_command_handler()
Copy link

Choose a reason for hiding this comment

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

yup, you are right

pybpodapi/bpod/bpod_base.py Outdated Show resolved Hide resolved
@ckarageorgkaneen
Copy link
Author

Codacy analysis failures are of low severity. However, they should be dealt with in a future PR of their own.

pybpodapi/bpod/bpod_base.py Outdated Show resolved Hide resolved
@oraby
Copy link

oraby commented Dec 29, 2020

LGTM 👍

@ckarageorgkaneen ckarageorgkaneen force-pushed the add-emulator-support branch 2 times, most recently from f3b5954 to 415bea0 Compare January 9, 2021 19:14
@ckarageorgkaneen ckarageorgkaneen force-pushed the add-emulator-support branch 2 times, most recently from a92dc05 to 3d215d1 Compare April 10, 2021 20:03
- Add Emulator object for emulating bpod hardware behavior and
communicating outputs to emulator GUI server
- Modify bpod classes to accommodate emulator functionality
- Add emulator examples to showcase its usage
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

Successfully merging this pull request may close these issues.

2 participants