Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitIgnore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
from raspbian/systemd:latest
FROM --platform=linux/arm raspbian/systemd:latest
workdir /home/chronos

RUN echo "deb http://legacy.raspbian.org/raspbian stretch main contrib non-free rpi" > /etc/apt/sources.list
run apt-get update -y && apt-get install python2.7 python-pip cron sqlite3 nginx libssl-dev vim -y
run useradd pi
run mkdir -p /home/pi/chronos_db
run CFLAGS="-I/usr/include/openssl" && LDFLAGS="-L/usr/lib/arm-linux-gnueabihf" && UWSGI_PROFILE_OVERRIDE=ssl=true && pip install -trusted-host pypi.org --trusted-host files.pythonhosted.or -I --no-binary=:all: --no-cache-dir uwsgi==2.0.20
run pip install flask pyserial pymodbus APScheduler==3.6.3
RUN pip install flask==1.1.4 flask-cors==3.0.10 pyserial pymodbus APScheduler==3.6.3
run pip install --upgrade setuptools
run pip install sqlalchemy python-socketio==0.4.1 socketIO_client six==1.15.0
run pip install gevent
run pip install python-engineio==3.11.2 python-socketio==4.4.0
run pip install gevent-websocket


# Try not to touch the above since installing gvenet takes too long
# Install python3 and run the virtual serial emulators
run apt-get install python3 python3-pip socat -y



copy . .
copy chronos.sql /home/pi/chronos_db/
run python setup.py install
run rm /etc/nginx/sites-enabled/default
run ln -s /etc/nginx/sites-enabled/chronos_conf /etc/nginx/sites-enabled/default
#run /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
RUN pip install uwsgi
run /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
run chmod +x entrypoint.sh

entrypoint [ "./entrypoint.sh" ]

77 changes: 77 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,83 @@

Chronos is a boiling/cooling water system working on Raspberry Pi. Chronos has a web interface to control the system and tracking for the state.

