-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Changelist <!-- Give a list of the changes covered in this PR. This will help both you and the reviewer keep this PR within scope. --> ### Testing Done <!-- Outline the testing that was done to demonstrate the changes are solid. This could be unit tests, integration tests, testing on the car, etc. Include relevant code snippets, screenshots, etc as needed. --> ### Resolved Tickets <!-- Link any tickets that this PR resolves. --> --------- Co-authored-by: Ashli <[email protected]> Co-authored-by: Ashli Forbes <[email protected]>
- Loading branch information
1 parent
44a328f
commit 73e0609
Showing
87 changed files
with
3,536 additions
and
6,579 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
import serial | ||
|
||
|
||
def receive_data(): | ||
ser = serial.Serial('/dev/ttyUSB0', baudrate=57600, stopbits=1, timeout=100) | ||
ser = serial.Serial("/dev/ttyUSB0", baudrate=57600, stopbits=1, timeout=100) | ||
|
||
tick_count = 0 | ||
|
||
try: | ||
while True: | ||
line = ser.readline(12).decode().strip() | ||
line = ser.readline(12).decode().strip() | ||
print(line) | ||
tick_count+=1 | ||
tick_count += 1 | ||
|
||
except KeyboardInterrupt: | ||
# Close the serial port on Ctrl+C | ||
ser.close() | ||
print(tick_count) | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
receive_data() | ||
receive_data() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
import serial | ||
import time | ||
|
||
|
||
def generate_data_rate(target_data_rate_kbps): | ||
ser = serial.Serial('/dev/ttyUSB0', baudrate=57600, stopbits=1, timeout=100) | ||
ser = serial.Serial("/dev/ttyUSB0", baudrate=57600, stopbits=1, timeout=100) | ||
|
||
target_data_rate_bps = target_data_rate_kbps * 1000 | ||
delay = 80 / target_data_rate_bps | ||
tick_count = 0 | ||
|
||
try: | ||
while True: | ||
msg = str(int(tick_count)) +'\n' | ||
ser.write(msg) #10 characters at 8 bits each | ||
msg = str(int(tick_count)) + "\n" | ||
ser.write(msg) # 10 characters at 8 bits each | ||
# 80 bits | ||
|
||
time.sleep(delay) | ||
tick_count+=1 | ||
tick_count += 1 | ||
|
||
except KeyboardInterrupt: | ||
# Close the serial port on Ctrl+C | ||
ser.close() | ||
print(tick_count) | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
target_data_rate_kbps = 10 | ||
generate_data_rate(target_data_rate_kbps) | ||
|
||
generate_data_rate(target_data_rate_kbps) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.log |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
""" | ||
This module is responsible for the process of the application. It is the main module of the application. | ||
""" | ||
|
||
# from http_app import app as http_app | ||
|
||
|
||
__all__ = ["signal_util", "influx_handler", "definitions"] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dashboards.json |
9 changes: 9 additions & 0 deletions
9
software/tracksight/backend/app/process/flask_apps/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
""" | ||
This module contains the Flask applications that are used to handle requests from the client. | ||
""" | ||
|
||
__all__ = [ | ||
"database_app", | ||
"http_app", | ||
"socket_app", | ||
] |
86 changes: 86 additions & 0 deletions
86
software/tracksight/backend/app/process/flask_apps/database_app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
""" | ||
This module contains the flask app for the database. | ||
""" | ||
|
||
import json | ||
import os | ||
|
||
from flask import request, jsonify, Blueprint | ||
|
||
DB_JSON_PATH = "./dashboards.json" | ||
|
||
|
||
# HELPERS | ||
def read_json_file(): | ||
""" | ||
:return: | ||
""" | ||
if not os.path.exists(DB_JSON_PATH): | ||
return {} # TODO respond with some error | ||
with open(DB_JSON_PATH) as file: | ||
return json.load(file) | ||
|
||
|
||
def write_json_file(data): | ||
""" | ||
:param data: | ||
""" | ||
with open(DB_JSON_PATH, "w") as file: | ||
json.dump(data, file, indent=4) | ||
|
||
|
||
app = Blueprint("database_app", __name__) | ||
|
||
|
||
@app.route("/get-data", methods=["GET"]) | ||
def get_data(): | ||
""" | ||
:return: | ||
""" | ||
path = request.args.get("path") | ||
data = read_json_file() | ||
path_data = data.get(path, "No data found") | ||
return jsonify(path_data) | ||
|
||
|
||
@app.route("/save-data", methods=["POST"]) | ||
def save_data(): | ||
""" | ||
:return: | ||
""" | ||
content = request.json | ||
data_to_save = content["data"] | ||
data = read_json_file() | ||
# may want to add error handling when there is duplicate name? | ||
name = data_to_save["dbname"] | ||
data["dashboards"][name] = data_to_save | ||
write_json_file(data) | ||
return jsonify({"message": "Data saved successfully"}) | ||
|
||
|
||
@app.route("/delete-data", methods=["POST"]) | ||
def delete_data(): | ||
""" | ||
:return: | ||
""" | ||
content = request.json | ||
path = content["path"] | ||
print(path) | ||
data = read_json_file() | ||
|
||
path_parts = path.split("/") | ||
if ( | ||
len(path_parts) == 2 | ||
and path_parts[0] == "dashboards" | ||
and path_parts[1] in data.get("dashboards", {}) | ||
): | ||
del data["dashboards"][path_parts[1]] | ||
write_json_file(data) | ||
return jsonify({"message": "Data deleted successfully"}) | ||
else: | ||
return jsonify({"error": "Data not found"}), 404 |
Oops, something went wrong.