r2c2.git
3 years agoDon't crash if a train has no router master
Mikko Rasa [Fri, 17 Apr 2015 23:46:23 +0000 (02:46 +0300)]
Don't crash if a train has no router

3 years agoMake some internal colors darker to match linear color space
Mikko Rasa [Fri, 17 Apr 2015 23:45:49 +0000 (02:45 +0300)]
Make some internal colors darker to match linear color space

3 years agoUse skylight for nicer lighting
Mikko Rasa [Fri, 17 Apr 2015 23:44:59 +0000 (02:44 +0300)]
Use skylight for nicer lighting

3 years agoAdd a high-quality model for BR 194
Mikko Rasa [Fri, 17 Apr 2015 23:39:56 +0000 (02:39 +0300)]
Add a high-quality model for BR 194

3 years agoRe-export high-quality models with shaders
Mikko Rasa [Fri, 17 Apr 2015 23:33:30 +0000 (02:33 +0300)]
Re-export high-quality models with shaders

3 years agoProperly round negative z coordinates for Terrain
Mikko Rasa [Wed, 15 Apr 2015 09:23:05 +0000 (12:23 +0300)]
Properly round negative z coordinates for Terrain

3 years agoAdd a new remote control program with GLtk-based UI
Mikko Rasa [Tue, 14 Apr 2015 23:37:43 +0000 (02:37 +0300)]
Add a new remote control program with GLtk-based UI

3 years agoRemove the GTK-based remote control program
Mikko Rasa [Tue, 14 Apr 2015 23:36:07 +0000 (02:36 +0300)]
Remove the GTK-based remote control program

It's woefully outdated, and GTK is annoying to deploy to other operating
systems.

3 years agoSome other minor UI tweaks
Mikko Rasa [Tue, 14 Apr 2015 23:11:49 +0000 (02:11 +0300)]
Some other minor UI tweaks

3 years agoRe-export fonts with latest tools
Mikko Rasa [Tue, 14 Apr 2015 22:16:47 +0000 (01:16 +0300)]
Re-export fonts with latest tools

Fixes a number of minor issues with character spacing and texture
wrapping.

3 years agoBugfixes for the network server
Mikko Rasa [Fri, 10 Apr 2015 18:02:39 +0000 (21:02 +0300)]
Bugfixes for the network server

3 years agoMinor style correction
Mikko Rasa [Thu, 9 Apr 2015 07:51:59 +0000 (10:51 +0300)]
Minor style correction

3 years agoAdd maximum speed to BR 23
Mikko Rasa [Thu, 9 Apr 2015 07:49:40 +0000 (10:49 +0300)]
Add maximum speed to BR 23

3 years agoExport AI control parameters over the network
Mikko Rasa [Thu, 9 Apr 2015 07:07:52 +0000 (10:07 +0300)]
Export AI control parameters over the network

I'm going to revamp the whole network thing a bit later, but this at
least allows it to function.

3 years agoMake Client hold a non-const reference to the Catalogue
Mikko Rasa [Thu, 9 Apr 2015 07:01:40 +0000 (10:01 +0300)]
Make Client hold a non-const reference to the Catalogue

Since the entire catalogue is no longer loaded at once, it needs to be
non-const so things can be loaded on the fly.

3 years agoProper ID management for Signals
Mikko Rasa [Wed, 8 Apr 2015 20:11:40 +0000 (23:11 +0300)]
Proper ID management for Signals

3 years agoAvoid nested block reservations completely
Mikko Rasa [Wed, 8 Apr 2015 16:55:21 +0000 (19:55 +0300)]
Avoid nested block reservations completely

The emission queue turned out to still be broken in some situations.
Rather than make the logic even more complex, I'll just delay the
reservation until we're no longer inside a signal emission.  For good
measure, the same is applied to turnout and sensor signals too.

3 years agoOnly use postprocessors that can be supported
Mikko Rasa [Tue, 7 Apr 2015 12:19:27 +0000 (15:19 +0300)]
Only use postprocessors that can be supported

3 years agoFix some minor shader errors
Mikko Rasa [Tue, 7 Apr 2015 12:18:17 +0000 (15:18 +0300)]
Fix some minor shader errors

3 years agoRemove a queued block reservation if the block is released
Mikko Rasa [Tue, 7 Apr 2015 10:56:47 +0000 (13:56 +0300)]
Remove a queued block reservation if the block is released

This can happen in some situations with instantly changing turnouts.

3 years agoBetter handling of network communication errors
Mikko Rasa [Mon, 6 Apr 2015 22:26:41 +0000 (01:26 +0300)]
Better handling of network communication errors

Apparently, if a client abruptly disconnects, recv may return ECONNRESET.

3 years agoMake View3D trackable since it connects to a signal
Mikko Rasa [Mon, 6 Apr 2015 22:25:16 +0000 (01:25 +0300)]
Make View3D trackable since it connects to a signal

3 years agoImprove accessory turn-off logic in arducontrol driver
Mikko Rasa [Sun, 5 Apr 2015 08:50:44 +0000 (11:50 +0300)]
Improve accessory turn-off logic in arducontrol driver

In some cases the limit switch won't trigger properly, so we can't rely
on the current dropping to determine success.

3 years agoRemember the states of locomotive functions
Mikko Rasa [Sat, 4 Apr 2015 16:12:35 +0000 (19:12 +0300)]
Remember the states of locomotive functions

3 years agoProperly handle setting multiple functions in rapid succession
Mikko Rasa [Sat, 4 Apr 2015 16:11:45 +0000 (19:11 +0300)]
Properly handle setting multiple functions in rapid succession

3 years agoReflect the current state of functions in a newly opened train dialog
Mikko Rasa [Sat, 4 Apr 2015 16:05:05 +0000 (19:05 +0300)]
Reflect the current state of functions in a newly opened train dialog

3 years agoBetter graphics for the clock
Mikko Rasa [Sat, 4 Apr 2015 13:52:05 +0000 (16:52 +0300)]
Better graphics for the clock

3 years agoPersist most dialogs across runs
Mikko Rasa [Fri, 3 Apr 2015 22:42:35 +0000 (01:42 +0300)]
Persist most dialogs across runs

3 years agoSome refactoring in preparation for UI persistence
Mikko Rasa [Fri, 3 Apr 2015 22:40:03 +0000 (01:40 +0300)]
Some refactoring in preparation for UI persistence

3 years agoRemove some unnecessary proxy functions
Mikko Rasa [Fri, 3 Apr 2015 22:36:53 +0000 (01:36 +0300)]
Remove some unnecessary proxy functions

3 years agoMinor adjustments to UI code
Mikko Rasa [Fri, 3 Apr 2015 16:37:46 +0000 (19:37 +0300)]
Minor adjustments to UI code

3 years agoMove user interface code to its own class
Mikko Rasa [Fri, 3 Apr 2015 16:29:46 +0000 (19:29 +0300)]
Move user interface code to its own class

3 years agoAdd a dialog and necessary support code to display departures
Mikko Rasa [Thu, 2 Apr 2015 21:53:08 +0000 (00:53 +0300)]
Add a dialog and necessary support code to display departures

3 years agoSet delay to zero before emitting signal_departed
Mikko Rasa [Thu, 2 Apr 2015 21:50:33 +0000 (00:50 +0300)]
Set delay to zero before emitting signal_departed

3 years agoHandle the case of a train being late
Mikko Rasa [Tue, 31 Mar 2015 21:49:03 +0000 (00:49 +0300)]
Handle the case of a train being late

Send it on its next trip after a short fixed delay instead of waiting
for the next day.

3 years agoMove the responsibility of starting the train to TrainRouter
Mikko Rasa [Tue, 31 Mar 2015 21:42:00 +0000 (00:42 +0300)]
Move the responsibility of starting the train to TrainRouter

This avoids any further sync problems with the planner, accounts for
irregular situations and also makes more sense.

3 years agoAdd two new telemetry values to the arducontrol driver
Mikko Rasa [Mon, 30 Mar 2015 20:18:38 +0000 (23:18 +0300)]
Add two new telemetry values to the arducontrol driver

