ONLYIFCONNECTED and ONLYIFUPTODATE

The ONLYIFCONNECTED and ONLYIFUPTODATE modifiers can be used on any sampling or calculation mode to retrieve bad data if the collector is not currently connected and sending data to the archiver. The bad data is not stored in the IHA file but is only returned in the query. If the collector reconnects and flushes data and you run the query again, the actual stored data is returned in the following situations:

  • Collector loses connection to the Archiver
  • Collector crashes
  • Collector compression is used and no value exceeds the deadband

Any data query will return the last known value repeated till the current time with the quality of data as good. But the information could have changed in the real world and has yet to reach the archiver.

Repeating the last known good value data can be misleading. Data should be returned as bad quality if no data is coming in from a collector.

The Data Archiver keeps track of the newest raw sample received for any tag for each collector. If no data is received for any tag, the collector is considered to be idle. If the collector is idle for more than 270 seconds, then either the data is heavily compressed or the collector is crashed or has lost connection. The collector idle time defaults to 270 seconds and this current setting appears in the dataarchiver.shw file. You can change the value using an SDK program. The setting applies to all collectors.

Use the ONLYIFUPTODATE modifier to return bad data from the time of the newest raw sample to the current time. However, if there is an unlikely chance that all tags are heavily compressed, then use the ONLYIFCONNECTED modifier. The difference in the behavior of the two modifiers is given in the following examples:

When you add an ONLYIFCONNECTED or ONLYIFUPTODATE modifier to the query, and the collector is disconnected from the archiver, bad values are returned from the time of the disconnect until the current time. Queries of data before the disconnect time are unaffected.

Note:
  • The ONLYIFCONNECTED and ONLYIFUPTODATE modifiers are applicable to tags that are collected by data collectors.
  • For raw by number, if the number of samples collected are greater or equal to the number of samples, bad data quality is not added.
  • For raw by time, if the endtime is less than maximum data received time, bad data quality is not added.
  • For raw by number backward, bad data quality is added at the beginning.
Example 1: Using ONLYIFCONNECTED to detect connection loss

To demonstrate the behavior of ONLYIFCONNECTED, you need to query data currently being collected.

  1. Configure the Simulation collector to collect any tag once per second with no compression. For example, collect the simulation RAMP tag.
  2. Let the collector run for at least 5 minutes of collection.
  3. Disconnect the collector but leave it running. In this test, the collector was disconnected at 20:55:00.
  4. After about 5 minutes, query the data without ONLYIFCONNECTED and the last known value repeated with good quality to the current time, even though the collector is not connected.
    set starttime='22-Aug-2012 20:53:00',endtime='now 
    select timestamp,value,quality
    from ihrawdata
    where tagname = RAMP and samplingmode=Interpolated and intervalmilliseconds=5s order by timestamp asc
    Time StampValueQuality
    8/22/2012 20:54:55166.666666666667100.0000000
    8/22/2012 20:55:000.000000000000100.0000000
    8/22/2012 20:55:05166.666666666667100.0000000
    8/22/2012 20:55:10 333.333333333333100.0000000
    8/22/2012 20:55:15 500.000000000000100.0000000
    8/22/2012 20:55:20 533.333333333333100.0000000
    8/22/2012 20:55:25 533.333333333333100.0000000
    8/22/2012 20:55:30533.333333333333100.0000000
    8/22/2012 20:55:35 533.333333333333100.0000000
  5. Run the query again with ONLYIFCONNECTED and the data is marked bad at the time of the collector disconnect:
    set starttime='22-Aug-2012 20:53:00',endtime='now 
    select timestamp,value,quality
    from ihrawdata
    where tagname = RAMP and samplingmode=Interpolated and intervalmilliseconds=5s and criteriastring=#onlyifconnect
    Time StampValueQuality
    8/22/2012 20:54:55166.666666666667100.0000000
    8/22/2012 20:55:000.000000000000100.0000000
    8/22/2012 20:55:05166.666666666667100.0000000
    8/22/2012 20:55:10 333.333333333333100.0000000
    8/22/2012 20:55:15 500.000000000000100.0000000
    8/22/2012 20:55:20 0.0000000000000.0000000
    8/22/2012 20:55:25 0.0000000000000.0000000
    8/22/2012 20:55:300.0000000000000.0000000
    8/22/2012 20:55:35 0.0000000000000.0000000
  6. Reconnect the collector and once the collector reconnects and flushes its buffered data run the query again with ONLYIFCONNECTED and the period of bad data is filled in with ramping values:
    Time StampValueQuality
    8/22/2012 20:54:55166.666666666667100.0000000
    8/22/2012 20:55:000.000000000000100.0000000
    8/22/2012 20:55:05166.666666666667100.0000000
    8/22/2012 20:55:10 333.333333333333100.0000000
    8/22/2012 20:55:15 500.000000000000100.0000000
    8/22/2012 20:55:20 569.696969985962100.0000000
    8/22/2012 20:55:25 615.151515960693100.0000000
    8/22/2012 20:55:30660.606061935425100.0000000
    8/22/2012 20:55:35 706.060606002808100.0000000
