from typing import List

from .......Internal.Core import Core
from .......Internal.CommandsGroup import CommandsGroup
from .......Internal.Types import DataType
from .......Internal.StructBase import StructBase
from .......Internal.ArgStruct import ArgStruct
from ....... import repcap


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

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

	# noinspection PyTypeChecker
	class ResultData(StructBase):
		"""Response structure. Fields: \n
			- Reliability: int: See 'Reliability indicator values'
			- Freq: List[float]: Tone frequency Unit: Hz
			- Level: List[float]: Audio level measured at the tone frequency Unit: dBV"""
		__meta_args_list = [
			ArgStruct.scalar_int('Reliability', 'Reliability'),
			ArgStruct('Freq', DataType.FloatList, None, False, True, 1),
			ArgStruct('Level', DataType.FloatList, None, False, True, 1)]

		def __init__(self):
			StructBase.__init__(self, self)
			self.Reliability: int = None
			self.Freq: List[float] = None
			self.Level: List[float] = None

	def fetch(self, audioInput=repcap.AudioInput.Default) -> ResultData:
		"""SCPI: FETCh:AFRF:MEASurement<Instance>:MEValuation:MTONes:AIN<Nr>:AVERage \n
		Snippet: value: ResultData = driver.afRf.measurement.multiEval.mtones.audioInput.average.fetch(audioInput = repcap.AudioInput.Default) \n
		Queries the multitone results measured for an AF input path. The results are returned in the following order:
		<Reliability>, {<Freq>, <Level>}Tone 1, ..., {<Freq>, <Level>}Tone 20 \n
			:param audioInput: optional repeated capability selector. Default value: Nr1 (settable in the interface 'AudioInput')
			:return: structure: for return value, see the help for ResultData structure arguments."""
		audioInput_cmd_val = self._base.get_repcap_cmd_value(audioInput, repcap.AudioInput)
		return self._core.io.query_struct(f'FETCh:AFRF:MEASurement<Instance>:MEValuation:MTONes:AIN{audioInput_cmd_val}:AVERage?', self.__class__.ResultData())

	def read(self, audioInput=repcap.AudioInput.Default) -> ResultData:
		"""SCPI: READ:AFRF:MEASurement<Instance>:MEValuation:MTONes:AIN<Nr>:AVERage \n
		Snippet: value: ResultData = driver.afRf.measurement.multiEval.mtones.audioInput.average.read(audioInput = repcap.AudioInput.Default) \n
		Queries the multitone results measured for an AF input path. The results are returned in the following order:
		<Reliability>, {<Freq>, <Level>}Tone 1, ..., {<Freq>, <Level>}Tone 20 \n
			:param audioInput: optional repeated capability selector. Default value: Nr1 (settable in the interface 'AudioInput')
			:return: structure: for return value, see the help for ResultData structure arguments."""
		audioInput_cmd_val = self._base.get_repcap_cmd_value(audioInput, repcap.AudioInput)
		return self._core.io.query_struct(f'READ:AFRF:MEASurement<Instance>:MEValuation:MTONes:AIN{audioInput_cmd_val}:AVERage?', self.__class__.ResultData())
