def close(self, info, isok): app = info.object # convenience app.sensor.disconnect() file_name = os.path.join( ETSConfig.get_application_home(True), 'sensor_output %s.csv' % str(datetime.datetime.now()).replace(':', '-')) # make sure directory exists. if not os.path.exists(ETSConfig.get_application_home(False)): os.makedirs(ETSConfig.get_application_home(False)) arr = np.array(app.sensor.history) if not arr.size: return isok np.savetxt(file_name, arr) msg = 'Output (size %s) saved to %s.' % (str(arr.shape), file_name) logging.info(msg) from pyface.api import information information(info.ui.control, msg, title='Array saved to disk.') return isok
def close(self, info, isok): app = info.object # convenience app.sensor.disconnect() file_name = os.path.join(ETSConfig.get_application_home(True), 'sensor_output %s.csv' % str(datetime.datetime.now()).replace(':', '-')) # make sure directory exists. if not os.path.exists(ETSConfig.get_application_home(False)): os.makedirs(ETSConfig.get_application_home(False)) arr = np.array(app.sensor.history) if not arr.size: return isok np.savetxt(file_name, arr) msg = 'Output (size %s) saved to %s.' % (str(arr.shape), file_name) logging.info(msg) from pyface.api import information information(info.ui.control, msg, title='Array saved to disk.') return isok
def _id_default(self): """ Use the application's directory as the id """ from traits.etsconfig.etsconfig import ETSConfig return ETSConfig._get_application_dirname()
from pyface.api import ImageResource from pyface.timer.api import do_later from apptools.preferences.api import Preferences # Internal imports from hardware import EEGSensor, SAMPLE_RATE, MAX_HISTORY_LENGTH from matplotlib.figure import Figure from mpl import MPLFigureEditor # We package QDarkStyle for convenience. The most current version is # at https://pypi.python.org/pypi/QDarkStyle # or https://github.com/ColinDuquesnoy/QDarkStyleSheet # This packages is simply for aesthetics. import qdarkstyle preferences = Preferences(filename=os.path.join(ETSConfig.get_application_home(True), "preferences.ini")) # Custom parameters. X_WIDTH_S = 6.0 PLOT_STEP = 1 class SensorOperationController(tui.Controller): """ UI for controlling the hardware. """ model = t.Instance(EEGSensor) connect = t.Button() disconnect = t.Button() def _connect_changed(self): self.model.connect()
from pyface.timer.api import do_later from apptools.preferences.api import Preferences # Internal imports from hardware import EEGSensor, SAMPLE_RATE, MAX_HISTORY_LENGTH from matplotlib.figure import Figure from mpl import MPLFigureEditor # We package QDarkStyle for convenience. The most current version is # at https://pypi.python.org/pypi/QDarkStyle # or https://github.com/ColinDuquesnoy/QDarkStyleSheet # This packages is simply for aesthetics. import qdarkstyle preferences = Preferences(filename=os.path.join( ETSConfig.get_application_home(True), 'preferences.ini')) # Custom parameters. X_WIDTH_S = 6.0 PLOT_STEP = 1 class SensorOperationController(tui.Controller): """ UI for controlling the hardware. """ model = t.Instance(EEGSensor) connect = t.Button() disconnect = t.Button() def _connect_changed(self): self.model.connect()