from ......Internal.Core import Core
from ......Internal.CommandsGroup import CommandsGroup
from ......Internal import Conversions


# noinspection PyPep8Naming,PyAttributeOutsideInit,SpellCheckingInspection
class GateCls:
	"""Gate commands group definition. 3 total commands, 0 Subgroups, 3 group commands"""

	def __init__(self, core: Core, parent):
		self._core = core
		self._cmd_group = CommandsGroup("gate", core, parent)

	def get_edelay(self) -> float:
		"""SCPI: [SOURce<HW>]:[BB]:DME:ANALysis:GATE:EDELay \n
		Snippet: value: float = driver.source.bb.dme.analysis.gate.get_edelay() \n
		Sets the expected reply delay. The expected reply delay and the gate length determine the measurement window (expected
		reply delay +/- gate length/2) . \n
			:return: edelay: float Range: 0 to 150E-6
		"""
		response = self._core.io.query_str('SOURce<HwInstance>:BB:DME:ANALysis:GATE:EDELay?')
		return Conversions.str_to_float(response)

	def set_edelay(self, edelay: float) -> None:
		"""SCPI: [SOURce<HW>]:[BB]:DME:ANALysis:GATE:EDELay \n
		Snippet: driver.source.bb.dme.analysis.gate.set_edelay(edelay = 1.0) \n
		Sets the expected reply delay. The expected reply delay and the gate length determine the measurement window (expected
		reply delay +/- gate length/2) . \n
			:param edelay: float Range: 0 to 150E-6
		"""
		param = Conversions.decimal_value_to_str(edelay)
		self._core.io.write(f'SOURce<HwInstance>:BB:DME:ANALysis:GATE:EDELay {param}')

	def get_time(self) -> float:
		"""SCPI: [SOURce<HW>]:[BB]:DME:ANALysis:GATE:TIME \n
		Snippet: value: float = driver.source.bb.dme.analysis.gate.get_time() \n
		Sets the DME analysis measurement time. \n
			:return: measurement_time: float Range: 0.1 to 20
		"""
		response = self._core.io.query_str('SOURce<HwInstance>:BB:DME:ANALysis:GATE:TIME?')
		return Conversions.str_to_float(response)

	def set_time(self, measurement_time: float) -> None:
		"""SCPI: [SOURce<HW>]:[BB]:DME:ANALysis:GATE:TIME \n
		Snippet: driver.source.bb.dme.analysis.gate.set_time(measurement_time = 1.0) \n
		Sets the DME analysis measurement time. \n
			:param measurement_time: float Range: 0.1 to 20
		"""
		param = Conversions.decimal_value_to_str(measurement_time)
		self._core.io.write(f'SOURce<HwInstance>:BB:DME:ANALysis:GATE:TIME {param}')

	def get_length(self) -> int:
		"""SCPI: [SOURce<HW>]:[BB]:DME:ANALysis:GATE:[LENGth] \n
		Snippet: value: int = driver.source.bb.dme.analysis.gate.get_length() \n
		Sets the gate length for the measurement window. The measurement gate settings determine the measurement window (expected
		reply delay +/- gate length/2) . Only reply pulses for which the 50% voltage point of the rising edge of the first pulse
		is within the measurement window are used to evaluate the delay time and reply efficiency. The delay measurement is
		averaged within the measurement cycle. The reply efficiency is calculated once for each measurement cycle.
		The gate length is 1 us and the expected reply delay is 50 us. The measurement window lies in the range between 49.5 and
		50.5 us. Only pulse pairs are used for the measurement whose 50% voltage point of the rising edge of the first pulse is
		within this range. \n
			:return: length: integer Range: 100E-9 to 326E-6
		"""
		response = self._core.io.query_str('SOURce<HwInstance>:BB:DME:ANALysis:GATE:LENGth?')
		return Conversions.str_to_int(response)

	def set_length(self, length: int) -> None:
		"""SCPI: [SOURce<HW>]:[BB]:DME:ANALysis:GATE:[LENGth] \n
		Snippet: driver.source.bb.dme.analysis.gate.set_length(length = 1) \n
		Sets the gate length for the measurement window. The measurement gate settings determine the measurement window (expected
		reply delay +/- gate length/2) . Only reply pulses for which the 50% voltage point of the rising edge of the first pulse
		is within the measurement window are used to evaluate the delay time and reply efficiency. The delay measurement is
		averaged within the measurement cycle. The reply efficiency is calculated once for each measurement cycle.
		The gate length is 1 us and the expected reply delay is 50 us. The measurement window lies in the range between 49.5 and
		50.5 us. Only pulse pairs are used for the measurement whose 50% voltage point of the rising edge of the first pulse is
		within this range. \n
			:param length: integer Range: 100E-9 to 326E-6
		"""
		param = Conversions.decimal_value_to_str(length)
		self._core.io.write(f'SOURce<HwInstance>:BB:DME:ANALysis:GATE:LENGth {param}')
