rubis-lab / CPSim_linux

8 stars 26 forks source link

get previous data in the task code #15

Open sehkmg opened 7 years ago

sehkmg commented 7 years ago

This PR changes components.h, DesignParser.cpp, real-time_simulator_basic.cpp to apply a new feature which allows using previous data in task codes of eclipse.

Usage: On each task codes such as CC1.h, return a value that you want to use in the next execution of the task code such as code: in CC1.h. Then, it will be stored in real-time_simulator and passed to the procedure of the task by a parameter previous_data. Thus, you can access it by previous_data in task codes.

Example:

var:0

input:0

output:1
internal_data[4]

CAN_input:1
0:0x7FD:1
car_output[SPEED]

CAN_output:0

code:
{
    float want_to_store;
    float data = previous_data;     //you can access stored data (want_to_store from previous execution) by previous_data

    internal_data[4] = car_output[SPEED];

    return want_to_store;       //return what you want to store globally
}