-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Problem statement
Currently we do not have mock communicator;
users of this library cannot use this without implementing concrete communication means.
For instance, drive cannot run program-execution on an Android emulator because Android emulators do not have the bluetooth function.
For this purpose, a mocking communicator is needed.
Proposal
I'd like to explain my thoughts of the means to resolve this.
I've implemented one class and one interface; MockCommunicator and MachineBackend.
MockCommunicator is a very simple communicator implementation:
- It has a reference of MachineBackend
- It passes input of ICommunicator#write to MachineBackend#write
- It calls MachineBackend#read and returns its return values.
MachineBackend is an interface for concrete classes of this; typical implementations are NxtBackend, Ev3Backend, and PileBackend.
These concrete classes should be able to:
- receive input of
writefunction - send output via
readfunction according to the request (the argument) - make state-transition by functions
(e.g., NxtBackend#setMotor can change its internal state of motors) - record history of operations
Conclusion
What do you think? Does my proposal make sense?
If you have any questions and opinions particularly for the structure of these classes,
feel free to leave a comment