FirstRawValue/FirstRawTime Modes
Retrieves the first good raw sample value or timestamp for a given time interval.
- Value
- The value of the raw sample or zero if there are no good raw samples in the interval. The timestamp of the sample or the year 1969 if there are no good raw samples in the interval.
- Quality
- The quality is the same for FirstRawValue and First RawTime. If there are no good raw samples in the interval, then the percent good is 0. Otherwise, the percent good is always 100, even if the interval contains bad quality samples.
The Raw sample has a quality of Good, Bad or Uncertain, and that is converted to a 0 or 100 percent.
- Example: Retrieving the FirstRawValue/FirstRawTime Values
-
Import this data to Historian:
[Tags] Tagname,DataType,HiEngineeringUnits,LoEngineeringUnits Tag1,SingleFloat,60,0 [Data] Tagname,TimeStamp,Value,DataQuality Tag1,07-05-2011 17:24:00,29.72,Bad Tag1,07-05-2011 17:25:00,29.6,Good Tag1,07-05-2011 17:26:00,29.55,Good Tag1,07-05-2011 17:27:00,29.49,Bad Tag1,07-05-2011 17:28:00,29.53,Bad Tag1,07-05-2011 17:29:00,29.58,Good Tag1,07-05-2011 17:30:00,29.61,Bad Tag1,07-05-2011 17:31:00,29.63,Bad Tag1,07-05-2011 18:19:00,30,Good Tag1,07-05-2011 18:20:00,29.96,Good Tag1,07-05-2011 18:21:00,29.89,Good Tag1,07-05-2011 18:22:00,29.84,Good Tag1,07-05-2011 18:23:00,29.81,Bad
- Using FirstRawValue Calculation Mode
-
set starttime='07-05-2011 16:00:00', endtime='07-05-2011 19:00:00' select timestamp,value,quality from ihrawdata where tagname like 'Tag1' and samplingMode=Calculated and CalculationMode=FirstRawValue and intervalmilliseconds=1h
The output is as follows:
Time Stamp Value Quality 07-05-201117:00:00 0.0000000 0.0000000 07-05-201118:00:00 29.6000000 100.0000000 07-05-201119:00:00 30.0 100.0000000 For the time interval 16:00 to 17:00 there are no raw values so a value and quality of 0 is returned for both FirstRawValue and FirstRawTime. The first raw sample from17:00 to 18:00 is 29.72 but it is a bad data quality so it is skipped and the 29.6 is returned and its timestamp of 17:25 is returned in FirstRawTime. FirstRawValue calculation mode considers only good quality data. In the last interval the first good raw sample is 30 and is returned and its timestamp is returned as FirstRawTime.