At about this time, he witnessed a train wreck where two engineers saw one another, but were unable to stop their trains in time using the existing brakes. Brakemen had to run from car to car, on catwalks atop the cars, applying the brakes manually on each car.
In 1869, at age 22, Westinghouse invented a railroad braking system using compressed air. The Westinghouse system used a compressor on the locomotive, a reservoir and a special valve on each car, and a single pipe running the length of the train (with flexible connections) which both refilled the reservoirs and controlled the brakes, allowing the engineer to apply and release the brakes simultaneously on all cars. It is a failsafe system, in that any rupture or disconnection in the train pipe will apply the brakes throughout the train. It was patented by Westinghouse on October 28, 1873.
Westinghouse pursued many improvements in railway signals (which then used oil lamps). In 1881 he founded the Union Switch and Signal Company to manufacture his signaling and switching inventions.
According to wikipedia