Skip to content

BryggansBryggeri/bryggio

Repository files navigation

BryggIO

BRYGGANS BRYGGERI's very own brewery control software.

Currently under developement, but usable. The goal is to develop a stand-alone pub-sub backend with which any client can communicate and thereby control the brewery hardware. See ARCHITECTURE.md for a project overview.

Installation

Before the first release we will not publish any binaries, see Build from source. Note, that the there is a released version on Github, but it is mainly for prototyping the CLI install option.

Build from source

  • Install rust and Cargo. Rust and Cargo are provided by official distributions.

  • Build targets bryggio-supervisor, bryggio-cli from source.

    git clone git@github.com:BryggansBryggeri/bryggio.git bryggio
    cd bryggio
    cargo build

Install NATS server

either from the website or by running (rather buggy right now)

cargo run --bin bryggio-cli install

Installation is a fancy word for simply downloading the nats-server executable. Do this by manual download from the link above, or the bryggio-cli install command. The latter figures out what OS you are running, and downloads the corresponding executable. This is the preferred method, the end-goal is to use the CLI for a complete install of the entire BryggIO app. It is though -- as stated -- still in development.

Configuration

The bryggio-supervisor executable expects a JSON file which specifies general settings, and importantly the path to the nats-server binary (that you downloaded in the install step). See sample-bryggio.json for an example.

Run

The bryggio-supervisor, starts up a nats-server in a separate process and then runs a supervisor pub-sub client which, listening to special command subjects, starts and stops other clients like sensors, actors and controllers.

There are two ways to run the supervisor:

# This will build the executable (i.e. recompile if there are code changes) and run it
cargo run --bin bryggio-supervisor -- run <path_to_bryggio_config_file>
# ... while this will simply run the executable created in the build step.
./target/<profile>/bryggio-supervisor run <path_to_bryggio_config_file>

Build for and run on rbpi

We use cross for cross compilation. To use it, install and setup Docker then install cross.

You can get Docker from here, if you're on a Debian-like distro this will perform the setup:

sudo apt install docker.io
sudo systemctl start docker
sudo chmod 666 /var/run/docker.sock

Install cross through Cargo:

cargo install cross

Build the required executables

# In the bryggio repo root
cross build --target=armv7-unknown-linux-musleabihf --release

Move the resulting executable (target/armv7-unknown-linux-musleabihf/<build-mode>/bryggio-supervisor) and rbpi-nats-server (you need to download the Arm version of it) to the rbpi, as well as the config files listed in Configuration

On the rbpi run:

sudo ./bryggio-supervisor <path_to_bryggio_config_file>
# E.g.:
# sudo ./bryggio-supervisor run sample-bryggio.toml

sudo is required for GPIO manipulation.

Docs

The documentation is generated by running

cargo doc --document-private-items --no-deps --open

Issues/Road map

  • Asynchronicity: This application is async. in nature; sensors publish measurements at semi-random interval, triggering controllers to compute a new signal, which actors react to. The entire design would be much more intuitive if we managed to make it async. We have done some minor work exploring async. but much more remain to be done here, see Tracking issue: Async.
  • Permanent data logging: Currently, no data is stored. We will start out with some simple, writing to file and from there explore proper database options, see db tracking issue.
  • BryggIO protocol: The system of subjects that structure the communication have grown organically. Some work should be dedicated to create a more principled protocol, see the issue.
  • 1.0 version: For a more detailed version, see the Github project.