-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
* Gitignore fix * Initial Refactor * Refactor CC * Added 'this' * changeEvent & Sort Headers * Lib version update * Const ref & Closing ValueInput/MessageAlert * simulator namespace * Add m_ prefix * Enum names upper case * Folder refactor * Removed space after std::shared_ptr
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,5 +41,7 @@ target_wrapper.* | |
|
||
# QtCreator CMake | ||
CMakeLists.txt.user* | ||
|
||
out/ | ||
.idea/ | ||
dependencies/out/ | ||
dependencies/ |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
#include "machine/ConveyorControl.h" | ||
#include "machine/DeliveryControl.h" | ||
#include "machine/FeederControl.h" | ||
#include "machine/PaintStationControl.h" | ||
#include "Simulator.h" | ||
|
||
Simulator::Simulator() | ||
{ | ||
m_machine = std::make_shared<simulator::Machine>("Main Machine"); | ||
m_feeder = std::make_shared<simulator::Feeder>("Feeder", *m_machine.get(), FEEDER_CAPACITY, FEEDER_START_COUNT); | ||
m_machine->addComponent(m_feeder); | ||
m_cyan = std::make_shared<simulator::PaintStation>("Cyan Paint", *m_machine.get(), PAINT_STATION_CAPACITY, | ||
PAINT_STATION_START_COUNT); | ||
m_machine->addComponent(m_cyan); | ||
m_magenta = std::make_shared<simulator::PaintStation>("Magenta Paint", *m_machine.get(), PAINT_STATION_CAPACITY, | ||
PAINT_STATION_START_COUNT); | ||
m_machine->addComponent(m_magenta); | ||
m_yellow = std::make_shared<simulator::PaintStation>("Yellow Paint", *m_machine.get(), PAINT_STATION_CAPACITY, | ||
PAINT_STATION_START_COUNT); | ||
m_machine->addComponent(m_yellow); | ||
m_black = std::make_shared<simulator::PaintStation>("Black Paint", *m_machine.get(), PAINT_STATION_CAPACITY, | ||
PAINT_STATION_START_COUNT); | ||
m_machine->addComponent(m_black); | ||
m_delivery = std::make_shared<simulator::Delivery> | ||
("Delivery", *m_machine.get(), DELIVERY_CAPACITY, DELIVERY_START_COUNT); | ||
m_machine->addComponent(m_delivery); | ||
m_conveyor = std::make_shared<simulator::Conveyor> | ||
("Conveyor Belt", *m_machine.get(), CONVEYOR_MAX_RATE, CONVEYOR_START_RATE); | ||
m_machine->addComponent(m_conveyor); | ||
} | ||
|
||
std::shared_ptr<simulator::Machine> Simulator::getMachine() const | ||
{ | ||
return m_machine; | ||
} | ||
|
||
std::shared_ptr<simulator::Feeder> Simulator::getFeeder() const | ||
{ | ||
return m_feeder; | ||
} | ||
|
||
std::shared_ptr<simulator::PaintStation> Simulator::getCyanPaint() const | ||
{ | ||
return m_cyan; | ||
} | ||
|
||
std::shared_ptr<simulator::PaintStation> Simulator::getMagentaPaint() const | ||
{ | ||
return m_magenta; | ||
} | ||
|
||
std::shared_ptr<simulator::PaintStation> Simulator::getYellowPaint() const | ||
{ | ||
return m_yellow; | ||
} | ||
|
||
std::shared_ptr<simulator::PaintStation> Simulator::getBlackPaint() const | ||
{ | ||
return m_black; | ||
} | ||
|
||
std::shared_ptr<simulator::Delivery> Simulator::getDelivery() const | ||
{ | ||
return m_delivery; | ||
} | ||
|
||
std::shared_ptr<simulator::Conveyor> Simulator::getConveyor() const | ||
{ | ||
return m_conveyor; | ||
} | ||
|
||
QWidget *Simulator::getFeederWidget() const | ||
{ | ||
return m_feederWidget; | ||
} | ||
|
||
void Simulator::setFeederWidget(QWidget *value) | ||
{ | ||
m_feederWidget = value; | ||
} | ||
|
||
QWidget *Simulator::getDeliveryWidget() const | ||
{ | ||
return m_deliveryWidget; | ||
} | ||
|
||
void Simulator::setDeliveryWidget(QWidget *value) | ||
{ | ||
m_deliveryWidget = value; | ||
} | ||
|
||
QWidget *Simulator::getConveyorWidget() const | ||
{ | ||
return m_conveyorWidget; | ||
} | ||
|
||
void Simulator::setConveyorWidget(QWidget *value) | ||
{ | ||
m_conveyorWidget = value; | ||
} | ||
|
||
QWidget *Simulator::getCyanWidget() const | ||
{ | ||
return m_cyanWidget; | ||
} | ||
|
||
void Simulator::setCyanWidget(QWidget *value) | ||
{ | ||
m_cyanWidget = value; | ||
} | ||
|
||
QWidget *Simulator::getMagentaWidget() const | ||
{ | ||
return m_magentaWidget; | ||
} | ||
|
||
void Simulator::setMagentaWidget(QWidget *value) | ||
{ | ||
m_magentaWidget = value; | ||
} | ||
|
||
QWidget *Simulator::getYellowWidget() const | ||
{ | ||
return m_yellowWidget; | ||
} | ||
|
||
void Simulator::setYellowWidget(QWidget *value) | ||
{ | ||
m_yellowWidget = value; | ||
} | ||
|
||
QWidget *Simulator::getBlackWidget() const | ||
{ | ||
return m_blackWidget; | ||
} | ||
|
||
void Simulator::setBlackWidget(QWidget *value) | ||
{ | ||
m_blackWidget = value; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#ifndef SIMULATOR_H | ||
#define SIMULATOR_H | ||
|
||
#include "components/Conveyor.h" | ||
#include "components/Delivery.h" | ||
#include "components/Feeder.h" | ||
#include "components/PaintStation.h" | ||
#include "Machine.h" | ||
|
||
#include <QWidget> | ||
|
||
#define FEEDER_CAPACITY 17000 | ||
#define DELIVERY_CAPACITY 17000 | ||
#define PAINT_STATION_CAPACITY 10000 | ||
|
||
#define FEEDER_START_COUNT 1000 | ||
#define DELIVERY_START_COUNT 16950 | ||
#define PAINT_STATION_START_COUNT 10000 | ||
|
||
#define CONVEYOR_MAX_RATE 15000 | ||
#define CONVEYOR_START_RATE 14400 | ||
|
||
class Simulator | ||
{ | ||
public: | ||
std::shared_ptr<simulator::Machine> getMachine() const; | ||
|
||
std::shared_ptr<simulator::Feeder> getFeeder() const; | ||
|
||
std::shared_ptr<simulator::PaintStation> getCyanPaint() const; | ||
|
||
std::shared_ptr<simulator::PaintStation> getMagentaPaint() const; | ||
|
||
std::shared_ptr<simulator::PaintStation> getYellowPaint() const; | ||
|
||
std::shared_ptr<simulator::PaintStation> getBlackPaint() const; | ||
|
||
std::shared_ptr<simulator::Delivery> getDelivery() const; | ||
|
||
std::shared_ptr<simulator::Conveyor> getConveyor() const; | ||
|
||
QWidget *getFeederWidget() const; | ||
|
||
void setFeederWidget(QWidget *value); | ||
|
||
QWidget *getDeliveryWidget() const; | ||
|
||
void setDeliveryWidget(QWidget *value); | ||
|
||
QWidget *getConveyorWidget() const; | ||
|
||
void setConveyorWidget(QWidget *value); | ||
|
||
QWidget *getCyanWidget() const; | ||
|
||
void setCyanWidget(QWidget *value); | ||
|
||
QWidget *getMagentaWidget() const; | ||
|
||
void setMagentaWidget(QWidget *value); | ||
|
||
QWidget *getYellowWidget() const; | ||
|
||
void setYellowWidget(QWidget *value); | ||
|
||
QWidget *getBlackWidget() const; | ||
|
||
void setBlackWidget(QWidget *value); | ||
|
||
Simulator(); | ||
|
||
private: | ||
std::shared_ptr<simulator::Machine> m_machine; | ||
std::shared_ptr<simulator::Feeder> m_feeder; | ||
std::shared_ptr<simulator::PaintStation> m_cyan, m_magenta, m_yellow, m_black; | ||
std::shared_ptr<simulator::Delivery> m_delivery; | ||
std::shared_ptr<simulator::Conveyor> m_conveyor; | ||
QWidget *m_feederWidget, *m_deliveryWidget, *m_conveyorWidget; | ||
QWidget *m_cyanWidget, *m_magentaWidget, *m_yellowWidget, *m_blackWidget; | ||
}; | ||
|
||
#endif // SIMULATOR_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#include "WindowManager.h" | ||
|
||
std::vector <std::shared_ptr<QFrame>>& WindowManager::getFrames() | ||
{ | ||
return m_frames; | ||
} | ||
|
||
WindowManager::WindowManager() {} | ||
|
||
int WindowManager::addFrame(std::shared_ptr<QFrame> frame) | ||
{ | ||
m_frames.push_back(frame); | ||
return m_frames.size() - 1; | ||
} | ||
|
||
void WindowManager::showFrame(int index) | ||
{ | ||
if (m_frameStack.size() > 0) | ||
{ | ||
int m_index = m_frameStack.top(); | ||
m_frames[m_index]->hide(); | ||
} | ||
if (m_frameStack.size() == 0 || m_frameStack.top() != index) | ||
{ | ||
m_frameStack.push(index); | ||
} | ||
m_frames[index]->show(); | ||
} | ||
|
||
void WindowManager::showFrame(std::shared_ptr<QFrame> frame) | ||
{ | ||
for (int i = 0; i < m_frames.size(); i++) | ||
{ | ||
if (m_frames[i] == frame) | ||
{ | ||
showFrame(i); | ||
} | ||
} | ||
} | ||
|
||
void WindowManager::goBack() | ||
{ | ||
if (m_frameStack.size() > 0) | ||
{ | ||
int topIndex = m_frameStack.top(); | ||
m_frames[topIndex]->hide(); | ||
m_frameStack.pop(); | ||
if (m_frameStack.size() > 0) | ||
{ | ||
int backIndex = m_frameStack.top(); | ||
m_frames[backIndex]->show(); | ||
} | ||
} | ||
} | ||
|
||
void WindowManager::hideEverything() | ||
{ | ||
if (m_frameStack.size() > 0) | ||
{ | ||
int topIndex = m_frameStack.top(); | ||
m_frames[topIndex]->hide(); | ||
} | ||
} | ||
|
||
void WindowManager::clearStack() | ||
{ | ||
if (m_frameStack.size() > 0) | ||
{ | ||
int topIndex = m_frameStack.top(); | ||
m_frames[topIndex]->hide(); | ||
m_frames.clear(); | ||
} | ||
} | ||
|
||
WindowManager::~WindowManager() | ||
{ | ||
m_frameStack.empty(); | ||
m_frames.clear(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef BITTOGGLETHREAD_H | ||
#define BITTOGGLETHREAD_H | ||
|
||
#include "modbus/modbus.h" | ||
|
||
#include <thread> | ||
#include <QThread> | ||
|
||
class BitToggleThread : public QThread | ||
{ | ||
Q_OBJECT | ||
public: | ||
BitToggleThread(int bit, modbus_mapping_t *mappings) : m_mappings(mappings), m_bit(bit) {} | ||
|
||
void run() override | ||
{ | ||
m_mappings->tab_input_bits[m_bit] = 1; | ||
std::this_thread::sleep_for(std::chrono::seconds(5)); | ||
m_mappings->tab_input_bits[m_bit] = 0; | ||
finished(); | ||
} | ||
private: | ||
modbus_mapping_t *m_mappings; | ||
int m_bit; | ||
}; | ||
|
||
#endif // BITTOGGLETHREAD_H |