commit 32035fac55e58ddd9624918b5002b991d837ce07 Author: Ryan@WorkStation Date: Thu Sep 8 14:44:33 2022 -0400 a starting point diff --git a/README.md b/README.md new file mode 100644 index 0000000..cc7ce77 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +in Ubuntu 22.04 + +sudo apt-get install python3-tk diff --git a/dashboard.py b/dashboard.py new file mode 100755 index 0000000..21c8d88 --- /dev/null +++ b/dashboard.py @@ -0,0 +1,109 @@ +#!/usr/bin/python3 + +from tkinter import * +import math +from random import randint +import numpy as np + +class DipoleMagnet(): + def __init__(self, EntryPos, Size, Angle, Color): + self.radius = (Size[0] + Size[1])/2 + self.EntryPos = EntryPos + 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 + + +class Tandem(): + def __init__(self, EntryPos, Size, 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, 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 + +class BeamRectElement(): + def __init__(self, EntryPos, Size, Angle, 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.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 + +class BeamFan(): + def __init__(self, EntryPos, Size, Angle, Color): + self.beamFan = canvas.create_arc( ) + +############################## Start GUI +windowSize = [3840, 1080]# 4K upper half + +window = Tk(className = 'FSU Fox\'s Lab Experimental Hall') +#window.geometry("1920x1080") @ 2K +#window.geometry("3840x2160") # 4K +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) + +tandemStart = [windowSize[0] * 0.9, windowSize[1] * 0.9] # beam entry pos +tandemSize = [100, 300] # width, height +tandem = Tandem(tandemStart, tandemSize, 'Green') + +bl1 = BeamRectElement( tandem.GetExitPos() , [10, 100], 0, 'white') + +bl1a = BeamRectElement( bl1.GetExitPos(), [10, 300], 0, 'white') # beam by-pass D-1 + +#-------- beam line to target room 1 +dMagnetSize = [80, 20] # outer, inner radius +d1 = DipoleMagnet(bl1.GetExitPos(), dMagnetSize, [0, 90], 'Yellow') + +bl2 = BeamRectElement( d1.GetExitPos(), [10, 100], 90, 'white') + + + + +#-------- beam line to target room 2 +d2 = DipoleMagnet(bl1a.GetExitPos(), [80, 20], [0, 90], 'Yellow') + +bl3 = BeamRectElement(d2.GetExitPos(), [10, 2000], 90, 'grey') + +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') + + +#==================== Labels and info + +label = Label(canvas, text='hahaha') +label.place(x = windowSize[0] * 0.9, y = tandemStart[1] - 100) +#label.bind('', lambda e: label.configure(text='Moved mouse inside')) +#label.bind('', lambda e: label.configure(text='Moved mouse outside')) + + + +#==================== Button + +exit_button = Button(canvas, text="Exit", command=window.destroy) +exit_button.place(x = windowSize[0] - 200, y = 50) + +def update(): + label['text'] = "Pressure : "+ str(randint(0, 1000)) + " bar" + window.after(1000, update) # run itself again after 1000 ms + +update() + +window.mainloop() +