I fail to understand why you all want to re-invent the wheel.
Have done it in a PLC but it wasted so much of my time I went back to using generator controllers.
Use the easYgen 3100 these days or GCP if I require soft transfer.
My time is far to valuable to waste re-inventing the wheel.
Besides which in Australia specifications general;ly will not let you use a PLC for that application.