3 years agoKeep UI better in sync with the clock
Mikko Rasa [Sun, 29 Mar 2015 22:31:36 +0000 (01:31 +0300)]
Keep UI better in sync with the clock

3 years agoSync timetable on clock discontinuity
Mikko Rasa [Sun, 29 Mar 2015 22:29:48 +0000 (01:29 +0300)]
Sync timetable on clock discontinuity

3 years agoUse add_argument instead of get_args
Mikko Rasa [Fri, 27 Mar 2015 07:15:10 +0000 (09:15 +0200)]
Use add_argument instead of get_args

3 years agoAdd an option to set simulation speed
Mikko Rasa [Fri, 27 Mar 2015 07:12:58 +0000 (09:12 +0200)]
Add an option to set simulation speed

Useful for testing long timetables.  Will cause problems if used with a
physical layout; currently there are no checks to prevent it.

3 years agoLimit timestep to 10 milliseconds
Mikko Rasa [Fri, 27 Mar 2015 07:04:54 +0000 (09:04 +0200)]
Limit timestep to 10 milliseconds

The simulation still has some problems with detriggering sensors if a
train advances too much during a step.  This should alleviate the issue.

3 years agoAllow zones with no qualifier or no number
Mikko Rasa [Thu, 26 Mar 2015 20:09:05 +0000 (22:09 +0200)]
Allow zones with no qualifier or no number

3 years agoAvoid unnecessary wait time with shared destinations
Mikko Rasa [Tue, 24 Mar 2015 10:28:40 +0000 (12:28 +0200)]
Avoid unnecessary wait time with shared destinations

If a train gets blocked by another train which has already arrived but
has a trip duration, a step must be processed when the blocking train
departs again.  Otherwise the next step might be a long time off (in case
all other trains have long departure delays) and would get an overly
inflated cost.

3 years agoAvoid negative values of wait_time
Mikko Rasa [Tue, 24 Mar 2015 10:07:47 +0000 (12:07 +0200)]
Avoid negative values of wait_time

3 years agoAdd missing initializer
Mikko Rasa [Tue, 24 Mar 2015 09:13:44 +0000 (11:13 +0200)]
Add missing initializer

3 years agoTweak the picking of the next train to process
Mikko Rasa [Mon, 23 Mar 2015 21:12:33 +0000 (23:12 +0200)]
Tweak the picking of the next train to process

If a train just became unblocked, it should be considered for picking
immediately.

3 years agoFix handling of trains that are becoming blocked
Mikko Rasa [Mon, 23 Mar 2015 20:49:29 +0000 (22:49 +0200)]
Fix handling of trains that are becoming blocked

3 years agoPenalize running against the preferred direction when planning routes
Mikko Rasa [Sun, 22 Mar 2015 16:03:24 +0000 (18:03 +0200)]
Penalize running against the preferred direction when planning routes

3 years agoCosmetic tweaks
Mikko Rasa [Sun, 22 Mar 2015 16:02:25 +0000 (18:02 +0200)]
Cosmetic tweaks

3 years agoAdd explicit typecast to avoid infinite recursion
Mikko Rasa [Sun, 22 Mar 2015 16:01:58 +0000 (18:01 +0200)]
Add explicit typecast to avoid infinite recursion

3 years agoGive zones a preferred running direction
Mikko Rasa [Sun, 22 Mar 2015 15:58:41 +0000 (17:58 +0200)]
Give zones a preferred running direction

It's also reflected in tracks as a preferred exit endpoint to avoid
having to look up zones while routing.  Weird things may happen if a
track belongs to multiple zones.

3 years agoAdd a using statement for get_end in Zone
Mikko Rasa [Sun, 22 Mar 2015 15:32:16 +0000 (17:32 +0200)]
Add a using statement for get_end in Zone

The virtual function declaration hides the other overload if it's not
explicitly brought in.

3 years agoRetain addresses of previously seen locomotives
Mikko Rasa [Mon, 2 Mar 2015 21:16:20 +0000 (23:16 +0200)]
Retain addresses of previously seen locomotives

