diff options
-rw-r--r-- | eitControl.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/eitControl.py b/eitControl.py index 61441bf..e9cda92 100644 --- a/eitControl.py +++ b/eitControl.py @@ -2,6 +2,7 @@ import tkinter as tk from tkinter import * from tkinter import ttk import platform +import argparse from threading import Thread @@ -21,12 +22,15 @@ from rfGen import rfGenLMX2487 class Experiment: - def __init__(self, root): + def __init__(self, root, args): self.root = root self.tic = 0 self.channelsNames2grab={'tic', 'x','rfFreq','dac0', 'dac1', 'adc0', 'adc1', 'adc2', 'adc3'} #self.channelsNames2plot={'dac0', 'dac1', 'adc0', 'adc1', 'adc2', 'adc3'} - self.channelsNames2plot={'adc0'} + if args.test: + self.channelsNames2plot={'adc0', 'adc1'} + else: + self.channelsNames2plot={'adc0'} self.xChannelName='rfFreq' # can be also 'tic' or any of above self.xlabel='' self.lines2plot={} @@ -35,8 +39,8 @@ class Experiment: self.guiSweeper = Sweeper(self.root, Npoints=2, SweepTime=1, onTicCallbacks=[self.updatePlot]) self.guiSweeper.cmdStart() self.hardware = {} - self.hardwareSetup() - self.sweeper = Sweeper(self.root, Npoints=500, SweepTime=10, onTicCallbacks=[self.onTic]) + self.hardwareSetup(args) + self.sweeper = Sweeper(self.root, Npoints=100, SweepTime=10, onTicCallbacks=[self.onTic]) # self.funcGen = SinGen(2, 2, sweeper = self.sweeper) # self.funcGen = RampGen(0, 5, sweeper = self.sweeper) self.funcGen = TriangleGen(0, 5, sweeper = self.sweeper) @@ -47,8 +51,12 @@ class Experiment: self.rfGenFunc = RampGen(fCent-fSpan/2, fCent+fSpan/2, sweeper = self.sweeper) - def hardwareSetup(self): - self.hardware['LabJack'] = ue9qol.UE9qol() + def hardwareSetup(self,args): + if args.test: + print("Test mode, run with fake hardware") + self.hardware['LabJack'] = ue9qol.UE9qolDummy() + else: + self.hardware['LabJack'] = ue9qol.UE9qol() if platform.system() == 'Linux': rf=rfGenLMX2487(port='/dev/ttyUSB0', speed=115200, timeout=1) @@ -227,10 +235,15 @@ class Experiment: if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Perform EIT based experiment.') + parser.add_argument('--test', '-t', action='store_true', + help='test mode, use fake/dummy hardware') + args = parser.parse_args() + root=Tk() root.geometry("800x600") - experiment=Experiment(root) + experiment=Experiment(root, args) root.mainloop() |