@Override public ArrayList<AlarmDecoderBindingConfig> getConfigurations( ADMsgType mt, String addr, String feature) { HashMap<String, ArrayList<AlarmDecoderBindingConfig>> a2c = m_itemMap.get(mt.getValue()); if (addr != null) { ArrayList<AlarmDecoderBindingConfig> al = a2c.get(addr); return (al == null ? new ArrayList<AlarmDecoderBindingConfig>() : al); } else { ArrayList<AlarmDecoderBindingConfig> al = new ArrayList<AlarmDecoderBindingConfig>(); for (Entry<String, ArrayList<AlarmDecoderBindingConfig>> a : a2c.entrySet()) { if (feature == null) { al.addAll(a.getValue()); } else { for (AlarmDecoderBindingConfig cf : a.getValue()) { al.add(cf); } } } return (al); } }
/** {@inheritDoc} */ @Override public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException { super.processBindingConfiguration(context, item, bindingConfig); HashMap<String, String> params = new HashMap<String, String>(); String[] parts = s_parseConfigString(item.getName(), bindingConfig, params); AlarmDecoderBindingConfig bc = null; if (parts[0].equals("SEND")) { // binding for sending commands if (!(parts.length == 2)) { throw new BindingConfigParseException("invalid SEND item config: " + bindingConfig); } bc = new AlarmDecoderBindingConfig(item, params); } else { // binding for receiving messages ADMsgType mt = ADMsgType.s_fromString(parts[0]); HashMap<String, ArrayList<AlarmDecoderBindingConfig>> addrToItemsMap = m_itemMap.get(mt.getValue()); ArrayList<AlarmDecoderBindingConfig> bcl = addrToItemsMap.get(parts[1]); if (bcl == null) { // don't have this address mapped to anything yet, start a new item list bcl = new ArrayList<AlarmDecoderBindingConfig>(); addrToItemsMap.put(parts[1], bcl); } else { // without this line a new binding configuration is entered whenever // the .items file is edited removeExisting(bcl, item); } bc = new AlarmDecoderBindingConfig(item, mt, parts[1], parts[2], params); bcl.add(bc); } addBindingConfig(item, bc); m_itemsToConfig.put(item.getName(), bc); logger.trace( "processing item \"{}\" read from .items file with cfg string {}", item.getName(), bindingConfig); }