I have modified an RTA so that the incident detection node now uses a TrackFieldWindow("speedInMph", -3, 0) expression to look at the last three (Current, -1, and -2) transactions for vehicle speeding.
The Incident starts based on this logic, and defaults to Ends when the Logic returns false.
// $feature.speedInMph > 25
// Get last 3 speed observations
var speeds = TrackFieldWindow("speedInMph", -3, 0);
// Check that all 3 speeds are > 25 MPH
return
Count(speeds) == 3 &&
speeds[0] > 25 &&
speeds[1] > 25 &&
speeds[2] > 25;
Now I am trying to decide if I can fix the IncidentDuration added to the Schema, as the reports are 30 seconds apart, so speeds[2] is actually 60 seconds old at this point. Could I add a fieldCalculation after the Detection Node to adjust the tIncidentDuration time? If so, would I need to do it for all Started, Ended, and Ongoing states, or can I somehow impact the value in the stored state?
Solved! Go to Solution.
@JeffSilberberg Thanks for clarifying - the changes would need to be applied each time. The attribute state is maintained at the tool level and the arcade expression only evaluates to true vs false to determine whether the incident should be opened/continue/closed. We would not expect the contents of this arcade expression to change feature attribute prior state values.
Just thought I would bump this ---
Hi @JeffSilberberg not sure I am understanding your question correctly. Yes - you can add the Calculate Fields tool after any other tool in your model to adjust datetime values as desired. However this would need to occur outside/after the Detect Incidents tool.
https://developers.arcgis.com/arcade/function-reference/date_functions/#dateadd (can add negatives)
It's not a question of whether I can add the Calculate Fields; it's a question of whether I can change the Incident Duration time as it started, not at the current transaction, but two transactions before, based on the
TrackFieldWindow("speedInMph", -3, 0);
If I change it on "Started", does it keep the change, or does the change need to be applied each time a transaction passes through the logic?
@JeffSilberberg Thanks for clarifying - the changes would need to be applied each time. The attribute state is maintained at the tool level and the arcade expression only evaluates to true vs false to determine whether the incident should be opened/continue/closed. We would not expect the contents of this arcade expression to change feature attribute prior state values.