The deal brings an end to the two-year dispute by train drivers.