@Override public RXTXSerialPort getValue() { if(myTracker == null){ return null; } DynamixelController c = (DynamixelController)myTracker.getService(); if(c == null){ return null; } return c.getPort(); } }
@Override public boolean writeServiceConfig(AddOn addon, File file) throws Exception { Config config = myConfigAdapter.createConfig(addon); ConfigurationWriter<Config,File> writer = myWriterTracker.getService(); if(writer == null){ return false; } return writer.writeConfiguration(config, file); }
/** * Returns a global RobotManager. The RobotManager is retrieved from the * OSGi Service Registry. * @param context BundleContext for OSGi * @return global RobotManager */ public static RobotManager getRobotManager(BundleContext context){ if(context == null){ throw new NullPointerException(); } if(theManagerTracker == null){ theManagerTracker = new SingleServiceListener( RobotManager.class, context, null); theManagerTracker.start(); } RobotManager manager = theManagerTracker.getService(); if(manager == null){ RobotManager tmp = new RobotManager(context); context.registerService(RobotManager.class.getName(), tmp, null); manager = theManagerTracker.getService(); } if(manager == null){ throw new NullPointerException( "Unknown error registering and tracking RobotManager."); } return manager; } }