Skip to content

base

Abstract base class for hardware components acting as logic containers.

Base

Bases: BlockInterface, ABC

Abstract base class for hardware components.

Provides a structured way to define internal logic hierarchies by wrapping complex logic into a single modular unit.

Source code in src/ecc_analyzer/core/base.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class Base(BlockInterface, ABC):
    """Abstract base class for hardware components.

    Provides a structured way to define internal logic hierarchies by wrapping
    complex logic into a single modular unit.
    """

    def __init__(self, name: str):
        """Initializes the component and triggers the internal block configuration.

        Args:
            name (str): The descriptive name of the hardware component.
        """
        self.name = name
        self.root_block: Optional[BlockInterface] = None
        self.configure_blocks()

    @abstractmethod
    def configure_blocks(self):
        """Abstract method to define the internal logic structure (root block).

        Must be implemented by subclasses to specify the internal tree of blocks
        (e.g., using SumBlock, PipelineBlock).
        """
        pass

    def compute_fit(self, spfm_rates: dict[FaultType, float], lfm_rates: dict[FaultType, float]) -> tuple[dict[FaultType, float], dict[FaultType, float]]:
        """Delegates the FIT rate transformation to the internal root block.

        This allows the component to be treated as a single modular unit within the system,
        hiding its internal complexity.

        Args:
            spfm_rates (dict[FaultType, float]): Current residual failure rates.
            lfm_rates (dict[FaultType, float]): Current latent failure rates.

        Returns:
            tuple[dict[FaultType, float], dict[FaultType, float]]: Updated FIT rates
            processed by the internal root block.
        """
        if self.root_block is None:
            return spfm_rates.copy(), lfm_rates.copy()

        return self.root_block.compute_fit(spfm_rates, lfm_rates)

__init__(name)

Initializes the component and triggers the internal block configuration.

Parameters:

Name Type Description Default
name str

The descriptive name of the hardware component.

required
Source code in src/ecc_analyzer/core/base.py
18
19
20
21
22
23
24
25
26
def __init__(self, name: str):
    """Initializes the component and triggers the internal block configuration.

    Args:
        name (str): The descriptive name of the hardware component.
    """
    self.name = name
    self.root_block: Optional[BlockInterface] = None
    self.configure_blocks()

compute_fit(spfm_rates, lfm_rates)

Delegates the FIT rate transformation to the internal root block.

This allows the component to be treated as a single modular unit within the system, hiding its internal complexity.

Parameters:

Name Type Description Default
spfm_rates dict[FaultType, float]

Current residual failure rates.

required
lfm_rates dict[FaultType, float]

Current latent failure rates.

required

Returns:

Type Description
dict[FaultType, float]

tuple[dict[FaultType, float], dict[FaultType, float]]: Updated FIT rates

dict[FaultType, float]

processed by the internal root block.

Source code in src/ecc_analyzer/core/base.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def compute_fit(self, spfm_rates: dict[FaultType, float], lfm_rates: dict[FaultType, float]) -> tuple[dict[FaultType, float], dict[FaultType, float]]:
    """Delegates the FIT rate transformation to the internal root block.

    This allows the component to be treated as a single modular unit within the system,
    hiding its internal complexity.

    Args:
        spfm_rates (dict[FaultType, float]): Current residual failure rates.
        lfm_rates (dict[FaultType, float]): Current latent failure rates.

    Returns:
        tuple[dict[FaultType, float], dict[FaultType, float]]: Updated FIT rates
        processed by the internal root block.
    """
    if self.root_block is None:
        return spfm_rates.copy(), lfm_rates.copy()

    return self.root_block.compute_fit(spfm_rates, lfm_rates)

configure_blocks() abstractmethod

Abstract method to define the internal logic structure (root block).

Must be implemented by subclasses to specify the internal tree of blocks (e.g., using SumBlock, PipelineBlock).

Source code in src/ecc_analyzer/core/base.py
28
29
30
31
32
33
34
35
@abstractmethod
def configure_blocks(self):
    """Abstract method to define the internal logic structure (root block).

    Must be implemented by subclasses to specify the internal tree of blocks
    (e.g., using SumBlock, PipelineBlock).
    """
    pass