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


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

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

	def set(self, tsource: enums.TetraTscSource, testMode=repcap.TestMode.Default, slot=repcap.Slot.Default, channel=repcap.Channel.Default) -> None:
		"""SCPI: [SOURce<HW>]:BB:TETRa:SCONfiguration:TMODe<DI>:SLOT<ST>:LDIRection<CH>:TSOurce \n
		Snippet: driver.source.bb.tetra.sconfiguration.tmode.slot.ldirection.tsource.set(tsource = enums.TetraTscSource.DEFault, testMode = repcap.TestMode.Default, slot = repcap.Slot.Default, channel = repcap.Channel.Default) \n
		Determines whether the default or a user-defined training sequence (TSC) is used. A user-defined training sequence can be
		created in the field 'TSC User Defined'. \n
			:param tsource: DEFault| UDEFined
			:param testMode: optional repeated capability selector. Default value: Nr1 (settable in the interface 'Tmode')
			:param slot: optional repeated capability selector. Default value: Nr1 (settable in the interface 'Slot')
			:param channel: optional repeated capability selector. Default value: Nr1 (settable in the interface 'Ldirection')"""
		param = Conversions.enum_scalar_to_str(tsource, enums.TetraTscSource)
		testMode_cmd_val = self._base.get_repcap_cmd_value(testMode, repcap.TestMode)
		slot_cmd_val = self._base.get_repcap_cmd_value(slot, repcap.Slot)
		channel_cmd_val = self._base.get_repcap_cmd_value(channel, repcap.Channel)
		self._core.io.write(f'SOURce<HwInstance>:BB:TETRa:SCONfiguration:TMODe{testMode_cmd_val}:SLOT{slot_cmd_val}:LDIRection{channel_cmd_val}:TSOurce {param}')

	# noinspection PyTypeChecker
	def get(self, testMode=repcap.TestMode.Default, slot=repcap.Slot.Default, channel=repcap.Channel.Default) -> enums.TetraTscSource:
		"""SCPI: [SOURce<HW>]:BB:TETRa:SCONfiguration:TMODe<DI>:SLOT<ST>:LDIRection<CH>:TSOurce \n
		Snippet: value: enums.TetraTscSource = driver.source.bb.tetra.sconfiguration.tmode.slot.ldirection.tsource.get(testMode = repcap.TestMode.Default, slot = repcap.Slot.Default, channel = repcap.Channel.Default) \n
		Determines whether the default or a user-defined training sequence (TSC) is used. A user-defined training sequence can be
		created in the field 'TSC User Defined'. \n
			:param testMode: optional repeated capability selector. Default value: Nr1 (settable in the interface 'Tmode')
			:param slot: optional repeated capability selector. Default value: Nr1 (settable in the interface 'Slot')
			:param channel: optional repeated capability selector. Default value: Nr1 (settable in the interface 'Ldirection')
			:return: tsource: DEFault| UDEFined"""
		testMode_cmd_val = self._base.get_repcap_cmd_value(testMode, repcap.TestMode)
		slot_cmd_val = self._base.get_repcap_cmd_value(slot, repcap.Slot)
		channel_cmd_val = self._base.get_repcap_cmd_value(channel, repcap.Channel)
		response = self._core.io.query_str(f'SOURce<HwInstance>:BB:TETRa:SCONfiguration:TMODe{testMode_cmd_val}:SLOT{slot_cmd_val}:LDIRection{channel_cmd_val}:TSOurce?')
		return Conversions.str_to_scalar_enum(response, enums.TetraTscSource)
