Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PAnTHer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
puma
client
PAnTHer
Commits
bcf508ee
Commit
bcf508ee
authored
10 months ago
by
Lucio Zambon
Browse files
Options
Downloads
Patches
Plain Diff
Update bpm2d.js
parent
e0a01044
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bpm2d.js
+106
-65
106 additions, 65 deletions
bpm2d.js
with
106 additions
and
65 deletions
bpm2d.js
+
106
−
65
View file @
bcf508ee
...
@@ -2,7 +2,38 @@
...
@@ -2,7 +2,38 @@
const
bpmData
=
{};
const
bpmData
=
{};
const
corr
=
{};
const
corr
=
{};
function
bpmMenu
(
lattice
,
facilities
,
params
)
{
function
bpmMenu
(
lattice
,
facilities
,
params
)
{
if
(
document
.
location
.
search
.
indexOf
(
'
new
'
)
>-
1
)
{
bpmMenuNew
(
params
);
return
;}
if
(
document
.
location
.
search
.
indexOf
(
'
old
'
)
>-
1
)
{
bpmMenuOld
(
lattice
,
facilities
,
params
);
return
;}
params
.
bpm
=
''
;
$
(
'
.bpmhor
'
).
css
(
'
display
'
,
'
none
'
);
$
(
'
.bpmver
'
).
css
(
'
display
'
,
'
none
'
);
params
.
bpm
=
document
.
location
.
search
.
indexOf
(
'
bpm
'
)
>-
1
&&
document
.
location
.
search
.
indexOf
(
'
=bpm
'
)
==-
1
;
gui
.
add
(
params
,
'
bpm
'
).
name
(
'
bpm H <img id="h" src="red.svg" style="margin-bottom: -4px;"> V <img id="v" src="green.svg" style="margin-bottom: -4px;">
'
).
onChange
(
function
()
{
bpmSwitch
(
bpmData
,
params
);});
for
(
let
f
in
facilities
)
{
const
b
=
facilities
[
f
];
if
(
b
==
''
||
typeof
bpmData
[
b
]
==
'
undefined
'
||
typeof
lattice
[
b
].
bpm
==
'
undefined
'
||
typeof
lattice
[
b
].
bpm
.
orbitconf
==
'
undefined
'
)
continue
;
console
.
log
(
'
bpmMenu() -
'
,
b
);
// bpmData[b].datasrc = lattice[b].bpm.orbithor+';'+lattice[b].bpm.orbitver;
bpmData
[
b
].
datasrc
=
lattice
[
b
].
bpm
.
orbithor
;
bpmData
[
b
].
map
=
[];
fetch
(
conf
.
rchan
+
lattice
[
b
].
bpm
.
orbitconf
)
.
then
((
response
)
=>
{
return
response
.
json
();})
.
then
((
bpmData2
)
=>
{
let
bpmCounter
=
0
;
let
photoCounter
=
0
;
for
(
let
i
in
bpmData2
)
{
const
name
=
bpmData2
[
i
];
if
(
name
.
indexOf
(
bpmData
[
b
].
skip
)
>-
1
)
continue
;
for
(
let
bl
in
bpmData
[
b
].
obj
)
{
// console.log('b', bl, bpmData[b].obj, bpmData[b].obj[bl]);
if
(
name
==
bpmData
[
b
].
obj
[
bl
])
{
bpmData
[
b
].
map
[
bl
]
=
bpmCounter
;
bpmCounter
++
;}
}
}
console
.
log
(
'
bpmMenu(), name
'
,
b
,
bpmData
[
b
],
lattice
[
b
]);
});
}
}
function
bpmMenuOld
(
lattice
,
facilities
,
params
)
{
if
(
document
.
location
.
search
.
indexOf
(
'
old
'
)
>-
1
)
{
bpmMenuOld
(
lattice
,
facilities
,
params
);
return
;}
params
.
bpm
=
''
;
params
.
bpm
=
''
;
$
(
'
.bpmhor
'
).
css
(
'
display
'
,
'
none
'
);
$
(
'
.bpmhor
'
).
css
(
'
display
'
,
'
none
'
);
$
(
'
.bpmver
'
).
css
(
'
display
'
,
'
none
'
);
$
(
'
.bpmver
'
).
css
(
'
display
'
,
'
none
'
);
...
@@ -32,7 +63,7 @@
...
@@ -32,7 +63,7 @@
});
});
}
}
}
}
function
bpmMenuNew
(
params
)
{
function
bpmMenuNew
(
lattice
,
facilities
,
params
)
{
params
.
bpm
=
''
;
params
.
bpm
=
''
;
bpmSwitchNew
(
params
);
bpmSwitchNew
(
params
);
fetch
(
conf
.
bpmSrcUrl
)
fetch
(
conf
.
bpmSrcUrl
)
...
@@ -53,28 +84,32 @@
...
@@ -53,28 +84,32 @@
}
}
const
threshold
=
document
.
location
.
search
.
indexOf
(
'
threshold=
'
)
>-
1
?
document
.
location
.
search
.
split
(
'
threshold=
'
)[
1
].
split
(
'
&
'
)[
0
]:
1000
;
const
threshold
=
document
.
location
.
search
.
indexOf
(
'
threshold=
'
)
>-
1
?
document
.
location
.
search
.
split
(
'
threshold=
'
)[
1
].
split
(
'
&
'
)[
0
]:
1000
;
const
f
=
document
.
location
.
search
.
indexOf
(
'
factor=
'
)
>-
1
?
document
.
location
.
search
.
split
(
'
factor=
'
)[
1
].
split
(
'
&
'
)[
0
]:
3000
;
const
f
=
document
.
location
.
search
.
indexOf
(
'
factor=
'
)
>-
1
?
document
.
location
.
search
.
split
(
'
factor=
'
)[
1
].
split
(
'
&
'
)[
0
]:
3000
;
function
bpmInit
(
facility
)
{
function
bpmInit
(
facilities
)
{
if
(
bpmData
[
facility
].
obj
.
length
>
0
)
{
console
.
log
(
'
bpmData
'
,
bpmData
);
console
.
log
(
'
bpmInit
'
,
facility
,
bpmData
[
facility
]);
for
(
let
fi
in
facilities
)
{
const
dhor
=
[];
const
facility
=
facilities
[
fi
];
const
dver
=
[];
if
(
facility
.
length
>
0
&&
bpmData
[
facility
].
obj
.
length
>
0
)
{
for
(
i
=
0
;
i
<
bpmData
[
facility
].
pos
.
length
;
i
++
)
{
console
.
log
(
'
bpmInit
'
,
facility
,
bpmData
[
facility
]);
if
(
i
>
threshold
)
break
;
const
dhor
=
[];
const
dir
=
bpmData
[
facility
].
dir
[
i
];
const
dver
=
[];
const
beta
=
Math
.
PI
*
dir
/
180
;
for
(
i
=
0
;
i
<
bpmData
[
facility
].
pos
.
length
;
i
++
)
{
if
(
threshold
<
1000
)
console
.
log
(
'
i
'
,
i
,
'
pos
'
,
bpmData
[
facility
].
pos
[
i
],
'
dir
'
,
dir
,
beta
,
Math
.
cos
(
beta
),
Math
.
sin
(
beta
));
if
(
i
>
threshold
)
break
;
dhor
.
push
((
i
==
0
?
'
M
'
:
'
L
'
)
+
const
dir
=
bpmData
[
facility
].
dir
[
i
];
Math
.
round
(
bpmData
[
facility
].
pos
[
i
][
0
]
-
f
*
Math
.
sin
(
beta
))
+
'
'
+
const
beta
=
Math
.
PI
*
dir
/
180
;
Math
.
round
(
bpmData
[
facility
].
pos
[
i
][
1
]
+
f
*
Math
.
cos
(
beta
))
if
(
threshold
<
1000
)
console
.
log
(
'
i
'
,
i
,
'
pos
'
,
bpmData
[
facility
].
pos
[
i
],
'
dir
'
,
dir
,
beta
,
Math
.
cos
(
beta
),
Math
.
sin
(
beta
));
);
dhor
.
push
((
i
==
0
?
'
M
'
:
'
L
'
)
+
dver
.
push
((
i
==
0
?
'
M
'
:
'
L
'
)
+
Math
.
round
(
bpmData
[
facility
].
pos
[
i
][
0
]
-
f
*
Math
.
sin
(
beta
))
+
'
'
+
Math
.
round
(
bpmData
[
facility
].
pos
[
i
][
0
]
-
f
*
1.05
*
Math
.
sin
(
beta
))
+
'
'
+
Math
.
round
(
bpmData
[
facility
].
pos
[
i
][
1
]
+
f
*
Math
.
cos
(
beta
))
Math
.
round
(
bpmData
[
facility
].
pos
[
i
][
1
]
+
f
*
1.05
*
Math
.
cos
(
beta
))
);
);
dver
.
push
((
i
==
0
?
'
M
'
:
'
L
'
)
+
Math
.
round
(
bpmData
[
facility
].
pos
[
i
][
0
]
-
f
*
1.05
*
Math
.
sin
(
beta
))
+
'
'
+
Math
.
round
(
bpmData
[
facility
].
pos
[
i
][
1
]
+
f
*
1.05
*
Math
.
cos
(
beta
))
);
}
appendSvg
(
"
path
"
,
{
id
:
facility
+
"
_bpmhor
"
,
class
:
"
bpmhor
"
+
facility
,
visibility
:
"
hidden
"
,
name
:
"
bpmhor
"
,
fill
:
"
none
"
,
"
stroke-width
"
:
"
50
"
,
"
stroke
"
:
"
red
"
,
d
:
dhor
.
join
(
'
'
)
+
(
lattice
[
facility
].
sections
[
0
].
chamber
?
'
Z
'
:
''
)});
appendSvg
(
"
path
"
,
{
id
:
facility
+
"
_bpmver
"
,
class
:
"
bpmver
"
+
facility
,
visibility
:
"
hidden
"
,
name
:
"
bpmver
"
,
fill
:
"
none
"
,
"
stroke-width
"
:
"
50
"
,
"
stroke
"
:
"
green
"
,
d
:
dver
.
join
(
'
'
)
+
(
lattice
[
facility
].
sections
[
0
].
chamber
?
'
Z
'
:
''
)});
console
.
log
(
"
path
"
,
{
id
:
facility
+
"
_bpmhor
"
,
name
:
"
bpmhor
"
,
d
:
dver
.
join
(
'
'
)
+
'
Z
'
});
}
}
appendSvg
(
"
path
"
,
{
id
:
facility
+
"
_bpmhor
"
,
class
:
"
bpmhor
"
+
facility
,
visibility
:
"
hidden
"
,
name
:
"
bpmhor
"
,
fill
:
"
none
"
,
"
stroke-width
"
:
"
50
"
,
"
stroke
"
:
"
red
"
,
d
:
dhor
.
join
(
'
'
)
+
(
lattice
[
facility
].
sections
[
0
].
chamber
?
'
Z
'
:
''
)});
appendSvg
(
"
path
"
,
{
id
:
facility
+
"
_bpmver
"
,
class
:
"
bpmver
"
+
facility
,
visibility
:
"
hidden
"
,
name
:
"
bpmver
"
,
fill
:
"
none
"
,
"
stroke-width
"
:
"
50
"
,
"
stroke
"
:
"
green
"
,
d
:
dver
.
join
(
'
'
)
+
(
lattice
[
facility
].
sections
[
0
].
chamber
?
'
Z
'
:
''
)});
console
.
log
(
"
path
"
,
{
id
:
facility
+
"
_bpmhor
"
,
name
:
"
bpmhor
"
,
d
:
dver
.
join
(
'
'
)
+
'
Z
'
});
}
}
}
}
function
bpmSwitch
(
bpmData
,
params
)
{
function
bpmSwitch
(
bpmData
,
params
)
{
...
@@ -85,13 +120,13 @@
...
@@ -85,13 +120,13 @@
$
(
'
#applicationFrame
'
).
removeAttr
(
"
src
"
);
$
(
'
#applicationFrame
'
).
removeAttr
(
"
src
"
);
}
}
else
{
else
{
if
(
typeof
params
.
bpm
!=
'
string
'
)
return
;
const
bpms
=
'
sr,bts,preinjector
'
.
split
(
'
,
'
);
// <<<<<<<<<<<<<<<<<<<<<<<<--------------------------------------------------
const
bpms
=
params
.
bpm
.
split
(
'
,
'
);
for
(
let
facility
in
bpmData
)
{
for
(
let
bs
=
0
;
bs
<
bpms
.
length
;
bs
++
)
{
if
(
typeof
bpmData
[
facility
].
map
==
'
undefined
'
)
continue
;
bpmData
.
oldIndex
=
bpms
[
bs
]
;
bpmData
.
oldIndex
=
facility
;
bpmRead
(
bpmData
,
params
);
bpmRead
(
bpmData
,
params
);
$
(
'
#
'
+
bpms
[
bs
]
+
"
_bpmhor
"
).
attr
(
'
visibility
'
,
"
visible
"
);
$
(
'
#
'
+
facility
+
"
_bpmhor
"
).
attr
(
'
visibility
'
,
"
visible
"
);
$
(
'
#
'
+
bpms
[
bs
]
+
"
_bpmver
"
).
attr
(
'
visibility
'
,
"
visible
"
);
$
(
'
#
'
+
facility
+
"
_bpmver
"
).
attr
(
'
visibility
'
,
"
visible
"
);
}
}
bpmData
.
reader
=
setInterval
(
bpmRead
,
3000
,
bpmData
,
params
);
bpmData
.
reader
=
setInterval
(
bpmRead
,
3000
,
bpmData
,
params
);
$
(
'
#application
'
).
show
();
$
(
'
#application
'
).
show
();
...
@@ -116,7 +151,7 @@
...
@@ -116,7 +151,7 @@
$
(
'
#
'
+
params
.
bpm
+
"
_bpmhor
"
).
attr
(
'
visibility
'
,
"
visible
"
);
$
(
'
#
'
+
params
.
bpm
+
"
_bpmhor
"
).
attr
(
'
visibility
'
,
"
visible
"
);
$
(
'
#
'
+
params
.
bpm
+
"
_bpmver
"
).
attr
(
'
visibility
'
,
"
visible
"
);
$
(
'
#
'
+
params
.
bpm
+
"
_bpmver
"
).
attr
(
'
visibility
'
,
"
visible
"
);
bpmData
.
reader
=
setInterval
(
bpmRead
,
300
0
,
bpmData
,
params
);
bpmData
.
reader
=
setInterval
(
bpmRead
,
300
,
bpmData
,
params
);
$
(
'
#application
'
).
show
();
$
(
'
#application
'
).
show
();
$
(
'
.bpmhor.
'
+
params
.
bpm
).
css
(
'
display
'
,
'
block
'
);
$
(
'
.bpmhor.
'
+
params
.
bpm
).
css
(
'
display
'
,
'
block
'
);
$
(
'
.bpmver.
'
+
params
.
bpm
).
css
(
'
display
'
,
'
block
'
);
$
(
'
.bpmver.
'
+
params
.
bpm
).
css
(
'
display
'
,
'
block
'
);
...
@@ -124,48 +159,54 @@
...
@@ -124,48 +159,54 @@
$
(
"
#applicationFrame
"
).
height
(
window
.
innerHeight
);
$
(
"
#applicationFrame
"
).
height
(
window
.
innerHeight
);
}
}
}
}
function
bpmRender
(
bpm
,
bpmData
)
{
function
bpmRender
(
facility
,
val
)
{
const
facility
=
bpm
.
split
(
'
_
'
)[
0
];
// console.log('bpmRender()',facility, val);
/*
const bpmMaxX = Math.max.apply(null, val.x.map(Math.abs)); // https://stackoverflow.com/questions/29515761/find-absolute-max-value-in-javascript-array
const bpmMaxY = Math.max.apply(null, val.y.map(Math.abs));
let bpmPeakX = (Math.log10(bpmMaxX) + 2) * 5000;
let bpmPeakY = (Math.log10(bpmMaxY) + 2) * 5000;
bpmPeakX = bpmPeakX>20000? 20000: (bpmPeakX<2000? 2000: bpmPeakX);
bpmPeakY = bpmPeakY>20000? 20000: (bpmPeakY<2000? 2000: bpmPeakY);
const bpmFactorX = bpmPeakX/bpmMaxX;
const bpmFactorY = bpmPeakY/bpmMaxY;
/*
console.log('bpmRender(), facility', facility, 'bpmData', bpmData);
console.log('bpmRender(), facility', facility, 'bpmData', bpmData);
const bpmd = facility==''? bpmData: bpmData[facility];
const bpmd = facility==''? bpmData: bpmData[facility];
const bpmMax = Math.max.apply(null, bpmd.val.map(Math.abs)); // https://stackoverflow.com/questions/29515761/find-absolute-max-value-in-javascript-array
const bpmMax = Math.max.apply(null, bpmd.val.map(Math.abs)); // https://stackoverflow.com/questions/29515761/find-absolute-max-value-in-javascript-array
let bpmPeak = (Math.log10(bpmMax) + 2) * 5000;
let bpmPeak = (Math.log10(bpmMax) + 2) * 5000;
bpmPeak = bpmPeak>20000? 20000: (bpmPeak<2000? 2000: bpmPeak);
bpmPeak = bpmPeak>20000? 20000: (bpmPeak<2000? 2000: bpmPeak);
const
bpmFactor
=
bpmPeak
/
bpmMax
;
*/
const
dhor
=
[];
const
dhor
=
[];
const
dver
=
[];
const
dver
=
[];
for
(
i
=
0
;
i
<
bpmd
.
pos
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
val
.
Hor
.
length
;
i
++
)
{
if
(
i
>
threshold
)
break
;
// if (i>threshold) break;
const
dir
=
bpmd
.
dir
[
i
];
const
pos
=
bpmData
[
facility
].
pos
[
i
];
const
beta
=
Math
.
PI
*
dir
/
180
;
if
(
pos
==
null
)
continue
;
if
(
threshold
<
1000
)
console
.
log
(
'
i
'
,
i
,
'
pos
'
,
bpmd
.
pos
[
i
],
'
dir
'
,
dir
,
beta
,
Math
.
cos
(
beta
),
Math
.
sin
(
beta
));
const
beta
=
Math
.
PI
*
bpmData
[
facility
].
dir
[
i
]
/
180
;
dhor
.
push
((
i
==
0
?
'
M
'
:
'
L
'
)
+
// console.log('i', i, 'pos',pos, 'dir', bpmData[facility].dir[i], 'facility', facility, beta, Math.cos(beta), Math.sin(beta));
Math
.
round
(
bpmd
.
pos
[
i
][
0
]
-
bpmd
.
val
[
0
][
i
]
/
1000
*
Math
.
sin
(
beta
))
+
'
'
+
dhor
.
push
((
i
==
0
?
'
M
'
:
'
L
'
)
+
Math
.
round
(
bpmd
.
pos
[
i
][
1
]
+
bpmd
.
val
[
0
][
i
]
/
1000
*
Math
.
cos
(
beta
))
Math
.
round
(
pos
[
0
]
-
val
.
Hor
[
i
]
/
1000
*
Math
.
sin
(
beta
))
+
'
'
+
);
Math
.
round
(
pos
[
1
]
+
val
.
Hor
[
i
]
/
1000
*
Math
.
cos
(
beta
))
dver
.
push
((
i
==
0
?
'
M
'
:
'
L
'
)
+
);
Math
.
round
(
bpmd
.
pos
[
i
][
0
]
-
bpmd
.
val
[
1
][
i
]
/
1000
*
Math
.
sin
(
beta
))
+
'
'
+
dver
.
push
((
i
==
0
?
'
M
'
:
'
L
'
)
+
Math
.
round
(
bpmd
.
pos
[
i
][
1
]
+
bpmd
.
val
[
1
][
i
]
/
1000
*
Math
.
cos
(
beta
))
Math
.
round
(
pos
[
0
]
-
val
.
Ver
[
i
]
/
1000
*
Math
.
sin
(
beta
))
+
'
'
+
);
Math
.
round
(
pos
[
1
]
+
val
.
Ver
[
i
]
/
1000
*
Math
.
cos
(
beta
))
}
);
$
(
'
#
'
+
facility
+
"
_bpmhor
"
).
attr
(
'
d
'
,
dhor
.
join
(
'
'
)
+
(
lattice
[
facility
].
sections
[
0
].
chamber
?
'
Z
'
:
''
));
}
$
(
'
#
'
+
facility
+
"
_bpmver
"
).
attr
(
'
d
'
,
dver
.
join
(
'
'
)
+
(
lattice
[
facility
].
sections
[
0
].
chamber
?
'
Z
'
:
''
));
$
(
'
#
'
+
facility
+
"
_bpmhor
"
).
attr
(
'
d
'
,
dhor
.
join
(
'
'
)
+
(
lattice
[
facility
].
sections
[
0
].
chamber
?
'
Z
'
:
''
));
console
.
log
(
"
bpmRender(),
"
,
{
id
:
facility
+
"
_bpmhor
"
,
name
:
"
bpmhor
"
,
d
:
dver
.
join
(
'
'
)
+
'
Z
'
});
$
(
'
#
'
+
facility
+
"
_bpmver
"
).
attr
(
'
d
'
,
dver
.
join
(
'
'
)
+
(
lattice
[
facility
].
sections
[
0
].
chamber
?
'
Z
'
:
''
));
// console.log("bpmRender(),", {id:facility+"_bpmhor", name:"bpmhor", d: dver.join(' ')+' Z'});
// if (params.bpm) {bpmLabel(bpmData, params, camera, THREE);}
// if (params.bpm) {bpmLabel(bpmData, params, camera, THREE);}
}
}
function
bpmRead
(
bpmData
,
params
)
{
function
bpmRead
(
bpmData
,
params
)
{
const
bpms
=
params
.
bpm
.
split
(
'
,
'
);
fetch
(
conf
.
bpmUrl
)
console
.
log
(
'
bpms
'
,
bpms
);
.
then
((
response
)
=>
{
return
response
.
json
();})
for
(
let
bs
=
0
;
bs
<
bpms
.
length
;
bs
++
)
{
.
then
((
eventData
)
=>
{
if
(
bpmData
[
bpms
[
bs
]]
&&
bpmData
[
bpms
[
bs
]].
datasrc
)
{
// console.log('bpmRead()', eventData);
console
.
log
((
bpmData
[
bpms
[
bs
]].
datasrc
.
indexOf
(
'
http
'
)
>-
1
?
''
:
conf
.
rchan
)
+
bpmData
[
bpms
[
bs
]].
datasrc
);
for
(
let
i
in
eventData
)
{
fetch
((
bpmData
[
bpms
[
bs
]].
datasrc
.
indexOf
(
'
http
'
)
>-
1
?
''
:
conf
.
rchan
)
+
bpmData
[
bpms
[
bs
]].
datasrc
)
// console.log(i, eventData[i]);
.
then
((
response
)
=>
{
return
response
.
json
();})
bpmRender
(
i
,
eventData
[
i
]);
.
then
((
eventData
)
=>
{
bpmData
[
bpms
[
bs
]].
val
=
eventData
;
console
.
log
(
'
bpmRead()
'
,
conf
.
rchan
+
bpmData
[
bpms
[
bs
]].
datasrc
,
bpms
[
bs
],
bpmData
,
eventData
);
bpmRender
(
bpms
[
bs
],
bpmData
);
});
}
}
}
}
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment