def _test_headset_1(self, serial_mock):
     """
     Test starting of streaming
     """
     model = ApplicationModel()
     model.select_port(0, "__test_port_name__")
     model.headsets[0].start()
     self.assertTrue(model.is_headset_streaming(), "Should be streaming from headset")
     model.headsets[0].stop()
 def _test_headset_1(self, serial_mock):
     """
     Test starting of streaming
     """
     model = ApplicationModel()
     model.select_port(0, "__test_port_name__")
     model.headsets[0].start()
     self.assertTrue(model.is_headset_streaming(),
                     "Should be streaming from headset")
     model.headsets[0].stop()
 def _test_headset_3(self, serial_mock):
     """
     Test starting of toggle streaming
     """
     model = ApplicationModel()
     model.select_port(0, "__test_port_name__")
     model.start_headsets()
     time.sleep(.1)
     self.assertTrue(model.is_headset_streaming(),
                     "Should be streaming from headset")
     model.stop_headsets()
Example #4
0
def __main__():
    """
    Initializes the windows and starts the application
    """
    logger = logging.getLogger()

    #DATE = time.strftime('%y%m%d_%H%M%S')   # Every second a new file
    DATE = time.strftime('%y%m%d')  # Every day e new logfile
    logging.basicConfig(
        level=logging.INFO,
        filename='logging_%s.log' % (DATE),
        format='%(asctime)s - %(funcName)s - %(levelname)s - %(message)s')
    formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')

    # create console handler and set level to debug
    ch = logging.StreamHandler()
    ch.setLevel(logging.NOTSET)
    ch.setFormatter(formatter)

    # add ch to logger
    logger.addHandler(ch)

    # Initialize the application components
    # First create view, tk instance must exist before you can create a object in the model (ex. IntVar())
    view = ApplicationView()
    model = ApplicationModel()
    controller = ApplicationController(model, view)
    controller.update_gui_forever()
 def _test_headset_3(self, serial_mock):
     """
     Test starting of toggle streaming
     """
     model = ApplicationModel()
     model.select_port(0, "__test_port_name__")
     model.start_headsets()
     time.sleep(.1)
     self.assertTrue(model.is_headset_streaming(), "Should be streaming from headset")
     model.stop_headsets()
Example #6
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     
     self.model = ApplicationModel()
     
     _eeg_type = 1
     
     [ mat, frequencies ] = HDFReader().read( filenames[6][0] )
     data = [ np.asarray( mat[i-1][ _eeg_type ] ) for i in range(1,9) ]  
     
     interval = 1. / frequencies[_eeg_type]  
     
     self.model.simulators[0].set_simulation_data(data)
     self.model.simulators[0].set_simulation_interval(interval)
     
     eeg_chans = ['/eega0/channel_%d/pp' % i for i in range(1,9) ]
     
     self.model.simulators[0].set_patterns( eeg_chans )
 def test_headset_2(self):
     """
     Test recording state after streaming start and setting of filename
     """
     model = ApplicationModel()
     model.start_headsets()
     self.assertFalse(model.is_recording(), "Should not be recording")
     model.stop_headsets()
 def test_init(self):
     """
     Tests for initial state
     """
     model = ApplicationModel()
     
     self.assertEqual(model.get_simulation_state(), DataSimulator.IDLE, "Simulation state should initialize as IDLE")
     self.assertFalse(model.is_receiving_data(), "Should not be receiving data")
     self.assertFalse(model.is_recording(), "Should not be recording data")
     self.assertFalse(model.is_headset_streaming(), "Should not be streaming from headset")
     self.assertFalse(model.is_headset_connected(), "No headset should be selected")
 def test_headset_4(self):
     """
     Test recording state after streaming start
     """
     record_time = 10
     
     model = ApplicationModel()
     model.start_headsets()
     model.start_recording(record_time)
     model.stop_recording()
     model.stop_headsets()
     self.assertFalse(model.is_recording(), "Should not be recording")
Example #10
0
class TestApplicationModelSimulation( unittest.TestCase ):

    def setUp(self):
        unittest.TestCase.setUp(self)
        
        self.model = ApplicationModel()
        
        _eeg_type = 1
        
        [ mat, frequencies ] = HDFReader().read( filenames[6][0] )
        data = [ np.asarray( mat[i-1][ _eeg_type ] ) for i in range(1,9) ]  
        
        interval = 1. / frequencies[_eeg_type]  
        
        self.model.simulators[0].set_simulation_data(data)
        self.model.simulators[0].set_simulation_interval(interval)
        
        eeg_chans = ['/eega0/channel_%d/pp' % i for i in range(1,9) ]
        
        self.model.simulators[0].set_patterns( eeg_chans )
    
    def _test_modelstate_1(self):
        self.model.start_simulation()
        self.assertEquals( self.model.get_simulation_state(), DataSimulator.PLAYING )
        self.model.stop_simulation()
        
    def _test_modelstate_2(self):
        self.model.start_simulation()
        self.model.stop_simulation()
        self.assertEquals( self.model.get_simulation_state(), DataSimulator.IDLE )
         
    def _test_modelstate_3(self):
        self.model.start_simulation()
        self.model.pause_simulation()
        sleep( .2 )
        self.assertEquals( self.model.get_simulation_state(), DataSimulator.PAUSED )
        self.model.stop_simulation()
         
    def _test_modelstate_4(self):
        self.model.pause_simulation()
        self.assertEquals( self.model.get_simulation_state(), DataSimulator.IDLE )
        
    def tearDown(self):
        unittest.TestCase.tearDown(self)
        self.model.stop_simulation()
        self.model.stop_recording()
        self.model.stop_headsets()