|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.kuka.roboticsAPI.RoboticsAPIContext
public class RoboticsAPIContext
Main entry point for the RoboticsAPI. Provides access to Controllers and engines.
A context is created through a configuration URL which contains information about the configured controller and
engines. Only if the defaultContext is chosen, the configuration URL is not set and therefore the
'getConfigurationFile' method will return null.
Context creation is an expensive operation. Your application should need in most cases only one context during it's life-cycle. If a context pointing to the same configuration URL is created twice, the other context will get disposed.
| Field Summary | |
|---|---|
protected Map<String,Controller> |
_controllers
The list of controllers. |
static String |
DEFAULT_FILE_NAME
Default name of the robotics api configuration file. |
| Constructor Summary | |
|---|---|
protected |
RoboticsAPIContext(Class<?> applicationContext,
URL configFile)
Creates a new context instance. |
| Method Summary | ||
|---|---|---|
static void |
addContextListener(IContextListener listener)
Registers a listener for context events. |
|
boolean |
containsController(String name)
Checks if a controller is contained in the context. |
|
|
containsEngine(Class<T> clazz)
Determines if an engine type is loaded in this context. |
|
static RoboticsAPIContext |
create()
Creates a new RoboticsAPIContext out of the config file which is located on the default package scope. |
|
static RoboticsAPIContext |
create(Class<?> applicationContext)
Creates a new RoboticsAPIContext out of the config file which is located on the default package scope. |
|
protected Controller |
createController(com.kuka.common.ParameterSet description)
Creates a controller instance. |
|
static RoboticsAPIContext |
createDefaultContext()
Creates a default context with the default engines and the MockController inside. |
|
static RoboticsAPIContext |
createFromFile(Class<?> applicationContext,
File configFile)
Creates a new RoboticsAPIContext out of the given config file. |
|
static RoboticsAPIContext |
createFromFile(File configFile)
Creates a new RoboticsAPIContext out of the given config file. |
|
static RoboticsAPIContext |
createFromResource(Class<?> applicationContext,
String resourceName)
Creates a new RoboticsAPIContext out of the given configuration file. |
|
static RoboticsAPIContext |
createFromResource(String resourceName)
Creates a new RoboticsAPIContext out of the given configuration file. |
|
static RoboticsAPIContext |
createFromURL(Class<?> applicationContext,
URL configURL)
Creates a new RoboticsAPIContext out of the given config URL. |
|
Object |
createInstance(String fqcn,
Class<?>[] types,
Object... parameters)
Creates an instance of the given class. |
|
void |
dispose()
Disposes this context and all included resources. |
|
void |
dumpDevices()
Debug Routine for displaying the installed devices from all controllers. |
|
void |
finalizeObject()
Do finalization (cleanup) actions here. |
|
Class<?> |
getApplicationClass()
Returns the application context from which the context was created. |
|
URL |
getConfigurationFile()
Returns the configuration file to which this context is bound. |
|
Controller |
getController(String controllerName)
Gets the controller with the specified name. |
|
IControllerInitializeBehaviour |
getControllerInitializeBehavior()
Gets the initialization behavior of the controller. |
|
Collection<Controller> |
getControllers()
Returns the controllers loaded in this context. |
|
Controller |
getDefaultController()
Returns the first available controller or throws an exception if none is found. |
|
IDeviceFactory |
getDeviceFactory()
Gets the device factory of this context. |
|
Device |
getDeviceFromName(String deviceName)
Gets the device with the given name from the default controller. |
|
Device |
getDeviceFromName(String controllerName,
String deviceName)
Gets the device with the given name on the given controller. |
|
|
getDeviceFromType(Class<T> deviceClass)
Gets the first device with the given type from the default controller. |
|
|
getEngine(Class<T> clazz)
Gets the engine of the given type, if available. |
|
Map<String,com.kuka.common.ParameterSet> |
getInvalidControllers()
Gets the controllers which are invalid due to an initialization error. |
|
Iterable<com.kuka.common.ParameterSet> |
getInvalidEngines()
Gets the engines which are invalid due to an initialization error. |
|
ISyncManager |
getSyncManager()
Gets the sync manager of this context. |
|
void |
initialize()
Initializes this RoboticsAPIContext. |
|
boolean |
isInitialized()
Indicates if this context is initialized. |
|
Class<?> |
loadClass(String className)
Loads a class through a given context. |
|
protected Controller |
loadControllers(Iterable<com.kuka.common.ParameterSet> descriptions,
Map<String,Controller> controllers,
Map<String,com.kuka.common.ParameterSet> invalidControllers)
Loads all controllers from the parameter set descriptions. |
|
void |
registerEngine(IEngine engine)
Registers engine programmatically. |
|
static void |
removeContextListener(IContextListener listener)
Unregisters a listener from context events. |
|
URL |
resolve(String resourceName)
Resolves a resource within the system. |
|
protected void |
setFirstController(Controller controller)
sets the first controller. |
|
String |
toString()
|
|
|
tryGetEngine(Class<T> clazz)
Gets the engine of the given type. |
|
URL |
tryResolve(String resourceName)
Resolves a resource within the system. |
|
static void |
useGracefulInitialization(boolean value)
If set to true, this flag indicates if the context initialization will continue even if a engine or controller was not created. |
|
static boolean |
usingGracefulInitialization()
Gets the flag which indicates if graceful initialization is activated. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_FILE_NAME
protected final Map<String,Controller> _controllers
| Constructor Detail |
|---|
protected RoboticsAPIContext(Class<?> applicationContext,
URL configFile)
applicationContext - The application context. Can be null.configFile - The configuration file. Can be null.| Method Detail |
|---|
public static void useGracefulInitialization(boolean value)
value - The flag for the graceful initialization.public static boolean usingGracefulInitialization()
useGracefulInitialization(boolean)public static void addContextListener(IContextListener listener)
listener - The listener.public static void removeContextListener(IContextListener listener)
listener - The listener.protected void setFirstController(Controller controller)
controller - the first controller to set.
protected Controller loadControllers(Iterable<com.kuka.common.ParameterSet> descriptions,
Map<String,Controller> controllers,
Map<String,com.kuka.common.ParameterSet> invalidControllers)
descriptions - The set of descriptions. The "Class"-Attribute describes the type of the controller, the "Name"
attribute the name.controllers - The map in which the created controllers should get added.invalidControllers - The map in which invalid controllers should get added (if graceful initialization is on).
protected final Controller createController(com.kuka.common.ParameterSet description)
description - The controller description. The "Class"-Attribute describes the type of the controller, the "Name"
attribute the name.
public void registerEngine(IEngine engine)
If engine with the same type is already registered it will be replaced with the specified engine.
engine - engine to register.public URL getConfigurationFile()
public String toString()
toString in class Object
public Device getDeviceFromName(String controllerName,
String deviceName)
controllerName - The controller name.deviceName - The name of the device.
public Device getDeviceFromName(String deviceName)
Devices with the same name on different controllers are not handled by this method. This method just returns the first found device with the given name.
This method is a convenience method for the call deviceFromType(null, deviceName).
deviceName - The name of the device.
RequestedResourceNotAvailable - if device with the specified name does not exists.public <T extends Device> T getDeviceFromType(Class<T> deviceClass)
Devices with the same type on different controllers are not handled by this method. This method just returns the first found device with the given type.
T - The type of the device.deviceClass - The device class.
IllegalArgumentException - if device of the specified type does not exists.public Collection<Controller> getControllers()
public Controller getController(String controllerName)
controllerName - The name of the controller
public boolean containsController(String name)
name - The name of the controller.
public Controller getDefaultController()
public Class<?> getApplicationClass()
public Map<String,com.kuka.common.ParameterSet> getInvalidControllers()
public Iterable<com.kuka.common.ParameterSet> getInvalidEngines()
public ISyncManager getSyncManager()
public IDeviceFactory getDeviceFactory()
public <T extends IEngine> boolean containsEngine(Class<T> clazz)
T - The type of the engine.clazz - The type of the engine.
public <T extends IEngine> T getEngine(Class<T> clazz)
T - The type of the engine.clazz - The type of the engine.
null.
IllegalArgumentException - if clazz is null, or engine of the requested type not foundpublic <T extends IEngine> T tryGetEngine(Class<T> clazz)
T - The type of the engine.clazz - The type of the engine.
null if no such engine could be found.
IllegalArgumentException - if clazz is nullpublic boolean isInitialized()
public void initialize()
public Class<?> loadClass(String className)
className - The name of the class.
public Object createInstance(String fqcn,
Class<?>[] types,
Object... parameters)
fqcn - The full qualified class name.types - The classes the are needed by the constructor.parameters - The parameters for the constructor.
public URL resolve(String resourceName)
resourceName - The name of the resource.
public URL tryResolve(String resourceName)
resourceName - The name of the resource.
public void finalizeObject()
IFinalizableObject
finalizeObject in interface IFinalizableObjectpublic void dispose()
public static RoboticsAPIContext createDefaultContext()
public static RoboticsAPIContext create()
public static RoboticsAPIContext create(Class<?> applicationContext)
applicationContext - The application context.
public static RoboticsAPIContext createFromResource(String resourceName)
resourceName - The resource file. null is not allowed.
public static RoboticsAPIContext createFromResource(Class<?> applicationContext,
String resourceName)
applicationContext - The application context.resourceName - The resource file. null is not allowed.
public static RoboticsAPIContext createFromFile(File configFile)
configFile - The config file. null is not allowed.
public static RoboticsAPIContext createFromFile(Class<?> applicationContext,
File configFile)
applicationContext - The application context.configFile - The config file. null is not allowed.
public static RoboticsAPIContext createFromURL(Class<?> applicationContext,
URL configURL)
applicationContext - The application context.configURL - The URL to the config file. null is not allowed.
public IControllerInitializeBehaviour getControllerInitializeBehavior()
public void dumpDevices()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||