Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
samplestream:adaptable_example [2024/04/25 22:50] optrix created |
samplestream:adaptable_example [2024/04/26 00:11] (current) 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 | + | This would mean the code wouldn' |
+ | |||
+ | Using ARDI, it's also possible to load these // | ||
<code python> | <code python> | ||
- | srv = ardiapi.Server(' | + | srv = ardiapi.Server(' |
+ | #Get the ' | ||
+ | req = ardiapi.AQLQuery(srv) | ||
+ | resp = req.Execute("' | ||
- | #Get the results | + | #Go through each asset and write its lag value to a dictionary |
+ | distances = {} | ||
+ | for value in resp[' | ||
+ | distances[value[' | ||
+ | |||
+ | #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(' | + | lcq.RateLagQuery(' |
- | lcq.AddQuery("' | + | lcq.AddQuery("' |
- | lcq.AddQuery("' | + | lcq.AddQuery("' |
lcq.multiplier = 0.0166 | lcq.multiplier = 0.0166 | ||
lcq.shavems = True | lcq.shavems = True | ||
Line 23: | Line 33: | ||
df = lcq.Execute(starttime, | df = lcq.Execute(starttime, | ||
</ | </ | ||
+ | |||
+ | This technique has several benefits.. | ||
+ | |||
+ | ===Adapt to Line Changes=== | ||
+ | |||
+ | Sometimes, equipment gets moved. This isn't limited to portable hardware - even the ' | ||
+ | |||
+ | In some cases, product lines are flexible, allowing changes between batches to cater for different products. | ||
+ | |||
+ | Being adaptable allows the system to deal with these changes, [[simple lag|as long as they don't happen mid-range]]. | ||
+ | |||
+ | ===Adapt to Line and Site Differences=== | ||
+ | |||
+ | Loading the list of assets and their distances dynamically means you can apply the same logic to different process lines. Large manufacturers may have several similar systems producing different types of product - this way, you can use the one piece of code across each of those lines. | ||
+ | |||
+ | This also lets you drop your logic into different sites with minimal changes required. |