====LagCorrectedQuery Class==== The **LagCorrectedQuery** class uses a [[class_samplestream|samplestream]] to search backwards in time to produce a single data-frame that includes lag-corrected values. This allows you to easily create analytics that compare quality or deal with lag caused by the distance between different sensors along a line. Note that this function only works with [[simple lag|simple forms of lag]]. ===Functions=== The class has the following functions... [[lcq_constructor|Constructor]] \\ ==Setup== [[lcq_AmountLagQuery|AmountLagQuery]] \\ [[lcq_RateLagQuery|RateLagQuery]] \\ ==Adding Subqueries== [[lcq_AddQuery|AddQuery]] \\ ==Running== [[lcq_Execute|Execute]] \\ ===Variables=== The following member variables are available ^Name^Type^Usage^ |expected|int|Normal length of the lag when running (seconds)| |maxtime|int|Maximum length of the search (seconds)| |multiplier|float|Multiplier to be applied to the value in data-frame index| |shavems|bool|When True, times are rounded to the nearest second| ===Usage=== You build up your query out of three main parts... ==Source of Lag== First, you need a number that can be used to compensate for lag. This might be a distance, a flow-rate, a speed or some other **counter** or **rate** that can be used to see how much of a //thing// (other than time) has passed. This is called the [[source|source of lag]]. ==End Asset== Next, you'll choose an [[End Asset|end asset]]. This is usually the //last// part of your system. This is because the class only searches [[building backwards|backwards through time]] rather than forwards. ==Assets and Distances== Next, identify all of the individual pieces you'll want to add to the query, and how much [[distance|distance]] there is between them. For example, if a conveyor moves through three different temperature sensors, you'd identify them and measure how far away they are from one-another. ===Additional Parameters=== The **multiplier** is usually used to convert the time-base of a //rate//. The class expects your rate to be //per second//, so if you wanted to use a **per minute** input time, you can set the multiplier to 0.016666. The **shavems** option is useful if you want to simplify the data you're getting by eliminating sub-second results. This will effectively 'round up' your results so you have no more than one point per second. ===Example=== [[example|See an example]]