improving the info display

This commit is contained in:
Ryan Tang 2023-01-05 14:53:50 -05:00
parent 651a3ad7c1
commit 81455c6d62
3 changed files with 208 additions and 99 deletions

103
geo.js
View File

@ -23,11 +23,11 @@ function distance(xy1, xy2){
let colors = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"];
let color = {
let color = { //[on, off]
BeamPipe : ['red', 'grey'],
Dipole : ['gold', '#CDCD5B'],
Dipole : ['gold', '#DEDE6C'],
Deflector : ['Orange', '#228522'],
Qpole : ['#7F7FFF', '#8F8FBC'],
Qpole : ['#4E4EEE', '#8F8FBC'],
Detector : ['Yellow', '#8B8B0A'],
LINAC : ['Cyan', '#44AAAA'],
Tandem : [ '#782F40', '#CEB888'],
@ -137,7 +137,7 @@ class multiBeamLine extends basicShape{
this.clear();
let ctx = this.layer.getContext('2d');
if(isDashed){
ctx.setLineDash([4,4]);
ctx.setLineDash([8,8]);
ctx.lineDashOffset = -this.offset;
ctx.strokeStyle = this.color[0];
}else{
@ -149,8 +149,8 @@ class multiBeamLine extends basicShape{
}
march(){
this.offset+=1;
if( this.offset > 8) this.offset = 0;
this.offset+=2;
if( this.offset > 16) this.offset = 0;
this.draw(true);
//setTimeout(this.march.bind(this), 20);
}
@ -552,43 +552,51 @@ let beamLineHaHa;
//============================== Draw
var destination = 'Gamma';
for( const ele in beamLineHaHa){
beamLineHaHa[ele].draw(false);
}
function DisableAllDetector(){
for( const ele in sourceLine){
sourceLine[ele].draw(true);
}
targetRoom1.dipole.draw(true);
targetRoom1.fan.draw(true);
targetRoom1.upperLine.q1a.draw(true);
targetRoom1.upperLine.df1a.draw(true);
targetRoom1.upperLine.GammaStation.draw(false);
targetRoom1.upperLine.Catrina.draw(false);
targetRoom1.lowerLine.q1c.draw(false);
targetRoom1.lowerLine.df1c.draw(false);
for( const ele in targetRoom2){
try{
targetRoom2[ele].draw(false);
}catch(err){
for( const haha in targetRoom2[ele]){
try{
targetRoom2[ele][haha].draw(false);
}catch(err){
for( const kaka in targetRoom2[ele][haha]){
targetRoom2[ele][haha][kaka].draw(false);
for( const ele in beamLineHaHa){
beamLineHaHa[ele].draw(false);
}
for( const ele in sourceLine){
sourceLine[ele].draw(true);
}
for( const ele in targetRoom1){
try{
targetRoom1[ele].draw(false);
}catch(err){
for( const haha in targetRoom1[ele]){
try{
targetRoom1[ele][haha].draw(false);
}catch(err){
}
}
}
}
for( const ele in targetRoom2){
try{
targetRoom2[ele].draw(false);
}catch(err){
for( const haha in targetRoom2[ele]){
try{
targetRoom2[ele][haha].draw(false);
}catch(err){
for( const kaka in targetRoom2[ele][haha]){
targetRoom2[ele][haha][kaka].draw(false);
}
}
}
}
}
}
var destination = 'Gamma';
function EnableDetector(){
DisableAllDetector();
if( destination == 'Gamma' ) targetRoom1.upperLine.GammaStation.draw(true);
if( destination == 'Catrina') targetRoom1.upperLine.Catrina.draw(true);
if( destination == 'RESOLUT') targetRoom2.ResolutLine.Resolut.draw(true);
@ -596,6 +604,33 @@ function EnableDetector(){
if( destination == 'SPS') targetRoom2.lowerLine.SplitPoleLine.SPS.draw(true);
if( destination == 'Clarion2') targetRoom2.lowerLine.ClarionLine.Clarion2.draw(true);
if( destination == 'Gamma' || destination == 'Catrina'){
for( const ele in targetRoom1){
try{
targetRoom2[ele].draw(true);
}catch(err){
}
}
}
if( destination == 'RESOLUT' || destination == 'Anasen' || destination == 'SPS' || destination == 'Clarion2'){
for( const ele in targetRoom2){
try{
targetRoom2[ele].draw(true);
}catch(err){
}
}
}
if( destination == 'RESOLUT'){
for( const ele in targetRoom2.ResolutLine){
try{
targetRoom2.ResolutLine[ele].draw(true);
}catch(err){
}
}
}
}
function lineMotion(){

View File

@ -54,11 +54,38 @@
z-index: 3;
}
#text{
#BeamInfo{
color: orange;
position:absolute;
font-size: 100px;
top : 25%;
left : 35%;
z-index:1001;
}
#SrcInfo{
color: white;
position:absolute;
font-size: 15px;
bottom : 9.6%;
right : 10%;
z-index:1001;
}
#TandemInfo{
color: white;
position:absolute;
font-size: 15px;
bottom : 35%;
right : 10%;
z-index:1001;
}
#footnote{
color: aqua;
position:absolute;
top : 20%;
left : 45%;
bottom : 2%;
right : 1%;
width: 100;
height: 100;
z-index:1001;
@ -68,9 +95,16 @@
<body>
<div id="text"></div>
<div id='clock'></div>
<div id='footnote'></div>
<div id="BeamInfo"></div>
<div id="SrcInfo"></div>
<div id="TandemInfo"></div>
<div id="DipoleInfo"></div>
<div id="SwitchInfo"></div>
<!--<iframe src="http://localhost:3000/d-solo/MFym59G4k/new-dashboard?orgId=1&from=1672071127881&to=1672092727881&theme=dark&panelId=2" id="iframe1"></iframe>-->
<!--<iframe src="http://localhost:3000/d-solo/MFym59G4k/new-dashboard?orgId=1&from=1672071308654&to=1672092908654&panelId=4" id="iframe2"></iframe>-->
@ -79,64 +113,94 @@
<canvas width="3840" height="2160" id='beamLine' > Your browser doe snot support HTML canvas</canvas>
<canvas width="3840" height="2160" id='static' > Your browser doe snot support HTML canvas</canvas>
===================
Isotope: C12
PreAcceleration: 120.0 kV
Inflector: 3.70 A
LEB Voltage: -2.62 V
LEB feedback: 0.090 V
Tandem Pot.: 7.126 MV
Beam Energy: 50.000 MeV
Beam Charge: 6
Frac. Charge: 0.044
Beta: 0.0943
Analyzing Magnet: 6813.81 G
Beam Line: RESOLUT
</body>
<!-- ################################################ -->
<script>
let data;
function GetMassFromAZ(){
let client = new XMLHttpRequest();
client.onreadystatechange = function() {
data = client.responseText;
//alert(data);
}
client.open('GET', "test.py", false);
client.send();
}
GetMassFromAZ();
document.getElementById("text").innerHTML = data;
var beam_Line = 'RESOLUT';
function time() {
let clock = document.getElementById('clock');
let d = new Date();
clock.textContent = d;
}
time();
setInterval(time, 1000);
</script>
<script type="text/javascript" src="geo.js"></script>
<script>
let updateTime = 10; //min
document.getElementById("footnote").innerHTML = "Accelrator setting update every " + updateTime + " min.";
var Mass;
var Sym;
var preAccel;
var inflector;
var LEB_volatage;
var TandemPot;
var beamEnergy;
var beamCharge;
var dipoleField;
var beam_Line = 'RESOLUT';
var SwitchMagnet;
function GetBeamSetting(){
let client = new XMLHttpRequest();
client.onreadystatechange = function() {
let data = client.responseText.split(" ");
//alert(data);
beamMass = data[0];
Sym = data[1];
preAccel = data[2];
inflector = data[3];
LEB_volatage = data[4];
TandemPot = data[5];
beamEnergy = parseFloat(data[6]);
beamCharge = parseInt(data[7]);
dipoleField = data[8];
beam_Line = data[9];
SwitchMagnet = data[10];
}
client.open('GET', "test.py", false);
client.send();
}
function BeamSettings(){
GetBeamSetting();
//format beamInfo
let beamKEA = beamEnergy/parseFloat(beamMass);
let beamInfo = "<sup>"+ beamMass + "</sup>" + Sym + "("+ beamCharge + "<sup>+</sup>) " + beamKEA.toFixed(2) + " MeV/u";
document.getElementById("BeamInfo").innerHTML = beamInfo;
//srouce info
document.getElementById("SrcInfo").innerHTML = preAccel + " kV";
//tadem info
document.getElementById("TandemInfo").innerHTML = TandemPot + " MV";
destination = beam_Line;
EnableDetector();
lineMotion();
}
BeamSettings();
setInterval(BeamSettings, updateTime * 60 * 1000);
</script>
<!--

60
test.py
View File

@ -36,8 +36,8 @@ switchingMagnet = '404'
file = open("beam.txt")
print("Content-type:text/html\r\n\r\n")
print('<html>')
print('<body>')
#print('<html>')
#print('<body>')
for x in file:
#print("<br>" + x)
@ -70,30 +70,40 @@ for x in file:
#print('<p>===================<p>')
print("Isotope: " + isotope.upper() + "<br>")
print("PreAcceleration: " + preacc + " kV <br>")
print("Inflector: " + inflector + " A<br>")
print("LEB Voltage: " + LEB_Voltage + " V<br>")
print("LEB feedback: " + LEB_Feedback + " V<br>")
print("Tandem Pot.: " + tandam_pot + " MV<br>")
print("Beam Energy: " + beam_energy + " MeV<br>")
print("Beam Charge: " + charge + "<br>")
print("Frac. Charge: " + charge_frac + "<br>")
print("Beta: " + beta + "<br>")
print("Analyzing Magnet: " + analysisMagnet + " G<br>")
print("Beam Line: " + beamLine + "<br>")
print("Switching Magnet: " + switchingMagnet + " A<br>")
#print("Isotope: " + isotope.upper() + "<br>")
#print("PreAcceleration: " + preacc + " kV <br>")
#print("Inflector: " + inflector + " A<br>")
#print("LEB Voltage: " + LEB_Voltage + " V<br>")
#print("LEB feedback: " + LEB_Feedback + " V<br>")
#print("Tandem Pot.: " + tandam_pot + " MV<br>")
#print("Beam Energy: " + beam_energy + " MeV<br>")
#print("Beam Charge: " + charge + "<br>")
#print("Frac. Charge: " + charge_frac + "<br>")
#print("Beta: " + beta + "<br>")
#print("Analyzing Magnet: " + analysisMagnet + " G<br>")
#print("Beam Line: " + beamLine + "<br>")
#print("Switching Magnet: " + switchingMagnet + " A<br>")
import re
MassNumber = (re.findall(r'\d+', isotope))[0]
pos = isotope.find(str(MassNumber))
IsotopeSym = isotope[0:pos].upper()
#
#file = open("test.txt")
#
#for x in file:
# print("<br>")
# print(x)
#
#print('<p>===================<p>')
print('</body>')
print('</html>')
print(MassNumber,
IsotopeSym,
preacc,
inflector,
LEB_Voltage,
tandam_pot,
beam_energy,
charge,
analysisMagnet,
beamLine,
switchingMagnet
)
#print('</body>')
#print('</html>')