#-------------------------------------------------------------------------------
# Name:        CCCS
# Author:      d.fathi
# Created:     10/03/2017
# Modified:    24/03/2025
# Copyright:   (c) PyAMS
#-------------------------------------------------------------------------------

from pyams_lib import model, signal, param
from pyams_lib import current

# Current-Controlled Current Source (CCCS) Model
class CCCS(model):
    """
    This class implements a Current-Controlled Current Source (CCCS) model.

    A CCCS is a dependent current source where the output current (Iout) 
    is proportional to the input current (Iin) with a gain factor.

    Attributes:
        Iin (signal): Input current signal that controls the source, defined between nodes (p1, n1).
        Iout (signal): Output current signal generated by the source, defined between nodes (p2, n2).
        G (param): Gain multiplier, default is 1.0.

    Methods:
        analog(): Defines the current transformation:
                  Iout = G * Iin
    """
    
    def __init__(self, p1, n1, p2, n2):
        # Signal declarations
        self.Iin = signal('in', current, p1, n1)
        self.Iout = signal('out', current, p2, n2)

        # Parameter declarations
        self.G = param(1.0, ' ', 'Gain multiplier')

    def analog(self):
        """Defines the CCCS behavior where output current is a scaled version of input current."""
        self.Iout += self.G * self.Iin



