void addChannel(ChannelHandler channel, Object value, Collection<String> precedingChannels) { channels.put(channel.getChannelName(), channel); values.put(channel.getChannelName(), value); preceding.put(channel.getChannelName(), new HashSet<String>(precedingChannels)); for (String precedingChannel : precedingChannels) { Set<String> succeedingChannels = succeeding.get(precedingChannel); if (succeedingChannels == null) { succeedingChannels = new HashSet<String>(); succeeding.put(precedingChannel, succeedingChannels); } succeedingChannels.add(channel.getChannelName()); } if (precedingChannels.isEmpty()) { leafs.add(channel.getChannelName()); } }
@Override public void run() { for (Map.Entry<ChannelHandler, ChannelHandlerReadSubscription> entry : handlers.entrySet()) { ChannelHandler channelHandler = entry.getKey(); ChannelHandlerReadSubscription channelHandlerReadSubscription = entry.getValue(); channelHandler.removeReader(channelHandlerReadSubscription); } }
@Override public void run() { for (Map.Entry<ChannelHandler, ChannelHandlerWriteSubscription> entry : handlers.entrySet()) { ChannelHandler channelHandler = entry.getKey(); ChannelHandlerWriteSubscription channelHandlerWriteSubscription = entry.getValue(); channelHandler.removeWrite(channelHandlerWriteSubscription); } } });
private void scheduleNext() { for (Map.Entry<ChannelHandler, Object> entry : planner.nextChannels().entrySet()) { final String channelName = entry.getKey().getChannelName(); try { entry.getKey().write(entry.getValue(), new ChannelWriteCallback() { AtomicInteger counter = new AtomicInteger(); @Override public void channelWritten(Exception ex) { planner.removeChannel(channelName); // If there was an error, notify the exception // and don't schedule anything else if (ex != null) { exceptionHandler.handleException(ex); return; } // Notify only when the last channel was written if (planner.isDone()) { callback.run(); } else { scheduleNext(); } } }); } catch (RuntimeException ex) { exceptionHandler.handleException(ex); } } }
private void channelDetailsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_channelDetailsButtonActionPerformed try { ChannelHandler handler = PVManager.getDefaultDataSource().getChannels().get(pvName.getText()); if (handler != null) { Map<String, Object> properties = handler.getProperties(); StringBuilder builder = new StringBuilder(); builder.append("Channel properties:\n"); for (Map.Entry<String, Object> entry : properties.entrySet()) { String string = entry.getKey(); Object object = entry.getValue(); builder.append(string).append(" = ").append(object).append("\n"); } JOptionPane.showMessageDialog(this, builder.toString()); } } catch (RuntimeException e) { e.printStackTrace(); } }//GEN-LAST:event_channelDetailsButtonActionPerformed PVReader<?> pv;
@Override public void run() { for (Map.Entry<ChannelHandler, Collection<ChannelHandlerWriteSubscription>> entry : handlers.entrySet()) { ChannelHandler channelHandler = entry.getKey(); Collection<ChannelHandlerWriteSubscription> subscriptions = entry.getValue(); for (ChannelHandlerWriteSubscription subscription : subscriptions) { try { channelHandler.addWriter(subscription); } catch (Exception ex) { // If an error happens while adding the write subscription, // notify the appropriate handler subscription.getExceptionWriteFunction().writeValue(ex); } } } } });
@Override public void run() { for (Map.Entry<ChannelHandler, Collection<ChannelReadRecipe>> entry : handlersWithSubscriptions.entrySet()) { ChannelHandler channelHandler = entry.getKey(); Collection<ChannelReadRecipe> channelRecipes = entry.getValue(); for (ChannelReadRecipe channelRecipe : channelRecipes) { try { channelHandler.addReader(channelRecipe.getReadSubscription()); } catch(Exception ex) { // If an error happens while adding the read subscription, // notify the appropriate handler channelRecipe.getReadSubscription().getExceptionWriteFunction().writeValue(ex); } } } } });