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;
String absName = 'Pfuderer_Golfballmaschine.Mechatronik.RTS24';
rts = TypeClass.findType(self.getUnitOfWork(), absName);
//Ermitteln der Bibliothekskomponente
name="Pfuderer_Baukasten.Mechatronik.Stationen.Einsetzen.Einsetzen";
type=TypeClass.findType(uow,name);
//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(rts, type, "St07Einsetzen", true);
}
catch (NoMatchingPlaceholderException nmpe)
{
// error handling
}
The instantiation API supports several methods to better control the instantiation process: concrete placeholders can be assigned 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 method instantiate 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)