added test.py for reading beam.txt and test.txt
This commit is contained in:
parent
9479d96c91
commit
651a3ad7c1
13
geo.js
13
geo.js
|
@ -403,7 +403,7 @@ let targetRoom2;
|
|||
let df2a_2 = new beamRectElement( df2a_1.GetExitPos(30), fan2.GetExitAng(frac), 30, 40, color.Deflector);
|
||||
let d3 = new beamDipole(fan2.GetExitPos(frac, 500), 80, 90* deg, -40 * deg, color.Dipole);
|
||||
let b2a_1 = new beamLine( d3.GetExitPos(0), -95 * deg, 500); // dummy
|
||||
let Resolut = new detectorStation(b2a_1.GetExitPos(0), "Resolut");
|
||||
let Resolut = new detectorStation(b2a_1.GetExitPos(0), "RESOLUT");
|
||||
|
||||
ResolutLine = {df2a_0, q2a, df2a_1, df2a_2, d3, Resolut};
|
||||
}
|
||||
|
@ -586,12 +586,12 @@ for( const ele in targetRoom2){
|
|||
}
|
||||
}
|
||||
|
||||
let destination = 'Gamma';
|
||||
var destination = 'Gamma';
|
||||
|
||||
function EnableDetector(){
|
||||
if( destination == 'Gamma' ) targetRoom1.upperLine.GammaStation.draw(true);
|
||||
if( destination == 'Catrina') targetRoom1.upperLine.Catrina.draw(true);
|
||||
if( destination == 'Resolut') targetRoom2.ResolutLine.Resolut.draw(true);
|
||||
if( destination == 'RESOLUT') targetRoom2.ResolutLine.Resolut.draw(true);
|
||||
if( destination == 'Anasen') targetRoom2.AnasenLine.Anasen.draw(true);
|
||||
if( destination == 'SPS') targetRoom2.lowerLine.SplitPoleLine.SPS.draw(true);
|
||||
if( destination == 'Clarion2') targetRoom2.lowerLine.ClarionLine.Clarion2.draw(true);
|
||||
|
@ -601,7 +601,7 @@ function EnableDetector(){
|
|||
function lineMotion(){
|
||||
if( destination == 'Gamma' ) beamLineHaHa.Gamma.march();
|
||||
if( destination == 'Catrina') beamLineHaHa.Catrina.march();
|
||||
if( destination == 'Resolut') beamLineHaHa.Resolut.march();
|
||||
if( destination == 'RESOLUT') beamLineHaHa.Resolut.march();
|
||||
if( destination == 'Anasen') beamLineHaHa.Anasen.march();
|
||||
if( destination == 'SPS') beamLineHaHa.SPS.march();
|
||||
if( destination == 'Clarion2') beamLineHaHa.Clarion2.march();
|
||||
|
@ -609,7 +609,6 @@ function lineMotion(){
|
|||
setTimeout(lineMotion, 50);
|
||||
}
|
||||
|
||||
destination = 'Clarion2';
|
||||
//EnableDetector();
|
||||
//lineMotion();
|
||||
|
||||
EnableDetector();
|
||||
lineMotion();
|
||||
|
|
52
index.html
52
index.html
|
@ -54,45 +54,69 @@
|
|||
z-index: 3;
|
||||
}
|
||||
|
||||
#text{
|
||||
color: aqua;
|
||||
position:absolute;
|
||||
top : 20%;
|
||||
left : 45%;
|
||||
width: 100;
|
||||
height: 100;
|
||||
z-index:1001;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="text"></div>
|
||||
|
||||
<div id='clock'></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>-->
|
||||
|
||||
<iframe src="http://localhost:3000/d/MFym59G4k/new-dashboard?orgId=1&from=1672835547268&to=1672857147269" id="iframe1"></iframe>
|
||||
<iframe src="http://192.168.0.201:3000/d/MFym59G4k/new-dashboard?orgId=1&from=1672835547268&to=1672857147269" id="iframe1"></iframe>
|
||||
|
||||
<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>
|
||||
===================
|
||||
|
||||
<p id='text'></p>
|
||||
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);
|
||||
//alert(data);
|
||||
}
|
||||
client.open('GET', "/Users/user/Desktop/test.txt", false);
|
||||
client.open('GET', "test.py", false);
|
||||
client.send();
|
||||
}
|
||||
|
||||
GetMassFromAZ();
|
||||
|
||||
document.getElementById('text').innerHTML = data;
|
||||
*/
|
||||
document.getElementById("text").innerHTML = data;
|
||||
|
||||
var beam_Line = 'RESOLUT';
|
||||
|
||||
function time() {
|
||||
let clock = document.getElementById('clock');
|
||||
|
@ -104,13 +128,19 @@ function time() {
|
|||
time();
|
||||
setInterval(time, 1000);
|
||||
|
||||
// set a timer to update the color of the circle every second
|
||||
//setInterval(drawCircle, 1000);
|
||||
</script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="geo.js"></script>
|
||||
|
||||
<script>
|
||||
destination = beam_Line;
|
||||
EnableDetector();
|
||||
lineMotion();
|
||||
</script>
|
||||
|
||||
<!--
|
||||
<script src="geo.js"></script>
|
||||
-->
|
||||
<script src="FoxLabDashBoard/geo.js"></script>
|
||||
-->
|
||||
|
||||
</html>
|
||||
|
|
99
test.py
Executable file
99
test.py
Executable file
|
@ -0,0 +1,99 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
def printHTML(str):
|
||||
print("<br>====|%s|" % str)
|
||||
|
||||
def FindString(x, str1, str2):
|
||||
pos1 = x.find(str1)
|
||||
pos2 = x.find(str2, pos1+1)
|
||||
if( str2 == ''):
|
||||
pos2 = len(x)
|
||||
|
||||
offset = len(str1)
|
||||
|
||||
if( pos1 > -1 and pos2 > -1):
|
||||
haha = x[pos1+offset:pos2].strip()
|
||||
#printHTML(haha)
|
||||
return haha
|
||||
else:
|
||||
return '404'
|
||||
|
||||
|
||||
isotope = '404'
|
||||
preacc = '404'
|
||||
inflector = '404'
|
||||
LEB_Voltage = '404'
|
||||
LEB_Feedback = '404'
|
||||
tandam_pot = '404'
|
||||
beam_energy = '404'
|
||||
charge = '404'
|
||||
charge_frac = '404'
|
||||
beta = '404'
|
||||
analysisMagnet = '404'
|
||||
beamLine = '404'
|
||||
switchingMagnet = '404'
|
||||
|
||||
file = open("beam.txt")
|
||||
|
||||
print("Content-type:text/html\r\n\r\n")
|
||||
print('<html>')
|
||||
print('<body>')
|
||||
|
||||
for x in file:
|
||||
#print("<br>" + x)
|
||||
if( isotope == '404') :
|
||||
isotope = FindString(x, 'nucleus is', 'and')
|
||||
if( preacc == '404'):
|
||||
preacc = FindString(x, 'is at', 'kV')
|
||||
if( inflector == '404'):
|
||||
inflector = FindString(x, 'magnet is', 'A')
|
||||
if( LEB_Voltage == '404'):
|
||||
LEB_Voltage = FindString(x, 'Voltage is', 'V')
|
||||
if( LEB_Feedback == '404'):
|
||||
LEB_Feedback = FindString(x, 'Feedback is', 'V')
|
||||
if( tandam_pot == '404'):
|
||||
tandam_pot = FindString(x, 'Potential =', 'MV')
|
||||
if( beam_energy == '404'):
|
||||
beam_energy = FindString(x, 'Energy =', 'MeV')
|
||||
if( charge == '404'):
|
||||
charge = FindString(x, 'charge=', 'Fraction')
|
||||
if( charge_frac == '404'):
|
||||
charge_frac = FindString(x, 'Fraction =', 'Beta')
|
||||
if( beta == '404'):
|
||||
beta = FindString(x, 'Beta =', '')
|
||||
if( analysisMagnet == '404'):
|
||||
analysisMagnet = FindString(x, 'field is', 'G')
|
||||
if( beamLine == '404'):
|
||||
beamLine = FindString(x, '\"', '\"')
|
||||
if( switchingMagnet == '404'):
|
||||
switchingMagnet = FindString(x, 'Current is', 'A')
|
||||
|
||||
|
||||
#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>")
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
#file = open("test.txt")
|
||||
#
|
||||
#for x in file:
|
||||
# print("<br>")
|
||||
# print(x)
|
||||
#
|
||||
#print('<p>===================<p>')
|
||||
print('</body>')
|
||||
print('</html>')
|
Loading…
Reference in New Issue
Block a user