refactor: Scan process.
This commit is contained in:
52
src/utilities/ScanProcessSequence.cpp
Normal file
52
src/utilities/ScanProcessSequence.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "ScanProcessSequence.h"
|
||||
|
||||
#include "event/EventCenter.h"
|
||||
#include "device/DeviceManager.h"
|
||||
|
||||
ScanProcessSequence* ScanProcessSequence::getInstance()
|
||||
{
|
||||
static ScanProcessSequence instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
ScanProcessSequence::ScanProcessSequence(QObject* aParent)
|
||||
: QObject(aParent)
|
||||
, mScanProtocol()
|
||||
{
|
||||
connect(DeviceManager::Default(), &DeviceManager::startAutoLocateResult, this, &ScanProcessSequence::startAutoLocate);
|
||||
connect(DeviceManager::Default(), &DeviceManager::updateAutoLocatePosition, this, &ScanProcessSequence::updateAutoLocatePosition);
|
||||
connect(DeviceManager::Default(), &DeviceManager::autolocatePositionEffective, this, &ScanProcessSequence::stopAutoLocate);
|
||||
connect(EventCenter::Default(), &EventCenter::StopScanProcess, this, &ScanProcessSequence::quitAutoLocate);
|
||||
}
|
||||
|
||||
void ScanProcessSequence::updateAutoLocatePosition(int aX, int aY, int aZ)
|
||||
{
|
||||
emit autoLocateXYUpdated(aX, aY);
|
||||
emit autoLocateZUpdated(aZ);
|
||||
}
|
||||
|
||||
void ScanProcessSequence::pushPosition(ScanPosition aPostion)
|
||||
{
|
||||
mScanProtocol.push(aPostion);
|
||||
}
|
||||
|
||||
ScanPosition ScanProcessSequence::popPosition()
|
||||
{
|
||||
return mScanProtocol.pop();
|
||||
}
|
||||
|
||||
ScanPosition ScanProcessSequence::topPosition()
|
||||
{
|
||||
return mScanProtocol.top();
|
||||
}
|
||||
|
||||
void ScanProcessSequence::clear()
|
||||
{
|
||||
return mScanProtocol.clear();
|
||||
}
|
||||
|
||||
int ScanProcessSequence::getScanPositionSize()
|
||||
{
|
||||
return mScanProtocol.size();
|
||||
}
|
||||
|
||||
41
src/utilities/ScanProcessSequence.h
Normal file
41
src/utilities/ScanProcessSequence.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef SCANPROCESSSEQUENCE_H
|
||||
#define SCANPROCESSSEQUENCE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QStack>
|
||||
|
||||
enum ScanPosition
|
||||
{
|
||||
Left = 0, Right
|
||||
};
|
||||
|
||||
class ScanProcessSequence : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static ScanProcessSequence* getInstance();
|
||||
void pushPosition(ScanPosition aPosition);
|
||||
ScanPosition popPosition();
|
||||
ScanPosition topPosition();
|
||||
int getScanPositionSize();
|
||||
void clear();
|
||||
|
||||
signals:
|
||||
void startAutoLocate();
|
||||
void stopAutoLocate();
|
||||
void quitAutoLocate();
|
||||
void startFullScan();
|
||||
void fullScanDataExport();
|
||||
void autoLocateXYUpdated(int aX, int aY);
|
||||
void autoLocateZUpdated(int aZ);
|
||||
|
||||
private slots:
|
||||
void updateAutoLocatePosition(int aX, int aY, int aZ);
|
||||
|
||||
private:
|
||||
ScanProcessSequence(QObject* aParent = nullptr);
|
||||
QStack<ScanPosition> mScanProtocol;
|
||||
|
||||
};
|
||||
|
||||
#endif // SCANPROCESSSEQUENCE_H
|
||||
Reference in New Issue
Block a user