Examples of ItemRegistry


Examples of org.openhab.core.items.ItemRegistry

   *
   * @param args array which contains the arguments for the update command
   * @param console the console for printing messages for the user
   */
  static public void handleUpdate(String[] args, Console console) {
    ItemRegistry registry = (ItemRegistry) ConsoleActivator.itemRegistryTracker.getService();
    EventPublisher publisher = (EventPublisher) ConsoleActivator.eventPublisherTracker.getService();
    if(publisher!=null) {
      if(registry!=null) {
        if(args.length>0) {
          String itemName = args[0];
          try {
            Item item = registry.getItemByPattern(itemName);
            if(args.length>1) {
              String stateName = args[1];
              State state = TypeParser.parseState(item.getAcceptedDataTypes(), stateName);
              if(state!=null) {
                publisher.postUpdate(item.getName(), state);
View Full Code Here

Examples of org.openhab.core.items.ItemRegistry

   *
   * @param args array which contains the arguments for the send command
   * @param console the console for printing messages for the user
   */
  static public void handleSend(String[] args, Console console) {
    ItemRegistry registry = (ItemRegistry) ConsoleActivator.itemRegistryTracker.getService();
    EventPublisher publisher = (EventPublisher) ConsoleActivator.eventPublisherTracker.getService();
    if(publisher!=null) {
      if(registry!=null) {
        if(args.length>0) {
          String itemName = args[0];
          try {
            Item item = registry.getItemByPattern(itemName);
            if(args.length>1) {
              String commandName = args[1];
              Command command = TypeParser.parseCommand(item.getAcceptedCommandTypes(), commandName);
              if(command!=null) {
                publisher.sendCommand(itemName, command);
View Full Code Here

Examples of org.openhab.core.items.ItemRegistry

   *
   * @param args array which contains the arguments for the items command
   * @param console the console for printing messages for the user
   */
  static public void handleItems(String[] args, Console console) {
    ItemRegistry registry = (ItemRegistry) ConsoleActivator.itemRegistryTracker.getService();
    if(registry!=null) {
      String pattern = (args.length == 0) ? "*" : args[0];
      Collection<Item> items = registry.getItems(pattern);
      if(items.size()>0) {
        for(Item item : items) {
          console.println(item.toString());
        }
      } else {
View Full Code Here

Examples of org.openhab.core.items.ItemRegistry

   *
   * @param args array which contains the arguments for the status command
   * @param console the console for printing messages for the user
   */
  static public void handleStatus(String[] args, Console console) {
    ItemRegistry registry = (ItemRegistry) ConsoleActivator.itemRegistryTracker.getService();
    if(registry!=null) {
      if(args.length>0) {
        String itemName = args[0];
        try {
          Item item = registry.getItemByPattern(itemName);
          console.println(item.getState().toString());
        } catch (ItemNotFoundException e) {
          console.println("Error: Item '" + itemName + "' does not exist.");
        } catch (ItemNotUniqueException e) {
          console.print("Error: Multiple items match this pattern: ");
View Full Code Here

Examples of org.openhab.core.items.ItemRegistry

  static public void handleSay(String[] args, Console console) {
    StringBuilder msg = new StringBuilder();
    for(String word : args) {
      if(word.startsWith("%") && word.endsWith("%") && word.length()>2) {
        String itemName = word.substring(1, word.length()-1);
        ItemRegistry registry = (ItemRegistry) ConsoleActivator.itemRegistryTracker.getService();
        if(registry!=null) {
          try {
            Item item = registry.getItemByPattern(itemName);
            msg.append(item.getState().toString());
          } catch (ItemNotFoundException e) {
            console.println("Error: Item '" + itemName + "' does not exist.");
          } catch (ItemNotUniqueException e) {
            console.print("Error: Multiple items match this pattern: ");
View Full Code Here

Examples of org.openhab.core.items.ItemRegistry

  }

  private List<IEObjectDescription> createItemFeatures(ResourceSet rs) {
    IJvmTypeProvider provider = typeProviderFactory.findOrCreateTypeProvider(rs);
    List<IEObjectDescription> descriptions = new ArrayList<IEObjectDescription>();
    ItemRegistry itemRegistry = itemRegistryProvider.get();
    if(itemRegistry!=null) {
      for(Item item : itemRegistry.getItems()) {
        descriptions.add(EObjectDescription.create(item.getName(), provider.findTypeByName(item.getClass().getCanonicalName())));
      }
    }
    return descriptions;
  }
View Full Code Here

Examples of org.openhab.core.items.ItemRegistry

public class BusEvent {

  static private final Logger logger = LoggerFactory.getLogger(BusEvent.class);
 
  static public void sendCommand(String itemName, String commandString) {
    ItemRegistry registry = (ItemRegistry) RulesActivator.itemRegistryTracker.getService();
    EventPublisher publisher = (EventPublisher) RulesActivator.eventPublisherTracker.getService();
    if(publisher!=null && registry!=null) {
      try {
        Item item = registry.getItem(itemName);
        Command command = TypeParser.parseCommand(item.getAcceptedCommandTypes(), commandString);
        publisher.sendCommand(itemName, command);
      } catch (ItemNotFoundException e) {
        logger.warn("Item '" + itemName + "' does not exist.");
      }
View Full Code Here

Examples of org.openhab.core.items.ItemRegistry

      }
    }
  }

  static public void postUpdate(String itemName, String stateString) {
    ItemRegistry registry = (ItemRegistry) RulesActivator.itemRegistryTracker.getService();
    EventPublisher publisher = (EventPublisher) RulesActivator.eventPublisherTracker.getService();
    if(publisher!=null && registry!=null) {
      try {
        Item item = registry.getItem(itemName);
        State state = TypeParser.parseState(item.getAcceptedDataTypes(), stateString);
        publisher.postUpdate(itemName, state);
      } catch (ItemNotFoundException e) {
        logger.warn("Item '" + itemName + "' does not exist.");
      }
View Full Code Here

Examples of org.openhab.core.items.ItemRegistry

 
  @Override
  public void complete_ItemName(EObject model, RuleCall ruleCall,
      ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
    super.complete_ItemName(model, ruleCall, context, acceptor);
    ItemRegistry itemRegistry = RuleModelUIActivator.itemRegistryTracker.getService();
   
    for(Item item : itemRegistry.getItems()) {
      if(item.getName().startsWith(context.getPrefix())) {
        acceptor.accept(createCompletionProposal(item.getName(), context));
      }
    }
  }
View Full Code Here

Examples of org.openhab.core.items.ItemRegistry

  @Override
  public void complete_GroupItemRef(EObject model, RuleCall ruleCall,
      ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
    super.complete_GroupItemRef(model, ruleCall, context, acceptor);

    ItemRegistry registry = (ItemRegistry) UIActivator.itemRegistryTracker.getService();
    if(registry!=null) {
      for(Item item : registry.getItems(context.getPrefix() + "*")) {
        if(item instanceof GroupItem) {
          ICompletionProposal completionProposal = createCompletionProposal(item.getName(), context);
          acceptor.accept(completionProposal);
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.