#593 Query on watch mechanism

Pun Mum Wed 7 Mar 2018

Hi All,

Please consider following example:

Say Haystack point is pt1 which is mapped to BACnet object AI1

watchSub with "watchDis = Watch1" and "lease = 30 min" for pt1 is used

Watch is created with watchId = Watch1, lease = 30 min Response data is: pt1 = 5

Changes in value of AI1: at watchSub i.e. min 0 = 5, at min 10 = 10, at min 20 = 20, at min 30 = 30, at min 40 = 5, at min 60 = 30, at min 70 = 25

Understanding:

  1. When watchPoll is called 1st time at min 30 for watch 1, response is:
    pt1, 30 // i.e. value at min 30

    Response does NOT return all changes in value of pt1 e.g. pt1 = 5 ,10, 20, 30

  2. When watchPoll is called 2nd time at min 60, response is empty grid because value at 1st watchPoll (at min 30) was 30 and value at min 60 is also 30. Hence, there is no change in value
  3. If watchPoll operation is not called in lease period, watch can be closed. Also, once watchPoll is received, lease period is renewed. In above example as 2nd watchPoll is received at min 60, watch will be active for next 30 min. If we don't receive watchPoll till min 90, then watch can be closed say at min 91.
  4. In above example, it is ok if latest data is fetched from BACnet device whenever watchPoll operation is executed. There is no need to continuously poll the value of AI1 or receive COV notificaiton from AI1.

Please let me know if there are any gaps in my understanding.

Thanks.

Brian Frank Wed 7 Mar 2018

Your understanding is correct.

The lease period determine how much time can elapse without a poll before the watch and its associated resources can be freed by the server.

Each poll returns the current entity if and only if its changed since the last poll.

The way I implement this in our software is to keep track of a global version counter. So each time a record changes, I increment this counter and each record keeps track of its version. Then all the watch need to do is keep track of the version counter of the last poll and can just iterate the records in its watched list. Its fast and memory efficient (vs keeping track of a queue on a per watch basis)

I would caution against your proposal in 4. In general I would keep the watchPoll separate from BACnet polls. There could be 100s of watches on a given point and they could all be polling at different frequencies. That is separate from how fast you could poll the underlying BACnet object.

What we do is just keep track of how many watches are on a given point. When it goes from zero to one we tell the underlying connector (BACnet, etc) to start polling/subscribe to the source data. Then when the watches go from one to zero we tell the connector to stop poll/unsubscribe from the source data

Login or Signup to reply.