diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..d1b0f66 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Debug (Launch) with Arguments Prompt", + "request": "launch", + "mainClass": "celtech.roboxremote.Root", + "args": "server root.yml", + "vmArgs": "-DlibertySystems.configFile=RoboxRoot.configFile.xml" + } + ] +} \ No newline at end of file diff --git a/RoboxRoot.bat b/RoboxRoot.bat index 21660c3..d413491 100755 --- a/RoboxRoot.bat +++ b/RoboxRoot.bat @@ -1 +1 @@ -java\bin\java -Djava.net.preferIPv4Stack=true -DlibertySystems.configFile=RoboxRoot.configFile.xml -jar RoboxRemoteServer.jar server printerControl.yml +java -DlibertySystems.configFile=RoboxRoot.configFile.xml -jar target/Root.jar server root.yml diff --git a/RoboxRoot.sh b/RoboxRoot.sh index 475f440..944e7bf 100755 --- a/RoboxRoot.sh +++ b/RoboxRoot.sh @@ -1 +1 @@ -java/bin/java -Djava.net.preferIPv4Stack=true -DlibertySystems.configFile=RoboxRoot.configFile.xml -jar RoboxRemoteServer.jar server printerControl.yml +java/bin/java -DlibertySystems.configFile=RoboxRoot.configFile.xml -jar target/Root.jar server root.yml diff --git a/nologname.log.1 b/nologname.log.1 index e69de29..5f1d08b 100644 --- a/nologname.log.1 +++ b/nologname.log.1 @@ -0,0 +1,14 @@ +2023-01-01 13:09:32,654 [main] INFO - StenographerFactory initialised with logfile=nologname.log loglevel= logmode=LOCAL +>>>> ERROR loading system config (using -DlibertySystems.configFile) org.apache.commons.configuration.ConfigurationException: Cannot locate configuration source null +2023-01-01 13:09:32,983 [main] ERROR celtech.roboxbase.configuration.BaseConfiguration.loadConfigurationInstance(BaseConfiguration.java:293) - Couldn't load configuration - the application cannot derive the install directory +Exception in thread "main" +java.lang.NullPointerException + at java.base/java.io.File.(File.java:278) + at celtech.roboxbase.configuration.BaseConfiguration.getCommonApplicationDirectory(BaseConfiguration.java:398) + at celtech.roboxbase.configuration.BaseConfiguration.getApplicationPrinterDirectory(BaseConfiguration.java:419) + at celtech.roboxbase.configuration.datafileaccessors.PrinterContainer.(PrinterContainer.java:36) + at celtech.roboxbase.configuration.datafileaccessors.PrinterContainer.getCompletePrinterList(PrinterContainer.java:97) + at celtech.roboxbase.configuration.BaseConfiguration.initialise(BaseConfiguration.java:176) + at celtech.roboxremote.Root.initialize(Root.java:65) + at io.dropwizard.Application.run(Application.java:88) + at celtech.roboxremote.Root.main(Root.java:48) diff --git a/src/main/resources/assets/about.html b/src/main/resources/assets/about.html index 9089bb5..9c35672 100644 --- a/src/main/resources/assets/about.html +++ b/src/main/resources/assets/about.html @@ -50,6 +50,7 @@ + diff --git a/src/main/resources/assets/access-pin.html b/src/main/resources/assets/access-pin.html index a44d39e..ce362ff 100644 --- a/src/main/resources/assets/access-pin.html +++ b/src/main/resources/assets/access-pin.html @@ -62,6 +62,7 @@

Access PIN

