I'm trying to calculate the maintenance time so my program is continuously reading registers to identify the stats and then using a pandas csv register the time when the register == 1 (maintenance in progress) and register = 0 (no maintenance) this way... creating a variable "mantenimiento" to make sure the time is registered only when the maintenance starts or ends saving its value at a column of csv.
regs1 = c.read_holding_registers(230)
mantenimiento = df['col28']
if regs1 == [1] and mantenimiento == 0:
df['col1'] = time.time()
df.to_csv("oee.csv", sep=' ', header=True, index=False, mode='r+')
print(df['col1'])
c.write_multiple_registers(0, [0])
c.write_multiple_registers(5, [10])
mantenimiento = 1
print("Maintenance in progress", mantenimiento)
if regs1 == [0] and mantenimiento == 1:
tiempoparomant = time.time() - df['col1']
df['col2'] = tiempoparomant
minutos = tiempoparomant / 60
segundos = tiempoparomant % 60
df['col2'] = minutos * 60
df['col3'] = df['col3'] + df['col2']
df.to_csv("oee.csv", sep=' ', header=True, index=False, mode='r+')
c.write_multiple_registers(0, [0])
mantenimiento = 0
I was doing it wrong registering time every time that regs1=0 so it has no sense... when added the mantenimiento variable stored at the csv shows me the following error: ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Do you know what can I do to solve this?
There would be any way to register time firs moment when regs1=1 and then wait for regs1=0 to save the time again making the program stop to no loosing time of maintenance during the readings of the stats of registers?
Thank you in advice.