Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Proposal of Mock communicator and machine #12

@mandaiy

Description

@mandaiy

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 write function
  • send output via read function 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

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions