diff --git a/dashboard.py b/dashboard.py index e8d32d0..939e161 100755 --- a/dashboard.py +++ b/dashboard.py @@ -60,14 +60,15 @@ class BeamRectElement(): canvas.itemconfig(self.beamPipe, fill = 'grey10') def Activate(self): self.Active = True - - if self.Color == 'White' : - self.Color = 'Red' - canvas.itemconfig(self.beamPipe, fill = 'Red') - else: - self.Color = 'White' - canvas.itemconfig(self.beamPipe, fill = 'White') - + def Blink(self): + if self.Active == True: + if self.Color == 'White' : + self.Color = 'Red' + canvas.itemconfig(self.beamPipe, fill = 'Red') + else: + self.Color = 'White' + canvas.itemconfig(self.beamPipe, fill = 'White') + class BeamCircleElement(): def __init__(self, Center, Size, Color): self.Center = Center @@ -93,7 +94,7 @@ class DetectorStation(): def __init__(self, Center, Size, Name, 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, 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.place(x=Center[0], y=Center[1], anchor = "center") @@ -103,14 +104,12 @@ class DetectorStation(): canvas.tag_bind(self.Detector, '', self.HopOver) canvas.tag_bind(self.Detector, '', self.Leave) - def SetColor(Color): + def SetColor(self, Color): canvas.itemconfig(self.Detector, fill = Color) self.label.config(bg = Color) def onClick(self, event): - global ActiveBeamLine - ActiveBeamLine = self.Name - print("========== ", ActiveBeamLine) + print("========== ", self.Name) bl0.Deactivate() bl1.Deactivate() bl1a.Deactivate(); bl1a_1.Deactivate() @@ -122,6 +121,9 @@ class DetectorStation(): bl2c.Deactivate() bl2c_1.Deactivate() bl2c_2.Deactivate() + + SetActiveBeamLine(self.Name) + return self.Name def HopOver(self, event): @@ -132,12 +134,17 @@ class DetectorStation(): def GetName(self): return self.Name + + def Activate(self, OnOff): + + if OnOff == True: + self.SetColor('Pink') + else: + self.SetColor('Pink4') -def SetActiveBeamLine( ): - - global ActiveBeamLine - if ActiveBeamLine == "Gamma\nStation": +def SetActiveBeamLine(BeamLineName): + if BeamLineName == "Gamma\nStation": bl0.Activate() bl1.Activate() @@ -156,7 +163,15 @@ def SetActiveBeamLine( ): bl2c_1.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() bl1.Activate() @@ -175,8 +190,15 @@ def SetActiveBeamLine( ): bl2c.Deactivate() bl2c_1.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() bl1.Deactivate() @@ -196,7 +218,14 @@ def SetActiveBeamLine( ): bl2c_1.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() bl1.Deactivate() @@ -215,8 +244,15 @@ def SetActiveBeamLine( ): 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 ActiveBeamLine == "SPS" : + elif BeamLineName == "SPS" : bl0.Activate() bl1.Deactivate() @@ -235,8 +271,16 @@ def SetActiveBeamLine( ): 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 ActiveBeamLine == "CLARION-2" : + + elif BeamLineName == "CLARION-2" : bl0.Activate() bl1.Deactivate() @@ -256,6 +300,13 @@ def SetActiveBeamLine( ): bl2c_1.Deactivate() bl2c_2.Activate() + GammaStation.Activate(False) + Catrina.Activate(False) + Resolut.Activate(False) + Anasen.Activate(False) + SPS.Activate(False) + Clarion2.Activate(True) + ############################## Start GUI #windowSize = [3840, 1500]# 4K width @@ -281,7 +332,7 @@ canvas.pack( expand = True, fill = BOTH) #==================== Beam line #++++++++++++++++ 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') blS = BeamRectElement( RFsource2.GetExitPos(), [10, 200], 0, 'white') @@ -449,12 +500,32 @@ exit_button.place(x = windowSize[0] - 200, y = 50) ###################### Beam line activation -global ActiveBeamLine -ActiveBeamLine = Catrina.GetName() +Catrina.onClick(Event); def update(): 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 update()