Skip to content

Commit

Permalink
Fixed T14 Mode?
Browse files Browse the repository at this point in the history
  • Loading branch information
Imeguras committed Nov 11, 2023
1 parent 51aa009 commit 6baf487
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 29 deletions.
11 changes: 7 additions & 4 deletions LukHudX.pro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
######################################################################
# Automatically generated by qmake (3.1) Wed Feb 8 13:19:20 2023
######################################################################
DEFINES += __LART_T24__
DEFINES += __LART_T14__

QT += core gui widgets serialport

Expand Down Expand Up @@ -34,7 +34,8 @@ HEADERS += \
src/contamudancas.h \
src/mainwindow.h \
#Biz Logic
src/store.h
src/store.h \
src/tfortwindow.h

SOURCES += \
#Constants Macros Aux stuff
Expand All @@ -45,9 +46,11 @@ SOURCES += \
src/main.cpp \
src/mainwindow.cpp \
#Biz Logic
src/store.cpp
src/store.cpp \
src/tfortwindow.cpp

FORMS += src/mainwindow.ui
FORMS += src/mainwindow.ui \
src/tfortwindow.ui

TRANSLATIONS += src/LukHudX_1_en_US.ts

Expand Down
22 changes: 17 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
* IDK who developed the "default" main.cpp, but it was not me.
* @b Don't touch this unless you know what you are doing, theres very "few" things to "properly" implement here.
**/
#ifdef __LART_T14__
#include "src/tfortwindow.h"
#endif

#ifdef __LART_T24__
#include "mainwindow.h"
#endif

#include <QApplication>
#include <QLocale>
#include <QTranslator>
Expand All @@ -25,9 +32,14 @@ int main(int argc, char *argv[]){
}
}

MainWindow w;
w.show();

return a.exec();
#ifdef __LART_T24__
MainWindow w;
w.show();
#endif
#ifdef __LART_T14__
TfortWindow w;
w.show();
#endif
return a.exec();

}
}
17 changes: 1 addition & 16 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,7 @@ MainWindow::MainWindow(QWidget *parent, QString serialDev)
* The magic occurs in qmake through the DEFINES variable.
* @see bson_var.h
**/
#ifdef __LART_T14__
FLabel* OilPressure_Label = this->findChild<FLabel*>("OilPressure_Label");
FLabel* OilTemperature_Label = this->findChild<FLabel*>("OilTemperature_Label");
FLabel* DataLogger_Label = this->findChild<FLabel*>("DataLogger_Label");
FLabel* Lambda_Label = this->findChild<FLabel*>("Lambda_Label");
FLabel* TcSlip_Label = this->findChild<FLabel*>("TcSlip_Label");
FLabel* TcLaunch_Label = this->findChild<FLabel*>("TcLaunch_Label");

connect(store_ref, &store::dataLoggerChanged, DataLogger_Label, (void (FLabel::*)(int, int))&FLabel::setVisual);
connect(store_ref, &store::lambdaChanged, Lambda_Label, (void (FLabel::*)(float, float))&FLabel::setVisual);
connect(store_ref, &store::tcSlipChanged, TcSlip_Label, (void (FLabel::*)(int, int))&FLabel::setVisual);
connect(store_ref, &store::tcLaunchChanged, TcLaunch_Label, (void (FLabel::*)(int, int))&FLabel::setVisual);

connect(store_ref, &store::oilPressureChanged, OilPressure_Label, (void (FLabel::*)(float, float))&FLabel::setVisual);
connect(store_ref, &store::oilTemperatureChanged, OilTemperature_Label, (void (FLabel::*)(float, float))&FLabel::setVisual);
#endif

#ifdef __LART_T24__
FLabel* Soc_Label = this->findChild<FLabel*>("Soc_Label");
FLabel* BatteryTemperature_Label = this->findChild<FLabel*>("BatteryTemperature_Label");
Expand Down
81 changes: 81 additions & 0 deletions src/tfortwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* @file mainwindow.cpp
* @brief This file contains the logic for the MainWindow class
* @see mainwindow.h
* @see store.h
* @see flabel.h
* @author João Vieira
* This piece of software was developed for the T24e project belonging to the LART Team
**/
#include "tfortwindow.h"
#include "./ui_tfortwindow.h"
#include "./store.h"
#include <cstddef>
#include <qmainwindow.h>
#include "flabel.h"

