2018-08-01 18:36:58 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import sys
|
2018-09-13 11:56:05 +00:00
|
|
|
import argparse
|
2018-08-01 18:36:58 +00:00
|
|
|
from lasp.lasp_rtapsdialog import RealTimeAPSDialog
|
|
|
|
from lasp.lasp_avstream import AvStream
|
2018-09-13 11:56:05 +00:00
|
|
|
from lasp.device.lasp_daqconfig import default_soundcard, roga_plugndaq, umik
|
|
|
|
from lasp.lasp_gui_tools import Branding, warningdialog
|
2018-08-01 18:36:58 +00:00
|
|
|
from PySide import QtGui
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2018-09-13 11:56:05 +00:00
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description='Run real time power spectra monitor')
|
|
|
|
device_help = 'Device to record from'
|
|
|
|
parser.add_argument('-d', '--device', help=device_help, type=str,
|
|
|
|
choices=['roga', 'umik', 'default'], default='roga')
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
device_str = args.device
|
|
|
|
if 'roga' == device_str:
|
|
|
|
device = roga_plugndaq
|
|
|
|
elif 'default' == device_str:
|
|
|
|
device = default_soundcard
|
|
|
|
elif 'umik' == device_str:
|
|
|
|
device = umik
|
|
|
|
|
2018-08-01 18:36:58 +00:00
|
|
|
app = QtGui.QApplication(sys.argv) # A new instance of QApplication
|
|
|
|
app.setFont(Branding.font())
|
|
|
|
|
2018-09-13 11:56:05 +00:00
|
|
|
# stream = AvStream(default_soundcard)
|
|
|
|
stream = AvStream(device)
|
2018-08-01 18:36:58 +00:00
|
|
|
mw = RealTimeAPSDialog(None, stream)
|
|
|
|
|
|
|
|
# Install exception hook to catch exceptions
|
|
|
|
def excepthook(cls, exception, traceback):
|
|
|
|
"""
|
|
|
|
This exception hook is installed as the global exception hook. Shows a
|
|
|
|
simple QMessageBox in case of an exception that is not caught.
|
|
|
|
"""
|
|
|
|
if __debug__:
|
|
|
|
import traceback as tb
|
|
|
|
tbtxt = ''.join(tb.format_tb(sys.last_traceback))
|
|
|
|
warningdialog(mw, str(exception), tbtxt)
|
|
|
|
else:
|
|
|
|
warningdialog(mw, str(exception))
|
|
|
|
|
|
|
|
# Set custom exception hook that catches all exceptions
|
|
|
|
sys.excepthook = excepthook
|
|
|
|
stream.start()
|
2018-09-13 11:56:05 +00:00
|
|
|
mw.show() # Show the window
|
|
|
|
app.exec_() # and start the event loop
|
2018-08-01 18:36:58 +00:00
|
|
|
stream.stop()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main() # run the main function
|