-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
51 lines (38 loc) · 1.32 KB
/
Copy pathmain.cpp
File metadata and controls
51 lines (38 loc) · 1.32 KB
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
49
50
51
#include <csignal>
#include "src/operations.hpp"
#include "src/file.hpp"
#include "src/server.hpp"
static volatile bool lauf = true;
void int_handler(int l) {
lauf = false;
}
int main(int argc, char** argv) {
signal(SIGINT, int_handler);
signal(SIGABRT, int_handler);
signal(SIGKILL, int_handler);
signal(SIGQUIT, int_handler);
signal(SIGTERM, int_handler);
if(argc < 3){
std::cout << "eaOpcUa für Kunbus Revolution Pi" << std::endl
<< "Starten mit Parametern:" << std::endl
<< "-a pfad_zu_adresstabelle" << std::endl
<< "-o pfad_zu_operationentabelle" << std::endl;
return -1;
}
std::string adressen, operationen;
uint16_t port = 4840;
for(int i = 1; i < argc; ++i){
if(strncmp(argv[i], "-a", 2) == 0){
adressen = std::string(argv[++i]);
}else if(strncmp(argv[i], "-o", 2) == 0){
operationen = std::string(argv[++i]);
}else if(strncmp(argv[i], "-p", 2) == 0){
port = std::stoi(std::string(argv[++i]));
}
}
if(adressen.empty() || operationen.empty()) return -1;
std::map<std::string, address> io_addresses = readIODescription(adressen);
std::map<std::string, operation> operations = readOpDescription(operationen, &io_addresses);
server(io_addresses, operations, &lauf, port);
return 0;
}