blob: f56035d336e562189548d5f3f051007f85b99520 [file] [log] [blame]
/*****************************************************************************
* Copyright (c) 2017 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.moka.fmu.control.queue;
import java.util.List;
import org.eclipse.papyrus.moka.fmi.profile.util.FMIProfileUtil;
import org.eclipse.papyrus.moka.fmu.engine.semantics.FMUObject;
import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.IParameterValue;
import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.ILocus;
import org.eclipse.papyrus.moka.fuml.control.execution.RootExecution;
import org.eclipse.uml2.uml.Class;
public class FMIRootExecution extends RootExecution {
// FMU instance registered in the locus
protected FMUObject fmuObject;
public FMIRootExecution(Class classifier, List<IParameterValue> inputParameterValues, ILocus locus){
super(classifier, inputParameterValues, locus);
}
public FMUObject getFMUObject(){
// Return the FMU instance corresponding to the class.
if(this.fmuObject == null && FMIProfileUtil.isCS_FMU(this.executedClass)) {
this.fmuObject = (FMUObject) this.locus.instantiate(this.executedClass);
this.fmuObject.init();
}
return this.fmuObject;
}
@Override
public void execute() {
// If the class to execute is an FMU then instantiate the corresponding
// object and start its classifier behavior. In any other situation apply
// the regular instantiation strategy.
if(FMIProfileUtil.isCS_FMU(this.executedClass)) {
if(this.fmuObject == null) {
this.getFMUObject();
}
this.fmuObject.startBehavior(this.executedClass, this.parameterValues);
}else {
super.execute();
}
}
}