Added event counter to PLC Code

The system now shuts off when X number of events have ocured.