--- /dev/null
+const electron = require('electron')
+
+// Module to control application life.
+const app = electron.app
+app.commandLine.appendSwitch('--ignore-gpu-blacklist');
+
+// Module to create native browser window.
+const BrowserWindow = electron.BrowserWindow
+
+const path = require('path')
+const url = require('url')
+
+// Keep a global reference of the window object, if you don't, the window will
+// be closed automatically when the JavaScript object is garbage collected.
+let mainWindow
+
+function createWindow () {
+ // Create the browser window.
+ mainWindow = new BrowserWindow({width: 1200, height: 800,
+ 'web-preferences': {
+ 'web-security': false,
+ "webgl": true
+ }})
+
+
+ // and load the index.html of the app.
+ mainWindow.loadURL(url.format({
+ pathname: path.join(__dirname, 'views/live_data.html'),
+ protocol: 'file:',
+ slashes: true
+ }))
+
+ // Open the DevTools.
+ mainWindow.webContents.openDevTools()
+
+ // Emitted when the window is closed.
+ mainWindow.on('closed', function () {
+ // Dereference the window object, usually you would store windows
+ // in an array if your app supports multi windows, this is the time
+ // when you should delete the corresponding element.
+ mainWindow = null
+ })
+}
+
+// This method will be called when Electron has finished
+// initialization and is ready to create browser windows.
+// Some APIs can only be used after this event occurs.
+app.on('ready', createWindow)
+
+// Quit when all windows are closed.
+app.on('window-all-closed', function () {
+ // On OS X it is common for applications and their menu bar
+ // to stay active until the user quits explicitly with Cmd + Q
+ if (process.platform !== 'darwin') {
+ app.quit()
+ }
+})
+
+app.on('activate', function () {
+ // On OS X it's common to re-create a window in the app when the
+ // dock icon is clicked and there are no other windows open.
+ if (mainWindow === null) {
+ createWindow()
+ }
+})
+
+// In this file you can include the rest of your app's specific main process
+// code. You can also put them in separate files and require them here.
+
+/*
+ * Create TCP server for source tracking
+ */
+
+// Load modules
+const StringDecoder = require('string_decoder').StringDecoder;
+var net = require('net');
+
+var server = net.createServer();
+server.on('connection', handleConnection);
+
+server.listen(9000, function() {
+ console.log('server listening to %j', server.address());
+});
+
+function handleConnection(conn) {
+ var remoteAddress = conn.remoteAddress + ':' + conn.remotePort;
+ console.log('new client connection from %s', remoteAddress);
+
+ conn.on('data', onConnData);
+ conn.once('close', onConnClose);
+ conn.on('error', onConnError);
+
+ function onConnData(d) {
+
+ var decoder = new StringDecoder();
+
+ // Decode received string
+ var str = decoder.write(d);
+
+ try {
+ mainWindow.webContents.send('newTracking',str);
+ }
+
+ catch(err) {
+ console.log('Window was closed');
+ }
+
+ }
+
+ function onConnClose() {
+ console.log('connection from %s closed', remoteAddress);
+ }
+
+ function onConnError(err) {
+ console.log('Connection %s error: %s', remoteAddress, err.message);
+ }
+}
+
+
+/*
+ * Create TCP server for potential sources
+ */
+
+var potentialServer = net.createServer();
+potentialServer.on('connection', handlePotConnection);
+
+potentialServer.listen(9001, function() {
+ console.log('server listening to %j', potentialServer.address());
+});
+
+function handlePotConnection(conn) {
+ var remoteAddress = conn.remoteAddress + ':' + conn.remotePort;
+ console.log('new client connection from %s', remoteAddress);
+
+ conn.on('data', onConnData);
+ conn.once('close', onConnClose);
+ conn.on('error', onConnError);
+
+ function onConnData(d) {
+
+ var decoder = new StringDecoder();
+
+ // Decode received string
+ var str = decoder.write(d);
+
+ try {
+ mainWindow.webContents.send('newPotential',str);
+ }
+
+ catch(err) {
+
+ console.log('Window was closed');
+ }
+
+ }
+
+ function onConnClose() {
+ console.log('connection from %s closed', remoteAddress);
+ }
+
+ function onConnError(err) {
+ console.log('Connection %s error: %s', remoteAddress, err.message);
+ }
+}
{
- "name": "odas-web",
- "version": "0.2.0",
- "description": "Web interface for ODAS platform",
- "repository": "MARS on GitHub/introlab",
- "license" : "MIT",
- "dependencies": {
+ "name": "electron-quick-start",
+ "version": "1.0.0",
+ "description": "A minimal Electron application",
+ "main": "main.js",
+ "scripts": {
+ "start": "electron ."
+ },
+ "repository": "https://github.com/electron/electron-quick-start",
+ "keywords": [
+ "Electron",
+ "quick",
+ "start",
+ "tutorial",
+ "demo"
+ ],
+ "author": "GitHub",
+ "license": "CC0-1.0",
+ "devDependencies": {
+ "electron": "~1.7.8",
"express": "^4.15.2",
"express-ws": "^3.0.0",
"systeminformation": "^3.17.3"
/*! =======================================================
- VERSION 9.8.0
+ VERSION 9.8.0
========================================================= */
"use strict";
+var rangeSlider;
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
/*! =========================================================
}
// Reference to Slider constructor
- var Slider;
+ var Slider;
(function ($) {
}
})($);
+ rangeSlider = new Slider('#range_slider', {});
+
return Slider;
});
-
-var rangeSlider = new Slider('#range_slider', {});
\ No newline at end of file
// Get gradiant index corresponding to energy
function scaleEnergy(e) {
-
+
var min = rangeSlider.getValue()[0];
var max = rangeSlider.getValue()[1];
-
+
// Rescale according to minimal value
-
+
e -= min;
max -= min;
-
+
if( e > max)
e = max;
-
+
// Round energy between 0 and 10
return Math.round((e/max)*10);
}
// Single source data
class Source {
constructor(index) {
-
+
// Web UI info
this.index = index;
this.rgbValueString = rgbValueStrings[index];
this.selected = true;
-
+
// Source info
this.id = null;
this.active = false;
// Single data frame
class DataFrame {
constructor() {
-
+
this.timestamp = null;
this.ptimestamp = null;
-
+
this.sources = [];
rgbValueStrings.forEach(function (color,i) {
this.sources.push(new Source(i));
}.bind(this));
-
+
this.potentialSources = [];
}
}
methods : {
showHide: function(e) {
document.dispatchEvent(new Event('update-selection'));
- }
+ }
}
});
}
});
+/*
+ * System Monitor
+ */
+
// System monitor model
var systemMonitor = new Vue({
el: '#system-monitor',
data: {
system : {cpu:'0 %',mem:0,temp:0}
}
-});
\ No newline at end of file
+});
+
+var si = require('systeminformation');
+
+function updateSi() { // Gather params
+
+ var sysInfo = {cpu:0,mem:0,temp:0};
+
+ si.currentLoad(function(data) {
+ sysInfo.cpu = data.currentload;
+
+ si.mem(function(data) {
+ sysInfo.mem = (data.active/data.total)*100;
+
+ si.cpuTemperature(function(data) {
+ sysInfo.temp = data.main;
+
+ systemMonitor.system.cpu = sysInfo.cpu.toPrecision(3).toString() + ' %';
+ systemMonitor.system.mem = sysInfo.mem.toPrecision(2).toString() + ' %';
+ systemMonitor.system.temp = sysInfo.temp.toPrecision(3).toString() + ' °C';
+
+ });
+ });
+ });
+
+}
+
+// Schedule update
+setInterval(updateSi,500);
--- /dev/null
+const electron = require('electron')
+
+const BrowserWindow = electron.remote.BrowserWindow
+
+const path = require('path')
+const url = require('url')
+
+let legalWindow
+
+function openLegalWindow () {
+ // Create the browser window.
+ legalWindow = new BrowserWindow({width: 800, height: 600, show: false})
+
+
+ // and load the index.html of the app.
+ legalWindow.loadURL(url.format({
+ pathname: path.join(__dirname, 'legal.html'),
+ protocol: 'file:',
+ slashes: true
+ }))
+
+ legalWindow.once('ready-to-show', function () {
+
+ legalWindow.show()
+ })
+
+ // Emitted when the window is closed.
+ legalWindow.on('closed', function () {
+ // Dereference the window object, usually you would store windows
+ // in an array if your app supports multi windows, this is the time
+ // when you should delete the corresponding element.
+ legalWindow = null
+ })
+}
*/
function init() {
-
+
// Canvas
canvas = document.getElementById("sphere");
-
+
canvas.style.height = '100%';
canvas.style.width = '100%';
-
+
// Renderer
renderer = new THREE.WebGLRenderer( { antialias: true, canvas: canvas });
renderer.setClearColor( 0xffffff );
controls.rotateSpeed = 5;
controls.noZoom = true;
controls.noPan = true;
-
+
controls.dynamicDampingFactor = 0.2;
-
+
// Scene
scene = new THREE.Scene();
// Sphere
-
+
// Top
- var sphereGeometry = new THREE.SphereGeometry( 1, 10, 10,0,Math.PI,0,Math.PI);
+ var sphereGeometry = new THREE.SphereGeometry( 1, 10, 10,0,Math.PI,0,Math.PI);
var sphereMaterial = new THREE.MeshBasicMaterial({ color:0x0000ff, transparent: true, opacity:0.25});
-
+
var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial );
//scene.add(sphere);
-
+
var sphereMaterial = new THREE.MeshBasicMaterial({ color:0x0000ff, transparent: true, opacity:0.25, wireframe:true});
-
+
var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial );
scene.add(sphere);
-
+
// Bottom
- var sphereGeometry = new THREE.SphereGeometry( 1, 10, 10,Math.PI,Math.PI,0,Math.PI);
+ var sphereGeometry = new THREE.SphereGeometry( 1, 10, 10,Math.PI,Math.PI,0,Math.PI);
var sphereMaterial = new THREE.MeshBasicMaterial({ color:0x8d4f1a, transparent: true, opacity:0.5});
-
+
var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial );
//scene.add(sphere);
-
+
var sphereMaterial = new THREE.MeshBasicMaterial({ color:0x8d4f1a, transparent: true, opacity:0.5, wireframe:true});
-
+
var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial );
scene.add(sphere);
-
+
// Ground
var groundGeometry = new THREE.CircleGeometry(1,10);
var groundMaterial = new THREE.MeshBasicMaterial({ color:0x328327, transparent: true, opacity:0.5});
groundMaterial.side = THREE.DoubleSide;
-
+
var ground = new THREE.Mesh(groundGeometry, groundMaterial);
scene.add(ground);
-
+
// Cube
var cubeGeometry = new THREE.BoxGeometry(0.5,0.5,0.1);
var cubeMaterial = new THREE.MeshBasicMaterial( { color: 0x000000, wireframe:false});
-
+
var cube = new THREE.Mesh(cubeGeometry,cubeMaterial);
-
+
scene.add(cube);
-
+
// Sources
sourceGroup = new THREE.Group();
var sourceGeometry = new THREE.SphereGeometry( 0.08, 10, 10);
-
+
rgbValueStrings.forEach(function(color) {
-
+
var sourceMaterial = new THREE.MeshBasicMaterial( {color: color, wireframe:false} );
var source = new THREE.Mesh( sourceGeometry, sourceMaterial );
source.visible = false;
-
+
sources3D.push(source);
sourceGroup.add(source);
});
scene.add( sourceGroup );
-
+
// Potential sources
potGroup = new THREE.Group();
scene.add(potGroup);
-
+
/*
* Draw sub canvas with axis
*/
-
+
// Canvas
subCanvas = document.getElementById("axis");
-
+
// Renderer
subRenderer = new THREE.WebGLRenderer( { antialias: true, canvas: subCanvas });
subRenderer.setClearColor(0xffffff);
subRenderer.setSize(80,80);
-
+
// Scene
subScene = new THREE.Scene();
-
+
// Camera
subCamera = new THREE.PerspectiveCamera(90,1,0.1,5);
subCamera.position.z = 3.5;
subCamera.up = camera.up;
-
+
// Axis
var axis = new THREE.AxisHelper(1.2);
scene.add( axis );
var subAxis = new THREE.AxisHelper(1.2);
subScene.add( subAxis );
-
+
// Add axes labels
var loader = new THREE.FontLoader();
- loader.load( 'fonts/helvetiker_regular.typeface.json', function ( helFont ) {
-
+ loader.load( './../ressources/fonts/helvetiker_regular.typeface.json', function ( helFont ) {
+
var textGeo = new THREE.TextGeometry('X', {
size: 0.3,
height: 0.001,
curveSegments: 6,
font: helFont,
- style: "normal"
+ style: "normal"
});
var textMaterial = new THREE.MeshBasicMaterial({ color: "rgb(255,0,0)" });
labelX.position.y = 0.01;
labelX.position.z = 0;
subScene.add(labelX);
-
+
var textGeo = new THREE.TextGeometry('Y', {
size: 0.3,
height: 0.001,
curveSegments: 6,
font: helFont,
- style: "normal"
+ style: "normal"
});
var textMaterial = new THREE.MeshBasicMaterial({ color: "rgb(0,255,0)" });
labelY.position.y = 1.2;
labelY.position.z = 0;
subScene.add(labelY);
-
+
var textGeo = new THREE.TextGeometry('Z', {
size: 0.3,
height: 0.001,
curveSegments: 6,
font: helFont,
- style: "normal"
+ style: "normal"
});
var textMaterial = new THREE.MeshBasicMaterial({ color: "rgb(0,0,255)" });
labelZ.position.y = 0.01;
labelZ.position.z = 1.2;
subScene.add(labelZ);
-
+
} );
window.addEventListener( 'resize', onWindowResize, false );
* Resize canvas and renderer when page is resized
*/
function onWindowResize() {
-
+
camera.aspect = canvas.offsetWidth/canvas.offsetHeight ;
camera.updateProjectionMatrix();
renderer.setSize(canvas.offsetWidth,canvas.offsetHeight);
-
+
canvas.style.height = '100%';
canvas.style.width = '100%';
}
*/
function animate() {
-
+
requestAnimationFrame( animate );
-
+
if(controls.enabled)
controls.update();
-
+
try {
subCamera.rotation.copy(camera.rotation);
subCamera.position.copy(camera.position);
labelY.rotation.copy(camera.rotation);
labelZ.rotation.copy(camera.rotation);
}
-
+
catch(err) {
// Scene not loaded
}
-
+
finally {
render();
}
}
function render() {
-
+
renderer.render( scene, camera );
subRenderer.render( subScene, subCamera);
-
+
}
/*
// Update on new event
document.addEventListener('tracking', function(e) {
-
+
// Clear older trail pixels
if(sources3DTrail.length > 0) {
-
+
sources3DTrail.forEach(function(src,i) {
src.life--;
-
+
if(src.life < 1) { // Dispose of pixel if life is over
-
+
src.obj.material.dispose();
src.obj.geometry.dispose();
src.obj.parent.remove(src.obj);
}
})
}
-
+
// Update source on sphere
currentFrame.sources.forEach(function(source,index) {
-
+
sources3D[index].visible = filterManager.showSources && source.active && source.selected && !(source.x == 0 && source.y == 0 && source.z == 0);
-
+
sources3D[index].position.x = source.x;
sources3D[index].position.y = source.y;
sources3D[index].position.z = source.z;
-
+
// Add a pixel to the tail if the source is visible
if( sources3D[index].visible ) {
-
+
var geo = new THREE.Geometry();
var ps = new THREE.Vector3(source.x,source.y,source.z);
geo.vertices.push(ps);
// Update visibility when selection is changed
document.addEventListener('update-selection',function(e){
-
+
currentFrame.sources.forEach(function(source,index) {
sources3D[index].visible = filterManager.showSources && source.active && source.selected && !(source.x == 0 && source.y == 0 && source.z == 0);
- });
+ });
});
/*
// Update on 'potential' event
document.addEventListener('potential', function(e) {
-
+
// Remove old trail points
if(potSources3D.length > 0) {
-
+
potSources3D.forEach(function(src,i) {
src.life--;
-
+
if(src.life < 1) { // Dispose if life is over
src.obj.material.dispose();
src.obj.geometry.dispose();
}
})
}
-
+
// Add potential source to sphere if potential source filter is selected
if(currentFrame.potentialSources.length > 0 && filterManager.showPotentials) {
-
+
currentFrame.potentialSources.forEach(function(s) {
-
+
if ( energyIsInRange(s.e) ) { // Add source if source's energy's in range
var geo = new THREE.Geometry();
var ps = new THREE.Vector3(s.x,s.y,s.z);
geo.vertices.push(ps);
-
+
var sys = new THREE.Points(geo,potSourceMaterial[scaleEnergy(s.e)]);
potSources3D.push({obj:sys,life:50});
potGroup.add(sys);
}
});
-
+
}
});
*/
document.addEventListener('clearChart',function(e) {
-
+
if(potSources3D.length > 0) {
-
+
potSources3D.forEach(function(src,i) {
src.obj.material.dispose();
src.obj.geometry.dispose();
src.obj.parent.remove(src.obj);
});
}
-
+
potSources3D = [];
-
+
if(sources3DTrail.length > 0) {
-
+
sources3DTrail.forEach(function(src,i) {
src.obj.material.dispose();
src.obj.geometry.dispose();
src.obj.parent.remove(src.obj);
});
}
-
+
sources3DTrail = [];
});
*/
var viewFront = function() {
-
+
camera.up.set(0,0,1);
-
+
camera.position.x = 0;
camera.position.y = -camOffset;
camera.position.z = 0;
-
+
controls.reset();
};
* Web Socket connection to server
*/
-// Generate websocket server URL
-var loc = window.location, new_uri, sys_uri, pot_uri;
-
-if (loc.protocol === "https:") {
- new_uri = "wss:";
-} else {
- new_uri = "ws:";
-}
-
-audio_uri = new_uri + "//" + loc.host + "/audio";
-sys_uri = new_uri + "//" + loc.host + "/system.info";
-pot_uri = new_uri + "//" + loc.host + "/potential";
-new_uri += "//" + loc.host + "/tracking";
+ const ipcRenderer = require('electron').ipcRenderer
/*
* Tracking data socket
*/
-// Open socket and create parser
-var socket = new WebSocket(new_uri);
-console.log(new_uri);
-
// Update current data with received data
var indexMap = {};
-socket.onmessage = function(msg) {
-
- try {
- var strData = msg.data;
- var data = JSON.parse(strData);
+const processTracking = function(event, msg) {
+
+ try {
+ var data = JSON.parse(msg);
}
catch(err) {
// Can't parse frame
console.error(err);
- console.log(strData);
+ console.log(msg);
return;
}
-
+
if(Math.abs(data.timeStamp - currentFrame.timestamp) > 1)
console.warn('Frame skipped ' + data.timeStamp.toString());
indexPool.push(index);
});
var hasNewSource = false;
-
+
data.src = data.src.filter(function(s) {
return s.id !== 0;
});
-
+
if(data.src) { // If frame contains sources
data.src.forEach(function(src) { // Remove still used index from the pool
-
+
if(typeof(indexMap[src.id])!='undefined') { // If source is not new
indexPool.splice(indexPool.indexOf(indexMap[src.id]),1);
//console.log(indexPool);
}
});
-
+
data.src.forEach(function(src) { // Update sources
if(typeof(indexMap[src.id])!='undefined') { // Source is already registered
currentFrame.sources[newMap[src.id]].active = !(src.x==0 && src.y==0 && src.z==0);
});
-
+
}
-
+
indexMap = newMap;
-
+
indexPool.forEach(function(index) { // Clear unused source slot
-
+
currentFrame.sources[index].id = null;
-
+
currentFrame.sources[index].x = null;
currentFrame.sources[index].y = null;
currentFrame.sources[index].z = null;
-
+
currentFrame.sources[index].active = false;
currentFrame.sources[index].selected = true;
});
// Trigger update
document.dispatchEvent(new Event('tracking'));
-
+
if(hasNewSource)
document.dispatchEvent(new Event('update-selection'));
};
+ipcRenderer.on('newTracking', processTracking)
+
/*
* Potential sources socket
*/
-var potentialSocket = new WebSocket(pot_uri);
-console.log(pot_uri);
-
// Update current data with received potential sources
-potentialSocket.onmessage = function(msg) {
-
- try {
- var strData = msg.data;
- var data = JSON.parse(strData);
+const processPotential = function(event, msg) {
+
+ try {
+ var data = JSON.parse(msg);
}
catch(err) {
// Can't parse frame
console.error(err);
- console.log(strData);
+ console.log(msg);
return;
}
-
+
if(Math.abs(data.timeStamp - currentFrame.ptimestamp) > 1)
console.warn('Frame skipped ' + data.timeStamp.toString());
currentFrame.ptimestamp = data.timeStamp;
currentFrame.potentialSources = [];
-
+
if(data.src) { // If frame contains sources
-
+
data.src.forEach(function(source) {
-
+
var newSource = new PotentialSource();
-
+
newSource.e = source.E;
newSource.x = source.x;
newSource.y = source.y;
newSource.z = source.z;
-
+
currentFrame.potentialSources.push(newSource);
-
+
});
-
+
}
// Trigger update
};
+ipcRenderer.on('newPotential', processPotential)
+
/*
* Frame reset when no data is received
*/
document.addEventListener('clearChart', function(e){
-
+
currentFrame.timestamp = 0;
currentFrame.ptimestamp = 0;
-
+
currentFrame.sources.forEach(function(source){
source.id = null;
-
+
source.x = null;
source.y = null;
source.z = null;
-
+
source.active = false;
source.selected = true;
});
-
+
currentFrame.potentialSources = [];
-
+
document.dispatchEvent(new Event('tracking'));
document.dispatchEvent(new Event('potential'));
document.dispatchEvent(new Event('update-selection'));
-
+
sourceManager.showPotentials = true;
document.dispatchEvent(new Event('potential-visibility'));
-
+
viewFront();
-
+
var req = setInterval(function() {
-
+
document.dispatchEvent(new Event('request-chart'));
-
+
hasPotential = false;
clearInterval(req);
console.log('UI cleaned');
-
+
},500);
});
-/*
- * System info socket
- */
-
-var systemSocket = new WebSocket(sys_uri);
-
-systemSocket.onmessage = function(msg) {
-
- var data = JSON.parse(msg.data);
-
- systemMonitor.system.cpu = data.cpu.toPrecision(3).toString() + ' %';
- systemMonitor.system.mem = data.mem.toPrecision(2).toString() + ' %';
- systemMonitor.system.temp = data.temp.toPrecision(3).toString() + ' °C';
-};
-
/*
* Audio socket
*/
-var audioSocket = new WebSocket(audio_uri);
-audioSocket.onmessage = function(msg) {
-
+const processAudio = function(msg) {
+
var reader = new FileReader();
-
+
reader.onloadend = function() {
document.dispatchEvent(new CustomEvent('audioData', { 'detail': reader.result}));
};
- reader.readAsArrayBuffer(msg.data);
-};
\ No newline at end of file
+ reader.readAsArrayBuffer(msg.data);
+};
// Websocket to stream tracking
app.ws('/tracking',function(ws, req) {
-
+
// Sends new data to client
var sendData = function(data) {
-
+
try {
ws.send(data);
}
-
+
catch(e) {
console.warn('Socket closed');
}
};
-
+
// Register client to event
eventEmitter.on('newTracking',sendData);
console.log('registered tracking');
-
+
// Remove listener when connection closes
ws.on('close', function() {
eventEmitter.removeListener('newTracking',sendData);
// Websocket to stream potential sources
app.ws('/potential',function(ws, req) {
-
+
// Sends new data to client
var sendData = function(data) {
-
+
try {
ws.send(data);
}
-
+
catch(e) {
console.warn('Socket closed');
}
};
-
+
// Register client to event
eventEmitter.on('newPotential',sendData);
console.log('registered potential');
-
+
// Remove listener when connection closes
ws.on('close', function() {
eventEmitter.removeListener('newPotential',sendData);
// Websocket to stream system information
app.ws('/system.info',function(ws, req) {
-
+
// Sends new data to client
var sendData = function(data) {
-
+
try {
ws.send(JSON.stringify(data));
}
-
+
catch(e) {
console.warn('Socket closed');
}
};
-
+
// Register client to event
eventEmitter.on('sysInfo',sendData);
console.log('registered sysInfo');
-
+
// Remove listener when connection closes
ws.on('close', function() {
eventEmitter.removeListener('sysInfo',sendData);
// Websocket to stream audio
app.ws('/audio',function(ws, req) {
-
+
// Sends new data to client
var sendData = function(data) {
-
+
try {
ws.send(data);
console.log(`Sent audio on ${new Date().getTime()}`);
}
-
+
catch(e) {
console.warn('Socket closed');
}
};
-
+
// Register client to event
eventEmitter.on('newAudio',sendData);
console.log('registered audio');
-
+
// Remove listener when connection closes
ws.on('close', function() {
eventEmitter.removeListener('newAudio',sendData);
// Load modules
var net = require('net');
-var server = net.createServer();
+var server = net.createServer();
server.on('connection', handleConnection);
-server.listen(9000, function() {
+server.listen(9000, function() {
console.log('server listening to %j', server.address());
});
-function handleConnection(conn) {
+function handleConnection(conn) {
var remoteAddress = conn.remoteAddress + ':' + conn.remotePort;
console.log('new client connection from %s', remoteAddress);
conn.on('error', onConnError);
function onConnData(d) {
-
+
var decoder = new StringDecoder();
-
+
// Decode received string
var str = decoder.write(d);
-
+
eventEmitter.emit('newTracking',str);
}
* Create TCP server for potential sources
*/
-var potentialServer = net.createServer();
+var potentialServer = net.createServer();
potentialServer.on('connection', handlePotConnection);
-potentialServer.listen(9001, function() {
+potentialServer.listen(9001, function() {
console.log('server listening to %j', potentialServer.address());
});
-function handlePotConnection(conn) {
+function handlePotConnection(conn) {
var remoteAddress = conn.remoteAddress + ':' + conn.remotePort;
console.log('new client connection from %s', remoteAddress);
conn.on('error', onConnError);
function onConnData(d) {
-
+
var decoder = new StringDecoder();
-
+
// Decode received string
var str = decoder.write(d);
-
+
eventEmitter.emit('newPotential',str);
}
*/
// Load modules
-var si = require('systeminformation');
-
-function updateSi() { // Gather params
-
- var sysInfo = {cpu:0,mem:0,temp:0};
-
- si.currentLoad(function(data) {
- sysInfo.cpu = data.currentload;
-
- si.mem(function(data) {
- sysInfo.mem = (data.active/data.total)*100;
-
- si.cpuTemperature(function(data) {
- sysInfo.temp = data.main;
- eventEmitter.emit('sysInfo',sysInfo);
- });
- });
- });
-
-}
-// Schedule update
-setInterval(updateSi,500);
/*
* Audio stream server
*/
-var audioServer = net.createServer();
+var audioServer = net.createServer();
audioServer.on('connection', handleAudioConnection);
-audioServer.listen(10001, function() {
+audioServer.listen(10001, function() {
console.log('server listening to %j', audioServer.address());
});
-function handleAudioConnection(conn) {
-
+function handleAudioConnection(conn) {
+
var remoteAddress = conn.remoteAddress + ':' + conn.remotePort;
console.log('new client connection from %s', remoteAddress);
conn.on('error', onConnError);
function onConnData(d) {
-
- console.log(`Received audio on ${new Date().getTime()}`);
+
+ console.log(`Received audio on ${new Date().getTime()}`);
eventEmitter.emit('newAudio',d);
}
var dummyPorts = [];
for(n = 2; n<=16; n++) {
-
+
var dummy = net.createServer();
-
+
dummy.on('connection', function(conn) {
// Dummy
});
-
+
dummy.listen(10000+n);
console.log(`Dummy listen on ${10000+n}`);
-
+
dummyPorts.push(dummy);
-
+
}
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Legal</title>
- <link href="css/bootstrap.css" rel="stylesheet">
- <link href="css/style.css" rel="stylesheet">
+ <link href="../ressources/css/bootstrap.css" rel="stylesheet">
+ <link href="../ressources/css/style.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-default bg-primary navbar-fixed-top ">
- <div class="container-fluid">
-
+ <div class="container-fluid">
<div class="navbar-header">
- <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-content" aria-expanded="false">
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- <a class="navbar-brand navbar-logo" width="120" href="https://github.com/introlab/odas"><img src="images/introlab_icon.png"></a>
+ <a class="navbar-brand navbar-logo" width="120" href="https://github.com/introlab/odas"><img src="../ressources/images/introlab_icon.png"></a>
<a class="navbar-brand" width="120" href="https://github.com/introlab/odas"><span>ODAS</span></a>
</div>
-
- <div class="collapse navbar-collapse" id="navbar-content">
- <ul class="nav navbar-nav navbar-right">
- <li><a href='/'>Live Data</a></li>
- <li><a href="/config">Configure</a></li>
- </ul>
- </div>
-
</div>
</nav>
<p>
The MIT License (MIT)<br>
<br>
- Copyright 2017 IntRoLab<br>
+ Copyright <script>document.write(new Date().getFullYear())</script> IntRoLab<br>
<br>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
</div>
</div>
</div>
-
+
<footer class="footer">
<div class="container-fluid">
<div class="row">
<p class="col-xs-10 text-muted">ODAS platform web interface</p>
- <a href="/legal" class="col-xs-2 text-right">Legal</a>
+ <a href="javascript:window.close()" class="col-xs-2 text-right">Close</a>
</div>
</div>
</footer>
-
- <script src="js/jquery.min.js"></script>
- <script src="js/bootstrap.min.js"></script>
</body>
-</html>
\ No newline at end of file
+</html>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
-
+
<title>Live Data</title>
- <link rel="icon" href="images/introlab_icon.png">
-
- <link href="css/bootstrap.css" rel="stylesheet">
- <link href="css/style.css" rel="stylesheet">
- <link href="css/bootstrap_slider.css" rel="stylesheet">
+ <link rel="icon" href="./../ressources/images/introlab_icon.png">
+
+ <link href="./../ressources/css/bootstrap.css" rel="stylesheet">
+ <link href="./../ressources/css/style.css" rel="stylesheet">
+ <link href="./../ressources/css/bootstrap_slider.css" rel="stylesheet">
</head>
<body>
<div class="wrapper">
<nav class="navbar navbar-default bg-primary navbar-fixed-top ">
- <div class="container-fluid">
+ <div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-content" aria-expanded="false">
<button type="button" class="navbar-toggle collapsed navbar-button" data-toggle="collapse" data-target="#source-list" aria-expanded="false">
Sources
</button>
- <a class="navbar-brand navbar-logo" width="120" href="https://github.com/introlab/odas"><img src="images/introlab_icon.png"></a>
+ <a class="navbar-brand navbar-logo" width="120" href="https://github.com/introlab/odas"><img src="./../ressources/images/introlab_icon.png"></a>
<a class="navbar-brand" width="120" href="https://github.com/introlab/odas"><span>ODAS</span></a>
</div>
<div class="collapse navbar-collapse" id="navbar-content">
<ul class="nav navbar-nav navbar-right">
- <li><a href='/'>Live Data</a></li>
- <li><a href="/config">Configure</a></li>
+ <li><a href='#'>Live Data</a></li>
+ <li><a href="#">Configure</a></li>
</ul>
</div>
<div class="container-fluid content main">
<div class="row content">
- <div class="col-md-3 col-lg-2 layout darker">
+ <div class="col-md-3 layout darker">
<h2>ODAS Data</h2>
<div class="well" id="system-monitor">
<form>
</form>
</div>
</div>
- <div class="col-md-7 col-lg-8 layout">
+ <div class="col-md-7 layout">
<div class="row graph-row">
<div class="col-xs-12 content">
<h4 class="abs_head">Source Elevation</h4>
</div>
<div class="col-md-2 layout darker">
<div class="collapse navbar-collapse" id="source-list">
-
+
<h2>Sources</h2>
<table class="table table-hover" id="source_table">
<tr v-for = "source in sources">
</td>
</tr>
</table>
-
+
<h2>Filters</h2>
<table class="table table-hover" id="filter_table">
<tr>
<p>Potential sources energy range:</p>
<b id="left-marker">0</b>
<input id="range_slider" type="text" class="span2" value="" data-slider-min="0" data-slider-max="1" data-slider-step="0.05" data-slider-value="[0,1]"/>
- <b id="right-marker">1</b>
+ <b id="right-marker">1</b>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<p class="col-xs-10 text-muted">ODAS platform web interface</p>
- <a href="/legal" class="col-xs-2 text-right">Legal</a>
+ <a href="#" class="col-xs-2 text-right" onclick="openLegalWindow()">Legal</a>
</div>
</div>
</footer>
</div>
- <script src="js/jquery.min.js"></script>
- <script src="js/bootstrap.min.js"></script>
-
- <script src="js/vue.js"></script>
- <script src="js/bootstrap_slider.js"></script>
- <script src="js/interface.js"></script>
-
-
- <script src="js/tcp_link.js"></script>
-
- <script src="js/three.min.js"></script>
- <script src="js/stats.min.js"></script>
- <script src="js/TrackballControls.js"></script>
-
- <script src="js/Chart.bundle.min.js"></script>
- <script src="js/graph.js"></script>
-
- <script src="js/source_sphere.js"></script>
-
- <script src="js/audio_stream.js"></script>
+ <script>window.$ = window.jQuery = require('./../ressources/js/jquery.min.js');</script>
+ <script src="./../ressources/js/bootstrap.min.js"></script>
+
+ <script src="./../ressources/js/vue.js"></script>
+ <script src="./../ressources/js/bootstrap_slider.js"></script>
+ <script src="./../ressources/js/interface.js"></script>
+
+ <script src="./../ressources/js/tcp_link.js"></script>
+
+ <script src="./../ressources/js/three.min.js"></script>
+ <script src="./../ressources/js/stats.min.js"></script>
+ <script src="./../ressources/js/TrackballControls.js"></script>
+
+ <script src="./../ressources/js/Chart.bundle.min.js"></script>
+ <script src="./../ressources/js/graph.js"></script>
+
+ <script src="./../ressources/js/source_sphere.js"></script>
+
+ <script src="./../ressources/js/audio_stream.js"></script>
+
+ <script src="./../ressources/js/legal.js"></script>
</body>
</html>