-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
49 lines (39 loc) · 1.87 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/** @file
* @brief This file contains the template for the main program for the Esmacat slave
* project */
/*****************************************************************************************
* INCLUDES
****************************************************************************************/
#include <iostream>
#include "my_app.h"
/*****************************************************************************************
* FUNCTIONS
****************************************************************************************/
/**
* @brief Initializes the execution of the Ethercat communication and
* primary real-time loop for your application for the desired
* slave
* @return
*/
int main()
{
//this is defined in my_app.cpp and my_app.h
static plog::RollingFileAppender<plog::CsvFormatter> fileAppender("esmacat_log.csv", 80000, 10); // Create the 1st appender.
static plog::ColorConsoleAppender<plog::TxtFormatter> consoleAppender; // Create the 2nd appender.
plog::init(plog::warning, &fileAppender).addAppender(&consoleAppender); // Initialize the logger with the both appenders.
//this is defined in my_app.cpp and my_app.h
my_app app;
// if you already know the ethernet adapter name for EtherCAT, uncomment and use the line below
// app.set_ethercat_adapter_name(" WRITE YOUR ETHERNET ADAPTER NAME");
// If the name is not known, select through the terminal an ethernet adapter (the slave)
// you'd like to communicate with over EtherCAT
// app.set_ethercat_adapter_name_through_terminal();
// start the esmacat application customized for your slave
app.start();
// set the cycle time in ns
app.set_one_cycle_time_ns(1000000L);
//the application runs as long as the esmacat master and slave are in communication
while (app.is_esmacat_app_closed() == false );
app.close();
return 0;
}