wiki:news:10oct2013
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
wiki:news:10oct2013 [2013/09/21 18:48] – pmueller | wiki:news:10oct2013 [2022/08/17 19:44] (current) – Discussion status changed pmueller | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Multiple instances of the same machine ====== | ====== Multiple instances of the same machine ====== | ||
- | Sometimes you want to run the same state machine multiple times. E.g. processing | + | Sometimes you want to run the same state machine multiple times. E.g. processing |
- | Luckily in C there there is also a well known concept to do this. Instead of defining objects you define | + | Luckily in C there is also a well known concept to do this. Instead of defining objects you define |
In this example we will show you how to " | In this example we will show you how to " | ||
Line 23: | Line 23: | ||
You can now simply declare multiple variables of type TESTCASE_INSTANCEDATA_T which contains the data per instance. When calling the state machine just point to one of these variables. | You can now simply declare multiple variables of type TESTCASE_INSTANCEDATA_T which contains the data per instance. When calling the state machine just point to one of these variables. | ||
- | To let the state machine | + | Sometimes it is necessary that a state machine |
<code c> | <code c> | ||
Line 47: | Line 47: | ||
</ | </ | ||
- | I think you agree that this is no magic and easy to understand. | + | I think you agree that there is no magic in running multiple instances of the state handler. |
- | ===== Provide own Instance | + | ===== Provide |
- | Sometimes it makes sense to provide an own instance structure. In our example we want to store the baud rate, parity and other values relevant for each serial port. So the state machine can store there all local data and makes it " | + | Sometimes it makes sense to provide an own instance structure. In our example we want to store the baud rate, parity and other values relevant for each serial port. |
- | So first define an own struct in a file called '' | + | So first define an own struct in a file called '' |
<code c> | <code c> | ||
#ifndef __OWN_INST_TYPE__ | #ifndef __OWN_INST_TYPE__ | ||
#define __OWN_INST_TYPE__ | #define __OWN_INST_TYPE__ | ||
- | |||
- | |||
typedef struct InstanceData MY_TESTCASE_INSTANCEDATA_T; | typedef struct InstanceData MY_TESTCASE_INSTANCEDATA_T; | ||
Line 112: | Line 110: | ||
===== Putting all Things Together ===== | ===== Putting all Things Together ===== | ||
- | Coming back now to the example of three serial interfaces. The following figure shows a simplified state machine for handling a serial interface. The state machine is generic. | + | Coming back now to the example of three serial interfaces. The following figure shows a simplified state machine for handling a serial interface. The state machine is generic. |
+ | {{: | ||
+ | I hope that the concepts how to run multiple state machines of the same type are clearer now. And also how to define an own instance structure that is necessary for more complex machines. | ||
- | Hope that the concepts how to run multiple state machines | + | In case of any questions don't hesitate |
- | In case of any questions don't hesitate to contact us! | ||
- | {(rater> | + | ~~DISCUSSION:closed|Leave your comments~~ |
- | ~~DISCUSSION|Leave your comments~~ | + |
wiki/news/10oct2013.1379782108.txt.gz · Last modified: 2013/09/21 18:48 by pmueller