gen: only send state-changes if the change occur.

This prevents a flood of messages in the logs (and syskit).
I recognized oftten that user simply call the state(FOO) function
independently if a change is needed.
This commit will only send the events if the new state is different than
the old one.