From 651a3ad7c1c530f29f42c44c28ae8e229812d8e5 Mon Sep 17 00:00:00 2001 From: SysAdmin Date: Wed, 4 Jan 2023 17:06:30 -0500 Subject: [PATCH] added test.py for reading beam.txt and test.txt --- beam.txt | 1 + geo.js | 13 ++++--- index.html | 52 ++++++++++++++++++++++------ test.py | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ test.txt | 1 + 5 files changed, 148 insertions(+), 18 deletions(-) create mode 120000 beam.txt create mode 100755 test.py create mode 120000 test.txt diff --git a/beam.txt b/beam.txt new file mode 120000 index 0000000..56cbbf6 --- /dev/null +++ b/beam.txt @@ -0,0 +1 @@ +/home/sysadmin/beam.txt \ No newline at end of file diff --git a/geo.js b/geo.js index 4c12beb..6fd5f6e 100644 --- a/geo.js +++ b/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(); diff --git a/index.html b/index.html index cbaba7e..6536aa9 100644 --- a/index.html +++ b/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; + } + +
+
- + Your browser doe snot support HTML canvas Your browser doe snot support HTML 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 + + + + +--> + diff --git a/test.py b/test.py new file mode 100755 index 0000000..3901c3e --- /dev/null +++ b/test.py @@ -0,0 +1,99 @@ +#!/usr/bin/python3 + +def printHTML(str): + print("
====|%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('') +print('') + +for x in file: + #print("
" + 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('

===================

') +print("Isotope: " + isotope.upper() + "
") +print("PreAcceleration: " + preacc + " kV
") +print("Inflector: " + inflector + " A
") +print("LEB Voltage: " + LEB_Voltage + " V
") +print("LEB feedback: " + LEB_Feedback + " V
") +print("Tandem Pot.: " + tandam_pot + " MV
") +print("Beam Energy: " + beam_energy + " MeV
") +print("Beam Charge: " + charge + "
") +print("Frac. Charge: " + charge_frac + "
") +print("Beta: " + beta + "
") +print("Analyzing Magnet: " + analysisMagnet + " G
") +print("Beam Line: " + beamLine + "
") +print("Switching Magnet: " + switchingMagnet + " A
") + + + + +# +#file = open("test.txt") +# +#for x in file: +# print("
") +# print(x) +# +#print('

===================

') +print('') +print('') \ No newline at end of file diff --git a/test.txt b/test.txt new file mode 120000 index 0000000..9199a2a --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +/home/sysadmin/test.txt \ No newline at end of file