Thank you for all this but my original question is actually what Real time trains display and an other 3rd party show in the screen shot I added . I understand the Term Headcode and what it is (as in the train ID be it 2 or 4 characters) but this Headcode (see screenshot) is something different and not always shown, this is refering to something different.
The screen shot quite clearly shows the 1V62 as Identity to many this is what you are referring to as the Headcode (commonly used), but on the screen shot you will see the word Headcode or TOC Headcode further down from the 1V62. On my 1st screen shot it shows as 1710. Some have said this is a retail thing for seat reservations. This is what I'm really trying to find out, where does this come from and how I can find a connection between this number and the Train UID and the signaling id which would be as you have mentioned what we all know as the Headcode 1V62.
The four digits you refer to are the Retail Service ID. They are unique on any given day for
most TOCs, but some TOCs (e.g. Heathrow Express) do duplicate them. They are the code used to identify trains when making seat reservations and thus controlling the sale and price of Advance tickets.
Whilst there are databases where you can search by UID to find the headcode and RSID and vice versa, there is no direct link between the RSID, UID or headcode.
TOCs do tend to follow a pattern when deciding what RSID to use, for example using a certain 'series' for each line/service group and then using odd increments in one direction and evens in the other direction.
But the same RSID could refer to differently timed trains (and thus headcodes) on different days. SWR use the old 'Southern Region' route codes as the first two digits of their RSIDs.
The UID, meanwhile, is simply an internal identification code allocated by Network Rail. There can only be one schedule with a given UID departing on a given date. It's allocated whenever a train is first bid, based on alphabetic order of the headcodes (including the last two letters that aren't published) if several schedules are bid at once, as happens with each new timetable.
Schedules can be added in at different stages which can lead to consecutive trains having UIDs that are seemingly incongruous. But there's no great significance to it, it's just an internal reference number.