Not code, but a method
I won't write the code for you, but I'll suggest an approach. I'm assuming that you want a "rolling" hour window - that if the machine was running for 1 hour, then goes down for 15 minutes, and then goes back to running, you want the one-hour display to show 75% for 45 minutes, and then climb back to 100% as rest of the hour ends (assuming no further downtime).
To track when the machine was up and down, you need a shift register. But it's a pain to count the number of bits in a word, so just compare the entering and exitting bits.
Use a self-resetting one minute timer.
Set up a Bit-shift register that is 60 bits long.
Have a register that represents the total number of 'UP' minutes of the machine.
At the end of each minute, examine the status of the machine. If it's UP, set the bit that will enter the shift registers. If down, reset the bit. Perform the bit shift. If the bit exiting the shift register is reset, and the machine is currently running, add one to the Up-minutes register. If the machine is down and the exiting bit is set, subtract one. If the current status and exiting bit (i.e., the machine status one hour ago) match, do nothing - the efficiency hasn't changed.
Althought in theory, the up-minutes register should never be able to be calculated to be greater than 60 or less than 0, error checking wouldn't hurt.
Percentage running time = Up-minutes/0.60
For 8 hours, use a 5-minute timer and a 96 bit shift-register (a 480-bit register would be too much for some PLCs, and I doubt you need more than ±1% accuracy.