-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…troller #6-Created-Speed-Controller
- Loading branch information
Showing
9 changed files
with
268 additions
and
0 deletions.
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
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,112 @@ | ||
#include "speedcontroller.h" | ||
|
||
SpeedController::SpeedController(Model *model, QObject* parent): ButtonController{model, parent}, m_tractionControl(), m_packTemp(), | ||
m_motorTemp(), m_chargeState(), m_currentTime(), m_fastestTime(), m_lastTime(), m_currentSpeed(), | ||
m_maxSpeed(), m_current(), m_maxCurrent(), m_currentDischarge(), m_maxCurrentDischarge(){ | ||
connect(m_model, &Model::onCurrentDataChange, this, &SpeedController::update); | ||
} | ||
|
||
bool SpeedController::tractionControl() const {return m_tractionControl;} | ||
void SpeedController::setTractionControl(bool tractionStatus) { | ||
if (tractionStatus != m_tractionControl) { | ||
m_tractionControl = tractionStatus; | ||
emit tractionControlChanged(tractionStatus); | ||
} | ||
} | ||
float SpeedController::packTemp() const {return m_packTemp;} | ||
void SpeedController::setPackTemp(float packTemp) { | ||
if (packTemp != m_packTemp) { | ||
m_packTemp = packTemp; | ||
emit packTempChanged(packTemp); | ||
} | ||
} | ||
float SpeedController::motorTemp() const {return m_motorTemp;} | ||
void SpeedController::setMotorTemp(float motorTemp) { | ||
if (motorTemp != m_motorTemp) { | ||
m_motorTemp = motorTemp; | ||
emit motorTempChanged(motorTemp); | ||
} | ||
} | ||
float SpeedController::chargeState() const {return m_chargeState;} | ||
void SpeedController::setChargeState(float chargeState) { | ||
if (chargeState != m_chargeState) { | ||
m_chargeState = chargeState; | ||
emit packTempChanged(chargeState); | ||
} | ||
} | ||
int SpeedController::currentTime() const {return m_currentTime;} | ||
void SpeedController::setCurrentTime(int currentTime) { | ||
if (currentTime != m_currentTime) { | ||
m_currentTime = currentTime; | ||
emit currentTimeChanged(currentTime); | ||
} | ||
} | ||
int SpeedController::fastestTime() const {return m_fastestTime;} | ||
void SpeedController::setFastestTime(int fastTime) { | ||
if (fastTime != m_fastestTime) { | ||
m_fastestTime = fastTime; | ||
emit fastestTimeChanged(fastTime); | ||
} | ||
} | ||
int SpeedController::lastTime() const {return m_lastTime;} | ||
void SpeedController::setLastTime(int lastTime) { | ||
if (lastTime != m_lastTime) { | ||
m_lastTime = lastTime; | ||
emit lastTimeChanged(lastTime); | ||
} | ||
} | ||
int SpeedController::currentSpeed() const {return m_currentSpeed;} | ||
void SpeedController::setCurrentSpeed(int currentSpeed) { | ||
if (currentSpeed != m_currentSpeed) { | ||
m_currentSpeed = currentSpeed; | ||
emit currentSpeedChanged(currentSpeed); | ||
} | ||
} | ||
int SpeedController::maxSpeed() const {return m_maxSpeed;} | ||
void SpeedController::setMaxSpeed(int maxSpeed) { | ||
if (maxSpeed != m_maxSpeed) { | ||
m_maxSpeed = maxSpeed; | ||
emit maxSpeedChanged(maxSpeed); | ||
} | ||
} | ||
float SpeedController::current() const {return m_current;} | ||
void SpeedController::setCurrent(float current) { | ||
if (current != m_current) { | ||
m_current = current; | ||
emit currentChanged(current); | ||
} | ||
} | ||
float SpeedController::maxCurrent() const {return m_maxCurrent;} | ||
void SpeedController::setMaxCurrent(float maxCurrent) { | ||
if (maxCurrent != m_maxCurrent) { | ||
m_maxCurrent = maxCurrent; | ||
emit maxCurrentChanged(maxCurrent); | ||
} | ||
} | ||
float SpeedController::currentDischarge() const {return m_currentDischarge;} | ||
void SpeedController::setCurrentDischarge(float currentDischarge) { | ||
if (currentDischarge != m_currentDischarge) { | ||
m_currentDischarge = currentDischarge; | ||
emit currentDischargeChanged(currentDischarge); | ||
} | ||
} | ||
float SpeedController::maxCurrentDischarge() const {return m_maxCurrentDischarge;} | ||
void SpeedController::setMaxCurrentDischarge(float maxCurrentDischarge) { | ||
if (maxCurrentDischarge != m_maxCurrentDischarge) { | ||
m_maxCurrentDischarge = maxCurrentDischarge; | ||
emit maxCurrentDischargeChanged(maxCurrentDischarge); | ||
} | ||
} | ||
|
||
void SpeedController::update() { | ||
setTractionControl(*m_model->getTractionControl()); | ||
setPackTemp(*m_model->getPackTemp()); | ||
setMotorTemp(*m_model->getMotorTemp()); | ||
setChargeState(*m_model->getStateOfCharge()); | ||
setCurrentTime(*m_model->getTime()); | ||
setFastestTime(m_model->getFastestTime()); | ||
setLastTime(m_model->getLastTime()); | ||
setCurrentSpeed(*m_model->getMph()); | ||
setMaxSpeed(m_model->getMaxSpeed()); | ||
setCurrent(*m_model->getCurrent()); | ||
} |
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,107 @@ | ||
#ifndef SPEEDCONTROLLER_H | ||
#define SPEEDCONTROLLER_H | ||
|
||
#include <QObject> | ||
#include "../models/model.h" | ||
#include "buttoncontroller.h" | ||
|
||
class SpeedController : public ButtonController { | ||
Q_OBJECT | ||
Q_PROPERTY(bool tractionControl READ tractionControlStatus WRITE setTractionControl | ||
NOTIFY tractionControlChanged); | ||
|
||
Q_PROPERTY(float packTemp READ packTemp WRITE setPackTemp NOTIFY packTempChanged); | ||
|
||
Q_PROPERTY(float motorTemp READ motorTemp WRITE setMotorTemp NOTIFY motorTempChanged); | ||
|
||
Q_PROPERTY(float chargeState READ chargeState WRITE setChargeState NOTIFY chargeStateChanged); | ||
|
||
Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime NOTIFY currentTimeChanged); | ||
|
||
Q_PROPERTY(int fastestTime READ fastestTime WRITE setFastestTime NOTIFY fastestTimeChanged); | ||
|
||
Q_PROPERTY(int lastTime READ lastTime WRITE setLastTime NOTIFY lastTimeChanged); | ||
|
||
Q_PROPERTY(int currentSpeed READ currentSpeed WRITE setCurrentSpeed NOTIFY currentSpeedChanged); | ||
|
||
Q_PROPERTY(int maxSpeed READ maxSpeed WRITE setMaxSpeed NOTIFY maxSpeedChanged); | ||
|
||
Q_PROPERTY(float current READ current WRITE setCurrent NOTIFY currentChanged); | ||
|
||
Q_PROPERTY(float maxCurrent READ maxCurrent WRITE setMaxCurrent NOTIFY maxCurrentChanged); | ||
|
||
Q_PROPERTY(float currentDischarge READ currentDischarge WRITE setCurrentDischarge NOTIFY currentDischargeChanged); | ||
|
||
Q_PROPERTY(float maxCurrentDischarge READ maxCurrentDischarge WRITE setMaxCurrentDischarge | ||
NOTIFY maxcurrentDischargeChanged); | ||
|
||
|
||
|
||
|
||
public: | ||
explicit SpeedController(Model *model ,QObject *parent = nullptr); | ||
|
||
bool tractionControl() const; | ||
float packTemp() const; | ||
float motorTemp() const; | ||
float chargeState() const; | ||
int currentTime() const; | ||
int fastestTime() const; | ||
int lastTime() const; | ||
int currentSpeed() const; | ||
int maxSpeed() const; | ||
float current() const; | ||
float maxCurrent() const; | ||
float currentDischarge() const; | ||
float maxCurrentDischarge() const; | ||
|
||
signals: | ||
void tractionControlChanged(bool); | ||
void packTempChanged(float); | ||
void motorTempChanged(float); | ||
void chargeStateChanged(float); | ||
void currentTimeChanged(int); | ||
void fastestTimeChanged(int); | ||
void lastTimeChanged(int); | ||
void currentSpeedChanged(int); | ||
void maxSpeedChanged(int); | ||
void currentChanged(float); | ||
void maxCurrentChanged(float); | ||
void currentDischargeChanged(float); | ||
void maxCurrentDischargeChanged(float); | ||
|
||
public slots: | ||
void setTractionControl(bool); | ||
void setPackTemp(float); | ||
void setMotorTemp(float); | ||
void setChargeState(float); | ||
void setCurrentTime(int); | ||
void setFastestTime(int); | ||
void setLastTime(int); | ||
void setCurrentSpeed(int); | ||
void setMaxSpeed(int); | ||
void setCurrent(float); | ||
void setMaxCurrent(float); | ||
void setCurrentDischarge(float); | ||
void setMaxCurrentDischarge(float); | ||
|
||
void update(); | ||
|
||
private: | ||
bool m_tractionControl = false; | ||
float m_packTemp = 0; | ||
float m_motorTemp = 0; | ||
float m_chargeState = 0; | ||
int m_currentTime = 0; | ||
int m_fastestTime = 0; | ||
int m_lastTime = 0; | ||
int m_currentSpeed = 0; | ||
int m_maxSpeed = 0; | ||
float m_current = 0; | ||
float m_maxCurrent = 0; | ||
float m_currentDischarge = 0; | ||
float m_maxCurrentDischarge = 0; | ||
|
||
}; | ||
|
||
#endif // SPEEDCONTROLLER_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
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
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
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
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
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