![Alt text](http://i.imgur.com/8II1ydG.png "A screenshot of the Chronos web interface")
## Frontend and Backend Separation

### Overview

The Chronos project has been refactored to separate the frontend and backend components. The backend operates as a standalone service providing APIs, while the frontend is handled separately.

### A screenshot of API response of Chronos
![Alt text](https://miro.medium.com/v2/resize:fit:720/format:webp/1*p5MTHzrfaLYycSmZFSdmoA.png "A screenshot of API response of Chronos")

### API Endpoints

The backend provides the following API endpoints:

#### Base URL
- **Base URL**: `http://<backend-server-url>:90`

#### Endpoints

- **Get System Data**:
- **URL**: `/`
- **Method**: `GET`
- **Description**: Retrieves the current system data, including temperature settings and mode status.
- **Response**: JSON object containing system data.

- **Get Rendered Season Templates**:
- **URL**: `/season_templates`
- **Method**: `GET`
- **Description**: Retrieves data for rendering season templates.
- **Response**: JSON object with system results, activity stream, and efficiency details.

- **Download Log**:
- **URL**: `/download_log`
- **Method**: `GET`
- **Description**: Downloads the system log as a CSV file.
- **Response**: CSV file download.

- **Update Settings**:
- **URL**: `/update_settings`
- **Method**: `POST`
- **Description**: Updates system settings based on provided form data.
- **Request Body**: Form data with settings to update.
- **Response**: JSON object with the updated form data.

- **Switch Mode**:
- **URL**: `/switch_mode`
- **Method**: `POST`
- **Description**: Switches the system mode between winter and summer.
- **Request Body**: Form data with the new mode (`TO_WINTER` or `TO_SUMMER`).
- **Response**: JSON object with error status and mode switch lockout time.

- **Update Device State**:
- **URL**: `/update_state`
- **Method**: `POST`
- **Description**: Updates the state of a specific device based on provided form data.
- **Request Body**: Form data with device number and manual override value.
- **Response**: Empty response.

- **Winter Mode Data**:
- **URL**: `/winter`
- **Method**: `GET`
- **Description**: Retrieves data specific to the winter mode.
- **Response**: JSON object with system data.

- **Summer Mode Data**:
- **URL**: `/summer`
- **Method**: `GET`
- **Description**: Retrieves data specific to the summer mode.
- **Response**: JSON object with system data.

- **Chart Data**:
- **URL**: `/chart_data`
- **Method**: `GET`
- **Description**: Retrieves data for charts.
- **Response**: JSON object containing chart data.


![Alt text](http://i.imgur.com/8II1ydG.png "A screenshot of the Chronos web interface")
### Summary of set up ###

Expand Down
29 changes: 6 additions & 23 deletions chronos/chronos.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ def get_chronos_status():
@app.route("/season_templates")
def get_rendered_season_templates():
data = get_data()
form = render_template("form.html", data=data)
stats = render_template("stats.html", data=data)
system_map = render_template("system_map.html", data=data)
data = {
"form": form,
"stats": stats,
"system_map": system_map
}
return jsonify(data)


Expand Down Expand Up @@ -104,16 +96,7 @@ def switch_mode():
@app.route("/")
def index():
data = get_data()
mode = int(data["results"]["mode"])
if mode == WINTER:
resp = render_template("winter.html", data=data)
elif mode == SUMMER:
resp = render_template("summer.html", data=data)
elif mode == TO_WINTER:
resp = render_template("to_winter.html", data=data)
elif mode == TO_SUMMER:
resp = render_template("to_summer.html", data=data)
return resp
return jsonify(data)


@app.route("/update_state", methods=["POST"])
Expand All @@ -127,14 +110,14 @@ def update_state():

@app.route("/winter")
def winter():
data = get_data()
return render_template("winter.html", data=data)
data = get_data()
return jsonify(data)


@app.route("/summer")
def summer():
data = get_data()
return render_template("summer.html", data=data)
data = get_data() # Get data from the get_data function
return jsonify(data) # Use jsonify to return JSON response


@app.route("/chart_data")
Expand All @@ -149,4 +132,4 @@ def chart_data():


if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000, debug=True)
app.run(host='0.0.0.0', port=5000, debug=True)
33 changes: 0 additions & 33 deletions chronos/static/css/main.css

This file was deleted.

Binary file removed chronos/static/images/Boiler-Cold.png
Binary file not shown.
Binary file removed chronos/static/images/Boiler-Hot.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/Boiler/Boiler-OFF.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/Boiler/Boiler-ON.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/Boiler/Chiller-OFF.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/Boiler/Chiller-ON.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/Boiler/arrow1.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/Boiler/arrow2.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/Boiler/arrow3.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/Boiler/arrow4.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/DBWEB/DFDBF.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/DBWEB/DFDBO.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/DBWEB/DODBF.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/DBWEB/DODBO.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/GPIO/GPIOF.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/GPIO/GPIOO.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/Logo.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed chronos/static/images/Icons/MainImage/OCIC.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/MainImage/OCIH.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/MainImage/OHIC.png
Binary file not shown.
Binary file removed chronos/static/images/Icons/MainImage/OHIH.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed chronos/static/images/Icons/Manual/Auto.png
Diff not rendered.
Binary file removed chronos/static/images/Icons/Manual/OFF.png
Diff not rendered.
Binary file removed chronos/static/images/Icons/Manual/ON.png
Diff not rendered.
Binary file removed chronos/static/images/Icons/TINTOUT/TFTF.png
Diff not rendered.
Binary file removed chronos/static/images/Icons/TINTOUT/TFTO.png
Diff not rendered.
Binary file removed chronos/static/images/Icons/TINTOUT/TOTF.png
Diff not rendered.
Binary file removed chronos/static/images/Icons/TINTOUT/TOTO.png
Diff not rendered.
Binary file removed chronos/static/images/Icons/WinterSummer/SOff.png
Diff not rendered.
Binary file removed chronos/static/images/Icons/WinterSummer/SOn.png
Diff not rendered.
Binary file removed chronos/static/images/Icons/WinterSummer/WOff.png
Diff not rendered.
Binary file removed chronos/static/images/Icons/WinterSummer/WOn.png
Diff not rendered.
5 changes: 0 additions & 5 deletions chronos/static/images/Icons/bootstrap/bootstrap/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion chronos/static/images/Icons/bootstrap/bootstrap/CNAME

This file was deleted.

14 changes: 0 additions & 14 deletions chronos/static/images/Icons/bootstrap/bootstrap/CONTRIBUTING.md

This file was deleted.

Loading