wiki:news:16aug2013
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
wiki:news:16aug2013 [2013/08/16 15:34] – pmueller | wiki:news:16aug2013 [2021/04/18 13:41] (current) – [Microwave Oven Example in C#] pmueller | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== C# backend now available again ====== | + | ====== |
- | |||
- | In an earlier version it was possible to generate C# code. This was not possible with the latest versions of the code generator, but is available now again with version 3.3. | ||
To generate C# code call the code generator with the new command line flag '' | To generate C# code call the code generator with the new command line flag '' | ||
Line 8: | Line 6: | ||
The generated code does not follow the state pattern as you might expect (if you are fa- miliar with common design patterns). The reason is that the machine code is completely generated and no hand-coding is involved. So the number of classes and files in your project is reduced to a minimum. The following figure shows the structure of the generated code. The classes marked with ''< | The generated code does not follow the state pattern as you might expect (if you are fa- miliar with common design patterns). The reason is that the machine code is completely generated and no hand-coding is involved. So the number of classes and files in your project is reduced to a minimum. The following figure shows the structure of the generated code. The classes marked with ''< | ||
- | {{ : | + | {{ : |
Figure: Structure of the generated C# code. | Figure: Structure of the generated C# code. | ||
===== Microwave Oven Example in C# ===== | ===== Microwave Oven Example in C# ===== | ||
- | The following | + | A microwave oven is taken from the examples folder of the code generator |
- | {{ : | + | {{ : |
A simple hardware abstraction layer provides helper functions like a timer etc. You can see how it is called from the state machine (e.g. in an entry action) as '' | A simple hardware abstraction layer provides helper functions like a timer etc. You can see how it is called from the state machine (e.g. in an entry action) as '' | ||
Line 29: | Line 27: | ||
+ | To generate code from the diagram call the generator as follows: | ||
+ | |||
+ | <code bash> | ||
+ | java -Djava.ext.dirs=../ | ||
+ | </ | ||
The generated code looks as follows: | The generated code looks as follows: | ||
- | < | + | < |
namespace OvenMachineNS | namespace OvenMachineNS | ||
{ | { | ||
Line 118: | Line 121: | ||
</ | </ | ||
+ | |||
+ | |||
+ | Finally start the generated exe file and play with the microwave oven. First increment the cooking time. Then start cooking by closing the door. | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | The sinelabore code generator provides much more features than just code generations. Before generation an extensive check is performed to ensure your diagram is correct (e.g. each transition has an associated event, all state names are unique ...). You can add trace code if needed, simulate the state machine, generate test cases and more. | ||
+ | |||
+ | If you want to try out the example yourself download the code generator demo. The oven can be found in the examples folder. | ||
+ | |||
+ | |||
+ | |||
+ | ~~DISCUSSION: | ||
+ | |||
+ | |||
+ |
wiki/news/16aug2013.1376660060.txt.gz · Last modified: 2013/08/16 15:34 by pmueller