RawByFilterToggle Sampling Mode
The RawByFilterToggle sampling mode is a form of filtered data query. A filtered data query returns data values for a particular time period whereas RawByFilterToggle sampling mode returns the time periods where the condition becomes TRUE or FALSE. The RawByFilterToggle sampling mode returns the Timestamp, Value, and Data Quality for the matching entries. The data values returned will have the same tagname which you queried for.
RawByFilterToggle returns only 0 and 1. The value 1 is returned with a timestamp when the filter condition becomes TRUE, and the value 0 is returned with the timestamp when the filter condition becomes FALSE. You can have multiple pairs of 1 and 0 values if the condition becomes TRUE multiple times between the start and end time. If the condition never became TRUE between the start and end time, you will not get any values.
- Timestamp
-
The RawByFilterToggle sampling mode returns 0 and 1 as values. The value 1 is returned with a timestamp when the filter condition becomes TRUE, and the value 0 is returned with the timestamp when the filter condition becomes FALSE. You can have multiple pairs of 1 and 0 values if the condition becomes TRUE multiple times between the start and end time. If the condition never became TRUE between the start and end time, you will not get any values. You can use a filterexpression to return the time ranges that match the criteria.
The RawByFilterToggle sampling mode can return any timestamp between the start and end time, depending on if and when the condition becomes TRUE or FALSE. The timestamps returned can be queried further using RawByTime, RawByNumber, Interpolated, or any other sampling or calculation mode.
- Value
-
This sampling mode only returns 0 and 1 as values. The value 1 is returned with a timestamp where the filter condition is TRUE and 0 is returned with the timestamp where the filter condition is FALSE.
- Data Quality
-
The RawByFilterToggle considers only Good quality data.
Retrieving Data Using RawByFilterToggle Sampling Mode
The following two examples use this data that is imported into Proficy Historian. This data will be used in the examples for retrieving data with the RawByFilterToggle sampling mode.
[Tags]
Tagname,DataType,HiEngineeringUnits,
LoEngineeringUnits RAMP,SingleInteger,10,0
[Data]
Tagname,TimeStamp,Value,Data Quality
RAMP,25-Feb-2013 07:00:00.000,0,Good,
RAMP,25-Feb-2013 07:00:01.000,1,Good,
RAMP,25-Feb-2013 07:00:02.000,2,Good,
RAMP,25-Feb-2013 07:00:03.000,3,Good,
RAMP,25-Feb-2013 07:00:04.000,4,Good,
RAMP,25-Feb-2013 07:00:05.000,5,Good,
RAMP,25-Feb-2013 07:00:06.000,6,Good,
RAMP,25-Feb-2013 07:00:07.000,7,Good,
RAMP,25-Feb-2013 07:00:08.000,8,Good,
RAMP,25-Feb-2013 07:00:09.000,9,Good,
RAMP,25-Feb-2013 07:00:10.000,10,Good,
RAMP,25-Feb-2013 07:00:11.000,11,Good,
RAMP,25-Feb-2013 07:00:12.000,12,Good,
RAMP,25-Feb-2013 07:00:13.000,13,Good,
RAMP,25-Feb-2013 07:00:14.000,14,Good,
RAMP,25-Feb-2013 07:00:15.000,15,Good,
RAMP,25-Feb-2013 07:00:16.000,16,Good,
RAMP,25-Feb-2013 07:00:17.000,17,Good,
RAMP,25-Feb-2013 07:00:18.000,18,Good,
RAMP,25-Feb-2013 07:00:19.000,19,Good,
RAMP,25-Feb-2013 07:00:20.000,20,Good,
RAMP,25-Feb-2013 07:00:21.000,21,Good,
RAMP,25-Feb-2013 07:00:22.000,22,Good,
RAMP,25-Feb-2013 07:00:23.000,23,Good,
RAMP,25-Feb-2013 07:00:24.000,24,Good,
RAMP,25-Feb-2013 07:00:25.000,25,Good,
RAMP,25-Feb-2013 07:00:26.000,26,Good,
RAMP,25-Feb-2013 07:00:27.000,27,Good,
RAMP,25-Feb-2013 07:00:28.000,28,Good,
RAMP,25-Feb-2013 07:00:29.000,29,Good,
RAMP,25-Feb-2013 07:00:30.000,30,Good,
RAMP,25-Feb-2013 07:00:31.000,31,Good,
RAMP,25-Feb-2013 07:00:32.000,32,Good,
RAMP,25-Feb-2013 07:00:33.000,33,Good,
RAMP,25-Feb-2013 07:00:34.000,34,Good,
RAMP,25-Feb-2013 07:00:35.000,35,Good,
RAMP,25-Feb-2013 07:00:36.000,36,Good,
RAMP,25-Feb-2013 07:00:37.000,37,Good,
RAMP,25-Feb-2013 07:00:38.000,38,Good,
RAMP,25-Feb-2013 07:00:39.000,39,Good,
RAMP,25-Feb-2013 07:00:40.000,40,Good,
RAMP,25-Feb-2013 07:00:41.000,41,Good,
RAMP,25-Feb-2013 07:00:42.000,42,Good,
RAMP,25-Feb-2013 07:00:43.000,43,Good,
RAMP,25-Feb-2013 07:00:44.000,44,Good,
RAMP,25-Feb-2013 07:00:45.000,45,Good,
RAMP,25-Feb-2013 07:00:46.000,46,Good,
RAMP,25-Feb-2013 07:00:47.000,47,Good,
RAMP,25-Feb-2013 07:00:48.000,48,Good,
RAMP,25-Feb-2013 07:00:49.000,49,Good,
RAMP,25-Feb-2013 07:00:50.000,50,Good,
RAMP,25-Feb-2013 07:00:51.000,51,Good,
RAMP,25-Feb-2013 07:00:52.000,52,Good,
RAMP,25-Feb-2013 07:00:53.000,53,Good,
RAMP,25-Feb-2013 07:00:54.000,54,Good,
RAMP,25-Feb-2013 07:00:55.000,55,Good,
RAMP,25-Feb-2013 07:00:56.000,56,Good,
RAMP,25-Feb-2013 07:00:57.000,57,Good,
RAMP,25-Feb-2013 07:00:58.000,58,Good,
RAMP,25-Feb-2013 07:00:59.000,59,Good,
Determining the Time Range After the Condition Became TRUE
An example of a Query using RawByFilterToggle sampling mode is as follows:
starttime=’02/25/2013 07:00:00’, endtime=’02/25/2013 07:10:00’
select timestamp, value, quality from ihrawdata where tagname = RAMP and samplingmode= rawbyfiltertoggle
and filterexpression=’(RAMP>50)’ and filtermode=AfterTime
This query set
would determine when the ramp value exceeded 50 and
returns the time range after that. The following results are obtained:
Timestamp | Value | Quality |
---|---|---|
02/25/201307:00:00 | 0 | Good NonSpecific |
02/25/201307:00:51 | 1 | Good NonSpecific |
02/25/201307:10:00 | 1 | Good NonSpecific |
You can see in the raw data that the condition became true at 7:00:51 so the sample is returned with a value of 1. The 0 and 1 are bounding values that would make the data easier to plot. You cannot simply count the number of 1s returned to count the number of times the condition became true. You have to exclude the bounding values
Example 2: Determining the Time Range Before the Condition Became TRUE
An example of a query using RawByFilterToggle sampling mode is as follows
set starttime=’02/25/2013 07:00:00’, endtime=’02/25/2013 08:00:00’
select timestamp, value, quality from ihrawdata where tagname = RAMP and samplingmode= rawbyfiltertoggle
and filterexpression=’(RAMP>10)’ and filtermode=BeforeTime
The following results are obtained
Timestamp | Value | Quality |
---|---|---|
02/25/201307:00:00 | 0 | Good NonSpecific |
02/25/201307:00:10 | 1 | Good NonSpecific |
02/25/201307:00:59 | 0 | Good NonSpecific |
02/25/201308:00:00 | 0 | Good NonSpecific |
You can see in the raw data that the condition became true at 7:00:10 so the sample is returned with a value of 1.
Anticipated Usage
This sampling mode can be used for the same reasons as filtered data queries. That is, when you want the Historian Data Archiver to determine the exact time(s) of the event and you have an approximate time range for an event of interest, such as:
- A batch starting or completing.
- A value exceeding a limit.
- A collected value matching a specified value.
Once you have the exact time range(s) as returned from RawByFilterToggle
, you can use those time ranges in the subsequent data queries or in custom reporting or data analysis applications.