This is an old revision of the document!


Frame Looping / Splitting

There are times when you might want to capture details about multiple events that occur in a single day. For example, you might want to capture some key analytics all of the individual batches based on batch number.

If you have built up a table of time frames (records that contain a 'StartTime' and 'EndTime' attribute, which you can get using layers such as get_days, get_events, or timeframes), certain layers will then loop over those time frames.

Layers that will loop over time frames include… get_query, get_events, get_api, lookup, lookup_event

Example

Step 1

For example, lets start by making a query that gets our Batch Number across the day with the get_query function.

[
  { "type": "get_query", "points": ["Production Line.Batch Number"] }
]

Step 2

Next, take that batch number and break our day into individual time-frames for each value.

[
  { "type": "get_query", "points": ["Production Line.Batch Number"] },
  { "type": "timeframe", "split": ["Production Line.Batch Number"] }
]

Step 3

Finally, we want to query and capture the average amount of power consumed across that batch with a query and a flatten operation.

[
  { "type": "get_query", "points": ["Production Line.Batch Number"] },
  { "type": "timeframe", "split": "Production Line.Batch Number" },
  { "type": "get_query", "points": ["Main Power Incomer.Power"] },
  { "type": "flatten", "method": "avg" }
]

Layers 3 & 4 of this configuration will run many times - once for each batch. Each one of the time frames found by the timeframe step (ie. each individual batch) will be queried individually.