Skip to content

Commit

Permalink
MariaDB removed
Browse files Browse the repository at this point in the history
  • Loading branch information
drbacke committed Oct 6, 2024
1 parent b8d07db commit 1621528
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 46 deletions.
4 changes: 0 additions & 4 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
]


# Optional
db_config = {"user": "eos", "password": "eos", "host": "mariadb", "database": "eos"}


def get_start_enddate(prediction_hours=48, startdate=None):
############
# Parameter
Expand Down
43 changes: 1 addition & 42 deletions flask_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

# Sets the Matplotlib backend to 'Agg' for rendering plots in environments without a display
matplotlib.use("Agg")
from datetime import timedelta

import pandas as pd
from flask import Flask, jsonify, redirect, request, send_from_directory, url_for
Expand All @@ -18,11 +17,10 @@
from modules.class_load_corrector import LoadPredictionAdjuster
from modules.class_optimize import isfloat, optimization_problem
from modules.class_pv_forecast import PVForecast
from modules.class_soc_calc import BatteryDataProcessor
from modules.class_strompreis import HourlyElectricityPriceForecast

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from config import db_config, get_start_enddate, optimization_hours, prediction_hours
from config import get_start_enddate, optimization_hours, prediction_hours

app = Flask(__name__)

Expand All @@ -31,45 +29,6 @@
)


@app.route("/soc", methods=["GET"])
def flask_soc():
# MariaDB connection details
config = db_config

# Set parameters for SOC (State of Charge) calculation
voltage_high_threshold = 55.4 # 100% SoC
voltage_low_threshold = 46.5 # 0% SoC
current_low_threshold = 2 # Low current threshold for both states
gap = 30 # Time gap in minutes for grouping maxima/minima
bat_capacity = 33 * 1000 / 48 # Battery capacity in watt-hours

# Define the reference time point (3 weeks ago)
zeitpunkt_x = (datetime.now() - timedelta(weeks=3)).strftime("%Y-%m-%d %H:%M:%S")

# Instantiate BatteryDataProcessor and perform calculations
processor = BatteryDataProcessor(
config,
voltage_high_threshold,
voltage_low_threshold,
current_low_threshold,
gap,
bat_capacity,
)
processor.connect_db()
processor.fetch_data(zeitpunkt_x)
processor.process_data()
last_points_100_df, last_points_0_df = processor.find_soc_points()
soc_df, integration_results = processor.calculate_resetting_soc(
last_points_100_df, last_points_0_df
)
# soh_df = processor.calculate_soh(integration_results) # Optional State of Health calculation
processor.update_database_with_soc(soc_df) # Update database with SOC data
# processor.plot_data(last_points_100_df, last_points_0_df, soc_df) # Optional data visualization
processor.disconnect_db() # Disconnect from the database

return jsonify("Done")


@app.route("/strompreis", methods=["GET"])
def flask_strompreis():
# Get the current date and the end date based on prediction hours
Expand Down

0 comments on commit 1621528

Please sign in to comment.