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


# noinspection PyPep8Naming,PyAttributeOutsideInit,SpellCheckingInspection
class Next:
	"""Next commands group definition. 3 total commands, 1 Sub-groups, 2 group commands"""

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

	@property
	def execute(self):
		"""execute commands group. 0 Sub-classes, 1 commands."""
		if not hasattr(self, '_execute'):
			from .Execute import Execute
			self._execute = Execute(self._core, self._cmd_group)
		return self._execute

	# noinspection PyTypeChecker
	def get_source(self) -> enums.ArbSegmNextSourIntNext:
		"""SCPI: [SOURce<HW>]:BB:ARBitrary:WSEGment:NEXT:SOURce \n
		Snippet: value: enums.ArbSegmNextSourIntNext = driver.source.bb.arbitrary.wsegment.next.get_source() \n
		Selects the next segment source, i.e. determines whether the next segment is switched upon receiving of an external
		trigger signal or upon executing of software trigger . \n
			:return: source: INTernal| NEXT INTernal Switch over to any segment is triggered manually by means of the command BB:ARB:WSEG:NEXT:EXEC. NEXT The trigger event for switching to the next segment is input on the NEXT connector.
		"""
		response = self._core.io.query_str('SOURce<HwInstance>:BB:ARBitrary:WSEGment:NEXT:SOURce?')
		return Conversions.str_to_scalar_enum(response, enums.ArbSegmNextSourIntNext)

	def set_source(self, source: enums.ArbSegmNextSourIntNext) -> None:
		"""SCPI: [SOURce<HW>]:BB:ARBitrary:WSEGment:NEXT:SOURce \n
		Snippet: driver.source.bb.arbitrary.wsegment.next.set_source(source = enums.ArbSegmNextSourIntNext.INTernal) \n
		Selects the next segment source, i.e. determines whether the next segment is switched upon receiving of an external
		trigger signal or upon executing of software trigger . \n
			:param source: INTernal| NEXT INTernal Switch over to any segment is triggered manually by means of the command BB:ARB:WSEG:NEXT:EXEC. NEXT The trigger event for switching to the next segment is input on the NEXT connector.
		"""
		param = Conversions.enum_scalar_to_str(source, enums.ArbSegmNextSourIntNext)
		self._core.io.write(f'SOURce<HwInstance>:BB:ARBitrary:WSEGment:NEXT:SOURce {param}')

	def get_value(self) -> int:
		"""SCPI: [SOURce<HW>]:BB:ARBitrary:WSEGment:NEXT \n
		Snippet: value: int = driver.source.bb.arbitrary.wsegment.next.get_value() \n
		Selects the segment to be output. \n
			:return: next_py: float Range: 0 to 1023
		"""
		response = self._core.io.query_str('SOURce<HwInstance>:BB:ARBitrary:WSEGment:NEXT?')
		return Conversions.str_to_int(response)

	def set_value(self, next_py: int) -> None:
		"""SCPI: [SOURce<HW>]:BB:ARBitrary:WSEGment:NEXT \n
		Snippet: driver.source.bb.arbitrary.wsegment.next.set_value(next_py = 1) \n
		Selects the segment to be output. \n
			:param next_py: float Range: 0 to 1023
		"""
		param = Conversions.decimal_value_to_str(next_py)
		self._core.io.write(f'SOURce<HwInstance>:BB:ARBitrary:WSEGment:NEXT {param}')

	def clone(self) -> 'Next':
		"""Clones the group by creating new object from it and its whole existing sub-groups
		Also copies all the existing default Repeated Capabilities setting,
		which you can change independently without affecting the original group"""
		new_group = Next(self._core, self._cmd_group.parent)
		self._cmd_group.synchronize_repcaps(new_group)
		return new_group
