package io.openems.edge.ess.generic.symmetric.essfaultbehaviour;

import io.openems.edge.ess.generic.symmetric.statemachine.Context;

public class CheckAllEssFaultBehaviour implements EssFaultBehaviour {

	@Override
	public boolean hasEssFault(Context context) {
		final var essFault = context.getParent().hasFaults();
		final var batteryFault = context.battery.hasFaults();
		final var inverterFault = context.batteryInverter.hasFaults();
		context.getParent()._setEssFaultDueToBatteryFault(batteryFault);
		context.getParent()._setEssFaultDueToBatteryInverterFault(inverterFault);
		return essFault || batteryFault || inverterFault;
	}

	@Override
	public boolean isEssStarted(Context context) {
		return context.battery.isStarted() && context.batteryInverter.isStarted();
	}

}
