add Tandem onoff

This commit is contained in:
Ryan Tang 2022-09-15 12:59:51 -04:00
parent 3a0b7bcd30
commit 15c3fb45ee

View File

@ -30,13 +30,62 @@ class DipoleMagnet():
class Tandem(): class Tandem():
def __init__(self, EntryPos, Size, Color): def __init__(self, EntryPos, Size, Color):
self.Color = Color
self.ULC = [EntryPos[0] - Size[0]/2, EntryPos[1] - Size[1] ] self.ULC = [EntryPos[0] - Size[0]/2, EntryPos[1] - Size[1] ]
self.ExistPos = np.array([ EntryPos[0] , 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, outline = Color) 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, outline = Color) 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, outline = Color) 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): def GetExitPos(self, downstream = 0):
return self.ExistPos + np.array([0, - downstream]) 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(): class BeamElementColor():
beamPipe = ['White', 'grey30'] beamPipe = ['White', 'grey30']
@ -45,6 +94,7 @@ class BeamElementColor():
Qpole = ['Blue', 'Blue4'] Qpole = ['Blue', 'Blue4']
Detector = ['Yellow', 'Yellow4'] Detector = ['Yellow', 'Yellow4']
LINAC = ['Cyan', 'Cyan4'] LINAC = ['Cyan', 'Cyan4']
Tandem = [ '#782F40', '#CEB888']
Buncher = ['Ivory', 'Ivory4'] Buncher = ['Ivory', 'Ivory4']
SNICS = ['tan', 'tan4'] SNICS = ['tan', 'tan4']
RFsourcce = ['Olivedrab', 'Olivedrab4'] RFsourcce = ['Olivedrab', 'Olivedrab4']
@ -162,7 +212,8 @@ def SetActiveBeamLine(BeamLineName):
bl1c.Deactivate() bl1c.Deactivate()
bl0a.Deactivate(); bl3.Deactivate() bl0a.Deactivate(); bl3.Deactivate()
bl2a.Deactivate(); bl2a_1.Deactivate() bl2a.Deactivate(); bl2a_1.Deactivate()
bl2b.Deactivate() bl2b.Deactivate()
bl2c.Deactivate() bl2c.Deactivate()
bl2c_1.Deactivate() bl2c_1.Deactivate()
bl2c_2.Deactivate() bl2c_2.Deactivate()
@ -179,24 +230,28 @@ def SetActiveBeamLine(BeamLineName):
bl1.Activate() bl1.Activate()
bl1a.Activate(); bl1a.Activate();
GammaStation.Activate(True) GammaStation.Activate(True)
tandem.Activate(True)
elif BeamLineName == "CATRiNA" : elif BeamLineName == "CATRiNA" :
bl0.Activate() bl0.Activate()
bl1.Activate() bl1.Activate()
bl1a.Activate(); bl1a_1.Activate() bl1a.Activate(); bl1a_1.Activate()
Catrina.Activate(True) Catrina.Activate(True)
tandem.Activate(True)
elif BeamLineName == "RESOLUT" : elif BeamLineName == "RESOLUT" :
bl0.Activate() bl0.Activate()
bl0a.Activate(); bl3.Activate() bl0a.Activate(); bl3.Activate()
bl2a.Activate(); bl2a_1.Activate() bl2a.Activate(); bl2a_1.Activate()
Resolut.Activate(True) Resolut.Activate(True)
tandem.Activate(True)
elif BeamLineName == "ANASEN" : elif BeamLineName == "ANASEN" :
bl0.Activate() bl0.Activate()
bl0a.Activate(); bl3.Activate() bl0a.Activate(); bl3.Activate()
bl2b.Activate() bl2b.Activate()
Anasen.Activate(True) Anasen.Activate(True)
tandem.Activate(True)
elif BeamLineName == "SPS" : elif BeamLineName == "SPS" :
bl0.Activate() bl0.Activate()
@ -204,6 +259,7 @@ def SetActiveBeamLine(BeamLineName):
bl2c.Activate() bl2c.Activate()
bl2c_1.Activate() bl2c_1.Activate()
SPS.Activate(True) SPS.Activate(True)
tandem.Activate(True)
elif BeamLineName == "CLARION-2" : elif BeamLineName == "CLARION-2" :
bl0.Activate() bl0.Activate()
@ -211,6 +267,10 @@ def SetActiveBeamLine(BeamLineName):
bl2c.Activate() bl2c.Activate()
bl2c_2.Activate() bl2c_2.Activate()
Clarion2.Activate(True) Clarion2.Activate(True)
tandem.Activate(True)
elif BeamLineName == "Tandem" :
tandem.Activate(True)
bl0.Activate()
class IsotopeInfo(): class IsotopeInfo():
@ -323,8 +383,8 @@ SNICS = BeamRectElement( blS0.GetExitPos(), [50, 50], bfanS.GetExistAbsAngle(30)
blS1 = BeamRectElement( bfanS.GetExitPos(-30), [10, 50], bfanS.GetExistAbsAngle(-30), BeamElementColor.beamPipe) blS1 = BeamRectElement( bfanS.GetExitPos(-30), [10, 50], bfanS.GetExistAbsAngle(-30), BeamElementColor.beamPipe)
TriSource = BeamRectElement( blS1.GetExitPos(), [50, 50], bfanS.GetExistAbsAngle(-30), BeamElementColor.Detector) TriSource = BeamRectElement( blS1.GetExitPos(), [50, 50], bfanS.GetExistAbsAngle(-30), BeamElementColor.Detector)
tandemSize = [100, 300] # width, height tandemSize = [200, 300] # width, height
tandem = Tandem(blS.GetExitPos(), tandemSize, 'Green') tandem = Tandem(blS.GetExitPos(), tandemSize, BeamElementColor.Tandem)
bl0 = BeamRectElement( tandem.GetExitPos() , [10, 300], 0, BeamElementColor.beamPipe) bl0 = BeamRectElement( tandem.GetExitPos() , [10, 300], 0, BeamElementColor.beamPipe)
@ -478,7 +538,6 @@ Chart()
exit_button = Button(canvas, text="Exit", command=window.destroy) exit_button = Button(canvas, text="Exit", command=window.destroy)
exit_button.place(x = windowSize[0] - 200, y = 50) exit_button.place(x = windowSize[0] - 200, y = 50)
###################### Beam line activation ###################### Beam line activation
Catrina.onClick(Event); Catrina.onClick(Event);