Skip to content

Commit

Permalink
Done Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Imeguras committed Aug 30, 2024
1 parent aa90b1f commit 3057f97
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 11 deletions.
43 changes: 33 additions & 10 deletions src/store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ void store::stopGeneralErrorLog(){
}
/**
* @brief Writes an error to the error log
* @param error The error message
* @param error The
* error message
* @param severity The severity of the error
* @return The number of bytes written to the file
* @see store.h
Expand All @@ -143,7 +144,7 @@ qint64 store::scribeError(QString error, error_severity severity){
QString dateStr = now.toString("hh:mm:ss dd-MM-yyyy");
error.prepend(dateStr + " |" + QString::number(severity) + "|*_");

ret= errorLog.write(error.toUtf8()+"|EOL|\n");
ret= errorLog.write(error.toUtf8()+"|EOL|\n");
if (severity>=error_severity::CRITICAL){
//TODO handle exception graphically

Expand Down Expand Up @@ -352,28 +353,49 @@ void store::parseBson(std::vector<std::uint8_t> v){
this->setOilTemperature(t.decoded);
}
#endif
#ifdef __LART_T24__

if(j.contains(BSON_MENU))
{
int t;
t =j[BSON_MENU];
this->setMenu(t);
if(m_menu != t)
{
store::closeSerial();
VoidsterdebugWindow debugWindow;
PilotWindow pl;
store::closeSerial();

// VoidsterdebugWindow debugWindow = new VoidsterdebugWindow();
//PilotWindow pl = new PilotWindow();
switch(t)
{
case 0:
pl.show();

MainWindow* temp_ref;
//Verify if position 0 is empty
if(ref_windows[0] == nullptr){
//store currently displayed window
MainWindow temp;
temp_ref = &temp;

ref_windows[0] = temp_ref;

}else{
temp_ref = ref_windows[0];


}
temp_ref->show();
break;
case 1:
debugWindow.show();
//QMessageBox::information(nullptr, "Menu 0", "Menu 0 has been selected.");
VoidsterdebugWindow* temp_ref;
if(ref_windows[1] == nullptr){
VoidsterdebugWindow temp;
temp_ref = &temp;
ref_windows[1] = temp_ref;
}else{
temp_ref = ref_windows[1];
}
temp_ref->show();


break;
default:
break;
Expand Down Expand Up @@ -549,6 +571,7 @@ void store::setMenu(int menu){
this->m_menu=menu;
emit menuChanged(this->m_menu, oldMenu);
}

}else{
this->scribeError(__LART_STORE_SETRPM_ERROR__, store::error_severity::MINOR);
}
Expand Down
6 changes: 5 additions & 1 deletion src/store.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "references/bson_var.h"
#include "QtWidgets"
#include "QMessageBox"
#include <vector>
/**
* @brief Go big or go home, :)
**/
Expand Down Expand Up @@ -102,6 +103,7 @@ class store: public QObject{
QByteArray serialLog;
QByteArray lastMessage;
QByteArray bufferMessage;
std::vector<QMainWindow *> ref_windows;
char * markerBSON_WARNING=nullptr;
void parseBson(std::vector<std::uint8_t> v);
void bsonMining();
Expand All @@ -127,6 +129,7 @@ class store: public QObject{
void setBatteryVoltage(float batteryVoltage);
void setVehicleSpeed(int vehicleVelocity);
void updateValue(int newValue);

#ifdef __LART_T14__
int getGearShift() const;
float getOilPressure() const;
Expand Down Expand Up @@ -182,7 +185,8 @@ class store: public QObject{
void setBaudRate(QSerialPort::BaudRate baud);

static bool initialized;
protected:
protected:

QJsonDocument persistent_json;
int startGeneralErrorLog(uint depth=0);
void stopGeneralErrorLog();
Expand Down

0 comments on commit 3057f97

Please sign in to comment.