From 19aeb68b4475149107e85963fbc1144818bb7b29 Mon Sep 17 00:00:00 2001 From: bruno vicente Date: Sat, 24 Aug 2024 15:36:33 +0100 Subject: [PATCH] banana --- src/main.cpp | 7 ++++--- src/pilot.cpp | 2 +- src/references/bson_var.h | 2 ++ src/store.cpp | 39 ++++++++++++++++++++++++++++++++++----- src/store.h | 8 ++++++-- 5 files changed, 47 insertions(+), 11 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4dd71d9..969dd26 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -52,9 +52,10 @@ int main(int argc, char *argv[]){ check_menu(value); });*/ - PilotWindow pl; - pl.show(); - + //PilotWindow pl; + //pl.show(); + MainWindow m; + m.show(); //VoidsterdebugWindow debugWindow; diff --git a/src/pilot.cpp b/src/pilot.cpp index e50c44e..0dfe83a 100644 --- a/src/pilot.cpp +++ b/src/pilot.cpp @@ -85,7 +85,7 @@ PilotWindow::PilotWindow(QWidget *parent, QString serialDev) HV_SOC_BAR->setValue(soc); }); - connect(store_ref,&store::socChanged,[LV_SOC_BAR](int soc){ + connect(store_ref,&store::lvsocChanged,[LV_SOC_BAR](int soc){ LV_SOC_BAR->setValue(soc); }); diff --git a/src/references/bson_var.h b/src/references/bson_var.h index 7d55b1c..aaa417b 100644 --- a/src/references/bson_var.h +++ b/src/references/bson_var.h @@ -14,6 +14,7 @@ #define BSON_VEHICLESPEED "vel" #define BSON_MOTORTEMPERATURE "eng_t" #define BSON_BATTERYVOLTAGE "bat_v" +#define BSON_IGNITION "ignition" #ifdef __LART_T14__ #define BSON_GEARSHIFT "gear" @@ -34,6 +35,7 @@ #define BSON_HV "hv" #define BSON_MENU "menu" #define BSON_POWER_LIMIT "power_available" + #define BSON_LV_SOC "lv_soc" #endif diff --git a/src/store.cpp b/src/store.cpp index 662253a..1eef3a2 100644 --- a/src/store.cpp +++ b/src/store.cpp @@ -343,19 +343,19 @@ void store::parseBson(std::vector v){ this->setMenu(t); if(m_menu != t) { - //store::closeSerial(); - //VoidsterdebugWindow debugWindow; - //PilotWindow pl; + store::closeSerial(); + VoidsterdebugWindow debugWindow; + PilotWindow pl; // VoidsterdebugWindow debugWindow = new VoidsterdebugWindow(); //PilotWindow pl = new PilotWindow(); switch(t) { case 0: - //pl.show(); + pl.show(); break; case 1: - // debugWindow.show(); + debugWindow.show(); //QMessageBox::information(nullptr, "Menu 0", "Menu 0 has been selected."); break; default: @@ -368,6 +368,11 @@ void store::parseBson(std::vector v){ t.encoded=j[BSON_SOC]; this->setSoc(t.decoded); } + if(j.contains(BSON_LV_SOC)){ + EncodingUnion t; + t.encoded=j[BSON_LV_SOC]; + this->setLV_Soc(t.decoded); + } if(j.contains(BSON_MOTORTEMPERATURE)){ // EncodingUnion t; // t.encoded=j[BSON_MOTORTEMPERATURE]; @@ -705,6 +710,15 @@ float store::getSoc() const{ } +/** +* @brief getter for the state of charge variable +* @return The lv state of charge variable +**/ +float store::getLV_Soc() const{ + return this->m_lv_stateOfCharge; +} + + /** * @brief getter for the state of charge variable * @return The state of charge variable @@ -781,6 +795,21 @@ void store::setSoc(float soc){ + + +/** +* @brief setter for the state of charge variable +* @param LV_soc The new value for the state of charge variable +**/ +void store::setLV_Soc(float soc){ + float oldSoc = this->m_lv_stateOfCharge; + this->m_stateOfCharge=soc; + emit socChanged(this->m_lv_stateOfCharge, oldSoc); +} + + + + /** * @brief setter for the power limit * @param power limit The new value for the state of charge variable diff --git a/src/store.h b/src/store.h index d01e621..779a9df 100644 --- a/src/store.h +++ b/src/store.h @@ -143,7 +143,8 @@ class store: public QObject{ #endif #ifdef __LART_T24__ - float getSoc() const; + float getSoc() const; + float getLV_Soc() const; float getPowerLimit() const; float getBatteryTemperature() const; int getInverterTemperature() const; @@ -156,6 +157,7 @@ class store: public QObject{ //int getTyreTemperature() const; void setSoc(float soc); + void setLV_Soc(float soc); void setPowerLimit(float powerl); void setBatteryTemperature(float batteryTemperature); void setInverterTemperature(int inverterTemperature); @@ -195,7 +197,8 @@ class store: public QObject{ void tcLaunchChanged(int newTcLaunch, int oldTcLaunch); #endif #ifdef __LART_T24__ - void socChanged(float newSoc, float oldSoc); + void socChanged(float newSoc, float oldSoc); + void lvsocChanged(float newSoc, float oldSoc); void power_limitChanged(float newlimit, float oldlimit); void batteryTemperatureChanged(float newBatteryTemperature, float oldBatteryTemperature); void inverterTemperatureChanged(int newInverterTemperature, int oldInverterTemperature); @@ -228,6 +231,7 @@ class store: public QObject{ #endif #ifdef __LART_T24__ float m_stateOfCharge=0; + float m_lv_stateOfCharge = 0; float m_power_limit = 0; float m_batteryTemperature=0; int m_inverterTemperature=0;