Skip to content

Commit 396dca2

Browse files
author
Valentin Heun
committed
support for multiple targets in single file
1 parent bc4f998 commit 396dca2

4 files changed

Lines changed: 244 additions & 65 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* @preserve
3+
*
4+
* .,,,;;,'''..
5+
* .'','... ..',,,.
6+
* .,,,,,,',,',;;:;,. .,l,
7+
* .,',. ... ,;, :l.
8+
* ':;. .'.:do;;. .c ol;'.
9+
* ';;' ;.; ', .dkl';, .c :; .'.',::,,'''.
10+
* ',,;;;,. ; .,' .'''. .'. .d;''.''''.
11+
* .oxddl;::,,. ', .'''. .... .'. ,:;..
12+
* .'cOX0OOkdoc. .,'. .. ..... 'lc.
13+
* .:;,,::co0XOko' ....''..'.'''''''.
14+
* .dxk0KKdc:cdOXKl............. .. ..,c....
15+
* .',lxOOxl:'':xkl,',......'.... ,'.
16+
* .';:oo:... .
17+
* .cd, ╔═╗┌─┐┬─┐┬ ┬┌─┐┬─┐ .
18+
* .l; ╚═╗├┤ ├┬┘└┐┌┘├┤ ├┬┘ '
19+
* 'l. ╚═╝└─┘┴└─ └┘ └─┘┴└─ '.
20+
* .o. ...
21+
* .''''','.;:''.........
22+
* .' .l
23+
* .:. l'
24+
* .:. .l.
25+
* .x: :k;,.
26+
* cxlc; cdc,,;;.
27+
* 'l :.. .c ,
28+
* o.
29+
* .,
30+
*
31+
* ╦ ╦┬ ┬┌┐ ┬─┐┬┌┬┐ ╔═╗┌┐ ┬┌─┐┌─┐┌┬┐┌─┐
32+
* ╠═╣└┬┘├┴┐├┬┘│ ││ ║ ║├┴┐ │├┤ │ │ └─┐
33+
* ╩ ╩ ┴ └─┘┴└─┴─┴┘ ╚═╝└─┘└┘└─┘└─┘ ┴ └─┘
34+
*
35+
* Created by Valentin on 10/22/14.
36+
* Modified by Carsten on 12/06/15.
37+
*
38+
* Copyright (c) 2015 Valentin Heun
39+
*
40+
* All ascii characters above must be included in any redistribution.
41+
*
42+
* This Source Code Form is subject to the terms of the Mozilla Public
43+
* License, v. 2.0. If a copy of the MPL was not distributed with this
44+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
45+
*/
46+
47+
/**
48+
* Set to true to enable the hardware interface
49+
**/
50+
exports.enabled = true;
51+
52+
// this needs to be true all the time otherwise the server crashes.
53+
54+
if (exports.enabled) {
55+
var server = require(__dirname + '/../../libraries/hardwareInterfaces');
56+
server.addNode("allTargetsPlaceholder", "this", "node");
57+
}

libraries/utilities.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ exports.uuidTime = function () {
120120

121121
exports.getObjectIdFromTarget = function (folderName, dirnameO) {
122122

123+
if(folderName === "allTargetsPlaceholder"){
124+
return "allTargetsPlaceholder000000000000";
125+
}
126+
123127
var xmlFile = dirnameO + '/objects/' + folderName + '/target/target.xml';
124128

125129
if (fs.existsSync(xmlFile)) {

libraries/webFrontend.js

Lines changed: 181 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -114,86 +114,183 @@ exports.printFolder = function (objects, dirnameO, debug, objectInterfaceName, o
114114
tempFiles.splice(0, 1);
115115
}
116116

117+
var allFilesOn = false;
118+
117119
for (var i = 0; i < tempFiles.length; i++) {
118-
resText += "<li class='list-group-item'>" +
119-
"<div class='row'>" +
120-
"<div class='col-xs-4'>" +
121-
"<font size='5'>" + tempFiles[i] + "</font>" +
122-
"</div>" +
123-
"<div class='col-xs-8 text-right' style='' >";
124-
125-
if (objects.hasOwnProperty(utilities.readObject(objectLookup, tempFiles[i])) && fs.existsSync(objectPath + "/" + tempFiles[i] + "/target/target.xml")) {
120+
if(tempFiles[i] === "allTargetsPlaceholder") {
121+
122+
resText += "<li class='list-group-item'>" +
123+
"<div class='row'>" +
124+
"<div class='col-xs-4'>" +
125+
"<font size='5'>single Targets File</font>" +
126+
"</div>" +
127+
"<div class='col-xs-8 text-right' style='' >";
128+
129+
if (objects.hasOwnProperty(utilities.readObject(objectLookup, tempFiles[i])) && fs.existsSync(objectPath + "/" + tempFiles[i] + "/target/target.xml")) {
130+
resText +=
131+
"<button class='btn btn-info' onclick=\"window.location.href='/info/" + tempFiles[i] + "'\" > Info</button> ";
132+
} else {
133+
resText +=
134+
"<button style='display: none;' class='btn btn-info' disabled='disabled'>Info</button> ";
135+
}
136+
137+
resText += "<button style='width:120px; position: relative; right: 262px;' class='pull-right ";
138+
if (fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.dat") && fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.xml") && fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.jpg")) {
139+
resText += "btn btn-success";
140+
} else {
141+
resText += "btn btn-primary";
142+
}
143+
144+
resText += "' onclick=\"window.location.href='/target/" + tempFiles[i] + "'\">Target</button> " +
145+
"<button style='visibility: hidden;' class='";
146+
147+
if (fs.existsSync(objectPath + '/' + tempFiles[i] + "/index.htm") || fs.existsSync(objectPath + '/' + tempFiles[i] + "/index.html")) {
148+
149+
if (fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.dat") && fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.xml") && fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.jpg")) {
150+
resText += "btn btn-success";
151+
}
152+
else {
153+
resText += "btn btn-warning";
154+
}
155+
} else {
156+
resText += "btn btn-primary";
157+
}
158+
159+
resText += "' onclick=\"window.location.href='/content/" + tempFiles[i] + "'\">Interface</button> ";
160+
161+
var thisObject = utilities.readObject(objectLookup, tempFiles[i]);
162+
163+
if (objects.hasOwnProperty(thisObject)) {
164+
165+
if (objects[thisObject].deactivated !== true) {
166+
allFilesOn = true;
167+
resText += " <button style='width:125px; position: relative; right: 13px;' class='btn btn-success pull-right'";
168+
resText += "' onclick=\"window.location.href='/object/" + thisObject + "/deactivate/'\">on</button> ";
169+
}
170+
else {
171+
allFilesOn = false;
172+
resText += " <button style='width:125px; position: relative; right: 13px;' class='btn btn-warning pull-right'";
173+
resText += "' onclick=\"window.location.href='/object/" + thisObject + "/activate/'\">off</button> ";
174+
}
175+
176+
} else {
177+
resText += " <button style='width:125px; position: relative; right: 13px;' class='btn btn-default pull-right' disabled='disabled'>off</button>";
178+
}
179+
126180
resText +=
127-
"<button class='btn btn-info' onclick=\"window.location.href='/info/" + tempFiles[i] + "'\" > Info</button> ";
128-
} else {
181+
182+
// "</div>"+
183+
// "<div class='col-xs-3'>"+
184+
185+
// " <div>" +
186+
' <button style="display: none;" class="btn btn-default" onclick="window.location.href=\'/object/' + tempFiles[i] + '/zipBackup/\'"' + tempFiles[i] + '\'" > ' +
187+
188+
'Download' +
189+
'</button> ' +
190+
" <form style='display: none; id='delete" + i + "' action='" + objectInterfaceName + "' method='post' style='margin: 0px; padding: 0px'>" +
191+
"<input type='hidden' style='display: none;' name='name' value='" + tempFiles[i] + "'>" +
192+
"<input type='hidden' style='display: none;' name='action' value='delete'>" +
193+
" <input type='submit' style='display: none;' class='btn btn-danger' value='X' onclick=\"return confirm('Do you really want to delete the object " + tempFiles[i] + "?')\">" +
194+
"</form>";
195+
129196
resText +=
130-
"<button class='btn btn-info' disabled='disabled'>Info</button> ";
197+
//" </div>"+
198+
"</div>" +
199+
"</div></li>";
200+
131201
}
132202

203+
}
133204

134-
resText += "<button class='";
135-
if (fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.dat") && fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.xml") && fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.jpg")) {
136-
resText += "btn btn-success";
137-
} else {
138-
resText += "btn btn-primary";
139-
}
205+
resText += "</ul><ul class='list-group'>";
140206

207+
for (var i = 0; i < tempFiles.length; i++) {
141208

142-
resText += "' onclick=\"window.location.href='/target/" + tempFiles[i] + "'\">Target</button> " +
143-
"<button class='";
209+
if(tempFiles[i] !== "allTargetsPlaceholder") {
144210

145-
if (fs.existsSync(objectPath + '/' + tempFiles[i] + "/index.htm") || fs.existsSync(objectPath + '/' + tempFiles[i] + "/index.html")) {
211+
resText += "<li class='list-group-item'>" +
212+
"<div class='row'>" +
213+
"<div class='col-xs-4'>" +
214+
"<font size='5'>" + tempFiles[i] + "</font>" +
215+
"</div>" +
216+
"<div class='col-xs-8 text-right' style='' >";
146217

147-
if (fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.dat") && fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.xml")&& fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.jpg")) {
148-
resText += "btn btn-success";
149-
}
150-
else {
151-
resText += "btn btn-warning";
218+
if (objects.hasOwnProperty(utilities.readObject(objectLookup, tempFiles[i])) && fs.existsSync(objectPath + "/" + tempFiles[i] + "/target/target.xml")) {
219+
resText +=
220+
"<button class='btn btn-info' onclick=\"window.location.href='/info/" + tempFiles[i] + "'\" > Info</button> ";
221+
} else {
222+
resText +=
223+
"<button class='btn btn-info' disabled='disabled'>Info</button> ";
152224
}
153-
} else {
154-
resText += "btn btn-primary";
155-
}
156225

157-
resText += "' onclick=\"window.location.href='/content/" + tempFiles[i] + "'\">Interface</button> ";
226+
resText += "<button class='";
227+
if (fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.dat") && fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.xml") && fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.jpg")) {
228+
resText += "btn btn-success'";
229+
} else {
230+
resText += "btn btn-primary'";
231+
}
158232

159-
var thisObject = utilities.readObject(objectLookup, tempFiles[i]);
160233

161-
if (objects.hasOwnProperty(thisObject)) {
162-
if(objects[thisObject].deactivated !== true) {
163-
resText += " <button class='btn btn-success'";
164-
resText += "' onclick=\"window.location.href='/object/" + thisObject+ "/deactivate/'\">on</button> ";
234+
if(allFilesOn){
235+
// resText += " disabled='disabled'";
165236
}
166-
else{
167-
resText += " <button class='btn btn-warning'";
168-
resText += "' onclick=\"window.location.href='/object/" + thisObject + "/activate/'\">off</button> ";
237+
238+
239+
resText += " onclick=\"window.location.href='/target/" + tempFiles[i] + "'\">Target</button> " +
240+
"<button class='";
241+
242+
if (fs.existsSync(objectPath + '/' + tempFiles[i] + "/index.htm") || fs.existsSync(objectPath + '/' + tempFiles[i] + "/index.html")) {
243+
244+
if (fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.dat") && fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.xml") && fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.jpg")) {
245+
resText += "btn btn-success";
246+
}
247+
else {
248+
resText += "btn btn-warning";
249+
}
250+
} else {
251+
resText += "btn btn-primary";
169252
}
170253

171-
} else {
172-
resText += " <button class='btn btn-default' disabled='disabled'>off</button>";
173-
}
254+
resText += "' onclick=\"window.location.href='/content/" + tempFiles[i] + "'\">Interface</button> ";
255+
256+
var thisObject = utilities.readObject(objectLookup, tempFiles[i]);
174257

175-
resText +=
258+
if (objects.hasOwnProperty(thisObject)) {
259+
if (objects[thisObject].deactivated !== true) {
260+
resText += " <button class='btn btn-success'";
261+
resText += "' onclick=\"window.location.href='/object/" + thisObject + "/deactivate/'\">on</button> ";
262+
}
263+
else {
264+
resText += " <button class='btn btn-warning'";
265+
resText += "' onclick=\"window.location.href='/object/" + thisObject + "/activate/'\">off</button> ";
266+
}
176267

177-
// "</div>"+
268+
} else {
269+
resText += " <button class='btn btn-default' disabled='disabled'>off</button>";
270+
}
271+
272+
resText +=
273+
274+
// "</div>"+
178275
// "<div class='col-xs-3'>"+
179276

180277
// " <div>" +
181-
' <button class="btn btn-default" onclick="window.location.href=\'/object/' + tempFiles[i] + '/zipBackup/\'"' + tempFiles[i] + '\'" > ' +
278+
' <button class="btn btn-default" onclick="window.location.href=\'/object/' + tempFiles[i] + '/zipBackup/\'"' + tempFiles[i] + '\'" > ' +
182279

183-
'Download' +
184-
'</button> ' +
185-
" <form style='display: inline; background-color: #bde9ba;' id='delete" + i + "' action='" + objectInterfaceName + "' method='post' style='margin: 0px; padding: 0px'>" +
186-
"<input type='hidden' name='name' value='" + tempFiles[i] + "'>" +
187-
"<input type='hidden' name='action' value='delete'>" +
188-
" <input type='submit' class='btn btn-danger' value='X' onclick=\"return confirm('Do you really want to delete the object " + tempFiles[i] + "?')\">" +
189-
"</form>";
280+
'Download' +
281+
'</button> ' +
282+
" <form style='display: inline; background-color: #bde9ba;' id='delete" + i + "' action='" + objectInterfaceName + "' method='post' style='margin: 0px; padding: 0px'>" +
283+
"<input type='hidden' name='name' value='" + tempFiles[i] + "'>" +
284+
"<input type='hidden' name='action' value='delete'>" +
285+
" <input type='submit' class='btn btn-danger' value='X' onclick=\"return confirm('Do you really want to delete the object " + tempFiles[i] + "?')\">" +
286+
"</form>";
190287

191-
resText +=
288+
resText +=
192289
//" </div>"+
193-
"</div>" +
194-
"</div></li>";
195-
290+
"</div>" +
291+
"</div></li>";
196292

293+
}
197294
}
198295

199296
}
@@ -580,19 +677,40 @@ exports.uploadTargetText = function (parm, objectLookup, objects) {
580677
'<body style="height:100vh; weight: 100%; background-color: #ffffff; background:repeating-linear-gradient(-45deg, #e4f6ff, #e4f6ff 5px, white 5px, white 10px);" >\n' +
581678
'<div class="container" id="container" style="width: 750px;">\n' +
582679
' <div class="panel panel-primary">\n' +
583-
' <div class="panel-heading">\n' +
584-
' <h3 class="panel-title"><font size="6">Hybrid Object - ' + parm + ' - Target&nbsp;&nbsp;&nbsp;&nbsp;<a href="../" style=" color: #ffffff; text-decoration: underline;">back</a></font></h3>\n' +
680+
' <div class="panel-heading">\n';
681+
682+
if (parm !== "allTargetsPlaceholder") {
683+
text +=
684+
' <h3 class="panel-title"><font size="6">Hybrid Object - ' + parm + ' - Target&nbsp;&nbsp;&nbsp;&nbsp;<a href="../" style=" color: #ffffff; text-decoration: underline;">back</a></font></h3>\n';
685+
} else {
686+
text +=
687+
' <h3 class="panel-title"><font size="6">Hybrid Object - single Targets File&nbsp;&nbsp;&nbsp;&nbsp;<a href="../" style=" color: #ffffff; text-decoration: underline;">back</a></font></h3>\n';
688+
}
689+
text +=
585690
' </div>\n' +
586691
' </div>\n' +
587692
' <div id="actions" class="row">\n' +
588-
' <div class="col-xs-7">\n' +
693+
' <div class="col-xs-7">\n';
694+
695+
if (parm !== "allTargetsPlaceholder") {
696+
text +=
589697
' <b>1. Upload your target source image (jpg only, < 0.5 MB)</b><br>' +
590-
' 2. Login to the Vuforia Target Manager.<br>' +
591-
' 3. Create a new or open a Device Databases.<br>' +
592-
' 4. Create a target for your Object and name it exactly:<br><b>&nbsp;&nbsp;&nbsp;&nbsp;' + objectName + '</b><br>' +
593-
' 5. Make sure that only this one Target is Activated.<br>' +
594-
' 6. Download the database and then upload it here:<br>' +
595-
' (You can just drag and drop the files anywhere in the striped area)' +
698+
' 2. Login to the Vuforia Target Manager.<br>' +
699+
' 3. Create a new or open a Device Databases.<br>' +
700+
' 4. Create a target for your Object and name it exactly:<br><b>&nbsp;&nbsp;&nbsp;&nbsp;' + objectName + '</b><br>' +
701+
' 5. Make sure that only this one Target is Activated.<br>' +
702+
' 6. Download the database and then upload it here:<br>' +
703+
' (You can just drag and drop the files anywhere in the striped area)';
704+
} else {
705+
text +=
706+
' <b>1. Upload a random jpg image (jpg only, < 0.5 MB)</b><br>' +
707+
' 2. Login to the Vuforia Target Manager.<br>' +
708+
' 3. Download a device database that includes all targets generated for your objects.<br>' +
709+
' 6. Download the database and then upload it here:<br>' +
710+
' (You can just drag and drop the files anywhere in the striped area)';
711+
}
712+
713+
text +=
596714
' </div>' +
597715
' <div class="col-xs-5">' +
598716
' ' +

server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const beatPort = 52316; // this is the port for UDP broadcasting so t
9191
const timeToLive = 2; // the amount of routers a UDP broadcast can jump. For a local network 2 is enough.
9292
const beatInterval = 5000; // how often is the heartbeat sent
9393
const socketUpdateInterval = 2000; // how often the system checks if the socket connections are still up and running.
94-
const version = "1.7.5"; // the version of this server
94+
const version = "1.7.6"; // the version of this server
9595
const protocol = "R1"; // the version of this server
9696
const netmask = "255.255.0.0"; // define the network scope from which this server is accessable.
9797
// for a local network 255.255.0.0 allows a 16 bit block of local network addresses to reach the object.
@@ -2115,7 +2115,7 @@ function objectWebServer() {
21152115

21162116
res.json(returnJSON);
21172117
});
2118-
2118+
21192119
// ****************************************************************************************************************
21202120
// post interfaces
21212121
// ****************************************************************************************************************

0 commit comments

Comments
 (0)