Skip to content

Commit

Permalink
some updates
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Sep 23, 2024
1 parent d4cbc38 commit b60d88d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
6 changes: 4 additions & 2 deletions developer-guide/02-important-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ The Pioreactor software works as follows:
One of the Raspberry Pi's is assigned as the "leader", and this hosts most of the services: web server, MQTT broker, database, etc. It also sends commands to any "workers". The leader can also be a worker. Together, the leader and all the workers are called a "cluster". A cluster can be a small as a single leader+worker. See more information about clusters [here](/user-guide/create-cluster).


### Networking
### Networking and communication

The Raspberry Pis communicate through the local network (in more advanced cases, this network is hosted on the leader). Users control the Pioreactor cluster while being on the same network, and accessing the web UI or the command line of the Pioreactors.
The Raspberry Pis / Pioreactors communicate through the local network (in more advanced cases, this network is hosted on the leader). Users control the Pioreactor cluster while being on the same network, and accessing the web UI or the command line of the Pioreactors.

Leaders talk to Pioreactors via http requests between their respective web servers (using lighttpd + Flask, on port 80 by default). Workers send experiment data back to the leader via MQTT (see below). We expect users to control the leader only (using the web interface or CLI), and let the leader control the workers (there are exceptions).


### MQTT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ pioreactor/{unit name or $broadcast}/{experiment name or $experiment}/...
2. If writing a script:

```python
from pioreactor.utils import subscribe, subscribe_and_callback
from pioreactor.pubsub import subscribe, subscribe_and_callback

```
11 changes: 8 additions & 3 deletions developer-guide/20-User interface/01-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ title: Overview
slug: /web-ui-introduction
---


