I'm trying to create Totalize runtime and Daily Flow Average and Hourly Flow Average.
New in Ignition
totalizer_tag_path = "[default]Tags1/Totalizer_Tag"
data_tag_path = "[default]Tags1/Flow_Data_Tag"
def update_totalizer(tag, previousValue, value, quality, timestamp):
# Get the current totalizer value
current_totalizer = system.tag.readBlocking(totalizer_tag_path).value
system.util.getLogger(current_totalizer)
#current_totalizer = system.tag.read(totalizer_tag_path).value
Calculate the change in data value
data_change = value.value - previousValue.value
type or paste code here
# Log the current values
system.util.getLogger("Totalizer Script").info("Current Totalizer Value: %s", current_totalizer)
system.util.getLogger("Totalizer Script").info("Data Change: %s", data_change)
# Update the totalizer value
new_totalizer = current_totalizer + data_change
system.tag.write(totalizer_tag_path, new_totalizer)
system.util.getLogger("Totalizer Script").info("New Totalizer Value: %s", new_totalizer)
# Subscribe to the data tag changes
`system.tag.writeBlocking(data_tag_path, update_totalizer)`