If you own the machine, the OEM or PLC manufacturer has a legal "master key." This is the only risk-free method.

Your action plan during a lockout: