Search in sources :

Example 1 with ModemDBEntry

use of org.openhab.binding.insteonplm.internal.driver.ModemDBEntry in project openhab1-addons by openhab.

the class InsteonPLMActiveBinding method getLinkInfo.

private String getLinkInfo(HashMap<InsteonAddress, ModemDBEntry> dbes, InsteonAddress a) {
    ModemDBEntry dbe = dbes.get(a);
    ArrayList<Byte> controls = dbe.getControls();
    ArrayList<Byte> responds = dbe.getRespondsTo();
    StringBuffer buf = new StringBuffer("the modem");
    if (!controls.isEmpty()) {
        buf.append(" controls groups [");
        buf.append(toGroupString(controls));
        buf.append("]");
    }
    if (!responds.isEmpty()) {
        if (!controls.isEmpty()) {
            buf.append(" and");
        }
        buf.append(" responds to groups [");
        buf.append(toGroupString(responds));
        buf.append("]");
    }
    return buf.toString();
}
Also used : ModemDBEntry(org.openhab.binding.insteonplm.internal.driver.ModemDBEntry)

Example 2 with ModemDBEntry

use of org.openhab.binding.insteonplm.internal.driver.ModemDBEntry in project openhab1-addons by openhab.

the class ModemDBBuilder method logModemDB.

private void logModemDB() {
    try {
        logger.debug("MDB ------- start of modem link records ------------------");
        HashMap<InsteonAddress, ModemDBEntry> dbes = m_port.getDriver().lockModemDBEntries();
        for (Entry<InsteonAddress, ModemDBEntry> db : dbes.entrySet()) {
            ArrayList<Msg> lrs = db.getValue().getLinkRecords();
            for (Msg m : lrs) {
                int recordFlags = m.getByte("RecordFlags") & 0xff;
                String ms = ((recordFlags & (0x1 << 6)) != 0) ? "CTRL" : "RESP";
                logger.debug("MDB {}: {} group: {} data1: {} data2: {} data3: {}", db.getKey(), ms, toHex(m.getByte("ALLLinkGroup")), toHex(m.getByte("LinkData1")), toHex(m.getByte("LinkData2")), toHex(m.getByte("LinkData2")));
            }
            logger.debug("MDB -----");
        }
        logger.debug("MDB ---------------- end of modem link records -----------");
    } catch (FieldException e) {
        logger.error("cannot access field:", e);
    } finally {
        m_port.getDriver().unlockModemDBEntries();
    }
}
Also used : Msg(org.openhab.binding.insteonplm.internal.message.Msg) FieldException(org.openhab.binding.insteonplm.internal.message.FieldException) ModemDBEntry(org.openhab.binding.insteonplm.internal.driver.ModemDBEntry)

Example 3 with ModemDBEntry

use of org.openhab.binding.insteonplm.internal.driver.ModemDBEntry in project openhab1-addons by openhab.

the class ModemDBBuilder method updateModemDB.

public void updateModemDB(InsteonAddress linkAddr, Port port, Msg m) {
    HashMap<InsteonAddress, ModemDBEntry> dbes = port.getDriver().lockModemDBEntries();
    ModemDBEntry dbe = dbes.get(linkAddr);
    if (dbe == null) {
        dbe = new ModemDBEntry(linkAddr);
        dbes.put(linkAddr, dbe);
    }
    dbe.setPort(port);
    if (m != null) {
        dbe.addLinkRecord(m);
        try {
            byte group = m.getByte("ALLLinkGroup");
            int recordFlags = m.getByte("RecordFlags") & 0xff;
            if ((recordFlags & (0x1 << 6)) != 0) {
                dbe.addControls(group);
            } else {
                dbe.addRespondsTo(group);
            }
        } catch (FieldException e) {
            logger.error("cannot access field:", e);
        }
    }
    port.getDriver().unlockModemDBEntries();
}
Also used : FieldException(org.openhab.binding.insteonplm.internal.message.FieldException) ModemDBEntry(org.openhab.binding.insteonplm.internal.driver.ModemDBEntry)

Example 4 with ModemDBEntry

use of org.openhab.binding.insteonplm.internal.driver.ModemDBEntry in project openhab1-addons by openhab.

the class InsteonPLMActiveBinding method checkIfInModemDatabase.

/**
     * Checks if a device is in the modem link database, and, if the database
     * is complete, logs a warning if the device is not present
     *
     * @param dev The device to search for in the modem database
     * @return number of devices in modem database
     */
private int checkIfInModemDatabase(InsteonDevice dev) {
    InsteonAddress addr = dev.getAddress();
    HashMap<InsteonAddress, ModemDBEntry> dbes = m_driver.lockModemDBEntries();
    if (dbes.containsKey(addr)) {
        if (!dev.hasModemDBEntry()) {
            logger.info("device {} found in the modem database and {}.", addr, getLinkInfo(dbes, addr));
            dev.setHasModemDBEntry(true);
        }
    } else {
        if (m_driver.isModemDBComplete() && !addr.isX10()) {
            logger.warn("device {} not found in the modem database. Did you forget to link?", addr);
        }
    }
    int ndev = dbes.size();
    m_driver.unlockModemDBEntries();
    return ndev;
}
Also used : InsteonAddress(org.openhab.binding.insteonplm.internal.device.InsteonAddress) ModemDBEntry(org.openhab.binding.insteonplm.internal.driver.ModemDBEntry)

Aggregations

ModemDBEntry (org.openhab.binding.insteonplm.internal.driver.ModemDBEntry)4 FieldException (org.openhab.binding.insteonplm.internal.message.FieldException)2 InsteonAddress (org.openhab.binding.insteonplm.internal.device.InsteonAddress)1 Msg (org.openhab.binding.insteonplm.internal.message.Msg)1