in perspective
Cannot repeatedly call scripts with parameters, and everytime after saving the project, the global variables of the script will be reset to zero, and the output value will also be zero
import time
total = 0
tempa = 0
oldtotal = 0
def calculate_downtime(start):
global total, tempa, start_time, end_time,oldtotal
if start == False and tempa == 0:
start_time = time.time()
tempa = 1
elif start == True:
tempa = 0
if tempa == 1:
end_time = time.time()
total = (end_time - start_time) + oldtotal
return total/60
elif tempa == 0:
oldtotal = total
return oldtotal/60
This is a script for calculating cumulative downtime, accumulating when start is 1 and stopping when start is 0