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


# noinspection PyPep8Naming,PyAttributeOutsideInit,SpellCheckingInspection
class Frequency:
	"""Frequency commands group definition. 1 total commands, 0 Sub-groups, 1 group commands"""

	def __init__(self, core: Core, parent):
		self._core = core
		self._base = CommandsGroup("frequency", core, parent)

	def set(self, frequency: float, internalGen=repcap.InternalGen.Default) -> None:
		"""SCPI: SOURce:AFRF:GENerator<Instance>:IGENerator<nr>:FREQuency \n
		Snippet: driver.source.afRf.generator.internalGenerator.frequency.set(frequency = 1.0, internalGen = repcap.InternalGen.Default) \n
		Configures the frequency of a single tone or square signal, generated by an internal audio generator.
		The maximum frequency for square signals is 4000 Hz. \n
			:param frequency: Range: 0 Hz to 21 kHz, Unit: Hz
			:param internalGen: optional repeated capability selector. Default value: Nr1 (settable in the interface 'InternalGenerator')"""
		param = Conversions.decimal_value_to_str(frequency)
		internalGen_cmd_val = self._base.get_repcap_cmd_value(internalGen, repcap.InternalGen)
		self._core.io.write(f'SOURce:AFRF:GENerator<Instance>:IGENerator{internalGen_cmd_val}:FREQuency {param}')

	def get(self, internalGen=repcap.InternalGen.Default) -> float:
		"""SCPI: SOURce:AFRF:GENerator<Instance>:IGENerator<nr>:FREQuency \n
		Snippet: value: float = driver.source.afRf.generator.internalGenerator.frequency.get(internalGen = repcap.InternalGen.Default) \n
		Configures the frequency of a single tone or square signal, generated by an internal audio generator.
		The maximum frequency for square signals is 4000 Hz. \n
			:param internalGen: optional repeated capability selector. Default value: Nr1 (settable in the interface 'InternalGenerator')
			:return: frequency: Range: 0 Hz to 21 kHz, Unit: Hz"""
		internalGen_cmd_val = self._base.get_repcap_cmd_value(internalGen, repcap.InternalGen)
		response = self._core.io.query_str(f'SOURce:AFRF:GENerator<Instance>:IGENerator{internalGen_cmd_val}:FREQuency?')
		return Conversions.str_to_float(response)
