Jump to content

Simulator for development


Recommended Posts

You might try this:

https://github.com/PlayWithIt/TFStubserver (without user interface)

https://github.com/PlayWithIt/TFStubViz (a simple user interface)


Not all devices are supported yet ... (MotionDetector is supported (also in UI).


There is a german description for it with an example:



Link to comment
Share on other sites

@Theo: I'll describe what I've done..


First of all, I wanted all concrete TF classes for bricklets to become interfaces. Chiefly so that I could have multiple implementations (e.g. one bound to the real hardware, another bound to an emulated bricklet, a unit test mock, etc.)


To obtain those interfaces, I wrote a code generator that parses the official TF JAR, and generates the interfaces, and a bunch of other things (like concrete classes wrapping the TF bricklet classes, and implementing the interfaces).


I also wrote a few (not many) emulated bricklets. E.g. the LCD bricklet, various sensors.


The end result is that I can write TF applications that are interface-based, and which can trivially switch execution between emulated and real hardware.


By the way, it's kind of ironic that my approach is code generation-based, because Tinkerforge also uses a code generator as their foundation for language-neutral description of all their devices.

Link to comment
Share on other sites



first of all sorry for the delay.

I used a different approach, I think it's more like TFStubserver does it: I wrote a replacement for the brickd.

It's a TCP Server which behaves like the original brickd but with data from emulated hardware devices.

The emulator device classes are generated with a python generator like the other TF language bindings. The generator uses the device descriptions of the TF generator stack. I started the development by rewriting the TF java bindings generator.

Writing over 65 device classes by hand is just to time consuming, boring and error-prone. But writing the generator is also a challenge ;-(.

The core TCP server and helper classes are hand coded. The emulator is still not ready and has a lot of rough edges but I'm preparing a github project to provide some insights. Hopefully I can finish this before going on holidays for 2 weeks.





Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...