Package org.openhab.model.rule.rules

Examples of org.openhab.model.rule.rules.ChangedEventTrigger


        State newState = (State) newType;
        State oldState = (State) oldType;
        for(Rule rule : rules) {
          for(EventTrigger t : rule.getEventtrigger()) {
            if (t instanceof ChangedEventTrigger) {
              ChangedEventTrigger ct = (ChangedEventTrigger) t;           
              if(ct.getItem().equals(item.getName())) {
                if(ct.getOldState()!=null) {
                  State triggerOldState = TypeParser.parseState(item.getAcceptedDataTypes(), ct.getOldState());
                  if(!oldState.equals(triggerOldState)) {
                    continue;
                  }               
                }
                if(ct.getNewState()!=null) {
                  State triggerNewState = TypeParser.parseState(item.getAcceptedDataTypes(), ct.getNewState());
                  if(!newState.equals(triggerNewState)) {
                    continue;
                  }               
                }
                result.add(rule);
              }
            }
          }
        }
      }
      break;
    case COMMAND: 
      if(newType instanceof Command) {
        Command command = (Command) newType;
        for(Rule rule : rules) {
          for(EventTrigger t : rule.getEventtrigger()) {
            if (t instanceof CommandEventTrigger) {
              CommandEventTrigger ct = (CommandEventTrigger) t;
              Command triggerCommand = TypeParser.parseCommand(item.getAcceptedCommandTypes(), ct.getCommand());
              if(ct.getItem().equals(item.getName()) &&
                  (triggerCommand==null || command.equals(triggerCommand))) {
                result.add(rule);
              }
            }
          }
View Full Code Here


          rules = new HashSet<Rule>();
          updateEventTriggeredRules.put(ueTrigger.getItem(), rules);
        }
        rules.add(rule);
      } else if(t instanceof ChangedEventTrigger) {
        ChangedEventTrigger ceTrigger = (ChangedEventTrigger) t;
        Set<Rule> rules = changedEventTriggeredRules.get(ceTrigger.getItem());
        if(rules==null) {
          rules = new HashSet<Rule>();
          changedEventTriggeredRules.put(ceTrigger.getItem(), rules);
        }
        rules.add(rule);
      } else if(t instanceof TimerTrigger) {
        timerEventTriggeredRules.add(rule);
        try {
View Full Code Here

TOP

Related Classes of org.openhab.model.rule.rules.ChangedEventTrigger

Copyright © 2018 www.massapicom. 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.