Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
provide ghost train detection (#109)
Browse files Browse the repository at this point in the history
* #104

* #104

* #104

* #104

* #104

* #104

* #104

Co-authored-by: Christian Benjamin Ries <c.ries@beckhoff.com>
  • Loading branch information
cbries and Christian Benjamin Ries committed Apr 30, 2021
1 parent ed50b85 commit 591cdb5
Show file tree
Hide file tree
Showing 14 changed files with 660 additions and 52 deletions.
40 changes: 36 additions & 4 deletions EcosApp/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ html, body {
overflow: hidden; /* hide vertical scrollbars */
}

.ghost {
background-color: lightpink;
-webkit-box-shadow: inset 0 0 0 4px #ff0000;
-moz-box-shadow: inset 0 0 0 4px #ff0000;
box-shadow: inset 0 0 0 4px #ff0000;
}

/**
Workspace Selection
*/
Expand Down Expand Up @@ -538,10 +545,10 @@ div.textfieldElementToolbar {
right: 5px;
}

.debugConsole .messageContainer {
overflow-y: scroll;
height: 100%;
}
.debugConsole .messageContainer {
overflow-y: scroll;
height: 100%;
}

.debugConsole .messageContainer span.dt {
font-weight: bold;
Expand Down Expand Up @@ -641,6 +648,31 @@ div.overlayAutoMode {
opacity: 0.9;
}

div.overlayGhost {
position: fixed;
display: none;
width: 100%;
height: 0;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 200000;
cursor: pointer;
}

div.overlayGhost .overlayGhostText {
position: absolute;
width: 100%;
top: 0;
left: 0;
font-size: 1.25em;
padding: 5px;
color: black;
background-color: #ffd700;
background-color: rgba(255, 200, 0, 1.0);
}

/**
Overwrite jquery ui css stuff
*/
Expand Down
8 changes: 6 additions & 2 deletions EcosApp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
{{WEBCAM CODE JS}}
}
</script>

<style type="text/css">
body {
{{BACKGROUND_COLOR}}
Expand All @@ -86,6 +86,10 @@
<div class="overlayAutoModeText"></div>
</div>

<div class="overlayGhost">
<div class="overlayGhostText"></div>
</div>

<div id="sidebar" style="height: 100%; width: 200px; float: right"></div>

<div class="no container full-height">
Expand Down Expand Up @@ -126,7 +130,7 @@
</div>
<div class="messageContainer"></div>
</div>

<div id="routePopUp" style="display: none; position: relative;"></div>

<div id="tplLocomotiveControl" title="CHANGE" style="display: none; overflow: hidden;">
Expand Down
65 changes: 59 additions & 6 deletions EcosApp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ $(document).ready(function () {

addJqueryExtensions();
initDebugConsole();

$('#statusBar div.autoMode').tipso({
size: 'tiny',
speed: 100,
Expand Down Expand Up @@ -533,16 +533,16 @@ $(document).ready(function () {
var jsonData = JSON.parse(ev.data);
changeLocomotive('function', jsonData);
});

window.planField = new Planfield({
isEditMode: false
});
window.planField.install();
window.planField.on('controlCreated', function (ev) {
const ctrlInstance = ev.data.instance;

// inform the Route/S88/Signals dialog for updating its internal lists
if(typeof window.blocksDlg !== "undefined" && window.blocksDlg != null)
if (typeof window.blocksDlg !== "undefined" && window.blocksDlg != null)
window.blocksDlg.controlCreated(ctrlInstance);
});
window.planField.on('clicked', function (ev) { itemClicked(ev.data); });
Expand Down Expand Up @@ -726,6 +726,59 @@ $(document).ready(function () {
const subCmd = jsonCommand.data.command;

switch (subCmd) {

case "ghost":
{
const state = jsonCommand.data.state;
if (typeof state === "undefined" || state == null) break;

const fncClearGhost = function() {
const allFbItems = $('div.ctrlItemFeedback[id]');
const iMax = allFbItems.length;
for (let i = 0; i < iMax; ++i) {
$(allFbItems[i]).removeClass("ghost");
}
}

const fncHideGhostOverlay = function() {
$('.overlayGhost').hide();
$('.overlayGhostText').hide();
}

const fncShowGhostOverlay = function(message) {
$('.overlayGhost').show();
$('.overlayGhostText').html(message);
$('.overlayGhostText').show();
}

if (typeof state.found === "undefined"
|| state.found == null
|| state.found === false)
{
fncClearGhost();
fncHideGhostOverlay();
} else {
fncClearGhost();

const allFbItems = $('div.ctrlItemFeedback[id]');
const fbs = state.fbs;
for (let i = 0; i < fbs.length; ++i) {
const fbItem = fbs[i];
if (typeof fbItem === "undefined") continue;
if (fbItem == null) continue;

const fbItemCoord = fbItem.coord;
const item = getCtrlOfCoord(fbItemCoord.x, fbItemCoord.y, allFbItems);
item.addClass("ghost");
}

if (fbs.length > 0) {
fncShowGhostOverlay("Ghost train detected!");
}
}

} break;

case "state": {

let state = jsonCommand.data.state;
Expand Down Expand Up @@ -996,7 +1049,7 @@ var loadSideBar = (function () {
'</table></div>'
});
w2ui['sidebar'].unselect('cmdAbout');
} else if(target === "cmdReport") {
} else if (target === "cmdReport") {
window.open("/report.html", '_blank').focus();
}
}
Expand Down Expand Up @@ -1118,7 +1171,7 @@ var loadSideBar = (function () {
// do nothing
});
}

//w2ui.sidebar.goFlat();

function showTodoDialog() {
Expand Down
4 changes: 2 additions & 2 deletions EcosApp/railessentials.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions EcosApp/src/planField.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,8 +740,8 @@ class Planfield {
createControl(jsonData, coord, options = {}) {
const self = this;

var knownControls = $('div.ctrlItem[id]');
var knownCtrl = getCtrlOfCoord(coord.x, coord.y, knownControls);
let knownControls = $('div.ctrlItem[id]');
let knownCtrl = getCtrlOfCoord(coord.x, coord.y, knownControls);
if (typeof knownCtrl !== "undefined" && knownCtrl != null) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion EcosApp/src/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ function getCtrlOfCoord(x, y, listOfCtrls) {
if (typeof c0data === "undefined" || c0data == null) continue;
const c = c0data.coord;
if (typeof c === "undefined" || c == null) return null;
if (c.x === x && c.y === y) return c;
if (c.x === x && c.y === y) return c0;
}
return null;
}
Expand Down

0 comments on commit 591cdb5

Please sign in to comment.