# \[ANN\] Abaco.jl - the abacus of a stream of variables

**URL:** <https://discourse.julialang.org/t/ann-abaco-jl-the-abacus-of-a-stream-of-variables/71516>\
**Category:** Package Announcements\
**Tags:** package\
**Created:** [November 15, 2021, 5:43pm UTC](https://discourse.julialang.org/t/ann-abaco-jl-the-abacus-of-a-stream-of-variables/71516 "2021-11-15T17:43:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![attdona](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/attdona/32/15859_2.png) [@attdona](https://discourse.julialang.org/u/attdona)\
**Post date:** [November 15, 2021, 5:43pm UTC](https://discourse.julialang.org/t/ann-abaco-jl-the-abacus-of-a-stream-of-variables/71516/1 "2021-11-15T17:43:34Z")

</div>

[Abaco.jl](https://github.com/attdona/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

```julia

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)

```
