private static boolean isRootLocation(final UnitConfig unitConfig, final Map<String, IdentifiableMessage<String, UnitConfig, UnitConfig.Builder>> locations) { // if this unit is not a location it can not be a root location if (unitConfig.getType() != UnitType.LOCATION) { return false; } // if no locations are available this location should be the root location if (locations.isEmpty()) { return true; } // is this unit a root location? return unitConfig.getLocationConfig().hasRoot() && unitConfig.getLocationConfig().getRoot(); }
@Override public StandbyState getStandbyState() throws NotAvailableException { try { return getData().getStandbyState(); } catch (CouldNotPerformException ex) { throw new NotAvailableException("StandbyState", ex); } }
@Override default PresenceState getPresenceState() throws NotAvailableException { try { return getData().getPresenceState(); } catch (CouldNotPerformException ex) { throw new NotAvailableException("PresenceState", ex); } }
@Override protected void execute() throws CouldNotPerformException, InterruptedException { logger.debug("Execute PartyLightTileFollowerApp[" + getLabel() + "]"); // verify if (!Registries.getLocationRegistry().getLocationConfigById(getConfig().getPlacementConfig().getLocationId()).getLocationConfig().getType().equals(LocationConfigType.LocationConfig.LocationType.TILE)) { throw new InvalidStateException("App location is not a tile!"); } new TileFollower().call(); }
private String getRootLocationId() throws CouldNotPerformException { for (UnitConfig location : locationRegistry.getMessages()) { if (location.getLocationConfig().getRoot()) { return location.getId(); } } throw new NotAvailableException("rootLocation"); } }
@Override public UnitConfig applyConfigUpdate(UnitConfig config) throws CouldNotPerformException, InterruptedException { UnitConfig unitConfig = super.applyConfigUpdate(config); serviceRemoteManager.applyConfigUpdate(unitConfig.getLocationConfig().getUnitIdList()); return unitConfig; }
private boolean parentHasChild(UnitConfig parent, UnitConfig child) { return parent.getLocationConfig().getChildIdList().stream().anyMatch((children) -> (children.equals(child.getId()))); } }
private UnitConfig generateDefaultRootLocation() { return UnitConfig.newBuilder() .setType(UnitType.LOCATION) .setLabel(DEFAULT_ROOT_LOCATION_NAME) .setLocationConfig(LocationConfig.newBuilder() .setType(LocationType.ZONE) .build()) .setPlacementConfig(PlacementConfig.newBuilder() .setShape(Shape.newBuilder() .addFloor(Vec3DDouble.newBuilder().setX(0).setY(0).setZ(0).build()) .addFloor(Vec3DDouble.newBuilder().setX(1).setY(0).setZ(0).build()) .addFloor(Vec3DDouble.newBuilder().setX(1).setY(1).setZ(0).build()) .addFloor(Vec3DDouble.newBuilder().setX(0).setY(1).setZ(0).build()) .build()) .build()) .build(); } }
@Override public void activate() throws CouldNotPerformException, InterruptedException { if (locationDataObserver == null) { throw new NotInitializedException(this); } active = true; locationDataProvider.addDataObserver(locationDataObserver); // start initial timeout presenceTimeout.start(); updateMotionState(locationDataProvider.getData().getMotionState()); }
@Override public void update(Observable<PresenceState> source, PresenceState data) throws Exception { try (ClosableDataBuilder<LocationData.Builder> dataBuilder = getDataBuilder(this)) { LOGGER.debug("Set " + this + " presence to [" + data.getValue() + "]"); dataBuilder.getInternalBuilder().setPresenceState(data); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not apply presense state change!", ex); } } });
default UnitConfig getRootLocationConfig() throws CouldNotPerformException, NotAvailableException { for (UnitConfig locationConfig : getUnitConfigs(UnitType.LOCATION)) { if (locationConfig.getLocationConfig().hasRoot() && locationConfig.getLocationConfig().getRoot()) { return locationConfig; } } throw new NotAvailableException("rootlocation"); }
public PartyLightTileFollowerApp() throws InstantiationException, InterruptedException { super(PartyLightTileFollowerApp.class); try { Registries.getLocationRegistry().waitForData(); Registries.getUnitRegistry().waitForData(); this.locationRemoteMap = new HashMap<>(); // init tile remotes for (final UnitConfig locationUnitConfig : Registries.getLocationRegistry().getLocationConfigs()) { if (!locationUnitConfig.getLocationConfig().getType().equals(LocationConfigType.LocationConfig.LocationType.TILE)) { continue; } locationRemoteMap.put(locationUnitConfig.getId(), Units.getUnit(locationUnitConfig, false, Units.LOCATION)); } } catch (CouldNotPerformException ex) { throw new InstantiationException(this, ex); } }
private List<RdfTriple> getInsertHasUnitRelation(final UnitConfig unitConfig) { final List<RdfTriple> triples = new ArrayList<>(); // get all unit IDs, which can be found in the unit location for (final String unitId : unitConfig.getLocationConfig().getUnitIdList()) { triples.add(new RdfTriple(unitConfig.getId(), OntProp.UNIT.getName(), unitId)); } return triples; }
private List<RdfTriple> getInsertSubLocationRelation(final UnitConfig unitConfig) { final List<RdfTriple> triples = new ArrayList<>(); // get all child IDs of the unit location for (final String childId : unitConfig.getLocationConfig().getChildIdList()) { triples.add(new RdfTriple(unitConfig.getId(), OntProp.SUB_LOCATION.getName(), childId)); } return triples; }
public PersonLightProviderAgent() throws InstantiationException, CouldNotPerformException, InterruptedException { super(PersonLightProviderAgent.class); locationObserver = (final Observable<LocationDataType.LocationData> source, LocationDataType.LocationData data) -> { try { notifyPresenceStateChanged(data.getPresenceState()); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not notify presence state change!", ex), logger); } }; }
@Override public StandbyState getStandbyState() throws NotAvailableException { try { return this.getData().getStandbyState(); } catch (CouldNotPerformException ex) { throw new NotAvailableException("StandbyState", ex); } } }
/** * {@inheritDoc} * * @throws org.openbase.jul.exception.CouldNotPerformException {@inheritDoc} * @throws org.openbase.jul.exception.NotAvailableException {@inheritDoc} */ @Override public UnitConfig getRootLocationConfig() throws CouldNotPerformException, NotAvailableException { for (UnitConfig locationConfig : getLocationConfigs()) { if (locationConfig.getLocationConfig().hasRoot() && locationConfig.getLocationConfig().getRoot()) { return locationConfig; } } throw new NotAvailableException("rootlocation"); }
@Override public synchronized UnitConfig applyConfigUpdate(final UnitConfig config) throws CouldNotPerformException, InterruptedException { UnitConfig unitConfig = super.applyConfigUpdate(config); serviceRemoteManager.applyConfigUpdate(unitConfig.getLocationConfig().getUnitIdList()); // if already active than update the current location state. if (isActive()) { updateUnitData(); } return unitConfig; }
private void loopTestTopDown(final UnitConfig locationConfig, ProtoBufRegistry<String, UnitConfig, UnitConfig.Builder> registry, List<String> processedLocations) throws InvalidStateException, CouldNotPerformException { markAsProcessed(locationConfig, processedLocations); for (String locationId : locationConfig.getLocationConfig().getChildIdList()) { loopTestTopDown(registry.get(locationId).getMessage(), registry, processedLocations); } }
/** * {@inheritDoc} * * @throws org.openbase.jul.exception.CouldNotPerformException {@inheritDoc} * @throws org.openbase.jul.exception.NotAvailableException {@inheritDoc} */ @Override public UnitConfig getRootLocationConfig() throws CouldNotPerformException, NotAvailableException { validateData(); for (UnitConfig locationConfig : locationUnitConfigRemoteRegistry.getMessages()) { if (locationConfig.getLocationConfig().hasRoot() && locationConfig.getLocationConfig().getRoot()) { return locationConfig; } } throw new NotAvailableException("rootlocation"); }