/**
 * This function checks for electrical faults based on the circuit breaker trips.
 *
 * @param electricalFaults A map containing the electrical faults and their status (true or false).
 * @param circuitBreakerTrip A boolean representing whether the circuit breaker tripped or not.
 * @return A list of electrical faults that are active and cause the circuit breaker to trip.
 */
fun checkElectricalFaults(electricalFaults: Map<String, Boolean>, circuitBreakerTrip: Boolean): List<String> {

    if (circuitBreakerTrip) {
        // Filter the electrical faults based on the status
        val activeFaults = electricalFaults.filterValues { it }.keys.toList()
        return activeFaults
    } else {
        return emptyList()
    }
}

// Electrical faults map containing different faults and their status
val electricalFaults = mapOf(
    "short_circuit" to true,
    "overload" to true,
    "earth_leakage" to false,
    "open_circuit" to false,
    "phase_failure" to true,
    "voltage_surge" to false
)

// Circuit breaker tripped indicator
val circuitBreakerTrip = true

// Checking for active electrical faults
val activeFaults = checkElectricalFaults(electricalFaults, circuitBreakerTrip)
/**
 * This function checks for electrical faults based on the circuit breaker trips.
 *
 * @param electricalFaults A map containing the electrical faults and their status (true or false).
 * @param circuitBreakerTrip A boolean representing whether the circuit breaker tripped or not.
 * @return A list of electrical faults that are active and cause the circuit breaker to trip.
 */
fun checkElectricalFaults(electricalFaults: Map<String, Boolean>, circuitBreakerTrip: Boolean): List<String> {
/**
 * This function checks for electrical faults based on the circuit breaker trips.
 *
 * @param electricalFaults A map containing the electrical faults and their status (true or false).
 * @param circuitBreakerTrip A boolean representing whether the circuit breaker tripped or not.
 * @return A list of electrical faults that are active and cause the circuit breaker to trip.
 */
fun checkElectricalFaults(electricalFaults: Map<String, Boolean>, circuitBreakerTrip: Boolean): List<String> {

    if (circuitBreakerTrip) {
        // Filter the electrical faults based on the status
        val activeFaults = electricalFaults.filterValues { it }.keys.toList()
        return activeFaults
    } else {
        return emptyList()
    }
}

// Electrical faults map containing different faults and their status
val electricalFaults = mapOf(
    "short_circuit" to true,
    "overload" to true,
    "earth_leakage" to false,
    "open_circuit" to false,
    "phase_failure" to true,
    "voltage_surge" to false
)

// Circuit breaker tripped indicator
val circuitBreakerTrip = true

// Checking for active electrical faults
val activeFaults = checkElectricalFaults(electricalFaults, circuitBreakerTrip)