It may happen that a locomotive gets re-enumerated, e.g. after visiting
another layout.  Since they are identified by their address, it's useful
to keep the same address.

3 years agoRead MFX locomotive name
Mikko Rasa [Thu, 26 Feb 2015 17:29:37 +0000 (19:29 +0200)]
Read MFX locomotive name

3 years agoRewrite goal initialization for TrainRouteMetric
Mikko Rasa [Mon, 23 Feb 2015 14:42:00 +0000 (16:42 +0200)]
Rewrite goal initialization for TrainRouteMetric

The previous code incorrectly added all tracks as goals when a direction
was specified, instead of only the ends.  This caused cost estimate creep
in the route planner, resulting in suboptimal performance.

3 years agoUse cached path length from occupied_tracks
Mikko Rasa [Mon, 23 Feb 2015 14:41:02 +0000 (16:41 +0200)]
Use cached path length from occupied_tracks

TrackType::get_path_length is not only a function call but also loops
through all parts to calculate the length.

3 years agoFix a problem with estimated remaining distance in route planner
Mikko Rasa [Mon, 23 Feb 2015 14:40:02 +0000 (16:40 +0200)]
Fix a problem with estimated remaining distance in route planner

The front of the occupied tracks list contains the length of the chosen
path on the current track and needs to be updated when the path changes.

3 years agoFollow the same path until another is significantly better
Mikko Rasa [Mon, 23 Feb 2015 10:17:27 +0000 (12:17 +0200)]
Follow the same path until another is significantly better

This replaces the cost penalty for routing steps.  In the penalty approach
it was possible to get two or more steps with the same penalty, which
would then race with each other.  In the new approach, all other steps are
sorted by their unpenalized cost and only the preferred one gets special
treatment.

3 years agoConsider train length when calculating wait time estimate
Mikko Rasa [Mon, 23 Feb 2015 10:14:58 +0000 (12:14 +0200)]
Consider train length when calculating wait time estimate

This allows also estimating wait time when a train is blocked.

3 years agoReset wait time estimate when the train starts moving again
Mikko Rasa [Mon, 23 Feb 2015 10:13:25 +0000 (12:13 +0200)]
Reset wait time estimate when the train starts moving again

Just in case the estimate was too high.

3 years agoAdd an actual heuristic for wait time
Mikko Rasa [Sun, 22 Feb 2015 18:09:51 +0000 (20:09 +0200)]
Add an actual heuristic for wait time

4 years agoDon't go past end of allocation when checking blocks for a signal
Mikko Rasa [Sat, 21 Feb 2015 23:52:44 +0000 (01:52 +0200)]
Don't go past end of allocation when checking blocks for a signal

4 years agoDon't clear current_sequence in set_route
Mikko Rasa [Sat, 21 Feb 2015 23:38:31 +0000 (01:38 +0200)]
Don't clear current_sequence in set_route

It may be still needed by routers of other trains.

4 years agoRobustify sequence handling while applying route plans
Mikko Rasa [Sat, 21 Feb 2015 19:05:28 +0000 (21:05 +0200)]
Robustify sequence handling while applying route plans

Setting current_sequence of all participating routers to zero beforehand
will make sequence points involving them not cleared and avoid the need
to special case everything.

4 years agoOnly schedule a sequence check if we're waiting at a sequence point
Mikko Rasa [Sat, 21 Feb 2015 18:30:15 +0000 (20:30 +0200)]
Only schedule a sequence check if we're waiting at a sequence point

4 years agoCombine the sequence_check_pending flag with state
Mikko Rasa [Sat, 21 Feb 2015 18:29:30 +0000 (20:29 +0200)]
Combine the sequence_check_pending flag with state

4 years agoSprinkle some comments on the routing system
Mikko Rasa [Fri, 20 Feb 2015 22:46:46 +0000 (00:46 +0200)]
Sprinkle some comments on the routing system

