detecting sleep/awake

Hello,
MacOSlibrary contains code to know if a computere is sleeping or awake.
I’d appreciate if somebody could show me how to make use of it.
I do not need to be notified by any window showing up; just the result of the function.
In pseudo code:
if isSleeping then return
or
if isAwake then
//do something
end if

Thanks,
Carlo