Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#46-Update-Controller #53

Merged
merged 23 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
64c0456
#46-Update-Controller
mliam0608 Jan 25, 2024
305e999
Added names and status headers, with model class to combine them.
mliam0608 Jan 27, 2024
737ed43
Delete NERODevelopment/src/controllers/signalsController.h
mliam0608 Jan 29, 2024
7d6bb0a
Delete NERODevelopment/src/controllers/signalscontroler.cpp
mliam0608 Jan 29, 2024
1b56c44
#46 Delete NERODevelopment/src/controllers/offviewmodel.cpp
mliam0608 Jan 29, 2024
ced3c6c
#46 Delete NERODevelopment/src/controllers/offviewmodel.h
mliam0608 Jan 29, 2024
eaa577a
#53 Update-Controller
mliam0608 Jan 29, 2024
9350ac9
Merge branch '#46-Update-Controller' of https://github.com/Northeaste…
mliam0608 Jan 29, 2024
01e71b8
#46 Rename attributeNames.h to attributenames.h
mliam0608 Jan 29, 2024
c1af0dd
#46-Update-Controller
mliam0608 Jan 30, 2024
32b1184
#46-Update-Controller
mliam0608 Jan 30, 2024
3bfdf76
#46-Update-controller
mliam0608 Jan 31, 2024
0f88127
Rename offViewController.cpp to offviewcontroller.cpp
mliam0608 Jan 31, 2024
cf5a7d5
Rename offViewController.h to offviewcontroller.h
mliam0608 Jan 31, 2024
04c96ad
#46-Update-controller
mliam0608 Jan 31, 2024
6582807
#46-update-controller
mliam0608 Jan 31, 2024
9a2d90f
Merge branch '#46-Update-Controller' of https://github.com/Northeaste…
mliam0608 Jan 31, 2024
017c6ab
#46-Update-controller
mliam0608 Jan 31, 2024
30932f6
#46-Update-controller
mliam0608 Jan 31, 2024
8fdab8c
Merge branch '#46-Update-Controller' of https://github.com/Northeaste…
mliam0608 Jan 31, 2024
ed4cd05
#46-Update-Controller
mliam0608 Feb 1, 2024
99d6a4d
#46-Update-controller
mliam0608 Feb 1, 2024
47e5b0d
#46-Update-controller
mliam0608 Feb 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions NERODevelopment/src/controllers/attributenames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef ATTRIBUTENAMES_H
#define ATTRIBUTENAMES_H

#define SIDEBRBS "SIDEBRBS"
#define BMS "BMS"
#define BSPD "BSPD"
#define MPU "MPU"
#define BOTS "BOTS"
#define INERTIA "INERTIA"
#define CPBRB "CP BRB"
#define TSMS "TSMS"
#define HVDINTRLK "HVD INTRLK"
#define HVCNCTR "HV CNCTR"

#endif //ATTRIBUTENAMES_H
10 changes: 10 additions & 0 deletions NERODevelopment/src/controllers/attributestatus.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef ATTRIBUTESTATUS_H
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this file to utils

#define ATTRIBUTESTATUS_H

enum class AttributeStatus : int {
GOOD = 0,
FAULTED = 1,
OFF = 2
};

#endif // ATTRIBUTESTATUS_H
54 changes: 54 additions & 0 deletions NERODevelopment/src/controllers/offViewController.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "offviewcontroller.h"
Peyton-McKee marked this conversation as resolved.
Show resolved Hide resolved

OffViewController::OffViewController(OffViewModel *viewModel, QObject *parent)
: QObject(parent), m_viewModel(viewModel)
{
updateAttributesFromModel();
}

QMap<QString, AttributeStatus> OffViewController::getAttributeStatus() const
{
return m_attributeStatus;
}



QMap<QString, AttributeStatus> OffViewController::getAttributeStatus() const { return m_attributeStatus; }
void OffViewController::setAttributeStatus(const QString &name, AttributeStatus status)
{
if (m_attributeStatus.value(name) != status)
{
m_attributeStatus[name] = status;
emit attributeStatusChanged(m_attributeStatus);
}
}

void OffViewController::updateAttributesFromModel() {
for (const auto& attributeName : {SIDEBRBS, BMS, BSPD, MPU, BOTS, INERTIA, CPBRB, TSMS, HVDINTRLK, HVCNCTR}) {
setAttributeStatus(attributeName, m_attributeStatus[attributeName]);
Peyton-McKee marked this conversation as resolved.
Show resolved Hide resolved
}
}

int OffViewController::packTemp() const { return m_packTemp; }
void OffViewController::setPackTemp(int degrees) {
if (degrees != m_packTemp) {
m_packTemp = degrees;
emit packTempChanged(degrees);
}
}

qreal OffViewController::motorTemp() const { return m_motorTemp; }
void OffViewController::setMotorTemp(qreal temp) {
if (temp != m_motorTemp) {
m_motorTemp = temp;
emit motorTempChanged(temp);
}
}

int OffViewController::stateOfCharge() const { return m_stateOfCharge; }
void OffViewController::setStateOfCharge(int charge) {
if (charge != m_stateOfCharge) {
m_stateOfCharge = charge;
emit stateOfChargeChanged(charge);
}
}
49 changes: 49 additions & 0 deletions NERODevelopment/src/controllers/offViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#ifndef OFFVIEWCONTROLLER_H
#define OFFVIEWCONTROLLER_H

#include <QObject>
#include <QMap>
#include <QString>
#include "attributenames.h"
#include "attributestatus.h"
#include "offviewmodel.h"

class OffViewController : public QObject {
Q_OBJECT
Q_PROPERTY(QMap<QString, AttributeStatus> attributeStatus READ getAttributeStatus NOTIFY attributeStatusChanged)
Q_PROPERTY(
int packTemp READ packTemp WRITE setPackTemp NOTIFY packTempChanged FINAL) //QProperty for pack temp
Q_PROPERTY(qreal motorTemp READ motorTemp WRITE setMotorTemp NOTIFY //QProperty for motor temp
motorTempChanged FINAL)
Q_PROPERTY(int stateOfCharge READ stateOfCharge WRITE setStateOfCharge NOTIFY
stateOfChargeChanged FINAL) //QProperty for state of charge

public:
explicit OffViewController(OffViewModel *viewModel, QObject *parent = nullptr);

QMap<QString, AttributeStatus> getAttributeStatus() const;
int packTemp() const;
qreal motorTemp() const;
Peyton-McKee marked this conversation as resolved.
Show resolved Hide resolved
int stateOfCharge() const;
void updateAttributesFromModel();

signals:
void attributeStatusChanged(const QMap<QString, AttributeStatus> &attributeStatus);
void packTempChanged(int);
void motorTempChanged(qreal);
void stateOfChargeChanged(int);

public slots:
void setAttributeStatus(const QString &name, AttributeStatus status);
void setPackTemp(int);
void setMotorTemp(qreal);
void setStateOfCharge(int);

private:
QMap<QString, AttributeStatus> m_attributeStatus;
int m_packTemp;
qreal m_motorTemp;
int m_stateOfCharge;
};

#endif // OFFVIEWCONTROLLER_H
Loading