SinelaboreRT Header Logo

SinelaboreRT

Productivity for embedded software development

User Tools

Site Tools


wiki:news:22may2016

Vending Machine example on GitHub

Overview

A new fully functional vending machine example is available now. It is now hosted on GitHub so you can quickly check out the model and code yourself. Link to the repository: https://github.com/sinelabore/examples

The envisioned machine is shown below.

To compile the example just call make. It is assumed that you have installed the code generator from sinelabore and the Astah* Community UML tool (locations see Makefile).

After startup you can select a product “A”, “B” or “C” by pressing one of theses buttons on your keyboard.

Then you have to insert the coins to pay for the product. Only 10Ct, 20Ct and 50Ct coins are supported. To “insert” them click “1”,“2” or “5” on your keyboard.

After you paid the product will be released and you receive back your change.

Implementation

Most of the code is automatically generated from the UML model. It contains two state machines and an activity diagram. The state machines receive events from a message queue and can also send messages to other state machines. This is a well known design pattern to decouple objects. A timer service provides basic timer services that can be used from the state machines to realize delays or repetitive activities.

Product Store State Machine

The “product_store_sm” implements a simple product store containing the goods. It is responsible to release the products by turning on the motor etc.

Vending Machine

This is the controller machine keeping things together.

Change Algorithm

This is a simple algorithm modeled with the help of an activity diagram to release the right amount of money if the user overpaid. It takes care if one coin type is empty.

Have fun!

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
wiki/news/22may2016.txt · Last modified: 2022/09/25 08:57 by pmueller

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki