diff --git a/EcosApp/index.js b/EcosApp/index.js index cd7dbb8..b395f25 100644 --- a/EcosApp/index.js +++ b/EcosApp/index.js @@ -214,6 +214,21 @@ function relayWebsocketCommand(data) { }); } +function triggerMqttMessage(data) { + var srv = window.serverHandling; + if (typeof srv === "undefined" || srv == null) + return; // TODO show error + + // data.mode := string ['mqtt', ...] + // data.data := object, binary, etc. + + srv.sendCommand({ + "command": "mqtt", + "timestamp": Date.now(), + "cmddata": data + }); +} + function removeTextfieldFromGlobalList(uniqueId) { if (uniqueId == null) return; @@ -461,13 +476,17 @@ $(document).ready(function () { window.dialogLightAndPower = new LightAndPower(); window.dialogLightAndPower.install(); - window.dialogLightAndPower.on('relayCommand', function (ev) { + let fncPowerLightChanged = function (ev) { const data = ev.data; - if (data.mode === "websocket") - relayWebsocketCommand(data); - else - console.log("TODO unknown relay mode: " + data.mode); - }); + if (data.mode === "mqtt") { + triggerMqttMessage(data); + } + else { + console.log("TODO unknown data mode: " + data.mode); + } + }; + window.dialogLightAndPower.on('powerSwitchesChanged', fncPowerLightChanged); + window.dialogLightAndPower.on('lightChanged', fncPowerLightChanged); window.dialogS88 = new FeedbackVisualization(); window.dialogS88.install(); @@ -732,7 +751,7 @@ $(document).ready(function () { const state = jsonCommand.data.state; if (typeof state === "undefined" || state == null) break; - const fncClearGhost = function() { + const fncClearGhost = function () { const allFbItems = $('div.ctrlItemFeedback[id]'); const iMax = allFbItems.length; for (let i = 0; i < iMax; ++i) { @@ -740,12 +759,12 @@ $(document).ready(function () { } } - const fncHideGhostOverlay = function() { + const fncHideGhostOverlay = function () { $('.overlayGhost').hide(); $('.overlayGhostText').hide(); } - const fncShowGhostOverlay = function(message) { + const fncShowGhostOverlay = function (message) { $('.overlayGhost').show(); $('.overlayGhostText').html(message); $('.overlayGhostText').show(); @@ -753,8 +772,7 @@ $(document).ready(function () { if (typeof state.found === "undefined" || state.found == null - || state.found === false) - { + || state.found === false) { fncClearGhost(); fncHideGhostOverlay(); } else { diff --git a/EcosApp/railessentials.min.js b/EcosApp/railessentials.min.js index 2f76089..1e00271 100644 --- a/EcosApp/railessentials.min.js +++ b/EcosApp/railessentials.min.js @@ -1,4 +1,4 @@ -function bringToFront(n){const r=$(".ui-dialog");let t=null,i=0;for(let u=0;ui&&(i=s);const o=e.attr("aria-describedby");typeof o!="undefined"&&o!=null&&o===n&&(t=e)}}t!=null&&t.css({"z-index":i+1})}function getRouteByName(n){if(typeof n=="undefined"||n==null||n.length===0||typeof routes=="undefined"||window.routes==null)return null;for(let t=0;t>16&255,g:t>>8&255,b:t&255,w:1023};throw new Error("Bad Hex");}function toggleAllLocomotiveInformation(n){const i=$("div.locomotiveInfo");let t;const r=i.length;for(t=0;t0&&parseInt(i.Port1)>0,t=parseInt(i.Addr2)>0&&parseInt(i.Port2)>0;return{planItem:f,themeData:u,ecosAddresses:[{ecosAddr:e,ecosAddrValid:n,inverse:i.Inverse1},{ecosAddr:o,ecosAddrValid:t,inverse:i.Inverse2}]}}}}}return null}function getFbByEcosAddr(n,t){if(typeof n=="undefined"||n==null||typeof t=="undefined")return null;const i=n.length;for(let r=0;r=f)break}}}return t}function loadLocomotiveImageIntoHtml(n,t,i="100%"){if(typeof window.__cachedLocomotiveImages[t]!="undefined"&&window.__cachedLocomotiveImages[t]!=null){const i=$("img#"+n);i.get(0).src=window.__cachedLocomotiveImages[t]}const r=new Image;(typeof i=="undefined"||i==null)&&(i="100%");r.onload=function(){const r=$("img#"+n);r.get(0).src=this.src;r.css({width:i});window.__cachedLocomotiveImages[t]=this.src};t=t.replace("/","_");t=t.replace(".","_");const u="./images/locomotives/"+t+".png";r.src=u}function getCtrlOfPosition(n,t,i){if(n==null||t==null||i==null)return null;let r;const u=i.length;for(r=0;r=e&&n<=c&&t>=f&&t<=l)return $(u)}}return null}function getCtrlOfCoord(n,t,i){if(n==null||t==null||i==null)return null;let r;const u=i.length;for(r=0;r=100&&n<=125?!0:!1:!1}function isSwitchOrAccessory(n){return n?n>=50&&n<150&&n!==54&&n!==55?!0:!1:!1}function isAccessory(n){return n?n>=250&&n<=260?!0:!1:!1}function isDecoupler(n){return n?n===70?!0:!1:!1}function isBlock(n){return n===150?!0:n===151?!0:n===152?!0:!1}function isFeedback(n){return n?n>=200&&n<=210?!0:!1:!1}function changeLocomotive(n,t={}){var i=window.serverHandling;typeof i!="undefined"&&i!=null&&(t.mode=n,i.sendCommand({command:"locomotive",timestamp:Date.now(),cmddata:t}))}function accessoryExecute(n){var t=window.serverHandling;typeof t!="undefined"&&t!=null&&t.sendCommand({command:"accessory",timestamp:Date.now(),cmddata:n})}function accessoryTest(n){var t=window.serverHandling;typeof t!="undefined"&&t!=null&&t.sendCommand({command:"accessory",timestamp:Date.now(),cmddata:n})}function itemClicked(n){var t=window.serverHandling;typeof t!="undefined"&&t!=null&&t.sendCommand({command:"accessory",timestamp:Date.now(),cmddata:n})}function assignLocomotiveToBlock(n){var t=window.serverHandling;typeof t!="undefined"&&t!=null&&t.sendCommand({command:"routing",timestamp:Date.now(),cmddata:n})}function resetAssignment(n){var t=window.serverHandling;typeof t!="undefined"&&t!=null&&t.sendCommand({command:"routing",timestamp:Date.now(),cmddata:n})}function gotoBlock(n){var t=window.serverHandling;typeof t!="undefined"&&t!=null&&t.sendCommand({command:"routing",timestamp:Date.now(),cmddata:n})}function checkRoute(n){var t=window.serverHandling;typeof t!="undefined"&&t!=null&&t.sendCommand({command:"routing",timestamp:Date.now(),cmddata:n})}function changeSetting(n){var t=window.serverHandling;typeof t!="undefined"&&t!=null&&t.sendCommand({command:"setting",timestamp:Date.now(),cmddata:n})}function relayWebsocketCommand(n){var t=window.serverHandling;typeof t!="undefined"&&t!=null&&t.sendCommand({command:"relayCommand",timestamp:Date.now(),cmddata:n})}function removeTextfieldFromGlobalList(n){var i,t,r;if(n!=null){for(i=-1,t=0;t0){window.open("?workspace="+i,"_self");return}}}function handleWorkspace(){const n=$("#workspaceSelectionFrame");n.w2popup({title:"Workspace Selection",height:"200px",width:"450px",buttons:'