Visual Programming in DIA

What is it?

It's script that converts DIA diagrams into programs. You're writing programs by dragging function shapes into the diagram and connecting them together.

Picture 1

Every function shape has name, arguments and return value.

Picture 2

Functions can be connected together using Bezierline connections in a way that return value of one function is passed as an argument of another function.


Picture 3

You can also directly define arguments in function shape properties.

Picture 4

Writing program this way you must follow this rules:
  1. You can't pass return value as argument to the same function
  2. Every arguments must be defined.
After you draw diagram you must run script that converts it into program.
Diagram from Picture 3 would be transformed into this formula: O1(AND(I1(), I2()));

How does it work?

Script transforms DIA diagram XML file into C language program. Then this program is compiled with C compilator which creates executable.

 System is based on three files:
  • main.c - main C file includes loop() function which is defined in program.c file
  • program.c - this is what the transformation script is compiling from DIA diagram
  • functions.c - definition of functions used to build programs
The set of function shapes can be generated from a function.h header file using special script. It will automatically name function and its arguments. Script is using doxygen to parse functions.h file. It's set to output XML file. In next step script uses Saxon (XSLT processor) and a special xslt file to transform doxygen xml file into set of xml files that DIA recognizes as shapes. Script also uses imagemagick to create icon files for function (it generates images with names of functions).

To generate program another script is used but in the same way. It translates DIA diagram (which is a XML file) using Saxon and second xslt file to generate program.c file which includes formula for the program.

The last step is creating executable file using GCC.

Here is link to repository: https://bitbucket.org/limgo/avr-dia-plc/src

 

Brak komentarzy:

Prześlij komentarz