The simple answer is an H bridge sensor.
But first take a simplistic view with a couple of resistors in the transmission line between the generator and the load,
a---[Rtop]---c
b--[Rbot]---d
If the generator is connected on AB and the load on CD it can quickly be seen that the voltage across AB will be marginaly greater than CD so you know what direction the power is going but importantly you can measure a few things like load current / power as well.
Obviously if you put the load on AB and the generator on CD the situation would be reversed and you would know which direction power is flowing.
You dont actually need resistors to do this you can replace the resistors with coils on a transformer frame and add the other parts of the bridge to get out phase angle etc for measuring power factor as well if you are so declined measure power lost by the load to earth that causes an imbalance that can be used to trip the supply.