Select to view content in your preferred language

Calculate Running Total in Real Time Analytic

301
2
11-04-2024 07:24 AM
KevinPiraino2
Frequent Contributor

I am currently trying to build a workflow in a Real Time Analytic (RTA) that will calculate the running total of material used/spread by a snow plow vehicle over a given event. Each vehicle's AVL data includes a "rate" of material spread and distance traveled using the Odometer (although the distance traveled values are not very accurate). I am using the Calculate Motion Statistics to capture the distance traveled between each track's polled event.

At this time I am able to calculate the material used between each time the vehicle is polled, but I am having trouble building a workflow to capture the running total of material used. I have been able to build a Big Data Analytic to capture the sum total of material used, but this is not 100% what I am looking for. Is it possible to calculate the running total in an RTA? Below is the general workflow I have so far, but does not seem to work.

Calculate Motion Stats --> calculate distance;
- Dist. Tolerance: 10ft
- Timespan Tolerance: 3sec
- Target Time Window: 1 min
- History Depth: 3
- Method: Geodesic

Calculate Fields --> calculate distance moved in miles; convert feet to miles
- calculate material spread between each point? (distance * granular rate)
- granular rate and distance should use same units (feet to feet; miles to miles; etc.)

Map Fields --> map fields to be created in output
- add field for Material Spread Sum --> return 0 (can't return null)

Calculate Fields (2) --> calculate running total of material spread

    //GranularMaterialSpread_dist == current material spread (not total)
    var currMaterialSpread = $feature.GranularMaterialSpread_dist
    var prevMaterialSum = null

    if(count(TrackFieldWindow('GranMaterialSum', -1, 0)) < 1){
      prevMaterialSum = 0
      return (currMaterialSpread + prevMaterialSum)
    }
    if(count(TrackFieldWindow('GranMaterialSum', -1, 0)) >= 1){
      prevMaterialSum = TrackFieldWindow('GranMaterialSum', -1, 0)[0]
      return (currMaterialSpread + prevMaterialSum)
    }
    else{
      return -999
    }

 

0 Kudos
2 Replies
JeffSilberberg
Frequent Contributor

Kevin, 

      I think that the Track Functions you are using look at the Feed data coming in, not the Feature layer data you are outputting with the new/built schema.  If a big data analytic is not the answer then you could possibly join by track id to a new feed built over the output feature layer.   

     

 

KevinPiraino2
Frequent Contributor

Jeff,

Thanks for the suggestion. What you are saying about the track functions makes a lot of sense. I will definitely try creating a feed from the output of the RTA and use it as an input in the RTA.

0 Kudos