Abaco.jl tackles the issue of real-time calculation of mathematical expressions by taking the independent variables from a periodic stream and emitting results as soon as formulas become computables.
This is a preview version, where I made an effort to keep Abaco minimal and simple.
A starting ground base to eventually evolve more advanced features.
A simple example
using Abaco
# Initialize the abaco with a time interval of 5 minutes.
abaco = abaco_init(width=300) do timestamp, device_name, formula, value, inputs
@info "[$device_name] $formula = $value (ts=$timestamp)"
end
# Add formulas
add_formula!(abaco, "area = x*y")
add_formula!(abaco, "volume = x*y*z")
add_formula!(abaco, "z*exp(y-1)")
# Start of values feeding.
# Simulates both random timestamps and time of arrival.
sn = "mysensor"
ts = 1636575600 # seconds from epoch
# The first data message,
# for example a JSON string from a broker ...
msg = Dict("ts" => ts, "sn" => sn, "x" => 3)
add_values!(abaco, ts, sn, msg)
# Time flows and y value marked with timestamp ts is received
# area is computable
add_value!(abaco, ts, sn, "y", 2)
# [ Info: [mysensor] area = 6 (ts=1636575600)
# The z value marked with a timestamp included in the
# interval [start_time, start_time + width) is received:
# The volume and the formula "z*exp(y-1)" are computable.
add_value!(abaco, ts+150, sn, "z", 4)
# [ Info: [mysensor] volume = 24 (ts=1636575600)
# [ Info: [mysensor] z*exp(y-1) = 10.87312731383618 (ts=1636575600)