Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
samplestream:lc_amount [2024/04/23 06:52]
optrix created
samplestream:lc_amount [2024/04/25 23:43] (current)
optrix
Line 5: Line 5:
 ===Description=== ===Description===
  
-This function is used to calculate a [[lagged time]] based on a //counter//+This function is used to calculate a [[data-driven lag|data-driven lag time]] based on a //counter//
  
-For example, you can use it if you have a sensor that counts the number of products that have gone past a particular point, to go from any given time to a time //x number of products ago//.+Use this if the source of your lag is being **counted** or **totalised** instead of being measured as a **rate**. Note that in many industrial applications, field-based counters or totalisers are more accurate than performing calculations on rates. 
 + 
 +For example, you might have a conveyor system measuring how many meters you've moved. If Sensor X is 50m away from Sensor Y, you can calculate the //time lag// between Y and X by going backwards and finding out how long it took for 50m of conveyor to pass.
  
 ===Parameters=== ===Parameters===
  
 ^Parameter^Type^Meaning^ ^Parameter^Type^Meaning^
-|times|list of datetimes|The UTC dates and times for each sample|+|server|ARDI API Server|The ARDI server to query| 
 +|query|string|The AQL Query to send| 
 +|amount|float|The amount to lag the time by| 
 +|origin|datetime|The ending/reference time (default=now)| 
 +|seconds|int|The maximum number of seconds to search (default=1 day)| 
 +|expected|int|The average amount of time in normal operation (default=10 minutes)|
  
 ===Returns=== ===Returns===
  
-A list of samples - one for each requested time-frame.+The number of seconds of lag between the **origin** time and when **amount** has been counted. 
 + 
 +===Notes and Behaviour=== 
 + 
 +The **expected** time should be the maximum amount of lag you'd //expect// to have during normal operation (ie. if your machines didn't stop in the mean-time). 
 + 
 +The **seconds** time should be the maximum amount of lag you're willing to search for.
  
 ===Example=== ===Example===
  
 <code python> <code python>
-    srv = ardiapi.Server("demo.optrix.com.au/s/ex"+    srv = ardiapi.Server('demo.optrix.com.au/s/pl') 
-    smp = samplestream.samplestream(srv,"'Wind Turbine #1' ASSET 'Power' PROPERTY",30,30,15+ 
-    +    lc = samplestream.LagCorrection() 
-    datesneeded = [ datetime.datetime.now(datetime.timedelta(seconds=200+    diff = lc.Amount(srv,"'Paint Line' ASSET 'Distance' PROPERTY VALUES",25
-    samples = smp.GatherSamples(datesneeded)+ 
 +    print("Roller 2 Lag Correction " + str(dt))
  </code>  </code>