A man with the emotional reactions of a "toddler" could have caused "terrible loss of life" by placing obstacles on railway lines.
Michael Martin, 25, was angry about being "told off" by a train driver when he placed obstructions on the line near Gilberdyke Railway Station on December, 18, 29, and 30 last year.
He then tried to stab a sergeant from British Transport Police who confronted him while investigating the incidents, Hull Crown Court heard.
In the first incident, Martin placed a large piece of metal on the eastbound track in the path of a Hull Trains service from London Kings Cross to Hull that was passing through Gilberdyke at 2.03pm.
The driver had slowed from the usual 125mph for the 70mph limit at the station, and saw the obstacle about 200 metres past the station. Jayne Bryan, prosecuting, said the driver immediately applied the emergency brakes but was unable to avoid the collision.
After safely stopping the train she contacted a signaller to block both lines so she could inspect the damage, and found a large piece of metal stuck to the "lifeguard" - which protects the wheels - underneath the driver's cab.
Mis Bryan said: "In her view, if the train had been travelling at 125mph in all likelihood the train would have been derailed."
The driver tried to unsuccessfully to remove the object and had to wait for engineers to cut it free. The object was later identified as a signal wedge taken from the Ferriby to Goole signalling project, the court heard.
'Big enough to derail train'
A technical riding inspector who was one of the engineers attending the scene said if the lifeguard "hadn't done its job" the signal wedge was "big enough and heavy enough to potentially derail the train".
As well as causing damage to the infrastructure of the Saddlethorpe crossing when the signal wedge was dragged along, there was service disruption to 27 trains leading to delays of "1,491 minutes", and costing Network Rail £69,622 in compensation to passengers.
CCTV footage later recovered from the station showed Martin getting off the Northern train service from Goole to Gilberdyke at 1.49pm, and walking down the platform to place an item on the track.
At 5pm on December 29, a driver on another Hull Trains service heading to Hull from Kings Cross was passing through Gilberdyke when she saw what she thought was a "large rock" on the line in front of her.
She also could not avoid hitting the object despite braking. The driver stopped the train and alerted a signalman, and because everything in the cab appeared to be in good working order it was decided to continue the journey after five minutes.
But when a fitter examined the train at Hull station there was more damage than initially thought as the lifeguard had been bent. This had to be replaced and the train was taken out of service for repairs.
Debris 'flew across platform'
The review of CCTV footage later showed debris "flying across the platform" as the train passed through, and sparks underneath the train. Sparks were also seen from under a TransPennine train travelling through the station at about 4.30pm that day.
The footage also showed Martin on the platform and bending down over a rail. This incident caused a 12-minute delay and cost Network Rail £977 in compensation.
On December 30, Martin approached a man he knew who was sitting in a shelter at the station and asked if he knew what had happened to a fence he had been standing by. The man saw the fence had been repaired after damage and Martin told him "a boulder had gone through the fence".
WATCH how criminals are sentenced
Martin then pointed to a Transit van parked 20 yeards outside the station, and "kept saying he wanted the train to go over the boulder and he was hoping it would hit the van", Miss Bryan said.
The witness said a train did stop after passing through the station, and "that the defendant appeared pleased about that before leaving because his mum had arrived".
The same man said three days earlier, Martin had pointed to a camera at the side of the tracks and said: "They must have put that up there because of me."
At 1.20pm on December 30, the driver of a TransPennine service from Leeds to Hull felt the train strike an object, and thought it was ballast or small bricks. He slowed before carrying on his journey and noticed stone dust on the lifeguard on a scheduled stop at Brough.
CCTV caught Martin placing a "stone" on the rail at 1.13pm that day. He had caused a nine-minute delay and compensation payments totalling £273.
A detective sergeant with British Transport Police was investigating with a uniformed constable, and while travelling to Gilberdyke received a report of a man "pulling wires out of a metal cabinet" at the station.
When they arrived, Martin was being driven out of the station by his mother in a red Ford Fiesta. Martin returned to the station and was seen on a bridge over the track with his hood up.
Suspecting he was responsible, the sergeant went over to Martin as he walked off the bridge and identified himself as a police officer. When the officer tried to grab Martin's arm, he pulled out a knife and "lunged" towards his waist.
The sergeant shouted repeatedly at Martin to drop the knife but he lunged at him again. Although Martin was arrested, the officer suffered a 1cm cut behind his left knee.
'I tried to stab police officer'
In interview, Martin denied placing anything on the tracks. He said he knew the man who approached him was a police officer but he "did not like it when the officer took hold of him as he didn't like being touched.
He said he produced the knife and "intended to use it in self-defence by trying to stab the officer".
Martin, of Manor Drive, Gilberdyke, admitted three offences of obstructing a railway line with intent, assault occasioning actual bodily harm, and possession of an offensive weapon. He had previous convictions for arson and criminal damage.
Stephen Robinson, for Martin, said he had not appreciated the risks of what he had done, and his intention had been to "obstruct" the trains rather than derail them.
He said Martin had become "angry" at being told he could not walk on a path that was used locally as a short-cut.
Martin had a series of complex problems, Mr Robinson said, including the genetic condition karotype 47, XYY; congenital adrenal hyperplasia; learning disorders and attention deficits.
Mr Robinson said the author of a pyschological report "likens the behaviour as a little akin to, on occasion, this defendant can lose his temper a bit like a toddler not getting their own way". He said: "It's clear these problems have bedevilled the defendant through his life."
Jailing Martin for six years, Judge Paul Watson QC, Honorary Recorder of Hull and the East Riding told him: "What you did could have had catastrophic consequences leading to terrible loss of life."
We have launched a new Facebook group to bring you all the latest news from Hull's courts.
Whether it's Crown Court or Magistrates Court, our group will bring you all the latest updates as criminals are brought to justice.
To join our Facebook group, click here.
Follow Hull Live
Our daily newsletter - To get the latest headlines direct to your email inbox every day, click here.
Download our app - You can download our free app for iPhone and iPad from Apple's App Store, or get the Android version from Google Play.
Follow us on Instagram - On the Hull Live Instagram page we share gorgeous pictures of our stunning city - and if you tag us in your posts, we could repost your picture on our page! We also put the latest news in our Instagram Stories. Click here to follow Hull Live on Instagram.