4 years agoDon't bother with creating intermediate steps for state updates
Mikko Rasa [Fri, 20 Feb 2015 22:42:40 +0000 (00:42 +0200)]
Don't bother with creating intermediate steps for state updates

They were needed back when the wait system was different, but no longer
have any use.

4 years agoClear the critical flag one track earlier
Mikko Rasa [Fri, 20 Feb 2015 16:40:54 +0000 (18:40 +0200)]
Clear the critical flag one track earlier

Check_arrival is called when the train reaches the end of its current
track.  The flag should be cleared when the track it is entering is no
longer critical.

4 years agoMove duplicated successor step creation code to a function
Mikko Rasa [Fri, 20 Feb 2015 16:11:41 +0000 (18:11 +0200)]
Move duplicated successor step creation code to a function

4 years agoAllow direction to be specified for routing waypoints
Mikko Rasa [Fri, 20 Feb 2015 16:08:20 +0000 (18:08 +0200)]
Allow direction to be specified for routing waypoints

4 years agoSupport directionality for zones
Mikko Rasa [Fri, 20 Feb 2015 15:44:56 +0000 (17:44 +0200)]
Support directionality for zones

4 years agoStore zone blocks in order and use add_tracks to load them
Mikko Rasa [Fri, 20 Feb 2015 15:41:53 +0000 (17:41 +0200)]
Store zone blocks in order and use add_tracks to load them

4 years agoDon't save an allocated but pending block
Mikko Rasa [Fri, 20 Feb 2015 09:58:42 +0000 (11:58 +0200)]
Don't save an allocated but pending block

It could be a failed turnout which is still set the wrong way.

4 years agoCosmetic fixes
Mikko Rasa [Fri, 20 Feb 2015 09:54:15 +0000 (11:54 +0200)]
Cosmetic fixes

4 years agoDon't attempt to use planned route if no waypoints are set
Mikko Rasa [Fri, 20 Feb 2015 09:53:45 +0000 (11:53 +0200)]
Don't attempt to use planned route if no waypoints are set

4 years agoInitialize the halted flag of dummy driver
Mikko Rasa [Fri, 20 Feb 2015 09:50:54 +0000 (11:50 +0200)]
Initialize the halted flag of dummy driver

4 years agoAdd a dialog to display telemetry data from the driver
Mikko Rasa [Thu, 19 Feb 2015 13:44:28 +0000 (15:44 +0200)]
Add a dialog to display telemetry data from the driver

4 years agoAdd a common base class for dialogs that need to update dynamically
Mikko Rasa [Thu, 19 Feb 2015 13:31:56 +0000 (15:31 +0200)]
Add a common base class for dialogs that need to update dynamically

4 years agoUse deque rather than list for queues
Mikko Rasa [Thu, 19 Feb 2015 13:30:03 +0000 (15:30 +0200)]
Use deque rather than list for queues

List makes one allocation for every item, deque only one per a bunch of
items.

4 years agoProvide some telemetry values from ArduControl
Mikko Rasa [Thu, 19 Feb 2015 13:29:34 +0000 (15:29 +0200)]
Provide some telemetry values from ArduControl

4 years agoAdd telemetry framework for drivers
Mikko Rasa [Thu, 19 Feb 2015 12:01:52 +0000 (14:01 +0200)]
Add telemetry framework for drivers

4 years agoImprove ArduControl task scheduling
Mikko Rasa [Thu, 19 Feb 2015 09:18:02 +0000 (11:18 +0200)]
Improve ArduControl task scheduling

The new scheduler can handle multiple tasks with the same priority, so
other things won't get blocked by the priority command queue for too
long.  It also handles sleeping at the scheduler rather than individual
tasks.

4 years agoTurn ArduControl command_queue into a Task
Mikko Rasa [Mon, 16 Feb 2015 00:17:03 +0000 (02:17 +0200)]
Turn ArduControl command_queue into a Task

It seems that I was thinking of this back in d5d8ee8, but left it
unfinished probably because it was simpler to use a Queue directly.  Now
some upcoming task management improvements call for it to be a Task.

