@Override public void init() throws InitializationException, InterruptedException { if (!initialized) { try { registryTransformerRegistry = new SynchronizableRegistryImpl<>(); registryTransformerRegistry.setName("registryTransformers"); handleJPArguments(); rsbConnection.init(); initialized = true; } catch (JPValidationException | JPNotAvailableException | CouldNotPerformException ex) { throw new InitializationException(SkeletonMergingController.class, ex); } } }
public UnitProbabilityCollection getUnitProbabilities(PointingRay3DFloatDistributionCollection pointingRays) throws CouldNotPerformException { UnitProbabilityCollection.Builder collectionBuilder = UnitProbabilityCollection.newBuilder(); //TODO: Invert this here! first iterate the distributions, then the objects! collectionBuilder.addAllElement(selectedObjectRegistry.getEntries().stream() .map( entry -> pointingRays.getElementList().stream() .map(rayDist -> getUnitProbability(entry, rayDist)) .max((u1, u2) -> Float.compare(u1.getProbability(), u2.getProbability()))) .filter(u -> u.isPresent() && u.get().getProbability() >= threshold) .map(u -> u.get()) .collect(Collectors.toList())); return collectionBuilder.build(); }
public AbstractUnitSelector(double threshold) throws InstantiationException { this.threshold = threshold; try { this.selectedObjectRegistry = new SynchronizableRegistryImpl<>(); } catch (InstantiationException ex) { throw new InstantiationException(this, ex); } }
/** * {@inheritDoc} * * @param event {@inheritDoc} */ @Override public void handleEvent(final Event event) { LOGGER.trace(event.toString()); if ((event.getData() instanceof UnitProbabilityCollection)) { UnitProbabilityCollection collection = (UnitProbabilityCollection) event.getData(); collection.getElementList().stream().filter(x -> x.getProbability() >= threshold).forEach(x -> { try { if (controllableObjectRegistry.contains(x.getId())) { try { if (controllableObjectRegistry.get(x.getId()).switchPowerState()) { LOGGER.info("Switched power state of unit " + controllableObjectRegistry.get(x.getId()).getConfig().getLabel() + " with id " + x.getId()); } else { LOGGER.trace("Did not switch power state of unit " + controllableObjectRegistry.get(x.getId()).getConfig().getLabel() + " with id " + x.getId()); } } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(ex, LOGGER, LogLevel.ERROR); } } } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Id of the UnitProbability is not set.", ex), LOGGER, LogLevel.WARN); } }); } }
if (scopeIdMap.containsKey(scope)) { LOGGER.trace("Using transformation for scope " + scope.toString() + " unit " + scopeIdMap.get(scope)); currentTransformer = registryTransformerRegistry.get(scopeIdMap.get(scope)); } else { LOGGER.trace("Using transformation for scope " + scope.toString() + " from file.");
registryTransformerRegistry.addObserver(this); } catch (NotAvailableException ex) { throw new CouldNotPerformException("Could not connect to the registry.", ex);
/** * {@inheritDoc} * * @throws InitializationException {@inheritDoc} * @throws InterruptedException {@inheritDoc} */ @Override public void init() throws InitializationException, InterruptedException { if (!initialized) { try { LOGGER.info("Initializing ControlController."); controllableObjectRegistry = new SynchronizableRegistryImpl<>(); registryFlags = JPService.getProperty(JPPscUnitFilterList.class).getValue(); LOGGER.info("Selected Control Registry flags: " + registryFlags.toString()); threshold = JPService.getProperty(JPControlThreshold.class).getValue(); LOGGER.info("Selected Control threshold: " + threshold); initializeRegistryConnection(); rsbConnection = new RSBConnection(this); rsbConnection.init(); initialized = true; } catch (JPNotAvailableException | CouldNotPerformException ex) { throw new InitializationException(ControlController.class, ex); } } }