+ diff --git a/src/main/resources/assets/assets/css/RoboxRoot.css b/src/main/resources/assets/assets/css/RoboxRoot.css index 197fc1b..a1a14fc 100644 --- a/src/main/resources/assets/assets/css/RoboxRoot.css +++ b/src/main/resources/assets/assets/css/RoboxRoot.css @@ -1707,3 +1707,7 @@ img.rbx-colour-button { .machine-logo { } +.camera-select-label{ + color: #009ee3; +} + diff --git a/src/main/resources/assets/assets/img/Icon-Camera.svg b/src/main/resources/assets/assets/img/Icon-Camera.svg new file mode 100644 index 0000000..4dffce4 --- /dev/null +++ b/src/main/resources/assets/assets/img/Icon-Camera.svg @@ -0,0 +1,52 @@ + +Icon-Camera + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/assets/assets/js/camera.js b/src/main/resources/assets/assets/js/camera.js new file mode 100644 index 0000000..2ecc7db --- /dev/null +++ b/src/main/resources/assets/assets/js/camera.js @@ -0,0 +1,59 @@ +var cameraprofilejson; +var cameras; +function cameraInit() +{ + $('#left-button').on('click', goToPreviousPage); + $("#selectcamera").on('change', changeCamera); + GetCameraProfile(); +} + +function GetCameraProfile(){ + promiseGetCommandToRoot('discovery/listCameras', null) + .then(function(result) + { + if(result.cameras.length){ + cameras = result.cameras; + + if(cameras.length > 1){ + var select = $("#selectcamera"); + $("#camera-select-panel").removeClass("hidden"); + cameras.forEach(element => { + var opt = document.createElement('option'); + opt.value = element.cameraNumber; + opt.innerHTML = `${element.cameraNumber} : ${element.cameraName}`; + select[0].appendChild(opt); + }); + } + loadCamera(cameras[0].cameraNumber); + } + else{ + $("#no-cameras").removeClass("hidden"); + } + }); +} + +function loadCamera(cameranumber){ + var camera = cameras.find(camera => camera.cameraNumber === Number(cameranumber));; + cameraprofilejson = {"profile":{},"camera":{"udevName":camera.udevName,"cameraName":camera.cameraName,"cameraNumber":camera.cameraNumber,"serverIP":""}} + loadFrame(); +} + +function loadFrame(){ + if(cameraprofilejson){ + promisePostCommandToRoot(`cameraControl/${cameraprofilejson.camera.cameraNumber}/snapshot`, cameraprofilejson, true) + .then(function(result) + { + var reader = new FileReader(); + reader.onload = function() { + var b64 = reader.result + document.getElementById("camerapreview").src = b64 + loadFrame(); + } + reader.readAsDataURL(result) + }); + } +} + +function changeCamera(){ + loadCamera($("#selectcamera").find(":selected").val()); +} diff --git a/src/main/resources/assets/assets/js/jquery.binary.js b/src/main/resources/assets/assets/js/jquery.binary.js new file mode 100644 index 0000000..728b995 --- /dev/null +++ b/src/main/resources/assets/assets/js/jquery.binary.js @@ -0,0 +1,42 @@ +// use this transport for "binary" data type +$.ajaxTransport("+binary", function(options, originalOptions, jqXHR){ + // check for conditions and support for blob / arraybuffer response type + if (window.FormData && ((options.dataType && (options.dataType == 'binary')) || (options.data && ((window.ArrayBuffer && options.data instanceof ArrayBuffer) || (window.Blob && options.data instanceof Blob))))) + { + return { + // create new XMLHttpRequest + send: function(headers, callback){ + // setup all variables + var xhr = new XMLHttpRequest(), + url = options.url, + type = options.type, + async = options.async || true, + // blob or arraybuffer. Default is blob + dataType = options.responseType || "blob", + data = options.data || null, + username = options.username || null, + password = options.password || null; + + xhr.addEventListener('load', function(){ + var data = {}; + data[options.dataType] = xhr.response; + // make callback and send data + callback(xhr.status, xhr.statusText, data, xhr.getAllResponseHeaders()); + }); + + xhr.open(type, url, async, username, password); + + // setup custom headers + for (var i in headers ) { + xhr.setRequestHeader(i, headers[i] ); + } + + xhr.responseType = dataType; + xhr.send(data); + }, + abort: function(){ + jqXHR.abort(); + } + }; + } +}); diff --git a/src/main/resources/assets/assets/js/page-init.js b/src/main/resources/assets/assets/js/page-init.js index 1f3f773..3f77fb4 100644 --- a/src/main/resources/assets/assets/js/page-init.js +++ b/src/main/resources/assets/assets/js/page-init.js @@ -1,5 +1,6 @@ var pageInitMap = {'about':aboutInit, 'access-pin':accessPINInit, + 'camera':cameraInit, 'console':consoleInit, 'head-eeprom':headEEPromInit, 'home':homeInit, diff --git a/src/main/resources/assets/assets/js/promise-funcs.js b/src/main/resources/assets/assets/js/promise-funcs.js index 0dc9a31..c91a0f0 100644 --- a/src/main/resources/assets/assets/js/promise-funcs.js +++ b/src/main/resources/assets/assets/js/promise-funcs.js @@ -1,4 +1,4 @@ -function promiseCommandToRoot(requestType, service, dataToSend) +function promiseCommandToRoot(requestType, service, dataToSend, isBinary) { return new Promise(function(resolve, reject) { @@ -13,6 +13,8 @@ function promiseCommandToRoot(requestType, service, dataToSend) }, contentType: 'application/json', // send as JSON type: requestType, + dataType: isBinary ? "binary" : "", + processData: !isBinary, success:function (data, textStatus, jqXHR) { resolve(data); @@ -47,7 +49,7 @@ function promiseGetCommandToRoot(service, dataToSend) return promiseCommandToRoot('GET', service, dataToSend); } -function promisePostCommandToRoot(service, dataToSend) +function promisePostCommandToRoot(service, dataToSend, isBinary) { - return promiseCommandToRoot('POST', service, dataToSend); + return promiseCommandToRoot('POST', service, dataToSend, isBinary); } diff --git a/src/main/resources/assets/camera.html b/src/main/resources/assets/camera.html new file mode 100644 index 0000000..6e1ba0c --- /dev/null +++ b/src/main/resources/assets/camera.html @@ -0,0 +1,76 @@ + + + + + + + Robox :: Camera + + + + + + + + + + +
+
+
+

Camera Preview

+
+
+
+ +
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/assets/console.html b/src/main/resources/assets/console.html index d5755b6..436f88e 100644 --- a/src/main/resources/assets/console.html +++ b/src/main/resources/assets/console.html @@ -65,6 +65,7 @@ + diff --git a/src/main/resources/assets/control.html b/src/main/resources/assets/control.html index 524d1dc..2f7a07e 100644 --- a/src/main/resources/assets/control.html +++ b/src/main/resources/assets/control.html @@ -92,6 +92,7 @@

Heat

+ diff --git a/src/main/resources/assets/error.html b/src/main/resources/assets/error.html index 2046446..334778c 100644 --- a/src/main/resources/assets/error.html +++ b/src/main/resources/assets/error.html @@ -56,6 +56,7 @@ + diff --git a/src/main/resources/assets/head-eeprom.html b/src/main/resources/assets/head-eeprom.html index fd044a9..b3dfad8 100644 --- a/src/main/resources/assets/head-eeprom.html +++ b/src/main/resources/assets/head-eeprom.html @@ -57,7 +57,7 @@

H
-

 

+

 

@@ -190,6 +190,7 @@

H + diff --git a/src/main/resources/assets/home.html b/src/main/resources/assets/home.html index 9ca9a43..907833b 100644 --- a/src/main/resources/assets/home.html +++ b/src/main/resources/assets/home.html @@ -160,6 +160,7 @@

°C< + diff --git a/src/main/resources/assets/index.html b/src/main/resources/assets/index.html index d907b3f..5a8dc5e 100644 --- a/src/main/resources/assets/index.html +++ b/src/main/resources/assets/index.html @@ -46,6 +46,7 @@ + diff --git a/src/main/resources/assets/job-progress.html b/src/main/resources/assets/job-progress.html index 12bbd7b..573c415 100644 --- a/src/main/resources/assets/job-progress.html +++ b/src/main/resources/assets/job-progress.html @@ -72,6 +72,7 @@

 

+ diff --git a/src/main/resources/assets/locales/en/translation.json b/src/main/resources/assets/locales/en/translation.json index 8019fd7..80a798d 100644 --- a/src/main/resources/assets/locales/en/translation.json +++ b/src/main/resources/assets/locales/en/translation.json @@ -9,6 +9,8 @@ "axis-testing":"Test Axis/Speed", "b":"B", "bed-temp":"Bed", + "camera-title": "Camera Preview", + "camera-select-label": "Select Camera", "clean-nozzle-right":"Clean Right Nozzle", "clean-nozzle-left":"Clean Left Nozzle", "clean-nozzle-description":"Please wait while the nozzle is cleaned.", diff --git a/src/main/resources/assets/locales/fr/translation.json b/src/main/resources/assets/locales/fr/translation.json index 7ff8c15..5cc0742 100644 --- a/src/main/resources/assets/locales/fr/translation.json +++ b/src/main/resources/assets/locales/fr/translation.json @@ -9,6 +9,7 @@ "axis-testing":"FRTest Axis/Speed", "b":"FRB", "bed-temp":"FRBed", + "camera-title": "FRCamera Preview", "clean-nozzle-right":"FRClean Right Nozzle", "clean-nozzle-left":"FRClean Left Nozzle", "clean-nozzle-description":"FRPlease wait while the nozzle is cleaned.", diff --git a/src/main/resources/assets/login.html b/src/main/resources/assets/login.html index 6799cbc..7d90cfa 100644 --- a/src/main/resources/assets/login.html +++ b/src/main/resources/assets/login.html @@ -60,6 +60,7 @@

Login

+ diff --git a/src/main/resources/assets/menu-grid.html b/src/main/resources/assets/menu-grid.html index 6f709d3..9a2fc21 100644 --- a/src/main/resources/assets/menu-grid.html +++ b/src/main/resources/assets/menu-grid.html @@ -30,7 +30,7 @@