![JAR search and dependency download from the Maven repository](/logo.png)
com.powsybl.openrao.data.cracimpl.OnInstantAdderImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of open-rao-crac-impl Show documentation
Show all versions of open-rao-crac-impl Show documentation
Object model for CRAC implementation
/*
* Copyright (c) 2021, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.openrao.data.cracimpl;
import com.powsybl.openrao.commons.OpenRaoException;
import com.powsybl.openrao.data.cracapi.Instant;
import com.powsybl.openrao.data.cracapi.usagerule.OnInstant;
import com.powsybl.openrao.data.cracapi.usagerule.OnInstantAdder;
import com.powsybl.openrao.data.cracapi.usagerule.UsageMethod;
import static com.powsybl.openrao.data.cracimpl.AdderUtils.assertAttributeNotNull;
/**
* @author Peter Mitri {@literal }
* @author Baptiste Seguinot {@literal }
*/
public class OnInstantAdderImpl> implements OnInstantAdder {
private T owner;
private String instantId;
private UsageMethod usageMethod;
OnInstantAdderImpl(AbstractRemedialActionAdder owner) {
this.owner = (T) owner;
}
@Override
public OnInstantAdder withInstant(String instantId) {
this.instantId = instantId;
return this;
}
@Override
public OnInstantAdder withUsageMethod(UsageMethod usageMethod) {
this.usageMethod = usageMethod;
return this;
}
@Override
public T add() {
assertAttributeNotNull(instantId, "OnInstant", "instant", "withInstant()");
assertAttributeNotNull(usageMethod, "OnInstant", "usage method", "withUsageMethod()");
Instant instant = owner.getCrac().getInstant(instantId);
if (instant.isOutage()) {
throw new OpenRaoException("OnInstant usage rules are not allowed for OUTAGE instant.");
}
if (instant.isPreventive()) {
owner.getCrac().addPreventiveState();
}
OnInstant onInstant = new OnInstantImpl(usageMethod, instant);
owner.addUsageRule(onInstant);
return owner;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy