From 68508b2e44f29ef5209c2989ebf0b4c558556a92 Mon Sep 17 00:00:00 2001 From: Lucio Zambon <lucio.zambon@elettra.eu> Date: Mon, 17 Feb 2025 00:14:27 +0000 Subject: [PATCH] Update gof2d.js --- gof2d.js | 100 ++++++++++++------------------------------------------- 1 file changed, 22 insertions(+), 78 deletions(-) diff --git a/gof2d.js b/gof2d.js index 2229a79..b103825 100644 --- a/gof2d.js +++ b/gof2d.js @@ -19,20 +19,20 @@ return defaultValue; } if (document.location.search.indexOf('machine=esrf')>-1 || document.location.search.indexOf('machine=gof_esrf')>-1) { - gofFactorsHor = {"": 1, "corr": 100000, 'beta': 0.2, 'eta': 100, 'mu': 0.2, 'sigma': 20000000000}; - gofFactorsVer = {"": 1, "corr": 1, 'beta': 0.1, 'eta': 100, 'mu': 0.2, 'sigma': 50000000000}; + gofFactorsHor = {"": 1, "corr": 100000, 'bpm': getParam('positionScaleH', 0.00002)}; + gofFactorsVer = {"": 1, "corr": 1, 'bpm': getParam('positionScaleV', 0.00002)}; } else if (document.location.search.indexOf('machine=gof_soleil')>-1) { - gofFactorsHor = {"": 1, "corr": 50000, 'beta': 0.2, 'eta': 50, 'mu': 0.2, 'sigma': 20000000000}; - gofFactorsVer = {"": 1, "corr": 10000, 'beta': 0.1, 'eta': 100, 'mu': 0.2, 'sigma': 50000000000}; + gofFactorsHor = {"": 1, "corr": 50000, 'bpm': getParam('positionScaleH', 0.00002)}; + gofFactorsVer = {"": 1, "corr": 10000, 'bpm': getParam('positionScaleV', 0.00002)}; } else if (document.location.search.indexOf('machine=elettra2')>-1) { - gofFactorsHor = {"": 1, "corr": 500000, 'beta': 0.2, 'eta': 50, 'mu': 0.2, 'sigma': 20000000000}; - gofFactorsVer = {"": 1, "corr": 500000, 'beta': 0.1, 'eta': 100, 'mu': 0.2, 'sigma': 50000000000}; + gofFactorsHor = {"": 1, "corr": 500000, 'bpm': getParam('positionScaleH', 0.00002)}; + gofFactorsVer = {"": 1, "corr": 500000, 'bpm': getParam('positionScaleV', 0.00002)}; } else { - gofFactorsHor = {"": 1, "corr": getParam('positionScaleH', 0.005), 'beta': 0.5, 'eta': 100, 'mu': 0.2, 'sigma': 5000000000000}; - gofFactorsVer = {"": 1, "corr": getParam('positionScaleV', 0.005), 'beta': 0.25, 'eta': 100, 'mu': 0.2, 'sigma': 5000000000000}; + gofFactorsHor = {"": 1, "corr": getParam('positionScaleH', 0.005), 'bpm': getParam('positionScaleH', 0.00002)}; + gofFactorsVer = {"": 1, "corr": getParam('positionScaleV', 0.005), 'bpm': getParam('positionScaleV', 0.00002)}; } let gof = document.location.search.indexOf('gof=')>-1? document.location.search.split('gof=')[1].split('&')[0]: ''; const gofTimeout = document.location.search.indexOf('gofTimeout=')>-1? document.location.search.split('gofTimeout=')[1].split('&')[0]: 10; @@ -325,66 +325,7 @@ gofData.reader.clearInterval(); gofMaxFps = 0; } - else if (params.gof=='bpm') { - $('#fps').show(); - $('#fpsr').show(); - $('#scaleh').show(); - $('#scalev').show(); - $('#trajectoryWidth').show(); - $('#ruler').show(); - $('#notice').show(); - for (let facility in gofData) { - if (typeof $('#'+facility+"_gofbpmhor").attr('visibility') != 'undefined') { - $('#'+facility+"_gofbpmhor").attr('visibility', "visible"); - $('#'+facility+"_gofbpmver").attr('visibility', "visible"); - } - if (typeof gofData[facility] == 'undefined' || typeof gofData[facility].bpmMap == 'undefined') continue; - gofData.oldIndex = facility; - gofRead(gofData, params); - } - displayer = setInterval(gofDisplay, gofDisplayerPeriod, params); - if (gofTimeout) { - setTimeout(gofRead, gofTimeout, gofData, params); - } - else { - gofData.reader = setInterval(gofRead, gofPeriod, gofData, params); - } - $('.gofhor').css('display', 'block'); - $('.gofver').css('display', 'block'); - gofFactorHor = localStorage.getItem('scale'+gof+'hor')!=null? localStorage.getItem('scale'+gof+'hor')-0: gofFactorsHor[menuParams.gof]*1000; - gofFactorVer = localStorage.getItem('scale'+gof+'ver')!=null? localStorage.getItem('scale'+gof+'ver')-0: gofFactorsVer[menuParams.gof]*1000; - if (gofScaleType == 'slider') { - const fHor = gofFactorHor/1000; - menuParams['scale H'] = fHor; - const mxHor = Math.pow(10, Math.floor(Math.log10(fHor))+1); - gofScaleHor.max(mxHor); - gofScaleHor.min(mxHor/100); - gofScaleHor.step(mxHor/1000); - gofScaleHor.setValue(fHor); - const fVer = gofFactorVer/1000; - menuParams['scale V'] = fVer; - const mxVer = Math.pow(10, Math.floor(Math.log10(fVer))+1); - gofScaleVer.max(mxVer); - gofScaleVer.min(mxVer/100); - gofScaleVer.step(mxVer/1000); - gofScaleVer.setValue(fVer); - } - else { - document.getElementById("horgauge").contentWindow.maxval = Math.pow(10, Math.floor(Math.log10(gofFactorsHor[params.gof]))+2); - document.getElementById("horgauge").contentWindow.reset(); - document.getElementById("horgauge").contentWindow.setVal(gofFactorsHor[params.gof]); - document.getElementById("vergauge").contentWindow.maxval = Math.pow(10, Math.floor(Math.log10(gofFactorsVer[params.gof]))+2); - document.getElementById("vergauge").contentWindow.reset(); - document.getElementById("vergauge").contentWindow.setVal(gofFactorsVer[params.gof]); - $('.gofgauge').show(); - } - gPos = $("#fps").children().eq(1).children()[0].getBoundingClientRect(); - $('#fpsr').css('left', gPos.left); - $('#fpsr').css('top', gPos.top+gPos.height-3); - } else { - // $('#application').show(); - // $('#applicationReference').show(); $('#fps').show(); $('#fpsr').show(); $('#scaleh').show(); @@ -394,10 +335,10 @@ $('#notice').show(); for (let facility in gofData) { if (typeof $('#'+facility+"_gofhor").attr('visibility') != 'undefined') { - $('#'+facility+"_gofhor").attr('visibility', "visible"); - $('#'+facility+"_gofver").attr('visibility', "visible"); + $('#'+facility+"_gof"+(params.gof=='corr'? '': params.gof)+"hor").attr('visibility', "visible"); + $('#'+facility+"_gof"+(params.gof=='corr'? '': params.gof)+"ver").attr('visibility', "visible"); } - if (typeof gofData[facility] == 'undefined' || typeof gofData[facility].corrMap == 'undefined') continue; + if (typeof gofData[facility] == 'undefined' || typeof gofData[facility][params.gof+'Map'] == 'undefined') continue; gofData.oldIndex = facility; gofRead(gofData, params); } @@ -444,6 +385,8 @@ } function gofRender(facility, gb, gof) { // console.log('gofRender(), gb', gb, gof); + const horIndex = gof=='corr'? 0: 2; + const verIndex = gof=='corr'? 1: 3; gofDataHor = []; gofDataVer = []; let refHor, refVer; @@ -451,12 +394,12 @@ const referencever = JSON.parse(localStorage.getItem('reference'+gof+'ver')); $('#hor_set').css('background-color',localStorage.getItem('reference'+gof+'hor')!=null?'red':''); $('#ver_set').css('background-color',localStorage.getItem('reference'+gof+'ver')!=null?'green':''); - if (gb[0]) { - const valh = gb[0].split(','); - const valv = gb[1].split(','); - console.log('gofRender(), valh', valh); + if ((gof!='') && gb[horIndex]) { + const valh = gb[horIndex].split(','); + const valv = gb[verIndex].split(','); + console.log('gofRender(), valh, valv', valh, valv, gof, compData[facility].bpmMap); for (i=0; i<valh.length; i++) { - if (gof!='bpm' && typeof compData[facility].corrMap[i] == 'undefined') continue; + if (gof=='corr' && typeof compData[facility].corrMap[i] == 'undefined') continue; if (gof=='bpm' && typeof compData[facility].bpmMap[i] == 'undefined') continue; const j = gof=='bpm'? compData[facility].bpmMap[i]: compData[facility].corrMap[i]; if (document.location.search.indexOf('pulse=')>-1 && i!=document.location.search.split('pulse=')[1].split('&')[0]) {valh[i] = 0;} @@ -466,6 +409,7 @@ const vh = localStorage.getItem('reference'+gof+'hor')==null? valh[i]-0: valh[i] - referencehor[i]; // https://en.wikipedia.org/wiki/Logarithmic_scale#Extensions const valHor = gofLogScaleHor? Math.sign(vh)*Math.log10(1+ Math.abs(vh*Math.LN10)): vh; + // console.log(i, j, pos, beta, vh, valHor); const vv = localStorage.getItem('reference'+gof+'ver')==null? valv[i]-0: valv[i] - referencever[i]; const valVer = gofLogScaleVer? Math.sign(vv)*Math.log10(1+ Math.abs(vv*Math.LN10)): vv; gofDataHor.push((gofDataHor.length==0?'M':'L')+ @@ -477,10 +421,10 @@ Math.round(pos[1] + valVer*gofFactorVer*Math.cos(beta)) ); } - console.log('Hor', gofDataHor.join(' ')+(lattice[facility].sections[0].chamber?' Z':'')); + // console.log('Hor', gofDataHor.join(' ')+(lattice[facility].sections[0].chamber?' Z':'')); if (gof=='bpm') { - $('#'+facility+"_gofbpmhor").attr('d', gofDataHor.join(' ')+(lattice[facility].sections[0].chamber?' Z':'')); - $('#'+facility+"_gofbpmver").attr('d', gofDataVer.join(' ')+(lattice[facility].sections[0].chamber?' Z':'')); + $('#'+facility+"_gofbpmhor").attr('d', gofDataHor.join(' ').replaceAll('LNaN NaN L','L')+(lattice[facility].sections[0].chamber?' Z':'')); + $('#'+facility+"_gofbpmver").attr('d', gofDataVer.join(' ').replaceAll('LNaN NaN L','L')+(lattice[facility].sections[0].chamber?' Z':'')); } else { $('#'+facility+"_gofhor").attr('d', gofDataHor.join(' ')+(lattice[facility].sections[0].chamber?' Z':'')); -- GitLab