diff --git a/api-example.sh b/api-example.sh new file mode 100644 index 0000000000..961fd93f78 --- /dev/null +++ b/api-example.sh @@ -0,0 +1,11 @@ +curl -X POST http://localhost:8888/api/service \ + -d '{"name":"i01.chatBot","method":"getResponse","data":["grog", "hi there!"]}' + +curl -X POST http://localhost:8888/api/service/i01.chatBot/getResponse \ + -d '["grog", "hi there!"]' + +curl -X POST http://localhost:8888/api/service/i01.chatBot/setCurrentBotName \ + -d '["ru-RU"]' + + + diff --git a/src/main/java/org/myrobotlab/service/Gpt3.java b/src/main/java/org/myrobotlab/service/Gpt3.java index 93e4404b3c..b7b3308d64 100644 --- a/src/main/java/org/myrobotlab/service/Gpt3.java +++ b/src/main/java/org/myrobotlab/service/Gpt3.java @@ -109,6 +109,8 @@ public Response getResponse(String text) { HttpClient http = (HttpClient) startPeer("http"); + log.info("curl {} -d '{}'", c.url, json); + String msg = http.postJson(c.token, c.url, json); Map payload = CodecUtils.fromJson(msg, new StaticType<>() {}); diff --git a/src/main/java/org/myrobotlab/service/InMoov2.java b/src/main/java/org/myrobotlab/service/InMoov2.java index 3f34588a7c..c971d94147 100644 --- a/src/main/java/org/myrobotlab/service/InMoov2.java +++ b/src/main/java/org/myrobotlab/service/InMoov2.java @@ -115,7 +115,7 @@ public Heartbeat(InMoov2 inmoov) { * This method will load a python file into the python interpreter. * * @param file - * file to load + * file to load * @return success/failure */ @Deprecated /* use execScript - this doesn't handle resources correctly */ @@ -262,8 +262,7 @@ public InMoov2Config apply(InMoov2Config c) { super.apply(c); try { - locales = Locale.getLocaleMap("en-US", "fr-FR", "es-ES", "de-DE", "nl-NL", "pl-PL", "ru-RU", "hi-IN", "it-IT", - "fi-FI", "pt-PT", "tr-TR"); + locales = Locale.getLocaleMap("en-US", "fr-FR", "es-ES", "de-DE", "nl-NL", "pl-PL", "ru-RU", "hi-IN", "it-IT", "fi-FI", "pt-PT", "tr-TR"); if (c.locale != null) { setLocale(c.locale); @@ -273,9 +272,28 @@ public InMoov2Config apply(InMoov2Config c) { // one way sync configuration into predicates configToPredicates(); + execScript(); + + loadAppsScripts(); + + loadInitScripts(); + + if (c.loadGestures) { + loadGestures(); + } + + if (c.heartbeat) { + startHeartbeat(); + } else { + stopHeartbeat(); + } + + // one way sync configuration into predicates + configToPredicates(); + } catch (Exception e) { error(e); - } + } return c; } @@ -627,6 +645,13 @@ public void disable() { sendToPeer("torso", "disable"); } + public void disableRandom() { + Random random = (Random) getPeer("random"); + if (random != null) { + random.disable(); + } + } + public void displayFullScreen(String src) { try { if (imageDisplay == null) { @@ -649,13 +674,6 @@ public void enableRandomHead() { } } - public void disableRandom() { - Random random = (Random) getPeer("random"); - if (random != null) { - random.disable(); - } - } - public void enable() { sendToPeer("head", "enable"); sendToPeer("rightHand", "enable"); @@ -686,7 +704,7 @@ public boolean exec(String pythonCode) { * This method will try to launch a python command with error handling * * @param gesture - * the gesture + * the gesture * @return gesture result */ public String execGesture(String gesture) { @@ -721,7 +739,7 @@ public void execScript() { * a filesystem file :P * * @param someScriptName - * execute a resource script + * execute a resource script * @return success or failure */ public void execScript(String someScriptName) { @@ -970,7 +988,7 @@ public void loadGestures() { * file should contain 1 method definition that is the same as the filename. * * @param directory - * - the directory that contains the gesture python files. + * - the directory that contains the gesture python files. * @return true/false */ public boolean loadGestures(String directory) { @@ -1069,8 +1087,7 @@ public void moveHand(String which, Double thumb, Double index, Double majeure, D moveHand(which, thumb, index, majeure, ringFinger, pinky, null); } - public void moveHand(String which, Double thumb, Double index, Double majeure, Double ringFinger, Double pinky, - Double wrist) { + public void moveHand(String which, Double thumb, Double index, Double majeure, Double ringFinger, Double pinky, Double wrist) { invoke("publishMoveHand", which, thumb, index, majeure, ringFinger, pinky, wrist); } @@ -1122,10 +1139,8 @@ public void moveLeftHand(Double thumb, Double index, Double majeure, Double ring moveHand("left", thumb, index, majeure, ringFinger, pinky, wrist); } - public void moveLeftHand(Integer thumb, Integer index, Integer majeure, Integer ringFinger, Integer pinky, - Integer wrist) { - moveHand("left", (double) thumb, (double) index, (double) majeure, (double) ringFinger, (double) pinky, - (double) wrist); + public void moveLeftHand(Integer thumb, Integer index, Integer majeure, Integer ringFinger, Integer pinky, Integer wrist) { + moveHand("left", (double) thumb, (double) index, (double) majeure, (double) ringFinger, (double) pinky, (double) wrist); } public void moveRightArm(Double bicep, Double rotate, Double shoulder, Double omoplate) { @@ -1136,10 +1151,8 @@ public void moveRightHand(Double thumb, Double index, Double majeure, Double rin moveHand("right", thumb, index, majeure, ringFinger, pinky, wrist); } - public void moveRightHand(Integer thumb, Integer index, Integer majeure, Integer ringFinger, Integer pinky, - Integer wrist) { - moveHand("right", (double) thumb, (double) index, (double) majeure, (double) ringFinger, (double) pinky, - (double) wrist); + public void moveRightHand(Integer thumb, Integer index, Integer majeure, Integer ringFinger, Integer pinky, Integer wrist) { + moveHand("right", (double) thumb, (double) index, (double) majeure, (double) ringFinger, (double) pinky, (double) wrist); } public void moveTorso(Double topStom, Double midStom, Double lowStom) { @@ -1168,7 +1181,7 @@ public PredicateEvent onChangePredicate(PredicateEvent event) { * comes in from runtime which owns the config list * * @param configList - * list of configs + * list of configs */ public void onConfigList(List configList) { this.configList = configList; @@ -1197,12 +1210,23 @@ public void onErrors(List log) { errors.addAll(log); } + @Deprecated /* use onConfigFinished */ public void onFinishedConfig(String configName) { log.info("onFinishedConfig"); - // invoke("publishEvent", "configFinished"); invoke("publishConfigFinished", configName); } + public void onConfigFinished(String configName) { + log.info("onConfigFinished"); + invoke("publishConfigFinished", configName); + } + + public void onConfigStarted(String configName) { + log.info("onConfigStarted"); + invoke("publishConfigStarted", configName); + } + + public void onGestureStatus(Status status) { if (!status.equals(Status.success()) && !status.equals(Status.warn("Python process killed !"))) { error("I cannot execute %s, please check logs", lastGestureExecuted); @@ -1236,6 +1260,23 @@ public void onJoystickInput(JoystickData input) throws Exception { invoke("publishEvent", "joystick"); } + /** + * Centralized logging system will have all logging from all services, + * including lower level logs that do not propegate as statuses + * + * @param log + * - flushed log from Log service + */ + public void onLogEvents(List log) { + // scan for warn or errors + for (LogEntry entry : log) { + if ("ERROR".equals(entry.level) && errors.size() < 100) { + errors.add(entry); + // invoke("publishError", entry); + } + } + } + public String onNewState(String state) { log.error("onNewState {}", state); @@ -1421,7 +1462,7 @@ public void powerUp() { } public void processMessage(String method) { - processMessage(method, null); + processMessage(method, (Object[]) null); } /** @@ -1593,8 +1634,7 @@ public Message publishMessage(Message msg) { return msg; } - public HashMap publishMoveArm(String which, Double bicep, Double rotate, Double shoulder, - Double omoplate) { + public HashMap publishMoveArm(String which, Double bicep, Double rotate, Double shoulder, Double omoplate) { HashMap map = new HashMap<>(); map.put("bicep", bicep); map.put("rotate", rotate); @@ -1608,8 +1648,7 @@ public HashMap publishMoveArm(String which, Double bicep, Double return map; } - public HashMap publishMoveHand(String which, Double thumb, Double index, Double majeure, - Double ringFinger, Double pinky, Double wrist) { + public HashMap publishMoveHand(String which, Double thumb, Double index, Double majeure, Double ringFinger, Double pinky, Double wrist) { HashMap map = new HashMap<>(); map.put("which", which); map.put("thumb", thumb); @@ -1626,8 +1665,7 @@ public HashMap publishMoveHand(String which, Double thumb, Doubl return map; } - public HashMap publishMoveHead(Double neck, Double rothead, Double eyeX, Double eyeY, Double jaw, - Double rollNeck) { + public HashMap publishMoveHead(Double neck, Double rothead, Double eyeX, Double eyeY, Double jaw, Double rollNeck) { HashMap map = new HashMap<>(); map.put("neck", neck); map.put("rothead", rothead); @@ -1647,8 +1685,7 @@ public HashMap publishMoveLeftArm(Double bicep, Double rotate, D return map; } - public HashMap publishMoveLeftHand(Double thumb, Double index, Double majeure, Double ringFinger, - Double pinky, Double wrist) { + public HashMap publishMoveLeftHand(Double thumb, Double index, Double majeure, Double ringFinger, Double pinky, Double wrist) { HashMap map = new HashMap<>(); map.put("thumb", thumb); map.put("index", index); @@ -1668,8 +1705,7 @@ public HashMap publishMoveRightArm(Double bicep, Double rotate, return map; } - public HashMap publishMoveRightHand(Double thumb, Double index, Double majeure, Double ringFinger, - Double pinky, Double wrist) { + public HashMap publishMoveRightHand(Double thumb, Double index, Double majeure, Double ringFinger, Double pinky, Double wrist) { HashMap map = new HashMap<>(); map.put("thumb", thumb); map.put("index", index); @@ -1851,8 +1887,7 @@ public void setAutoDisable(Boolean param) { } @Override - public void setConfigValue(String fieldname, Object value) - throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { + public void setConfigValue(String fieldname, Object value) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { super.setConfigValue(fieldname, value); setPredicate(fieldname, value); } @@ -1861,8 +1896,7 @@ public void setHandSpeed(String which, Double thumb, Double index, Double majeur setHandSpeed(which, thumb, index, majeure, ringFinger, pinky, null); } - public void setHandSpeed(String which, Double thumb, Double index, Double majeure, Double ringFinger, Double pinky, - Double wrist) { + public void setHandSpeed(String which, Double thumb, Double index, Double majeure, Double ringFinger, Double pinky, Double wrist) { InMoov2Hand hand = getHand(which); if (hand == null) { warn("%s hand not started", which); @@ -1872,14 +1906,12 @@ public void setHandSpeed(String which, Double thumb, Double index, Double majeur } @Deprecated - public void setHandVelocity(String which, Double thumb, Double index, Double majeure, Double ringFinger, - Double pinky) { + public void setHandVelocity(String which, Double thumb, Double index, Double majeure, Double ringFinger, Double pinky) { setHandSpeed(which, thumb, index, majeure, ringFinger, pinky, null); } @Deprecated - public void setHandVelocity(String which, Double thumb, Double index, Double majeure, Double ringFinger, Double pinky, - Double wrist) { + public void setHandVelocity(String which, Double thumb, Double index, Double majeure, Double ringFinger, Double pinky, Double wrist) { setHandSpeed(which, thumb, index, majeure, ringFinger, pinky, wrist); } @@ -1895,8 +1927,7 @@ public void setHeadSpeed(Double rothead, Double neck, Double eyeXSpeed, Double e setHeadSpeed(rothead, neck, eyeXSpeed, eyeYSpeed, jawSpeed, null); } - public void setHeadSpeed(Double rothead, Double neck, Double eyeXSpeed, Double eyeYSpeed, Double jawSpeed, - Double rollNeckSpeed) { + public void setHeadSpeed(Double rothead, Double neck, Double eyeXSpeed, Double eyeYSpeed, Double jawSpeed, Double rollNeckSpeed) { sendToPeer("head", "setSpeed", rothead, neck, eyeXSpeed, eyeYSpeed, jawSpeed, rollNeckSpeed); } @@ -1920,8 +1951,7 @@ public void setHeadVelocity(Double rothead, Double neck, Double eyeXSpeed, Doubl } @Deprecated - public void setHeadVelocity(Double rothead, Double neck, Double eyeXSpeed, Double eyeYSpeed, Double jawSpeed, - Double rollNeckSpeed) { + public void setHeadVelocity(Double rothead, Double neck, Double eyeXSpeed, Double eyeYSpeed, Double jawSpeed, Double rollNeckSpeed) { setHeadSpeed(rothead, neck, eyeXSpeed, eyeYSpeed, jawSpeed, rollNeckSpeed); } @@ -1933,15 +1963,12 @@ public void setLeftArmSpeed(Integer bicep, Integer rotate, Integer shoulder, Int setArmSpeed("left", (double) bicep, (double) rotate, (double) shoulder, (double) omoplate); } - public void setLeftHandSpeed(Double thumb, Double index, Double majeure, Double ringFinger, Double pinky, - Double wrist) { + public void setLeftHandSpeed(Double thumb, Double index, Double majeure, Double ringFinger, Double pinky, Double wrist) { setHandSpeed("left", thumb, index, majeure, ringFinger, pinky, wrist); } - public void setLeftHandSpeed(Integer thumb, Integer index, Integer majeure, Integer ringFinger, Integer pinky, - Integer wrist) { - setHandSpeed("left", (double) thumb, (double) index, (double) majeure, (double) ringFinger, (double) pinky, - (double) wrist); + public void setLeftHandSpeed(Integer thumb, Integer index, Integer majeure, Integer ringFinger, Integer pinky, Integer wrist) { + setHandSpeed("left", (double) thumb, (double) index, (double) majeure, (double) ringFinger, (double) pinky, (double) wrist); } @Override @@ -1979,6 +2006,11 @@ public void setNeopixelAnimation(String animation, Integer red, Integer green, I sendToPeer("neopixel", "animation", red, green, blue, speed); } + public boolean setPirPlaySounds(boolean b) { + config.pirPlaySounds = b; + return b; + } + public Object setPredicate(String key, Object data) { if (data == null) { chatBot.setPredicate(key, null); // "unknown" "null" other sillyness ? @@ -1996,15 +2028,12 @@ public void setRightArmSpeed(Integer bicep, Integer rotate, Integer shoulder, In setArmSpeed("right", (double) bicep, (double) rotate, (double) shoulder, (double) omoplate); } - public void setRightHandSpeed(Double thumb, Double index, Double majeure, Double ringFinger, Double pinky, - Double wrist) { + public void setRightHandSpeed(Double thumb, Double index, Double majeure, Double ringFinger, Double pinky, Double wrist) { setHandSpeed("right", thumb, index, majeure, ringFinger, pinky, wrist); } - public void setRightHandSpeed(Integer thumb, Integer index, Integer majeure, Integer ringFinger, Integer pinky, - Integer wrist) { - setHandSpeed("right", (double) thumb, (double) index, (double) majeure, (double) ringFinger, (double) pinky, - (double) wrist); + public void setRightHandSpeed(Integer thumb, Integer index, Integer majeure, Integer ringFinger, Integer pinky, Integer wrist) { + setHandSpeed("right", (double) thumb, (double) index, (double) majeure, (double) ringFinger, (double) pinky, (double) wrist); } public boolean setSpeechType(String speechType) { @@ -2218,6 +2247,7 @@ public void stopNeopixelAnimation() { public void systemCheck() { Platform platform = Runtime.getPlatform(); + log.info("systemCheck()"); int servoCount = 0; for (ServiceInterface si : Runtime.getServices()) { if (si.getClass().getSimpleName().equals("Servo")) { diff --git a/src/main/java/org/myrobotlab/service/config/InMoov2Config.java b/src/main/java/org/myrobotlab/service/config/InMoov2Config.java index ae22df4f8b..b043165cf6 100644 --- a/src/main/java/org/myrobotlab/service/config/InMoov2Config.java +++ b/src/main/java/org/myrobotlab/service/config/InMoov2Config.java @@ -124,6 +124,9 @@ public class InMoov2Config extends ServiceConfig { */ public int sleepTimeoutMs = 300000; + /** + * Start sound + */ public boolean startupSound = true; /** @@ -548,8 +551,6 @@ public Plan getDefault(Plan plan, String name) { htmlFilter.listeners.add(new Listener("publishText", name)); - htmlFilter.listeners.add(new Listener("publishText", name)); - OakDConfig oakd = (OakDConfig) plan.get(getPeerName("oakd")); oakd.listeners.add(new Listener("publishClassification", name)); oakd.getPeer("py4j").name = getPeerName("py4j"); @@ -571,4 +572,4 @@ public Plan getDefault(Plan plan, String name) { return plan; } -} \ No newline at end of file +} diff --git a/src/main/java/org/myrobotlab/service/config/ProgramABConfig.java b/src/main/java/org/myrobotlab/service/config/ProgramABConfig.java index 74af07df13..c1d82dbe29 100644 --- a/src/main/java/org/myrobotlab/service/config/ProgramABConfig.java +++ b/src/main/java/org/myrobotlab/service/config/ProgramABConfig.java @@ -50,6 +50,10 @@ public class ProgramABConfig extends ServiceConfig { public Plan getDefault(Plan plan, String name) { super.getDefault(plan, name); addDefaultPeerConfig(plan, name, "search", "Wikipedia"); + bots.add("resource/ProgramAB/Alice"); + bots.add("resource/ProgramAB/Dr.Who"); + bots.add("resource/ProgramAB/Ency"); + bots.add("resource/ProgramAB/Mr. Turing"); return plan; } diff --git a/src/main/java/org/myrobotlab/service/meta/ImageDisplayMeta.java b/src/main/java/org/myrobotlab/service/meta/ImageDisplayMeta.java index e6fe0165ba..7a19a9e273 100644 --- a/src/main/java/org/myrobotlab/service/meta/ImageDisplayMeta.java +++ b/src/main/java/org/myrobotlab/service/meta/ImageDisplayMeta.java @@ -15,12 +15,6 @@ public class ImageDisplayMeta extends MetaData { public ImageDisplayMeta() { addDescription("IBus serial protocol"); setAvailable(true); // false if you do not want it viewable in a gui - // add dependency if necessary - - // TEMPORARY CORE DEPENDENCIES !!! (for uber-jar) - // addDependency("orgId", "artifactId", "2.4.0"); - - setAvailable(false); addCategory("general"); } diff --git a/src/main/resources/resource/WebGui/app/service/js/AudioFileGui.js b/src/main/resources/resource/WebGui/app/service/js/AudioFileGui.js index 1edc44bbf8..2a34217609 100644 --- a/src/main/resources/resource/WebGui/app/service/js/AudioFileGui.js +++ b/src/main/resources/resource/WebGui/app/service/js/AudioFileGui.js @@ -3,6 +3,7 @@ angular.module('mrlapp.service.AudioFileGui', []).controller('AudioFileGuiCtrl', var _self = this var msg = this.msg $scope.peak = 0 + $scope.peakMax = 0 // playing paused stopped $scope.activity = null @@ -90,6 +91,9 @@ angular.module('mrlapp.service.AudioFileGui', []).controller('AudioFileGuiCtrl', break case 'onPeak': $scope.peak = Math.round(data/* * 100 */) + if ($scope.peak > $scope.peakMax){ + $scope.peakMax = $scope.peak + } $scope.$apply() break diff --git a/src/main/resources/resource/WebGui/app/service/js/RuntimeGui.js b/src/main/resources/resource/WebGui/app/service/js/RuntimeGui.js index b1007dcbc1..adb479a116 100644 --- a/src/main/resources/resource/WebGui/app/service/js/RuntimeGui.js +++ b/src/main/resources/resource/WebGui/app/service/js/RuntimeGui.js @@ -1,14 +1,27 @@ -angular.module('mrlapp.service.RuntimeGui', []).controller('RuntimeGuiCtrl', ['$scope', 'mrl', 'statusSvc', '$timeout', '$uibModal', 'modalService', function($scope, mrl, statusSvc, $timeout, $uibModal, modalService) { - console.info('RuntimeGuiCtrl') +angular.module("mrlapp.service.RuntimeGui", []).controller("RuntimeGuiCtrl", [ + "$scope", + "mrl", + "statusSvc", + "$timeout", + "$uibModal", + "modalService", + function ($scope, mrl, statusSvc, $timeout, $uibModal, modalService) { + console.info("RuntimeGuiCtrl") var _self = this var msg = this.msg var statusMaxSize = 2500 - this.updateState = function(service) { - $scope.service = service - $scope.locale.selected = service.locale.language - $scope.localeTag.selected = service.locale + // configName is static so it needs to be + // kept in sync on a subobject + $scope.selected = { + configName: "default", + } + + this.updateState = function (service) { + $scope.service = service + $scope.locale.selected = service.locale.language + $scope.localeTag.selected = service.locale } $scope.locales = {} @@ -20,28 +33,28 @@ angular.module('mrlapp.service.RuntimeGui', []).controller('RuntimeGuiCtrl', ['$ $scope.newName = null $scope.newType = "" $scope.heartbeatTs = null - $scope.hosts = [] + $scope.hosts = [] // $scope.selectedOption = "current" $scope.languages = { - 'en': { - 'language': 'en', - 'displayLanguage': 'English' - } + en: { + language: "en", + displayLanguage: "English", + }, } $scope.locale = { - selected: null + selected: null, } $scope.localeTag = { - 'selected': { - 'tag': 'en-US' - } + selected: { + tag: "en-US", + }, } $scope.category = { - selected: null + selected: null, } $scope.categoryServiceTypes = null @@ -55,354 +68,360 @@ angular.module('mrlapp.service.RuntimeGui', []).controller('RuntimeGuiCtrl', ['$ // $scope.categoryServiceTypes = $scope.service.serviceData.categoryTypes[$scope.category.selected].serviceTypes - $scope.filterServices = function() { - var result = {} - // console.debug('$scope.category.selected is ' + $scope.category.selected) - const entries = Object.entries($scope.service.serviceData.serviceTypes) + $scope.filterServices = function () { + var result = {} + // console.debug('$scope.category.selected is ' + $scope.category.selected) + const entries = Object.entries($scope.service.serviceData.serviceTypes) - if ($scope.category.selected != null && ($scope.category.selected == 'show all')) { - return $scope.service.serviceData.serviceTypes - } + if ($scope.category.selected != null && $scope.category.selected == "show all") { + return $scope.service.serviceData.serviceTypes + } - for (const [fullTypeName,metaData] of entries) { - // if (metaData.simpleName.toLowerCase().includes($scope.newType)) { + for (const [fullTypeName, metaData] of entries) { + // if (metaData.simpleName.toLowerCase().includes($scope.newType)) { - if ($scope.category.selected != null) { - categoryServiceTypes = $scope.service.serviceData.categoryTypes[$scope.category.selected].serviceTypes - } else { - categoryServiceTypes = null - } + if ($scope.category.selected != null) { + categoryServiceTypes = $scope.service.serviceData.categoryTypes[$scope.category.selected].serviceTypes + } else { + categoryServiceTypes = null + } - if (/*metaData.simpleName.toLowerCase().includes($scope.newType) && */ - categoryServiceTypes != null && categoryServiceTypes.includes(metaData.name)) { - result[fullTypeName] = metaData - } + if (/*metaData.simpleName.toLowerCase().includes($scope.newType) && */ categoryServiceTypes != null && categoryServiceTypes.includes(metaData.name)) { + result[fullTypeName] = metaData } - return result + } + return result } // FIXME - maintain contextPath !!! - $scope.sendToCli = function(cmd) { - console.log("sendToCli " + cmd) - $scope.cmd = "" - contextPath = null - msg.send("sendToCli", "runtime@" + mrl.getId(), cmd) + $scope.sendToCli = function (cmd) { + console.log("sendToCli " + cmd) + $scope.cmd = "" + contextPath = null + msg.send("sendToCli", "runtime@" + mrl.getId(), cmd) } - $scope.setServiceType = function(serviceType) { - $scope.newType = serviceType + $scope.setServiceType = function (serviceType) { + $scope.newType = serviceType } - $scope.setConfig = function() { - console.info('setConfig') - if ($scope.selectedConfig.length > 0) { - $scope.configName = $scope.selectedConfig[0] - msg.sendTo('runtime', 'setConfig', $scope.configName) - msg.sendTo('runtime', 'getConfigName') - } + $scope.setConfig = function () { + console.info("setConfig") + if ($scope.selectedConfig.length > 0) { + msg.sendTo("runtime", "setConfig", $scope.selectedConfig[0]) + msg.sendTo("runtime", "getConfigName") + } } - $scope.start = function() { - - if ($scope.newName == null) { - mrl.error("name of service is required") - return - } - if ($scope.newType == null) { - mrl.error("type of service is required") - return - } - - if (typeof $scope.newType == 'object') { - $scope.newType = $scope.newType.simpleName - } - msg.send('start', $scope.newName, $scope.newType) - - $scope.newName = null - $scope.newType = null + $scope.start = function () { + if ($scope.newName == null) { + mrl.error("name of service is required") + return + } + if ($scope.newType == null) { + mrl.error("type of service is required") + return + } + + if (typeof $scope.newType == "object") { + $scope.newType = $scope.newType.simpleName + } + msg.send("start", $scope.newName, $scope.newType) + + $scope.newName = null + $scope.newType = null } - this.onMsg = function(inMsg) { - let data = null - if (inMsg.data) { - data = inMsg.data[0] - } - - switch (inMsg.method) { - case 'onState': - _self.updateState(data) - $scope.$apply() - break - case 'onPlan': - $scope.plan = data - $scope.$apply() - break - case 'onLocalServices': - $scope.registry = data - // $scope.$apply() - break - case 'onLocale': - $scope.locale.selected = data.language - $scope.$apply() - break - case 'onLocales': - ls = data - unique = {} - $scope.service.locales = {} - // new Set() - for (const key in ls) { - if (ls[key].displayLanguage) { - // unique.add(ls[key].displayLanguage) - // unique.push(ls[key].language) - unique[ls[key].language] = { - 'language': ls[key].language, - 'displayLanguage': ls[key].displayLanguage - } - } - // $scope.service.locales[key] =ls[key] + this.onMsg = function (inMsg) { + let data = null + if (inMsg.data) { + data = inMsg.data[0] + } + + switch (inMsg.method) { + case "onState": + _self.updateState(data) + $scope.$apply() + break + case "onPlan": + $scope.plan = data + $scope.$apply() + break + case "onLocalServices": + $scope.registry = data + // $scope.$apply() + break + case "onLocale": + $scope.locale.selected = data.language + $scope.$apply() + break + case "onLocales": + ls = data + unique = {} + $scope.service.locales = {} + // new Set() + for (const key in ls) { + if (ls[key].displayLanguage) { + // unique.add(ls[key].displayLanguage) + // unique.push(ls[key].language) + unique[ls[key].language] = { + language: ls[key].language, + displayLanguage: ls[key].displayLanguage, + } } - // $scope.languages = Array.from(unique) - $scope.languages = unique - $scope.locales = ls - // it is transient in java to reduce initial registration payload - // $scope.service.locales = ls + // $scope.service.locales[key] =ls[key] + } + // $scope.languages = Array.from(unique) + $scope.languages = unique + $scope.locales = ls + // it is transient in java to reduce initial registration payload + // $scope.service.locales = ls + $scope.$apply() + break + + case "onConfigList": + if (data) { + $scope.service.configList = data.sort() $scope.$apply() - break - - case 'onConfigList': - if (data) { - $scope.service.configList = data.sort() - $scope.$apply() - } - break - - case 'onStartYml': - $scope.startYml = data + } + break + + case "onStartYml": + $scope.startYml = data + $scope.$apply() + break + + case "onSaveDefaults": + if (data.length > 0) { + $scope.defaultsSaved = "saved defaults to " + data + msg.send("publishConfigList") $scope.$apply() - break - - case 'onSaveDefaults': - if (data.length > 0) { - $scope.defaultsSaved = 'saved defaults to ' + data - msg.send('publishConfigList') - $scope.$apply() - } else { - 'service does not have defaults' - } - break - - case 'onInterfaceToNames': - $scope.interfaceToPossibleServices = data - mrl.interfaceToPossibleServices = data - break - - case 'onServiceTypes': - $scope.serviceTypes = data - mrl.setPossibleServices($scope.serviceTypes) - break - - case 'onRegistered': - console.log("onRegistered") - break - - case 'onConnections': - $scope.connections = data - $scope.$apply() - break - case 'onHosts': - $scope.hosts = data - $scope.$apply() - break - case 'onStatus': - $scope.status = data.name + ' ' + data.level + ' ' + data.detail + "\n" + $scope.status + } else { + ;("service does not have defaults") + } + break + + case "onInterfaceToNames": + $scope.interfaceToPossibleServices = data + mrl.interfaceToPossibleServices = data + break + + case "onServiceTypes": + $scope.serviceTypes = data + mrl.setPossibleServices($scope.serviceTypes) + break + + case "onRegistered": + console.log("onRegistered") + break + + case "onConnections": + $scope.connections = data + $scope.$apply() + break + case "onHosts": + $scope.hosts = data + $scope.$apply() + break + case "onStatus": + $scope.status = data.name + " " + data.level + " " + data.detail + "\n" + $scope.status + if ($scope.status.length > 300) { + $scope.status = $scope.status.substring(0, statusMaxSize) + } + break + case "onCli": + if (data != null) { + $scope.status = JSON.stringify(data, null, 2) + "\n" + $scope.status if ($scope.status.length > 300) { - $scope.status = $scope.status.substring(0, statusMaxSize) + $scope.status = $scope.status.substring(0, statusMaxSize) } - break - case 'onCli': - if (data != null) { - $scope.status = JSON.stringify(data, null, 2) + "\n" + $scope.status - if ($scope.status.length > 300) { - $scope.status = $scope.status.substring(0, statusMaxSize) - } - $scope.$apply() - } else { - $scope.status += "null\n" - } - break - case 'onReleased': - console.info("runtime - onRelease" + data) - break - case 'onConfigName': - $scope.configName = data - $scope.$apply() - console.info("runtime - onConfigName" + data) - break - case 'onHeartbeat': - let heartbeat = data - let hb = heartbeat.name + '@' + heartbeat.id + ' sent onHeartbeat - ' - $scope.heartbeatTs = heartbeat.ts $scope.$apply() - - for (let i in heartbeat.serviceList) { - let serviceName = heartbeat.serviceList[i].name + '@' + heartbeat.serviceList[i].id - hb += serviceName + ' ' - - // FIXME - 'merge' ie remove missing services - - // FIXME - want to maintain "local" registry ??? - // currently maintaining JS process registry - should the RuntimeGui also maintain - // its 'own' sub-registry ??? - if (!serviceName in mrl.getRegistry()) { - // - console.warn(serviceName + ' not defined in registry - sending registration request') - } - // else already registered + } else { + $scope.status += "null\n" + } + break + case "onReleased": + console.info("runtime - onRelease " + data) + break + case "onConfigName": + console.info("runtime - onConfigName " + data) + // is not part of service, because configName is static + $scope.selected.configName = data + $scope.$apply() + break + case "onHeartbeat": + let heartbeat = data + let hb = heartbeat.name + "@" + heartbeat.id + " sent onHeartbeat - " + $scope.heartbeatTs = heartbeat.ts + $scope.$apply() + + for (let i in heartbeat.serviceList) { + let serviceName = heartbeat.serviceList[i].name + "@" + heartbeat.serviceList[i].id + hb += serviceName + " " + + // FIXME - 'merge' ie remove missing services + + // FIXME - want to maintain "local" registry ??? + // currently maintaining JS process registry - should the RuntimeGui also maintain + // its 'own' sub-registry ??? + if (!serviceName in mrl.getRegistry()) { + // + console.warn(serviceName + " not defined in registry - sending registration request") } + // else already registered + } - console.info(hb) + console.info(hb) - // CHECK REGISTRY - // SYNC SERVICES - // REQUEST REGISTRATIONS !!!! - break + // CHECK REGISTRY + // SYNC SERVICES + // REQUEST REGISTRATIONS !!!! + break default: - console.error("ERROR - unhandled method " + $scope.name + " " + inMsg.method) - break - } + console.error("ERROR - unhandled method " + $scope.name + " " + inMsg.method) + break + } } - $scope.shutdown = function(type) { - var modalInstance = $uibModal.open({ - //animation: true, - // templateUrl: 'nav/shutdown.html', - // template: '', - // controller: $scope.doShutdown, - // controller: 'RuntimeGuiCtrl', - scope: $scope, - // controller: 'ModalController', - - animation: true, - templateUrl: 'nav/shutdown.html', - controller: 'shutdownCtrl2', - - resolve: { - type: function() { - return type - } - } - }) - console.info('shutdown ' + modalInstance) + $scope.shutdown = function (type) { + var modalInstance = $uibModal.open({ + //animation: true, + // templateUrl: 'nav/shutdown.html', + // template: '', + // controller: $scope.doShutdown, + // controller: 'RuntimeGuiCtrl', + scope: $scope, + // controller: 'ModalController', + + animation: true, + templateUrl: "nav/shutdown.html", + controller: "shutdownCtrl2", + + resolve: { + type: function () { + return type + }, + }, + }) + console.info("shutdown " + modalInstance) } - $scope.setAllLocales = function(locale) { - console.info(locale) + $scope.setAllLocales = function (locale) { + console.info(locale) } - $scope.loadConfig = function() { - console.info('loadConfig') - if ($scope.selectedConfig.length) { - for (let i = 0; i < $scope.selectedConfig.length; ++i) { - // msg.sendTo('runtime', 'load', 'data/config/' + $scope.selectedConfig[i] + '/runtime.yml') - msg.sendTo('runtime', 'setConfig', $scope.selectedConfig[i]) - msg.sendTo('runtime', 'load', 'runtime') - } + $scope.loadConfig = function () { + console.info("loadConfig") + if ($scope.selectedConfig.length) { + for (let i = 0; i < $scope.selectedConfig.length; ++i) { + // msg.sendTo('runtime', 'load', 'data/config/' + $scope.selectedConfig[i] + '/runtime.yml') + msg.sendTo("runtime", "setConfig", $scope.selectedConfig[i]) + msg.sendTo("runtime", "load", "runtime") } + } } - $scope.unsetConfig = function() { - console.info('unsetConfig') - msg.sendTo('runtime', 'unsetConfig') + $scope.unsetConfig = function () { + console.info("unsetConfig") + msg.sendTo("runtime", "unsetConfig") } - $scope.startConfig = function() { - console.info('startConfig') - if ($scope.selectedConfig.length) { - for (let i = 0; i < $scope.selectedConfig.length; ++i) { - // msg.sendTo('runtime', 'load', 'data/config/' + $scope.selectedConfig[i] + '/runtime.yml') - msg.sendTo('runtime', 'startConfig', $scope.selectedConfig[i]) - } + $scope.startConfig = function () { + console.info("startConfig") + if ($scope.selectedConfig.length) { + for (let i = 0; i < $scope.selectedConfig.length; ++i) { + // msg.sendTo('runtime', 'load', 'data/config/' + $scope.selectedConfig[i] + '/runtime.yml') + msg.sendTo("runtime", "startConfig", $scope.selectedConfig[i]) } + } } - $scope.releaseConfig = function() { - console.info('releaseConfig') - if ($scope.selectedConfig && $scope.selectedConfig.length) { - for (let i = 0; i < $scope.selectedConfig.length; ++i) { - msg.sendTo('runtime', 'releaseConfig', $scope.selectedConfig[i]) - // msg.sendTo('runtime', 'releaseConfig', 'runtime') - } - } else { - msg.sendTo('runtime', 'releaseConfig') + $scope.releaseConfig = function () { + console.info("releaseConfig") + if ($scope.selectedConfig && $scope.selectedConfig.length) { + for (let i = 0; i < $scope.selectedConfig.length; ++i) { + msg.sendTo("runtime", "releaseConfig", $scope.selectedConfig[i]) + // msg.sendTo('runtime', 'releaseConfig', 'runtime') } + } else { + msg.sendTo("runtime", "releaseConfig") + } } - $scope.savePlan = function() { - console.info('saveConfig') - - let onOK = function() { - msg.sendTo('runtime', 'savePlan', $scope.service.configName) - // msg.sendTo('runtime', 'save') - } - - let onCancel = function() { - console.info('save config cancelled') - } - - let ret = modalService.openOkCancel('widget/modal-dialog.view.html', 'Save Plan Configuration', 'Save your current configuration in a directory named', onOK, onCancel, $scope) - console.info('ret ' + ret) + $scope.savePlan = function () { + console.info("saveConfig") + + let onOK = function () { + msg.sendTo("runtime", "savePlan", $scope.selected.configName) + // msg.sendTo('runtime', 'save') + } + + let onCancel = function () { + console.info("save config cancelled") + } + + let ret = modalService.openOkCancel( + "widget/modal-dialog.view.html", + "Save Plan Configuration", + "Save your current configuration in a directory named", + onOK, + onCancel, + $scope + ) + console.info("ret " + ret) } - $scope.saveDefaults = function() { - console.info('saveDefaults') - msg.send('saveDefaults', $scope.newType.simpleName) + $scope.saveDefaults = function () { + console.info("saveDefaults") + msg.send("saveDefaults", $scope.newType.simpleName) } - $scope.getConfigName = function(){ - return $scope.configName + $scope.setAutoStart = function (b) { + console.info("setAutoStart") + msg.send("setAutoStart", b) } - $scope.setAutoStart = function(b) { - console.info('setAutoStart') - msg.send('setAutoStart', b) + $scope.saveConfig = function () { + $scope.service.includePeers = false + $scope.service.selectedOption = "current" + + $scope.selected.configName = $scope.selected.configName + var modalInstance = $uibModal.open({ + templateUrl: "saveConfig.html", + scope: $scope, + controller: function ($scope, $uibModalInstance) { + $scope.ok = function () { + $uibModalInstance.close() + } + + $scope.cancel = function () { + $uibModalInstance.dismiss("cancel") + } + }, + }) + + modalInstance.result.then( + function (result) { + // Handle 'OK' button click + console.log("Config Name: " + $scope.selected.configName) + console.log("Selected Option: " + $scope.service.selectedOption) + console.log("includePeers Option: " + $scope.service.includePeers) + console.log("configType Option: " + $scope.service.configType) + msg.send("setConfig", $scope.selected.configName) + if ($scope.service.selectedOption == "default") { + msg.send("saveDefault", $scope.selected.configName, $scope.service.defaultServiceName, $scope.service.configType, $scope.service.includePeers) + } else { + msg.sendTo("runtime", "saveConfig", $scope.selected.configName) + } + msg.send("getConfigName") + }, + function () { + // Handle 'Cancel' button click or modal dismissal + console.log("Modal dismissed") + } + ) } - $scope.saveConfig = function() { - $scope.service.includePeers = false - $scope.service.selectedOption = "current" - - var modalInstance = $uibModal.open({ - templateUrl: 'saveConfig.html', - scope: $scope, - controller: function($scope, $uibModalInstance) { - - $scope.ok = function() { - $uibModalInstance.close() - } - - $scope.cancel = function() { - $uibModalInstance.dismiss('cancel') - } - } - }) - - modalInstance.result.then(function(result) { - // Handle 'OK' button click - console.log('Config Name: ' + $scope.configName) - console.log('Selected Option: ' + $scope.service.selectedOption) - console.log('includePeers Option: ' + $scope.service.includePeers) - console.log('configType Option: ' + $scope.service.configType) - if ($scope.service.selectedOption == 'default'){ - msg.send('saveDefault', $scope.configName, $scope.service.defaultServiceName, $scope.service.configType, $scope.service.includePeers) - } else { - msg.sendTo('runtime', 'saveConfig', $scope.configName) - } - }, function() { - // Handle 'Cancel' button click or modal dismissal - console.log('Modal dismissed') - }) - } - // $scope.serviceTypes = Object.values(mrl.getPossibleServices()) msg.subscribe("getStartYml") msg.subscribe("saveDefaults") @@ -415,8 +434,8 @@ angular.module('mrlapp.service.RuntimeGui', []).controller('RuntimeGuiCtrl', ['$ msg.subscribe("getLocales") msg.subscribe("getHosts") msg.subscribe("publishStatus") - msg.subscribe('publishConfigList') - msg.subscribe('publishInterfaceToNames') + msg.subscribe("publishConfigList") + msg.subscribe("publishInterfaceToNames") // msg.subscribe("getPlan") //msg.send("getLocalServices") @@ -431,5 +450,5 @@ angular.module('mrlapp.service.RuntimeGui', []).controller('RuntimeGuiCtrl', ['$ // msg.send("getHosts") msg.subscribe(this) -} + }, ]) diff --git a/src/main/resources/resource/WebGui/app/service/views/AudioFileGui.html b/src/main/resources/resource/WebGui/app/service/views/AudioFileGui.html index 49edaff5a9..ffd479fc41 100644 --- a/src/main/resources/resource/WebGui/app/service/views/AudioFileGui.html +++ b/src/main/resources/resource/WebGui/app/service/views/AudioFileGui.html @@ -101,7 +101,7 @@
- loudness {{peak}} + loudness {{peak}} max {{peakMax}}
diff --git a/src/main/resources/resource/WebGui/app/service/views/RuntimeGui.html b/src/main/resources/resource/WebGui/app/service/views/RuntimeGui.html index 52229335c0..c81bb2b837 100644 --- a/src/main/resources/resource/WebGui/app/service/views/RuntimeGui.html +++ b/src/main/resources/resource/WebGui/app/service/views/RuntimeGui.html @@ -1,4 +1,4 @@ -

{{platform.arch}}.{{platform.jvmBitness}}.{{platform.os}} {{platform.mrlVersion}}

+

{{platform.arch}}.{{platform.jvmBitness}}.{{platform.os}} {{platform.mrlVersion}} {{service.id}}

@@ -58,7 +58,7 @@

{{platform.arch}}.{{platform.jvmBitness}}.{{platform.os}} {{platform.mrlVer
- Configurations {{getConfigName()}} + Configurations {{selected.configName}}

Save your current configuration in a directory named
- +


diff --git a/src/main/resources/resource/peak.png b/src/main/resources/resource/peak.png new file mode 100644 index 0000000000..03106b3b23 Binary files /dev/null and b/src/main/resources/resource/peak.png differ