Calculation of active power and apparent power through sampling
With a non-linear load, to calculate the real power, multiply instantaneous current and voltage samples. Average the positive and negative values and divide by the number of samples to determine the real power. You could work with the fundamental components of the waveform, but it might be difficult to get the phase information.