本文整理汇总了Python中mi.core.instrument.instrument_fsm.ThreadSafeFSM.get_current_state方法的典型用法代码示例。如果您正苦于以下问题:Python ThreadSafeFSM.get_current_state方法的具体用法?Python ThreadSafeFSM.get_current_state怎么用?Python ThreadSafeFSM.get_current_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mi.core.instrument.instrument_fsm.ThreadSafeFSM
的用法示例。
在下文中一共展示了ThreadSafeFSM.get_current_state方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SingleConnectionInstrumentDriver
# 需要导入模块: from mi.core.instrument.instrument_fsm import ThreadSafeFSM [as 别名]
# 或者: from mi.core.instrument.instrument_fsm.ThreadSafeFSM import get_current_state [as 别名]
#.........这里部分代码省略.........
@param timeout=timeout Optional command timeout.
@retval Current device state.
@raises InstrumentTimeoutException if could not wake device.
@raises InstrumentStateException if command not allowed in current state or if
device state not recognized.
@raises NotImplementedException if not implemented by subclass.
"""
# Forward event and argument to the protocol FSM.
return self._connection_fsm.on_event(DriverEvent.DISCOVER, DriverEvent.DISCOVER, *args, **kwargs)
def get_resource_capabilities(self, current_state=True, *args, **kwargs):
"""
Return driver commands and parameters.
@param current_state True to retrieve commands available in current
state, otherwise reutrn all commands.
@retval list of AgentCapability objects representing the drivers
capabilities.
@raises NotImplementedException if not implemented by subclass.
"""
if self._protocol:
return self._protocol.get_resource_capabilities(current_state)
else:
return [[], []]
def get_resource_state(self, *args, **kwargs):
"""
Return the current state of the driver.
@retval str current driver state.
@raises NotImplementedException if not implemented by subclass.
"""
connection_state = self._connection_fsm.get_current_state()
if connection_state == DriverConnectionState.CONNECTED:
return self._protocol.get_current_state()
else:
return connection_state
def get_resource(self, *args, **kwargs):
"""
Retrieve device parameters.
@param args[0] DriverParameter.ALL or a list of parameters to retrive.
@retval parameter : value dict.
@raises InstrumentParameterException if missing or invalid get parameters.
@raises InstrumentStateException if command not allowed in current state
@raises NotImplementedException if not implemented by subclass.
"""
# Forward event and argument to the protocol FSM.
return self._connection_fsm.on_event(DriverEvent.GET, DriverEvent.GET, *args, **kwargs)
def set_resource(self, *args, **kwargs):
"""
Set device parameters.
@param args[0] parameter : value dict of parameters to set.
@param timeout=timeout Optional command timeout.
@raises InstrumentParameterException if missing or invalid set parameters.
@raises InstrumentTimeoutException if could not wake device or no response.
@raises InstrumentProtocolException if set command not recognized.
@raises InstrumentStateException if command not allowed in current state.
@raises NotImplementedException if not implemented by subclass.
"""
# Forward event and argument to the protocol FSM.
return self._connection_fsm.on_event(DriverEvent.SET, DriverEvent.SET, *args, **kwargs)
def execute_resource(self, resource_cmd, *args, **kwargs):
示例2: SingleConnectionInstrumentDriver
# 需要导入模块: from mi.core.instrument.instrument_fsm import ThreadSafeFSM [as 别名]
# 或者: from mi.core.instrument.instrument_fsm.ThreadSafeFSM import get_current_state [as 别名]
#.........这里部分代码省略.........
@param timeout=timeout Optional command timeout.
@retval Current device state.
@raises InstrumentTimeoutException if could not wake device.
@raises InstrumentStateException if command not allowed in current state or if
device state not recognized.
@raises NotImplementedException if not implemented by subclass.
"""
# Forward event and argument to the protocol FSM.
return self._connection_fsm.on_event(
DriverEvent.DISCOVER, DriverEvent.DISCOVER, *args, **kwargs)
def get_resource_capabilities(self, current_state=True, *args, **kwargs):
"""
Return driver commands and parameters.
@param current_state True to retrieve commands available in current
state, otherwise return all commands.
@retval list of AgentCapability objects representing the drivers
capabilities.
@raises NotImplementedException if not implemented by subclass.
"""
if self._protocol:
return self._protocol.get_resource_capabilities(current_state)
else:
return [[], []]
def get_resource_state(self, *args, **kwargs):
"""
Return the current state of the driver.
@retval str current driver state.
@raises NotImplementedException if not implemented by subclass.
"""
connection_state = self._connection_fsm.get_current_state()
if connection_state == DriverConnectionState.CONNECTED:
return self._protocol.get_current_state()
else:
return connection_state
def get_resource(self, *args, **kwargs):
"""
Retrieve device parameters.
@param args[0] DriverParameter.ALL or a list of parameters to retrieve.
@retval parameter : value dict.
@raises InstrumentParameterException if missing or invalid get parameters.
@raises InstrumentStateException if command not allowed in current state
@raises NotImplementedException if not implemented by subclass.
"""
# Forward event and argument to the protocol FSM.
return self._connection_fsm.on_event(DriverEvent.GET, DriverEvent.GET, *args, **kwargs)
def set_resource(self, *args, **kwargs):
"""
Set device parameters.
@param args[0] parameter : value dict of parameters to set.
@param timeout=timeout Optional command timeout.
@raises InstrumentParameterException if missing or invalid set parameters.
@raises InstrumentTimeoutException if could not wake device or no response.
@raises InstrumentProtocolException if set command not recognized.
@raises InstrumentStateException if command not allowed in current state.
@raises NotImplementedException if not implemented by subclass.
"""
# Forward event and argument to the protocol FSM.
return self._connection_fsm.on_event(DriverEvent.SET, DriverEvent.SET, *args, **kwargs)
def execute_resource(self, resource_cmd, *args, **kwargs):