def __init__(self, colour, enabled, alert, frequency, threshold, dynamic, signals, periods): Monitor.__init__(self, colour, enabled, alert, frequency, threshold, dynamic, signals, periods) self._isSaved = True
def set_enabled(self, enabled): Monitor.set_enabled(self, enabled) self._checkEnable.SetValue(enabled) self._buttonDel.Enable(not self._enabled) self.__enable_freq() if not self._enabled: self._meterLevel.set_level(LEVEL_MIN)
def set_dynamic(self, dynamic): Monitor.set_dynamic(self, dynamic) self._checkDynamic.SetValue(dynamic) if self._dynamic: self._sliderThreshold.SetMin(LEVEL_DYN_MIN) self._sliderThreshold.SetMax(LEVEL_DYN_MAX) else: self._sliderThreshold.SetMin(LEVEL_MIN) self._sliderThreshold.SetMax(LEVEL_MAX) self._threshold = self._sliderThreshold.GetValue() self._meterLevel.set_threshold(self.get_dynamic_threshold())
def set_frequency(self, freq): freqs = map(float, self._choiceFreq.GetItems()) try: self._choiceFreq.SetSelection(freqs.index(freq)) except ValueError: self._choiceFreq.SetSelection(len(freqs) / 2) index = self._choiceFreq.GetSelection() freq = float(self._choiceFreq.GetItems()[index]) Monitor.set_frequency(self, freq) self._signals = [] self.__set_records()
def __init__(self, parent, eventHandler): Monitor.__init__(self, None, False, False, None, None, False, [], []) self._eventHandler = eventHandler self._isRecording = False self._isRunning = False self._isLow = True self._colours = [] pre = wx.PrePanel() self._ui = load_ui('PanelMonitor.xrc') handlerNumCtrl = XrcHandlerNumCtrl() handlerMeter = XrcHandlerMeter() self._ui.AddHandler(handlerNumCtrl) self._ui.AddHandler(handlerMeter) self._ui.LoadOnPanel(pre, parent, 'PanelMonitor') self.PostCreate(pre) self._panelColour = xrc.XRCCTRL(pre, 'panelColour') self._checkEnable = xrc.XRCCTRL(pre, 'checkEnable') self._checkAlert = xrc.XRCCTRL(pre, 'checkAlert') self._checkDynamic = xrc.XRCCTRL(pre, 'checkDynamic') self._choiceFreq = xrc.XRCCTRL(pre, 'choiceFreq') self._textSignals = xrc.XRCCTRL(pre, 'textSignals') # TODO: hackish for child in self.GetChildren(): if isinstance(child, WidgetMeter): self._meterLevel = child self._sliderThreshold = xrc.XRCCTRL(pre, 'sliderThreshold') self._buttonDel = xrc.XRCCTRL(pre, 'buttonDel') self.__set_records() self._on_del = None self._panelColour.Bind(wx.EVT_LEFT_UP, self.__on_colour) self.Bind(wx.EVT_CHECKBOX, self.__on_enable, self._checkEnable) self.Bind(wx.EVT_CHECKBOX, self.__on_alert, self._checkAlert) self.Bind(wx.EVT_CHECKBOX, self.__on_dynamic, self._checkDynamic) self.Bind(wx.EVT_CHOICE, self.__on_freq, self._choiceFreq) self.Bind(wx.EVT_SLIDER, self.__on_threshold, self._sliderThreshold) self.Bind(wx.EVT_BUTTON, self.__on_del, self._buttonDel)
def set_level(self, level, timestamp, location): threshold = self.get_dynamic_threshold() self._meterLevel.set_threshold(threshold, False) self._meterLevel.set_noise(self._noise) self._meterLevel.set_level(level) signal = None if self._isRecording: signal = Monitor.set_level(self, level, timestamp, location) if signal is not None: self.__set_records() if level >= threshold and self._isLow: self._isLow = False if self._alert: event = Event(Events.MON_ALERT) post_event(self._eventHandler, event) elif level < threshold: self._isLow = True return signal
def load_recordings(filename): handle = open(filename, 'rb') data = json.loads(handle.read()) handle.close() _header = data[0] _version = data[1]['Version'] freq = data[1]['Frequency'] / 1e6 gain = data[1]['Gain'] if 'Gain' in data[1] else None cal = data[1]['Calibration'] if 'Calibration' in data[1] else 0 dynP = data[1]['DynamicPercentile'] if 'DynamicPercentile' in data[ 1] else 33 jsonMonitors = data[1]['Monitors'] monitors = [] for jsonMonitor in jsonMonitors: alert = jsonMonitor['Alert'] if 'Alert' in jsonMonitor else False signals = [ Signal().from_list(signal) for signal in jsonMonitor['Signals'] ] dynamic = False if 'Dynamic' in jsonMonitor: dynamic = jsonMonitor['Dynamic'] colour = None if 'Colour' in jsonMonitor: colour = jsonMonitor['Colour'] periods = [] if 'Periods' in jsonMonitor: periods = [ Period().from_list(period) for period in jsonMonitor['Periods'] ] monitor = Monitor(colour, jsonMonitor['Enabled'], alert, jsonMonitor['Frequency'] / 1e6, jsonMonitor['Threshold'], dynamic, signals, periods) monitors.append(monitor) return freq, gain, cal, dynP, monitors
def set_signals(self, signals): Monitor.set_signals(self, signals) self.__set_records()
def set_threshold(self, threshold): Monitor.set_threshold(self, threshold) self._meterLevel.set_threshold(self.get_dynamic_threshold()) self._sliderThreshold.SetValue(threshold)
def set_level(self, level, timestamp, location): signal = Monitor.set_level(self, level, timestamp, location) if signal is not None: self._isSaved = False return signal
def set_noise(self, noise): if not self._dynamic: noise = None Monitor.set_noise(self, noise)
def clear(self): Monitor.clear(self) self.__set_records()
def set_alert(self, alert): Monitor.set_alert(self, alert) self._checkAlert.SetValue(alert)