-
Notifications
You must be signed in to change notification settings - Fork 1
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
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
64c0456
#46-Update-Controller
mliam0608 305e999
Added names and status headers, with model class to combine them.
mliam0608 737ed43
Delete NERODevelopment/src/controllers/signalsController.h
mliam0608 7d6bb0a
Delete NERODevelopment/src/controllers/signalscontroler.cpp
mliam0608 1b56c44
#46 Delete NERODevelopment/src/controllers/offviewmodel.cpp
mliam0608 ced3c6c
#46 Delete NERODevelopment/src/controllers/offviewmodel.h
mliam0608 eaa577a
#53 Update-Controller
mliam0608 9350ac9
Merge branch '#46-Update-Controller' of https://github.com/Northeaste…
mliam0608 01e71b8
#46 Rename attributeNames.h to attributenames.h
mliam0608 c1af0dd
#46-Update-Controller
mliam0608 32b1184
#46-Update-Controller
mliam0608 3bfdf76
#46-Update-controller
mliam0608 0f88127
Rename offViewController.cpp to offviewcontroller.cpp
mliam0608 cf5a7d5
Rename offViewController.h to offviewcontroller.h
mliam0608 04c96ad
#46-Update-controller
mliam0608 6582807
#46-update-controller
mliam0608 9a2d90f
Merge branch '#46-Update-Controller' of https://github.com/Northeaste…
mliam0608 017c6ab
#46-Update-controller
mliam0608 30932f6
#46-Update-controller
mliam0608 8fdab8c
Merge branch '#46-Update-Controller' of https://github.com/Northeaste…
mliam0608 ed4cd05
#46-Update-Controller
mliam0608 99d6a4d
#46-Update-controller
mliam0608 47e5b0d
#46-Update-controller
mliam0608 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef ATTRIBUTESTATUS_H | ||
#define ATTRIBUTESTATUS_H | ||
|
||
enum class AttributeStatus : int { | ||
GOOD = 0, | ||
FAULTED = 1, | ||
OFF = 2 | ||
}; | ||
|
||
#endif // ATTRIBUTESTATUS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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