def __init__(self, addresses, type): """Do: 1) run super constructor to receive configs 2) run DriverComm constructor that fires binary driver 3) get json description from the driver (desc_params are required) 4) store that description in self.configs to share it with other modules 5) if autostart is set to true: 6) set driver params from config (sampling_rate and active_channels) 7) start sampling """ super(BinaryDriverWrapper, self).__init__(addresses=addresses, type=type) self._init_got_configs() self._mx_addresses = addresses context = ctx.get_new_context() context['logger'] = self.logger DriverComm.__init__(self, self.config, addresses, context) desc = self.get_driver_description() if desc.startswith('DEVICE OPEN ERROR'): self.abort("DEVICE PROBLEM: " + desc + " ...ABORTING!!!") self.store_driver_description(desc) autostart = self.config.true_val(self.config.get_param('start_sampling')) self.logger.info('Automatic start' + str(autostart)) self.ready() if autostart: self.set_driver_params() self.start_sampling()
def __init__(self, addresses, type): """Do: 1) run super constructor to receive configs 2) run DriverComm constructor that fires binary driver 3) get json description from the driver (desc_params are required) 4) store that description in self.configs to share it with other modules 5) if autostart is set to true: 6) set driver params from config (sampling_rate and active_channels) 7) start sampling """ super(BinaryDriverWrapper, self).__init__(addresses=addresses, type=type) self._init_got_configs() self._mx_addresses = addresses context = ctx.get_new_context() context['logger'] = self.logger DriverComm.__init__(self, self.config, addresses, context) desc = self.get_driver_description() if desc.startswith('DEVICE OPEN ERROR'): self.abort("DEVICE PROBLEM: " + desc + " ...ABORTING!!!") self.store_driver_description(desc) autostart = self.config.true_val( self.config.get_param('start_sampling')) self.logger.info('Automatic start' + str(autostart)) self.ready() if autostart: self.set_driver_params() self.start_sampling()
def get_description_from_driver(): conf = PeerConfig('amplifier') conf.add_local_param('driver_executable', _AMP_EXECUTABLE) conf.add_local_param('samples_per_packet', '4') driv = DriverComm(conf, catch_signals=False) descr = driv.get_driver_description() dic = json.loads(descr) driv.terminate_driver() return dic
def get_description_from_driver(device_path=None): conf = PeerConfig('amplifier') conf.add_local_param('driver_executable', 'drivers/eeg/cpp_amplifiers/gtec_amplifier') conf.add_local_param('samples_per_packet', '4') driv = DriverComm(conf, catch_signals=False) descr = driv.get_driver_description() try: dic = json.loads(descr) except ValueError, e: print "AMPLIFIER ", device_path, "IS PROBABLY BUSY.", print "Invalid channel description: ", descr dic = None
def get_description_from_driver(device_path): conf = PeerConfig("amplifier") conf.add_local_param("driver_executable", "drivers/eeg/cpp_amplifiers/tmsi_amplifier") conf.add_local_param("samples_per_packet", "4") conf.add_local_param("bluetooth_device", "") conf.add_local_param("usb_device", device_path) driv = DriverComm(conf, catch_signals=False) descr = driv.get_driver_description() try: dic = json.loads(descr) except ValueError, e: print "AMPLIFIER ", device_path, "IS PROBABLY BUSY.", print "Invalid channel description: ", descr dic = None
def get_description_from_driver(device_path): conf = PeerConfig('amplifier') conf.add_local_param('driver_executable', _AMP_EXECUTABLE) conf.add_local_param('samples_per_packet', '4') conf.add_local_param('bluetooth_device', '') conf.add_local_param('usb_device', device_path) driv = DriverComm(conf, catch_signals=False) descr = driv.get_driver_description() try: dic = json.loads(descr) except ValueError as e: print("AMPLIFIER ", device_path, "IS PROBABLY BUSY.", end=' ') print("Invalid channel description: ", descr) dic = None driv.terminate_driver() return dic
def abort(self, error_msg): self.set_param('error_details', error_msg) DriverComm.abort(self, error_msg)