def _handler_connected_set_over_current(self, *args, **kwargs): """ """ if log.isEnabledFor(logging.TRACE): # pragma: no cover log.trace("%r/%s args=%s kwargs=%s" % (self._platform_id, self.get_driver_state(), str(args), str(kwargs))) port_id = kwargs.get('port_id', None) if port_id is None: raise FSMError('set_over_current: missing port_id argument') ma = kwargs.get('ma', None) if ma is None: raise FSMError('set_over_current: missing ma argument') us = kwargs.get('us', None) if us is None: raise FSMError('set_over_current: missing us argument') # TODO: provide source info if not explicitly given: src = kwargs.get('src', 'source TBD') try: result = self.set_over_current(port_id, ma, us, src) return None, result except PlatformConnectionException as e: return self._connection_lost(RSNPlatformDriverEvent.TURN_OFF_PORT, args, kwargs, e)
def _handler_connected_disconnect_instrument(self, *args, **kwargs): """ """ if log.isEnabledFor(logging.TRACE): # pragma: no cover log.trace("%r/%s args=%s kwargs=%s" % ( self._platform_id, self.get_driver_state(), str(args), str(kwargs))) port_id = kwargs.get('port_id', None) if port_id is None: raise FSMError('disconnect_instrument: missing port_id argument') instrument_id = kwargs.get('instrument_id', None) if instrument_id is None: raise FSMError('disconnect_instrument: missing instrument_id argument') try: result = self.disconnect_instrument(port_id, instrument_id) next_state = None except PlatformConnectionException as e: return self._connection_lost(RSNPlatformDriverEvent.DISCONNECT_INSTRUMENT, args, kwargs, e) return next_state, result
def _handler_connected_set(self, *args, **kwargs): """ """ if log.isEnabledFor(logging.TRACE): # pragma: no cover log.trace("%r/%s args=%s kwargs=%s" % ( self._platform_id, self.get_driver_state(), str(args), str(kwargs))) if not self.supports_set_operation(): raise FSMError('Unsupported operation: %s' % PlatformDriverEvent.SET) attrs = kwargs.get('attrs', None) if attrs is None: raise FSMError('set_attribute_values: missing attrs argument') try: result = self.set_attribute_values(attrs) return None, result except PlatformConnectionException as e: return self._connection_lost(PlatformDriverEvent.SET, args, kwargs, e)
def _handler_connected_execute(self, *args, **kwargs): """ """ if log.isEnabledFor(logging.TRACE): # pragma: no cover log.trace("%r/%s args=%s kwargs=%s" % ( self._platform_id, self.get_driver_state(), str(args), str(kwargs))) if len(args) == 0: raise FSMError('execute_resource: missing resource_cmd argument') try: result = self.execute(*args, **kwargs) return None, result except PlatformConnectionException as e: return self._connection_lost(PlatformDriverEvent.EXECUTE, args, kwargs, e)
def _handler_connected_turn_off_port(self, *args, **kwargs): """ """ if log.isEnabledFor(logging.TRACE): # pragma: no cover log.trace("%r/%s args=%s kwargs=%s" % ( self._platform_id, self.get_driver_state(), str(args), str(kwargs))) port_id = kwargs.get('port_id', None) if port_id is None: raise FSMError('turn_off_port: missing port_id argument') try: result = self.turn_off_port(port_id) return None, result except PlatformConnectionException as e: return self._connection_lost(RSNPlatformDriverEvent.TURN_OFF_PORT, args, kwargs, e)
def _handler_unconfigured_configure(self, *args, **kwargs): """ """ if log.isEnabledFor(logging.TRACE): # pragma: no cover log.trace("%r/%s args=%s kwargs=%s" % ( self._platform_id, self.get_driver_state(), str(args), str(kwargs))) driver_config = kwargs.get('driver_config', None) if driver_config is None: raise FSMError('configure: missing driver_config argument') try: result = self.configure(driver_config) next_state = PlatformDriverState.DISCONNECTED except PlatformDriverException as e: result = None next_state = None log.error("%r: Error in platform driver configuration", self._platform_id, e) return next_state, result