static store* store_ref;
/**
* @brief Constructor for the MainWindow Class.
* @b Connects @b **most** variables from the store to the FLabels on the screen.
**/
TfortWindow::TfortWindow(QWidget *parent, QString serialDev)
: QMainWindow(parent)
, ui(new Ui::TfortWindow){

store_ref = new store(serialDev);

ui->setupUi(this);
//store_ref->setParent(this);
//store_ref->requestSlotAttachment();

FLabel* EngineTemperature_Label= this->findChild<FLabel*>("EngineTemperature_Label");
FLabel* BatteryVoltage_Label = this->findChild<FLabel*>("BatteryVoltage_Label");
FLabel* VehicleSpeed_Label = this->findChild<FLabel*>("VehicleSpeed_Label");
connect(store_ref, &store::engineTemperatureChanged, EngineTemperature_Label, (void (FLabel::*)(int, int))&FLabel::setVisual);
connect(store_ref, &store::batteryVoltageChanged, BatteryVoltage_Label, (void (FLabel::*)(float, float))&FLabel::setVisual);
connect(store_ref, &store::vehicleSpeedChanged, VehicleSpeed_Label, (void (FLabel::*)(int, int))&FLabel::setVisual);
/**
* @brief bellow is the spaggeti code thats preprocessed to permit portable use between vehicles
* The magic occurs in qmake through the DEFINES variable.
* @see bson_var.h
**/
#ifdef __LART_T14__
FLabel* OilPressure_Label = this->findChild<FLabel*>("OilPressure_Label");
FLabel* OilTemperature_Label = this->findChild<FLabel*>("OilTemperature_Label");
FLabel* DataLogger_Label = this->findChild<FLabel*>("DataLogger_Label");
FLabel* Lambda_Label = this->findChild<FLabel*>("Lambda_Label");
FLabel* TcSlip_Label = this->findChild<FLabel*>("TcSlip_Label");
FLabel* TcLaunch_Label = this->findChild<FLabel*>("TcLaunch_Label");

connect(store_ref, &store::dataLoggerChanged, DataLogger_Label, (void (FLabel::*)(int, int))&FLabel::setVisual);
connect(store_ref, &store::lambdaChanged, Lambda_Label, (void (FLabel::*)(float, float))&FLabel::setVisual);
connect(store_ref, &store::tcSlipChanged, TcSlip_Label, (void (FLabel::*)(int, int))&FLabel::setVisual);
connect(store_ref, &store::tcLaunchChanged, TcLaunch_Label, (void (FLabel::*)(int, int))&FLabel::setVisual);

connect(store_ref, &store::oilPressureChanged, OilPressure_Label, (void (FLabel::*)(float, float))&FLabel::setVisual);
connect(store_ref, &store::oilTemperatureChanged, OilTemperature_Label, (void (FLabel::*)(float, float))&FLabel::setVisual);
#endif



}


/**
* @brief A getter for a store pointer. <b> use with caution, </b>
* <em> with great power comes great *frickery... This function is by reference and should be used for startup stuff</em>
* @returns a pointer to the store object
**/
store* TfortWindow::getStore(){
return store_ref;
}
/**
* @brief Destructor for the MainWindow Class.
* @b Deletes the store object. which can cause some odd behaviour to happen
**/
TfortWindow::~TfortWindow(){
store_ref->~store();
delete ui;
}

23 changes: 23 additions & 0 deletions src/tfortwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef TFORTWINDOW_H
#define TFORTWINDOW_H
#include <QMainWindow>
#include "store.h"

QT_BEGIN_NAMESPACE
namespace Ui { class TfortWindow; }
QT_END_NAMESPACE

class TfortWindow : public QMainWindow
{
Q_OBJECT

public:
TfortWindow(QWidget *parent = nullptr, QString serialDev=nullptr);
store* getStore();
~TfortWindow();

private:

Ui::TfortWindow *ui;
};
#endif // TFORTWINDOW_H
37 changes: 33 additions & 4 deletions src/mainwindow_old.ui → src/tfortwindow.ui
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<class>TfortWindow</class>
<widget class="TfortWindow" name="TfortWindow">
<property name="geometry">
<rect>
<x>0</x>
Expand Down Expand Up @@ -474,6 +474,14 @@
<bool>true</bool>
</property>
<widget class="QWidget" name="centralwidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>367</width>
<height>245</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
Expand Down Expand Up @@ -618,7 +626,7 @@
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0">
<property name="spacing">
<number>6</number>
</property>
Expand All @@ -639,6 +647,12 @@
</property>
<item>
<widget class="ContaMudancas" name="contamudancas" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
Expand Down Expand Up @@ -666,7 +680,16 @@
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QStatusBar" name="statusbar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>3</width>
<height>25</height>
</rect>
</property>
</widget>
</widget>
<customwidgets>
<customwidget>
Expand All @@ -680,6 +703,12 @@
<extends>QLabel</extends>
<header location="global">src/flabel.h</header>
</customwidget>
<customwidget>
<class>TfortWindow</class>
<extends>QWidget</extends>
<header>src/tfortwindow.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
Expand Down

0 comments on commit 6baf487

Please sign in to comment.