Skip to content
Snippets Groups Projects
Commit c344ec75 authored by Lucio Zambon's avatar Lucio Zambon
Browse files

Update simulator2d.js

parent e713f350
No related branches found
No related tags found
No related merge requests found
// jshint esversion: 6 // jshint esversion: 6
let factorsHor, factorsVer; let factorsHor, factorsVer;
let simulatorTimestamp, simulatorDataTs;
if (document.location.search.indexOf('machine=esrf')>-1 || document.location.search.indexOf('machine=simulator_esrf')>-1) { if (document.location.search.indexOf('machine=esrf')>-1 || document.location.search.indexOf('machine=simulator_esrf')>-1) {
factorsHor = {"": 1000, "position": 100000, 'beta': 0.2, 'eta': 100, 'mu': 0.2, 'sigma': 20000}; factorsHor = {"": 1000, "position": 100000, 'beta': 0.2, 'eta': 100, 'mu': 0.2, 'sigma': 20000};
factorsVer = {"": 1000, "position": 1000, 'beta': 0.1, 'eta': 100, 'mu': 0.2, 'sigma': 50000}; factorsVer = {"": 1000, "position": 1000, 'beta': 0.1, 'eta': 100, 'mu': 0.2, 'sigma': 50000};
...@@ -229,7 +230,7 @@ ...@@ -229,7 +230,7 @@
simulatorMenu(lattice, simfacilities, params); simulatorMenu(lattice, simfacilities, params);
} }
function getRulerPosition(main, event) { function getRulerPosition(main, event) {
console.log('clickStat', clickStat); // console.log('clickStat', clickStat);
if (clickStat) return; if (clickStat) return;
const rect = main.getBoundingClientRect(); const rect = main.getBoundingClientRect();
const x = event.clientX - rect.left; const x = event.clientX - rect.left;
...@@ -250,7 +251,7 @@ ...@@ -250,7 +251,7 @@
const i = dindex; const i = dindex;
const j = (i+1) % lattice.sr.sections.length; const j = (i+1) % lattice.sr.sections.length;
const alpha = 180/Math.PI*Math.atan2(lattice.sr.sections[j].start.z-lattice.sr.sections[i].start.z, lattice.sr.sections[j].start.x-lattice.sr.sections[i].start.x); const alpha = 180/Math.PI*Math.atan2(lattice.sr.sections[j].start.z-lattice.sr.sections[i].start.z, lattice.sr.sections[j].start.x-lattice.sr.sections[i].start.x);
console.log(dindex, p.dist, p.x, p.y, alpha); // console.log(dindex, p.dist, p.x, p.y, alpha);
$('#rulerg').attr('transform', 'translate('+ (p.x)+' '+(p.y)+'),rotate('+alpha+')'); $('#rulerg').attr('transform', 'translate('+ (p.x)+' '+(p.y)+'),rotate('+alpha+')');
} }
function rulerScale() { function rulerScale() {
...@@ -315,7 +316,7 @@ ...@@ -315,7 +316,7 @@
simulatorData.reader = false; simulatorData.reader = false;
if (params.simulator=='position') { if (params.simulator=='position') {
if (machine=='elettra') { if (machine=='elettra') {
if (document.location.host!="mac3d.elettra.eu") { if (document.location.host!="mac3d.elettra.eu") {
$('#applicationFrame').attr("src", 'https://puma-01.elettra.eu/spa/index.html?s=miniSynoptic'); $('#applicationFrame').attr("src", 'https://puma-01.elettra.eu/spa/index.html?s=miniSynoptic');
$('#applicationFrame').css("height", '1000px'); $('#applicationFrame').css("height", '1000px');
} }
...@@ -343,6 +344,7 @@ ...@@ -343,6 +344,7 @@
$('#rulerg').hide(); $('#rulerg').hide();
$('#application').hide(); $('#application').hide();
$('#applicationReference').hide(); $('#applicationReference').hide();
simulatorData.reader.clearInterval();
} }
else { else {
$('#application').show(); $('#application').show();
...@@ -438,16 +440,21 @@ ...@@ -438,16 +440,21 @@
function simulatorDisplay(params) { function simulatorDisplay(params) {
if (simulatorBuffer==false) return; if (simulatorBuffer==false) return;
simulatorRender('sr', simulatorBuffer, params.simulator); simulatorRender('sr', simulatorBuffer, params.simulator);
$('#delay').html(new Date() - simulatorDataTs);
} }
if (document.location.search.indexOf('stats')>-1) {$('#notice').show(); $('#notice').css('color', 'orange'); $('#notice').html('call time: <span id="requiredt"/>, delay: <span id="delay"/>');}
function simulatorRead(simulatorData, params) { function simulatorRead(simulatorData, params) {
// console.log('fetch()',conf.simulatorUrl+'&param='+params.simulator); // console.log('fetch()',conf.simulatorUrl+'&param='+params.simulator);
simulatorTimestamp = new Date() - 0;
fetch((conf.simulatorUrl+'&machine='+machine+'&param='+params.simulator).replace('?&','?'), {cache: "no-store"}) fetch((conf.simulatorUrl+'&machine='+machine+'&param='+params.simulator).replace('?&','?'), {cache: "no-store"})
.then((response) => {return response.json();}) .then((response) => {return response.json();})
.then((eventData) => { .then((eventData) => {
if (document.location.search.indexOf('stats')>-1) {
const requiredt = new Date() - simulatorTimestamp;
simulatorDataTs = eventData.timestamp;
$('#requiredt').html(requiredt);
$('#delay').html(new Date() - simulatorDataTs);
}
simulatorBuffer = eventData.sr; simulatorBuffer = eventData.sr;
// simulatorRender('sr', eventData['sr'], params.simulator);
/*for (let i in eventData) {
simulatorRender(i, eventData[i]);
}*/
}); });
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment