OPCQOR and OPCQAND Calculation Modes

The OPCQOR calculation mode is a bit-wise OR operation of all the 16 bit OPC qualities of the raw samples stored in the spe- cified interval. This calculation mode can be used only if you have set the ?Store OPC Quality to ?Enabled in the Historian Administrator and your data is coming from an OPC Collector.

The OPCQAND calculation mode is a bit wise AND operation of all the 16 bit OPC qualities of the raw samples stored in the spe- cified interval. This calculation mode can be used only if you have set the ?Store OPC Quality to Enabled in the Historian Administrator and your data is coming from an OPC Collector.

When collecting data from OPC servers, the Historian OPC collector will convert the 16 bits of OPC quality to a Historian quality and subquality. When ?Store OPC Quality is enabled, the 16 bits are also stored with the data and can be retrieved here.

Use the returned value from OPCQOR like a data quality. By using OPCQOR and OPCQAND values, you can see if a condition occurred during an interval and therefore know how trustworthy your returned data is.

Value

The 16 bits are in the following format:

VVVVVVVVQQSSSSSS

The first 16 bits are for vendor to fill in. The next two are the actual quality, good, bad,uncertain. The rest of the bits are subquality.

  • OPC good is a decimal 192 which is binary 0000000011000000.
  • OPC bad is all zeros 0000000000000000.
Quality

The percent good is 100 if all the samples have good Historian quality. The Historian quality is based on the OPC quality but both the qualities are not the same.

Example: Calculating the OPCQOR

The following is the data set used to run the query on.

TagName,Timestamp,Value
DATA1:Bad-0 OPC-(60)(08/09/12 18:00:01.000,Val=10
DATA2:Bad-0 OPC-(59)(08/09/12 18:00:02.000,Val=10
DATA3:Bad-0 OPC-(58)(08/09/12 18:00:03.000),Val=10
DATA4:Bad-0 OPC-(57)(08/09/12 18:00:04.000),Val=10
DATA5:Bad-0 OPC-(56)(08/09/12 18:00:05.000),Val=10
DATA6:Bad-0 OPC-(55)(08/09/12 18:00:06.000),Val=10
DATA7:Bad-0 OPC-(54)(08/09/12 18:00:07.000),Val=10
DATA8:Bad-0 OPC-(53)(08/09/12 18:00:08.000),Val=10
DATA9:Bad-0 OPC-(52)(08/09/12 18:00:09.000),Val=10
DATA10:Bad-0 OPC-(51)(08/09/12 18:00:10.000),Val=10
DATA11:Bad-0 OPC-(50)(08/09/12 18:00:11.000),Val=10

The following query retrieves the OPCQOR data with a start time of 18:00:00 and end time of 18:00:10 with a 2 second time interval.

set starttime='08/09/2012 18:00:00',endtime='08/09/2012 18:00:10'
select tagname,timestamp,value,Quality from ihrawdata where tagname like OPCQualityDataTag and samplingmode=Calculated
and calculationmode=OPCQOR and IntervalMilliseconds=2S

The following output is retrieved.

Tag NameTime StampValueQuality
OPCQualityDataTag8/9/2012 18:00:0263.00000000000050.0000000
OPCQualityDataTag8/9/2012 18:00:0459.000000000000100.0000000
OPCQualityDataTag8/9/2012 18:00:0663.000000000000100.0000000
OPCQualityDataTag8/9/2012 18:00:0855.000000000000100.0000000
OPCQualityDataTag8/9/2012 18:00:1055.000000000000100.0000000
Example: Calculating the OPCQAND

The following query retrieves the OPCQAND data with a start time of 18:00:00 and end time of 18:00:10 with a 2 second time interval.

set starttime='08/09/2012 18:00:00',endtime='08/09/2012 18:00:10'
select tagname,timestamp,value,Quality,opcquality from ihrawdata where tagname like OPCQualityDataTag and 
samplingmode=Calculated and calculationmode=OPCQAND and IntervalMilliseconds=2S

he following output is retrieved.

Tag NameTime StampValueQuality
OPCQualityDataTag8/9/2012 18:00:0250.00000000
OPCQualityDataTag8/9/2012 18:00:04100.00000000
OPCQualityDataTag8/9/2012 18:00:06100.00000000
OPCQualityDataTag8/9/2012 18:00:100.00000000
OPCQualityDataTag8/9/2012 18:00:10100.00000000
Anticipated Usage

The OPCQOR and OPCQAND calculation modes are useful if you want to the know the quality of your samples between a time interval. For example,if you want to know how many of your samples from 3pm to 4pm had the following quality:

  • All good - If you do an OPCAND from 3 P.M. to 4 P.M and get the result as 0000000011000000 which is 192 decimal, it means that the value was good for the whole time.
  • All bad - If OPCOR returns 0, then the data was bad the whole time.
  • Some bad - If you do a OPCOR and get the result as 0000000011000000 which is 192 decimal, it means that there were at least some good values. If you do an OPCAND and get the result as 0000000000000000, it means that at least some data was bad.