The invention consists of a relay device including: at least one mode change device for changing the relay device from a normal mode to a test mode; an interface for receiving test script from a source; a waveform generator for running the test script received from the source and outputting test results, wherein the source signals the relay to switch from the normal mode to the test mode; a logic device for providing a logic output to the waveform generator when the relay is in test mode and setting the waveform generator to a predetermined value; a data preparation component for calculating current and voltage samples from power system input data; and a data processor for performing phasor estimation and frequency tracking of the current and voltage samples from the power system input data and performing protection calculations to determine the output of the relay.