diff --git a/README.md b/README.md index e30ff7a..05d39cc 100644 --- a/README.md +++ b/README.md @@ -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 #### @@ -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 - ------------------------------------------------------ diff --git a/chronos/lib/__init__.py b/chronos/lib/__init__.py index 4f5a495..923cf9c 100644 --- a/chronos/lib/__init__.py +++ b/chronos/lib/__init__.py @@ -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" } @@ -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: diff --git a/chronos/static/css/main.css b/chronos/static/css/main.css index 8f9ca5a..298177f 100644 --- a/chronos/static/css/main.css +++ b/chronos/static/css/main.css @@ -26,4 +26,8 @@ } .block-margin-top { margin-top: 25px; -} \ No newline at end of file +} + +body{ + background-color: #daba7f; +} diff --git a/data_files/chronos_config.json b/data_files/chronos_config.json index 4815fef..b6a3dd3 100644 --- a/data_files/chronos_config.json +++ b/data_files/chronos_config.json @@ -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" diff --git a/entrypoint.sh b/entrypoint.sh index 5362cae..b6fecf2 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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