some progress
This commit is contained in:
parent
3e541653be
commit
0ecec626e2
127
dashboard.py
127
dashboard.py
|
@ -5,17 +5,21 @@ import math
|
|||
from random import randint
|
||||
import numpy as np
|
||||
|
||||
#class Room():
|
||||
# def __init__(self, points, 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[1])) , self.Center[1] - self.radius * math.sin(math.radians(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.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], extent = Angle[1], fill = 'black', outline = 'black')
|
||||
def GetExitPos(self):
|
||||
return self.ExistPos
|
||||
def GetExitPos(self, downstream = 0):
|
||||
return self.ExistPos + np.array([ downstream * math.cos(math.radians(self.Angle[1] + 90 )), -downstream * math.sin(math.radians(self.Angle[1] + 90 )) ])
|
||||
|
||||
|
||||
class Tandem():
|
||||
|
@ -25,27 +29,50 @@ class Tandem():
|
|||
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.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.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)
|
||||
def GetExitPos(self):
|
||||
return self.ExistPos
|
||||
def GetExitPos(self, downstream = 0):
|
||||
return self.ExistPos + np.array([0, - downstream])
|
||||
|
||||
class BeamRectElement():
|
||||
def __init__(self, EntryPos, Size, Angle, Color):
|
||||
self.Color = Color
|
||||
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 = Color, width = 0)
|
||||
def GetExitPos(self):
|
||||
return self.ExistPos
|
||||
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
|
||||
canvas.itemconfig(self.beamPipe, fill = Color)
|
||||
def GetColor(self):
|
||||
return self.Color
|
||||
|
||||
class BeamFan():
|
||||
def __init__(self, EntryPos, Size, Angle, Color):
|
||||
self.beamFan = canvas.create_arc( )
|
||||
class Beam90DegreeFan():
|
||||
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, outline = Color)
|
||||
def GetExitPos(self, angle, downstream = 0):
|
||||
return self.EntryPos + np.array([ (self.Radius + downstream)* math.cos(math.radians( 45 + angle + self.Angle)), - (self.Radius + downstream)*math.sin(math.radians( 45 + angle + self.Angle))])
|
||||
def GetExitAngle(self, angle):
|
||||
return 45 + angle + self.Angle - 90
|
||||
|
||||
class Station():
|
||||
def __init__(self, Center, Size, Name, Color):
|
||||
self.ULC = [Center[0] - Size/2, Center[1] - Size/2]
|
||||
self.station = canvas.create_oval(self.ULC[0], self.ULC[1], self.ULC[0] + Size, self.ULC[1]+Size, fill = Color, outline = Color)
|
||||
self.label = Label(canvas, text = Name, bg = Color)
|
||||
self.label.place(x=Center[0], y=Center[1], anchor = "center")
|
||||
|
||||
############################## Start GUI
|
||||
windowSize = [3840, 1080]# 4K upper half
|
||||
windowSize = [3840, 1500]# 4K upper half
|
||||
|
||||
window = Tk(className = 'FSU Fox\'s Lab Experimental Hall')
|
||||
#window.geometry("1920x1080") @ 2K
|
||||
|
@ -65,37 +92,75 @@ canvas.pack( expand = True, fill = BOTH)
|
|||
|
||||
#==================== Beam line
|
||||
|
||||
#------- source
|
||||
#++++++++++++++++ source
|
||||
|
||||
|
||||
tandemStart = [windowSize[0] * 0.9, windowSize[1] * 0.9] # beam entry pos
|
||||
|
||||
tandemStart = [windowSize[0] * 0.9, windowSize[1] * 0.8] # beam entry pos
|
||||
tandemSize = [100, 300] # width, height
|
||||
tandem = Tandem(tandemStart, tandemSize, 'Green')
|
||||
|
||||
bl1 = BeamRectElement( tandem.GetExitPos() , [10, 200], 0, 'white')
|
||||
bl0 = BeamRectElement( tandem.GetExitPos() , [10, 300], 0, 'white')
|
||||
|
||||
bl1a = BeamRectElement( bl1.GetExitPos(), [10, 300], 0, 'grey') # beam by-pass D-1
|
||||
bl0a = BeamRectElement( bl0.GetExitPos(), [10, 400], 0, 'grey12') # beam by-pass D-1
|
||||
|
||||
q1 = BeamRectElement(tandem.GetExitPos() + [0, -50], [40, 30], 0, 'orange')
|
||||
q2 = BeamRectElement(q1.GetExitPos() + [0, -50], [40, 30], 0, 'orange')
|
||||
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')
|
||||
|
||||
#-------- beam line to target room 1
|
||||
|
||||
#++++++++++++++++ beam line to target room 1
|
||||
dMagnetSize = [80, 20] # outer, inner radius
|
||||
d1 = DipoleMagnet(bl1.GetExitPos(), dMagnetSize, [0, 90], 'Yellow')
|
||||
d1 = DipoleMagnet(bl0.GetExitPos(), dMagnetSize, [0, 90], 'Yellow')
|
||||
|
||||
bl2 = BeamRectElement( d1.GetExitPos(), [10, 100], 90, 'white')
|
||||
bl1 = BeamRectElement( d1.GetExitPos(), [10, 100], 90, 'white')
|
||||
|
||||
bfan1 = Beam90DegreeFan(bl1.GetExitPos(), 100, 90, 'Yellow')
|
||||
|
||||
#-------- upper beam line
|
||||
angle_a = 30
|
||||
beamline1Angle_a = bfan1.GetExitAngle(angle_a)
|
||||
bl1a = BeamRectElement( bfan1.GetExitPos(angle_a), [10, 350], beamline1Angle_a, 'white')
|
||||
|
||||
q1a = BeamRectElement(bfan1.GetExitPos(angle_a, 100), [60, 60], beamline1Angle_a, 'blue')
|
||||
df1a = BeamRectElement(q1a.GetExitPos(30), [40, 30], beamline1Angle_a, 'orange')
|
||||
|
||||
bl1a_1 = BeamRectElement( bl1a.GetExitPos(), [10, 200], beamline1Angle_a, 'white')
|
||||
|
||||
#.......... Gamma station
|
||||
GammaStation = Station(bl1a.GetExitPos(), 100, "Gamma\nStation", 'Pink4')
|
||||
|
||||
#.......... Catrina
|
||||
Catrina = Station(bl1a_1.GetExitPos(), 100, "Catrina", 'Pink')
|
||||
|
||||
#---------middle beam line
|
||||
angle_b = 50
|
||||
beamline1Angle_b = bfan1.GetExitAngle(angle_b)
|
||||
bl1b = BeamRectElement( bfan1.GetExitPos(angle_b), [10, 300], beamline1Angle_b, 'grey12')
|
||||
|
||||
#--------- lower beam line
|
||||
angle_c = 70
|
||||
beamline1Angle_c = bfan1.GetExitAngle(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')
|
||||
|
||||
|
||||
#++++++++++++++++ beam line to target room 2
|
||||
|
||||
q2 = BeamRectElement( bl0.GetExitPos(100), [60, 60], 0, 'blue')
|
||||
|
||||
#-------- beam line to target room 2
|
||||
d2 = DipoleMagnet(bl1a.GetExitPos(), [80, 20], [0, 90], 'Yellow')
|
||||
df2 = BeamRectElement( q2.GetExitPos(50), [40, 40], 0, 'orange')
|
||||
|
||||
bl3 = BeamRectElement(d2.GetExitPos(), [10, 2000], 90, 'grey')
|
||||
q3 = BeamRectElement( df2.GetExitPos(50), [60, 60], 0, 'blue')
|
||||
|
||||
linac1 = BeamRectElement(d2.GetExitPos() + [-500, 0], [80, 300], 90, 'cyan')
|
||||
linac2 = BeamRectElement(linac1.GetExitPos() + [-30, 0], [80, 300], 90, 'cyan')
|
||||
linac3 = BeamRectElement(linac2.GetExitPos() + [-30, 0], [80, 300], 90, 'cyan')
|
||||
d2 = DipoleMagnet(bl0a.GetExitPos(), [80, 20], [0, 90], 'Yellow')
|
||||
|
||||
bl3 = BeamRectElement(d2.GetExitPos(), [10, 2000], 90, 'grey12')
|
||||
|
||||
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')
|
||||
|
||||
|
||||
#==================== Labels and info
|
||||
|
@ -114,9 +179,21 @@ exit_button.place(x = windowSize[0] - 200, y = 50)
|
|||
|
||||
|
||||
|
||||
###################### Beam line activation
|
||||
|
||||
def update():
|
||||
label['text'] = "Pressure : "+ str(randint(0, 1000)) + " bar"
|
||||
if bl0.GetColor() == 'Red' :
|
||||
bl0.SetColor('White')
|
||||
bl1.SetColor('White')
|
||||
bl1a.SetColor('White')
|
||||
bl1a_1.SetColor('White')
|
||||
else:
|
||||
bl0.SetColor('Red')
|
||||
bl1.SetColor('Red')
|
||||
bl1a.SetColor('Red')
|
||||
bl1a_1.SetColor('Red')
|
||||
|
||||
window.after(1000, update) # run itself again after 1000 ms
|
||||
|
||||
update()
|
||||
|
|
Loading…
Reference in New Issue
Block a user