From 1ed60cd00cd9fdcc45dab1f81e00dd723858a430 Mon Sep 17 00:00:00 2001 From: Joshua Drake Date: Fri, 18 Nov 2022 16:06:36 -0600 Subject: Made progress on battery class. --- EVPC.pro | 2 - EVPC.pro.user | 319 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ battery.cpp | 25 ++++- battery.h | 10 +- mainwindow.cpp | 18 ++++ mainwindow.h | 9 ++ mainwindow.ui | 30 +++--- 7 files changed, 397 insertions(+), 16 deletions(-) create mode 100644 EVPC.pro.user diff --git a/EVPC.pro b/EVPC.pro index 2cfb74e..fc1919d 100644 --- a/EVPC.pro +++ b/EVPC.pro @@ -26,11 +26,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target RESOURCES += \ - res.qrc \ resources/res.qrc DISTFILES += \ - res.rc \ resources/boxout-th.png \ resources/connect.png \ resources/connected.png \ diff --git a/EVPC.pro.user b/EVPC.pro.user new file mode 100644 index 0000000..7dccbb4 --- /dev/null +++ b/EVPC.pro.user @@ -0,0 +1,319 @@ + + + + + + EnvironmentId + {254b9858-411f-4b26-805e-af190719973f} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + false + true + false + 0 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + -fno-delayed-template-parsing + + true + Builtin.BuildSystem + + true + true + Builtin.DefaultTidyAndClazy + 4 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 5.12.11 MinGW 64-bit + Desktop Qt 5.12.11 MinGW 64-bit + qt.qt5.51211.win64_mingw73_kit + 0 + 0 + 0 + + 0 + C:\Users\30720.DITCHWITCH\Desktop\Programming\build-EVPC-Desktop_Qt_5_12_11_MinGW_64_bit-Debug + C:/Users/30720.DITCHWITCH/Desktop/Programming/build-EVPC-Desktop_Qt_5_12_11_MinGW_64_bit-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + C:\Users\30720.DITCHWITCH\Desktop\Programming\build-EVPC-Desktop_Qt_5_12_11_MinGW_64_bit-Release + C:/Users/30720.DITCHWITCH/Desktop/Programming/build-EVPC-Desktop_Qt_5_12_11_MinGW_64_bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + C:\Users\30720.DITCHWITCH\Desktop\Programming\build-EVPC-Desktop_Qt_5_12_11_MinGW_64_bit-Profile + C:/Users/30720.DITCHWITCH/Desktop/Programming/build-EVPC-Desktop_Qt_5_12_11_MinGW_64_bit-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + + 25 + + 1 + true + false + true + + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 2 + + ProjectExplorer.CustomExecutableRunConfiguration + + false + true + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/battery.cpp b/battery.cpp index e91b05f..5be2fc8 100644 --- a/battery.cpp +++ b/battery.cpp @@ -3,7 +3,13 @@ Battery::Battery() : activeBattery(batteries[0]), seriesCells(0), - parallelCells(0) + parallelCells(0), + systemVoltage(0), + peakPower(0), + packDischargeRate(0), + packChargeRate(0), + packWeight(0), + packEnergy(0) { } @@ -12,3 +18,20 @@ void Battery::changeBatteryChemistry(int name) { activeBattery= batteries[name]; } + +void Battery::setSystemVoltage(double voltage) +{ + systemVoltage = voltage; +} + +void Battery::setPeakSystemPower(double power) +{ + peakPower = power; +} + +void Battery::calculate() +{ + seriesCells = ceil(systemVoltage/activeBattery.nominalVoltage); + + +} diff --git a/battery.h b/battery.h index c1b7a86..887fb0e 100644 --- a/battery.h +++ b/battery.h @@ -2,6 +2,7 @@ #define BATTERY_H #include +#include "math.h" typedef struct batteryData { QString name; @@ -33,16 +34,23 @@ class Battery : public QObject Q_OBJECT public: Battery(); -private: + + void setSystemVoltage(double voltage); + void setPeakSystemPower(double power); void changeBatteryChemistry(int name); +private: batteryData_t activeBattery; int seriesCells; int parallelCells; + double systemVoltage; + double peakPower; float packDischargeRate; float packChargeRate; float packWeight; float packEnergy; + + void calculate(void); signals: }; diff --git a/mainwindow.cpp b/mainwindow.cpp index 93464f0..6fb2bf5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,11 +1,13 @@ #include "mainwindow.h" #include "ui_mainwindow.h" +#include "QDebug" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); + initializeGraphics(); } MainWindow::~MainWindow() @@ -19,3 +21,19 @@ void MainWindow::on_spinBoxPeakSystemPower_valueChanged(double arg1) } +void MainWindow :: initializeGraphics() +{ + for(auto entry : batteries)ui->comboBoxBatteryChemistry->addItem(entry.name); +} + +void MainWindow::on_comboBoxBatteryChemistry_currentIndexChanged(int index) +{ + m_battery.changeBatteryChemistry(index); +} + + +void MainWindow::on_actionactionSettings_triggered() +{ + +} + diff --git a/mainwindow.h b/mainwindow.h index 9fb7515..0add526 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -2,6 +2,8 @@ #define MAINWINDOW_H #include +#include +#include "battery.h" QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } @@ -18,7 +20,14 @@ public: private slots: void on_spinBoxPeakSystemPower_valueChanged(double arg1); + void on_comboBoxBatteryChemistry_currentIndexChanged(int index); + + void on_actionactionSettings_triggered(); + private: + Battery m_battery; + Ui::MainWindow *ui; + void initializeGraphics(void); }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index e82ca53..c7a03c8 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -20,7 +20,7 @@ Electric Vehicle Parameter Calculator - + :/img/icon.png:/img/icon.png @@ -249,9 +249,6 @@ false - - - @@ -329,11 +326,7 @@ - - - - - + @@ -441,10 +434,11 @@ + - + :/img/boxout-th.png:/img/boxout-th.png @@ -456,7 +450,7 @@ - + :/img/disk_green.png :/img/disk_green.png:/img/disk_green.png @@ -467,9 +461,21 @@ Save Data + + + + :/img/gear.png:/img/gear.png + + + actionSettings + + + Change Calculator Settings + + - + -- cgit v1.2.3