summaryrefslogtreecommitdiffstats
path: root/Kod/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'Kod/scripts')
-rw-r--r--Kod/scripts/display_bars.m63
-rw-r--r--Kod/scripts/display_graphs.m69
-rw-r--r--Kod/scripts/display_post_race_graphs.m66
3 files changed, 198 insertions, 0 deletions
diff --git a/Kod/scripts/display_bars.m b/Kod/scripts/display_bars.m
new file mode 100644
index 0000000..2f3fbe8
--- /dev/null
+++ b/Kod/scripts/display_bars.m
@@ -0,0 +1,63 @@
+addpath display/ClientServerApp/Release
+cd display/ClientServerApp/Release
+!startServer
+cd ../../..
+
+pause(1);
+
+% values1 = [1 1 2 3 4 5 6 7 8];
+values1 = [];
+values2 = [1 1.5 2 2.5 3 3.5 4 4.5 5];
+
+matlabclient(1, get_smallpackage(put_text(160, 8, 'C', 'Genomsnittlig tid per segment')))
+pause(0.2);
+
+% input('');
+matlabclient(1, get_smallpackage([ ...
+ toggle(0 , 216, 107, 240, 51, 61, 'C', 'Varv'), ...
+ toggle(107, 216, 213, 240, 52, 62, 'C', 'Segment'), ...
+ toggle(213, 216, 320, 240, 53, 63, 'C', 'Knapp 3'), ...
+ get_package('AP', [52 1]) ...
+]));
+pause(0.2);
+
+matlabclient(1, get_smallpackage([ ...
+ draw_line(20, 24, 20, 200), ... % y-axis
+ continue_line(304, 200), ... % x-axis
+ draw_line(16, 32, 20, 24), ... % arrow on y, left part
+ continue_line(24, 32), ... % arrow on y, right part
+ draw_line(304, 196, 304, 204) ... % line on x
+]));
+pause(0.2);
+
+[bars, max_val, min_y, max_height] = get_bars_from_values(values1, values2);
+
+for bar = bars
+ matlabclient(1, get_smallpackage(fill_area(bar.x_lo, bar.y_lo, bar.x_hi, bar.y_hi)));
+ pause(0.2);
+end
+
+matlabclient(1, get_smallpackage(put_text(9, 25, 'C', 's')));
+pause(0.2);
+
+% matlabclient(1, get_smallpackage(set_line_pattern(2)))
+% pause(0.2);
+for i = 1:floor(max_val)
+ x = 20;
+ y = 200 - round(max_height * (i/max_val));
+ matlabclient(1, get_smallpackage([draw_line(x, y, 300, y), ...
+ put_text(x-6, y-2, 'C', num2str(i))]))
+ pause(0.2);
+end
+% matlabclient(1, get_smallpackage(set_line_pattern(1)))
+% pause(0.2);
+
+for i = 0:8
+ x = 16+13 + 10 + 30*i;
+ matlabclient(1, get_smallpackage(put_text(x, 204, 'C', num2str(i + 1))));
+ pause(0.2);
+end
+
+pause(0.8);
+
+matlabclient(3) \ No newline at end of file
diff --git a/Kod/scripts/display_graphs.m b/Kod/scripts/display_graphs.m
new file mode 100644
index 0000000..a6e8f1c
--- /dev/null
+++ b/Kod/scripts/display_graphs.m
@@ -0,0 +1,69 @@
+addpath display/ClientServerApp/Release
+cd display/ClientServerApp/Release
+!startServer
+cd ../../..
+
+pause(1);
+
+display = struct;
+display.data = [];
+display.out = 0;
+display.shm = 0;
+display.shm_interp = struct;
+display.shm_interp.ack = 0;
+display.shm_interp.start_code = '';
+display.shm_interp.data = [];
+display.last_send = tic;
+display.send_interval = 0.5;
+
+graphs = struct;
+graphs.car1 = struct;
+graphs.car2 = struct;
+graphs.car1.lap_times = []; % Nx1
+graphs.car1.lap_deviation = std(graphs.car1.lap_times);
+graphs.car1.seg_times = []; % 9xM
+graphs.car2.lap_times = []; % Nx1
+graphs.car2.lap_deviation = std(graphs.car2.lap_times);
+graphs.car2.seg_times = []; % 9xM
+graphs.laps = max(length(graphs.car1.lap_times), length(graphs.car2.lap_times));
+
+disp('Drawing frame');
+% input('');
+matlabclient(1, get_smallpackage([ ...
+ line(32, 32, 32, 192), ... % y-axis
+ continue_line(298, 192), ... % x-axis
+ line(28, 40, 32, 32), ... % arrow on y
+ continue_line(36, 40), ... % arrow on y
+ line(298, 188, 298, 196) ... % line on x
+]));
+pause(0.2);
+
+disp('Drawing additional frames');
+% input('');
+matlabclient(1, get_smallpackage([ ...
+ line(190, 0, 190, 70), ...
+ continue_line(320, 70) ...
+]));
+pause(0.2);
+
+disp('Putting text');
+% input('');
+matlabclient(1, get_smallpackage([
+ text(304, 10, 'R', 'std: 0.15s'), ...
+ text(304, 30, 'R', 'mean: 12.4s'), ...
+ text(304, 50, 'R', 'target: 12.5s') ...
+]));
+pause(0.2);
+
+disp('Drawing buttons');
+% input('');
+matlabclient(1, get_smallpackage([ ...
+ key(0 , 216, 107, 240, 51, 61, 'C', 'Knapp 1'), ...
+ key(107, 216, 213, 240, 52, 62, 'C', 'Knapp 2'), ...
+ key(213, 216, 320, 240, 53, 63, 'C', 'Knapp 3') ...
+]))
+pause(0.2);
+
+disp('');
+% input('');
+matlabclient(3);
diff --git a/Kod/scripts/display_post_race_graphs.m b/Kod/scripts/display_post_race_graphs.m
new file mode 100644
index 0000000..77336ce
--- /dev/null
+++ b/Kod/scripts/display_post_race_graphs.m
@@ -0,0 +1,66 @@
+clear all;
+
+addpath display/ClientServerApp/Release
+cd display/ClientServerApp/Release
+!startServer
+cd ../../..
+
+pause(1);
+
+matlabclient(1, get_smallpackage([ ...
+ key(0 , 216, 107, 240, 51, 61, 'C', 'Varv'), ...
+ key(107, 216, 213, 240, 52, 62, 'C', 'Segment'), ...
+ key(213, 216, 320, 240, 53, 63, 'C', 'Avsluta') ...
+]));
+pause(0.2);
+
+%% CHECK DISPLAY BUTTONS
+display.last_check = tic;
+done = false;
+
+laptime_1 = [12 12.1 12.2 12.3 12.4 12.5 12.6 12.7 12.8 12.9 13];
+laptime_2 = [11 11.2 11.4 11.6 11.8 12 12.5 13 13.5 14 14.2 14.6 14.8 15];
+
+while 1
+ pause(0.1);
+ if toc(display.last_check) > 0.4
+ display.last_check = tic;
+
+ % read internal mem from last send
+ [display.out, display.shm] = matlabclient(2);
+ [display.shm_interp.ack, display.shm_interp.start_code, display.shm_interp.data] = get_response(display.shm);
+
+ % request internal mem
+ matlabclient(1, hex2dec(['12'; '01'; '53'; '66']));
+ if isempty(display.shm_interp.data)
+ continue;
+ end
+ update_ref_time = false;
+ for i = 1:length(display.shm_interp.data)
+ disp(num2str(length(display.shm_interp.data)))
+ data = display.shm_interp.data(i);
+ if data.data == 51
+ draw_lap_graph(laptime_1, laptime_2, 13, false);
+ elseif data.data == 52
+ draw_segment_bars([1 2 3 4 5 6 7 8 9], [9 8 7 6 5 4 3 2 1]);
+ elseif data.data == 53
+ pause(0.2);
+ matlabclient(1, get_smallpackage(clear_display()));
+ pause(0.2);
+ done = true;
+ elseif data.data == 70
+ draw_lap_graph(laptime_1, laptime_2, 13, true);
+ end
+ end
+ if done == true
+ break
+ end
+ if update_ref_time == true
+ pause(0.4);
+ matlabclient(1, get_smallpackage(put_text(160, 120, 'C', num2str(ref_time, '%.1f'))));
+ end
+ display.last_check = tic;
+ end
+end
+
+matlabclient(3);