from typing import List

from .......Internal.Core import Core
from .......Internal.CommandsGroup import CommandsGroup
from .......Internal import Conversions
from .......Internal.Types import DataType
from .......Internal.Utilities import trim_str_response
from .......Internal.StructBase import StructBase
from .......Internal.ArgStruct import ArgStruct
from ....... import enums


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

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

	# noinspection PyTypeChecker
	class ApatternStruct(StructBase):
		"""Structure for reading output parameters. Fields: \n
			- Dpattern: List[str]: numeric
			- Bitcount: int: integer Range: 1 to 64"""
		__meta_args_list = [
			ArgStruct('Dpattern', DataType.RawStringList, None, False, True, 1),
			ArgStruct.scalar_int('Bitcount')]

		def __init__(self):
			StructBase.__init__(self, self)
			self.Dpattern: List[str] = None
			self.Bitcount: int = None

	def get_apattern(self) -> ApatternStruct:
		"""SCPI: [SOURce<HW>]:BB:BTOoth:ECONfiguration:PCONfiguration:ACAD:APATtern \n
		Snippet: value: ApatternStruct = driver.source.bb.btooth.econfiguration.pconfiguration.acad.get_apattern() \n
		Specifies user-defined pattern.
		The settings is relevant for [:SOURce<hw>]:BB:BTOoth:ECONfiguration:PCONfiguration:ACADPATTern \n
			:return: structure: for return value, see the help for ApatternStruct structure arguments.
		"""
		return self._core.io.query_struct('SOURce<HwInstance>:BB:BTOoth:ECONfiguration:PCONfiguration:ACAD:APATtern?', self.__class__.ApatternStruct())

	def set_apattern(self, value: ApatternStruct) -> None:
		"""SCPI: [SOURce<HW>]:BB:BTOoth:ECONfiguration:PCONfiguration:ACAD:APATtern \n
		Snippet: driver.source.bb.btooth.econfiguration.pconfiguration.acad.set_apattern(value = ApatternStruct()) \n
		Specifies user-defined pattern.
		The settings is relevant for [:SOURce<hw>]:BB:BTOoth:ECONfiguration:PCONfiguration:ACADPATTern \n
			:param value: see the help for ApatternStruct structure arguments.
		"""
		self._core.io.write_struct('SOURce<HwInstance>:BB:BTOoth:ECONfiguration:PCONfiguration:ACAD:APATtern', value)

	def get_aselection(self) -> str:
		"""SCPI: [SOURce<HW>]:BB:BTOoth:ECONfiguration:PCONfiguration:ACAD:ASELection \n
		Snippet: value: str = driver.source.bb.btooth.econfiguration.pconfiguration.acad.get_aselection() \n
		Specifies data list file. The settings is relevant for [:SOURce<hw>]:BB:BTOoth:ECONfiguration:PCONfiguration:ACADDLISt \n
			:return: dselection: string Path and file name.
		"""
		response = self._core.io.query_str('SOURce<HwInstance>:BB:BTOoth:ECONfiguration:PCONfiguration:ACAD:ASELection?')
		return trim_str_response(response)

	def set_aselection(self, dselection: str) -> None:
		"""SCPI: [SOURce<HW>]:BB:BTOoth:ECONfiguration:PCONfiguration:ACAD:ASELection \n
		Snippet: driver.source.bb.btooth.econfiguration.pconfiguration.acad.set_aselection(dselection = '1') \n
		Specifies data list file. The settings is relevant for [:SOURce<hw>]:BB:BTOoth:ECONfiguration:PCONfiguration:ACADDLISt \n
			:param dselection: string Path and file name.
		"""
		param = Conversions.value_to_quoted_str(dselection)
		self._core.io.write(f'SOURce<HwInstance>:BB:BTOoth:ECONfiguration:PCONfiguration:ACAD:ASELection {param}')

	# noinspection PyTypeChecker
	def get_value(self) -> enums.DataSourceB:
		"""SCPI: [SOURce<HW>]:BB:BTOoth:ECONfiguration:PCONfiguration:ACAD \n
		Snippet: value: enums.DataSourceB = driver.source.bb.btooth.econfiguration.pconfiguration.acad.get_value() \n
		Specifies the pattern source used for additional controller advertising data (ACAD) . \n
			:return: data: ALL0| ALL1| PATTern| PN09| PN11| PN15| PN16| PN20| PN21| PN23| DLISt ALL0 / ALL1 All 0 or all 1 pattern PATTern User-defined pattern. The pattern can be specified via: [:SOURcehw]:BB:BTOoth:ECONfiguration:PCONfiguration:ACAD:APATtern PNxx Pseudo-random bit sequences (PRBS) of a length of xx bits. The length in bit can be 9, 11, 15, 16, 20, 21, or 23. DLISt Internal ACAD data list is used. The data list can be specified via: [:SOURcehw]:BB:BTOoth:ECONfiguration:PCONfiguration:ACAD:ASELection
		"""
		response = self._core.io.query_str('SOURce<HwInstance>:BB:BTOoth:ECONfiguration:PCONfiguration:ACAD?')
		return Conversions.str_to_scalar_enum(response, enums.DataSourceB)

	def set_value(self, data: enums.DataSourceB) -> None:
		"""SCPI: [SOURce<HW>]:BB:BTOoth:ECONfiguration:PCONfiguration:ACAD \n
		Snippet: driver.source.bb.btooth.econfiguration.pconfiguration.acad.set_value(data = enums.DataSourceB.ALL0) \n
		Specifies the pattern source used for additional controller advertising data (ACAD) . \n
			:param data: ALL0| ALL1| PATTern| PN09| PN11| PN15| PN16| PN20| PN21| PN23| DLISt ALL0 / ALL1 All 0 or all 1 pattern PATTern User-defined pattern. The pattern can be specified via: [:SOURcehw]:BB:BTOoth:ECONfiguration:PCONfiguration:ACAD:APATtern PNxx Pseudo-random bit sequences (PRBS) of a length of xx bits. The length in bit can be 9, 11, 15, 16, 20, 21, or 23. DLISt Internal ACAD data list is used. The data list can be specified via: [:SOURcehw]:BB:BTOoth:ECONfiguration:PCONfiguration:ACAD:ASELection
		"""
		param = Conversions.enum_scalar_to_str(data, enums.DataSourceB)
		self._core.io.write(f'SOURce<HwInstance>:BB:BTOoth:ECONfiguration:PCONfiguration:ACAD {param}')
