I would suggest that you draw some form of a software flow diagram to determine the different states of your application(Start Generator) for such applications a state machine, I would think is the best ways of getting the job done, as there is a couple of states involved and you have to react to th...