-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add lost
property to vehicles
#32
Comments
Keep in mind that vehicles that go back to the depot without deactivating, or that are at a particularly long timepoint will trigger `lost`.
|
Correct. This is very much an extrapolation, so there are bound to be false positives. Perhaps having the require 'active_support/core_ext/numeric/time'
Runaway.configure do |config|
config.threshold = 10.minutes
config.lost_condition = Proc.new do |vehicle|
vehicle.route ? (Time.now - vehicle.last_moved_at) > config.threshold : false
end
end In an effort to avoid over-configuration, I think having the default just be the time condition and defaulting to 10 minutes is sufficient for most cases. If we determine that it is not, and we have the ability to write a better heuristic, we can then add that in the configuration. |
Yeah. I don't think configuration of the condition is necessary, my point is more that consumers of the event model ought to know that "lost" might not mean actually lost. Another direction to take this: Can the lost condition be based on the vehicle not being stopped at its The downside to this would be a dependency on Timetable from a relatively low-level Shark middleware. |
I'm certainly open to suggestions on better lost conditions, but - from the way I'm reading it - I don't think what you described would work well, aside from the fact that it's adding a dependency. What happens when a vehicle is 11 minutes behind schedule and gets stuck at a stop light? My understanding of your idea says that the vehicle would be lost, since I do think that the "stationary for 10 minutes" conditional is rather naive, and would like to see it substituted. Am I misunderstanding your suggestion? |
Objects now include Dirtiable, which tracks changes to attributes defined through `attr_accessor` and `attr_writer`. Changes can also be recorded manually using `dirty_attribute <name>, <old_value>, <new_value>`. Changes are stored until `clean!` is called, after which the object is no longer considered dirty, and tracking will start from a blank slate. This allows components that have some dependence on state (the upcoming `LostNFound` middleware, for example. See #32) to be provided a set of changes, rather than having to maintain/determine that information themselves. The result is leaner components and a single source of truth about object dirtiness. Example usage of Dirtiable: vehicle = Shark::Vehicle.new(name: '4003', latitude: 10, longitude: -10) vehicle.dirty? #=> false vehicle.changes #=> { } vehicle.latitude = 15 vehicle.dirty? #=> true vehicle.changes #=> { latitude: [[10, 15]] } vehicle.name = '4004' vehicle.latitude = 10 vehicle.longitude = -15 vehicle.changes #=> { name: [['4003', '4004']], latitude: [[10, 15], [15, 10]], longitude: [[-10, -15]] } vehicle.clean! vehicle.dirty? #=> false vehicle.changes #=> { }
I should have added "additionally" to my explanation. I'm suggesting that the FWIW, I don't think CityBus has anything other than 5 minute timepoints. If you want to check for yourself, this awk script prints every nonequal ETA and ETD: |
That makes a lot more sense. I'm not sure why I didn't assume you meant additionally. However, I'm not sold on the benefits of using this heuristic with the cost of having RPCs in the middleware stack. I think there are still plenty of cases where buses would be wrongly considered "lost". The main one that comes to mind is when drivers leave the bus to take mandated breaks: the bus is technically active, and travelling on a route, but can often be delayed by 10+ minutes (I've seen one driver take 16 minutes to return to the bus). My thoughts for now are to just have the time condition, and see how many |
Sure. I'm all for keeping things simple until we actually detect a problem here :) |
In the course of an agency's operation, there may be times where a Vehicle is taken out of commission while it is traveling on a Route. I've had a personal experience where a bus caught fire and was unable to continue it's trip. As one of 2 buses on the 25 minute loop, this caused major delays for the route, but was completely ignored by existing transit applications at the time.
Most applications continued reporting the original scheduled stop times for the route (even though the bus that would make those stops was not in service), while others just showed increasing wait times for the bus.
The idea of the
lost
property of a Vehicle is an attempt to automatically determine situations like these and inform users of major delays as early as possible (rather than just accumulating wait times).The implementation of this property will be through a Middleware class that adds it to the Vehicle model. The Middleware will also add a hidden
last_moved_at
property to preserve state through multiple update cycles. On every cycle where thelatitude
orlongitude
of the Vehicle changes,last_moved_at
will be updated toTime.now
. Iflast_moved_at
exceeds a configurable threshold, thenlost
will be set totrue
for the Vehicle.When the
lost
property istrue
, the Middleware will not proxy events for that vehicle up the rest of the stack. The Middleware will, however, send alost
event up the stack so that clients can respond accordingly. This middleware should come closely after the Agency in the stack to avoid any miscellaneous events relating to the Vehicle coming from other Middlewares.Once the position of a Vehicle changes again, it's
lost
property will be set tofalse
and normal proxying will resume.Here's a quick implementation of the Middleware:
The text was updated successfully, but these errors were encountered: