Better closing of app
This commit is contained in:
parent
51e8263dbd
commit
3f34d88bbc
10
apps/idle.py
10
apps/idle.py
@ -17,10 +17,10 @@ kx, ky = np.meshgrid(np.fft.fftfreq(Nx,Lx/(Nx*2.0*np.pi)), np.fft.fftfreq(Ny,Ly/
|
||||
ksq = kx*kx + ky*ky
|
||||
|
||||
c = 0.0+(np.random.random((Ny,Nx))-0.5)*0.1
|
||||
#eps=0.3
|
||||
#delta=0.0
|
||||
eps = 0.1
|
||||
delta = 1.0
|
||||
eps=0.3
|
||||
delta=0.0
|
||||
#eps = 0.1
|
||||
#delta = 1.0
|
||||
|
||||
t = 0.0
|
||||
dt = 0.01
|
||||
@ -49,6 +49,8 @@ while True:
|
||||
i+= 1
|
||||
ck=Eu*(ck+dt*(delta*np.fft.fft2(np.fft.ifft2(ck)**2)-np.fft.fft2(np.fft.ifft2(ck)**3)))
|
||||
c=np.fft.ifft2(ck)
|
||||
eps = 0.1+0.2*np.cos(i/10000)
|
||||
delta = np.sin(i/10000)
|
||||
if(i % plotEveryNth == 0):
|
||||
myc = c.real
|
||||
myc = (myc-np.min(myc))/(np.max(myc)-np.min(myc))
|
||||
|
24
main.py
24
main.py
@ -6,6 +6,11 @@ import threading
|
||||
import json
|
||||
from bottle import route, run
|
||||
import time
|
||||
import sys
|
||||
import signal
|
||||
|
||||
running = True
|
||||
|
||||
if config.UseGui:
|
||||
import pygame
|
||||
|
||||
@ -18,13 +23,14 @@ if config.UseGui:
|
||||
self.data = data
|
||||
|
||||
def run(self):
|
||||
global running
|
||||
sf = config.GuiScaleFactor
|
||||
screen = pygame.display.set_mode((sf*config.ScreenX, sf*config.ScreenY))
|
||||
pygame.display.set_caption("Pixelserver - GUI Vis")
|
||||
while True:
|
||||
while running:
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
sys.exit(0)
|
||||
running = False
|
||||
screen.fill((0, 255, 0))
|
||||
for x in range(config.ScreenX):
|
||||
for y in range(config.ScreenY):
|
||||
@ -49,7 +55,7 @@ class SerialWriter(threading.Thread):
|
||||
def run(self):
|
||||
should_connect = True
|
||||
ser = None
|
||||
while True:
|
||||
while running:
|
||||
try:
|
||||
if should_connect:
|
||||
ser = serial.Serial(config.Serial)
|
||||
@ -72,7 +78,7 @@ class WatchDog(threading.Thread):
|
||||
self.check = check
|
||||
self.action = action
|
||||
def run(self):
|
||||
while True:
|
||||
while running:
|
||||
if self.check():
|
||||
self.action()
|
||||
time.sleep(1)
|
||||
@ -119,7 +125,7 @@ class AppRunner(threading.Thread):
|
||||
self.app = subprocess.Popen(args, stdout=subprocess.PIPE, close_fds=True)
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
while running:
|
||||
with self.lock:
|
||||
if self.app == None or self.app.poll() != None:
|
||||
self.requestedApp = 0
|
||||
@ -137,7 +143,10 @@ class AppRunner(threading.Thread):
|
||||
self.gui.setData(data)
|
||||
except:
|
||||
pass
|
||||
|
||||
self.watchdog.join()
|
||||
self.serial.join()
|
||||
if config.UseGui:
|
||||
self.gui.join()
|
||||
|
||||
runner = AppRunner()
|
||||
runner.start()
|
||||
@ -172,4 +181,7 @@ def apps_running():
|
||||
i = runner.currentApp
|
||||
return config.Apps[i]["name"]
|
||||
|
||||
|
||||
run(host="localhost", port=8000)
|
||||
running = False
|
||||
runner.join()
|
Loading…
Reference in New Issue
Block a user