588 lines
23 KiB
Python
Executable File
588 lines
23 KiB
Python
Executable File
#!/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):
|
|
self.room = canvas.create_polygon(points, width = 2, outline = Color)
|
|
|
|
class DipoleMagnet():
|
|
def __init__(self, EntryPos, Size, Angle, Color):
|
|
self.radius = (Size[0] + Size[1])/2
|
|
self.EntryPos = EntryPos
|
|
self.Angle = Angle
|
|
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[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 )) ])
|
|
def GetExitRelAngle(self):
|
|
return self.Angle[0]+self.Angle[1]
|
|
|
|
|
|
class Tandem():
|
|
def __init__(self, EntryPos, Size, Color):
|
|
self.Color = Color
|
|
self.ULC = [EntryPos[0] - Size[0]/2, EntryPos[1] - Size[1] ]
|
|
self.ExistPos = np.array([ EntryPos[0] , EntryPos[1] - Size[1] ])
|
|
self.tandem1 = canvas.create_arc (self.ULC[0], self.ULC[1] , self.ULC[0] + Size[0], self.ULC[1] + Size[0] , start = 0, extent = 180, fill = Color[0], outline = Color[0])
|
|
self.tandem2 = canvas.create_rectangle(self.ULC[0], self.ULC[1] + Size[0]/2 , self.ULC[0] + Size[0], self.ULC[1] + Size[1] - Size[0]/2 , fill = Color[0], outline = Color[0])
|
|
self.tandem3 = canvas.create_arc (self.ULC[0], self.ULC[1] + Size[1] - Size[0], self.ULC[0] + Size[0], self.ULC[1] + Size[1] , start = 0, extent = -180, fill = Color[0], outline = Color[0])
|
|
|
|
self.isActive = True
|
|
|
|
canvas.tag_bind(self.tandem1, '<1>', self.onClick)
|
|
canvas.tag_bind(self.tandem2, '<1>', self.onClick)
|
|
canvas.tag_bind(self.tandem3, '<1>', self.onClick)
|
|
|
|
canvas.tag_bind(self.tandem1, '<Enter>', self.HopOver)
|
|
canvas.tag_bind(self.tandem2, '<Enter>', self.HopOver)
|
|
canvas.tag_bind(self.tandem3, '<Enter>', self.HopOver)
|
|
|
|
canvas.tag_bind(self.tandem1, '<Leave>', self.Leave)
|
|
canvas.tag_bind(self.tandem2, '<Leave>', self.Leave)
|
|
canvas.tag_bind(self.tandem3, '<Leave>', self.Leave)
|
|
|
|
def GetExitPos(self, downstream = 0):
|
|
return self.ExistPos + np.array([0, - downstream])
|
|
|
|
def Activate(self, OnOff):
|
|
if OnOff == False :
|
|
self.isActive = False
|
|
canvas.itemconfig(self.tandem1, fill = self.Color[1])
|
|
canvas.itemconfig(self.tandem2, fill = self.Color[1])
|
|
canvas.itemconfig(self.tandem3, fill = self.Color[1])
|
|
canvas.itemconfig(self.tandem1, outline = self.Color[1])
|
|
canvas.itemconfig(self.tandem2, outline = self.Color[1])
|
|
canvas.itemconfig(self.tandem3, outline = self.Color[1])
|
|
else:
|
|
self.isActive = True
|
|
canvas.itemconfig(self.tandem1, fill = self.Color[0])
|
|
canvas.itemconfig(self.tandem2, fill = self.Color[0])
|
|
canvas.itemconfig(self.tandem3, fill = self.Color[0])
|
|
canvas.itemconfig(self.tandem1, outline = self.Color[0])
|
|
canvas.itemconfig(self.tandem2, outline = self.Color[0])
|
|
canvas.itemconfig(self.tandem3, outline = self.Color[0])
|
|
|
|
|
|
def onClick(self, event):
|
|
if self.isActive:
|
|
self.Activate(False)
|
|
SetActiveBeamLine("") #no beam line is active
|
|
else:
|
|
self.Activate(True)
|
|
SetActiveBeamLine("Tandem")
|
|
|
|
def HopOver(self, event):
|
|
canvas.config(cursor="hand1")
|
|
|
|
def Leave(self, event):
|
|
canvas.config(cursor="")
|
|
|
|
class BeamElementColor():
|
|
beamPipe = ['White', 'grey30']
|
|
dipole = ['gold', 'gold4']
|
|
deflector = ['Orange', 'Orange4']
|
|
Qpole = ['Blue', 'Blue4']
|
|
Detector = ['Yellow', 'Yellow4']
|
|
LINAC = ['Cyan', 'Cyan4']
|
|
Tandem = [ '#782F40', '#CEB888']
|
|
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)) ]
|
|
self.p4 = [self.p3[0] - Size[0] * math.cos(math.radians(Angle)), self.p3[1] + Size[0] * math.sin(math.radians(Angle)) ]
|
|
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 = 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 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 Deactivate(self):
|
|
self.Active = False
|
|
self.PresentColor = self.Color[1]
|
|
canvas.itemconfig(self.beamPipe, fill = self.Color[1])
|
|
def Activate(self):
|
|
self.Active = True
|
|
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.PresentColor = 'White'
|
|
canvas.itemconfig(self.beamPipe, fill = 'White')
|
|
|
|
class BeamCircleElement():
|
|
def __init__(self, Center, Size, Color):
|
|
self.Center = Center
|
|
self.ULC = [Center[0] - Size/2, Center[1] - Size/2]
|
|
self.beamCirc = canvas.create_oval(self.ULC[0], self.ULC[1], self.ULC[0] + Size, self.ULC[1]+Size, fill = Color, outline = Color)
|
|
def GetCenterPos(self):
|
|
return self.Center
|
|
|
|
class BeamSwitch():
|
|
def __init__(self, EntryPos, Radius, Angle, Color):
|
|
self.EntryPos = np.array(EntryPos)
|
|
self.Radius = Radius
|
|
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[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):
|
|
return angle + self.Angle
|
|
|
|
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[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)
|
|
self.label.bind('<1>', self.onClick)
|
|
|
|
canvas.tag_bind(self.Detector, '<Enter>', self.HopOver)
|
|
canvas.tag_bind(self.Detector, '<Leave>', self.Leave)
|
|
|
|
def SetCustomColor(self, Color):
|
|
canvas.itemconfig(self.Detector, fill = Color)
|
|
self.label.config(bg = Color)
|
|
|
|
def onClick(self, event):
|
|
print("========== ", self.Name)
|
|
|
|
SetActiveBeamLine(self.Name)
|
|
|
|
return self.Name
|
|
|
|
def HopOver(self, event):
|
|
canvas.config(cursor="hand1")
|
|
|
|
def Leave(self, event):
|
|
canvas.config(cursor="")
|
|
|
|
def GetName(self):
|
|
return self.Name
|
|
|
|
def Activate(self, OnOff):
|
|
if OnOff == True:
|
|
self.SetCustomColor(self.Color[0])
|
|
else:
|
|
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();
|
|
GammaStation.Activate(True)
|
|
tandem.Activate(True)
|
|
|
|
elif BeamLineName == "CATRiNA" :
|
|
bl0.Activate()
|
|
bl1.Activate()
|
|
bl1a.Activate(); bl1a_1.Activate()
|
|
Catrina.Activate(True)
|
|
tandem.Activate(True)
|
|
|
|
elif BeamLineName == "RESOLUT" :
|
|
bl0.Activate()
|
|
bl0a.Activate(); bl3.Activate()
|
|
bl2a.Activate(); bl2a_1.Activate()
|
|
Resolut.Activate(True)
|
|
tandem.Activate(True)
|
|
|
|
elif BeamLineName == "ANASEN" :
|
|
bl0.Activate()
|
|
bl0a.Activate(); bl3.Activate()
|
|
bl2b.Activate()
|
|
Anasen.Activate(True)
|
|
tandem.Activate(True)
|
|
|
|
elif BeamLineName == "SPS" :
|
|
bl0.Activate()
|
|
bl0a.Activate(); bl3.Activate()
|
|
bl2c.Activate()
|
|
bl2c_1.Activate()
|
|
SPS.Activate(True)
|
|
tandem.Activate(True)
|
|
|
|
elif BeamLineName == "CLARION-2" :
|
|
bl0.Activate()
|
|
bl0a.Activate(); bl3.Activate()
|
|
bl2c.Activate()
|
|
bl2c_2.Activate()
|
|
Clarion2.Activate(True)
|
|
tandem.Activate(True)
|
|
elif BeamLineName == "Tandem" :
|
|
tandem.Activate(True)
|
|
bl0.Activate()
|
|
|
|
|
|
class IsotopeInfo():
|
|
def __init__(self, A, Sym, energy, rate):
|
|
|
|
if A > 0 :
|
|
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 = 1770, 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)
|
|
|
|
else:
|
|
self.Label2 = Label(canvas, text = "No Beam", fg = 'White', bg = 'black', bd = 0, font = ("Arial", 96))
|
|
self.Label2.place(x = 1600, y = 500, 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
|
|
|
|
window = Tk(className = 'FSU Fox\'s Lab Experimental Hall')
|
|
window.geometry(str(windowSize[0]) + "x" + str(windowSize[1]))
|
|
window.configure(bg='black')
|
|
window.attributes('-fullscreen', True)
|
|
|
|
canvas = Canvas(window)
|
|
canvas.configure(bg='black', bd = 0, highlightthickness=0, relief='ridge')
|
|
canvas.pack( expand = True, fill = BOTH)
|
|
|
|
#==================== interlock
|
|
|
|
#room1 = Room([200, 100, 1400, 100, 1400, 250, 3500, 250, 3500, 420, 1400, 420, 1400, 1200, 200, 1200], 'White')
|
|
|
|
#room2 = Room([3300, 420, 3600, 420, 3600, 2000, 3300, 2000], 'White')
|
|
|
|
#room3 =
|
|
|
|
#==================== Beam line
|
|
#++++++++++++++++ source
|
|
|
|
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, BeamElementColor.beamPipe)
|
|
|
|
bfanS = BeamSwitch(RFsource2.GetExitPos(100), 50, 180, BeamElementColor.dipole)
|
|
|
|
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), BeamElementColor.beamPipe)
|
|
TriSource = BeamRectElement( blS1.GetExitPos(), [50, 50], bfanS.GetExistAbsAngle(-30), BeamElementColor.Detector)
|
|
|
|
tandemSize = [200, 300] # width, height
|
|
tandem = Tandem(blS.GetExitPos(), tandemSize, BeamElementColor.Tandem)
|
|
|
|
bl0 = BeamRectElement( tandem.GetExitPos() , [10, 300], 0, BeamElementColor.beamPipe)
|
|
|
|
bl0a = BeamRectElement( bl0.GetExitPos(), [10, 400], 0, BeamElementColor.beamPipe) # beam by-pass D-1
|
|
|
|
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], BeamElementColor.dipole)
|
|
|
|
bl1 = BeamRectElement( d1.GetExitPos(), [10, 100], 90, BeamElementColor.beamPipe)
|
|
|
|
bfan1 = BeamSwitch(bl1.GetExitPos(), 50, 100, BeamElementColor.dipole)
|
|
|
|
#-------- upper beam line
|
|
angle_a = -25
|
|
beamline1Angle_a = bfan1.GetExistAbsAngle(angle_a)
|
|
bl1a = BeamRectElement( bfan1.GetExitPos(angle_a), [10, 350], beamline1Angle_a, BeamElementColor.beamPipe)
|
|
|
|
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, BeamElementColor.beamPipe)
|
|
|
|
#.......... Gamma DetectorStation
|
|
GammaStation = DetectorStation(bl1a.GetExitPos(), 100, "Gamma\nStation", BeamElementColor.Detector)
|
|
|
|
#.......... Catrina
|
|
Catrina = DetectorStation(bl1a_1.GetExitPos(), 100, "CATRiNA", BeamElementColor.Detector)
|
|
|
|
#---------middle beam line
|
|
angle_b = 0
|
|
beamline1Angle_b = bfan1.GetExistAbsAngle(angle_b)
|
|
bl1b = BeamRectElement( bfan1.GetExitPos(angle_b), [10, 300], beamline1Angle_b, BeamElementColor.beamPipe)
|
|
|
|
#--------- lower beam line
|
|
angle_c = 30
|
|
beamline1Angle_c = bfan1.GetExistAbsAngle(angle_c)
|
|
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, 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], BeamElementColor.dipole)
|
|
|
|
bl3 = BeamRectElement(d2.GetExitPos(), [10, 2000], 90, BeamElementColor.beamPipe)
|
|
|
|
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, 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, 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, 100, BeamElementColor.dipole)
|
|
|
|
#------------- beam line 2a
|
|
angle2a = -25
|
|
beamlineAngle2a = bfan2.GetExistAbsAngle(angle2a);
|
|
|
|
bl2a = BeamRectElement( bfan2.GetExitPos(angle2a), [10, 500], beamlineAngle2a, BeamElementColor.beamPipe)
|
|
|
|
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], BeamElementColor.dipole)
|
|
|
|
bl2a_1 = BeamRectElement( d3.GetExitPos(), [10, 500], beamlineAngle2a + 30, BeamElementColor.beamPipe)
|
|
|
|
Resolut = DetectorStation(bl2a_1.GetExitPos(), 100, 'RESOLUT', BeamElementColor.Detector)
|
|
|
|
#------------- beam line 2b
|
|
angle2b =-10
|
|
beamlineAngle2b = bfan2.GetExistAbsAngle(angle2b);
|
|
|
|
bl2b = BeamRectElement( bfan2.GetExitPos(angle2b), [10, 500], beamlineAngle2b, BeamElementColor.beamPipe)
|
|
|
|
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", BeamElementColor.Detector)
|
|
|
|
#------------- beam line 2c
|
|
angle2c = 30
|
|
beamlineAngle2c = bfan2.GetExistAbsAngle(angle2c);
|
|
|
|
bl2c = BeamRectElement( bfan2.GetExitPos(angle2c), [10, 400], beamlineAngle2c, BeamElementColor.beamPipe)
|
|
|
|
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, 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, BeamElementColor.beamPipe)
|
|
|
|
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", 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, BeamElementColor.beamPipe)
|
|
|
|
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)
|
|
|
|
#==================== Labels and info
|
|
clock = Clock()
|
|
|
|
#BeamInfo = IsotopeInfo(2, "H", 4.6, 6.1e+9)
|
|
BeamInfo = IsotopeInfo(3, "He", 5, 6.1e+9)
|
|
#BeamInfo = IsotopeInfo( 0, "Off", 0, 0)
|
|
|
|
|
|
|
|
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
|
|
|
|
exit_button = Button(canvas, text="Exit", command=window.destroy)
|
|
exit_button.place(x = windowSize[0] - 200, y = 50)
|
|
|
|
###################### Beam line activation
|
|
|
|
Catrina.onClick(Event);
|
|
|
|
def update():
|
|
label['text'] = "Pressure : "+ str(randint(0, 1000)) + " bar"
|
|
bl0.Blink()
|
|
|
|
bl1.Blink()
|
|
|
|
bl1a.Blink();
|
|
bl1a_1.Blink()
|
|
|
|
bl1b.Blink()
|
|
bl1c.Blink()
|
|
|
|
bl0a.Blink();
|
|
bl3.Blink()
|
|
|
|
bl2a.Blink();
|
|
bl2a_1.Blink()
|
|
|
|
bl2b.Blink()
|
|
|
|
bl2c.Blink()
|
|
bl2c_1.Blink()
|
|
bl2c_2.Blink()
|
|
|
|
clock.update()
|
|
|
|
window.after(1000, update) # run itself again after 1000 ms
|
|
|
|
update()
|
|
|
|
window.mainloop()
|
|
|