SinelaboreRT Header Logo

SinelaboreRT

It's better when it's simple!

User Tools

Site Tools


Sidebar

Tool Landing Pages

Examples

Designers Toolbox

How-To

Integrated state-chart editor with auto-layout

Focus on modeling and not on moving states around to create a nice looking diagram! Syntax aware text fields offer a comfortable way to specify actions, guards etc. When the diagram passed the model checker it can be directly simulated. Connect the diagram to the real hardware to monitor the state machine in action.

There are better ways to model state machines than using spread sheets!

In the past different μC manufacturers have published application notes about the benefit of using state machines for the design of embedded software. An example is the application note SLAA402 from Texas Instruments (TI). It suggests to generate source code based on a spread sheet table. Nowadays several affordable UML modeling tools are available supporting the efficient design of state machines in a graphical way. SinelaboreRT generates production quality source code from state diagrams created with many different UML tools. Give it a try!

Latest Changes

wiki:news:24june2014

Reading data from an energy meter via Modbus – Activity diagram in practise

Background: For a data logger application the voltage and real power values should be read from an energy meter using the Modbus RTU protocol. The application runs in the context of collectd1) on a FreeBSD server and stores the values in a RRD database. The program can be called with a command line parameter that defines the data point to read and the serial port to use. The console output is in a format that is directly processed from collectd.

Example call and console output to read the line voltages:

./energy /dev/cuaU0 VOLTAGE
PUTVAL "/ENERGIE/UL1" N:239
PUTVAL "/ENERGIE/UL2" N:242
PUTVAL "/ENERGIE/UL3" N:238

Solution: In contrast to the microwave oven example where an activity is called from within a state diagram (see news entry from 24.5.2014) in this example a complete small command line program is modelled. The model was created with Enterprise Architect. Besides the basic design elements like actions, initial – and final nodes also a conditional node was used. This type of node is a convenient block to model multiple choices and actions in one block instead of using multiple choices and action blocks.

To generate code from the model export it into an XMI file using the latest XMI 2.4.1 format (this is important). Then call the code generator the following way to generate C-code from the mode file:

java -jar ../../codegen.jar -p EA -A -t "Model:implementation_model:modbus_client" -o modbus_client modbus_client.xml

And finally compile and link the object with the used Modbus library to create the exe file:

gcc -I/usr/local/include/modbus/ -g strommessung.c -L/usr/local/lib -lmodbus

Thats all! Here is the generated code: modbus_client_activity.c. A simple main file calls the generated method:

#include "modbus_client_activity.h"
 
int main(int argc, char* argv[]){
	return activity(argc, argv);
}

If you are interested in the model file just send a mail! Your thoughts are also very welcome!

Have fun!

Peter

How do you like this article?
 stars  from 8 votes
1) collectd is a daemon which collects system performance statistics periodically and provides mechanisms to store the values in a variety of ways, for example in RRD files.

Leave your comments

Enter your comment. Wiki syntax is allowed:
75 +4 = ?
 
wiki/news/24june2014.txt · Last modified: 2014/06/24 22:16 by pmueller