5.1. Example application
The example application will handle the following tasks:
EC-Monitor initialization
Process Data acquisition with EC-DAQ
Periodic Job Task in polling or interrupt mode
Thread with periodic tasks and application thread already implemented
Record and replay wireshark traces
Logging. The output messages of the demo application will be printed on the console as well as in some files.
“Out of the box” solution for different operating systems: Windows, Linux …
5.1.1. File reference
The EcMonitorDemo application consists of the following files:

EcDemoMain.cpp |
Entry point for the different operating systems |
EcDemoPlatform.h |
Operating system specific settings (task priorities, timer settings) |
EcDemoApp.cpp |
Initialize, start and terminate EC-Monitor |
EcDemoApp.h |
Application specific settings for EcDemoApp |
EcDemoParms.cpp |
Parsing of command line parameters |
EcDemoParms.h |
Basic configuration parameters |
EcSelectLinkLayer.cpp |
Common Functions which abstract the command line parsing into Link Layer parameters |
EcNotification.cpp |
Slave monitoring and error detection
(function |
EcSlaveInfo.cpp |
Slave information services |
EcLogging.cpp |
Message logging functions |
EcTimer.cpp |
Start and monitor timeouts |
5.1.2. EC-Monitor life cycle
Basically the operation of the EC-Monitor is wrapped between the functions
and
The EC-Monitor is made ready for operation and started with the first two functions mentioned. During this preparation, a thread is set up and started that handles all the cyclic tasks of the EC-Monitor. The last function stops the EC-Monitor and clears the memory.
An overview of the complete life cycle as a sequence diagram:
A more detailed description of the functions:
- EcDemoMain()
A wrapper to start the demo from the respective operating system. In addition to initializing the operating system, parsing command line parameters and initializing logging it also starts the timing task.
- EcDemoApp()
Demo application. The function takes care of starting and stopping the EC-Monitor and all related tasks. In between, the function runs idle, while all relevant work is done by the EcMonitorJobTask().
- EcMonitorJobTask()
Thread that does the necessary periodic work. Very important here is myAppWorkPd() between
eUsrJob_ProcessAllRxFrames
andeUsrJob_MonitorTimer
. Application-specific access to the process data image can be made here, which is synchronous with the bus cycle.- EcTimingTask()
Timing Thread. This thread sets the timing event that triggers the EcMonitorJobTask for the next cycle.
emInitMonitor()
Prepare the EC-Monitor for operation and set operational parameters, e.g. used Link Layer, buffer sizes, maximum number of slaves, … .
emConfigureNetwork()
Loads the configuration from the ENI (XML file).
emRegisterClient()
Register the application as a client at the EC-Monitor to receive event notifications.
emDeinitMonitor()
Clean up.