Search in sources :

Example 1 with LcnAddrGrp

use of org.openhab.binding.lcn.common.LcnAddrGrp in project openhab1-addons by openhab.

the class Connection method update.

/** Must be called periodically to keep the inner logic active. */
void update() {
    long currTime = System.nanoTime();
    // Reconnect logic
    if (this.reconnectTimestamp != 0 && currTime >= this.reconnectTimestamp) {
        this.beginConnect();
        this.reconnectTimestamp = 0;
    } else {
        if (this.isChannelConnected()) {
            // Keep-alive / ping logic
            if (currTime - this.lastPingTimeStamp > PING_INTERVAL_MSEC * 1000000L) {
                this.queue(PckGenerator.ping(++this.pingCounter));
                this.lastPingTimeStamp = currTime;
            }
            // Segment scan logic
            if (this.statusSegmentScan.shouldSendNextRequest(this.sets.getTimeout(), currTime)) {
                this.queue(new LcnAddrGrp(3, 3), false, PckGenerator.segmentCouplerScan());
                this.statusSegmentScan.onRequestSent(currTime);
            } else if (this.statusSegmentScan.isFailed(this.sets.getTimeout(), currTime)) {
                // Give up. Probably no segments available.
                this.setLocalSegId(0);
            }
        }
        // LcnModInfo logic
        this.callback.updateItems(this);
        if (this.isReady()) {
            for (Map.Entry<LcnAddrMod, ModInfo> entry : this.modData.entrySet()) {
                entry.getValue().update(this, this.sets.getTimeout(), currTime);
            }
        }
    }
}
Also used : LcnAddrGrp(org.openhab.binding.lcn.common.LcnAddrGrp) HashMap(java.util.HashMap) Map(java.util.Map) LcnAddrMod(org.openhab.binding.lcn.common.LcnAddrMod)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 LcnAddrGrp (org.openhab.binding.lcn.common.LcnAddrGrp)1 LcnAddrMod (org.openhab.binding.lcn.common.LcnAddrMod)1