Commit 11fbd58a authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Add traces path to ini file.

Small trace related stuff
parent 2d3db21c
/*
Copyright Jeroen Vreeken (jeroen@vreeken.net), 2014
Copyright Stichting C.A. Muller Radioastronomiestation, 2007, 2008, 2011
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -100,7 +99,7 @@ int main(int argc, char **argv)
printf("Connection ready for tracing\n");
if (interval) {
if (interval > 0) {
nsec_interval = t_int.tv_sec * 1000000000;
nsec_interval += t_int.tv_nsec;
......@@ -115,7 +114,15 @@ int main(int argc, char **argv)
trace_packet_write(trace, pkt);
trace_packet_write_fd(fd_file, pkt);
trace_packet_put(pkt);
} else if (interval < 0) {
pkt = trace_packet_new();
trace_packet_interval_set(pkt,
&t_int, TRACE_INTERVAL_TYPE_CHANGED);
trace_packet_write(trace, pkt);
trace_packet_write_fd(fd_file, pkt);
trace_packet_put(pkt);
}
pkt = trace_packet_new();
trace_packet_name_set(pkt, tracename);
......
......@@ -26,6 +26,7 @@ static char *controller_host = "localhost";
static char *console_host = "localhost";
static char *log_path = "/var/log/dt/";
static char *htdocs_path = "/var/www/htdocs/";
static char *traces_path = "/var/log/dt/traces/";
static unsigned short htdocs_port = 80;
static bool init_done = false;
......@@ -82,6 +83,10 @@ static int load_config(void)
htdocs_port =
g_key_file_get_integer(keyfile, groups[i], "port", NULL);
}
if (g_key_file_has_key(keyfile, groups[i], "traces", NULL)) {
traces_path = strdup(
g_key_file_get_string(keyfile, groups[i], "traces", NULL));
}
}
}
......@@ -127,6 +132,14 @@ char *dt_host_htdocs_path(void)
return htdocs_path;
}
char *dt_host_traces_path(void)
{
if (!init_done)
load_config();
return traces_path;
}
unsigned short dt_host_htdocs_port(void)
{
if (!init_done)
......
......@@ -24,6 +24,7 @@ char *dt_host_console(void);
char *dt_host_controller(void);
char *dt_host_log_path(void);
char *dt_host_htdocs_path(void);
char *dt_host_traces_path(void);
unsigned short dt_host_htdocs_port(void);
#endif /* _INCLUDE_DT_HOST_H_ */
......@@ -26,6 +26,7 @@
#include <libwebsockets.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <dt_port_numbers.h>
......@@ -168,7 +169,7 @@ void ws_client_flush(struct ws_client *client)
}
}
#define MAX_POLL_ELEMENTS 256
#define MAX_POLL_ELEMENTS 1024
struct pollfd pollfds[MAX_POLL_ELEMENTS];
int count_pollfds = 0;
......@@ -361,7 +362,7 @@ static int status_remove(struct libwebsocket *wsi)
}
#define MAX_TRACE_ELEMENTS 256
#define MAX_TRACE_ELEMENTS 1024
struct trace *traces[MAX_TRACE_ELEMENTS];
int count_traces = 0;
......@@ -757,16 +758,23 @@ static int callback_http(struct libwebsocket_context *context,
if (strcmp(requested_uri, "/") == 0) {
requested_uri = "/index.html";
}
char *cwd = dt_host_htdocs_path();
char *cwd;
if (strncmp(requested_uri, "/traces", 7) == 0) {
cwd = dt_host_traces_path();
requested_uri += 7;
} else {
cwd = dt_host_htdocs_path();
}
char *resource_path;
struct stat statbuf;
resource_path = malloc(strlen(cwd) + strlen(requested_uri) + 1);
sprintf(resource_path, "%s%s", cwd, requested_uri);
printf("resource path: %s\n", resource_path);
stat(resource_path, &statbuf);
if (resource_path[strlen(resource_path)-1] == '/') {
if (S_ISDIR(statbuf.st_mode)) {
r = list_dir(context, wsi, requested_uri, resource_path);
} else if (!strcmp(
resource_path + strlen(resource_path) - strlen(".cgi"),
......
......@@ -34,8 +34,8 @@ for tr in $TR; do
mv -f ${tr} ${tr}.1
done
screen -S console -X screen -t trace_az_pos ../../common/trace/trace2file localhost 10000 Azimuth_Position traces/Azimuth_Position.trace 250
screen -S console -X screen -t trace_az_pos ../../common/trace/trace2file localhost 10000 Elevation_Position traces/Elevation_Position.trace 250
screen -S console -X screen -t trace_az_pos ../../common/trace/trace2file localhost 10000 Azimuth_Speed traces/Azimuth_Speed.trace 250
screen -S console -X screen -t trace_az_pos ../../common/trace/trace2file localhost 10000 Elevation_Speed_Right traces/Elevation_Speed_Right.trace 250
screen -S console -X screen -t trace_az_pos ../../common/trace/trace2file localhost 10000 Elevation_Speed_Left traces/Elevation_Speed_Left.trace 250
screen -S console -X screen -t trace_az_pos ../../common/trace/trace2file localhost 10000 Azimuth_Position traces/Azimuth_Position.trace 15000
screen -S console -X screen -t trace_az_pos ../../common/trace/trace2file localhost 10000 Elevation_Position traces/Elevation_Position.trace 15000
screen -S console -X screen -t trace_az_pos ../../common/trace/trace2file localhost 10000 Azimuth_Speed traces/Azimuth_Speed.trace 15000
screen -S console -X screen -t trace_az_pos ../../common/trace/trace2file localhost 10000 Elevation_Speed_Right traces/Elevation_Speed_Right.trace 15000
screen -S console -X screen -t trace_az_pos ../../common/trace/trace2file localhost 10000 Elevation_Speed_Left traces/Elevation_Speed_Left.trace 15000
......@@ -11,9 +11,7 @@
<div id="trace_win"></div>
</head>
<body>
<div id="graphdiv"></div>
</body>
......@@ -31,13 +29,17 @@ tw.title_set("Trace");
var graph = new dt_ui_element("trace_win_graph");
var tsel = new dt_ui_select("trace_win_select");
var tlabel = new dt_ui_element("trace_win_label");
tw.add([ graph, tsel, tlabel ]);
tw.add([ graph, tsel ]);
tlabel.text_set("Select trace...");
graph.width_set(700);
graph.height_set(350);
graph.width_set(window.innerWidth - 60);
graph.height_set(window.innerHeight - 200);
tw.align_vertical([ tsel, tlabel, graph ]);
tw.align_vertical([ tsel, graph ]);
var traces_url = "/traces/";
......@@ -53,6 +55,8 @@ for (i = 0; i < traces_links.length; i++)
function load_trace(tracename)
{
tlabel.text_set("Loading " + tracename + " ...");
load_bin(tracename, function(buf) {
var ts = new trace_stream();
var got_time = false;
......@@ -86,9 +90,6 @@ function load_trace(tracename)
var graph_data = new Array();
for (i = 0; i < trace_data.length; i++) {
console.log(i+": " + trace_data[i].t.sec + "." +
trace_data[i].t.nsec + " " + trace_data[i].value);
var td = new Array();
td.push(new Date(trace_data[i].t.ms_get()));
......@@ -102,6 +103,7 @@ function load_trace(tracename)
graph_data,
{ labels: [ "x", ts.name ] }
);
tlabel.text_set("Viewing " + tracename);
});
}
......
../console/traces
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment