/** * {@inheritDoc} * * @return {@inheritDoc} * @throws InitializationException {@inheritDoc} */ @Override protected RSBListener getInitializedListener() throws InitializationException { try { LOGGER.info("Initializing RSB Listener on scope: " + baseScope); if (JPService.getProperty(JPLocalInput.class).getValue()) { LOGGER.warn("RSB input set to socket and localhost."); return RSBFactoryImpl.getInstance().createSynchronizedListener(baseScope, getLocalConfig()); } else { return RSBFactoryImpl.getInstance().createSynchronizedListener(baseScope); } } catch (CouldNotPerformException | JPNotAvailableException ex) { throw new InitializationException(RSBConnection.class, ex); } }
/** * {@inheritDoc} * * @return {@inheritDoc} * @throws InitializationException {@inheritDoc} */ @Override protected RSBInformer<TrackedPostures3DFloat> getInitializedInformer() throws InitializationException { try { LOGGER.info("Initializing RSB Informer on scope: " + outScope); if (JPService.getProperty(JPLocalOutput.class).getValue()) { LOGGER.warn("RSB output set to socket and localhost."); return RSBFactoryImpl.getInstance().createSynchronizedInformer(outScope, TrackedPostures3DFloat.class, getLocalConfig()); } else { return RSBFactoryImpl.getInstance().createSynchronizedInformer(outScope, TrackedPostures3DFloat.class); } } catch (CouldNotPerformException | JPNotAvailableException ex) { throw new InitializationException(RSBConnection.class, ex); } }
public static synchronized RSBFactoryImpl getInstance() { if (instance == null) { instance = new RSBFactoryImpl(); } return instance; }
@Override public void init() throws InitializationException, InterruptedException { try { remoteServer = RSBFactoryImpl.getInstance().createSynchronizedRemoteServer(JPService.getProperty(JPAuthenticationScope.class).getValue(), RSBSharedConnectionConfig.getParticipantConfig()); serverWatchDog = new WatchDog(remoteServer, "AuthenticatorWatchDog"); } catch (JPNotAvailableException | CouldNotPerformException ex) { throw new InitializationException(this, ex); } }
server = RSBFactoryImpl.getInstance().createSynchronizedLocalServer(internalScope.concat(new rsb.Scope(rsb.Scope.COMPONENT_SEPARATOR).concat(SCOPE_SUFFIX_CONTROL)), internalParticipantConfig);
private void initRemoteServer(final rsb.Scope scope, final ParticipantConfig participantConfig) throws CouldNotPerformException { try { this.remoteServer = RSBFactoryImpl.getInstance().createSynchronizedRemoteServer(scope.concat(RSBCommunicationService.SCOPE_SUFFIX_CONTROL), participantConfig); this.remoteServerWatchDog = new WatchDog(remoteServer, "RSBRemoteServer[" + scope.concat(RSBCommunicationService.SCOPE_SUFFIX_CONTROL) + "]"); this.listenerWatchDog.addObserver((final Observable<WatchDog.ServiceState> source, WatchDog.ServiceState data1) -> { logger.debug("listener state update: " + data1.name()); // Sync data after service start. if (data1 == WatchDog.ServiceState.RUNNING) { remoteServerWatchDog.waitForServiceActivation(); requestData(); } }); } catch (RuntimeException | InstantiationException ex) { throw new CouldNotPerformException("Could not create RemoteServer on scope [" + scope + "]!", ex); } }
private void initListener(final rsb.Scope scope, final ParticipantConfig participantConfig) throws CouldNotPerformException { try { this.listener = RSBFactoryImpl.getInstance().createSynchronizedListener(scope.concat(RSBCommunicationService.SCOPE_SUFFIX_STATUS), participantConfig); this.listenerWatchDog = new WatchDog(listener, "RSBListener[" + scope.concat(RSBCommunicationService.SCOPE_SUFFIX_STATUS) + "]"); } catch (InstantiationException ex) { throw new CouldNotPerformException("Could not create Listener on scope [" + scope + "]!", ex); } }
/** * {@inheritDoc} * * @return {@inheritDoc} * @throws InitializationException {@inheritDoc} */ @Override protected RSBInformer<PointingRay3DFloatDistributionCollection> getInitializedInformer() throws InitializationException { try { Scope outScope = JPService.getProperty(JPPSCBaseScope.class).getValue().concat(JPService.getProperty(JPRayScope.class).getValue()); LOGGER.info("Initializing RSB Informer on scope: " + outScope); if (JPService.getProperty(JPLocalOutput.class).getValue()) { LOGGER.warn("RSB output set to socket and localhost."); return RSBFactoryImpl.getInstance().createSynchronizedInformer(outScope, PointingRay3DFloatDistributionCollection.class, getLocalConfig()); } else { return RSBFactoryImpl.getInstance().createSynchronizedInformer(outScope, PointingRay3DFloatDistributionCollection.class); } } catch (CouldNotPerformException | JPNotAvailableException ex) { throw new InitializationException(RSBConnection.class, ex); } }
/** * {@inheritDoc} * * @return {@inheritDoc} * @throws InitializationException {@inheritDoc} */ @Override protected RSBListener getInitializedListener() throws InitializationException { try { Scope inScope = JPService.getProperty(JPPSCBaseScope.class).getValue().concat(JPService.getProperty(JPRayScope.class).getValue()); LOGGER.info("Initializing RSB Listener on scope: " + inScope); if (JPService.getProperty(JPLocalInput.class).getValue()) { return RSBFactoryImpl.getInstance().createSynchronizedListener(inScope, getLocalConfig()); } else { return RSBFactoryImpl.getInstance().createSynchronizedListener(inScope); } } catch (CouldNotPerformException | JPNotAvailableException ex) { throw new InitializationException(RSBConnection.class, ex); } }
/** * Constructor initiates the observation of the input unitRemote to detect the state values and send it to the ontology server. * * @param unitRemote contains the state data, which should be observed. * @throws InstantiationException is thrown in case the observation could not be initiated, because at least one component failed. */ public StateObservation(final UnitRemote unitRemote) throws InstantiationException { try { this.unitType = unitRemote.getUnitType(); this.rsbInformer = RSBFactoryImpl.getInstance().createSynchronizedInformer(OntConfig.getOntologyRsbScope(), OntologyChange.class); // this.stopwatch = new Stopwatch(); this.unitRemoteId = unitRemote.getId().toString(); this.connectionPhase = new ConnectionPhase(unitRemote); this.dateFormat = new SimpleDateFormat(OntConfig.DATE_TIME, Locale.getDefault()); createAndAddObserver(unitRemote); } catch (CouldNotPerformException ex) { throw new InstantiationException(this, ex); } }
/** * {@inheritDoc} * * @return {@inheritDoc} * @throws InitializationException {@inheritDoc} */ @Override protected RSBListener getInitializedListener() throws InitializationException { try { Scope inScope = JPService.getProperty(JPPSCBaseScope.class).getValue().concat(JPService.getProperty(JPPostureScope.class).getValue()); LOGGER.info("Initializing RSB Listener on scope: " + inScope); if (JPService.getProperty(JPLocalInput.class).getValue()) { LOGGER.warn("RSB input set to socket and localhost."); return RSBFactoryImpl.getInstance().createSynchronizedListener(inScope, getLocalConfig()); } else { return RSBFactoryImpl.getInstance().createSynchronizedListener(inScope); } } catch (CouldNotPerformException | JPNotAvailableException ex) { throw new InitializationException(RSBConnection.class, ex); } }
/** * {@inheritDoc} * * @return {@inheritDoc} * @throws InitializationException {@inheritDoc} */ @Override protected RSBInformer<UnitProbabilityCollection> getInitializedInformer() throws InitializationException { try { Scope outScope = JPService.getProperty(JPPSCBaseScope.class).getValue().concat(JPService.getProperty(JPSelectedUnitScope.class).getValue()); LOGGER.info("Initializing RSB Informer on scope: " + outScope); if (JPService.getProperty(JPLocalOutput.class).getValue()) { LOGGER.warn("RSB output set to socket and localhost."); return RSBFactoryImpl.getInstance().createSynchronizedInformer(outScope, UnitProbabilityCollection.class, getLocalConfig()); } else { return RSBFactoryImpl.getInstance().createSynchronizedInformer(outScope, UnitProbabilityCollection.class); } } catch (JPNotAvailableException | CouldNotPerformException ex) { throw new InitializationException(RSBConnection.class, ex); } }
/** * {@inheritDoc} * * @return {@inheritDoc} * @throws InitializationException {@inheritDoc} */ @Override protected RSBListener getInitializedListener() throws InitializationException { try { Scope selectedUnitScope = JPService.getProperty(JPPSCBaseScope.class).getValue().concat(JPService.getProperty(JPSelectedUnitScope.class).getValue()); LOGGER.info("Initializing RSB Selected Unit Listener on scope: " + selectedUnitScope); if (JPService.getProperty(JPLocalInput.class).getValue()) { LOGGER.warn("RSB input set to socket and localhost."); return RSBFactoryImpl.getInstance().createSynchronizedListener(selectedUnitScope, getLocalConfig()); } else { return RSBFactoryImpl.getInstance().createSynchronizedListener(selectedUnitScope); } } catch (CouldNotPerformException | JPNotAvailableException ex) { throw new InitializationException(RSBConnection.class, ex); } }
private void initRsb() throws CouldNotPerformException, InterruptedException { final RSBListener rsbListener = RSBFactoryImpl.getInstance().createSynchronizedListener(OntConfig.getOntologyRsbScope()); rsbListener.activate(); rsbListener.addHandler(event -> { try { ONTOLOGY_CHANGE_OBSERVABLE.notifyObservers((OntologyChange) event.getData()); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(ex, LOGGER, LogLevel.ERROR); } }, false); }
public SoundScapeApp() throws CouldNotPerformException, InterruptedException { super(SoundScapeApp.class); logger.debug("Creating sound scape app with scope [" + themeScope.toString() + "]!"); this.listener = RSBFactoryImpl.getInstance().createSynchronizedListener(themeScope, RSBSharedConnectionConfig.getParticipantConfig()); this.listenerWatchDog = new WatchDog(listener, "RSBListener[" + themeScope.concat(RSBCommunicationService.SCOPE_SUFFIX_STATUS) + "]"); listener.addHandler((Event event) -> { logger.debug("Got data [" + event.getData() + "]"); if (event.getData() instanceof String) { try { controlAmbienAgents(SoundScape.valueOf(StringProcessor.transformToUpperCase((String) event.getData()))); } catch (CouldNotPerformException ex) { logger.error("Could not de/activate ambient color agents"); } catch (IllegalArgumentException ex) { logger.error("Unable to parse [" + event.getData() + "] as sound scape!"); } } }, false); }
@Override protected void postInit() throws InitializationException, InterruptedException { try { openhabCommandListener = RSBFactoryImpl.getInstance().createSynchronizedListener(SCOPE_OPENHAB_COMMAND); openhabUpdateListener = RSBFactoryImpl.getInstance().createSynchronizedListener(SCOPE_OPENHAB_UPDATE);