The web UI is hosted on the leader Pioreactor. Here are the details:
Every Pioreactor, either worker or leader, have a web server on them. However, only the leader has an associated website (ex: http://pioreactor.local). Here are the details:

### Web server

Expand All @@ -19,9 +18,15 @@ The default protocol is `http` served on port `80`. To use `https` requires a ce

The backend app is a Flask app, with entry point in `/var/www/pioreactorui/main.fcgi`. The app uses Huey as background workers to perform `pio` tasks, save to disk, etc. Huey is controlled by systemd `huey.service`. The API is [available here](/developer-guide/web-ui-api)

:::info
Both workers and leaders have this backend. However, workers only use expose the `/unit_api/` endpoints. See full list [here](/developer-guide/web-ui-api).
:::

### Frontend

The frontend is a React app, built with Material UI components. The source code is at [pioreactorui_frontend](https://github.com/Pioreactor/pioreactorui_frontend). A lot of the "data" for the frontend comes from YAML files on the RPi's filesystem. For example, all the charts, activities, and automations are defined in their own YAML file in a `contrib` folder on the filesystem. This way, it's easy to add new data to the frontend without having to write new JS.
The frontend is a React app, built with Material UI. The source code is at [pioreactorui_frontend](https://github.com/Pioreactor/pioreactorui_frontend). A lot of the "data" for the frontend comes from YAML files on the RPi's filesystem. For example, all the charts, activities, and automations are defined in their own YAML file in a `contrib` folder on the filesystem. This way, it's easy to add new data to the frontend without having to write new JS.

A lot of the live data


### DNS name resolution to `pioreactor.local`
Expand Down
14 changes: 7 additions & 7 deletions developer-guide/20-User interface/03-example-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,33 @@ This controls a pioreactor called `worker02`, part of a cluster controlled by th
# RUN STIRRING
curl -H "Content-Type: application/json" \
--data '{"options": {"target_rpm": "600"}}' \
-X PATCH "http://leader.local/api/workers/worker02/experiments/Demo%20experiment%206/jobs/stirring/run"
-X PATCH "http://leader.local/api/workers/worker02/jobs/run/job_name/stirring/experiments/Demo%20experiment%206"

# UPDATE STIRRING RPM
curl -H "Content-Type: application/json" \
--data '{"settings": {"target_rpm": "500"}}' \
-X PATCH "http://leader.local/api/workers/worker02/experiments/Demo%20experiment%206/jobs/stirring/update"
-X PATCH "http://leader.local/api/workers/worker02/jobs/update/job_name/stirring/experiments/Demo%20experiment%206"

# STOP STIRRING
curl -X PATCH "http://leader.local/api/workers/worker02/experiments/Demo%20experiment%206/jobs/stirring/stop"
curl -X PATCH "http://leader.local/api/workers/worker02/jobs/stop/job_name/stirring/experiments/Demo%20experiment%206"

# CHANGE LEDS
curl -H "Content-Type: application/json" \
--data '{"options": {"A": 60}}' \
-X PATCH "http://leader.local/api/workers/worker02/experiments/Demo%20experiment%206/jobs/led_intensity/run"
-X PATCH "http://leader.local/api/workers/worker02/jobs/run/job_name/led_intensity/experiments/Demo%20experiment%206"

# START THERMOSTAT AT 35C
curl -H "Content-Type: application/json" \
--data '{"options": {"automation_name": "thermostat", "target_temperature": 35}}' \
-X PATCH "http://leader.local/api/workers/worker02/experiments/Demo%20experiment%206/jobs/temperature_automation/run"
-X PATCH "http://leader.local/api/workers/worker02/jobs/run/job_name/temperature_automation/experiments/Demo%20experiment%206"

# CHANGE TARGET TEMP TO 32C
curl -H "Content-Type: application/json" \
--data '{"settings": {"target_temperature": 32}}' \
-X PATCH "http://leader.local/api/workers/worker02/experiments/Demo%20experiment%206/jobs/temperature_automation/update"
-X PATCH "http://leader.local/api/workers/worker02/jobs/update/job_name/temperature_automation/experiments/Demo%20experiment%206"

# STOP THERMOSTAT
curl -X PATCH "http://leader.local/api/workers/worker02/experiments/Demo%20experiment%206/jobs/temperature_automation/stop"
curl -X PATCH "http://leader.local/api/workers/worker02/jobs/stop/job_name/temperature_automation/experiments/Demo%20experiment%206"

```

5 changes: 1 addition & 4 deletions user-guide/99-common-questions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,17 @@ Yes, follow the instructions [here](https://forum.pioreactor.com/t/creating-stir

### What Raspberry Pi hardware can I use? I see Raspberry Pi 1, 2, 3, 4, 5, A, B, +, Zero - it's confusing!

We've designed the hardware and software to be compatible with any Raspberry Pi that has onboard Wifi and a 40 pin header. That includes (at the time of writing):
We've designed the hardware and software to be compatible with most Raspberry Pis that have an onboard Wifi and a 40 pin header. That includes (at the time of writing):

* Raspberry Pi 3 Model B & B+
* Raspberry Pi 3 Model A+
* Raspberry Pi 4 Model B ² ³
* Raspberry Pi 5 ² ³
* Raspberry Pi Zero W (with headers) ¹
* Raspberry Pi Zero 2 (with headers)


Although you can use any above, **we like the Raspberry Pi 3 B+, Raspberry Pi 4 B 2GB and Raspberry Pi Zero 2**. All have the necessary CPU power and memory for the Pioreactor workload, and are generally easy to source. However, they don't a ethernet connector built-in. So talk to your team about if you need to use ethernet or wifi. If you need ethernet, we like the model RPi 3 B+ or 4 B, or purchase some microUSB-to-ethernet dongles for the RPi Zero 2.

¹ _Raspberry Pi Zero W_ can be used for Pioreactors _as workers_ - we don't recommend them to be your _leader_ (note sure what these terms mean? Here's an introduction to [leader and workers](/user-guide/create-cluster)). As workers, Raspberry Pi Zero W perform just fine, but will respond slower to commands. Note that this does not include the Raspberry Pi Zero _2_ W model, which is fine for all roles.

² You don't need a lot of RAM for the Pioreactor, so we recommend getting the lower RAM RPi if offered a choice. 2GB or less is fine. Also, if you are going to buy a Raspberry Pi 4, you should consider just upgrading for the Raspberry Pi 5 2GB (it's only a few dollars more, and much more performant).

³ These have a USB-C power connector, whereas the other Pis have a microUSB power connector.
Expand Down

0 comments on commit b60d88d

Please sign in to comment.