4 years agoDon't check sequence points while applying routes
Mikko Rasa [Sun, 15 Feb 2015 15:46:22 +0000 (17:46 +0200)]
Don't check sequence points while applying routes

The preceding train's routes might not be applied yet.  Instead queue a
sequence check to be done when all routes have been applied.

4 years agoCorrect TrackAttachment entry endpoint
Mikko Rasa [Sun, 15 Feb 2015 08:40:37 +0000 (10:40 +0200)]
Correct TrackAttachment entry endpoint

Since endpoint direction points outwards from the endpoint, we want to
find one that's as close to opposite to the TrackAttachment's direction
as possible.

4 years agoAlso check if the clock is stopped
Mikko Rasa [Sun, 15 Feb 2015 07:20:57 +0000 (09:20 +0200)]
Also check if the clock is stopped

4 years agoDon't eat away departure delay while halted
Mikko Rasa [Fri, 13 Feb 2015 00:50:36 +0000 (02:50 +0200)]
Don't eat away departure delay while halted

4 years agoDon't segfault if an emergency doesn't have a block
Mikko Rasa [Fri, 13 Feb 2015 00:48:03 +0000 (02:48 +0200)]
Don't segfault if an emergency doesn't have a block

4 years agoDeclare emergency if route planning fails
Mikko Rasa [Fri, 13 Feb 2015 00:47:25 +0000 (02:47 +0200)]
Declare emergency if route planning fails

4 years agoAbort route planning if it takes too long
Mikko Rasa [Fri, 13 Feb 2015 00:47:01 +0000 (02:47 +0200)]
Abort route planning if it takes too long

4 years agoBe more permissive when checking route continuity
Mikko Rasa [Thu, 12 Feb 2015 16:11:06 +0000 (18:11 +0200)]
Be more permissive when checking route continuity

In some cases more than one consecutive route may end on the same track,
or a route might only go one track past the previous one, with that track
being a turnout with undetermined path.  Allow skipping routes to deal
with these situations, as long as we don't go completely off route.

4 years agoEnsure that remaining estimate is negative if the waypoint is unreachable
Mikko Rasa [Thu, 12 Feb 2015 14:54:27 +0000 (16:54 +0200)]
Ensure that remaining estimate is negative if the waypoint is unreachable

4 years agoFix critical block logic
Mikko Rasa [Thu, 12 Feb 2015 14:46:45 +0000 (16:46 +0200)]
Fix critical block logic

First noncritical block is not reliable, as it could be outside of the
train's allocated blocks and not guaranteed to set to a consistent path.
Worse, the get_first_noncritical_block function could return a block on
the other side of a turnout which is changing path, and is_block_critical
used completely different logic.

4 years agoDon't allow trains to become blocked in critical blocks
Mikko Rasa [Thu, 12 Feb 2015 09:33:47 +0000 (11:33 +0200)]
Don't allow trains to become blocked in critical blocks

4 years agoAvoid arriving too early if there's an unexpected stop on the last route
Mikko Rasa [Wed, 11 Feb 2015 18:14:30 +0000 (20:14 +0200)]
Avoid arriving too early if there's an unexpected stop on the last route

If the final block of the route is allocated while the train is stopped,
arrival could be triggered prematurely.  I'm not entirely certain if this
can happen in absence of certain quirks of the dummy driver, but better
safe than sorry.

4 years agoBetter sequence syncing on route change
Mikko Rasa [Wed, 11 Feb 2015 16:28:49 +0000 (18:28 +0200)]
Better sequence syncing on route change

Immediately go into the wait state if an uncleared sequence point is
encountered during sync.

4 years agoApply all planned routes at once
Mikko Rasa [Wed, 11 Feb 2015 15:35:56 +0000 (17:35 +0200)]
Apply all planned routes at once

Letting each router to do it separately in the tick function causes
certain problems with synchronization.  In particular, sequence points
are difficult to synchronize unless the route update is atomic.

4 years agoAdd turnout failure simulation to the dummy driver
Mikko Rasa [Wed, 11 Feb 2015 12:54:49 +0000 (14:54 +0200)]
Add turnout failure simulation to the dummy driver