Example 2: Querying Compressed Data

If all tags for a collector are compressed, then the newest raw sample across all tags can easily be older than 270 seconds even when the collector is connected to archiver. It is unlikely in a real system that a collector will send 0 raw samples for 270 seconds, but it is possible.

  1. Use the simulation collector and collect the constant tag as 1 second polled with a small deadband such as 1. In the example below, the newest raw sample is at 17:27:31 and the current time is 5 minutes or more.
  2. Query the data as interpolated with a 5 second interval and no modifier.
    set starttime='23-Aug-2012 17:00:30',endtime='now,rowcount=0 
    select timestamp,value,quality
    from ihrawdata
    where tagname = CONSTANT and samplingmode=Interpolated and intervalmilliseconds=5s order by timestamp asc
    Time StampValueQuality
    8/23/20121 7:27:20500.000000000000100.0000000
    8/23/20121 7:27:25500.000000000000100.0000000
    8/23/20121 7:27:30 500.000000000000100.0000000
    8/23/20121 7:27:350.000000000000100.0000000
    8/23/20121 7:27:40 0.000000000000100.0000000
    Note: The newest sample is repeated to the current time
  3. Query with ONLYIFCONNECTED and you get the same results even when the newest raw sample is more than 270 seconds old. The data is old but the collector is currently connected.
    set starttime='23-Aug-2012 17:00:30',endtime='now,rowcount=0 
    select timestamp,value,quality
    from ihrawdata
    where tagname = CONSTANT and samplingmode=Interpolated and intervalmilliseconds=5s and criteriastring=#onlyifcon
    Time StampValueQuality
    8/23/20121 7:27:20500.000000000000100.0000000
    8/23/20121 7:27:25500.000000000000100.0000000
    8/23/20121 7:27:30 500.000000000000100.0000000
    8/23/20121 7:27:35500.000000000000100.0000000
    8/23/20121 7:27:40 500.000000000000100.0000000
  4. Query with ONLYIUPTODATE and the data is considered bad quality after the newest raw sample.
    set starttime='23-Aug-2012 17:00:30',endtime='now,rowcount=0 
    select timestamp,value,quality
    from ihrawdata
    where tagname = CONSTANT and samplingmode=Interpolated and intervalmilliseconds=5s and criteriastring=#onlyifupt
    Time StampValueQuality
    8/23/20121 7:27:20500.000000000000100.0000000
    8/23/20121 7:27:25500.000000000000100.0000000
    8/23/20121 7:27:30 500.000000000000100.0000000
    8/23/20121 7:27:350.0000000000000.0000000
    8/23/20121 7:27:40 0.0000000000000.0000000
Note: If your collector can possibly have no data for any tag due to compression, use ONLYIFCONNECTED. Otherwise, if you want to detect data being old due to collector crash or disconnect, then use ONLYIFUPTODATE and optionally adjust the collector idle time.
Anticipated Usage

Use the ONLYIFCONNECTED and ONLYIFUPTODATE modifiers so that your trend lines stop plotting when the collector loses connection.

Use the ONLYIFCONNECTED and ONLYIFUPTODATE modifiers with CurrentValue retrieval so that the current value turns to bad quality if the collector is disconnected. This way you are not misled by looking at an outdated value that does not match the real world.