aboutsummaryrefslogtreecommitdiff
path: root/panel.py
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2021-04-02 22:13:07 -0400
committerEugeniy E. Mikhailov <evgmik@gmail.com>2021-04-02 22:13:07 -0400
commited6a05fd4515ffd89de70da37bc9c12bd52c18e8 (patch)
tree0d6f0bc0996d8b402ca5f0e45bd6fe1fd25c1f1c /panel.py
parent21c687a7e5b3114d6cf5bd30302b8b84f0c4622e (diff)
downloadpyExpControl-ed6a05fd4515ffd89de70da37bc9c12bd52c18e8.tar.gz
pyExpControl-ed6a05fd4515ffd89de70da37bc9c12bd52c18e8.zip
added sweeper
Diffstat (limited to 'panel.py')
-rw-r--r--panel.py30
1 files changed, 28 insertions, 2 deletions
diff --git a/panel.py b/panel.py
index ea0c358..2889bf4 100644
--- a/panel.py
+++ b/panel.py
@@ -2,15 +2,30 @@ import tkinter as tk
from tkinter import *
from tkinter import ttk
+import time # For sleep, clock, time and perf_counter
+from datetime import datetime
+
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2Tk)
import ue9qol
+class Sweeper:
+ def __init__(self, start, stop, Npoints, SweepTime):
+ self.cnt = 0
+
+ def incr(self):
+ self.cnt += 1
+
+ def getCnt(self):
+ return self.cnt
+
+
class Experiment:
def __init__(self, root):
+ self.root = root
self.tic = 0
self.data = {}
self.data['tic'] = []
@@ -18,6 +33,8 @@ class Experiment:
self.guiSetup(root)
self.hardware = {}
self.hardwareSetup()
+ self.sweeper = Sweeper(0, 100, 100, 10)
+ self.root.after(1, self.hello )
def hardwareSetup(self):
self.hardware['LabJack'] = ue9qol.UE9qol()
@@ -33,8 +50,8 @@ class Experiment:
self.fig=plt.figure()
self.ax = self.fig.add_subplot(1,1,1)
- self.ax.set_xlim([0,20])
- self.ax.set_ylim([0,20])
+ # self.ax.set_xlim([0,20])
+ # self.ax.set_ylim([0,20])
self.ax.plot([i for i in range(10)],[i for i in range(10)])
self.canvas = FigureCanvasTkAgg(self.fig, master = root)
@@ -51,12 +68,21 @@ class Experiment:
self.canvas.get_tk_widget().pack()
def hello(self):
+ self.root.after(1, self.hello )
tic = self.tic
+ self.sweeper.incr()
+ tic = self.sweeper.getCnt()
+ self.hardware['LabJack'].setOutputCh(0, tic % 5)
self.data['tic'].append(tic)
self.data['ch1'].append( self.hardware['LabJack'].getInputCh(1) )
self.tic = self.tic + 1
+ start = datetime.now()
+ self.ax.cla()
self.ax.plot(self.data['tic'], self.data['ch1'])
self.canvas.draw()
+ stop = datetime.now()
+ runTime = (stop-start).seconds + float((stop-start).microseconds)/1000000
+ print("Replot took %s seconds." % runTime)
if __name__ == '__main__':