Retrofitting Legacy Machines for Industry 4.0