small change
This commit is contained in:
parent
9ccb10c9ad
commit
3a0b7bcd30
457
dashboard.py
457
dashboard.py
|
@ -1,9 +1,12 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
from tkinter import *
|
||||
from tkinter import ttk
|
||||
import math
|
||||
from random import randint
|
||||
import numpy as np
|
||||
import time
|
||||
import datetime
|
||||
|
||||
class Room():
|
||||
def __init__(self, points, Color):
|
||||
|
@ -17,7 +20,7 @@ class DipoleMagnet():
|
|||
self.Center = [ self.EntryPos[0] - self.radius * math.cos(math.radians(Angle[0])) , self.EntryPos[1] + self.radius * math.sin(math.radians(Angle[0])) ]
|
||||
self.ULC = [ self.Center[0] - Size[0], self.Center[1] - Size[0] ]
|
||||
self.ExistPos = np.array([self.Center[0] + self.radius * math.cos(math.radians(Angle[0]+Angle[1])) , self.Center[1] - self.radius * math.sin(math.radians(Angle[0]+Angle[1])) ])
|
||||
self.dMagnet1 = canvas.create_arc ( self.ULC[0], self.ULC[1], self.ULC[0] + 2*Size[0], self.ULC[1] + 2*Size[0], start = Angle[0], extent = Angle[1], fill = Color, outline = Color)
|
||||
self.dMagnet1 = canvas.create_arc ( self.ULC[0], self.ULC[1], self.ULC[0] + 2*Size[0], self.ULC[1] + 2*Size[0], start = Angle[0], extent = Angle[1], fill = Color[0], outline = Color[0])
|
||||
self.dMagnet2 = canvas.create_arc ( self.ULC[0] + (Size[0] - Size[1]), self.ULC[1] + (Size[0] - Size[1]), self.ULC[0] + (Size[0] + Size[1]), self.ULC[1] + (Size[0] + Size[1]), start = Angle[0]-2, extent = Angle[1]+4, fill = 'black', outline = 'black')
|
||||
def GetExitPos(self, downstream = 0):
|
||||
return self.ExistPos + np.array([ downstream * math.cos(math.radians(self.Angle[0]+self.Angle[1] + 90 )), -downstream * math.sin(math.radians(self.Angle[0] + self.Angle[1] + 90 )) ])
|
||||
|
@ -35,10 +38,23 @@ class Tandem():
|
|||
def GetExitPos(self, downstream = 0):
|
||||
return self.ExistPos + np.array([0, - downstream])
|
||||
|
||||
class BeamElementColor():
|
||||
beamPipe = ['White', 'grey30']
|
||||
dipole = ['gold', 'gold4']
|
||||
deflector = ['Orange', 'Orange4']
|
||||
Qpole = ['Blue', 'Blue4']
|
||||
Detector = ['Yellow', 'Yellow4']
|
||||
LINAC = ['Cyan', 'Cyan4']
|
||||
Buncher = ['Ivory', 'Ivory4']
|
||||
SNICS = ['tan', 'tan4']
|
||||
RFsourcce = ['Olivedrab', 'Olivedrab4']
|
||||
Other = ['Black', 'Red']
|
||||
|
||||
class BeamRectElement():
|
||||
def __init__(self, EntryPos, Size, Angle, Color):
|
||||
self.Active = False
|
||||
self.Color = Color
|
||||
self.PresentColor = Color[0]
|
||||
self.p1 = [ EntryPos[0] - Size[0]/2 * math.cos(math.radians(Angle)), EntryPos[1] + Size[0]/2 * math.sin(math.radians(Angle))]
|
||||
self.p2 = [self.p1[0] + Size[0] * math.cos(math.radians(Angle)), self.p1[1] - Size[0] * math.sin(math.radians(Angle)) ]
|
||||
self.p3 = [self.p2[0] - Size[1] * math.sin(math.radians(Angle)), self.p2[1] - Size[1] * math.cos(math.radians(Angle)) ]
|
||||
|
@ -46,29 +62,34 @@ class BeamRectElement():
|
|||
self.pts = [self.p1[0], self.p1[1], self.p2[0], self.p2[1], self.p3[0], self.p3[1], self.p4[0], self.p4[1] ]
|
||||
self.Angle = Angle
|
||||
self.ExistPos = np.array([(self.p4[0] + self.p3[0])/2, (self.p4[1] + self.p3[1])/2 ])
|
||||
self.beamPipe = canvas.create_polygon(self.pts, fill = Color, width = 0)
|
||||
self.beamPipe = canvas.create_polygon(self.pts, fill = self.PresentColor, width = 0)
|
||||
|
||||
def GetExitPos(self, downstream = 0):
|
||||
return self.ExistPos + np.array([ - downstream * math.sin(math.radians(self.Angle )), - downstream * math.cos(math.radians(self.Angle )) ])
|
||||
def SetColor(self, Color):
|
||||
self.Color = Color
|
||||
def GetCenterPos(self):
|
||||
return (np.array(self.p1) + np.array(self.p3))/2
|
||||
|
||||
def SetCustomColor(self, Color):
|
||||
self.PresentColor = Color
|
||||
canvas.itemconfig(self.beamPipe, fill = Color)
|
||||
def GetColor(self):
|
||||
return self.Color
|
||||
|
||||
def Deactivate(self):
|
||||
self.Active = False
|
||||
self.Color = 'grey10'
|
||||
canvas.itemconfig(self.beamPipe, fill = 'grey10')
|
||||
self.PresentColor = self.Color[1]
|
||||
canvas.itemconfig(self.beamPipe, fill = self.Color[1])
|
||||
def Activate(self):
|
||||
self.Active = True
|
||||
def Blink(self):
|
||||
if self.Active == True:
|
||||
if self.Color == 'White' :
|
||||
self.Color = 'Red'
|
||||
self.PresentColor = self.Color[0]
|
||||
canvas.itemconfig(self.beamPipe, fill = self.Color[0])
|
||||
def Blink(self): # only for beam pipe
|
||||
if self.Color[0] == 'White' and self.Active == True:
|
||||
if self.PresentColor == 'White' :
|
||||
self.PresentColor = 'Red'
|
||||
canvas.itemconfig(self.beamPipe, fill = 'Red')
|
||||
else:
|
||||
self.Color = 'White'
|
||||
self.PresentColor = 'White'
|
||||
canvas.itemconfig(self.beamPipe, fill = 'White')
|
||||
|
||||
|
||||
class BeamCircleElement():
|
||||
def __init__(self, Center, Size, Color):
|
||||
self.Center = Center
|
||||
|
@ -84,7 +105,7 @@ class BeamSwitch():
|
|||
self.Angle = Angle
|
||||
self.ULC = [EntryPos[0] - Radius, EntryPos[1] - Radius]
|
||||
self.beamFan1 = BeamRectElement(EntryPos, [Radius/2, Radius/2], Angle, Color)
|
||||
self.beamFan2 = canvas.create_arc( self.ULC[0], self.ULC[1], self.ULC[0] + 2 * Radius, self.ULC[1] + 2 * Radius , start = 45 + Angle, extent = 90, fill = Color, outline = Color)
|
||||
self.beamFan2 = canvas.create_arc( self.ULC[0], self.ULC[1], self.ULC[0] + 2 * Radius, self.ULC[1] + 2 * Radius , start = 45 + Angle, extent = 90, fill = Color[0], outline = Color[0])
|
||||
def GetExitPos(self, angle, downstream = 0):
|
||||
return self.EntryPos + np.array([ (self.Radius + downstream)* math.cos(math.radians( 90 + angle + self.Angle)), - (self.Radius + downstream)*math.sin(math.radians( 90 + angle + self.Angle))])
|
||||
def GetExistAbsAngle(self, angle):
|
||||
|
@ -92,10 +113,11 @@ class BeamSwitch():
|
|||
|
||||
class DetectorStation():
|
||||
def __init__(self, Center, Size, Name, Color):
|
||||
self.Color = Color
|
||||
self.Name = Name
|
||||
self.ULC = [Center[0] - Size/2, Center[1] - Size/2]
|
||||
self.Detector = canvas.create_oval(self.ULC[0], self.ULC[1], self.ULC[0] + Size, self.ULC[1]+Size, fill = Color, width = 0)
|
||||
self.label = Label(canvas, text = Name, bg = Color, cursor = "hand1")
|
||||
self.Detector = canvas.create_oval(self.ULC[0], self.ULC[1], self.ULC[0] + Size, self.ULC[1]+Size, fill = Color[0], width = 0)
|
||||
self.label = Label(canvas, text = Name, bg = self.Color[0], cursor = "hand1")
|
||||
self.label.place(x=Center[0], y=Center[1], anchor = "center")
|
||||
|
||||
canvas.tag_bind(self.Detector, '<1>', self.onClick)
|
||||
|
@ -104,23 +126,12 @@ class DetectorStation():
|
|||
canvas.tag_bind(self.Detector, '<Enter>', self.HopOver)
|
||||
canvas.tag_bind(self.Detector, '<Leave>', self.Leave)
|
||||
|
||||
def SetColor(self, Color):
|
||||
def SetCustomColor(self, Color):
|
||||
canvas.itemconfig(self.Detector, fill = Color)
|
||||
self.label.config(bg = Color)
|
||||
|
||||
def onClick(self, event):
|
||||
print("========== ", self.Name)
|
||||
bl0.Deactivate()
|
||||
bl1.Deactivate()
|
||||
bl1a.Deactivate(); bl1a_1.Deactivate()
|
||||
bl1b.Deactivate()
|
||||
bl1c.Deactivate()
|
||||
bl0a.Deactivate(); bl3.Deactivate()
|
||||
bl2a.Deactivate(); bl2a_1.Deactivate()
|
||||
bl2b.Deactivate()
|
||||
bl2c.Deactivate()
|
||||
bl2c_1.Deactivate()
|
||||
bl2c_2.Deactivate()
|
||||
|
||||
SetActiveBeamLine(self.Name)
|
||||
|
||||
|
@ -136,178 +147,145 @@ class DetectorStation():
|
|||
return self.Name
|
||||
|
||||
def Activate(self, OnOff):
|
||||
|
||||
if OnOff == True:
|
||||
self.SetColor('Pink')
|
||||
self.SetCustomColor(self.Color[0])
|
||||
else:
|
||||
self.SetColor('Pink4')
|
||||
self.SetCustomColor(self.Color[1])
|
||||
|
||||
|
||||
def SetActiveBeamLine(BeamLineName):
|
||||
|
||||
bl0.Deactivate()
|
||||
bl1.Deactivate()
|
||||
bl1a.Deactivate(); bl1a_1.Deactivate()
|
||||
bl1b.Deactivate()
|
||||
bl1c.Deactivate()
|
||||
bl0a.Deactivate(); bl3.Deactivate()
|
||||
bl2a.Deactivate(); bl2a_1.Deactivate()
|
||||
bl2b.Deactivate()
|
||||
bl2c.Deactivate()
|
||||
bl2c_1.Deactivate()
|
||||
bl2c_2.Deactivate()
|
||||
|
||||
GammaStation.Activate(False)
|
||||
Catrina.Activate(False)
|
||||
Resolut.Activate(False)
|
||||
Anasen.Activate(False)
|
||||
SPS.Activate(False)
|
||||
Clarion2.Activate(False)
|
||||
|
||||
if BeamLineName == "Gamma\nStation":
|
||||
bl0.Activate()
|
||||
|
||||
bl1.Activate()
|
||||
|
||||
bl1a.Activate(); bl1a_1.Deactivate()
|
||||
bl1b.Deactivate()
|
||||
bl1c.Deactivate()
|
||||
|
||||
bl0a.Deactivate(); bl3.Deactivate()
|
||||
|
||||
bl2a.Deactivate(); bl2a_1.Deactivate()
|
||||
|
||||
bl2b.Deactivate()
|
||||
|
||||
bl2c.Deactivate()
|
||||
bl2c_1.Deactivate()
|
||||
bl2c_2.Deactivate()
|
||||
|
||||
bl1a.Activate();
|
||||
GammaStation.Activate(True)
|
||||
Catrina.Activate(False)
|
||||
Resolut.Activate(False)
|
||||
Anasen.Activate(False)
|
||||
SPS.Activate(False)
|
||||
Clarion2.Activate(False)
|
||||
|
||||
|
||||
elif BeamLineName == "CATRiNA" :
|
||||
bl0.Activate()
|
||||
|
||||
bl0.Activate()
|
||||
bl1.Activate()
|
||||
|
||||
bl1a.Activate(); bl1a_1.Activate()
|
||||
|
||||
bl1b.Deactivate()
|
||||
bl1c.Deactivate()
|
||||
|
||||
bl0a.Deactivate(); bl3.Deactivate()
|
||||
|
||||
bl2a.Deactivate(); bl2a_1.Deactivate()
|
||||
|
||||
bl2b.Deactivate()
|
||||
|
||||
bl2c.Deactivate()
|
||||
bl2c_1.Deactivate()
|
||||
bl2c_2.Deactivate()
|
||||
|
||||
GammaStation.Activate(False)
|
||||
Catrina.Activate(True)
|
||||
Resolut.Activate(False)
|
||||
Anasen.Activate(False)
|
||||
SPS.Activate(False)
|
||||
Clarion2.Activate(False)
|
||||
cursor="hand1"
|
||||
|
||||
elif BeamLineName == "RESOLUT" :
|
||||
bl0.Activate()
|
||||
|
||||
bl1.Deactivate()
|
||||
|
||||
bl1a.Deactivate(); bl1a_1.Deactivate()
|
||||
|
||||
bl1b.Deactivate()
|
||||
bl1c.Deactivate()
|
||||
|
||||
bl0.Activate()
|
||||
bl0a.Activate(); bl3.Activate()
|
||||
|
||||
bl2a.Activate(); bl2a_1.Activate()
|
||||
|
||||
bl2b.Deactivate()
|
||||
|
||||
bl2c.Deactivate()
|
||||
bl2c_1.Deactivate()
|
||||
bl2c_2.Deactivate()
|
||||
|
||||
GammaStation.Activate(False)
|
||||
Catrina.Activate(False)
|
||||
Resolut.Activate(True)
|
||||
Anasen.Activate(False)
|
||||
SPS.Activate(False)
|
||||
Clarion2.Activate(False)
|
||||
|
||||
elif BeamLineName == "ANASEN" :
|
||||
bl0.Activate()
|
||||
|
||||
bl1.Deactivate()
|
||||
|
||||
bl1a.Deactivate(); bl1a_1.Deactivate()
|
||||
|
||||
bl1b.Deactivate()
|
||||
bl1c.Deactivate()
|
||||
|
||||
bl0a.Activate(); bl3.Activate()
|
||||
|
||||
bl2a.Deactivate(); bl2a_1.Deactivate()
|
||||
|
||||
bl2b.Activate()
|
||||
|
||||
bl2c.Deactivate()
|
||||
bl2c_1.Deactivate()
|
||||
bl2c_2.Deactivate()
|
||||
|
||||
GammaStation.Activate(False)
|
||||
Catrina.Activate(False)
|
||||
Resolut.Activate(False)
|
||||
Anasen.Activate(True)
|
||||
SPS.Activate(False)
|
||||
Clarion2.Activate(False)
|
||||
|
||||
elif BeamLineName == "SPS" :
|
||||
bl0.Activate()
|
||||
|
||||
bl1.Deactivate()
|
||||
|
||||
bl1a.Deactivate(); bl1a_1.Deactivate()
|
||||
|
||||
bl1b.Deactivate()
|
||||
bl1c.Deactivate()
|
||||
|
||||
bl0a.Activate(); bl3.Activate()
|
||||
|
||||
bl2a.Deactivate(); bl2a_1.Deactivate()
|
||||
|
||||
bl2b.Deactivate()
|
||||
|
||||
bl2c.Activate()
|
||||
bl2c_1.Activate()
|
||||
bl2c_2.Deactivate()
|
||||
|
||||
GammaStation.Activate(False)
|
||||
Catrina.Activate(False)
|
||||
Resolut.Activate(False)
|
||||
Anasen.Activate(False)
|
||||
SPS.Activate(True)
|
||||
Clarion2.Activate(False)
|
||||
|
||||
|
||||
elif BeamLineName == "CLARION-2" :
|
||||
bl0.Activate()
|
||||
|
||||
bl1.Deactivate()
|
||||
|
||||
bl1a.Deactivate(); bl1a_1.Deactivate()
|
||||
|
||||
bl1b.Deactivate()
|
||||
bl1c.Deactivate()
|
||||
|
||||
bl0a.Activate(); bl3.Activate()
|
||||
|
||||
bl2a.Deactivate(); bl2a_1.Deactivate()
|
||||
|
||||
bl2b.Deactivate()
|
||||
|
||||
bl2c.Activate()
|
||||
bl2c_1.Deactivate()
|
||||
bl2c_2.Activate()
|
||||
|
||||
GammaStation.Activate(False)
|
||||
Catrina.Activate(False)
|
||||
Resolut.Activate(False)
|
||||
Anasen.Activate(False)
|
||||
SPS.Activate(False)
|
||||
Clarion2.Activate(True)
|
||||
|
||||
|
||||
class IsotopeInfo():
|
||||
def __init__(self, A, Sym, energy, rate):
|
||||
self.Label1 = Label(canvas, text = A, fg = 'White', bg = 'black', bd = 0, font = ("Arial", 48))
|
||||
self.Label2 = Label(canvas, text = Sym, fg = 'White', bg = 'black', bd = 0, font = ("Arial", 96))
|
||||
self.Label1.place(x = 1600, y = 500, anchor = NE)
|
||||
self.Label2.place(x = 1600, y = 500, anchor = NW)
|
||||
|
||||
self.Energy = Label(canvas, text = " @ " + str(energy) + " MeV/u", fg = 'White', bg = 'black', bd = 0, font = ("Arial", 96))
|
||||
self.Energy.place(x = 1700, y = 500, anchor = NW)
|
||||
|
||||
self.rateOrder = int(math.log(rate, 10));
|
||||
self.rateDigi = rate/ math.pow(10, self.rateOrder)
|
||||
|
||||
self.rate1 = Label(canvas, text = ("%.2f x 10" % self.rateDigi), fg = 'White', bg = 'black', bd = 0, font = ("Arial", 70))
|
||||
self.rate1.place(x = 2000, y = 700, anchor = NE)
|
||||
|
||||
self.rate2 = Label(canvas, text = ("%d" % self.rateOrder), fg = 'White', bg = 'black', bd = 0, font = ("Arial", 35))
|
||||
self.rate2.place(x = 2000, y = 700, anchor = NW)
|
||||
|
||||
self.rate3 = Label(canvas, text = "pps", fg = 'White', bg = 'black', bd = 0, font = ("Arial", 70))
|
||||
self.rate3.place(x = 2050, y = 700, anchor = NW)
|
||||
|
||||
class Clock():
|
||||
def __init__(self):
|
||||
self.text = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
self.Label = Label(canvas, text = self.text, fg = 'White', bg = 'black', bd = 0, font = ("Arial", 48))
|
||||
self.Label.place(x = 100, y = 50, anchor = NW)
|
||||
|
||||
def update(self):
|
||||
self.text = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
self.Label['text'] = self.text
|
||||
|
||||
class Chart():
|
||||
def __init__(self):
|
||||
self.ULC = [100, 1300] # upper left corner
|
||||
self.LRC = [2400, 2060] # lower right corner
|
||||
self.Box = canvas.create_rectangle( 100, 1300, 2400, 2060, outline = "White", width = 2)
|
||||
|
||||
#10 tick on x
|
||||
xLenght = self.LRC[0] - self.ULC[0]
|
||||
xStep = xLenght/10.
|
||||
self.tickLabels = []
|
||||
for i in range(0, 11):
|
||||
canvas.create_line(self.ULC[0] + xStep * i, self.LRC[1], self.ULC[0] + xStep * i, self.LRC[1] - 30, fill = "White", width = 2)
|
||||
canvas.create_line(self.ULC[0] + xStep * i, self.ULC[1], self.ULC[0] + xStep * i, self.ULC[1] + 30, fill = "White", width = 2)
|
||||
self.tickLabels.append(Label(canvas, text = str(i), fg = 'White', bg = 'black', bd = 0, font = ("Arial", 20)))
|
||||
self.tickLabels[i].place(x = self.ULC[0] + xStep * i, y = self.LRC[1], anchor = N)
|
||||
|
||||
#10 tick on y
|
||||
yLenght = self.LRC[1] - self.ULC[1]
|
||||
yStep = yLenght/10.
|
||||
for i in range(0, 10):
|
||||
canvas.create_line(self.ULC[0], self.ULC[1] + yStep * i, self.ULC[0] + 30, self.ULC[1] + yStep * i, fill = "White", width = 2)
|
||||
canvas.create_line(self.LRC[0], self.ULC[1] + yStep * i, self.LRC[0] - 30, self.ULC[1] + yStep * i, fill = "White", width = 2)
|
||||
|
||||
#ComboBox For time scale
|
||||
self.current_var = StringVar()
|
||||
self.combobox = ttk.Combobox(canvas, textvariable = self.current_var, width= 10)
|
||||
self.items = ('5 mins', '10 mins', '30 mins', '1 hr', '2hr', '6 hr', '12 hr', '1 day', '2 days', '7 days')
|
||||
self.combobox['values'] = self.items
|
||||
self.combobox['state'] = 'readonly'
|
||||
self.combobox.place(x = self.LRC[0], y = self.ULC[1], anchor = NE)
|
||||
self.combobox.set('30 mins')
|
||||
self.combobox.bind('<<ComboboxSelected>>', self.timeScaleChanged)
|
||||
|
||||
def timeScaleChanged(self, event):
|
||||
temp = self.combobox.get()
|
||||
print("------------------ ", temp)
|
||||
#for a in self.items :
|
||||
# if temp == a :
|
||||
|
||||
|
||||
|
||||
############################## Start GUI
|
||||
#windowSize = [3840, 1500]# 4K width
|
||||
windowSize = [3840, 2160]# 4K
|
||||
|
@ -332,164 +310,168 @@ canvas.pack( expand = True, fill = BOTH)
|
|||
#==================== Beam line
|
||||
#++++++++++++++++ source
|
||||
|
||||
RFsource1 = BeamRectElement( [windowSize[0]*0.9, windowSize[1]*0.8], [100, 40], 0, 'olivedrab')
|
||||
RFsource2 = BeamRectElement( RFsource1.GetExitPos(), [20, 80], 0, 'olivedrab')
|
||||
RFsource1 = BeamRectElement( [windowSize[0]*0.9, windowSize[1]*0.8], [100, 40], 0, BeamElementColor.RFsourcce)
|
||||
RFsource2 = BeamRectElement( RFsource1.GetExitPos(), [20, 80], 0, BeamElementColor.RFsourcce)
|
||||
|
||||
blS = BeamRectElement( RFsource2.GetExitPos(), [10, 200], 0, 'white')
|
||||
blS = BeamRectElement( RFsource2.GetExitPos(), [10, 200], 0, BeamElementColor.beamPipe)
|
||||
|
||||
bfanS = BeamSwitch(RFsource2.GetExitPos(100), 50, 180, 'yellow')
|
||||
bfanS = BeamSwitch(RFsource2.GetExitPos(100), 50, 180, BeamElementColor.dipole)
|
||||
|
||||
blS0 = BeamRectElement( bfanS.GetExitPos(30), [10, 50], bfanS.GetExistAbsAngle(30), 'white')
|
||||
SNICS = BeamRectElement( blS0.GetExitPos(), [50, 50], bfanS.GetExistAbsAngle(30), 'tan')
|
||||
blS0 = BeamRectElement( bfanS.GetExitPos(30), [10, 50], bfanS.GetExistAbsAngle(30), BeamElementColor.beamPipe)
|
||||
SNICS = BeamRectElement( blS0.GetExitPos(), [50, 50], bfanS.GetExistAbsAngle(30), BeamElementColor.SNICS)
|
||||
|
||||
blS1 = BeamRectElement( bfanS.GetExitPos(-30), [10, 50], bfanS.GetExistAbsAngle(-30), 'white')
|
||||
TriSource = BeamRectElement( blS1.GetExitPos(), [50, 50], bfanS.GetExistAbsAngle(-30), 'cyan')
|
||||
blS1 = BeamRectElement( bfanS.GetExitPos(-30), [10, 50], bfanS.GetExistAbsAngle(-30), BeamElementColor.beamPipe)
|
||||
TriSource = BeamRectElement( blS1.GetExitPos(), [50, 50], bfanS.GetExistAbsAngle(-30), BeamElementColor.Detector)
|
||||
|
||||
tandemSize = [100, 300] # width, height
|
||||
tandem = Tandem(blS.GetExitPos(), tandemSize, 'Green')
|
||||
|
||||
bl0 = BeamRectElement( tandem.GetExitPos() , [10, 300], 0, 'white')
|
||||
bl0 = BeamRectElement( tandem.GetExitPos() , [10, 300], 0, BeamElementColor.beamPipe)
|
||||
|
||||
bl0a = BeamRectElement( bl0.GetExitPos(), [10, 400], 0, 'grey12') # beam by-pass D-1
|
||||
bl0a = BeamRectElement( bl0.GetExitPos(), [10, 400], 0, BeamElementColor.beamPipe) # beam by-pass D-1
|
||||
|
||||
q1 = BeamRectElement(tandem.GetExitPos(50) , [60, 60], 0, 'Blue')
|
||||
df1 = BeamRectElement(q1.GetExitPos(50) , [40, 30], 0, 'orange')
|
||||
df2 = BeamRectElement(df1.GetExitPos(20), [40, 30], 0, 'orange')
|
||||
q1 = BeamRectElement(tandem.GetExitPos(50) , [60, 60], 0, BeamElementColor.Qpole)
|
||||
df1 = BeamRectElement(q1.GetExitPos(50) , [40, 30], 0, BeamElementColor.deflector)
|
||||
df2 = BeamRectElement(df1.GetExitPos(20), [40, 30], 0, BeamElementColor.deflector)
|
||||
|
||||
#++++++++++++++++ beam line to target room 1
|
||||
dMagnetSize = [80, 20] # outer, inner radius
|
||||
d1 = DipoleMagnet(bl0.GetExitPos(), dMagnetSize, [0, 90], 'Yellow')
|
||||
d1 = DipoleMagnet(bl0.GetExitPos(), dMagnetSize, [0, 90], BeamElementColor.dipole)
|
||||
|
||||
bl1 = BeamRectElement( d1.GetExitPos(), [10, 100], 90, 'white')
|
||||
bl1 = BeamRectElement( d1.GetExitPos(), [10, 100], 90, BeamElementColor.beamPipe)
|
||||
|
||||
bfan1 = BeamSwitch(bl1.GetExitPos(), 50, 90, 'Yellow')
|
||||
bfan1 = BeamSwitch(bl1.GetExitPos(), 50, 100, BeamElementColor.dipole)
|
||||
|
||||
#-------- upper beam line
|
||||
angle_a = -15
|
||||
angle_a = -25
|
||||
beamline1Angle_a = bfan1.GetExistAbsAngle(angle_a)
|
||||
bl1a = BeamRectElement( bfan1.GetExitPos(angle_a), [10, 350], beamline1Angle_a, 'white')
|
||||
bl1a = BeamRectElement( bfan1.GetExitPos(angle_a), [10, 350], beamline1Angle_a, BeamElementColor.beamPipe)
|
||||
|
||||
q1a = BeamRectElement(bfan1.GetExitPos(angle_a, 100), [60, 60], beamline1Angle_a, 'blue')
|
||||
df1a = BeamRectElement(q1a.GetExitPos(30), [40, 30], beamline1Angle_a, 'orange')
|
||||
q1a = BeamRectElement(bfan1.GetExitPos(angle_a, 100), [60, 60], beamline1Angle_a, BeamElementColor.Qpole)
|
||||
df1a = BeamRectElement(q1a.GetExitPos(30), [40, 30], beamline1Angle_a, BeamElementColor.deflector)
|
||||
|
||||
bl1a_1 = BeamRectElement( bl1a.GetExitPos(), [10, 200], beamline1Angle_a, 'white')
|
||||
bl1a_1 = BeamRectElement( bl1a.GetExitPos(), [10, 200], beamline1Angle_a, BeamElementColor.beamPipe)
|
||||
|
||||
#.......... Gamma DetectorStation
|
||||
GammaStation = DetectorStation(bl1a.GetExitPos(), 100, "Gamma\nStation", 'Pink4')
|
||||
GammaStation = DetectorStation(bl1a.GetExitPos(), 100, "Gamma\nStation", BeamElementColor.Detector)
|
||||
|
||||
#.......... Catrina
|
||||
Catrina = DetectorStation(bl1a_1.GetExitPos(), 100, "CATRiNA", 'Pink')
|
||||
Catrina = DetectorStation(bl1a_1.GetExitPos(), 100, "CATRiNA", BeamElementColor.Detector)
|
||||
|
||||
#---------middle beam line
|
||||
angle_b = 10
|
||||
angle_b = 0
|
||||
beamline1Angle_b = bfan1.GetExistAbsAngle(angle_b)
|
||||
bl1b = BeamRectElement( bfan1.GetExitPos(angle_b), [10, 300], beamline1Angle_b, 'grey12')
|
||||
bl1b = BeamRectElement( bfan1.GetExitPos(angle_b), [10, 300], beamline1Angle_b, BeamElementColor.beamPipe)
|
||||
|
||||
#--------- lower beam line
|
||||
angle_c = 40
|
||||
angle_c = 30
|
||||
beamline1Angle_c = bfan1.GetExistAbsAngle(angle_c)
|
||||
bl1c = BeamRectElement( bfan1.GetExitPos(angle_c), [10, 300], beamline1Angle_c, 'grey12')
|
||||
q1c = BeamRectElement(bfan1.GetExitPos(angle_c, 100), [60, 60], beamline1Angle_c, 'blue')
|
||||
df1c = BeamRectElement(q1c.GetExitPos(50), [40, 30], beamline1Angle_c, 'orange')
|
||||
bl1c = BeamRectElement( bfan1.GetExitPos(angle_c), [10, 300], beamline1Angle_c, BeamElementColor.beamPipe)
|
||||
q1c = BeamRectElement(bfan1.GetExitPos(angle_c, 100), [60, 60], beamline1Angle_c, BeamElementColor.Qpole)
|
||||
df1c = BeamRectElement(q1c.GetExitPos(50), [40, 30], beamline1Angle_c, BeamElementColor.deflector)
|
||||
|
||||
|
||||
#++++++++++++++++ beam line to target room 2
|
||||
|
||||
q2 = BeamRectElement( bl0.GetExitPos(100), [60, 60], 0, 'blue')
|
||||
df2 = BeamRectElement( q2.GetExitPos(50), [40, 40], 0, 'orange')
|
||||
q3 = BeamRectElement( df2.GetExitPos(50), [60, 60], 0, 'blue')
|
||||
q2 = BeamRectElement( bl0.GetExitPos(100), [60, 60], 0, BeamElementColor.Qpole)
|
||||
df2 = BeamRectElement( q2.GetExitPos(50), [40, 40], 0, BeamElementColor.deflector)
|
||||
q3 = BeamRectElement( df2.GetExitPos(50), [60, 60], 0, BeamElementColor.Qpole)
|
||||
|
||||
d2 = DipoleMagnet(bl0a.GetExitPos(), [80, 20], [0, 90], 'Yellow')
|
||||
d2 = DipoleMagnet(bl0a.GetExitPos(), [80, 20], [0, 90], BeamElementColor.dipole)
|
||||
|
||||
bl3 = BeamRectElement(d2.GetExitPos(), [10, 2000], 90, 'grey12')
|
||||
bl3 = BeamRectElement(d2.GetExitPos(), [10, 2000], 90, BeamElementColor.beamPipe)
|
||||
|
||||
df3 = BeamRectElement(d2.GetExitPos(100), [40, 40], 90, 'orange')
|
||||
q4 = BeamRectElement(df3.GetExitPos(50), [60, 60], 90, 'blue')
|
||||
df4 = BeamRectElement(q4.GetExitPos(50), [40, 40], 90, 'orange')
|
||||
df3 = BeamRectElement(d2.GetExitPos(100), [40, 40], 90, BeamElementColor.deflector)
|
||||
q4 = BeamRectElement(df3.GetExitPos(50), [60, 60], 90, BeamElementColor.Qpole)
|
||||
df4 = BeamRectElement(q4.GetExitPos(50), [40, 40], 90, BeamElementColor.deflector)
|
||||
|
||||
buncher = BeamCircleElement(df4.GetExitPos(90), 80, 'ivory2')
|
||||
|
||||
linac1 = BeamRectElement(d2.GetExitPos(500) , [80, 300], 90, 'cyan')
|
||||
linac2 = BeamRectElement(linac1.GetExitPos(30) , [80, 300], 90, 'cyan')
|
||||
linac3 = BeamRectElement(linac2.GetExitPos(30) , [80, 300], 90, 'cyan')
|
||||
linac1 = BeamRectElement(d2.GetExitPos(500) , [80, 300], 90, BeamElementColor.LINAC)
|
||||
linac2 = BeamRectElement(linac1.GetExitPos(30) , [80, 300], 90, BeamElementColor.LINAC)
|
||||
linac3 = BeamRectElement(linac2.GetExitPos(30) , [80, 300], 90, BeamElementColor.LINAC)
|
||||
|
||||
df5 = BeamRectElement(linac3.GetExitPos(50), [40, 40], 90, 'orange')
|
||||
df6 = BeamRectElement(df5.GetExitPos(50), [40, 40], 90, 'orange')
|
||||
q5 = BeamRectElement(df6.GetExitPos(50), [60, 60], 90, 'blue')
|
||||
df7 = BeamRectElement(q5.GetExitPos(50), [40, 40], 90, 'orange')
|
||||
df5 = BeamRectElement(linac3.GetExitPos(50), [40, 40], 90, BeamElementColor.deflector)
|
||||
df6 = BeamRectElement(df5.GetExitPos(50), [40, 40], 90, BeamElementColor.deflector)
|
||||
q5 = BeamRectElement(df6.GetExitPos(50), [60, 60], 90, BeamElementColor.Qpole)
|
||||
df7 = BeamRectElement(q5.GetExitPos(50), [40, 40], 90, BeamElementColor.deflector)
|
||||
|
||||
bfan2 = BeamSwitch(bl3.GetExitPos(), 50, 90, 'Yellow')
|
||||
bfan2 = BeamSwitch(bl3.GetExitPos(), 50, 100, BeamElementColor.dipole)
|
||||
|
||||
#------------- beam line 2a
|
||||
angle2a = -15
|
||||
angle2a = -25
|
||||
beamlineAngle2a = bfan2.GetExistAbsAngle(angle2a);
|
||||
|
||||
bl2a = BeamRectElement( bfan2.GetExitPos(angle2a), [10, 500], beamlineAngle2a, 'grey12')
|
||||
bl2a = BeamRectElement( bfan2.GetExitPos(angle2a), [10, 500], beamlineAngle2a, BeamElementColor.beamPipe)
|
||||
|
||||
df2a_1 = BeamRectElement( bfan2.GetExitPos(angle2a, 50), [40,40], beamlineAngle2a, 'orange')
|
||||
q2a = BeamRectElement(df2a_1.GetExitPos(30), [60, 60], beamlineAngle2a, 'blue')
|
||||
df2a_2 = BeamRectElement(q2a.GetExitPos(30), [40, 30], beamlineAngle2a, 'orange')
|
||||
df2a_3 = BeamRectElement(df2a_2.GetExitPos(30), [40, 30], beamlineAngle2a, 'orange')
|
||||
df2a_1 = BeamRectElement( bfan2.GetExitPos(angle2a, 50), [40,40], beamlineAngle2a, BeamElementColor.deflector)
|
||||
q2a = BeamRectElement(df2a_1.GetExitPos(30), [60, 60], beamlineAngle2a, BeamElementColor.Qpole)
|
||||
df2a_2 = BeamRectElement(q2a.GetExitPos(30), [40, 30], beamlineAngle2a, BeamElementColor.deflector)
|
||||
df2a_3 = BeamRectElement(df2a_2.GetExitPos(30), [40, 30], beamlineAngle2a, BeamElementColor.deflector)
|
||||
|
||||
d3 = DipoleMagnet(bl2a.GetExitPos(), [100, 40], [beamlineAngle2a, 30], 'yellow')
|
||||
d3 = DipoleMagnet(bl2a.GetExitPos(), [100, 40], [beamlineAngle2a, 30], BeamElementColor.dipole)
|
||||
|
||||
bl2a_1 = BeamRectElement( d3.GetExitPos(), [10, 500], beamlineAngle2a + 30, 'grey12')
|
||||
bl2a_1 = BeamRectElement( d3.GetExitPos(), [10, 500], beamlineAngle2a + 30, BeamElementColor.beamPipe)
|
||||
|
||||
Resolut = DetectorStation(bl2a_1.GetExitPos(), 100, 'RESOLUT', 'Pink')
|
||||
Resolut = DetectorStation(bl2a_1.GetExitPos(), 100, 'RESOLUT', BeamElementColor.Detector)
|
||||
|
||||
#------------- beam line 2b
|
||||
angle2b = 0
|
||||
angle2b =-10
|
||||
beamlineAngle2b = bfan2.GetExistAbsAngle(angle2b);
|
||||
|
||||
bl2b = BeamRectElement( bfan2.GetExitPos(angle2b), [10, 500], beamlineAngle2b, 'grey12')
|
||||
bl2b = BeamRectElement( bfan2.GetExitPos(angle2b), [10, 500], beamlineAngle2b, BeamElementColor.beamPipe)
|
||||
|
||||
q2b = BeamRectElement(bfan2.GetExitPos(angle2b, 200), [60, 60], beamlineAngle2b, 'blue')
|
||||
df2b = BeamRectElement(q2b.GetExitPos(30), [40, 30], beamlineAngle2b, 'orange')
|
||||
q2b = BeamRectElement(bfan2.GetExitPos(angle2b, 200), [60, 60], beamlineAngle2b, BeamElementColor.Qpole)
|
||||
df2b = BeamRectElement(q2b.GetExitPos(30), [40, 30], beamlineAngle2b, BeamElementColor.deflector)
|
||||
|
||||
Anasen = DetectorStation( bl2b.GetExitPos(), 100, "ANASEN", 'Pink')
|
||||
Anasen = DetectorStation( bl2b.GetExitPos(), 100, "ANASEN", BeamElementColor.Detector)
|
||||
|
||||
#------------- beam line 2c
|
||||
angle2c = 40
|
||||
angle2c = 30
|
||||
beamlineAngle2c = bfan2.GetExistAbsAngle(angle2c);
|
||||
|
||||
bl2c = BeamRectElement( bfan2.GetExitPos(angle2c), [10, 400], beamlineAngle2c, 'grey12')
|
||||
bl2c = BeamRectElement( bfan2.GetExitPos(angle2c), [10, 400], beamlineAngle2c, BeamElementColor.beamPipe)
|
||||
|
||||
q2c = BeamRectElement(bfan2.GetExitPos(angle2c, 30), [60, 60], beamlineAngle2c, 'blue')
|
||||
df2c = BeamRectElement(q2c.GetExitPos(30), [40, 30], beamlineAngle2c, 'orange')
|
||||
q2c = BeamRectElement(bfan2.GetExitPos(angle2c, 30), [60, 60], beamlineAngle2c, BeamElementColor.Qpole)
|
||||
df2c = BeamRectElement(q2c.GetExitPos(30), [40, 30], beamlineAngle2c, BeamElementColor.deflector)
|
||||
|
||||
bfan2c = BeamSwitch(bl2c.GetExitPos(), 50, beamlineAngle2c, 'yellow' )
|
||||
bfan2c = BeamSwitch(bl2c.GetExitPos(), 50, beamlineAngle2c, BeamElementColor.dipole )
|
||||
|
||||
#-------------------- beam line 2c_1
|
||||
angle2c_1 = -10
|
||||
beamlineAngle2c_1 = bfan2c.GetExistAbsAngle(angle2c_1);
|
||||
|
||||
bl2c_1 = BeamRectElement( bfan2c.GetExitPos(angle2c_1), [10, 400], beamlineAngle2c_1, 'grey12')
|
||||
bl2c_1 = BeamRectElement( bfan2c.GetExitPos(angle2c_1), [10, 400], beamlineAngle2c_1, BeamElementColor.beamPipe)
|
||||
|
||||
q2c_1 = BeamRectElement(bfan2c.GetExitPos(angle2c_1, 30), [60, 60], beamlineAngle2c_1, 'blue')
|
||||
df2c_1a = BeamRectElement(q2c_1.GetExitPos(30), [40, 30], beamlineAngle2c_1, 'orange')
|
||||
df2c_1b = BeamRectElement(df2c_1a.GetExitPos(30), [40, 30], beamlineAngle2c_1, 'orange')
|
||||
q2c_1 = BeamRectElement(bfan2c.GetExitPos(angle2c_1, 30), [60, 60], beamlineAngle2c_1, BeamElementColor.Qpole)
|
||||
df2c_1a = BeamRectElement(q2c_1.GetExitPos(30), [40, 30], beamlineAngle2c_1, BeamElementColor.deflector)
|
||||
df2c_1b = BeamRectElement(df2c_1a.GetExitPos(30), [40, 30], beamlineAngle2c_1, BeamElementColor.deflector)
|
||||
|
||||
SPS = DetectorStation( bl2c_1.GetExitPos(), 100, "SPS", 'Pink')
|
||||
SPS = DetectorStation( bl2c_1.GetExitPos(), 100, "SPS", BeamElementColor.Detector)
|
||||
|
||||
#-------------------- beam line 2c_2
|
||||
angle2c_2 = 30
|
||||
beamlineAngle2c_2 = bfan2c.GetExistAbsAngle(angle2c_2);
|
||||
|
||||
bl2c_2 = BeamRectElement( bfan2c.GetExitPos(angle2c_2), [10, 400], beamlineAngle2c_2, 'grey12')
|
||||
bl2c_2 = BeamRectElement( bfan2c.GetExitPos(angle2c_2), [10, 400], beamlineAngle2c_2, BeamElementColor.beamPipe)
|
||||
|
||||
q2c_2 = BeamRectElement(bfan2c.GetExitPos(angle2c_2, 30), [60, 60], beamlineAngle2c_2, 'blue')
|
||||
df2c_2a = BeamRectElement(q2c_2.GetExitPos(30), [40, 30], beamlineAngle2c_2, 'orange')
|
||||
df2c_2b = BeamRectElement(df2c_2a.GetExitPos(30), [40, 30], beamlineAngle2c_2, 'orange')
|
||||
q2c_2 = BeamRectElement(bfan2c.GetExitPos(angle2c_2, 30), [60, 60], beamlineAngle2c_2, BeamElementColor.Qpole)
|
||||
df2c_2a = BeamRectElement(q2c_2.GetExitPos(30), [40, 30], beamlineAngle2c_2, BeamElementColor.deflector)
|
||||
df2c_2b = BeamRectElement(df2c_2a.GetExitPos(30), [40, 30], beamlineAngle2c_2, BeamElementColor.deflector)
|
||||
|
||||
Clarion2 = DetectorStation( bl2c_2.GetExitPos(), 100, "CLARION-2", BeamElementColor.Detector)
|
||||
|
||||
Clarion2 = DetectorStation( bl2c_2.GetExitPos(), 100, "CLARION-2", 'Pink')
|
||||
#==================== Labels and info
|
||||
clock = Clock()
|
||||
|
||||
IsotopeInfo(2, "H", 4.6, 6.1e+9)
|
||||
|
||||
label = Label(canvas, text='hahaha')
|
||||
label.place(x = windowSize[0] * 0.9, y = blS.GetExitPos()[1] - 100)
|
||||
#label.bind('<Enter>', lambda e: label.configure(text='Moved mouse inside'))
|
||||
#label.bind('<Leave>', lambda e: label.configure(text='Moved mouse outside'))
|
||||
|
||||
|
||||
Chart()
|
||||
|
||||
#==================== Button
|
||||
|
||||
|
@ -497,7 +479,6 @@ exit_button = Button(canvas, text="Exit", command=window.destroy)
|
|||
exit_button.place(x = windowSize[0] - 200, y = 50)
|
||||
|
||||
|
||||
|
||||
###################### Beam line activation
|
||||
|
||||
Catrina.onClick(Event);
|
||||
|
@ -526,6 +507,8 @@ def update():
|
|||
bl2c_1.Blink()
|
||||
bl2c_2.Blink()
|
||||
|
||||
clock.update()
|
||||
|
||||
window.after(1000, update) # run itself again after 1000 ms
|
||||
|
||||
update()
|
||||
|
|
Loading…
Reference in New Issue
Block a user