Skip to content

Commit

Permalink
updated backsplash, emulate water in / out
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu authored and root committed Mar 14, 2024
1 parent 9a2436b commit d64a03e
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 42 deletions.
76 changes: 40 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,49 @@ Chronos is a boiling/cooling water system working on Raspberry Pi. Chronos has a

![Alt text](http://i.imgur.com/8II1ydG.png "A screenshot of the Chronos web interface")
### Summary of set up ###
#### Installation ####
To install the latest version Chronos from Bitbucket repo enter the following command:

`# sudo pip install git+https://bitbucket.org/quarck/chronos.git`
#### Installation with Docker ####
This repository consists of a docker container that has all the dependencies and simulators built-in. Just run using these two commands:
```
sudo docker-compose up --build -d chronos
sudo docker restart chronos
```
### SIMULATORS

Chronos talks to the following components on the RPI.

These devices are specified in data_files/chronos_config.json
- Boiler via modbus connected to /dev/ttyUSB0
- Chillers via relays talking to serial port /dev/ttyACM0
- Relays to the Chillers via /tmp/pty0 and /tmp/pty1
- Water temperature in and out via /tmp/water_in and /tmp/water_out

To install a certain version from a tag, commit or branch enter this:
#### Test Chillers
The relays to the chillers are emulated using socat. socat creates virtual pty devices that can respond as serial ports.
The following command in entrypoint.sh brings up a virtual ptyp1 device to respond to relays
```
socat -d -d PTY,link=/tmp/ptyp1,raw,echo=0 PTY,link=/tmp/ttyp1,raw,echo=0 &
```

`# sudo pip install git+https://bitbucket.org/quarck/chronos.git@commit|tag|branch`
#### Test Boiler
The following commands in entrypoint.sh bring up a virtual ptyp0 device and then runs working-sync-server to emulate the boiler.
```
socat -d -d PTY,link=/tmp/ptyp0,raw,echo=0 PTY,link=/tmp/ttyp0,raw,echo=0 &
python2 working-sync-server.py /tmp/ttyp0 &
```
Actual device to simulator mappings are as follows, the chronos_config.json needs to be changed on the automation QA server to run as follows:
Boiler --> /dev/ttyUSB0 --> /tmp/ptyp0
Chillers --> /dev/ttyACM0 --> /tmp/ptyp1

#### Test water temperature
In order to provide a test incoming water temperature, use:
```
echo -e "YES\nt=100" > /tmp/water_in
```
In order to provide a test out water temperature, use:
```
echo -e "YES\nt=140" > /tmp/water_out
```

#### Python packages dependencies ####

Expand Down Expand Up @@ -79,37 +114,6 @@ https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-r
- sudo apt update
- sudo apt install docker.io docker-compose -y

### SIMULATORS

Chronos talks to the following components on the RPI.

These devices are specified in data_files/chronos_config.json
- Boiler via modbus connected to /dev/ttyUSB0
- Chillers via relays talking to serial port /dev/ttyACM0

In order to simulate the above devices, we use the following two components:
- socat
- working-sync-server.py

The relays to the chillers are emulated using socat. socat creates virtual pty devices that can respond as serial ports.
The following command in entrypoint.sh brings up a virtual ptyp1 device to respond to relays
```
socat -d -d PTY,link=/tmp/ptyp1,raw,echo=0 PTY,link=/tmp/ttyp1,raw,echo=0 &
```

The following commands in entrypoint.sh bring up a virtual ptyp0 device and then runs working-sync-server to emulate the boiler.
```
socat -d -d PTY,link=/tmp/ptyp0,raw,echo=0 PTY,link=/tmp/ttyp0,raw,echo=0 &
python2 working-sync-server.py /tmp/ttyp0 &
```

Actual device to simulator mappings are as follows, the chronos_config.json needs to be changed on the automation QA server to run as follows:

Boiler --> /dev/ttyUSB0 --> /tmp/ptyp0

Chillers --> /dev/ttyACM0 --> /tmp/ptyp1

-----------------------------------------------------



9 changes: 6 additions & 3 deletions chronos/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
from chronos.lib.root_logger import root_logger as logger
from apscheduler.schedulers.background import BackgroundScheduler

WEATHER_URL = "https://test.barnreportpro.com/api/live_data/divy"
#WEATHER_URL = "https://test.barnreportpro.com/api/live_data/divy"
WEATHER_URL = "https://barnreportpro.com/api/live_data/tlco"


WEATHER_HEADERS = {
"Authorization": "Bearer -_--8-_FLa0Ny995DE__--Hd._L6si4-CB3W-_.O4D_x.UOyP9n-zx_n9sp10H07cC-_.7g-5s96.CJ7tU.E699K8..A8_7-l9hHs._b93_9_.X.v04.5erQbM.-7_6R"
}
Expand Down Expand Up @@ -312,8 +315,8 @@ def __init__(self):

@staticmethod
def _read_temperature_sensor(sensor_id):
return 50
device_file = os.path.join("/sys/bus/w1/devices", sensor_id, "w1_slave")
#return 50
device_file = sensor_id #os.path.join("/sys/bus/w1/devices", sensor_id, "w1_slave")
while True:
try:
with open(device_file) as content:
Expand Down
6 changes: 5 additions & 1 deletion chronos/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@
}
.block-margin-top {
margin-top: 25px;
}
}

body{
background-color: #daba7f;
}
6 changes: 4 additions & 2 deletions data_files/chronos_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
"unit": 1
},
"sensors": {
"in_id": "28-00000677d509",
"out_id": "28-0000067841b0"
"in_id": "/tmp/water_in",
"_in_id": "28-00000677d509",
"out_id": "/tmp/water_out",
"_out_id": "28-0000067841b0"
},
"files": {
"log_path": "/var/log/chronos/chronos.log"
Expand Down
5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ sudo chown -R pi:pi /home/pi
sleep 2
mkdir /var/log/uwsgi
/usr/local/bin/uwsgi --ini /etc/uwsgi/apps-enabled/socketio_server.ini --pidfile /var/run/uwsgi/uwsgi-socketio.pid --daemonize /var/log/uwsgi/uwsgi-socketio.log

# Added to simulate water temperature in and out
echo -e "YES\nt=100" > /tmp/water_in
echo -e "YES\nt=150" > /tmp/water_out

service uwsgi start
service nginx start
service chronos start
Expand Down

0 comments on commit d64a03e

Please sign in to comment.