kirtonBCIlab / bci-essentials-python

Python backend for BCI Essentials
Mozilla Public License 2.0
11 stars 7 forks source link

EEG_data should publish output to subscribers #83

Closed gregbci closed 10 months ago

gregbci commented 10 months ago

B4K-227

I removed the LSL outlet dependency by injecting a "messenger" object. To keep things simple, the messenger is just a delegate, taking over responsibility for sending an event message, ex: "marker received". If we want to implement a true observer pattern (ex: publish / subscribe), we can make a messenger object that does that. Either way, EEG_data shouldn't have to care. At this point, I don't think pub/sub is needed.

All the "offline test" examples and existing unit tests don't need a messenger, so I made the default "None". If there isn't a messenger available, EEG_data won't try sending messages.

I added an LslMessenger for all the "unity backend" examples. They create it and pass to EEG_data.

I added another test for the "ping" message in test_eeg_data.py. This demonstrates using a mock Messenger object for testing, in this case, counting pings after running a few loops.