Rule syntax - Hourly pulse counter

Hello, i have created two rules, to register pulses from my electrical meter, and a second rule to generate hourly totals, the first rule is working, but the second doesn’t work because of syntax. (i always seem to have the same difficulty)

var long PulseCounter = 1
var long PulsePrevious = 1

rule "Pulse energy counter"
//////////////////////////////////////////////////////////////////////////////////////////////////
when
    Item NodeEnergy_Pulse received update
then
	logInfo("Pulse Counter=","            ReceivedValue=  YES" ) //########################################################### Send log
	PulseCounter = PulseCounter +1
	logInfo("Pulse Counter=","            Pulse Counter=" +PulseCounter) //########################################################### Send log
end

//////////////////////////////////////////////////////////////////////////////////////////////////
rule "Hourly energy pulse count"
//////////////////////////////////////////////////////////////////////////////////////////////////
when
	Time cron "0 0/1 * 1/1 * ? *" // 20 minutes for testing
	//Time cron "0 0 0/1 1/1 * ? *" // every hour
then
	
var long PulseHour = (PulseCounter.floatValue - NodeEnergy_PulseHour.state as DecimalType)

	logInfo("Pulse Hourly=",">>>>>>>>>>>>>>>>>>>>>>>       Hour  Pulse Counter=" +PulseCounter)     //########################################################### Send log
//	postUpdate(NodeEnergy_PulseHour, (PulseCounter - PulseHour)
	//logInfo("Pulse Hourly=","       Hour  Pulse Counter=" +PulseHour)     //########################################################### Send log
end ````



Can anyone point me in the right direction, i've tried different syntax and layouts, but i can't seem to determine the correct format. 

Thanks in advance

Forgot to include the error…

java.lang.ClassCastException: Cannot cast org.openhab.core.types.UnDefType to org.openhab.core.library.types.DecimalType ````

Or maybe teaching a man to fish instead of giving me a fish… How can i best determine the correct data type that is being used by the rule? For example here it says “Cannot cast org.openhab.core.types.UnDefType” , is there a simpler way to view what the data type is? some command that can be put into a log to “show data type of variable x” or "item x type = " is this possible?