Skip to content

npxpy.nodes.misc.Wait

Bases: Node

A class to represent a wait node with a specified wait time.

Attributes:

Name Type Description
wait_time float

The wait time in seconds.

Source code in npxpy/nodes/misc.py
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
class Wait(Node):
    """
    A class to represent a wait node with a specified wait time.

    Attributes:
        wait_time (float): The wait time in seconds.
    """

    def __init__(self, name: str = "Wait", wait_time: float = 1.0):
        """
        Initialize the wait node.

        Parameters:
            name (str): Name of the wait node.
            wait_time (float): Wait time in seconds, must be greater than 0.
        """
        super().__init__(node_type="wait", name=name)
        self.wait_time = wait_time

    @property
    def wait_time(self):
        """Get the wait time."""
        return self._wait_time

    @wait_time.setter
    def wait_time(self, value: float):
        """
        Set the wait time.

        Parameters:
            value (float): The wait time in seconds.

        Raises:
            ValueError: If the wait time is not greater than 0.
        """
        if value <= 0:
            raise ValueError("wait_time must be a positive number.")
        self._wait_time = value

    def to_dict(self) -> Dict[str, Any]:
        """
        Convert the Wait object into a dictionary.

        Returns:
            Dict[str, Any]: Dictionary representation of the object.
        """
        node_dict = super().to_dict()  # Get the basic dict from Node
        node_dict["wait_time"] = self.wait_time
        return node_dict

wait_time property writable

Get the wait time.

__init__(name='Wait', wait_time=1.0)

Initialize the wait node.

Parameters:

Name Type Description Default
name str

Name of the wait node.

'Wait'
wait_time float

Wait time in seconds, must be greater than 0.

1.0
Source code in npxpy/nodes/misc.py
372
373
374
375
376
377
378
379
380
381
def __init__(self, name: str = "Wait", wait_time: float = 1.0):
    """
    Initialize the wait node.

    Parameters:
        name (str): Name of the wait node.
        wait_time (float): Wait time in seconds, must be greater than 0.
    """
    super().__init__(node_type="wait", name=name)
    self.wait_time = wait_time

to_dict()

Convert the Wait object into a dictionary.

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: Dictionary representation of the object.

Source code in npxpy/nodes/misc.py
403
404
405
406
407
408
409
410
411
412
def to_dict(self) -> Dict[str, Any]:
    """
    Convert the Wait object into a dictionary.

    Returns:
        Dict[str, Any]: Dictionary representation of the object.
    """
    node_dict = super().to_dict()  # Get the basic dict from Node
    node_dict["wait_time"] = self.wait_time
    return node_dict