Initial value propagation
- Initial values are propagated from the control system, from all application modules and all device variles.
- ApplicationModules are waiting to receive an initial value for all variables before entering the main loop. The code in the main loop can rely on having initial values for all inputs.
- As a consequence all ApplicationModules have to write initial values to all of their outputs at application start because these outputs usually are inputs to other modules.
Required changes to existing applications
- Each application module has to write all of its outputs once before the first blocking read
- This can be done in two places
- Normally the initial values of the outputs are computed from the inital values of the inputs at the beginning of the ApplicationModule::mainLoop(). This is the preferred way.
- For constants or to break circulat dependencies between modules, initial values of the outpus can be written in ApplicationModule::prepare(). In this case they cannot be based in the initial values of the inputs, which are not available at this point in time. That's why sending initial values in ApplicationModule::prepare() should be avoided if possible.
while(true){
readAll();
doComputationsFromInputs();
writeAll();
}
}
while(true){
doComputationsFromInputs();
writeAll();
readAll();
}
}