Research Article
A Distributed Relation Detection Approach in the Internet of Things
Algorithm 2
Relation detection algorithm.
Function: sendAttributeInterval(String attributeID, Data value, Relation r, Timestamp t) | (1) if attributeID r.attributes then | (2) if events.get(attributeID) ≠ then | (3) Interval interval = events.get(attributeID) | (4) interval.endTime = t | (5) send Info(r.ID, attributeID, interval) | (6) end | (7) Interval interval = (value, t, ) | (8) events.get(attributeID).add(interval) | (9) end | Function: receiveInterval(Interval , NodeID , Relation r) | (1) | (2) if .size=1 then | (3) updatedQueue.add() | (4) end | (5) while updatedQueues ≠ do | (6) foreach updatedQueues do | (7) if then | (8) | (9) for = 1 to do | (10) | (11) if then | (12) newUpdatedQueues.add(j) | (13) end | (14) if then | (15) newUpdatedQueues.add(i) | (16) end | (17) end | (18) end | (19) endfch | (20) foreach newUpdatedQueues do | (21) .dequeue(); | (22) endfch | (23) updatedQueues = newUpdatedQueues | (24) end | (25) if ( then | (26) if exists in () then | (27) if parent then | (28) send all ( to parent | (29) else | (30) relation is detected and recorded | (31) end | (32) end | (33) end |
|