Rigbox
Rigbox copied to clipboard
Replace Socket with Communicator in StimulusControl
Is your feature request related to a problem? Please describe. srv.StimulusControl has a fixed implementation of the web sockets. This means that if the implementation changes, this class would need changing. Also, this class is not amenable to mocking and testing.
Describe the solution you'd like Replace the Socket and hSocket properties with Communicator. This property will contain an io.Communicator instance. All methods such as connect and send should call the Communicator methods. The concrete class created in srv.StimulusControl/connect would be io.WSJCommunicator.
For this to work right the io.(WSJ)Communicator class should implement the Timeout property. See here: https://github.com/cortex-lab/Rigbox/blob/a1a66648ef4bcb3b7630bccf88bae83fdab26c14/cb-tools/burgbox/%2Bio/WSJCommunicator.m#L204-L210
Describe alternatives you've considered For mocking this class we can use MATLAB's mocking framework in >2018b. For now I've just created a DummyStimulusControl class for use with eui.SignalsTest