forked from frc1418/2015-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUI_MainPage.html
252 lines (190 loc) · 8.46 KB
/
UI_MainPage.html
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>1418 DriverStation</title>
<script src="Resources/d3/d3.js"></script>
<script src="Resources/jquery-2.1.3.min.js"></script>
<link href="Resources/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="Resources/dist/css/bootstrap-theme.min.css" rel="stylesheet">
<script src="Resources/dist/js/bootstrap.min.js"></script>
<link type="text/css" rel="stylesheet" href="AkiUI_MainPageCSS.css"/>
</head>
<body class="UIPage">
<script src="/config.js"></script>
<script src="/networktables/networktables.js"></script>
<script src="RobotSV.js"></script>
<div class="MainDivide" id="leftSection">
<ul class="nav nav-tabs" role="tablist" id="camtab">
<li role="presentation" class="active"><a href="#frontcam-tab" aria-controls="frontcam-tab" role="tab" data-toggle="tab">Front</a></li>
<li role="presentation"><a href="#backcam-tab" aria-controls="frontcam-tab" role="tab" data-toggle="tab">Back</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="frontcam-tab">
<img id="frontcam-offline" class="webcam-img" src="Resources/CamFeedOffline.png"></img>
</div>
<div class="tab-pane" id="backcam-tab">
<img id="backcam-offline" class="webcam-img" src="Resources/CamFeedOffline.png"></img>
</div>
</div>
<img id="hammertime" src="Resources/1418-hammer.png" />
</div>
<div class="MainDivide" id="RobotDiagram">
<div class="AlloftheLevels BinButtons" id="AllofthemBins">
<button class="btn-primary" id="BinButton5" onclick="NetworkTables.setValue('/SmartDashboard/canTo',2048)">Bin Max</button>
<button class="btn-primary" id="BinButton4" onclick="NetworkTables.setValue('/SmartDashboard/canTo',4)">Bin 4</button>
<button class="btn-primary" id="BinButton3" onclick="NetworkTables.setValue('/SmartDashboard/canTo',3)">Bin 3</button>
<button class="btn-primary" id="BinButton2" onclick="NetworkTables.setValue('/SmartDashboard/canTo',2)">Bin 2</button>
<button class="btn-primary" id="BinButton1" onclick="NetworkTables.setValue('/SmartDashboard/canTo',1)">Bin 1</button>
<button class="btn-primary" id="BinButton0" onclick="NetworkTables.setValue('/SmartDashboard/canTo',0)">Bin 0</button>
</div>
<div class="Robotimg">
<img id=dog src="Resources/arrowleftred_benji_par_01.svg.thumb.png"></img>
<img id=do src="Resources/arrowrightred_benji_pa_01.svg.thumb.png"></img>
<img id=robotsv src="Resources/uirobot.png"></img>
<img id=toteArm1 src="toteArm.png"></img>
<img id=toteArm2 src="toteArm.png"></img>
<img id=toteArm3 src="toteArm.png"></img>
<img id=toteArm4 src="toteArm.png"></img>
<img id=binArm src="binArm.png"></img>
</div>
<div class="AlloftheLevels ToteButtons" id="AllofthemTotes">
<button class="btn-primary" id="ToteButton6" onclick="NetworkTables.setValue('/SmartDashboard/toteTo',6)">Tote 6</button>
<button class="btn-primary" id="ToteButton5" onclick="NetworkTables.setValue('/SmartDashboard/toteTo',5)">Tote 5</button>
<button class="btn-primary" id="ToteButton4" onclick="NetworkTables.setValue('/SmartDashboard/toteTo',4)">Tote 4</button>
<button class="btn-primary" id="ToteButton3" onclick="NetworkTables.setValue('/SmartDashboard/toteTo',3)">Tote 3</button>
<button class="btn-primary" id="ToteButton2" onclick="NetworkTables.setValue('/SmartDashboard/toteTo',2)">Tote 2</button>
<button class="btn-primary" id="ToteButton1" onclick="NetworkTables.setValue('/SmartDashboard/toteTo',1)">Tote 1</button>
<button class="btn-primary" id="ToteButton0" onclick="NetworkTables.setValue('/SmartDashboard/toteTo',0)">Tote 0</button>
</div>
</div>
<div class="MainDivide" id="AutoBox">
<button class="btn-primary SpecialButtons" id="ReverserSwitch" onclick="toggleNt('/SmartDashboard/reverseRobot')">Reverse Controls</button>
<button class="btn-primary SpecialButtons" id="AutoLifterSwitch" onclick="toggleNt('/SmartDashboard/autoLift')">Auto Lifting</button>
<button class="btn-primary SpecialButtons" id="Slo-MoSwitch" onclick="toggleNt('/SmartDashboard/slowMo')">Slow-Mo</button>
<select id="AutoPathChoice">
</select>
<div>
<input type="checkbox" id="cooperate" onclick="toggleNt('/SmartDashboard/Three Tote Hot\\cooperate'); return false" />
Cooperate
</div>
</div>
<script type="text/javascript">
"use strict";
$(document).ready(function(){
$('#camtab').tab('show');
$("div.ToteLiftLevels button").click(function() {
$("div.ToteLiftLevels button").removeClass("buttonactive");
$(this).addClass("buttonactive");
});
$("div.BinsLiftLevels button").click(function() {
$("div.BinsLiftLevels button").removeClass("buttonactive");
$(this).addClass("buttonactive");
});
var $autoSelector=$("#AutoPathChoice");
$autoSelector.change(function(event){
event.preventDefault();
//alert( $autoSelector.children(':selected').text());
var val=$autoSelector.find('option:selected').text();
//alert(val);
NetworkTables.setValue('/SmartDashboard/Autonomous Mode/selected', val);
});
// sets a function that will be called when the websocket connects/disconnects
NetworkTables.addWsConnectionListener(onNetworkTablesConnection, true);
// sets a function that will be called when the robot connects/disconnects
NetworkTables.addRobotConnectionListener(onRobotConnection, true);
// sets a function that will be called when any NetworkTables key/value changes
NetworkTables.addGlobalListener(onValueChanged, true);
});
function toggleNt(key) {
NetworkTables.setValue(key, !NetworkTables.getValue(key));
}
function updateChooser(id, key) {
var options = NetworkTables.getValue(key + '/options');
if (options === undefined)
return;
var optDefault = NetworkTables.getValue(key + '/default');
var selected = NetworkTables.getValue(key + '/selected');
var opt = d3.select(id)
.selectAll("option")
.data(options);
opt.enter()
.append("option");
opt.text(function(d,i){
return options[i];
});
opt.exit().remove();
if (selected !== undefined) {
$(id).val(selected);
} else if (optDefault !== undefined) {
$(id).val(optDefault);
}
}
// called when the robot connects/disconnects via networktables
function onRobotConnection(connected) {
// TODO: change some indicator
console.log("Robot connected: " + connected);
// make sure the camera stream isn't connected until the robot connects to us
if (connected) {
$('#frontcam-offline').hide();
$('#backcam-offline').hide();
$('#frontcam-tab').prepend('<img class="webcam-img" id="frontcam-img" src="' + Config.frontcam + '/?action=stream" />');
$('#backcam-tab').prepend('<img class="webcam-img" id="backcam-img" src="' + Config.backcam + '/?action=stream" />');
} else {
$('#frontcam-img').remove();
$('#backcam-img').remove();
$('#frontcam-offline').show();
$('#backcam-offline').show();
}
}
// called when the websocket connects/disconnects
function onNetworkTablesConnection(connected) {
// TODO: change some indicator
}
function onValueChanged(key, value, isNew) {
// key thing here: we're using the various NetworkTable keys as
// the id of the elements that we're appending, for simplicity. However,
// the key names aren't always valid HTML identifiers, so we use
// the NetworkTables.keyToId() function to convert them appropriately
//console.log(key, value);
switch (key) {
case "/SmartDashboard/Tote Forklift|Target Position":
$(".ToteButtons button").removeClass("buttonactive");
if (value != -1) {
$('#ToteButton' + value).addClass("buttonactive");
}
break;
case "/SmartDashboard/Can Forklift|Target Position":
$(".BinButtons button").removeClass("buttonactive");
if (value != -1) {
$('#BinButton' + value).addClass("buttonactive");
}
break;
case "/SmartDashboard/autoLift":
if (value)
$('#AutoLifterSwitch').addClass('buttonactive');
else
$('#AutoLifterSwitch').removeClass('buttonactive');
break;
case "/SmartDashboard/reverseRobot":
if (value)
$('#ReverserSwitch').addClass('buttonactive');
else
$('#ReverserSwitch').removeClass('buttonactive');
break;
case "/SmartDashboard/Three Tote Hot\\cooperate":
$('#cooperate').prop('checked', value);
break;
case "/SmartDashboard/Autonomous Mode/options":
case "/SmartDashboard/Autonomous Mode/default":
case "/SmartDashboard/Autonomous Mode/selected":
updateChooser('#AutoPathChoice', '/SmartDashboard/Autonomous Mode');
break;
}
// similarly, use keySelector to convert the key to a valid jQuery
// selector. This should work for class names also, not just for ids
$('#' + NetworkTables.keySelector(key)).text(value);
}
</script>
</body>
</html>