diff --git a/CumulativeStatistics.cpp b/CumulativeStatistics.cpp index edcef23..171914d 100644 --- a/CumulativeStatistics.cpp +++ b/CumulativeStatistics.cpp @@ -8,8 +8,8 @@ **************************************************************************/ #include "CumulativeStatistics.hpp" -int CumulativeStatistics::busyTimeLoaders = 0; -int CumulativeStatistics::busyTimeScale = 0; +unsigned int CumulativeStatistics::busyTimeLoaders = 0; +unsigned int CumulativeStatistics::busyTimeScale = 0; CumulativeStatistics::CumulativeStatistics() @@ -17,22 +17,22 @@ CumulativeStatistics::CumulativeStatistics() } -void CumulativeStatistics::appendLoadersBusyTime(int time) +void CumulativeStatistics::appendLoadersBusyTime(unsigned int time) { CumulativeStatistics::busyTimeLoaders += time; } -void CumulativeStatistics::appendScaleBusyTime(int time) +void CumulativeStatistics::appendScaleBusyTime(unsigned int time) { CumulativeStatistics::busyTimeScale += time; } -int CumulativeStatistics::getLoadersBusyTime() +unsigned int CumulativeStatistics::getLoadersBusyTime() { return CumulativeStatistics::busyTimeLoaders; } -int CumulativeStatistics::getScaleBusyTime() +unsigned int CumulativeStatistics::getScaleBusyTime() { return CumulativeStatistics::busyTimeScale; } diff --git a/CumulativeStatistics.hpp b/CumulativeStatistics.hpp index a144276..29dc4bc 100644 --- a/CumulativeStatistics.hpp +++ b/CumulativeStatistics.hpp @@ -14,15 +14,15 @@ class CumulativeStatistics { public: CumulativeStatistics(); - static void appendLoadersBusyTime(int time); - static void appendScaleBusyTime(int time); - static int getLoadersBusyTime(); - static int getScaleBusyTime(); + static void appendLoadersBusyTime(unsigned int time); + static void appendScaleBusyTime(unsigned int time); + static unsigned int getLoadersBusyTime(); + static unsigned int getScaleBusyTime(); static void clear(); private: - static int busyTimeLoaders; - static int busyTimeScale; + static unsigned int busyTimeLoaders; + static unsigned int busyTimeScale; }; #endif // CUMULATIVESTATISTICS_HPP diff --git a/DialogCharts.cpp b/DialogCharts.cpp index e53064c..bc61a21 100644 --- a/DialogCharts.cpp +++ b/DialogCharts.cpp @@ -64,7 +64,7 @@ void DialogCharts::initBusyChart() this->chartBusy->setAnimationOptions(QChart::AllAnimations); this->chartBusy->createDefaultAxes(); - int max = qMax(CumulativeStatistics::getLoadersBusyTime(), CumulativeStatistics::getScaleBusyTime()); + unsigned int max = qMax(CumulativeStatistics::getLoadersBusyTime(), CumulativeStatistics::getScaleBusyTime()); this->chartBusy->axes(Qt::Horizontal).back()->setRange(0, DataProvider::getCurrentClock()); this->chartBusy->axes(Qt::Horizontal).back()->setTitleText("Clock"); this->chartBusy->axes(Qt::Vertical).back()->setRange(0, max); diff --git a/DialogSimulation.cpp b/DialogSimulation.cpp index cd6617c..5dcfbaa 100644 --- a/DialogSimulation.cpp +++ b/DialogSimulation.cpp @@ -70,7 +70,7 @@ void DialogSimulation::initializeSimulationTable() strLstHeaders << "Clock t" << "LQ(t)" << "L(t)" << "WQ(t)" << "W(t)" << "Loader Queue" << "Weigh Queue" << "Future Event List" << "B L" << "B S"; ui->tableWidgetSimulation->setHorizontalHeaderLabels(strLstHeaders); QSettings settings; - ui->tableWidgetSimulation->setRowCount(settings.value("simulation/count").toUInt()); + ui->tableWidgetSimulation->setRowCount(settings.value("simulation/count").toInt()); // Load past state @@ -102,7 +102,7 @@ void DialogSimulation::executeSimulation() LoadingQueue loadingQueue; auto loadingQueueCount = settings.value("simulation/itemsInitialize/loadingQueue").toUInt(); for (unsigned int i = 0; i < loadingQueueCount; ++i) { - loadingQueue.addTruck(trucks.at(i)); + loadingQueue.addTruck(trucks.at(int(i))); } // Loaders @@ -111,7 +111,7 @@ void DialogSimulation::executeSimulation() auto loaderCount = settings.value("simulation/itemsInitialize/loader").toUInt(); loaderCount += loadingQueueCount; for (unsigned int i = loadingQueueCount; i < loaderCount; ++i) { - loaders.addTruck(trucks.at(i)); + loaders.addTruck(trucks.at(int(i))); } // Weigh queue @@ -120,7 +120,7 @@ void DialogSimulation::executeSimulation() auto weighQueueCount = settings.value("simulation/itemsInitialize/weighQueue").toUInt(); weighQueueCount += loaderCount; for (unsigned int i = loaderCount; i < weighQueueCount; ++i) { - weighQueue.addTruck(trucks.at(i)); + weighQueue.addTruck(trucks.at(int(i))); } // Scale diff --git a/DialogSimulation.hpp b/DialogSimulation.hpp index da63d7d..67eda6d 100644 --- a/DialogSimulation.hpp +++ b/DialogSimulation.hpp @@ -29,7 +29,7 @@ class DialogSimulation : public QDialog enum Columns { Clock, LQt, Lt, WQt, Wt, LoaderQueue, WeighQueue, FutureEventList, Bl, Bs }; - explicit DialogSimulation(QWidget *parent = 0); + explicit DialogSimulation(QWidget *parent = nullptr); ~DialogSimulation(); public slots: diff --git a/DumpTruck.cpp b/DumpTruck.cpp index 9edd26f..da3bb74 100644 --- a/DumpTruck.cpp +++ b/DumpTruck.cpp @@ -8,7 +8,7 @@ **************************************************************************/ #include "DumpTruck.hpp" -DumpTruck::DumpTruck(int index, QObject *parent) : QObject(parent), index(index) +DumpTruck::DumpTruck(unsigned int index, QObject *parent) : QObject(parent), index(index) { } @@ -23,7 +23,7 @@ QString DumpTruck::getName() const return "DT" + QString::number(this->index); } -int DumpTruck::getIndex() const +unsigned int DumpTruck::getIndex() const { return this->index; } diff --git a/DumpTruck.hpp b/DumpTruck.hpp index a6bbbfe..e809eb4 100644 --- a/DumpTruck.hpp +++ b/DumpTruck.hpp @@ -18,18 +18,18 @@ class DumpTruck : public QObject enum State { None, InLoaderQueue, Loading, InWeighQueue, Weighing, Traveling }; - explicit DumpTruck(int index, QObject *parent = nullptr); + explicit DumpTruck(unsigned int index, QObject *parent = nullptr); void setState(State state); QString getName() const; - int getIndex() const; + unsigned int getIndex() const; State getState() const; signals: public slots: private: - int index = -1; + unsigned int index = 0; State state = None; }; diff --git a/FutureEventList.cpp b/FutureEventList.cpp index a0a1a1e..37af067 100644 --- a/FutureEventList.cpp +++ b/FutureEventList.cpp @@ -71,14 +71,14 @@ Event *FutureEventList::getNextEvent() return this->lstEvents.at(index); } -Event *FutureEventList::atTruck(int truckIndex) const +Event *FutureEventList::atTruck(unsigned int truckIndex) const { if(this->lstEvents.isEmpty()) { return nullptr; } for (int i = 0; i < this->lstEvents.size(); ++i) { - int index = this->lstEvents.at(i)->getTruck()->getIndex(); + unsigned int index = this->lstEvents.at(i)->getTruck()->getIndex(); if(index == truckIndex) { return this->lstEvents.at(i); diff --git a/FutureEventList.hpp b/FutureEventList.hpp index f8b317c..28f1e46 100644 --- a/FutureEventList.hpp +++ b/FutureEventList.hpp @@ -20,7 +20,7 @@ class FutureEventList void clear(); QString getString() const; Event* getNextEvent(); - Event* atTruck(int truckIndex) const; + Event* atTruck(unsigned int truckIndex) const; signals: diff --git a/Loader.cpp b/Loader.cpp index 84923ea..75447f2 100644 --- a/Loader.cpp +++ b/Loader.cpp @@ -30,7 +30,9 @@ bool Loader::addTruck(DumpTruck *truck) truck->setState(DumpTruck::Loading); - short time = DataProvider::getRandomLoadingTime() + DataProvider::getCurrentClock(); + unsigned int randomLoadingTime = uint(DataProvider::getRandomLoadingTime()); + + unsigned int time = randomLoadingTime + DataProvider::getCurrentClock(); Event *event = new Event(Event::EL, time, truck); FutureEventList::getInstance()->addEvent(event); diff --git a/MainWindow.cpp b/MainWindow.cpp index cf6758b..c2fb7d8 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -191,18 +191,18 @@ void MainWindow::saveData() void MainWindow::loadData() { QSettings settings; - ui->spinBoxSimulationCount->setValue(settings.value("simulation/count").toUInt()); - ui->spinBoxNumberOfTrucks->setValue(settings.value("simulation/itemsInitialize/trucks").toUInt()); - ui->spinBoxNumberOfTrucksInLoadingQueue->setValue(settings.value("simulation/itemsInitialize/loadingQueue").toUInt()); - ui->spinBoxNumberOfTrucksInLoaders->setValue(settings.value("simulation/itemsInitialize/loader").toUInt()); - ui->spinBoxNumberOftrucksInWeighQueue->setValue(settings.value("simulation/itemsInitialize/weighQueue").toUInt()); + ui->spinBoxSimulationCount->setValue(settings.value("simulation/count").toInt()); + ui->spinBoxNumberOfTrucks->setValue(settings.value("simulation/itemsInitialize/trucks").toInt()); + ui->spinBoxNumberOfTrucksInLoadingQueue->setValue(settings.value("simulation/itemsInitialize/loadingQueue").toInt()); + ui->spinBoxNumberOfTrucksInLoaders->setValue(settings.value("simulation/itemsInitialize/loader").toInt()); + ui->spinBoxNumberOftrucksInWeighQueue->setValue(settings.value("simulation/itemsInitialize/weighQueue").toInt()); ui->checkBoxTruckInScale->setChecked(settings.value("simulation/itemsInitialize/scale").toBool()); } void MainWindow::on_pushButtonSimulation_clicked() { - unsigned int numberOfTrucks = ui->spinBoxNumberOfTrucks->value(); - unsigned int totalOtherTrucksCount = ui->spinBoxNumberOfTrucksInLoadingQueue->value(); + int numberOfTrucks = ui->spinBoxNumberOfTrucks->value(); + int totalOtherTrucksCount = ui->spinBoxNumberOfTrucksInLoadingQueue->value(); totalOtherTrucksCount += ui->spinBoxNumberOfTrucksInLoaders->value(); totalOtherTrucksCount += ui->spinBoxNumberOftrucksInWeighQueue->value(); totalOtherTrucksCount += ui->checkBoxTruckInScale->isChecked() ? 1 : 0; diff --git a/MainWindow.hpp b/MainWindow.hpp index d5adbc5..55b9d1a 100644 --- a/MainWindow.hpp +++ b/MainWindow.hpp @@ -20,7 +20,7 @@ class MainWindow : public QMainWindow Q_OBJECT public: - explicit MainWindow(QWidget *parent = 0); + explicit MainWindow(QWidget *parent = nullptr); ~MainWindow(); private slots: diff --git a/Scale.cpp b/Scale.cpp index 79283ca..03ced95 100644 --- a/Scale.cpp +++ b/Scale.cpp @@ -26,7 +26,7 @@ bool Scale::addTruck(DumpTruck *truck) return false; } truck->setState(DumpTruck::Weighing); - int time = DataProvider::getRandomWeighingTime() + DataProvider::getCurrentClock(); + unsigned int time = uint(DataProvider::getRandomWeighingTime()) + DataProvider::getCurrentClock(); Event *event = new Event(Event::EW, time, truck); FutureEventList::getInstance()->addEvent(event); return true; @@ -68,7 +68,7 @@ void Scale::processEvents(WeighQueue &weighQueue) if(event->getEventType() == Event::EW && event->getTime() == DataProvider::getCurrentClock()) { CumulativeStatistics::appendScaleBusyTime(timePenalty); // At this time, weighing is finished and we must add new event for ALQ and also clear scale - short time = DataProvider::getRandomTravelTime() + DataProvider::getCurrentClock(); + auto time = uint(DataProvider::getRandomTravelTime()) + DataProvider::getCurrentClock(); Event *alqEvent = new Event(Event::ALQ, time, event->getTruck()); futureList->removeEvent(event); futureList->addEvent(alqEvent);