# Software Integration ## EcSimulatorHilDemo The example application EcSimulatorHilDemo will handle the following tasks: - Stack initialization - Flash process data - Out of the box solution for different operating systems: - Windows - Linux - LxWin - … - Example implementation for polled mode or interrupt mode operation - Thread with periodic tasks and application thread already implemented - The output messages of the demo application will be printed on the console as well as in log files (\*.log) ### File reference The Demo application consists of the following files: | Filename | Description | |----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------| | [`EcDemoMain.cpp`](_downloads/fc875d17cbef52a4c4879f7ba411fe69/EcDemoMain.cpp) | Entry point for the different operating systems | | [`EcDemoPlatform.h`](_downloads/8a98bd88751f8738d3ec7f509d67f6e7/EcDemoPlatform.h) | Operating system specific settings (task priorities, timer settings) | | [`EcDemoApp.cpp`](_downloads/691b6cd9b7e98f10c49d10af7b111fd6/EcDemoApp.cpp) | Initialize, start and terminate the EC-Simulator stack | | [`EcDemoApp.h`](_downloads/ad6023c9ee4ce5ebde73c611bdd1b052/EcDemoApp.h) | Application specific settings for EcSimulatorHilDemo | | [`EcDemoParms.cpp`](_downloads/cc5a320ac29f8e16f99cb4d2be8320fa/EcDemoParms.cpp) | Parsing of command line parameters and generic helper functions | | [`EcDemoParms.h`](_downloads/7da4d0b851574416d0292c150711af29/EcDemoParms.h) | Basic configuration parameters | | [`EcSelectLinkLayer.cpp`](_downloads/bf62c71a4a7e317930818b9da4a9815c/EcSelectLinkLayer.cpp) | Common functions which abstract the command line parsing into Real-time Ethernet Driver parameter | | [`EcNotification.cpp`](_downloads/a8230e7ca1c52aaedb62898da301f674/EcNotification.cpp) | SubDevice monitoring and error detection (function `NotifyWrapper()` ) | | [`EcSlaveInfo.cpp`](_downloads/1717ceec03b28a568975a261bbaff164/EcSlaveInfo.cpp) | SubDevice information services | | [`EcLogging.cpp`](_downloads/688adc0df0fa9d756770fefe6720978f/EcLogging.cpp) | Message logging functions | | [`EcTimer.cpp`](_downloads/f9c3bd98e3ff32524fc04ff3bde41b53/EcTimer.cpp) | Start and monitor timeouts | ### Simulator lifecycle Basically the operation of the EC-Simulator stack is wrapped between the functions - [`esInitSimulator()`](api_general.html.md#_CPPv415esInitSimulator10EC_T_DWORDPK25EC_T_SIMULATOR_INIT_PARMS) - [`esConfigureNetwork()`](api_general.html.md#_CPPv418esConfigureNetwork10EC_T_DWORD13EC_T_CNF_TYPE10EC_T_PBYTE10EC_T_DWORD) - [`esDeinitSimulator()`](api_general.html.md#_CPPv417esDeinitSimulator10EC_T_DWORD) ### Logging The example program demonstrates how messages can be processed by the application, see `Examples/Common/EcLogging.cpp`. The messages handled by `EcLogging.cpp` are of different type, e.g. EC-Simulator Log Messages and Application Messages are logged to console and/or to files. The verbosity of the demo given as console parameter “-v” is used to determine the log level of the application, see “set application log level” in `EcDemoMain.cpp`. Logging is configured on initialization, see the structure documentation of `EC_T_SIMULATOR_INIT_PARMS::LogParms` in [`esInitSimulator()`](api_general.html.md#_CPPv415esInitSimulator10EC_T_DWORDPK25EC_T_SIMULATOR_INIT_PARMS). The EC-Simulator automatically filters log messages according to EC_T_SIMULATOR_INIT_PARMS::LogParms.dwLogLevel . Log messages which are less relevant according to their severity (see EC_LOG_LEVEL…) are filtered out. CAtEmLogging has various parameters beside the log level, like Roll Over setting, log task prio and affinity, log buffer size, etc. See InitLogging in `EcLogging.h`, `EcDemoMain.cpp` for reference. The application can override CAtEmLogging::PrintConsole / CAtEmLogging::PrintMsg if the default handler in `EcLogging.cpp` does not fulfill the application’s needs. #### IMPORTANT The callback is typically called from the Job Task’s context and should return as fast as possible. #### IMPORTANT Logging to files is disabled by default for some OS, because e.g. a file system must be added explicitly. Setting bLogFileEnb to 1 is needed for some operating systems to enable file logging. Identical messages are skipped automatically by default.