Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Limit dwell time
  • Loading branch information
EarToEarOak committed Feb 3, 2016
1 parent 9153816 commit 4b45dfa
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 32 deletions.
28 changes: 15 additions & 13 deletions src/cli.py
Expand Up @@ -37,7 +37,7 @@
from events import Event
from file import save_plot, export_plot, ScanInfo, File
from location import ThreadLocation
from misc import nearest, calc_real_dwell, next_2_to_pow
from misc import nearest, calc_real_dwell, next_2_to_pow, get_dwells
from scan import ThreadScan, update_spectrum, ThreadProcess
from settings import Settings

Expand Down Expand Up @@ -77,6 +77,8 @@ def __init__(self, args):
error = "Start should be lower than end"
elif dwell <= 0:
error = "Dwell should be positive"
elif dwell > max(get_dwells()[1::2]):
error = "Dwell should equal lower than {}s".format(max(get_dwells()[1::2]))
elif nfft <= 0:
error = "FFT bins should be positive"
elif ext != ".rfs" and File.get_type_index(ext) == -1:
Expand Down Expand Up @@ -107,19 +109,19 @@ def __init__(self, args):
self.settings.devicesRtl.append(device)
index = len(self.settings.devicesRtl) - 1

if args.conf is not None:
if os.path.exists(args.conf):
error = self.settings.load_conf(args.conf)
else:
error = 'Cannot find {}'.format(args.conf)
if args.conf is not None:
if os.path.exists(args.conf):
error = self.settings.load_conf(args.conf)
else:
error = 'Cannot find {}'.format(args.conf)

if end - 1 < start:
end = start + 1
if remote is None:
if len(self.settings.devicesRtl):
gain = nearest(gain, self.settings.devicesRtl[index].gains)
else:
error = 'No devices found'
if end - 1 < start:
end = start + 1
if remote is None:
if len(self.settings.devicesRtl):
gain = nearest(gain, self.settings.devicesRtl[index].gains)
else:
error = 'No devices found'

if error is not None:
print "Error: {}".format(error)
Expand Down
12 changes: 0 additions & 12 deletions src/constants.py
Expand Up @@ -54,18 +54,6 @@
16384,
32768]

DWELL = ["8 ms", 0.008,
"16 ms", 0.016,
"32 ms", 0.032,
"65 ms", 0.065,
"131 ms", 0.131,
"262 ms", 0.262,
"524 ms", 0.524,
"1 s", 1.048,
"2 s", 2.097,
"4 s", 4.194,
"8 s", 8.388]

DISPLAY = ["Plot", 0,
"Spectrogram", 1,
"3D Spectrogram", 2,
Expand Down
13 changes: 7 additions & 6 deletions src/main_window.py
Expand Up @@ -37,7 +37,7 @@
import wx
from wx.lib.masked.numctrl import NumCtrl

from constants import F_MIN, F_MAX, MODE, DWELL, NFFT, DISPLAY, Warn, \
from constants import F_MIN, F_MAX, MODE, NFFT, DISPLAY, Warn, \
Cal, Mode, APP_NAME, LOCATION_PORT
from devices import get_devices_rtl
from dialogs_devices import DialogDevicesRTL, DialogDevicesGPS
Expand All @@ -53,7 +53,7 @@
export_map, extension_add, File, run_file, export_gpx, Backups
from location import ThreadLocation, LocationServer
from menus import MenuMain, PopMenuMain
from misc import RemoteControl, calc_samples, calc_real_dwell, \
from misc import RemoteControl, calc_samples, get_dwells, calc_real_dwell, \
get_version_timestamp, get_version_timestamp_repo, format_iso_time, limit
from panels import PanelGraph
from printer import PrintOut
Expand Down Expand Up @@ -253,7 +253,7 @@ def __create_toolbars(self):
self.choiceMode.SetToolTipString('Scanning mode')

textDwell = wx.StaticText(self.toolbar2, label="Dwell")
self.choiceDwell = wx.Choice(self.toolbar2, choices=DWELL[::2])
self.choiceDwell = wx.Choice(self.toolbar2, choices=get_dwells()[::2])
self.choiceDwell.SetToolTipString('Scan time per step')

textNfft = wx.StaticText(self.toolbar2, label="FFT size")
Expand Down Expand Up @@ -1261,10 +1261,11 @@ def __set_controls(self):
self.spinCtrlStop.SetValue(self.settings.stop)
self.choiceMode.SetSelection(MODE[1::2].index(self.settings.mode))
dwell = calc_real_dwell(self.settings.dwell)
dwells = get_dwells()
try:
sel = DWELL[1::2].index(dwell)
sel = dwells[1::2].index(dwell)
except ValueError:
sel = DWELL[1::2][len(DWELL) / 4]
sel = dwells[1::2][len(dwells) / 4]
self.choiceDwell.SetSelection(sel)
self.choiceNfft.SetSelection(NFFT.index(self.settings.nfft))
self.choiceDisplay.SetSelection(DISPLAY[1::2].index(self.settings.display))
Expand Down Expand Up @@ -1299,7 +1300,7 @@ def __get_controls(self):
self.settings.startOption = self.buttonStart.GetSelected()
self.settings.stopOption = self.buttonStop.GetSelected()
self.settings.mode = MODE[1::2][self.choiceMode.GetSelection()]
self.settings.dwell = DWELL[1::2][self.choiceDwell.GetSelection()]
self.settings.dwell = get_dwells()[1::2][self.choiceDwell.GetSelection()]
self.settings.nfft = NFFT[self.choiceNfft.GetSelection()]
self.settings.display = DISPLAY[1::2][self.choiceDisplay.GetSelection()]

Expand Down
19 changes: 19 additions & 0 deletions src/misc.py
Expand Up @@ -128,6 +128,25 @@ def calc_samples(dwell):
return samples


def get_dwells():
dwells = ["8 ms", 0.008,
"16 ms", 0.016,
"32 ms", 0.032,
"65 ms", 0.065,
"131 ms", 0.131,
"262 ms", 0.262,
"524 ms", 0.524,
"1 s", 1.048,
"2 s", 2.097,
"4 s", 4.194,
"8 s", 8.388]

if sys.platform == 'linux' or sys.platform == "linux2":
del dwells[-4:]

return dwells


def calc_real_dwell(dwell):
samples = calc_samples(dwell)
dwellReal = samples / SAMPLE_RATE
Expand Down
2 changes: 1 addition & 1 deletion src/version-timestamp
@@ -1 +1 @@
1453648562
1454502628

0 comments on commit 4b45dfa

Please sign in to comment.