Simplify the beam line activation logic
This commit is contained in:
parent
180af57c91
commit
9ccb10c9ad
125
dashboard.py
125
dashboard.py
|
@ -60,14 +60,15 @@ class BeamRectElement():
|
||||||
canvas.itemconfig(self.beamPipe, fill = 'grey10')
|
canvas.itemconfig(self.beamPipe, fill = 'grey10')
|
||||||
def Activate(self):
|
def Activate(self):
|
||||||
self.Active = True
|
self.Active = True
|
||||||
|
def Blink(self):
|
||||||
if self.Color == 'White' :
|
if self.Active == True:
|
||||||
self.Color = 'Red'
|
if self.Color == 'White' :
|
||||||
canvas.itemconfig(self.beamPipe, fill = 'Red')
|
self.Color = 'Red'
|
||||||
else:
|
canvas.itemconfig(self.beamPipe, fill = 'Red')
|
||||||
self.Color = 'White'
|
else:
|
||||||
canvas.itemconfig(self.beamPipe, fill = 'White')
|
self.Color = 'White'
|
||||||
|
canvas.itemconfig(self.beamPipe, fill = 'White')
|
||||||
|
|
||||||
class BeamCircleElement():
|
class BeamCircleElement():
|
||||||
def __init__(self, Center, Size, Color):
|
def __init__(self, Center, Size, Color):
|
||||||
self.Center = Center
|
self.Center = Center
|
||||||
|
@ -93,7 +94,7 @@ class DetectorStation():
|
||||||
def __init__(self, Center, Size, Name, Color):
|
def __init__(self, Center, Size, Name, Color):
|
||||||
self.Name = Name
|
self.Name = Name
|
||||||
self.ULC = [Center[0] - Size/2, Center[1] - Size/2]
|
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, outline = Color)
|
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.label = Label(canvas, text = Name, bg = Color, cursor = "hand1")
|
||||||
self.label.place(x=Center[0], y=Center[1], anchor = "center")
|
self.label.place(x=Center[0], y=Center[1], anchor = "center")
|
||||||
|
|
||||||
|
@ -103,14 +104,12 @@ class DetectorStation():
|
||||||
canvas.tag_bind(self.Detector, '<Enter>', self.HopOver)
|
canvas.tag_bind(self.Detector, '<Enter>', self.HopOver)
|
||||||
canvas.tag_bind(self.Detector, '<Leave>', self.Leave)
|
canvas.tag_bind(self.Detector, '<Leave>', self.Leave)
|
||||||
|
|
||||||
def SetColor(Color):
|
def SetColor(self, Color):
|
||||||
canvas.itemconfig(self.Detector, fill = Color)
|
canvas.itemconfig(self.Detector, fill = Color)
|
||||||
self.label.config(bg = Color)
|
self.label.config(bg = Color)
|
||||||
|
|
||||||
def onClick(self, event):
|
def onClick(self, event):
|
||||||
global ActiveBeamLine
|
print("========== ", self.Name)
|
||||||
ActiveBeamLine = self.Name
|
|
||||||
print("========== ", ActiveBeamLine)
|
|
||||||
bl0.Deactivate()
|
bl0.Deactivate()
|
||||||
bl1.Deactivate()
|
bl1.Deactivate()
|
||||||
bl1a.Deactivate(); bl1a_1.Deactivate()
|
bl1a.Deactivate(); bl1a_1.Deactivate()
|
||||||
|
@ -122,6 +121,9 @@ class DetectorStation():
|
||||||
bl2c.Deactivate()
|
bl2c.Deactivate()
|
||||||
bl2c_1.Deactivate()
|
bl2c_1.Deactivate()
|
||||||
bl2c_2.Deactivate()
|
bl2c_2.Deactivate()
|
||||||
|
|
||||||
|
SetActiveBeamLine(self.Name)
|
||||||
|
|
||||||
return self.Name
|
return self.Name
|
||||||
|
|
||||||
def HopOver(self, event):
|
def HopOver(self, event):
|
||||||
|
@ -132,12 +134,17 @@ class DetectorStation():
|
||||||
|
|
||||||
def GetName(self):
|
def GetName(self):
|
||||||
return self.Name
|
return self.Name
|
||||||
|
|
||||||
|
def Activate(self, OnOff):
|
||||||
|
|
||||||
|
if OnOff == True:
|
||||||
|
self.SetColor('Pink')
|
||||||
|
else:
|
||||||
|
self.SetColor('Pink4')
|
||||||
|
|
||||||
|
|
||||||
def SetActiveBeamLine( ):
|
def SetActiveBeamLine(BeamLineName):
|
||||||
|
if BeamLineName == "Gamma\nStation":
|
||||||
global ActiveBeamLine
|
|
||||||
if ActiveBeamLine == "Gamma\nStation":
|
|
||||||
bl0.Activate()
|
bl0.Activate()
|
||||||
|
|
||||||
bl1.Activate()
|
bl1.Activate()
|
||||||
|
@ -156,7 +163,15 @@ def SetActiveBeamLine( ):
|
||||||
bl2c_1.Deactivate()
|
bl2c_1.Deactivate()
|
||||||
bl2c_2.Deactivate()
|
bl2c_2.Deactivate()
|
||||||
|
|
||||||
elif ActiveBeamLine == "CATRiNA" :
|
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()
|
bl1.Activate()
|
||||||
|
@ -175,8 +190,15 @@ def SetActiveBeamLine( ):
|
||||||
bl2c.Deactivate()
|
bl2c.Deactivate()
|
||||||
bl2c_1.Deactivate()
|
bl2c_1.Deactivate()
|
||||||
bl2c_2.Deactivate()
|
bl2c_2.Deactivate()
|
||||||
|
|
||||||
elif ActiveBeamLine == "RESOLUT" :
|
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()
|
bl0.Activate()
|
||||||
|
|
||||||
bl1.Deactivate()
|
bl1.Deactivate()
|
||||||
|
@ -196,7 +218,14 @@ def SetActiveBeamLine( ):
|
||||||
bl2c_1.Deactivate()
|
bl2c_1.Deactivate()
|
||||||
bl2c_2.Deactivate()
|
bl2c_2.Deactivate()
|
||||||
|
|
||||||
elif ActiveBeamLine == "ANASEN" :
|
GammaStation.Activate(False)
|
||||||
|
Catrina.Activate(False)
|
||||||
|
Resolut.Activate(True)
|
||||||
|
Anasen.Activate(False)
|
||||||
|
SPS.Activate(False)
|
||||||
|
Clarion2.Activate(False)
|
||||||
|
|
||||||
|
elif BeamLineName == "ANASEN" :
|
||||||
bl0.Activate()
|
bl0.Activate()
|
||||||
|
|
||||||
bl1.Deactivate()
|
bl1.Deactivate()
|
||||||
|
@ -215,8 +244,15 @@ def SetActiveBeamLine( ):
|
||||||
bl2c.Deactivate()
|
bl2c.Deactivate()
|
||||||
bl2c_1.Deactivate()
|
bl2c_1.Deactivate()
|
||||||
bl2c_2.Deactivate()
|
bl2c_2.Deactivate()
|
||||||
|
|
||||||
|
GammaStation.Activate(False)
|
||||||
|
Catrina.Activate(False)
|
||||||
|
Resolut.Activate(False)
|
||||||
|
Anasen.Activate(True)
|
||||||
|
SPS.Activate(False)
|
||||||
|
Clarion2.Activate(False)
|
||||||
|
|
||||||
elif ActiveBeamLine == "SPS" :
|
elif BeamLineName == "SPS" :
|
||||||
bl0.Activate()
|
bl0.Activate()
|
||||||
|
|
||||||
bl1.Deactivate()
|
bl1.Deactivate()
|
||||||
|
@ -235,8 +271,16 @@ def SetActiveBeamLine( ):
|
||||||
bl2c.Activate()
|
bl2c.Activate()
|
||||||
bl2c_1.Activate()
|
bl2c_1.Activate()
|
||||||
bl2c_2.Deactivate()
|
bl2c_2.Deactivate()
|
||||||
|
|
||||||
|
GammaStation.Activate(False)
|
||||||
|
Catrina.Activate(False)
|
||||||
|
Resolut.Activate(False)
|
||||||
|
Anasen.Activate(False)
|
||||||
|
SPS.Activate(True)
|
||||||
|
Clarion2.Activate(False)
|
||||||
|
|
||||||
elif ActiveBeamLine == "CLARION-2" :
|
|
||||||
|
elif BeamLineName == "CLARION-2" :
|
||||||
bl0.Activate()
|
bl0.Activate()
|
||||||
|
|
||||||
bl1.Deactivate()
|
bl1.Deactivate()
|
||||||
|
@ -256,6 +300,13 @@ def SetActiveBeamLine( ):
|
||||||
bl2c_1.Deactivate()
|
bl2c_1.Deactivate()
|
||||||
bl2c_2.Activate()
|
bl2c_2.Activate()
|
||||||
|
|
||||||
|
GammaStation.Activate(False)
|
||||||
|
Catrina.Activate(False)
|
||||||
|
Resolut.Activate(False)
|
||||||
|
Anasen.Activate(False)
|
||||||
|
SPS.Activate(False)
|
||||||
|
Clarion2.Activate(True)
|
||||||
|
|
||||||
|
|
||||||
############################## Start GUI
|
############################## Start GUI
|
||||||
#windowSize = [3840, 1500]# 4K width
|
#windowSize = [3840, 1500]# 4K width
|
||||||
|
@ -281,7 +332,7 @@ canvas.pack( expand = True, fill = BOTH)
|
||||||
#==================== Beam line
|
#==================== Beam line
|
||||||
#++++++++++++++++ source
|
#++++++++++++++++ source
|
||||||
|
|
||||||
RFsource1 = BeamRectElement( [windowSize[0]*0.9, windowSize[1]*0.95], [100, 40], 0, 'olivedrab')
|
RFsource1 = BeamRectElement( [windowSize[0]*0.9, windowSize[1]*0.8], [100, 40], 0, 'olivedrab')
|
||||||
RFsource2 = BeamRectElement( RFsource1.GetExitPos(), [20, 80], 0, 'olivedrab')
|
RFsource2 = BeamRectElement( RFsource1.GetExitPos(), [20, 80], 0, 'olivedrab')
|
||||||
|
|
||||||
blS = BeamRectElement( RFsource2.GetExitPos(), [10, 200], 0, 'white')
|
blS = BeamRectElement( RFsource2.GetExitPos(), [10, 200], 0, 'white')
|
||||||
|
@ -449,12 +500,32 @@ exit_button.place(x = windowSize[0] - 200, y = 50)
|
||||||
|
|
||||||
###################### Beam line activation
|
###################### Beam line activation
|
||||||
|
|
||||||
global ActiveBeamLine
|
Catrina.onClick(Event);
|
||||||
ActiveBeamLine = Catrina.GetName()
|
|
||||||
|
|
||||||
def update():
|
def update():
|
||||||
label['text'] = "Pressure : "+ str(randint(0, 1000)) + " bar"
|
label['text'] = "Pressure : "+ str(randint(0, 1000)) + " bar"
|
||||||
SetActiveBeamLine()
|
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()
|
||||||
|
|
||||||
window.after(1000, update) # run itself again after 1000 ms
|
window.after(1000, update) # run itself again after 1000 ms
|
||||||
|
|
||||||
update()
|
update()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user