what is the different between an electric motor and electric generator in terms of function