Differences

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

Link to this comparison view

Next revision
Previous revision
Last revision Both sides next revision
samplestream:adaptable_example [2024/04/25 22:50]
optrix created
samplestream:adaptable_example [2024/04/25 23:15]
optrix
Line 3: Line 3:
 In the [[example|previous example]], we hard-coded the [[distance|distance]] between each of our assets when requesting a lag-corrected query. In the [[example|previous example]], we hard-coded the [[distance|distance]] between each of our assets when requesting a lag-corrected query.
  
-Using ARDI, it's also possible to use relationships and static properties to load these values dynamically.+This would mean the code wouldn't be able to adapt to changes, move between various different lines, or deal with flexible systems that adjust for specific products. 
 + 
 +Using ARDI, it's also possible to load these //distance// values dynamically - although it is still limited to [[simple lag|only working on simple forms of lag]].
  
 <code python> <code python>
  
-srv = ardiapi.Server('demo.optrix.com.au/s/pl')+srv = ardiapi.Server('cupcake.ardi')
  
 +#Get the 'Distance To End' property value for all assets down-stream from the oven...
 +req = ardiapi.AQLQuery(srv)
 +resp = req.Execute("'Oven' ASSET 'Sequence' RELATIONSHIP 'downi' RELATED 'Distance To End' PROPERTY VALUES")
  
-#Get the results+#Go through each asset and write its lag value to a dictionary 
 +distances = {} 
 +for value in resp['response'][0]['value']: 
 +    distances[value['name']] = value['rawvalue'
 + 
 +#Same as the previous query, but replaces the fixed lag value with a dictionary lookup
 lcq = samplestream.LagCorrectedQuery(srv) lcq = samplestream.LagCorrectedQuery(srv)
-lcq.RateLagQuery('Strip Meters',"'Paint Line' ASSET 'Speed - Actual' PROPERTY VALUES"+lcq.RateLagQuery('Meters',"'Conveyor' ASSET 'Speed' PROPERTY VALUES"
-lcq.AddQuery("'Finish Oven Zone 1' ASSET 'Temperature - Oven' PROPERTY VALUES"+lcq.AddQuery("'Inspection Station' ASSET 'Brownness' PROPERTY VALUES"
-lcq.AddQuery("'Prime Oven Zone 1' ASSET 'Temperature - Oven' PROPERTY VALUES",lag=50)+lcq.AddQuery("'Oven' ASSET 'Temperature' PROPERTY VALUES",lag=distances['Oven'])
 lcq.multiplier = 0.0166 lcq.multiplier = 0.0166
 lcq.shavems = True lcq.shavems = True
Line 23: Line 33:
 df = lcq.Execute(starttime,endtime,samples=3600) df = lcq.Execute(starttime,endtime,samples=3600)
 </code> </code>
 +
 +Using this technique, your logic...
 +
 +   * Can adapt to temporary or permanent changes made to site,
 +   * Can be used across multiple product lines with different configurations, and
 +   * Can be used on multiple different sites