Two steps are necessary to create a project component:
- Determination of the library component, which is to instantiate.
- Creating and inserting the project component into the mechatronic structure by means of the instantiation API.
import com.mind8.mechatronic.skill.api.IMechatronicInstantiationAPI;
import com.mind8.mechatronic.skill.api. NoMatchingPlaceholderException;
import com.mind8.mechatronic.skill.eos.TypeClass;
absName = "T_Mechatronic_ModularSystem.Stations.Feeder";
absLibComp = "T_Mechatronic_ModularSystem.Functiongroups.Insert"; // Component to instantiate
instComp = "Insert"; // Name of new instance
feeder = TypeClass.findType(self.getUnitOfWork(), absLibComp);
// Ermitteln der Bibliothekskomponente
type = TypeClass.findType(self.getUnitOfWork(), instComp);
// Instanz erzeugen
try
{
// Die folgende Methode fügt das Objekt auf den ersten passenden
// Einfügeplatz von hinten ein.
// Gibt es mehrere passende Einfügeplätze muss dieser zunächst mittels der
// PlaceholderAPI ermittelt werden.
inst = IMechatronicInstantiationAPI.DEFAULT.instantiate(feeder, type, instComp, true);
}
catch (NoMatchingPlaceholderException nmpe)
{
// error handling
}
The instantiation API offers different methods to control the instantiation process more exactly: Concrete placeholders can be specified or the calculation of extension points can be suppressed. For several instantiations in a sequence, the performance is optimized by reuse of the instantiation context. The single methods of the API IMechatronicInstantiationAPI.DEFAULT are described as follows:
The instantiate method is implemented with different signatures:
- instantiate(instantiationTarget, MechatronicObjectClass classToInstantiate, String instanceName, boolean instantiateExtensions)
- instantiate(instantiationTarget, MechatronicObjectClass classToInstantiate, String instanceName, boolean instantiateExtensions, IMechatronicInstantiationContext context)
- instantiate(instantiationTarget, MechatronicObjectClass classToInstantiate, String instanceName, boolean instantiateExtensions, String placeholderName, IMechatronicInstantiationContext context)
- instantiate(instantiationTarget, MechatronicObjectClass classToInstantiate, String instanceName, boolean instantiateExtensions, String placeholderName)
- instantiate(instantiationTarget, MechatronicObjectClass classToInstantiate, String instanceName, boolean instantiateExtensions, Placeholder placeholder)