added USR1 signal to exit the program, also including some interface stuff

origin
steffen 5 years ago
parent 5843b0d365
commit 11dab29de7

@ -1,3 +1,7 @@
2021-03-07:
- fixed: high cpu load, sleep function was not working right. If the current
loop took below 1ms we would ot wait for the 25ms to finish.
2021-02-10: 2021-02-10:
- automatic mode with random destinations is working now - automatic mode with random destinations is working now

@ -9,9 +9,9 @@ ETCPREFIX=/etc
DISTNAME=modelbahn DISTNAME=modelbahn
CXX=g++ CXX=g++
CXXFLAGS= -ggdb -fPIC -Wno-write-strings -g -ggdb -std=c++11 CXXFLAGS= -ggdb -fPIC -Wno-write-strings -g -ggdb -std=c++11 -pg
LDFLAGS= -lm -lc -lpthread -L/usr/local/lib -g -ggdb LDFLAGS= -lm -lc -lpthread -L/usr/local/lib -g -ggdb -pg
LDFLAGS_CGI= -lm -lc -lpthread -L/usr/local/lib -g -ggdb LDFLAGS_CGI= -lm -lc -lpthread -L/usr/local/lib -g -ggdb -pg
DEPENDFILE=.depend DEPENDFILE=.depend
TARGET=modelbahn-server TARGET=modelbahn-server
@ -25,10 +25,10 @@ CURDIR=`pwd`
all: dep $(TARGET) test-json modelbahn-cgi all: dep $(TARGET) test-json modelbahn-cgi
modelbahn-server: $(SERVEROBJ) modelbahn-server: $(SERVEROBJ)
$(CXX) -o $@ $^ $(LDFLAGS_CGI) -lUDPTCPNetwork -L./ -I./ -lpthread $(CXX) -o $@ $^ $(LDFLAGS) -lUDPTCPNetwork -L./ -I./ -lpthread
modelbahn-cgi: modelbahn-cgi.o debug.o modelbahn-cgi: modelbahn-cgi.o debug.o
$(CXX) -o $@ $^ $(LDFLAGS) -lUDPTCPNetwork -L./ -I./ -lpthread $(CXX) -o $@ $^ $(LDFLAGS_CGI) -lUDPTCPNetwork -L./ -I./ -lpthread
test-json: json.o test-json.o debug.o test-json: json.o test-json.o debug.o
$(CXX) -o $@ $^ $(LDFLAGS) -L./ -I./ -lpthread $(CXX) -o $@ $^ $(LDFLAGS) -L./ -I./ -lpthread

@ -37,6 +37,10 @@ int main (int argc, char **argv) {
fprintf (stderr, "%s:%d could not set signal for SIGHUB\n", __FILE__, __LINE__); fprintf (stderr, "%s:%d could not set signal for SIGHUB\n", __FILE__, __LINE__);
return 0; return 0;
} }
if (signal(SIGUSR1, sig_int) == SIG_ERR) {
fprintf (stderr, "%s:%d could not set signal for SIGHUB\n", __FILE__, __LINE__);
return 0;
}
debug (0, "***************************************************"); debug (0, "***************************************************");
@ -46,7 +50,6 @@ int main (int argc, char **argv) {
debug (0, "***************************************************"); debug (0, "***************************************************");
debug (0, ""); debug (0, "");
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// application startup // application startup
@ -80,7 +83,6 @@ int main (int argc, char **argv) {
delete server; delete server;
debug (0, "* deleted server"); debug (0, "* deleted server");
debug (0, "* application exited"); debug (0, "* application exited");
return 0; return 0;
}; };

@ -117,12 +117,12 @@ void Server::ThreadProcess() {
// //
// mode manual // mode manual
else if (mode == SMODE_MANUAL) { else if (mode == SMODE_MANUAL) {
server->locomotives.Loop();
} }
// //
// mode auto // mode auto
else if (mode == SMODE_AUTO) { else if (mode == SMODE_AUTO) {
server->locomotives.Loop();
} }
gettimeofday (&tv, NULL); gettimeofday (&tv, NULL);

@ -84,6 +84,7 @@ ul.GUIcontextmenuElements {
button { button {
padding: 6px 6px 6px 6px;
background-color: var(--input-bg-color); background-color: var(--input-bg-color);
color: var(--input-fg-color); color: var(--input-fg-color);
} }

@ -1,4 +1,5 @@
<html> <html>
<meta charset="utf-8">
<head> <head>
<title>Modelbahn</title> <title>Modelbahn</title>
<script src="jquery-3.1.0.min.js"></script> <script src="jquery-3.1.0.min.js"></script>

@ -7,7 +7,7 @@ body {
:root { :root {
--top-height: 34px; --top-height: 34px;
--side-width: 37px; --side-width: 37px;
--bottom-height: 132px; --bottom-height: 2px;
--menu-bg-color: #333; --menu-bg-color: #333;
--menu-fg-color: linen; --menu-fg-color: linen;

@ -14,7 +14,7 @@ const RAILWAY_BLOCK = 8;
var track = { var track = {
size: {x: -1, y: -1}, size: {x: -1, y: -1},
scale: 24, scale: 32,
dbuf: {}, dbuf: {},
elements: [] elements: []
}; };

Loading…
Cancel
Save