Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 07f3268efc | |||
| 2322bf09cf | |||
| e14c5da80a | |||
| c2a3c28cdd | |||
| 52516d2f54 | |||
| af88a6a67e | |||
| 1e0cf1aa12 | |||
| 496f61c0e1 | |||
| ac241f45cc | |||
| 1867291c9b |
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,5 +1,11 @@
|
||||
# tc
|
||||
GeneratedFiles/
|
||||
ResononAPISetup-3.12-64bit.exe
|
||||
gdal202.dll
|
||||
*.rej
|
||||
HPPA类图.drawio
|
||||
HPPA - 副本.ui
|
||||
icon
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
716
HPPA/CaptureCoordinator.cpp
Normal file
716
HPPA/CaptureCoordinator.cpp
Normal file
@ -0,0 +1,716 @@
|
||||
#include "CaptureCoordinator.h"
|
||||
|
||||
TwoMotionCaptureCoordinator::TwoMotionCaptureCoordinator(
|
||||
IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_motorCtrl(motorCtrl)
|
||||
, m_cameraCtrl(cameraCtrl)
|
||||
, m_isRunning(false)
|
||||
{
|
||||
//这些信号槽是按照逻辑顺序的
|
||||
connect(this, SIGNAL(moveTo(int, double, double, int)),
|
||||
m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(moveTo(const std::vector<double>, const std::vector<double>, int)),
|
||||
m_motorCtrl, SLOT(moveTo(const std::vector<double>, const std::vector<double>, int)));
|
||||
connect(this, &TwoMotionCaptureCoordinator::stopMotorSignal, m_motorCtrl, &IrisMultiMotorController::stop);
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||
this, &TwoMotionCaptureCoordinator::handlePositionReached);
|
||||
//connect(m_motorCtrl, &IrisMultiMotorController::moveFailed,
|
||||
// this, &TwoMotionCaptureCoordinator::handleError);
|
||||
|
||||
connect(this, &TwoMotionCaptureCoordinator::startRecordHSISignal,
|
||||
m_cameraCtrl, &ImagerOperationBase::start_record);
|
||||
connect(this, &TwoMotionCaptureCoordinator::stopRecordHSISignal,
|
||||
m_cameraCtrl, &ImagerOperationBase::stop_record);
|
||||
connect(m_cameraCtrl, &ImagerOperationBase::RecordFinishedSignal_WhenFrameNumberMeet,
|
||||
this, &TwoMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet);
|
||||
//connect(m_cameraCtrl, &ImagerOperationBase::RecordFinishedSignal_WhenFrameNumberNotMeet,
|
||||
// this, &TwoMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberNotMeet);
|
||||
//connect(m_cameraCtrl, &ImagerOperationBase::captureFailed,
|
||||
// this, &TwoMotionCaptureCoordinator::handleError);
|
||||
}
|
||||
|
||||
TwoMotionCaptureCoordinator::TwoMotionCaptureCoordinator(
|
||||
IrisMultiMotorController* motorCtrl,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_motorCtrl(motorCtrl)
|
||||
, m_isRunning(false)
|
||||
{
|
||||
connect(this, SIGNAL(moveTo(int, double, double, int)),
|
||||
m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(moveTo(const std::vector<double>, const std::vector<double>, int)),
|
||||
m_motorCtrl, SLOT(moveTo(const std::vector<double>, const std::vector<double>, int)));
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||
this, &TwoMotionCaptureCoordinator::handlePositionReached);
|
||||
//connect(m_motorCtrl, &IrisMultiMotorController::moveFailed,
|
||||
// this, &TwoMotionCaptureCoordinator::handleError);
|
||||
}
|
||||
|
||||
TwoMotionCaptureCoordinator::~TwoMotionCaptureCoordinator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::start(QVector<PathLine> pathLines)
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (m_isRunning)
|
||||
{
|
||||
emit errorOccurred("Sequence already running");
|
||||
std::cout << "already running" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
getLocBeforeStart();
|
||||
|
||||
m_pathLines = pathLines;
|
||||
|
||||
m_isMoving2XMin = false;
|
||||
m_isMoving2XMax = false;
|
||||
m_isMoving2XStartLoc = false;
|
||||
|
||||
m_isMoving2YTargeLoc = false;
|
||||
m_isMoving2YStartLoc = false;
|
||||
m_isImagerFrameNumberMeet = false;
|
||||
|
||||
m_retryTimesMoving2XMin = 0;
|
||||
m_retryTimesMoving2XMax = 0;
|
||||
m_retryTimesMoving2YTargeLoc = 0;
|
||||
|
||||
m_isRunning = true;
|
||||
m_numCurrentPathLine = 0;
|
||||
processNextPathLine();
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::stop()
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
std::cout << "The user manually stops the collection! " << std::endl;
|
||||
savePathLinesToCsv();
|
||||
|
||||
emit sequenceComplete(1);
|
||||
emit finishRecordLineNumSignal(m_numCurrentPathLine);
|
||||
//emit stopRecordHSISignal(m_numCurrentPathLine);
|
||||
if (m_cameraCtrl != nullptr)
|
||||
{
|
||||
m_cameraCtrl->stop_record();
|
||||
}
|
||||
|
||||
move2LocBeforeStart();
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::getLocBeforeStart()
|
||||
{
|
||||
QEventLoop loop;
|
||||
bool received = false;
|
||||
|
||||
QTimer timer;
|
||||
timer.setSingleShot(true);
|
||||
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
||||
|
||||
QMetaObject::Connection conn = QObject::connect(m_motorCtrl, &IrisMultiMotorController::locationSignal,
|
||||
[&](std::vector<double> pos) {
|
||||
m_locBeforeStart = pos;
|
||||
received = true;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
QMetaObject::invokeMethod(m_motorCtrl, "getLoc", Qt::QueuedConnection);
|
||||
timer.start(3000);
|
||||
|
||||
loop.exec();
|
||||
|
||||
disconnect(conn);
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::getRecordState()
|
||||
{
|
||||
emit recordState(m_isRunning);
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::move2LocBeforeStart()
|
||||
{
|
||||
std::cout << "\nmove2LocBeforeStart." << std::endl;
|
||||
|
||||
PathLine& tmp = m_pathLines[0];
|
||||
std::vector<double> speed;
|
||||
speed.push_back(tmp.speedTargetXMinPosition);
|
||||
speed.push_back(tmp.speedTargetYPosition);
|
||||
emit moveTo(m_locBeforeStart, speed, 1000);
|
||||
|
||||
m_isRunning = false;
|
||||
|
||||
m_isMoving2XMin = false;
|
||||
m_isMoving2XMax = false;
|
||||
m_isMoving2YTargeLoc = false;
|
||||
|
||||
m_isMoving2XStartLoc = true;
|
||||
m_isMoving2YStartLoc = true;
|
||||
}
|
||||
|
||||
QVector<PathLine> TwoMotionCaptureCoordinator::pathLines() const
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
return m_pathLines;
|
||||
}
|
||||
|
||||
double TwoMotionCaptureCoordinator::getTimeDiffMinutes(QDateTime startTime, QDateTime endTime)
|
||||
{
|
||||
qint64 diffMillis = startTime.msecsTo(endTime);
|
||||
double diffMinutes = (double)diffMillis / 60000;//min
|
||||
|
||||
return diffMinutes;
|
||||
}
|
||||
|
||||
bool TwoMotionCaptureCoordinator::savePathLinesToCsv(QString filename)
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
if (filename.isEmpty())
|
||||
{
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
QString format1 = "yyyyMMdd_HHmmss";
|
||||
QString fileNameTmp = now.toString("yyyyMMdd_HHmmss");
|
||||
|
||||
filename = QDir::cleanPath(QString::fromStdString(directory) + QDir::separator() + "pathLines" + QDir::separator() + fileNameTmp + "_pathLines.csv");
|
||||
}
|
||||
|
||||
QDir dir = QFileInfo(filename).absoluteDir();
|
||||
|
||||
// 如果目录不存在,则递归创建
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkpath(".")) {
|
||||
qWarning() << "Failed to create directory:" << dir.path();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QFile file(filename);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextStream out(&file);
|
||||
out << "timestamp1,timestamp2,timestamp3,time consuming(min),targetYPosition,actualYPosition,targetXMinPosition,actualXMinPosition,targetXMaxPosition,actualXMaxPosition\n";
|
||||
|
||||
for (const auto& data : m_pathLines)
|
||||
{
|
||||
out << data.timestamp1.toString("yyyy-MM-dd HH:mm:ss.zzz") << ","
|
||||
<< data.timestamp2.toString("yyyy-MM-dd HH:mm:ss.zzz") << ","
|
||||
<< data.timestamp3.toString("yyyy-MM-dd HH:mm:ss.zzz") << ","
|
||||
<< QString::number(getTimeDiffMinutes(data.timestamp2, data.timestamp3), 'f', 4) << ","
|
||||
<< QString::number(data.targetYPosition, 'f', 4) << ","
|
||||
<< QString::number(data.actualYPosition, 'f', 4) << ","
|
||||
<< QString::number(data.targetXMinPosition, 'f', 4) << ","
|
||||
<< QString::number(data.actualXMinPosition, 'f', 4) << ","
|
||||
<< QString::number(data.targetXMaxPosition, 'f', 4) << ","
|
||||
<< QString::number(data.actualXMaxPosition, 'f', 4)
|
||||
<< "\n";
|
||||
}
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::handlePositionReached(int motorID, double pos)
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
PathLine &tmp = m_pathLines[m_numCurrentPathLine];
|
||||
|
||||
if (motorID == 1)//y马达
|
||||
{
|
||||
if (m_isMoving2YTargeLoc)
|
||||
{
|
||||
double threshold = getThre(tmp.targetYPosition, pos);
|
||||
|
||||
if (threshold > 5)
|
||||
{
|
||||
//没到准确位置,再次给马达发送命令
|
||||
if (m_retryTimesMoving2YTargeLoc < m_retryLimit)
|
||||
{
|
||||
m_retryTimesMoving2YTargeLoc++;
|
||||
|
||||
std::cout << "Y motor Moving2YTargeLoc error. Retry..." << std::endl;
|
||||
emit moveTo(1, tmp.targetYPosition, tmp.speedTargetYPosition, 1000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_retryTimesMoving2YTargeLoc = 0;
|
||||
|
||||
tmp.actualYPosition = pos;
|
||||
|
||||
m_isMoving2YTargeLoc = false;
|
||||
|
||||
std::cout << "y motor is reached!!!! " << std::endl;
|
||||
startRecordHsi();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_isMoving2YStartLoc)
|
||||
{
|
||||
m_isMoving2YStartLoc = false;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (motorID == 0)//x马达
|
||||
{
|
||||
if (m_isMoving2XMin)
|
||||
{
|
||||
double threshold = getThre(tmp.targetXMinPosition, pos);
|
||||
|
||||
if (threshold > 5)
|
||||
{
|
||||
//没到准确位置,再次给马达发送命令
|
||||
if (m_retryTimesMoving2XMin < m_retryLimit)
|
||||
{
|
||||
m_retryTimesMoving2XMin++;
|
||||
|
||||
std::cout << "X motor Moving2XMin error. Retry..." << std::endl;
|
||||
emit moveTo(0, tmp.targetXMinPosition, tmp.speedTargetXMinPosition, 1000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_retryTimesMoving2XMin = 0;
|
||||
|
||||
tmp.actualXMinPosition = pos;
|
||||
|
||||
m_isMoving2XMin = false;
|
||||
|
||||
std::cout << "x motor is reached!!!! " << std::endl;
|
||||
startRecordHsi();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_isMoving2XMax)
|
||||
{
|
||||
double threshold = getThre(tmp.targetXMaxPosition, pos);
|
||||
|
||||
if (threshold > 5 && !m_isImagerFrameNumberMeet)//马达没到准确位置 && 【非】光谱仪因帧数限制主动停止采集
|
||||
{
|
||||
//没到准确位置,再次给马达发送命令
|
||||
if (m_retryTimesMoving2XMax < m_retryLimit)
|
||||
{
|
||||
m_retryTimesMoving2XMax++;
|
||||
|
||||
std::cout << "X motor Moving2XMax error. Retry..." << std::endl;
|
||||
emit moveTo(0, tmp.targetXMaxPosition, tmp.speedTargetXMaxPosition, 1000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_retryTimesMoving2XMax = 0;
|
||||
|
||||
tmp.actualXMaxPosition = pos;
|
||||
tmp.timestamp3 = QDateTime::currentDateTime();
|
||||
|
||||
std::cout << "Line " << m_numCurrentPathLine << " time span(min):" << getTimeDiffMinutes(tmp.timestamp2, tmp.timestamp3) << std::endl;
|
||||
|
||||
//停止采集高光谱数据
|
||||
emit finishRecordLineNumSignal(m_numCurrentPathLine);
|
||||
//emit stopRecordHSISignal(m_numCurrentPathLine);
|
||||
if (m_cameraCtrl!=nullptr)
|
||||
{
|
||||
m_cameraCtrl->stop_record();
|
||||
}
|
||||
|
||||
m_isMoving2XMax = false;
|
||||
m_isImagerFrameNumberMeet = false;
|
||||
m_numCurrentPathLine++;
|
||||
processNextPathLine();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_isMoving2XStartLoc)
|
||||
{
|
||||
m_isMoving2XStartLoc = false;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double TwoMotionCaptureCoordinator::getThre(double targetLoc,double actualLoc)
|
||||
{
|
||||
double targetLocTmp;
|
||||
if (targetLoc == 0)
|
||||
{
|
||||
targetLocTmp = 0.001;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetLocTmp = targetLoc;
|
||||
}
|
||||
double thre = abs(targetLoc - actualLoc) / targetLocTmp * 100;
|
||||
|
||||
return thre;
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::startRecordHsi()
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (!m_isMoving2XMin && !m_isMoving2YTargeLoc)
|
||||
{
|
||||
//开始采集高光谱数据
|
||||
PathLine &tmp = m_pathLines[m_numCurrentPathLine];
|
||||
tmp.timestamp2 = QDateTime::currentDateTime();
|
||||
std::cout << "start recording hsi, moving to " << tmp.targetXMaxPosition << std::endl;
|
||||
|
||||
m_isMoving2XMax = true;
|
||||
emit moveTo(0, tmp.targetXMaxPosition, tmp.speedTargetXMaxPosition, 1000);
|
||||
|
||||
emit startRecordHSISignal(m_numCurrentPathLine);
|
||||
}
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet()
|
||||
{
|
||||
m_isImagerFrameNumberMeet = true;
|
||||
emit stopMotorSignal(0);
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::handleError(const QString& error)
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
m_isRunning = false;
|
||||
emit errorOccurred(error);
|
||||
}
|
||||
|
||||
void TwoMotionCaptureCoordinator::processNextPathLine()
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
int numPathLines = m_pathLines.size();
|
||||
|
||||
if (numPathLines == 0)
|
||||
{
|
||||
move2LocBeforeStart();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_isMoving2YTargeLoc || m_isMoving2XMin)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_numCurrentPathLine > numPathLines - 1)
|
||||
{
|
||||
std::cout << "\nAll path lines is finished! " << std::endl;
|
||||
|
||||
move2LocBeforeStart();
|
||||
savePathLinesToCsv();
|
||||
|
||||
emit sequenceComplete(0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "\nNew path line: " << m_numCurrentPathLine << std::endl;
|
||||
emit startRecordLineNumSignal(m_numCurrentPathLine);
|
||||
|
||||
PathLine &tmp = m_pathLines[m_numCurrentPathLine];
|
||||
tmp.timestamp1 = QDateTime::currentDateTime();
|
||||
|
||||
std::vector<double> loc;
|
||||
loc.push_back(tmp.targetXMinPosition);
|
||||
loc.push_back(tmp.targetYPosition);
|
||||
std::vector<double> speed;
|
||||
speed.push_back(tmp.speedTargetXMinPosition);
|
||||
speed.push_back(tmp.speedTargetYPosition);
|
||||
|
||||
m_isMoving2YTargeLoc = true;
|
||||
m_isMoving2XMin = true;
|
||||
emit moveTo(loc, speed, 1000);
|
||||
}
|
||||
|
||||
OneMotionCaptureCoordinator::OneMotionCaptureCoordinator(
|
||||
IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_motorCtrl(motorCtrl)
|
||||
, m_cameraCtrl(cameraCtrl)
|
||||
, m_isRunning(false)
|
||||
{
|
||||
connect(this, SIGNAL(moveTo(int, double, double, int)),
|
||||
m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_motorCtrl, SLOT(move(int, bool, double, int)));
|
||||
connect(this, &OneMotionCaptureCoordinator::stopMotorSignal, m_motorCtrl, &IrisMultiMotorController::stop);
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||
this, &OneMotionCaptureCoordinator::handleMotorStoped);
|
||||
//connect(m_motorCtrl, &IrisMultiMotorController::moveFailed,
|
||||
// this, &OneMotionCaptureCoordinator::handleError);
|
||||
|
||||
connect(this, &OneMotionCaptureCoordinator::startRecordHSISignal,
|
||||
m_cameraCtrl, &ImagerOperationBase::start_record);
|
||||
connect(this, &OneMotionCaptureCoordinator::stopRecordHSISignal,
|
||||
m_cameraCtrl, &ImagerOperationBase::stop_record);
|
||||
connect(m_cameraCtrl, &ImagerOperationBase::RecordFinishedSignal_WhenFrameNumberMeet,
|
||||
this, &OneMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet);
|
||||
}
|
||||
|
||||
OneMotionCaptureCoordinator::~OneMotionCaptureCoordinator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::startStepMotion(OneMotionCapturePathLine pathLine)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (m_isRunning)
|
||||
{
|
||||
emit errorOccurred("Sequence already running");
|
||||
return;
|
||||
}
|
||||
|
||||
m_isRunning = true;
|
||||
m_pathLine = pathLine;
|
||||
|
||||
getLocBeforeStart();
|
||||
m_pathLine.startPosition = m_locBeforeStart[0];
|
||||
m_pathLine.timestamp1 = QDateTime::currentDateTime();
|
||||
|
||||
//移动马达并开始采集高光谱
|
||||
emit moveSignal(0, false, m_pathLine.speedRecord, 1000);
|
||||
emit startRecordHSISignal();
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::stopStepMotion()
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (m_cameraCtrl != nullptr)
|
||||
{
|
||||
m_cameraCtrl->stop_record();
|
||||
}
|
||||
|
||||
emit stopMotorSignal(0);
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet()
|
||||
{
|
||||
emit stopMotorSignal(0);
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::getLocBeforeStart()
|
||||
{
|
||||
QEventLoop loop;
|
||||
bool received = false;
|
||||
|
||||
QTimer timer;
|
||||
timer.setSingleShot(true);
|
||||
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
||||
|
||||
QMetaObject::Connection conn = QObject::connect(m_motorCtrl, &IrisMultiMotorController::locationSignal,
|
||||
[&](std::vector<double> pos) {
|
||||
m_locBeforeStart = pos;
|
||||
received = true;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
QMetaObject::invokeMethod(m_motorCtrl, "getLoc", Qt::QueuedConnection);
|
||||
timer.start(3000);
|
||||
|
||||
loop.exec();
|
||||
|
||||
disconnect(conn);
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::move2LocBeforeStart()
|
||||
{
|
||||
std::cout << "\nmove2LocBeforeStart." << std::endl;
|
||||
|
||||
emit moveTo(0, m_locBeforeStart[0], m_pathLine.speedBack, 1000);
|
||||
|
||||
m_isRunning = false;
|
||||
}
|
||||
|
||||
bool OneMotionCaptureCoordinator::saveToCsv(const QString& filename)
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
QFile file(filename);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextStream out(&file);
|
||||
out << "startTime,stopTime,startPosition,stopPosition\n";
|
||||
|
||||
out << m_pathLine.timestamp1.toString("yyyy-MM-dd HH:mm:ss.zzz") << ","
|
||||
<< m_pathLine.timestamp2.toString("yyyy-MM-dd HH:mm:ss.zzz") << ","
|
||||
<< QString::number(m_pathLine.startPosition, 'f', 4) << ","
|
||||
<< QString::number(m_pathLine.stopPosition, 'f', 4) << "\n";
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::handleMotorStoped(int motorID, double pos)
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
// 记录位置信息
|
||||
m_pathLine.stopPosition = pos;
|
||||
m_pathLine.timestamp2 = QDateTime::currentDateTime();
|
||||
|
||||
//光谱仪停止采集,马达回到初始位置
|
||||
emit stopRecordHSISignal();
|
||||
if (m_cameraCtrl != nullptr)
|
||||
{
|
||||
m_cameraCtrl->stop_record();
|
||||
}
|
||||
move2LocBeforeStart();
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::handleCaptureComplete(double index)
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::handleError(const QString& error)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
m_isRunning = false;
|
||||
emit errorOccurred(error);
|
||||
}
|
||||
|
||||
DarkAndWhiteCaptureCoordinator::DarkAndWhiteCaptureCoordinator(
|
||||
int model,
|
||||
IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_model(model)
|
||||
, m_motorCtrl(motorCtrl)
|
||||
, m_cameraCtrl(cameraCtrl)
|
||||
, m_isRunning(false)
|
||||
{
|
||||
connect(this, SIGNAL(moveTo(int, double, double, int)),
|
||||
m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_motorCtrl, SLOT(move(int, bool, double, int)));
|
||||
connect(this, &DarkAndWhiteCaptureCoordinator::stopMotorSignal, m_motorCtrl, &IrisMultiMotorController::stop);
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||
this, &DarkAndWhiteCaptureCoordinator::handleMotorStoped);
|
||||
|
||||
if (m_model == 0)//dark
|
||||
{
|
||||
connect(this, &DarkAndWhiteCaptureCoordinator::startRecordHSISignal,
|
||||
m_cameraCtrl, &ImagerOperationBase::record_dark);
|
||||
connect(m_cameraCtrl, &ImagerOperationBase::RecordDarlFinishSignal,
|
||||
this, &DarkAndWhiteCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet);
|
||||
}
|
||||
else if(m_model == 1)//white
|
||||
{
|
||||
connect(this, &DarkAndWhiteCaptureCoordinator::startRecordHSISignal,
|
||||
m_cameraCtrl, &ImagerOperationBase::record_white);
|
||||
connect(m_cameraCtrl, &ImagerOperationBase::RecordWhiteFinishSignal,
|
||||
this, &DarkAndWhiteCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DarkAndWhiteCaptureCoordinator::~DarkAndWhiteCaptureCoordinator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DarkAndWhiteCaptureCoordinator::startStepMotion(double speed)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (m_isRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_isRunning = true;
|
||||
|
||||
m_speed = speed;
|
||||
|
||||
getLocBeforeStart();
|
||||
|
||||
//移动马达并开始采集高光谱
|
||||
emit moveSignal(0, false, m_speed, 1000);
|
||||
emit startRecordHSISignal();
|
||||
}
|
||||
|
||||
void DarkAndWhiteCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet()
|
||||
{
|
||||
emit stopMotorSignal(0);
|
||||
}
|
||||
|
||||
void DarkAndWhiteCaptureCoordinator::getLocBeforeStart()
|
||||
{
|
||||
QEventLoop loop;
|
||||
bool received = false;
|
||||
|
||||
QTimer timer;
|
||||
timer.setSingleShot(true);
|
||||
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
||||
|
||||
QMetaObject::Connection conn = QObject::connect(m_motorCtrl, &IrisMultiMotorController::locationSignal,
|
||||
[&](std::vector<double> pos) {
|
||||
m_locBeforeStart = pos;
|
||||
received = true;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
QMetaObject::invokeMethod(m_motorCtrl, "getLoc", Qt::QueuedConnection);
|
||||
timer.start(3000);
|
||||
|
||||
loop.exec();
|
||||
|
||||
disconnect(conn);
|
||||
}
|
||||
|
||||
void DarkAndWhiteCaptureCoordinator::move2LocBeforeStart()
|
||||
{
|
||||
std::cout << "\nmove2LocBeforeStart." << std::endl;
|
||||
|
||||
emit moveTo(0, m_locBeforeStart[0], m_speed, 1000);
|
||||
|
||||
m_isRunning = false;
|
||||
}
|
||||
|
||||
void DarkAndWhiteCaptureCoordinator::handleMotorStoped(int motorID, double pos)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (!m_isRunning) return;
|
||||
|
||||
move2LocBeforeStart();
|
||||
}
|
||||
|
||||
void DarkAndWhiteCaptureCoordinator::handleCaptureComplete(double index)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
}
|
||||
210
HPPA/CaptureCoordinator.h
Normal file
210
HPPA/CaptureCoordinator.h
Normal file
@ -0,0 +1,210 @@
|
||||
#pragma once
|
||||
#include <QDateTime>
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
#include <QMetaType>
|
||||
|
||||
#include "ImagerOperationBase.h"
|
||||
#include "IrisMultiMotorController.h"
|
||||
|
||||
struct PathLine
|
||||
{
|
||||
double targetYPosition;
|
||||
double actualYPosition;
|
||||
double speedTargetYPosition;
|
||||
|
||||
double targetXMinPosition;
|
||||
double actualXMinPosition;
|
||||
double speedTargetXMinPosition;
|
||||
|
||||
double targetXMaxPosition;
|
||||
double actualXMaxPosition;
|
||||
double speedTargetXMaxPosition;
|
||||
|
||||
QDateTime timestamp1;//开始航线
|
||||
QDateTime timestamp2;//开始采集高光谱
|
||||
QDateTime timestamp3;//结束采集高光谱
|
||||
|
||||
PathLine(double targetYPosition_=0, double targetXMinPosition_ = 0, double targetXMaxPosition_ = 0)
|
||||
: targetYPosition(targetYPosition_), actualYPosition(0), speedTargetYPosition(0),
|
||||
targetXMinPosition(targetXMinPosition_), actualXMinPosition(0), speedTargetXMinPosition(0),
|
||||
targetXMaxPosition(targetXMaxPosition_), actualXMaxPosition(0), speedTargetXMaxPosition(0),
|
||||
timestamp1(QDateTime::currentDateTime()), timestamp2(QDateTime::currentDateTime()), timestamp3(QDateTime::currentDateTime()) {}
|
||||
};
|
||||
Q_DECLARE_METATYPE(PathLine);
|
||||
//Q_DECLARE_METATYPE(QVector<PathLine>);
|
||||
|
||||
class TwoMotionCaptureCoordinator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TwoMotionCaptureCoordinator(IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent = nullptr);
|
||||
TwoMotionCaptureCoordinator(IrisMultiMotorController* motorCtrl,
|
||||
QObject* parent = nullptr);
|
||||
~TwoMotionCaptureCoordinator();
|
||||
|
||||
QVector<PathLine> pathLines() const;
|
||||
|
||||
signals:
|
||||
void sequenceComplete(int);//0:所有采集线正常运行完成,1:用户主动取消采集
|
||||
void startRecordLineNumSignal(int lineNum);
|
||||
void finishRecordLineNumSignal(int lineNum);
|
||||
|
||||
void startRecordHSISignal(int lineNum);
|
||||
void stopRecordHSISignal(int lineNum);
|
||||
|
||||
void errorOccurred(const QString& error);
|
||||
void moveTo(int, double, double, int);
|
||||
void moveTo(const std::vector<double>, const std::vector<double>, int);
|
||||
void stopMotorSignal(int axis);
|
||||
|
||||
void recordState(bool state);
|
||||
|
||||
private slots:
|
||||
void start(QVector<PathLine> pathLines);
|
||||
void stop();
|
||||
void getRecordState();
|
||||
|
||||
void handlePositionReached(int motorID, double pos);
|
||||
void handleCaptureCompleteWhenFrameNumberMeet();
|
||||
void handleError(const QString& error);
|
||||
|
||||
void move2LocBeforeStart();
|
||||
|
||||
private:
|
||||
void processNextPathLine();
|
||||
void startRecordHsi();
|
||||
void getLocBeforeStart();
|
||||
double getThre(double targetLoc, double actualLoc);
|
||||
|
||||
double getTimeDiffMinutes(QDateTime startTime, QDateTime endTime);
|
||||
bool savePathLinesToCsv(QString filename= QString());
|
||||
|
||||
IrisMultiMotorController* m_motorCtrl;
|
||||
ImagerOperationBase* m_cameraCtrl=nullptr;
|
||||
QVector<PathLine> m_pathLines;
|
||||
mutable QMutex m_dataMutex;
|
||||
|
||||
bool m_isRunning;
|
||||
bool m_isMoving2YTargeLoc;
|
||||
bool m_isMoving2XMin;
|
||||
bool m_isMoving2XMax;
|
||||
|
||||
int m_retryLimit = 3;
|
||||
int m_retryTimesMoving2YTargeLoc;
|
||||
int m_retryTimesMoving2XMin;
|
||||
int m_retryTimesMoving2XMax;
|
||||
|
||||
bool m_isImagerFrameNumberMeet;//光谱仪帧数限制到了,主动停止采集
|
||||
std::vector<double> m_locBeforeStart;
|
||||
|
||||
bool m_isMoving2XStartLoc;
|
||||
bool m_isMoving2YStartLoc;
|
||||
|
||||
int m_numCurrentPathLine;
|
||||
};
|
||||
|
||||
|
||||
struct OneMotionCapturePathLine
|
||||
{
|
||||
double startPosition;
|
||||
double stopPosition;
|
||||
double speedRecord;
|
||||
double speedBack;
|
||||
|
||||
QDateTime timestamp1;//开始
|
||||
QDateTime timestamp2;//结束
|
||||
|
||||
OneMotionCapturePathLine()
|
||||
: startPosition(0), stopPosition(0), speedRecord(0), speedBack(0),
|
||||
timestamp1(QDateTime::currentDateTime()), timestamp2(QDateTime::currentDateTime()) {}
|
||||
};
|
||||
Q_DECLARE_METATYPE(OneMotionCapturePathLine);
|
||||
|
||||
class OneMotionCaptureCoordinator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OneMotionCaptureCoordinator(IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent = nullptr);
|
||||
~OneMotionCaptureCoordinator();
|
||||
|
||||
bool saveToCsv(const QString& filename);
|
||||
|
||||
public slots:
|
||||
void startStepMotion(OneMotionCapturePathLine pathLine);
|
||||
void stopStepMotion();
|
||||
|
||||
void handleCaptureCompleteWhenFrameNumberMeet();
|
||||
|
||||
signals:
|
||||
void sequenceComplete(int);
|
||||
void errorOccurred(const QString& error);
|
||||
void moveTo(int, double, double, int);
|
||||
void moveSignal(int, bool, double, int);
|
||||
void stopMotorSignal(int axis);
|
||||
|
||||
void startRecordHSISignal();
|
||||
void stopRecordHSISignal();
|
||||
|
||||
private slots:
|
||||
void handleMotorStoped(int motorID, double pos);
|
||||
void handleCaptureComplete(double index);
|
||||
void handleError(const QString& error);
|
||||
|
||||
private:
|
||||
IrisMultiMotorController* m_motorCtrl;
|
||||
ImagerOperationBase* m_cameraCtrl;
|
||||
OneMotionCapturePathLine m_pathLine;
|
||||
mutable QMutex m_dataMutex;
|
||||
|
||||
bool m_isRunning;
|
||||
|
||||
std::vector<double> m_locBeforeStart;
|
||||
void getLocBeforeStart();
|
||||
void move2LocBeforeStart();
|
||||
};
|
||||
|
||||
class DarkAndWhiteCaptureCoordinator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DarkAndWhiteCaptureCoordinator(int model, IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent = nullptr);
|
||||
~DarkAndWhiteCaptureCoordinator();
|
||||
|
||||
public slots:
|
||||
void startStepMotion(double speed);
|
||||
|
||||
void handleCaptureCompleteWhenFrameNumberMeet();
|
||||
|
||||
signals:
|
||||
void sequenceComplete(int);
|
||||
void moveTo(int, double, double, int);
|
||||
void moveSignal(int, bool, double, int);
|
||||
void stopMotorSignal(int axis);
|
||||
|
||||
void startRecordHSISignal();
|
||||
|
||||
private slots:
|
||||
void handleMotorStoped(int motorID, double pos);
|
||||
void handleCaptureComplete(double index);
|
||||
|
||||
private:
|
||||
IrisMultiMotorController* m_motorCtrl;
|
||||
ImagerOperationBase* m_cameraCtrl;
|
||||
mutable QMutex m_dataMutex;
|
||||
|
||||
bool m_isRunning;
|
||||
|
||||
double m_speed;
|
||||
int m_model;//0:dark,1:white
|
||||
|
||||
std::vector<double> m_locBeforeStart;
|
||||
void getLocBeforeStart();
|
||||
void move2LocBeforeStart();
|
||||
};
|
||||
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>332</height>
|
||||
<width>632</width>
|
||||
<height>444</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -41,13 +41,10 @@
|
||||
<widget class="QComboBox" name="motorPort_comboBox"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<widget class="QRadioButton" name="ultrasound_radioButton">
|
||||
<property name="text">
|
||||
<string>超声</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
@ -57,14 +54,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QRadioButton" name="ultrasound_radioButton">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QRadioButton" name="is_new_version_radioButton">
|
||||
<property name="text">
|
||||
<string>超声</string>
|
||||
<string>新版</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="connectMotor_btn">
|
||||
<property name="text">
|
||||
<string>连接线性平台</string>
|
||||
@ -81,20 +78,49 @@
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>采样率</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="sample_ratio_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>20</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QProgressBar" name="autoFocusProgress_progressBar">
|
||||
<property name="value">
|
||||
<number>24</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="autoFocus_btn">
|
||||
<property name="text">
|
||||
<string>自动调焦</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -107,7 +133,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="manualFocus_btn">
|
||||
<property name="text">
|
||||
<string>手动调焦</string>
|
||||
@ -132,16 +158,16 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>更新</string>
|
||||
<string>更新实时位置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="currentLocation_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>46</height>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -150,75 +176,101 @@
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="moveto_btn">
|
||||
<property name="text">
|
||||
<string>移动至</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="move2_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>10</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="add_btn">
|
||||
<property name="text">
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="addStepSize_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>46</height>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>50</string>
|
||||
<string>10</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="logicZero_btn">
|
||||
<property name="text">
|
||||
<string>LogicZero</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="subtract_btn">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="subtractStepSize_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>46</height>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>50</string>
|
||||
<string>10</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="logicZero_btn">
|
||||
<property name="text">
|
||||
<string>LogicZero</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="max_btn">
|
||||
<property name="text">
|
||||
<string>max</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="rangeMeasurement_btn">
|
||||
<property name="text">
|
||||
<string>量程测量</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
1276
HPPA/HPPA.cpp
1276
HPPA/HPPA.cpp
File diff suppressed because it is too large
Load Diff
116
HPPA/HPPA.h
116
HPPA/HPPA.h
@ -32,9 +32,9 @@
|
||||
#include "aboutWindow.h"
|
||||
#include "adjustTable.h"
|
||||
#include "PowerControl.h"
|
||||
#include "PathPlan.h"
|
||||
#include "RobotArmControl.h"
|
||||
#include "OneMotorControl.h"
|
||||
#include "TwoMotorControl.h"
|
||||
|
||||
#include "hppaConfigFile.h"
|
||||
#include "path_tc.h"
|
||||
@ -123,36 +123,6 @@ signals:
|
||||
void threadSignal(QString s);
|
||||
};
|
||||
|
||||
|
||||
class ForLoopControl :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ForLoopControl();
|
||||
~ForLoopControl();
|
||||
|
||||
void setLoopCount(int loopCount);
|
||||
int getLoopCount() const;
|
||||
|
||||
bool m_boolRecordNextLine;
|
||||
bool m_boolQuitLoop;
|
||||
|
||||
protected:
|
||||
private:
|
||||
int m_loopCount;
|
||||
|
||||
|
||||
public slots:
|
||||
void startLoop();
|
||||
|
||||
signals:
|
||||
//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>źţ<C5BA>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>źŷ<C5BA><C5B7><EFBFBD><EFBFBD><EFBFBD>ֵʱ<D6B5><CAB1>intֵ<74><D6B5><EFBFBD><EFBFBD><EFBFBD>òɼ<C3B2><C9BC>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ˣ<EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>źŷ<C5BA><C5B7>为ֵʱ<D6B5><CAB1>-1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>ֹ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>-2<><32><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>ֹ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
void recordSignal(int);
|
||||
};
|
||||
|
||||
class HPPA : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -180,12 +150,10 @@ private:
|
||||
|
||||
Configfile mConfigfile;
|
||||
|
||||
ForLoopControl * m_ForLoopControl;
|
||||
ImagerOperationBase* m_Imager;//
|
||||
|
||||
int m_RecordState;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>̣<EFBFBD>ȡ2<C8A1><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1 <20><> <20><><EFBFBD>ڲɼ<DAB2><C9BC><EFBFBD>0 <20><> ֹͣ<CDA3>ɼ<EFBFBD>
|
||||
|
||||
QThread * m_ForLoopControlThread;//
|
||||
QThread * m_RecordThread;//Ӱ<><D3B0><EFBFBD>ɼ<EFBFBD><C9BC>߳<EFBFBD>
|
||||
QThread * m_RgbCameraThread;//rgb<67><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡͼ<C8A1><CDBC><EFBFBD>߳<EFBFBD>
|
||||
QThread * m_CopyFileThread;//Ӱ<><D3B0><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
@ -196,34 +164,8 @@ private:
|
||||
//QLineSeries *series;
|
||||
//QChart *chart;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
VinceControl *m_yMotor;
|
||||
VinceControl *m_xMotor;
|
||||
|
||||
long m_lXmotorLocationOfStartRecord;//<2F><>ʼ<EFBFBD>ɼ<EFBFBD>ǰx<C7B0><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
long m_lYmotorLocationOfStartRecord;//<2F><>ʼ<EFBFBD>ɼ<EFBFBD>ǰy<C7B0><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
|
||||
unsigned long m_lManualSpeedOfXMotor;//X<><58><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD><CBB6>ٶȣ<D9B6>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+X<><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̲<EFBFBD><CCB2><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶȣ<D9B6>12000*0.00052734375=6.328125cm/s
|
||||
unsigned long m_lManualSpeedOfYMotor;//Y<><59><EFBFBD><EFBFBD><EFBFBD><EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ͬ<EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Y<EFBFBD><59><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>װ<EFBFBD>ã<EFBFBD>ʵ<EFBFBD><CAB5>Y<EFBFBD><59><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>=X<><58><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>/5
|
||||
|
||||
int m_xConnectCount;//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>0<EFBFBD><30><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD>1<EFBFBD><31><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>״̬Ϊ1ʱ<31><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>
|
||||
int m_yConnectCount;
|
||||
|
||||
QTimer *m_timerMoveXmotor;
|
||||
QTimer *m_timerMoveYmotor;
|
||||
|
||||
QTimer *m_timerTestRangeOfxMotor;//<2F><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>x<EFBFBD><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
QTimer *m_timerTestRangeOfyMotor;//<2F><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>y<EFBFBD><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
QTimer *m_timerLocationFeedBackOfMotor_x_y;//<2F><><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>ƣ<EFBFBD>x/y<><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>Զ<EFBFBD><D4B6>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD>slider<65><72>
|
||||
QTimer *m_timerYmotorLocationFeedBackAfterRecord;//<2F>ɼ<EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD>ɺ<C9BA><F3A3ACBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ʵʱ<CAB5><CAB1><EFBFBD>ص<EFBFBD>slider<65><72>
|
||||
|
||||
QString operateWidget;//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>Ŀؼ<C4BF><D8BC><EFBFBD>
|
||||
|
||||
bool isMotorConnected(VinceControl *motor);//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD>true<75><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>false
|
||||
void SetXMotorWidgetEnable(bool enable);
|
||||
void SetYMotorWidgetEnable(bool enable);
|
||||
void setMotorRange();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̷<EFBFBD>Χ
|
||||
|
||||
//ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
double widthScale;//QGraphicsView<65><77>viewport<72><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>widthScale = rect.width() / maxDistance;
|
||||
double heightScale;//QGraphicsView<65><77>viewport<72>ߺ<EFBFBD><DFBA><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>heightScale = rect.height() / maxDistance;
|
||||
@ -248,17 +190,18 @@ private:
|
||||
|
||||
OneMotorControl* omc;
|
||||
QDockWidget* dock_omc;
|
||||
|
||||
TwoMotorControl* tmc;
|
||||
QDockWidget* dock_tmc;
|
||||
|
||||
|
||||
PathPlan* m_pathPlan;
|
||||
|
||||
FILE* m_hTimesFile;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onPlotHyperspectralImageRgbImage(int number);
|
||||
void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber);
|
||||
void PlotSpectral(int state);
|
||||
void onRecordFinishedSignal_WhenFrameNumberMeet();
|
||||
void onRecordFinishedSignal_WhenFrameNumberNotMeet();
|
||||
void onsequenceComplete();
|
||||
|
||||
void onExit();
|
||||
void onconnect();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
@ -272,7 +215,6 @@ public Q_SLOTS:
|
||||
void onReference();
|
||||
void recordWhiteFinish();
|
||||
void onStartRecordStep1();
|
||||
void onStartRecordStep2(int lineNumber);
|
||||
void onCreateTab(int trackNumber);
|
||||
void onTabWidgetCurrentChanged(int index);
|
||||
void onActionOpenDirectory();
|
||||
@ -288,50 +230,7 @@ public Q_SLOTS:
|
||||
void onLeftMouseButtonPressed(int x, int y);//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
void deleteMotor();
|
||||
void newMotor();
|
||||
void timerEvent(QTimerEvent *event);
|
||||
void setMotorParamMicroscope(VinceControl* motor);
|
||||
void setXMotorParamFromCfgFile(VinceControl* motor);
|
||||
void setYMotorParamFromCfgFile(VinceControl* motor);
|
||||
|
||||
|
||||
void onxMotorLeft();
|
||||
void onxMotorRight();
|
||||
void onxMotorStop();
|
||||
|
||||
void onyMotorForward();
|
||||
void onyMotorBackward();
|
||||
void onyMotorStop();
|
||||
|
||||
void onMotorReset();
|
||||
|
||||
void OnXmotorSpeedEditingFinished();
|
||||
|
||||
void ontimerLocationFeedBackOfMotor_x_y();
|
||||
void ontimerYmotorLocationFeedBackAfterRecord();
|
||||
|
||||
void OnXmotorSpeedLineeditEditingFinished();
|
||||
void OnXmotorSpeedSliderChanged(double speed);
|
||||
void OnXmotorLocationLineeditEditingFinished();
|
||||
void OnXmotorLocationSliderChanged(double location);
|
||||
void OnXmotorLocationSliderReleased();
|
||||
|
||||
|
||||
void OnYmotorLocationLineeditEditingFinished();
|
||||
void OnYmotorLocationSliderChanged(double location);
|
||||
void OnYmotorLocationSliderReleased();
|
||||
|
||||
|
||||
|
||||
void ontestRangeOfMotor_x_y();
|
||||
void ontimerTestRangeOfxMotor();
|
||||
void ontimerTestRangeOfyMotor();
|
||||
|
||||
void ontimerMoveXmotor();
|
||||
void ontimerMoveYmotor();
|
||||
|
||||
//
|
||||
void onimagerSimulatorMove(int x, int y);
|
||||
void OnSendLogToCallClass(QString str);
|
||||
@ -345,15 +244,12 @@ public Q_SLOTS:
|
||||
void requestFinished(QNetworkReply* reply);
|
||||
|
||||
void recordFromRobotArm(int fileCounter);
|
||||
void recordHyperSpecImg(int status);
|
||||
|
||||
void createOneMotorScenario();
|
||||
signals:
|
||||
void StartFocusSignal();
|
||||
void StartLoopSignal();
|
||||
void StartRecordSignal();
|
||||
void CopyFileThreadSignal(QString, QString);
|
||||
void BroadcastXMotorPosSignal(long long, int);
|
||||
|
||||
void RecordWhiteSignal();
|
||||
void RecordDarlSignal();
|
||||
|
||||
917
HPPA/HPPA.ui
917
HPPA/HPPA.ui
File diff suppressed because it is too large
Load Diff
@ -31,7 +31,7 @@
|
||||
<Import Project="$(QtMsBuild)\qt_defaults.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
|
||||
<QtInstall>5.9_msvc2017_64</QtInstall>
|
||||
<QtInstall>5.13.2_msvc2017_64</QtInstall>
|
||||
<QtModules>core;network;gui;widgets;serialport;websockets;charts</QtModules>
|
||||
<QtBuildConfig>debug</QtBuildConfig>
|
||||
</PropertyGroup>
|
||||
@ -55,11 +55,11 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;D:\cpp_library\vincecontrol_vs2017;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;$(IncludePath)</IncludePath>
|
||||
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;D:\cpp_library\vincecontrol_vs2017;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;D:\cpp_library\eigen-3.4-rc1;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Debug;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\HPPA\x64\Debug;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\x64\Debug;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;$(IncludePath)</IncludePath>
|
||||
<IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;D:\cpp_library\eigen-3.4-rc1;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\vincecontrol_vs2017_release;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Release;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\IrisMultiMotorController\x64\Release;C:\XIMEA\API\xiAPI;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@ -106,13 +106,13 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="aboutWindow.cpp" />
|
||||
<ClCompile Include="adjustTable.cpp" />
|
||||
<ClCompile Include="CaptureCoordinator.cpp" />
|
||||
<ClCompile Include="Corning410Imager.cpp" />
|
||||
<ClCompile Include="hppaConfigFile.cpp" />
|
||||
<ClCompile Include="ImagerOperationBase.cpp" />
|
||||
<ClCompile Include="imager_base.cpp" />
|
||||
<ClCompile Include="irisximeaimager.cpp" />
|
||||
<ClCompile Include="OneMotorControl.cpp" />
|
||||
<ClCompile Include="PathPlan.cpp" />
|
||||
<ClCompile Include="path_tc.cpp" />
|
||||
<ClCompile Include="PowerControl.cpp" />
|
||||
<ClCompile Include="QDoubleSlider.cpp" />
|
||||
@ -125,6 +125,7 @@
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TwoMotorControl.cpp" />
|
||||
<ClCompile Include="utility_tc.cpp" />
|
||||
<QtRcc Include="HPPA.qrc" />
|
||||
<QtUic Include="about.ui" />
|
||||
@ -145,7 +146,10 @@
|
||||
<QtUic Include="oneMotorControl.ui" />
|
||||
<QtUic Include="PathPlan.ui" />
|
||||
<QtUic Include="PowerControl.ui" />
|
||||
<QtUic Include="RadianceConversion.ui" />
|
||||
<QtUic Include="ReflectanceConversion.ui" />
|
||||
<QtUic Include="RobotArmControl.ui" />
|
||||
<QtUic Include="twoMotorControl.ui" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="fileOperation.h" />
|
||||
@ -159,12 +163,13 @@
|
||||
<ItemGroup>
|
||||
<QtMoc Include="adjustTable.h" />
|
||||
<QtMoc Include="PowerControl.h" />
|
||||
<QtMoc Include="PathPlan.h" />
|
||||
<QtMoc Include="RobotArmControl.h" />
|
||||
<QtMoc Include="Corning410Imager.h" />
|
||||
<QtMoc Include="CaptureCoordinator.h" />
|
||||
<ClInclude Include="imager_base.h" />
|
||||
<ClInclude Include="irisximeaimager.h" />
|
||||
<QtMoc Include="OneMotorControl.h" />
|
||||
<QtMoc Include="TwoMotorControl.h" />
|
||||
<ClInclude Include="utility_tc.h" />
|
||||
<QtMoc Include="aboutWindow.h" />
|
||||
<ClInclude Include="hppaConfigFile.h" />
|
||||
|
||||
@ -27,6 +27,9 @@
|
||||
<Filter Include="Source Files\motor">
|
||||
<UniqueIdentifier>{4672856c-86fb-46e3-94ff-0a296dcc6111}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\focus">
|
||||
<UniqueIdentifier>{f2bfb93e-9ef8-4fdd-a776-db93b81af553}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtRcc Include="HPPA.qrc">
|
||||
@ -109,9 +112,6 @@
|
||||
<ClCompile Include="PowerControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PathPlan.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RobotArmControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -127,6 +127,12 @@
|
||||
<ClCompile Include="OneMotorControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CaptureCoordinator.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TwoMotorControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="fileOperation.h">
|
||||
@ -171,9 +177,6 @@
|
||||
<QtMoc Include="PowerControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="PathPlan.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="RobotArmControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
@ -183,6 +186,12 @@
|
||||
<QtMoc Include="OneMotorControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="TwoMotorControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="CaptureCoordinator.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="imageProcessor.h">
|
||||
@ -238,6 +247,15 @@
|
||||
<QtUic Include="oneMotorControl.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="RadianceConversion.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="ReflectanceConversion.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="twoMotorControl.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="cpp.hint" />
|
||||
|
||||
@ -14,8 +14,17 @@
|
||||
|
||||
ImageViewer::ImageViewer(QWidget* pParent) :QGraphicsView(pParent)
|
||||
{
|
||||
setRenderHint(QPainter::Antialiasing);
|
||||
setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
setDragMode(QGraphicsView::ScrollHandDrag);
|
||||
|
||||
// <20>ؼ<EFBFBD><D8BC>㣺<EFBFBD><E3A3BA>ʹ<EFBFBD><CAB9> Qt Ĭ<>ϵ<EFBFBD> anchor<6F><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
setTransformationAnchor(QGraphicsView::NoAnchor);
|
||||
setResizeAnchor(QGraphicsView::NoAnchor);
|
||||
|
||||
m_qtGraphicsScene = new QGraphicsScene(this);
|
||||
this->setScene(m_qtGraphicsScene);
|
||||
m_qtGraphicsScene->setSceneRect(-1e6, -1e6, 2e6, 2e6);
|
||||
|
||||
m_framNumberLabel = new QLabel(this);
|
||||
m_framNumberLabel->setAlignment(Qt::AlignHCenter);
|
||||
@ -61,9 +70,24 @@ void ImageViewer::SetImage(QPixmap *image)
|
||||
{
|
||||
m_GraphicsPixmapItemHandle->setPixmap(*image);
|
||||
}
|
||||
ensureSceneVisible();
|
||||
}
|
||||
|
||||
setSceneRect(QRectF(image->rect()));
|
||||
|
||||
void ImageViewer::ensureSceneVisible()
|
||||
{
|
||||
resetTransform();
|
||||
|
||||
auto view_rect = viewport()->rect();
|
||||
auto scene_rect = this->scene()->itemsBoundingRect();
|
||||
|
||||
double x_ratio = view_rect.width() / scene_rect.width();
|
||||
double y_ratio = view_rect.height() / scene_rect.height();
|
||||
double scale_factor = std::min(x_ratio, y_ratio) * 0.9;
|
||||
|
||||
scale(scale_factor, scale_factor);
|
||||
m_scale *= scale_factor;
|
||||
|
||||
centerOn(scene_rect.center());
|
||||
}
|
||||
|
||||
bool ImageViewer::HasImage()
|
||||
@ -81,37 +105,50 @@ bool ImageViewer::HasImage()
|
||||
void ImageViewer::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
//qDebug() << "---------------+++++++++++++++++++++++++++++++++++++++++++++++++++ ";
|
||||
if (true)//HasImage()
|
||||
//if (true)//HasImage()
|
||||
//{
|
||||
// //Χ<><CEA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>https://blog.csdn.net/GoForwardToStep/article/details/77035287?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param
|
||||
// // <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>view<65><77>λ<EFBFBD><CEBB>;
|
||||
// QPointF cursorPoint = event->pos();
|
||||
// // <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>scene<6E><65>λ<EFBFBD><CEBB>;
|
||||
// QPointF scenePos = this->mapToScene(QPoint(cursorPoint.x(), cursorPoint.y()));
|
||||
|
||||
// // <20><>ȡview<65>Ŀ<EFBFBD><C4BF><EFBFBD>;
|
||||
// qreal viewWidth = this->viewport()->width();
|
||||
// qreal viewHeight = this->viewport()->height();
|
||||
|
||||
// // <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>൱<EFBFBD><E0B5B1>view<65><77>С<EFBFBD>ĺ<EFBFBD><C4BA>ݱ<EFBFBD><DDB1><EFBFBD>;
|
||||
// qreal hScale = cursorPoint.x() / viewWidth;
|
||||
// qreal vScale = cursorPoint.y() / viewHeight;
|
||||
|
||||
|
||||
// // <20><><EFBFBD>ֵĹ<D6B5><C4B9><EFBFBD><EFBFBD><EFBFBD>
|
||||
// QPoint scrollAmount = event->angleDelta();
|
||||
// // <20><>ֵ<EFBFBD><D6B5>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6>ʹ<EFBFBD><CAB9><EFBFBD>߷Ŵ<DFB7><C5B4><EFBFBD>ֵ<EFBFBD><D6B5>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
||||
// scrollAmount.y() > 0 ? zoomIn() : zoomOut();
|
||||
|
||||
|
||||
// // <20><>scene<6E><65><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
||||
// QPointF viewPoint = this->matrix().map(scenePos);
|
||||
// // ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>view<65>Ŵ<EFBFBD><C5B4><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>չʾscene<6E><65>λ<EFBFBD><CEBB>;
|
||||
// horizontalScrollBar()->setValue(int(viewPoint.x() - viewWidth * hScale));
|
||||
// verticalScrollBar()->setValue(int(viewPoint.y() - viewHeight * vScale));
|
||||
//}
|
||||
|
||||
if (HasImage())
|
||||
{
|
||||
//Χ<><CEA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>https://blog.csdn.net/GoForwardToStep/article/details/77035287?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param
|
||||
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>view<65><77>λ<EFBFBD><CEBB>;
|
||||
QPointF cursorPoint = event->pos();
|
||||
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>scene<6E><65>λ<EFBFBD><CEBB>;
|
||||
QPointF scenePos = this->mapToScene(QPoint(cursorPoint.x(), cursorPoint.y()));
|
||||
QPointF oldPos = mapToScene(event->pos());
|
||||
|
||||
// <20><>ȡview<65>Ŀ<EFBFBD><C4BF><EFBFBD>;
|
||||
qreal viewWidth = this->viewport()->width();
|
||||
qreal viewHeight = this->viewport()->height();
|
||||
|
||||
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>൱<EFBFBD><E0B5B1>view<65><77>С<EFBFBD>ĺ<EFBFBD><C4BA>ݱ<EFBFBD><DDB1><EFBFBD>;
|
||||
qreal hScale = cursorPoint.x() / viewWidth;
|
||||
qreal vScale = cursorPoint.y() / viewHeight;
|
||||
|
||||
|
||||
// <20><><EFBFBD>ֵĹ<D6B5><C4B9><EFBFBD><EFBFBD><EFBFBD>
|
||||
QPoint scrollAmount = event->angleDelta();
|
||||
// <20><>ֵ<EFBFBD><D6B5>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6>ʹ<EFBFBD><CAB9><EFBFBD>߷Ŵ<DFB7><C5B4><EFBFBD>ֵ<EFBFBD><D6B5>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
||||
scrollAmount.y() > 0 ? zoomIn() : zoomOut();
|
||||
|
||||
QPointF newPos = mapToScene(event->pos());
|
||||
|
||||
// <20><>scene<6E><65><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
||||
QPointF viewPoint = this->matrix().map(scenePos);
|
||||
// ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>view<65>Ŵ<EFBFBD><C5B4><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>չʾscene<6E><65>λ<EFBFBD><CEBB>;
|
||||
horizontalScrollBar()->setValue(int(viewPoint.x() - viewWidth * hScale));
|
||||
verticalScrollBar()->setValue(int(viewPoint.y() - viewHeight * vScale));
|
||||
QPointF delta = newPos - oldPos;
|
||||
translate(delta.x(), delta.y());
|
||||
}
|
||||
|
||||
QGraphicsView::wheelEvent(event);
|
||||
//QGraphicsView::wheelEvent(event);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
void ImageViewer::scaling(qreal scaleFactor)
|
||||
@ -141,7 +178,7 @@ void ImageViewer::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_bMouseTranslate){
|
||||
QPointF mouseDelta = mapToScene(event->pos()) - mapToScene(m_lastMousePos);
|
||||
translate(mouseDelta);
|
||||
translate(mouseDelta.x(),mouseDelta.y());
|
||||
}
|
||||
|
||||
m_lastMousePos = event->pos();
|
||||
@ -180,27 +217,6 @@ void ImageViewer::zoom(float scaleFactor)
|
||||
m_scale *= scaleFactor;
|
||||
}
|
||||
|
||||
void ImageViewer::translate(QPointF delta)
|
||||
{
|
||||
// <20><><EFBFBD>ݵ<EFBFBD>ǰ zoom <20><><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>
|
||||
delta *= m_scale;
|
||||
delta *= m_translateSpeed;
|
||||
|
||||
////<2F><><EFBFBD><EFBFBD>1<EFBFBD><31>
|
||||
//scene()->setSceneRect(scene()->sceneRect().x() - delta.x(), scene()->sceneRect().y() - delta.y(),
|
||||
// scene()->sceneRect().width(), scene()->sceneRect().height());
|
||||
//scene()->update();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>2<EFBFBD><32>
|
||||
// view <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µĵ<C2B5><C4B5><EFBFBD>Ϊê<CEAA><C3AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ scene
|
||||
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||
QPoint newCenter(VIEW_WIDTH / 2 - delta.x(), VIEW_HEIGHT / 2 - delta.y());
|
||||
centerOn(mapToScene(newCenter));
|
||||
|
||||
// scene <20><> view <20><><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>Ϊê<CEAA><C3AA>
|
||||
setTransformationAnchor(QGraphicsView::AnchorViewCenter);
|
||||
}
|
||||
|
||||
void ImageViewer::setTranslateSpeed(qreal speed)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ٶȷ<D9B6>Χ
|
||||
|
||||
@ -22,6 +22,7 @@ public:
|
||||
|
||||
void SetImage(QPixmap *image);
|
||||
bool HasImage();
|
||||
void ensureSceneVisible();
|
||||
|
||||
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
|
||||
void scaling(qreal scaleFactor);
|
||||
@ -29,7 +30,6 @@ public:
|
||||
void zoomIn(); // <20>Ŵ<EFBFBD>
|
||||
void zoomOut(); // <20><>С
|
||||
void zoom(float scaleFactor); // <20><><EFBFBD><EFBFBD> - scaleFactor<6F><72><EFBFBD>ŵı<C5B5><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void translate(QPointF delta); // ƽ<><C6BD>
|
||||
|
||||
// ƽ<><C6BD><EFBFBD>ٶ<EFBFBD>
|
||||
void setTranslateSpeed(qreal speed);
|
||||
|
||||
@ -6,7 +6,7 @@ ImagerOperationBase::ImagerOperationBase()
|
||||
m_bRecordControlState = true;
|
||||
|
||||
m_FileName2Save = "tmp_image";
|
||||
m_FileSavedCounter = 1;
|
||||
m_FileSavedCounter = 0;
|
||||
|
||||
m_RgbImage = new CImage();
|
||||
|
||||
@ -74,6 +74,8 @@ double ImagerOperationBase::auto_exposure()
|
||||
|
||||
void ImagerOperationBase::focus()
|
||||
{
|
||||
m_iFocusFramesNumber = 0;
|
||||
|
||||
m_iFocusFrameCounter = 1;
|
||||
//std::cout << "<22><><EFBFBD><EFBFBD>-----------" << std::endl;
|
||||
|
||||
@ -85,16 +87,42 @@ void ImagerOperationBase::focus()
|
||||
auto_exposure();
|
||||
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << getIntegrationTime() << std::endl;
|
||||
|
||||
int iWidth, iHeight;
|
||||
GetFrameSize(iWidth, iHeight);
|
||||
unsigned short* tmp = new unsigned short[m_FrameSize];
|
||||
|
||||
imagerStartCollect();
|
||||
|
||||
//emit SpectralSignal(1);
|
||||
m_bFocusControlState = true;
|
||||
while (m_bFocusControlState)
|
||||
{
|
||||
////<2F><>֡ƽ<D6A1><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>
|
||||
//memset((void*)buffer, 0, m_FrameSize * sizeof(unsigned short));
|
||||
//int fn = 5;
|
||||
//for (int i = 0; i < fn; i++)
|
||||
//{
|
||||
// getFrame(tmp);
|
||||
|
||||
// for (int j = 0; j < m_FrameSize; j++)
|
||||
// {
|
||||
// buffer[j] += tmp[j];
|
||||
// }
|
||||
//}
|
||||
//for (int j = 0; j < m_FrameSize; j++)
|
||||
//{
|
||||
// buffer[j] += buffer[j] / fn;
|
||||
//}
|
||||
|
||||
getFrame(buffer);
|
||||
|
||||
//m_RgbImage->FillFocusGrayImage(buffer);
|
||||
m_RgbImage->FillFocusGrayQImage(buffer);
|
||||
|
||||
double focusIndex = calcFocusIndexSobelPrivate(buffer);
|
||||
emit FocusIndexSobelSignal(focusIndex);
|
||||
std::cout << "focusIndex<EFBFBD><EFBFBD>" << focusIndex << std::endl;
|
||||
|
||||
emit SpectralSignal(1);
|
||||
|
||||
++m_iFocusFrameCounter;
|
||||
@ -102,6 +130,7 @@ void ImagerOperationBase::focus()
|
||||
emit SpectralSignal(0);
|
||||
|
||||
imagerStopCollect();
|
||||
delete[] tmp;
|
||||
|
||||
setFramerate(tmpFrmerate);
|
||||
setIntegrationTime(tmpIntegrationTime);
|
||||
@ -270,7 +299,7 @@ void ImagerOperationBase::start_record()
|
||||
//ÿ<><C3BF>1s<31><73><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><CEBD><EFBFBD>ͼ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>
|
||||
if (m_iFrameCounter % (int)getFramerate() == 0)
|
||||
{
|
||||
emit PlotSignal(m_iFrameCounter);
|
||||
emit PlotSignal(m_FileSavedCounter, m_iFrameCounter);
|
||||
}
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
@ -281,14 +310,14 @@ void ImagerOperationBase::start_record()
|
||||
}
|
||||
imagerStopCollect();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<CDBC><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//m_RgbImage
|
||||
emit PlotSignal(m_FileSavedCounter, -1);//<2F><>1<EFBFBD><31><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Է<EFBFBD><D4B7>ɼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<CAB5><C4B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ȫ<EFBFBD><C8AB>2<EFBFBD><32>ʹ<EFBFBD>û<EFBFBD>е<EFBFBD>۲ɼ<DBB2>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>俪ʼ<E4BFAA>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ᵼ<EFBFBD><E1B5BC><EFBFBD>ϴβɼ<CEB2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>źŵ<C5BA><C5B5>õIJۺ<C4B2><DBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>˼<EFBFBD><CBBC>ݣ<EFBFBD>ע<EFBFBD>͵<EFBFBD>
|
||||
|
||||
m_bRecordControlState = false;
|
||||
WriteHdr();
|
||||
m_FileSavedCounter++;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<CDBC><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//m_RgbImage
|
||||
emit PlotSignal(-1);//<2F><>1<EFBFBD><31><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Է<EFBFBD><D4B7>ɼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<CAB5><C4B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ȫ<EFBFBD><C8AB>2<EFBFBD><32>ʹ<EFBFBD>û<EFBFBD>е<EFBFBD>۲ɼ<DBB2>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>俪ʼ<E4BFAA>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ᵼ<EFBFBD><E1B5BC><EFBFBD>ϴβɼ<CEB2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>źŵ<C5BA><C5B5>õIJۺ<C4B2><DBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>˼<EFBFBD><CBBC>ݣ<EFBFBD>ע<EFBFBD>͵<EFBFBD>
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
{
|
||||
emit RecordFinishedSignal_WhenFrameNumberMeet();
|
||||
@ -312,7 +341,7 @@ void ImagerOperationBase::setFrameNumber(int FrameNumber)
|
||||
void ImagerOperationBase::setFileName2Save(string FileName)
|
||||
{
|
||||
m_FileName2Save = FileName;
|
||||
m_FileSavedCounter = 1;
|
||||
m_FileSavedCounter = 0;
|
||||
}
|
||||
|
||||
void ImagerOperationBase::setFocusControlState(bool FocusControlState)
|
||||
@ -335,6 +364,61 @@ int ImagerOperationBase::GetFrameSize(int& iWidth, int& iHeight)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ImagerOperationBase::getFocusIndexSobel()
|
||||
{
|
||||
imagerStartCollect();
|
||||
getFrame(buffer);
|
||||
imagerStopCollect();
|
||||
|
||||
double focusIndex = calcFocusIndexSobelPrivate(buffer);
|
||||
|
||||
emit FocusIndexSobelSignal(focusIndex);
|
||||
}
|
||||
|
||||
double ImagerOperationBase::calcFocusIndexSobelPrivate(void* pvData)
|
||||
{
|
||||
int iSelection = 0;
|
||||
int iWidth, iHeight;
|
||||
GetFrameSize(iWidth, iHeight);
|
||||
|
||||
unsigned short* psData;
|
||||
psData = (unsigned short*)pvData;
|
||||
|
||||
cv::Mat gray(iHeight, iWidth, CV_16UC1, psData);//<2F><><EFBFBD><EFBFBD>֤<EFBFBD><D6A4>gray.data<74><61><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD>psDataһ<61><D2BB><EFBFBD><EFBFBD>
|
||||
/*string rgbFilePathNoStrech = "E:\\hppa\\delete\\focusImg_";
|
||||
string tmp1 = std::to_string(m_iFocusFramesNumber);
|
||||
string tmp2 = ".png";*/
|
||||
|
||||
string rgbFilePathNoStrech = "E:\\hppa\\delete\\focusImg_" + std::to_string(m_iFocusFramesNumber) + ".png";
|
||||
|
||||
//cv::imwrite(rgbFilePathNoStrech, gray);
|
||||
m_iFocusFramesNumber++;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>
|
||||
//cv::Mat outputImage;
|
||||
//cv::Size kernelSize(5, 5);
|
||||
//double sigmaX = 1.5;
|
||||
//cv::GaussianBlur(gray, outputImage, kernelSize, sigmaX);
|
||||
|
||||
cv::Mat outputImage = gray;
|
||||
|
||||
cv::Mat gradX, gradY, absGradX, absGradY;
|
||||
|
||||
cv::Sobel(outputImage, gradX, CV_32F, 1, 0);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪCV_16S<36><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>cv::magnitude<64><65><EFBFBD><EFBFBD>
|
||||
cv::Sobel(outputImage, gradY, CV_32F, 0, 1);
|
||||
cv::convertScaleAbs(gradX, absGradX);
|
||||
cv::convertScaleAbs(gradY, absGradY);
|
||||
cv::Mat grad;
|
||||
cv::addWeighted(absGradX, 0.5, absGradY, 0.5, 0, grad);
|
||||
|
||||
cv::Mat magnitude, direction;
|
||||
cv::magnitude(gradX, gradY, magnitude);//
|
||||
cv::phase(gradX, gradY, direction, true); // true<75><65>ʾ<EFBFBD><CABE><EFBFBD>ؽǶȶ<C7B6><C8B6>ǻ<EFBFBD><C7BB><EFBFBD>
|
||||
|
||||
|
||||
return cv::mean(magnitude)[0];
|
||||
}
|
||||
|
||||
CImage* ImagerOperationBase::getRgbImage() const
|
||||
{
|
||||
return m_RgbImage;
|
||||
@ -365,6 +449,11 @@ void ImagerOperationBase::setRecordControlState(bool RecordControlState)
|
||||
m_bRecordControlState = RecordControlState;
|
||||
}
|
||||
|
||||
void ImagerOperationBase::stop_record()
|
||||
{
|
||||
m_bRecordControlState = false;
|
||||
}
|
||||
|
||||
int ImagerOperationBase::getFrameCounter() const
|
||||
{
|
||||
return m_iFrameCounter;
|
||||
@ -408,6 +497,7 @@ void ImagerOperationBase::WriteHdr()
|
||||
outfile << "interleave = bil\n";
|
||||
outfile << "data type = 12\n";
|
||||
outfile << "bit depth = 12\n";
|
||||
outfile << "byte order = 0\n";
|
||||
outfile << "samples = " << getSampleCount() << "\n";
|
||||
outfile << "bands = " << getBandCount() << "\n";
|
||||
outfile << "lines = " << m_iFrameCounter << "\n";
|
||||
|
||||
@ -55,6 +55,7 @@ public:
|
||||
void setFocusControlState(bool FocusControlState);
|
||||
int GetFrameSize(int& iWidth, int& iHeight);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
CImage* m_RgbImage;//<2F><>ʾ<EFBFBD><CABE>rgbͼ<62><CDBC>
|
||||
@ -85,16 +86,21 @@ protected:
|
||||
|
||||
|
||||
private:
|
||||
int m_iFocusFramesNumber;
|
||||
double calcFocusIndexSobelPrivate(void* pvData);
|
||||
|
||||
public slots:
|
||||
virtual void connect_imager(int frameNumber);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>
|
||||
virtual double auto_exposure();
|
||||
virtual void focus();
|
||||
virtual void start_record();
|
||||
void stop_record();
|
||||
virtual void record_dark();
|
||||
virtual void record_white();
|
||||
|
||||
void getFocusIndexSobel();
|
||||
signals:
|
||||
void PlotSignal(int);//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>źţ<C5BA>-1<EFBFBD><EFBFBD><EFBFBD>˴βɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>
|
||||
void PlotSignal(int, int);//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>źţ<C5BA><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD>-1<><31><EFBFBD><EFBFBD><EFBFBD>˴βɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>
|
||||
void RecordFinishedSignal_WhenFrameNumberMeet();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>m_iFrameNumber<65><72><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
void RecordFinishedSignal_WhenFrameNumberNotMeet();//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>m_iFrameNumber<65><72>û<EFBFBD>вɼ<D0B2><C9BC><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD>;ֹͣ<CDA3>ɼ<EFBFBD>
|
||||
void SpectralSignal(int);//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƹ<EFBFBD><C6B9>ף<EFBFBD><D7A3><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>
|
||||
@ -102,6 +108,8 @@ signals:
|
||||
void RecordWhiteFinishSignal();
|
||||
void RecordDarlFinishSignal();
|
||||
|
||||
void FocusIndexSobelSignal(double);
|
||||
|
||||
|
||||
void testImagerStatus();//<2F><>ʾ<EFBFBD><CABE><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
};
|
||||
|
||||
@ -32,7 +32,7 @@ void OneMotorControl::onConnectMotor()
|
||||
}
|
||||
|
||||
m_multiAxisController->moveToThread(&m_motorThread);
|
||||
m_motorThread.start();
|
||||
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||
|
||||
connect(this->ui.right_btn, SIGNAL(pressed()), this, SLOT(onxMotorRight()));
|
||||
connect(this->ui.right_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
||||
@ -53,12 +53,10 @@ void OneMotorControl::onConnectMotor()
|
||||
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement()));
|
||||
connect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||
|
||||
connect(this, SIGNAL(recordHyperSpecImgOneMotorSignal(int, double, double)), m_multiAxisController, SLOT(recordHyperSpecImgOneMotor(int, double, double)));
|
||||
|
||||
connect(m_multiAxisController, SIGNAL(startRecordLineSignal(int)), this, SIGNAL(startRecordLineSignal(int)));
|
||||
|
||||
connect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
||||
connect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
||||
|
||||
m_motorThread.start();
|
||||
emit testConnectivitySignal(0, 1000);
|
||||
}
|
||||
|
||||
@ -119,15 +117,60 @@ void OneMotorControl::onxMotorStop()
|
||||
emit stopSignal(0);
|
||||
}
|
||||
|
||||
void OneMotorControl::moveMotorAndRecordHyperSpecImg(int updateIntervalMs)
|
||||
void OneMotorControl::setImager(ImagerOperationBase* imager)
|
||||
{
|
||||
double runSpeed = ui.speed_lineEdit->text().toDouble();
|
||||
double returnSpeed = ui.return_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit recordHyperSpecImgOneMotorSignal(updateIntervalMs, runSpeed, returnSpeed);
|
||||
m_Imager = imager;
|
||||
}
|
||||
|
||||
void OneMotorControl::moveMotor2StartPosAndStopRecord()
|
||||
void OneMotorControl::record_dark()
|
||||
{
|
||||
m_multiAxisController->cancelRecord();
|
||||
double s = ui.speed_lineEdit->text().toDouble();
|
||||
|
||||
if (m_darkCaptureCoordinator == nullptr)
|
||||
{
|
||||
m_darkCaptureCoordinator = new DarkAndWhiteCaptureCoordinator(0, m_multiAxisController, m_Imager);
|
||||
}
|
||||
|
||||
m_darkCaptureCoordinator->startStepMotion(s);
|
||||
}
|
||||
|
||||
void OneMotorControl::record_white()
|
||||
{
|
||||
double s = ui.speed_lineEdit->text().toDouble();
|
||||
|
||||
if (m_whiteCaptureCoordinator == nullptr)
|
||||
{
|
||||
m_whiteCaptureCoordinator = new DarkAndWhiteCaptureCoordinator(1, m_multiAxisController, m_Imager);
|
||||
}
|
||||
|
||||
m_whiteCaptureCoordinator->startStepMotion(s);
|
||||
}
|
||||
|
||||
void OneMotorControl::run()
|
||||
{
|
||||
if (m_coordinator == nullptr)
|
||||
{
|
||||
qRegisterMetaType<OneMotionCapturePathLine>("OneMotionCapturePathLine");
|
||||
m_coordinator = new OneMotionCaptureCoordinator(m_multiAxisController, m_Imager);
|
||||
connect(this, SIGNAL(start(OneMotionCapturePathLine)), m_coordinator, SLOT(startStepMotion(OneMotionCapturePathLine)));
|
||||
connect(this, SIGNAL(stopStepMotionSignal()), m_coordinator, SLOT(stopStepMotion()));
|
||||
|
||||
connect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete()));
|
||||
}
|
||||
|
||||
OneMotionCapturePathLine tmp;
|
||||
tmp.speedRecord = ui.speed_lineEdit->text().toDouble();
|
||||
tmp.speedBack = ui.return_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit start(tmp);
|
||||
}
|
||||
|
||||
void OneMotorControl::stop()
|
||||
{
|
||||
emit stopStepMotionSignal();
|
||||
}
|
||||
|
||||
void OneMotorControl::onSequenceComplete()
|
||||
{
|
||||
emit sequenceComplete();
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
|
||||
#include "IrisMultiMotorController.h"
|
||||
#include "fileOperation.h"
|
||||
#include "CaptureCoordinator.h"
|
||||
|
||||
class OneMotorControl : public QDialog
|
||||
{
|
||||
@ -15,8 +16,13 @@ public:
|
||||
OneMotorControl(QWidget* parent = nullptr);
|
||||
~OneMotorControl();
|
||||
|
||||
void moveMotorAndRecordHyperSpecImg(int updateIntervalMs);
|
||||
void moveMotor2StartPosAndStopRecord();
|
||||
void setImager(ImagerOperationBase* imager);
|
||||
|
||||
void run();
|
||||
void stop();
|
||||
|
||||
void record_dark();
|
||||
void record_white();
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
@ -32,6 +38,8 @@ public Q_SLOTS:
|
||||
void onxMotorLeft();
|
||||
void onxMotorStop();
|
||||
|
||||
void onSequenceComplete();
|
||||
|
||||
signals:
|
||||
void moveSignal(int, bool, double, int);
|
||||
void move2LocSignal(int, double, double, int);
|
||||
@ -42,12 +50,20 @@ signals:
|
||||
void zeroStartSignal(int);
|
||||
void testConnectivitySignal(int, int);
|
||||
|
||||
void recordHyperSpecImgOneMotorSignal(int updateIntervalMs, double runSpeed, double returnSpeed);
|
||||
void start(OneMotionCapturePathLine);
|
||||
void stopStepMotionSignal();
|
||||
|
||||
void sequenceComplete();
|
||||
|
||||
void startRecordLineSignal(int);
|
||||
private:
|
||||
Ui::OneMotorControl_UI ui;
|
||||
|
||||
QThread m_motorThread;
|
||||
IrisMultiMotorController* m_multiAxisController;
|
||||
|
||||
OneMotionCaptureCoordinator* m_coordinator = nullptr;
|
||||
ImagerOperationBase* m_Imager;
|
||||
|
||||
DarkAndWhiteCaptureCoordinator* m_darkCaptureCoordinator = nullptr;
|
||||
DarkAndWhiteCaptureCoordinator* m_whiteCaptureCoordinator = nullptr;
|
||||
};
|
||||
|
||||
@ -1,308 +0,0 @@
|
||||
#include "PathPlan.h"
|
||||
#include <iostream>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <fileOperation.h>
|
||||
|
||||
PathPlan::PathPlan(VinceControl* xMotor, VinceControl* yMotor, QMotorDoubleSlider* xSlider, QMotorDoubleSlider* ySlider, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
m_xMotor = xMotor;
|
||||
m_yMotor = yMotor;
|
||||
|
||||
m_xSlider = xSlider;
|
||||
m_ySlider = ySlider;
|
||||
|
||||
ui.recordLine_tableWidget->setFocusPolicy(Qt::NoFocus);
|
||||
ui.recordLine_tableWidget->setStyleSheet("selection-background-color:rgb(255,209,128)");//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD>
|
||||
|
||||
ui.recordLine_tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>λ
|
||||
//ui.recordLine_tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>ģʽ<C4A3><CABD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//QHeaderView* headerView = ui.recordLine_tableWidget->verticalHeader();
|
||||
//headerView->setHidden(true);//ȥ<><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>к<EFBFBD>
|
||||
|
||||
|
||||
ui.recordLine_tableWidget->setColumnCount(2);
|
||||
ui.recordLine_tableWidget->setHorizontalHeaderLabels(QStringList() << "yPosition" << "xMaxPosition");
|
||||
|
||||
connect(ui.addRecordLine_btn, SIGNAL(clicked()), this, SLOT(onAddRecordLine_btn()));
|
||||
connect(ui.removeRecordLine_btn, SIGNAL(clicked()), this, SLOT(onRemoveRecordLine_btn()));
|
||||
connect(ui.generateRecordLine_btn, SIGNAL(clicked()), this, SLOT(onGenerateRecordLine_btn()));
|
||||
connect(ui.deleteRecordLine_btn, SIGNAL(clicked()), this, SLOT(onDeleteRecordLine_btn()));
|
||||
connect(ui.saveRecordLine2File_btn, SIGNAL(clicked()), this, SLOT(onSaveRecordLine2File_btn()));
|
||||
connect(ui.readRecordLineFile_btn, SIGNAL(clicked()), this, SLOT(onReadRecordLineFile_btn()));
|
||||
}
|
||||
|
||||
PathPlan::~PathPlan()
|
||||
{}
|
||||
|
||||
void PathPlan::setMotor(VinceControl* xMotor, VinceControl* yMotor)
|
||||
{
|
||||
m_xMotor = xMotor;
|
||||
m_yMotor = yMotor;
|
||||
}
|
||||
|
||||
QTableWidget* PathPlan::getRecordLineTableWidget()
|
||||
{
|
||||
return ui.recordLine_tableWidget;
|
||||
}
|
||||
|
||||
void PathPlan::onAddRecordLine_btn()
|
||||
{
|
||||
//<><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
ByteBack MotorState = m_yMotor->GetState();
|
||||
double currentPosOfYmotor = m_ySlider->getDistanceFromPulse(MotorState.Location);
|
||||
double maxRangeOfXmotro = m_xSlider->maximum();
|
||||
|
||||
//<2F><>ȡѡ<C8A1><D1A1><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
int currentRow = ui.recordLine_tableWidget->currentRow();
|
||||
std::cout << "currentRow<EFBFBD><EFBFBD>" << currentRow << std::endl;
|
||||
|
||||
QTableWidgetItem* Item1 = new QTableWidgetItem(QString::number(currentPosOfYmotor, 10, 2));
|
||||
QTableWidgetItem* Item2 = new QTableWidgetItem(QString::number(maxRangeOfXmotro, 10, 2));
|
||||
Item1->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
Item2->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
if (currentRow == -1)//<2F><>û<EFBFBD><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ʱ
|
||||
{
|
||||
int RowCount = ui.recordLine_tableWidget->rowCount();//Returns the number of rows. <20><>1<EFBFBD><31>ʼ<EFBFBD><CABC>
|
||||
ui.recordLine_tableWidget->insertRow(RowCount);//<2F><><EFBFBD><EFBFBD>һ<EFBFBD>У<EFBFBD><D0A3>β<EFBFBD><CEB2>Ǵ<EFBFBD>0<EFBFBD><30>ʼ<EFBFBD><CABC>
|
||||
|
||||
ui.recordLine_tableWidget->setItem(RowCount, 0, Item1);
|
||||
ui.recordLine_tableWidget->setItem(RowCount, 1, Item2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.recordLine_tableWidget->insertRow(currentRow + 1);//<2F><><EFBFBD><EFBFBD>һ<EFBFBD>У<EFBFBD><D0A3>β<EFBFBD><CEB2>Ǵ<EFBFBD>0<EFBFBD><30>ʼ<EFBFBD><CABC>
|
||||
|
||||
ui.recordLine_tableWidget->setItem(currentRow + 1, 0, Item1);
|
||||
ui.recordLine_tableWidget->setItem(currentRow + 1, 1, Item2);
|
||||
}
|
||||
}
|
||||
|
||||
void PathPlan::onRemoveRecordLine_btn()
|
||||
{
|
||||
int rowIndex = ui.recordLine_tableWidget->currentRow();
|
||||
if (rowIndex != -1)
|
||||
ui.recordLine_tableWidget->removeRow(rowIndex);
|
||||
}
|
||||
|
||||
void PathPlan::onGenerateRecordLine_btn()
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
double height = ui.height_lineEdit->text().toDouble();
|
||||
double fov = ui.fov_lineEdit->text().toDouble();
|
||||
double swath = (height * tan(fov / 2 * PI / 180)) * 2;//tan<61><6E><EFBFBD><EFBFBD><EFBFBD>ǻ<EFBFBD><C7BB><EFBFBD>
|
||||
ui.swath_lineEdit->setText(QString::number(swath));
|
||||
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ
|
||||
double xMotorRange = m_xSlider->maximum();
|
||||
double yMotorRange = m_ySlider->maximum();
|
||||
|
||||
|
||||
//ȷ<><C8B7><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC>ߣ<EFBFBD><DFA3><EFBFBD>ʽ<EFBFBD><CABD>numberOfRecordLine_tmp * swath - repetitiveLength<74><68>numberOfRecordLine_tmp - 1<><31> = overallLength
|
||||
double overallLength = yMotorRange + swath;
|
||||
double repetitiveRate = ui.repetitiveRate_lineEdit->text().toDouble() / 100;
|
||||
double repetitiveLength = repetitiveRate * swath;
|
||||
double offset = ui.offset_lineEdit->text().toDouble();
|
||||
|
||||
double numberOfRecordLine_tmp = (overallLength - repetitiveLength - offset) / (swath - repetitiveLength);
|
||||
double tmp = numberOfRecordLine_tmp - (int)numberOfRecordLine_tmp;
|
||||
int numberOfRecordLine;
|
||||
double threshold = ui.LastLineThreshold_lineEdit->text().toDouble();//<2F><>numberOfRecordLine_tmpΪС<CEAA><D0A1>ʱ<EFBFBD><CAB1><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>
|
||||
if (tmp > threshold)
|
||||
{
|
||||
numberOfRecordLine = (int)numberOfRecordLine_tmp + 1;
|
||||
//std::cout << "<22><><EFBFBD>ڣ<EFBFBD>" << threshold << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
numberOfRecordLine = (int)numberOfRecordLine_tmp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//ȥ<><C8A5>tableWidget<65><74><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>
|
||||
int rowCount = ui.recordLine_tableWidget->rowCount();
|
||||
for (size_t i = 0; i < rowCount; i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->removeRow(0);
|
||||
}
|
||||
|
||||
|
||||
//<2F><>tableWidget<65><74><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ɼ<EFBFBD><C9BC>ߣ<EFBFBD>
|
||||
QTableWidgetItem* tmpItem;
|
||||
for (size_t i = 0; i < numberOfRecordLine; i++)
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||
int RowCount = ui.recordLine_tableWidget->rowCount();
|
||||
ui.recordLine_tableWidget->insertRow(RowCount);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>yPosition
|
||||
if (tmp > threshold && i == numberOfRecordLine - 1)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>е<EFBFBD>yPosition
|
||||
{
|
||||
tmpItem = new QTableWidgetItem(QString::number(yMotorRange, 10, 2));
|
||||
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, 0, tmpItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
double x = swath * i - i * repetitiveLength + offset;
|
||||
tmpItem = new QTableWidgetItem(QString::number(x, 10, 2));
|
||||
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, 0, tmpItem);
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>x<EFBFBD><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>λ<EFBFBD><CEBB> <20><> ֵ<><D6B5><EFBFBD><EFBFBD>Ϊx<CEAA><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
tmpItem = new QTableWidgetItem(QString::number(xMotorRange, 10, 2));
|
||||
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, 1, tmpItem);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PathPlan::onDeleteRecordLine_btn()
|
||||
{
|
||||
int rowCount = ui.recordLine_tableWidget->rowCount();
|
||||
for (size_t i = 0; i < rowCount; i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->removeRow(0);
|
||||
}
|
||||
}
|
||||
|
||||
void PathPlan::onSaveRecordLine2File_btn()
|
||||
{
|
||||
//ȷ<><C8B7><EFBFBD>ɼ<EFBFBD><C9BC>ߴ<EFBFBD><DFB4><EFBFBD>
|
||||
if (ui.recordLine_tableWidget->rowCount() <= 0)
|
||||
{
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ켣<EFBFBD><EFBFBD>"));
|
||||
return;
|
||||
}
|
||||
|
||||
double height = ui.height_lineEdit->text().toDouble();
|
||||
double fov = ui.fov_lineEdit->text().toDouble();
|
||||
double swath = ui.swath_lineEdit->text().toDouble();
|
||||
double offset = ui.offset_lineEdit->text().toDouble();
|
||||
double repetitiveRate = ui.repetitiveRate_lineEdit->text().toDouble();
|
||||
double LastLineThreshold = ui.LastLineThreshold_lineEdit->text().toDouble();
|
||||
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
|
||||
QString RecordLineFilePath = QFileDialog::getSaveFileName(this, tr("Save RecordLine File"),
|
||||
QString::fromStdString(directory),
|
||||
tr("RecordLineFile (*.RecordLine)"));
|
||||
|
||||
if (RecordLineFilePath.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FILE* RecordLineFileHandle = fopen(RecordLineFilePath.toStdString().c_str(), "wb+");
|
||||
|
||||
fwrite(&height, sizeof(double), 1, RecordLineFileHandle);
|
||||
fwrite(&fov, sizeof(double), 1, RecordLineFileHandle);
|
||||
fwrite(&swath, sizeof(double), 1, RecordLineFileHandle);
|
||||
fwrite(&offset, sizeof(double), 1, RecordLineFileHandle);
|
||||
fwrite(&repetitiveRate, sizeof(double), 1, RecordLineFileHandle);
|
||||
fwrite(&LastLineThreshold, sizeof(double), 1, RecordLineFileHandle);
|
||||
|
||||
double number = ui.recordLine_tableWidget->rowCount() * ui.recordLine_tableWidget->columnCount();
|
||||
fwrite(&number, sizeof(double), 1, RecordLineFileHandle);
|
||||
|
||||
double* data = new double[number];
|
||||
//double data[number];
|
||||
for (size_t i = 0; i < ui.recordLine_tableWidget->rowCount(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
|
||||
{
|
||||
data[i * ui.recordLine_tableWidget->columnCount() + j] = ui.recordLine_tableWidget->item(i, j)->text().toDouble();
|
||||
}
|
||||
}
|
||||
|
||||
fwrite(data, sizeof(double), number, RecordLineFileHandle);
|
||||
|
||||
fclose(RecordLineFileHandle);
|
||||
delete[] data;
|
||||
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>"));
|
||||
}
|
||||
|
||||
void PathPlan::onReadRecordLineFile_btn()
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
//string RecordLineFilePath = directory + "\\test.RecordLine";
|
||||
|
||||
QString RecordLineFilePath = QFileDialog::getOpenFileName(this, tr("Open RecordLine File"),
|
||||
QString::fromStdString(directory),
|
||||
tr("RecordLineFile (*.RecordLine)"));
|
||||
|
||||
if (RecordLineFilePath.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FILE* RecordLineFileHandle = fopen(RecordLineFilePath.toStdString().c_str(), "rb");
|
||||
double height, fov, swath, offset, repetitiveRate, LastLineThreshold, number;
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
||||
fread(&height, sizeof(double), 1, RecordLineFileHandle);
|
||||
fread(&fov, sizeof(double), 1, RecordLineFileHandle);
|
||||
fread(&swath, sizeof(double), 1, RecordLineFileHandle);
|
||||
fread(&offset, sizeof(double), 1, RecordLineFileHandle);
|
||||
fread(&repetitiveRate, sizeof(double), 1, RecordLineFileHandle);
|
||||
fread(&LastLineThreshold, sizeof(double), 1, RecordLineFileHandle);
|
||||
fread(&number, sizeof(double), 1, RecordLineFileHandle);
|
||||
|
||||
double* data = new double[number];
|
||||
for (size_t i = 0; i < number; i++)
|
||||
{
|
||||
fread(data + i, sizeof(double), 1, RecordLineFileHandle);
|
||||
//std::cout << *(data + i) << std::endl;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д
|
||||
ui.height_lineEdit->setText(QString::number(height));
|
||||
ui.fov_lineEdit->setText(QString::number(fov));
|
||||
ui.swath_lineEdit->setText(QString::number(swath));
|
||||
ui.offset_lineEdit->setText(QString::number(offset));
|
||||
ui.repetitiveRate_lineEdit->setText(QString::number(repetitiveRate));
|
||||
ui.LastLineThreshold_lineEdit->setText(QString::number(LastLineThreshold));
|
||||
|
||||
|
||||
//<2F><>tableWidget<65><74><EFBFBD>Ӳɼ<D3B2><C9BC><EFBFBD>
|
||||
//<2F><>1<EFBFBD><31>ȥ<EFBFBD><C8A5>tableWidget<65><74><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>
|
||||
int rowCount = ui.recordLine_tableWidget->rowCount();
|
||||
for (size_t i = 0; i < rowCount; i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->removeRow(0);
|
||||
}
|
||||
//<2F><>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ɼ<EFBFBD><C9BC>ߣ<EFBFBD>
|
||||
int RecordLineCount = number / ui.recordLine_tableWidget->columnCount();
|
||||
for (size_t i = 0; i < RecordLineCount; i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->insertRow(0);
|
||||
|
||||
}
|
||||
//<2F><>3<EFBFBD><33><EFBFBD><EFBFBD>tableWidget<65><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
for (size_t i = 0; i < ui.recordLine_tableWidget->rowCount(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
|
||||
{
|
||||
QTableWidgetItem* tmp = new QTableWidgetItem(QString::number(data[i * ui.recordLine_tableWidget->columnCount() + j], 10, 5));
|
||||
tmp->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, j, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(RecordLineFileHandle);
|
||||
delete[] data;
|
||||
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD>ȡ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>"));
|
||||
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include "ui_PathPlan.h"
|
||||
#include "vincecontrol.h"
|
||||
#include <QMotorDoubleSlider.h>
|
||||
|
||||
#define PI 3.1415926
|
||||
|
||||
class PathPlan : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PathPlan(VinceControl* xMotor, VinceControl* yMotor, QMotorDoubleSlider* xSlider, QMotorDoubleSlider* ySlider, QWidget* parent = nullptr);
|
||||
~PathPlan();
|
||||
|
||||
void setMotor(VinceControl* xMotor, VinceControl* yMotor);
|
||||
QTableWidget* getRecordLineTableWidget();
|
||||
|
||||
private:
|
||||
Ui::PathPlanClass ui;
|
||||
|
||||
VinceControl* m_xMotor;
|
||||
VinceControl* m_yMotor;
|
||||
|
||||
QMotorDoubleSlider* m_xSlider;
|
||||
QMotorDoubleSlider* m_ySlider;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onAddRecordLine_btn();
|
||||
void onRemoveRecordLine_btn();
|
||||
void onGenerateRecordLine_btn();
|
||||
void onDeleteRecordLine_btn();
|
||||
void onSaveRecordLine2File_btn();
|
||||
void onReadRecordLineFile_btn();
|
||||
};
|
||||
167
HPPA/RadianceConversion.ui
Normal file
167
HPPA/RadianceConversion.ui
Normal file
@ -0,0 +1,167 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RadianceConversion_UI</class>
|
||||
<widget class="QDialog" name="RadianceConversion_UI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>544</width>
|
||||
<height>177</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>辐亮度转换</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>影像</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>定标文件</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="imgPath_lineEdit">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="calFilePath_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="imgSelect_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="calFileSelect_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="conversion_btn">
|
||||
<property name="text">
|
||||
<string>转换</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>191</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
167
HPPA/ReflectanceConversion.ui
Normal file
167
HPPA/ReflectanceConversion.ui
Normal file
@ -0,0 +1,167 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ReflectanceConversion_UI</class>
|
||||
<widget class="QDialog" name="ReflectanceConversion_UI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>544</width>
|
||||
<height>177</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>反射率转换</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>影像</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>白板影像</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="imgPath_lineEdit">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="whiteImgPath_lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="imgSelect_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="whiteImgSelect_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="conversion_btn">
|
||||
<property name="text">
|
||||
<string>转换</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>191</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -353,7 +353,7 @@ void ResononNirImager::start_record()
|
||||
//ÿ<><C3BF>1s<31><73><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><CEBD><EFBFBD>ͼ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>
|
||||
if (m_iFrameCounter % (int)getFramerate() == 0)
|
||||
{
|
||||
emit PlotSignal(m_iFrameCounter);
|
||||
emit PlotSignal(m_FileSavedCounter, m_iFrameCounter);
|
||||
}
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
@ -365,14 +365,14 @@ void ResononNirImager::start_record()
|
||||
}
|
||||
imagerStopCollect();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<CDBC><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//m_RgbImage
|
||||
emit PlotSignal(m_FileSavedCounter, -1);//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Է<EFBFBD><D4B7>ɼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<CAB5><C4B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ȫ
|
||||
|
||||
m_bRecordControlState = false;
|
||||
WriteHdr();
|
||||
m_FileSavedCounter++;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<CDBC><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//m_RgbImage
|
||||
emit PlotSignal(-1);//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Է<EFBFBD><D4B7>ɼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<CAB5><C4B1><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ȫ
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
{
|
||||
emit RecordFinishedSignal_WhenFrameNumberMeet();
|
||||
@ -399,6 +399,7 @@ void ResononNirImager::WriteHdr()
|
||||
outfile << "interleave = bil\n";
|
||||
outfile << "data type = 12\n";
|
||||
outfile << "bit depth = 12\n";
|
||||
outfile << "byte order = 0\n";
|
||||
outfile << "samples = " << getSampleCount() << "\n";
|
||||
outfile << "bands = " << getBandCount() << "\n";
|
||||
outfile << "lines = " << m_iFrameCounter << "\n";
|
||||
|
||||
619
HPPA/TwoMotorControl.cpp
Normal file
619
HPPA/TwoMotorControl.cpp
Normal file
@ -0,0 +1,619 @@
|
||||
#include "TwoMotorControl.h"
|
||||
|
||||
TwoMotorControl::TwoMotorControl(QWidget* parent) : QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
ui.recordLine_tableWidget->setFocusPolicy(Qt::NoFocus);
|
||||
ui.recordLine_tableWidget->setStyleSheet("selection-background-color:rgb(255,209,128)");//设置选择的行高亮
|
||||
|
||||
ui.recordLine_tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);//设置选择行为,以行为单位
|
||||
//ui.recordLine_tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);//设置选择模式,选择单行
|
||||
//QHeaderView* headerView = ui.recordLine_tableWidget->verticalHeader();
|
||||
//headerView->setHidden(true);//去除左边默认自带序列号
|
||||
|
||||
connect(this->ui.connect_btn, SIGNAL(pressed()), this, SLOT(onConnectMotor()));
|
||||
|
||||
connect(ui.addRecordLine_btn, SIGNAL(clicked()), this, SLOT(onAddRecordLine_btn()));
|
||||
connect(ui.removeRecordLine_btn, SIGNAL(clicked()), this, SLOT(onRemoveRecordLine_btn()));
|
||||
connect(ui.generateRecordLine_btn, SIGNAL(clicked()), this, SLOT(onGenerateRecordLine_btn()));
|
||||
connect(ui.deleteRecordLine_btn, SIGNAL(clicked()), this, SLOT(onDeleteRecordLine_btn()));
|
||||
connect(ui.saveRecordLine2File_btn, SIGNAL(clicked()), this, SLOT(onSaveRecordLine2File_btn()));
|
||||
connect(ui.readRecordLineFile_btn, SIGNAL(clicked()), this, SLOT(onReadRecordLineFile_btn()));
|
||||
}
|
||||
|
||||
void TwoMotorControl::setImager(ImagerOperationBase* imager)
|
||||
{
|
||||
m_Imager = imager;
|
||||
}
|
||||
|
||||
void TwoMotorControl::setPosFileName(QString posFileName)
|
||||
{
|
||||
isWritePosFile = true;
|
||||
m_posFileName = posFileName;
|
||||
m_posFileHandle = fopen(posFileName.toStdString().c_str(), "w+");
|
||||
}
|
||||
|
||||
bool TwoMotorControl::getState()
|
||||
{
|
||||
QEventLoop loop;
|
||||
bool tmp = false;
|
||||
bool received = false;
|
||||
|
||||
QTimer timer;
|
||||
timer.setSingleShot(true);
|
||||
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
||||
|
||||
QMetaObject::Connection conn = QObject::connect(
|
||||
m_coordinator, &TwoMotionCaptureCoordinator::recordState,
|
||||
[&](bool state) {
|
||||
tmp = state;
|
||||
received = true;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
QMetaObject::invokeMethod(m_coordinator, "getRecordState", Qt::QueuedConnection);
|
||||
timer.start(3000);
|
||||
|
||||
loop.exec();
|
||||
|
||||
disconnect(conn);
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void TwoMotorControl::record_dark()
|
||||
{
|
||||
double s = ui.xmotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
if (m_darkCaptureCoordinator == nullptr)
|
||||
{
|
||||
m_darkCaptureCoordinator = new DarkAndWhiteCaptureCoordinator(0, m_multiAxisController, m_Imager);
|
||||
}
|
||||
|
||||
m_darkCaptureCoordinator->startStepMotion(s);
|
||||
}
|
||||
|
||||
void TwoMotorControl::record_white()
|
||||
{
|
||||
double s = ui.xmotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
if (m_whiteCaptureCoordinator == nullptr)
|
||||
{
|
||||
m_whiteCaptureCoordinator = new DarkAndWhiteCaptureCoordinator(1, m_multiAxisController, m_Imager);
|
||||
}
|
||||
|
||||
m_whiteCaptureCoordinator->startStepMotion(s);
|
||||
}
|
||||
|
||||
void TwoMotorControl::run()
|
||||
{
|
||||
if (m_coordinator==nullptr)
|
||||
{
|
||||
qRegisterMetaType<QVector<PathLine>>("QVector<PathLine>");
|
||||
m_coordinator = new TwoMotionCaptureCoordinator(m_multiAxisController, m_Imager);
|
||||
m_coordinator->moveToThread(&m_coordinatorThread);
|
||||
connect(&m_coordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(start(QVector<PathLine>)), m_coordinator, SLOT(start(QVector<PathLine>)));
|
||||
connect(this, SIGNAL(stopSignal()), m_coordinator, SLOT(stop()));
|
||||
connect(m_coordinator, SIGNAL(startRecordLineNumSignal(int)), this, SLOT(receiveStartRecordLineNum(int)));
|
||||
connect(m_coordinator, SIGNAL(finishRecordLineNumSignal(int)), this, SLOT(receiveFinishRecordLineNum(int)));
|
||||
connect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete()));
|
||||
m_coordinatorThread.start();
|
||||
}
|
||||
|
||||
if (getState())
|
||||
{
|
||||
//std::cout << "已经开始运行,请勿重复点击!!!!!!!!" << std::endl;
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("已经开始运行,请勿重复点击!!!!!!!!!"));
|
||||
return;
|
||||
}
|
||||
|
||||
QVector<PathLine> pathLines;
|
||||
int rowCount = ui.recordLine_tableWidget->rowCount();
|
||||
//int columnCount = ui.recordLine_tableWidget->columnCount();
|
||||
for (size_t i = 0; i < rowCount; i++)
|
||||
{
|
||||
PathLine tmp;
|
||||
|
||||
tmp.targetYPosition = ui.recordLine_tableWidget->item(i, 0)->text().toDouble();
|
||||
tmp.speedTargetYPosition = ui.recordLine_tableWidget->item(i, 1)->text().toDouble();
|
||||
tmp.targetXMinPosition = ui.recordLine_tableWidget->item(i, 2)->text().toDouble();
|
||||
tmp.speedTargetXMinPosition = ui.recordLine_tableWidget->item(i, 3)->text().toDouble();
|
||||
tmp.targetXMaxPosition = ui.recordLine_tableWidget->item(i, 4)->text().toDouble();
|
||||
tmp.speedTargetXMaxPosition = ui.recordLine_tableWidget->item(i, 5)->text().toDouble();
|
||||
|
||||
pathLines.append(tmp);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < ui.recordLine_tableWidget->rowCount(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
|
||||
{
|
||||
ui.recordLine_tableWidget->item(i, j)->setBackgroundColor(QColor(240, 240, 240));
|
||||
}
|
||||
}
|
||||
|
||||
emit start(pathLines);
|
||||
}
|
||||
|
||||
void TwoMotorControl::stop()
|
||||
{
|
||||
emit stopSignal();
|
||||
}
|
||||
|
||||
TwoMotorControl::~TwoMotorControl()
|
||||
{
|
||||
m_motorThread.quit();
|
||||
m_motorThread.wait();
|
||||
|
||||
m_coordinatorThread.quit();
|
||||
m_coordinatorThread.wait();
|
||||
}
|
||||
|
||||
void TwoMotorControl::onConnectMotor()
|
||||
{
|
||||
try
|
||||
{
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
QString configFilePath = QString::fromStdString(directory) + "\\twoMotorConfigFile.cfg";
|
||||
|
||||
m_multiAxisController = new IrisMultiMotorController(configFilePath);
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("请连接马达!"));
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
m_multiAxisController->moveToThread(&m_motorThread);
|
||||
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||
|
||||
connect(this->ui.xmotor_right_btn, SIGNAL(pressed()), this, SLOT(onxMotorRight()));
|
||||
connect(this->ui.xmotor_right_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
||||
connect(this->ui.xmotor_left_btn, SIGNAL(pressed()), this, SLOT(onxMotorLeft()));
|
||||
connect(this->ui.xmotor_left_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
||||
|
||||
connect(this->ui.ymotor_forward_btn, SIGNAL(pressed()), this, SLOT(onyMotorforward()));
|
||||
connect(this->ui.ymotor_forward_btn, SIGNAL(released()), this, SLOT(onyMotorStop()));
|
||||
connect(this->ui.ymotor_backward_btn, SIGNAL(pressed()), this, SLOT(onyMotorbackward()));
|
||||
connect(this->ui.ymotor_backward_btn, SIGNAL(released()), this, SLOT(onyMotorStop()));
|
||||
|
||||
connect(this->ui.move2loc_x_pushButton, SIGNAL(pressed()), this, SLOT(onxMove2Loc()));
|
||||
connect(this->ui.move2loc_y_pushButton, SIGNAL(pressed()), this, SLOT(onyMove2Loc()));
|
||||
|
||||
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(displayRealTimeLoc(std::vector<double>)));
|
||||
|
||||
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
|
||||
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
|
||||
|
||||
connect(this->ui.zero_start_btn, SIGNAL(released()), this, SLOT(zeroStart()));
|
||||
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||
|
||||
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(on_rangeMeasurement()));
|
||||
connect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||
|
||||
connect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
||||
connect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
||||
|
||||
m_motorThread.start();
|
||||
emit testConnectivitySignal(0, 1000);
|
||||
emit testConnectivitySignal(1, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::receiveStartRecordLineNum(int lineNum)
|
||||
{
|
||||
emit startLineNumSignal(lineNum);
|
||||
for (size_t i = 0; i < ui.recordLine_tableWidget->columnCount(); i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->item(lineNum, i)->setBackgroundColor(QColor(255, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
void TwoMotorControl::receiveFinishRecordLineNum(int lineNum)
|
||||
{
|
||||
for (size_t i = 0; i < ui.recordLine_tableWidget->columnCount(); i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->item(lineNum, i)->setBackgroundColor(QColor(0, 255, 0));
|
||||
}
|
||||
}
|
||||
|
||||
void TwoMotorControl::onSequenceComplete()
|
||||
{
|
||||
isWritePosFile = false;
|
||||
fclose(m_posFileHandle);
|
||||
|
||||
emit sequenceComplete();
|
||||
}
|
||||
|
||||
void TwoMotorControl::display_motors_connectivity(std::vector<int> connectivity)
|
||||
{
|
||||
//std::cout << "-----------------------------------"<<connectivity.size()<< std::endl;
|
||||
if (connectivity[0])
|
||||
{
|
||||
this->ui.xMotorStateLabel->setStyleSheet("QLabel{background-color:rgb(0,255,0);}");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui.xMotorStateLabel->setStyleSheet("QLabel{background-color:rgb(255,0,0);}");
|
||||
}
|
||||
|
||||
if (connectivity[1])
|
||||
{
|
||||
this->ui.yMotorStateLabel->setStyleSheet("QLabel{background-color:rgb(0,255,0);}");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui.yMotorStateLabel->setStyleSheet("QLabel{background-color:rgb(255,0,0);}");
|
||||
}
|
||||
}
|
||||
|
||||
void TwoMotorControl::onxMotorRight()
|
||||
{
|
||||
double s = ui.xmotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(0, false, s, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onxMotorLeft()
|
||||
{
|
||||
double s = ui.xmotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(0, true, s, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onxMotorStop()
|
||||
{
|
||||
emit stopSignal(0);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onyMotorforward()
|
||||
{
|
||||
double s = ui.ymotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(1, false, s, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onyMotorbackward()
|
||||
{
|
||||
double s = ui.ymotor_move_speed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(1, true, s, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onyMotorStop()
|
||||
{
|
||||
emit stopSignal(1);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onxMove2Loc()
|
||||
{
|
||||
double s = ui.xmotor_move_speed_lineEdit->text().toDouble();
|
||||
double l = ui.move2loc_x_lineEdit->text().toDouble();
|
||||
|
||||
emit move2LocSignal(0, l, s, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onyMove2Loc()
|
||||
{
|
||||
double s = ui.ymotor_move_speed_lineEdit->text().toDouble();
|
||||
double l = ui.move2loc_y_lineEdit->text().toDouble();
|
||||
|
||||
emit move2LocSignal(1, l, s, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::displayRealTimeLoc(std::vector<double> loc)
|
||||
{
|
||||
double tmp = round(loc[0] * 100) / 100;
|
||||
if (isWritePosFile)
|
||||
{
|
||||
long long timeOs = getNanosecondsSinceMidnight();
|
||||
fprintf(m_posFileHandle, "%lld,%f\n", timeOs, loc[0]);
|
||||
}
|
||||
this->ui.xmotor_realTimeLoc_lineEdit->setText(QString::number(tmp));
|
||||
|
||||
tmp = round(loc[1] * 100) / 100;
|
||||
this->ui.ymotor_realTimeLoc_lineEdit->setText(QString::number(tmp));
|
||||
}
|
||||
|
||||
void TwoMotorControl::zeroStart()
|
||||
{
|
||||
zeroStartSignal(0);
|
||||
zeroStartSignal(1);
|
||||
}
|
||||
|
||||
void TwoMotorControl::on_rangeMeasurement()
|
||||
{
|
||||
double s0 = ui.xmotor_move_speed_lineEdit->text().toDouble();
|
||||
emit rangeMeasurement(0, s0, 1000);
|
||||
|
||||
s0 = ui.ymotor_move_speed_lineEdit->text().toDouble();
|
||||
emit rangeMeasurement(1, s0, 1000);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onAddRecordLine_btn()
|
||||
{
|
||||
//准备数据:获取y马达的当前位置,获取x马达的当前位置和最大位置
|
||||
double currentPosOfYmotor = 15;
|
||||
|
||||
double currentPosOfXmotor = 0;
|
||||
double maxRangeOfXmotor = 50;
|
||||
|
||||
//获取选中行的索引
|
||||
int currentRow = ui.recordLine_tableWidget->currentRow();
|
||||
std::cout << "currentRow:" << currentRow << std::endl;
|
||||
|
||||
QTableWidgetItem* Item1 = new QTableWidgetItem(QString::number(currentPosOfYmotor, 10, 2));
|
||||
QTableWidgetItem* Item2 = new QTableWidgetItem(QString::number(1, 10, 2));
|
||||
QTableWidgetItem* Item3 = new QTableWidgetItem(QString::number(currentPosOfXmotor, 10, 2));
|
||||
QTableWidgetItem* Item4 = new QTableWidgetItem(QString::number(1, 10, 2));
|
||||
QTableWidgetItem* Item5 = new QTableWidgetItem(QString::number(maxRangeOfXmotor, 10, 2));
|
||||
QTableWidgetItem* Item6 = new QTableWidgetItem(QString::number(1, 10, 2));
|
||||
Item1->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
Item2->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
Item3->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
Item4->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
Item5->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
Item6->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
if (currentRow == -1)//当没有选中行时
|
||||
{
|
||||
int RowCount = ui.recordLine_tableWidget->rowCount();//Returns the number of rows. 从1开始的
|
||||
ui.recordLine_tableWidget->insertRow(RowCount);//增加一行,形参是从0开始的
|
||||
|
||||
ui.recordLine_tableWidget->setItem(RowCount, 0, Item1);
|
||||
ui.recordLine_tableWidget->setItem(RowCount, 1, Item2);
|
||||
ui.recordLine_tableWidget->setItem(RowCount, 2, Item3);
|
||||
ui.recordLine_tableWidget->setItem(RowCount, 3, Item4);
|
||||
ui.recordLine_tableWidget->setItem(RowCount, 4, Item5);
|
||||
ui.recordLine_tableWidget->setItem(RowCount, 5, Item6);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.recordLine_tableWidget->insertRow(currentRow + 1);//增加一行,形参是从0开始的
|
||||
|
||||
ui.recordLine_tableWidget->setItem(currentRow + 1, 0, Item1);
|
||||
ui.recordLine_tableWidget->setItem(currentRow + 1, 1, Item2);
|
||||
ui.recordLine_tableWidget->setItem(currentRow + 1, 2, Item3);
|
||||
ui.recordLine_tableWidget->setItem(currentRow + 1, 3, Item4);
|
||||
ui.recordLine_tableWidget->setItem(currentRow + 1, 4, Item5);
|
||||
ui.recordLine_tableWidget->setItem(currentRow + 1, 5, Item6);
|
||||
}
|
||||
}
|
||||
|
||||
void TwoMotorControl::onRemoveRecordLine_btn()
|
||||
{
|
||||
int rowIndex = ui.recordLine_tableWidget->currentRow();
|
||||
if (rowIndex != -1)
|
||||
ui.recordLine_tableWidget->removeRow(rowIndex);
|
||||
}
|
||||
|
||||
void TwoMotorControl::onGenerateRecordLine_btn()
|
||||
{
|
||||
//求幅宽
|
||||
double height = ui.height_lineEdit->text().toDouble();
|
||||
double fov = ui.fov_lineEdit->text().toDouble();
|
||||
double swath = (height * tan(fov / 2 * PI / 180)) * 2;//tan输入是弧度
|
||||
ui.swath_lineEdit->setText(QString::number(swath));
|
||||
|
||||
|
||||
//读取马达测量范围
|
||||
double xMotorRange = 50;
|
||||
double yMotorRange = 500;
|
||||
|
||||
|
||||
//确定有多少条采集线,公式:numberOfRecordLine_tmp * swath - repetitiveLength(numberOfRecordLine_tmp - 1) = overallLength
|
||||
double overallLength = yMotorRange + swath;
|
||||
double repetitiveRate = ui.repetitiveRate_lineEdit->text().toDouble() / 100;
|
||||
double repetitiveLength = repetitiveRate * swath;
|
||||
double offset = ui.offset_lineEdit->text().toDouble();
|
||||
|
||||
double numberOfRecordLine_tmp = (overallLength - repetitiveLength - offset) / (swath - repetitiveLength);
|
||||
double tmp = numberOfRecordLine_tmp - (int)numberOfRecordLine_tmp;
|
||||
int numberOfRecordLine;
|
||||
double threshold = ui.LastLineThreshold_lineEdit->text().toDouble();//当numberOfRecordLine_tmp为小数时,判断是否多加一条采集线
|
||||
if (tmp > threshold)
|
||||
{
|
||||
numberOfRecordLine = (int)numberOfRecordLine_tmp + 1;
|
||||
//std::cout << "大于:" << threshold << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
numberOfRecordLine = (int)numberOfRecordLine_tmp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//去掉tableWidget中所有的行
|
||||
int rowCount = ui.recordLine_tableWidget->rowCount();
|
||||
for (size_t i = 0; i < rowCount; i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->removeRow(0);
|
||||
}
|
||||
|
||||
|
||||
//向tableWidget添加行(采集线)
|
||||
QTableWidgetItem* tmpItem;
|
||||
for (size_t i = 0; i < numberOfRecordLine; i++)
|
||||
{
|
||||
//增加一行
|
||||
int RowCount = ui.recordLine_tableWidget->rowCount();
|
||||
ui.recordLine_tableWidget->insertRow(RowCount);
|
||||
|
||||
//设置yPosition
|
||||
if (tmp > threshold && i == numberOfRecordLine - 1)//设置最后一行的yPosition
|
||||
{
|
||||
tmpItem = new QTableWidgetItem(QString::number(yMotorRange, 10, 2));
|
||||
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, 0, tmpItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
double x = swath * i - i * repetitiveLength + offset;
|
||||
tmpItem = new QTableWidgetItem(QString::number(x, 10, 2));
|
||||
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, 0, tmpItem);
|
||||
}
|
||||
tmpItem = new QTableWidgetItem(QString::number(1, 10, 2));
|
||||
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, 1, tmpItem);
|
||||
|
||||
tmpItem = new QTableWidgetItem(QString::number(0, 10, 2));
|
||||
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, 2, tmpItem);
|
||||
tmpItem = new QTableWidgetItem(QString::number(1, 10, 2));
|
||||
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, 3, tmpItem);
|
||||
|
||||
//设置x马达最大运动位置 → 值设置为x马达量程
|
||||
tmpItem = new QTableWidgetItem(QString::number(xMotorRange, 10, 2));
|
||||
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, 4, tmpItem);
|
||||
tmpItem = new QTableWidgetItem(QString::number(1, 10, 2));
|
||||
tmpItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, 5, tmpItem);
|
||||
}
|
||||
}
|
||||
|
||||
void TwoMotorControl::onDeleteRecordLine_btn()
|
||||
{
|
||||
int rowCount = ui.recordLine_tableWidget->rowCount();
|
||||
for (size_t i = 0; i < rowCount; i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->removeRow(0);
|
||||
}
|
||||
}
|
||||
|
||||
void TwoMotorControl::onSaveRecordLine2File_btn()
|
||||
{
|
||||
//确保采集线存在
|
||||
if (ui.recordLine_tableWidget->rowCount() <= 0)
|
||||
{
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请先生成轨迹!"));
|
||||
return;
|
||||
}
|
||||
|
||||
double height = ui.height_lineEdit->text().toDouble();
|
||||
double fov = ui.fov_lineEdit->text().toDouble();
|
||||
double swath = ui.swath_lineEdit->text().toDouble();
|
||||
double offset = ui.offset_lineEdit->text().toDouble();
|
||||
double repetitiveRate = ui.repetitiveRate_lineEdit->text().toDouble();
|
||||
double LastLineThreshold = ui.LastLineThreshold_lineEdit->text().toDouble();
|
||||
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
|
||||
QString RecordLineFilePath = QFileDialog::getSaveFileName(this, tr("Save RecordLine2 File"),
|
||||
QString::fromStdString(directory),
|
||||
tr("RecordLineFile2 (*.RecordLine2)"));
|
||||
|
||||
if (RecordLineFilePath.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FILE* RecordLineFileHandle = fopen(RecordLineFilePath.toStdString().c_str(), "wb+");
|
||||
|
||||
fwrite(&height, sizeof(double), 1, RecordLineFileHandle);
|
||||
fwrite(&fov, sizeof(double), 1, RecordLineFileHandle);
|
||||
fwrite(&swath, sizeof(double), 1, RecordLineFileHandle);
|
||||
fwrite(&offset, sizeof(double), 1, RecordLineFileHandle);
|
||||
fwrite(&repetitiveRate, sizeof(double), 1, RecordLineFileHandle);
|
||||
fwrite(&LastLineThreshold, sizeof(double), 1, RecordLineFileHandle);
|
||||
|
||||
double number = ui.recordLine_tableWidget->rowCount() * ui.recordLine_tableWidget->columnCount();
|
||||
fwrite(&number, sizeof(double), 1, RecordLineFileHandle);
|
||||
|
||||
double* data = new double[number];
|
||||
//double data[number];
|
||||
for (size_t i = 0; i < ui.recordLine_tableWidget->rowCount(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
|
||||
{
|
||||
data[i * ui.recordLine_tableWidget->columnCount() + j] = ui.recordLine_tableWidget->item(i, j)->text().toDouble();
|
||||
}
|
||||
}
|
||||
|
||||
fwrite(data, sizeof(double), number, RecordLineFileHandle);
|
||||
|
||||
fclose(RecordLineFileHandle);
|
||||
delete[] data;
|
||||
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("保存成功!"));
|
||||
}
|
||||
|
||||
void TwoMotorControl::onReadRecordLineFile_btn()
|
||||
{
|
||||
//打开文件
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
|
||||
QString RecordLineFilePath = QFileDialog::getOpenFileName(this, tr("Open RecordLine2 File"),
|
||||
QString::fromStdString(directory),
|
||||
tr("RecordLineFile (*.RecordLine2)"));
|
||||
|
||||
if (RecordLineFilePath.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FILE* RecordLineFileHandle = fopen(RecordLineFilePath.toStdString().c_str(), "rb");
|
||||
double height, fov, swath, offset, repetitiveRate, LastLineThreshold, number;
|
||||
|
||||
//读取数据
|
||||
fread(&height, sizeof(double), 1, RecordLineFileHandle);
|
||||
fread(&fov, sizeof(double), 1, RecordLineFileHandle);
|
||||
fread(&swath, sizeof(double), 1, RecordLineFileHandle);
|
||||
fread(&offset, sizeof(double), 1, RecordLineFileHandle);
|
||||
fread(&repetitiveRate, sizeof(double), 1, RecordLineFileHandle);
|
||||
fread(&LastLineThreshold, sizeof(double), 1, RecordLineFileHandle);
|
||||
fread(&number, sizeof(double), 1, RecordLineFileHandle);
|
||||
|
||||
double* data = new double[number];
|
||||
for (size_t i = 0; i < number; i++)
|
||||
{
|
||||
fread(data + i, sizeof(double), 1, RecordLineFileHandle);
|
||||
//std::cout << *(data + i) << std::endl;
|
||||
}
|
||||
|
||||
//向界面中填写
|
||||
ui.height_lineEdit->setText(QString::number(height));
|
||||
ui.fov_lineEdit->setText(QString::number(fov));
|
||||
ui.swath_lineEdit->setText(QString::number(swath));
|
||||
ui.offset_lineEdit->setText(QString::number(offset));
|
||||
ui.repetitiveRate_lineEdit->setText(QString::number(repetitiveRate));
|
||||
ui.LastLineThreshold_lineEdit->setText(QString::number(LastLineThreshold));
|
||||
|
||||
|
||||
//向tableWidget添加采集线
|
||||
//(1)去掉tableWidget中所有的行
|
||||
int rowCount = ui.recordLine_tableWidget->rowCount();
|
||||
for (size_t i = 0; i < rowCount; i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->removeRow(0);
|
||||
}
|
||||
//(2)添加行(采集线)
|
||||
int RecordLineCount = number / ui.recordLine_tableWidget->columnCount();
|
||||
for (size_t i = 0; i < RecordLineCount; i++)
|
||||
{
|
||||
ui.recordLine_tableWidget->insertRow(0);
|
||||
|
||||
}
|
||||
//(3)向tableWidget填充数据
|
||||
for (size_t i = 0; i < ui.recordLine_tableWidget->rowCount(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < ui.recordLine_tableWidget->columnCount(); j++)
|
||||
{
|
||||
QTableWidgetItem* tmp = new QTableWidgetItem(QString::number(data[i * ui.recordLine_tableWidget->columnCount() + j], 10, 5));
|
||||
tmp->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui.recordLine_tableWidget->setItem(i, j, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(RecordLineFileHandle);
|
||||
delete[] data;
|
||||
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("读取成功!"));
|
||||
}
|
||||
97
HPPA/TwoMotorControl.h
Normal file
97
HPPA/TwoMotorControl.h
Normal file
@ -0,0 +1,97 @@
|
||||
#pragma once
|
||||
#include <QThread>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "ui_twoMotorControl.h"
|
||||
|
||||
#include "IrisMultiMotorController.h"
|
||||
#include "fileOperation.h"
|
||||
#include "CaptureCoordinator.h"
|
||||
|
||||
#define PI 3.1415926
|
||||
|
||||
|
||||
|
||||
class TwoMotorControl : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TwoMotorControl(QWidget* parent = nullptr);
|
||||
~TwoMotorControl();
|
||||
|
||||
void setImager(ImagerOperationBase* imager);
|
||||
void setPosFileName(QString posFileName);
|
||||
|
||||
void record_dark();
|
||||
void record_white();
|
||||
|
||||
private:
|
||||
ImagerOperationBase* m_Imager;
|
||||
bool getState();
|
||||
|
||||
bool isWritePosFile = false;
|
||||
QString m_posFileName;
|
||||
FILE* m_posFileHandle;
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void onConnectMotor();
|
||||
|
||||
void displayRealTimeLoc(std::vector<double> loc);
|
||||
void display_motors_connectivity(std::vector<int> connectivity);
|
||||
//void onxMove2Loc();
|
||||
void zeroStart();
|
||||
void on_rangeMeasurement();
|
||||
|
||||
void onxMotorRight();
|
||||
void onxMotorLeft();
|
||||
void onxMotorStop();
|
||||
void onxMove2Loc();
|
||||
|
||||
void onyMotorforward();
|
||||
void onyMotorbackward();
|
||||
void onyMotorStop();
|
||||
void onyMove2Loc();
|
||||
|
||||
void onAddRecordLine_btn();
|
||||
void onRemoveRecordLine_btn();
|
||||
void onGenerateRecordLine_btn();
|
||||
void onDeleteRecordLine_btn();
|
||||
void onSaveRecordLine2File_btn();
|
||||
void onReadRecordLineFile_btn();
|
||||
|
||||
void run();
|
||||
void stop();
|
||||
void receiveStartRecordLineNum(int lineNum);
|
||||
void receiveFinishRecordLineNum(int lineNum);
|
||||
void onSequenceComplete();
|
||||
|
||||
signals:
|
||||
void moveSignal(int, bool, double, int);
|
||||
void move2LocSignal(int, double, double, int);
|
||||
void move2LocSignal(const std::vector<double>, const std::vector<double>, int);
|
||||
void stopSignal(int);
|
||||
|
||||
void rangeMeasurement(int, double, int);
|
||||
void zeroStartSignal(int);
|
||||
void testConnectivitySignal(int, int);
|
||||
|
||||
void start(QVector<PathLine>);
|
||||
void stopSignal();
|
||||
|
||||
void startLineNumSignal(int lineNum);
|
||||
void sequenceComplete();//所有采集线正常运行完成
|
||||
|
||||
private:
|
||||
Ui::twoMotorControl_UI ui;
|
||||
QThread m_coordinatorThread;
|
||||
TwoMotionCaptureCoordinator* m_coordinator = nullptr;
|
||||
|
||||
DarkAndWhiteCaptureCoordinator* m_darkCaptureCoordinator = nullptr;
|
||||
DarkAndWhiteCaptureCoordinator* m_whiteCaptureCoordinator = nullptr;
|
||||
|
||||
QThread m_motorThread;
|
||||
IrisMultiMotorController* m_multiAxisController;
|
||||
};
|
||||
@ -70,7 +70,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>版本:1.9.0</string>
|
||||
<string>版本:T2.1.2</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
||||
#include "focusWindow.h"
|
||||
|
||||
focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
//<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
//读取配置文件
|
||||
string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg";
|
||||
Configfile configfile;
|
||||
configfile.setConfigfilePath(HPPACfgFile);
|
||||
@ -18,7 +18,7 @@ focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager)
|
||||
|
||||
disableBeforeConnect(true);
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);//<EFBFBD><EFBFBD><EFBFBD>ùرմ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
setAttribute(Qt::WA_DeleteOnClose);//设置关闭窗体就调用窗体的析构函数
|
||||
|
||||
m_Imager = imager;
|
||||
m_FocusState = 0;
|
||||
@ -38,7 +38,9 @@ focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager)
|
||||
connect(this->ui.updateCurrentLocation_btn, SIGNAL(clicked()), this, SLOT(onUpdateCurrentLocation()));
|
||||
connect(this->ui.moveto_btn, SIGNAL(clicked()), this, SLOT(onMoveto()));
|
||||
|
||||
//<2F><><EFBFBD>ҿ<EFBFBD><D2BF>ô<EFBFBD><C3B4>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD>ʾ
|
||||
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement()));
|
||||
|
||||
//查找可用串口,并显示
|
||||
foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
|
||||
{
|
||||
QSerialPort serial;
|
||||
@ -51,20 +53,29 @@ focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager)
|
||||
}
|
||||
}
|
||||
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//设置自动调焦进度条
|
||||
ui.autoFocusProgress_progressBar->setMinimum(0);
|
||||
ui.autoFocusProgress_progressBar->setMaximum(100);
|
||||
ui.autoFocusProgress_progressBar->reset();
|
||||
|
||||
m_dSpeed = 1.0;
|
||||
|
||||
}
|
||||
|
||||
focusWindow::~focusWindow()
|
||||
{
|
||||
printf("destroy focusWindow-------------------------\n");
|
||||
|
||||
emit StartManualFocusSignal(0);//<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>û<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>ֹͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>رմ<EFBFBD><EFBFBD><EFBFBD>
|
||||
emit StartManualFocusSignal(0);//当用户没有点击停止调焦就关闭窗口
|
||||
|
||||
delete m_ctrlFocusMotor;
|
||||
//delete thread1, progressThread;
|
||||
|
||||
m_motorThread.quit();
|
||||
m_motorThread.wait();
|
||||
|
||||
m_MotionCaptureCoordinatorThread.quit();
|
||||
m_MotionCaptureCoordinatorThread.wait();
|
||||
}
|
||||
|
||||
void focusWindow::disableBeforeConnect(bool disable)
|
||||
@ -92,142 +103,239 @@ bool test(void *pCaller, int *x, int *y, void **pvdata)
|
||||
|
||||
void focusWindow::onConnectMotor()
|
||||
{
|
||||
if (m_ctrlFocusMotor != nullptr)
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-------------------------\n");
|
||||
return;
|
||||
}
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
QString configFilePath = QString::fromStdString(directory) + "\\oneMotorConfigFile_focus.cfg";
|
||||
|
||||
bool isUltrasound = ui.ultrasound_radioButton->isChecked();
|
||||
|
||||
QString motorPortTmp = ui.motorPort_comboBox->currentText();
|
||||
QString ultrasoundPortTmp = ui.ultrasoundPort_comboBox->currentText();
|
||||
|
||||
QRegExp rx("\\d+$");
|
||||
rx.indexIn(motorPortTmp, 0);
|
||||
int motorPort = rx.cap(0).toInt();
|
||||
rx.indexIn(ultrasoundPortTmp, 0);
|
||||
int ultrasoundPort = rx.cap(0).toInt();
|
||||
|
||||
|
||||
|
||||
if (isUltrasound)
|
||||
{
|
||||
PortInfo motor;
|
||||
motor.iPortType = 0;
|
||||
motor.indexParity = 0;
|
||||
m_multiAxisController = new IrisMultiMotorController(configFilePath);
|
||||
m_multiAxisController->moveToThread(&m_motorThread);
|
||||
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(rmoveSignal(int, double, double, int)), m_multiAxisController, SLOT(rmove(int, double, double, int)));
|
||||
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(rangeMeasurementSignal(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||
connect(this, SIGNAL(move2MaxLocSignal(int, double, int)), m_multiAxisController, SLOT(moveToMax(int, double, int)));
|
||||
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
||||
connect(m_multiAxisController, SIGNAL(motorStopSignal(int, double)), this, SLOT(moveAfterAutoFocus(int, double)));
|
||||
m_motorThread.start();
|
||||
|
||||
motor.iPortNumber = motorPort;
|
||||
motor.indexBaudRate = 0x13;
|
||||
motor.indexBytesize = 3;
|
||||
motor.indexStopBits = 0;
|
||||
//归零
|
||||
//emit zeroStartSignal(0);
|
||||
|
||||
PortInfo ultrasound;
|
||||
ultrasound.iPortType = 0;
|
||||
ultrasound.indexParity = 0;
|
||||
ultrasound.iPortNumber = ultrasoundPort;
|
||||
ultrasound.indexBaudRate = 0x0C;
|
||||
ultrasound.indexBytesize = 3;
|
||||
ultrasound.indexStopBits = 0;
|
||||
|
||||
m_ctrlFocusMotor = new CFocusMotorControl();
|
||||
|
||||
m_ctrlFocusMotor->SetLogicZero(m_iMinPos);
|
||||
m_ctrlFocusMotor->SetLimit(m_iMinPos, m_iMaxPos);
|
||||
m_ctrlFocusMotor->InitSystem(motor, ultrasound, test, this);
|
||||
//m_ctrlFocusMotor->MoveToLogicZero();
|
||||
//自动调焦逻辑
|
||||
m_coordinator = new MotionCaptureCoordinator(m_multiAxisController, m_Imager);
|
||||
m_coordinator->moveToThread(&m_MotionCaptureCoordinatorThread);
|
||||
connect(&m_MotionCaptureCoordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(startStepMotion(double, int, double, double)), m_coordinator, SLOT(startStepMotion(double, int, double, double)));
|
||||
connect(m_coordinator, SIGNAL(progressChanged(int)), this, SLOT(onAutoFocusProgress(int)));
|
||||
connect(m_coordinator, SIGNAL(sequenceComplete()), this, SLOT(onAutoFocusFinished()));
|
||||
m_MotionCaptureCoordinatorThread.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
PortInfo motor;
|
||||
motor.iPortType = 0;
|
||||
motor.indexParity = 0;
|
||||
motor.iPortNumber = motorPort;
|
||||
motor.indexBaudRate = 0x13;
|
||||
motor.indexBytesize = 3;
|
||||
motor.indexStopBits = 0;
|
||||
if (m_ctrlFocusMotor != nullptr)
|
||||
{
|
||||
printf("不能重复连接-------------------------\n");
|
||||
return;
|
||||
}
|
||||
|
||||
m_ctrlFocusMotor = new CFocusMotorControl();
|
||||
bool isUltrasound = ui.ultrasound_radioButton->isChecked();
|
||||
|
||||
m_ctrlFocusMotor->SetLogicZero(m_iMinPos);
|
||||
m_ctrlFocusMotor->SetLimit(m_iMinPos, m_iMaxPos);
|
||||
m_ctrlFocusMotor->InitSystem(motor, test, this);
|
||||
m_ctrlFocusMotor->MoveToLogicZero();
|
||||
QString motorPortTmp = ui.motorPort_comboBox->currentText();
|
||||
QString ultrasoundPortTmp = ui.ultrasoundPort_comboBox->currentText();
|
||||
|
||||
QRegExp rx("\\d+$");
|
||||
rx.indexIn(motorPortTmp, 0);
|
||||
int motorPort = rx.cap(0).toInt();
|
||||
rx.indexIn(ultrasoundPortTmp, 0);
|
||||
int ultrasoundPort = rx.cap(0).toInt();
|
||||
|
||||
|
||||
|
||||
if (isUltrasound)
|
||||
{
|
||||
PortInfo motor;
|
||||
motor.iPortType = 0;
|
||||
motor.indexParity = 0;
|
||||
|
||||
motor.iPortNumber = motorPort;
|
||||
motor.indexBaudRate = 0x13;
|
||||
motor.indexBytesize = 3;
|
||||
motor.indexStopBits = 0;
|
||||
|
||||
PortInfo ultrasound;
|
||||
ultrasound.iPortType = 0;
|
||||
ultrasound.indexParity = 0;
|
||||
ultrasound.iPortNumber = ultrasoundPort;
|
||||
ultrasound.indexBaudRate = 0x0C;
|
||||
ultrasound.indexBytesize = 3;
|
||||
ultrasound.indexStopBits = 0;
|
||||
|
||||
m_ctrlFocusMotor = new CFocusMotorControl();
|
||||
|
||||
m_ctrlFocusMotor->SetLogicZero(m_iMinPos);
|
||||
m_ctrlFocusMotor->SetLimit(m_iMinPos, m_iMaxPos);
|
||||
m_ctrlFocusMotor->InitSystem(motor, ultrasound, test, this);
|
||||
//m_ctrlFocusMotor->MoveToLogicZero();
|
||||
}
|
||||
else
|
||||
{
|
||||
PortInfo motor;
|
||||
motor.iPortType = 0;
|
||||
motor.indexParity = 0;
|
||||
motor.iPortNumber = motorPort;
|
||||
motor.indexBaudRate = 0x13;
|
||||
motor.indexBytesize = 3;
|
||||
motor.indexStopBits = 0;
|
||||
|
||||
m_ctrlFocusMotor = new CFocusMotorControl();
|
||||
|
||||
m_ctrlFocusMotor->SetLogicZero(m_iMinPos);
|
||||
m_ctrlFocusMotor->SetLimit(m_iMinPos, m_iMaxPos);
|
||||
m_ctrlFocusMotor->InitSystem(motor, test, this);
|
||||
m_ctrlFocusMotor->MoveToLogicZero();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
disableBeforeConnect(false);
|
||||
}
|
||||
|
||||
void focusWindow::display_x_loc(std::vector<double> loc)
|
||||
{
|
||||
double tmp = round(loc[0] * 100) / 100;
|
||||
this->ui.currentLocation_lineEdit->setText(QString::number(tmp));
|
||||
}
|
||||
|
||||
void focusWindow::onx_rangeMeasurement()
|
||||
{
|
||||
emit rangeMeasurementSignal(0, m_dSpeed, 1000);
|
||||
}
|
||||
|
||||
void focusWindow::onMove2MotorLogicZero()
|
||||
{
|
||||
m_ctrlFocusMotor->MoveToLogicZero();
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
emit zeroStartSignal(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ctrlFocusMotor->MoveToLogicZero();
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onMove2MotorMax()
|
||||
{
|
||||
m_ctrlFocusMotor->MoveToPos(m_iMaxPos);
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
emit move2MaxLocSignal(0, m_dSpeed, 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ctrlFocusMotor->MoveToPos(m_iMaxPos);
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onAdd()
|
||||
{
|
||||
DriverInfo di;
|
||||
m_ctrlFocusMotor->GetDriverStatus(di);
|
||||
double rdistance = ui.addStepSize_lineEdit->text().toDouble();
|
||||
|
||||
int stepSize = ui.addStepSize_lineEdit->text().toInt();
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
emit rmoveSignal(0, (double)abs(rdistance), m_dSpeed, 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
DriverInfo di;
|
||||
m_ctrlFocusMotor->GetDriverStatus(di);
|
||||
|
||||
m_ctrlFocusMotor->MoveToPos(di.iAbsPosition + stepSize);
|
||||
m_ctrlFocusMotor->MoveToPos(di.iAbsPosition + rdistance);
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onSubtract()
|
||||
{
|
||||
DriverInfo di;
|
||||
m_ctrlFocusMotor->GetDriverStatus(di);
|
||||
double rdistance = ui.subtractStepSize_lineEdit->text().toDouble();
|
||||
|
||||
int stepSize = ui.subtractStepSize_lineEdit->text().toInt();
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
emit rmoveSignal(0, (double)abs(rdistance) * -1, m_dSpeed, 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
DriverInfo di;
|
||||
m_ctrlFocusMotor->GetDriverStatus(di);
|
||||
|
||||
m_ctrlFocusMotor->MoveToPos(di.iAbsPosition - stepSize);
|
||||
m_ctrlFocusMotor->MoveToPos(di.iAbsPosition - rdistance);
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onAutoFocus()
|
||||
{
|
||||
bool isUltrasound = ui.ultrasound_radioButton->isChecked();
|
||||
WorkerThread2 *thread1 = new WorkerThread2(m_ctrlFocusMotor, isUltrasound);
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
//先按照一定间隔从负极限到正极限获取一系列(位置,调焦指数)
|
||||
m_iStepSize = ui.sample_ratio_lineEdit->text().toInt();
|
||||
ui.autoFocusProgress_progressBar->setMinimum(0);
|
||||
ui.autoFocusProgress_progressBar->setMaximum(m_iStepSize);
|
||||
ui.autoFocusProgress_progressBar->reset();
|
||||
|
||||
connect(thread1, SIGNAL(AutoFocusFinishedSignal()), this, SLOT(onAutoFocusFinished()));
|
||||
//获取马达最大位置
|
||||
std::vector<double> maxRangeLocations = m_multiAxisController->getMaxPos();
|
||||
double maxPos = maxRangeLocations[0];
|
||||
emit startStepMotion(m_dSpeed, m_iStepSize, 0, maxPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isUltrasound = ui.ultrasound_radioButton->isChecked();
|
||||
WorkerThread2* thread1 = new WorkerThread2(m_ctrlFocusMotor, isUltrasound);
|
||||
|
||||
thread1->start();
|
||||
connect(thread1, SIGNAL(AutoFocusFinishedSignal()), this, SLOT(onAutoFocusFinished()));
|
||||
|
||||
thread1->start();
|
||||
|
||||
WorkerThread4* progressThread = new WorkerThread4(m_ctrlFocusMotor);
|
||||
connect(progressThread, SIGNAL(AutoFocusProgressSignal(int)), this, SLOT(onAutoFocusProgress(int)));
|
||||
progressThread->start();
|
||||
ui.autoFocusProgress_progressBar->reset();
|
||||
}
|
||||
this->setDisabled(true);
|
||||
|
||||
WorkerThread4 *progressThread = new WorkerThread4(m_ctrlFocusMotor);
|
||||
connect(progressThread, SIGNAL(AutoFocusProgressSignal(int)), this, SLOT(onAutoFocusProgress(int)));
|
||||
progressThread->start();
|
||||
ui.autoFocusProgress_progressBar->reset();
|
||||
}
|
||||
|
||||
void focusWindow::onManualFocus()
|
||||
{
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
m_FocusState += 1;
|
||||
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť<EFBFBD><EFBFBD>" << std::endl;
|
||||
std::cout << "点击调焦按钮!" << std::endl;
|
||||
|
||||
|
||||
if (m_FocusState % 2 == 1)
|
||||
{
|
||||
//<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//开始调焦
|
||||
emit StartManualFocusSignal(1);
|
||||
ui.manualFocus_btn->setText(QString::fromLocal8Bit("ֹͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
||||
ui.manualFocus_btn->setText(QString::fromLocal8Bit("停止调焦"));
|
||||
|
||||
ui.manualFocus_btn->setStyleSheet("QWidget{background-color:rgb(255,0,0);}");
|
||||
|
||||
ui.autoFocus_btn->setDisabled(true);
|
||||
|
||||
//std::cout << "------------------------------------------<EFBFBD><EFBFBD>" << m_FocusState << std::endl;
|
||||
//std::cout << "------------------------------------------:" << m_FocusState << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
emit StartManualFocusSignal(0);
|
||||
m_Imager->setFocusControlState(false);
|
||||
|
||||
ui.manualFocus_btn->setText(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
||||
ui.manualFocus_btn->setText(QString::fromLocal8Bit("调焦"));
|
||||
|
||||
ui.manualFocus_btn->setStyleSheet("QWidget{background-color:rgb(0,255,0);}");
|
||||
|
||||
@ -237,30 +345,192 @@ void focusWindow::onManualFocus()
|
||||
|
||||
void focusWindow::onUpdateCurrentLocation()
|
||||
{
|
||||
DriverInfo di;
|
||||
m_ctrlFocusMotor->GetDriverStatus(di);
|
||||
ui.currentLocation_lineEdit->setText(QString::number(di.iAbsPosition));
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
//因为新版的马达控制是实时反馈位置信息,所以不需要做任何事
|
||||
}
|
||||
else
|
||||
{
|
||||
DriverInfo di;
|
||||
m_ctrlFocusMotor->GetDriverStatus(di);
|
||||
ui.currentLocation_lineEdit->setText(QString::number(di.iAbsPosition));
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onMoveto()
|
||||
{
|
||||
int pos = ui.currentLocation_lineEdit->text().toInt();
|
||||
//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>֤<EFBFBD><D6A4><EFBFBD>鿴<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>Χ<EFBFBD><CEA7>
|
||||
double pos = ui.move2_lineEdit->text().toDouble();
|
||||
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
emit move2LocSignal(0, (double)pos, m_dSpeed, 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
//需要做参数有效性验证,查看是否在有效范围内
|
||||
|
||||
m_ctrlFocusMotor->MoveToPos(pos);
|
||||
m_ctrlFocusMotor->MoveToPos(pos);
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onAutoFocusFinished()
|
||||
{
|
||||
this->setDisabled(false);
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
//通过高斯拟合获取最佳位置
|
||||
QVector<PositionData> positionData = m_coordinator->getAllPositionData();
|
||||
|
||||
onUpdateCurrentLocation();
|
||||
std::vector<double> actualPositions;
|
||||
std::vector<double> cameraIndices;
|
||||
|
||||
actualPositions.reserve(positionData.size());
|
||||
cameraIndices.reserve(positionData.size());
|
||||
|
||||
int scaleFactor = 100;
|
||||
for (const auto& data : positionData)
|
||||
{
|
||||
actualPositions.push_back(data.actualPosition * scaleFactor);
|
||||
cameraIndices.push_back(data.cameraIndex);
|
||||
}
|
||||
double a_init, mu_init, sigma_init, c_init;
|
||||
getGaussianInitParam(actualPositions, cameraIndices, a_init, mu_init, sigma_init, c_init);
|
||||
|
||||
double a = a_init, mu = mu_init, sigma = sigma_init, c = c_init;
|
||||
gaussian_fit(actualPositions, cameraIndices, a, mu, sigma, c);
|
||||
|
||||
mu_init = mu_init / scaleFactor;
|
||||
mu = mu / scaleFactor;
|
||||
|
||||
std::cout << "mu 初值:" << mu_init << std::endl << "mu 拟合值:" << mu << std::endl;
|
||||
|
||||
//对拟合值进行判断,排除错误拟合情况(地物没有纹理)
|
||||
std::vector<double> maxRangeLocations = m_multiAxisController->getMaxPos();
|
||||
double maxPos = maxRangeLocations[0];
|
||||
if (mu < 0 || mu > maxPos)
|
||||
{
|
||||
std::cout << "拟合失败!!!!!" << std::endl;
|
||||
m_goodPos = mu_init;
|
||||
m_isAutoFocusSuccess = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "拟合成功!!!!!" << std::endl;
|
||||
m_goodPos = mu;
|
||||
m_isAutoFocusSuccess = true;
|
||||
}
|
||||
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
QString format1 = "yyyyMMdd_HHmmss";
|
||||
QString fileName = now.toString("yyyyMMdd_HHmmss");
|
||||
|
||||
QString fitDataFile = QDir::cleanPath(QString::fromStdString(directory) + QDir::separator() + fileName + "_" + QString::number(m_iStepSize) + "interval_" + QString::number(mu) + ".csv");
|
||||
m_coordinator->saveToCsv(fitDataFile);
|
||||
|
||||
//由于马达移动准确性较低,自动调焦完成后,直接移动到m_goodPos效果不好,所以先移动到tmpPos,然后移动到m_goodPos
|
||||
double tmpPos = m_goodPos - positionData[positionData.size() - 1].actualPosition / 10;
|
||||
m_isMoveAfterAutoFocus = true;
|
||||
emit move2LocSignal(0, (double)tmpPos, m_dSpeed, 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
onUpdateCurrentLocation();
|
||||
}
|
||||
|
||||
this->setDisabled(false);
|
||||
}
|
||||
|
||||
void focusWindow::moveAfterAutoFocus(int motorID, double location)
|
||||
{
|
||||
if (!m_isMoveAfterAutoFocus)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "\n已经到达位置:" << location << std::endl;
|
||||
|
||||
//移动马达到最佳位置
|
||||
emit move2LocSignal(0, (double)m_goodPos, m_dSpeed, 1000);
|
||||
|
||||
double tmp = abs(location - m_goodPos) / m_goodPos * 100;
|
||||
if (tmp<5)
|
||||
{
|
||||
if (!m_isAutoFocusSuccess)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("纹理较弱,自动调焦效果不佳!请使用调焦纸进行自动调焦!"));
|
||||
msgBox.exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("自动调焦成功!"));
|
||||
msgBox.exec();
|
||||
}
|
||||
m_isMoveAfterAutoFocus = false;
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::getGaussianInitParam(const std::vector<double>& pos, const std::vector<double>& index, double& a_init, double& mu_init, double& sigma_init, double& c_init)
|
||||
{
|
||||
auto minmax_element = std::minmax_element(index.begin(), index.end());
|
||||
a_init = *minmax_element.second - *minmax_element.first;
|
||||
mu_init = pos[std::distance(index.begin(), minmax_element.second)];
|
||||
c_init = *minmax_element.first;
|
||||
|
||||
//sigma_init
|
||||
double half_max = (*minmax_element.second + *minmax_element.first) / 2.0;
|
||||
size_t peak_idx = std::distance(index.begin(), minmax_element.second);
|
||||
size_t left_idx = peak_idx;// 找左半高点
|
||||
while (left_idx > 0 && index[left_idx] > half_max) left_idx--;
|
||||
size_t right_idx = peak_idx;// 找右半高点
|
||||
while (right_idx < index.size() - 1 && index[right_idx] > half_max) right_idx++;
|
||||
double fwhm = pos[right_idx] - pos[left_idx];
|
||||
sigma_init = fwhm / 2.3548;
|
||||
}
|
||||
|
||||
// 使用 Gauss-Newton 进行高斯拟合
|
||||
void focusWindow::gaussian_fit(const std::vector<double>& x_data,
|
||||
const std::vector<double>& y_data,
|
||||
double& a, double& mu, double& sigma, double& c)
|
||||
{
|
||||
const int max_iter = 100;
|
||||
for (int iter = 0; iter < max_iter; iter++)
|
||||
{
|
||||
Eigen::MatrixXd J(x_data.size(), 4);
|
||||
Eigen::VectorXd r(x_data.size());
|
||||
|
||||
for (size_t i = 0; i < x_data.size(); i++)
|
||||
{
|
||||
double xi = x_data[i];
|
||||
double yi = y_data[i];
|
||||
double exp_part = std::exp(-(xi - mu) * (xi - mu) / (2 * sigma * sigma));
|
||||
double fi = a * exp_part + c;
|
||||
|
||||
r(i) = yi - fi;
|
||||
|
||||
// 雅可比
|
||||
J(i, 0) = -exp_part; // ∂f/∂a
|
||||
J(i, 1) = -a * exp_part * ((xi - mu) / (sigma * sigma)); // ∂f/∂mu
|
||||
J(i, 2) = -a * exp_part * ((xi - mu) * (xi - mu) / (sigma * sigma * sigma)); // ∂f/∂sigma
|
||||
J(i, 3) = -1.0; // ∂f/∂c
|
||||
}
|
||||
|
||||
Eigen::VectorXd delta = (J.transpose() * J).ldlt().solve(-J.transpose() * r);
|
||||
|
||||
a += delta(0);
|
||||
mu += delta(1);
|
||||
sigma += delta(2);
|
||||
c += delta(3);
|
||||
|
||||
if (delta.norm() < 1e-8) break;
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onAutoFocusProgress(int progress)
|
||||
{
|
||||
//std::cout << "<EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD>" << progress << std::endl;
|
||||
//std::cout << "进度:" << progress << std::endl;
|
||||
|
||||
ui.autoFocusProgress_progressBar->setValue(progress);
|
||||
}
|
||||
@ -287,7 +557,7 @@ WorkerThread2::WorkerThread2(CFocusMotorControl * ctrlFocusMotor, bool isUltraso
|
||||
|
||||
void WorkerThread2::run()
|
||||
{
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
//配置文件
|
||||
string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg";
|
||||
Configfile configfile;
|
||||
configfile.setConfigfilePath(HPPACfgFile);
|
||||
@ -326,15 +596,185 @@ void WorkerThread4::run()
|
||||
{
|
||||
int progress = m_ctrlFocusMotor->GetProgressIndex();
|
||||
|
||||
//std::cout << "WorkerThread4::run----<EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD>" << progress << std::endl;
|
||||
//std::cout << "WorkerThread4::run----自动调焦进度:" << progress << std::endl;
|
||||
|
||||
emit AutoFocusProgressSignal(progress);
|
||||
if (progress == 100)
|
||||
{
|
||||
//std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>" << std::endl;
|
||||
//std::cout << "自动调焦完成!" << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
msleep(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
MotionCaptureCoordinator::MotionCaptureCoordinator(
|
||||
IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_motorCtrl(motorCtrl)
|
||||
, m_cameraCtrl(cameraCtrl)
|
||||
, m_currentPos(0)
|
||||
, m_endPos(0)
|
||||
, m_isRunning(false)
|
||||
{
|
||||
//这些信号槽是按照逻辑顺序的
|
||||
connect(this, SIGNAL(moveTo(int, double, double, int)),
|
||||
m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||
|
||||
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
|
||||
this, &MotionCaptureCoordinator::handlePositionReached);
|
||||
//connect(m_motorCtrl, &IrisMultiMotorController::moveFailed,
|
||||
// this, &MotionCaptureCoordinator::handleError);
|
||||
|
||||
connect(this, SIGNAL(getFocusIndexSobel()),
|
||||
m_cameraCtrl, SLOT(getFocusIndexSobel()));
|
||||
|
||||
connect(m_cameraCtrl, &ImagerOperationBase::FocusIndexSobelSignal,
|
||||
this, &MotionCaptureCoordinator::handleCaptureComplete);
|
||||
//connect(m_cameraCtrl, &ImagerOperationBase::captureFailed,
|
||||
// this, &MotionCaptureCoordinator::handleError);
|
||||
}
|
||||
|
||||
MotionCaptureCoordinator::~MotionCaptureCoordinator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MotionCaptureCoordinator::startStepMotion(double speed, int stepInterval, double startPos, double endPos)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
if (m_isRunning)
|
||||
{
|
||||
emit errorOccurred("Sequence already running");
|
||||
return;
|
||||
}
|
||||
|
||||
m_counter = 0;
|
||||
|
||||
m_positionData.clear();
|
||||
|
||||
m_speed = speed;
|
||||
m_iStepInterval = stepInterval;
|
||||
m_iStepIntervalRealTime = 1;
|
||||
m_currentPos = startPos;
|
||||
m_endPos = endPos;
|
||||
m_posInternal = (endPos - startPos) / stepInterval;
|
||||
|
||||
m_isRunning = true;
|
||||
|
||||
processNextPosition();
|
||||
}
|
||||
|
||||
void MotionCaptureCoordinator::stopStepMotion()
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
m_isRunning = false;
|
||||
emit sequenceStopped();
|
||||
}
|
||||
|
||||
QVector<PositionData> MotionCaptureCoordinator::getAllPositionData() const
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
return m_positionData;
|
||||
}
|
||||
|
||||
bool MotionCaptureCoordinator::saveToCsv(const QString& filename)
|
||||
{
|
||||
//QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
QFile file(filename);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextStream out(&file);
|
||||
out << "Timestamp,targetPosition,ActualPosition,FocusIndex\n";
|
||||
|
||||
for (const auto& data : m_positionData)
|
||||
{
|
||||
out << data.timestamp.toString("yyyy-MM-dd HH:mm:ss.zzz") << ","
|
||||
<< QString::number(data.targetPosition, 'f', 4) << ","
|
||||
<< QString::number(data.actualPosition, 'f', 4) << ","
|
||||
<< QString::number(data.cameraIndex, 'f', 4) << "\n";
|
||||
}
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
void MotionCaptureCoordinator::handlePositionReached(int motorID, double pos)
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
//验证马达运动位置是否到达指定位置
|
||||
//if (pos != m_currentPos) return;
|
||||
|
||||
// 记录位置信息
|
||||
PositionData data;
|
||||
data.targetPosition = m_currentPos;
|
||||
data.actualPosition = pos;
|
||||
data.timestamp = QDateTime::currentDateTime();
|
||||
m_positionData.append(data);
|
||||
|
||||
// 开始采集
|
||||
emit getFocusIndexSobel();
|
||||
}
|
||||
|
||||
void MotionCaptureCoordinator::handleCaptureComplete(double index)
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
|
||||
// 更新最近一条记录的相机指数
|
||||
//if (!m_positionData.isEmpty() &&
|
||||
// m_positionData.last().targetPosition == m_positionData.last().actualPosition)
|
||||
//{
|
||||
// m_positionData.last().cameraIndex = index;
|
||||
//}
|
||||
m_positionData.last().cameraIndex = index;
|
||||
|
||||
m_currentPos += m_posInternal;
|
||||
m_iStepIntervalRealTime++;
|
||||
emit progressChanged(m_iStepIntervalRealTime);
|
||||
|
||||
m_counter += 1;
|
||||
|
||||
std::cout << "第" << m_counter << "次采集:" << std::endl;
|
||||
std::cout << "目标位置:" << m_positionData.last().targetPosition << std::endl;
|
||||
std::cout << "实际位置:" << m_positionData.last().actualPosition << std::endl;
|
||||
|
||||
processNextPosition();
|
||||
}
|
||||
|
||||
void MotionCaptureCoordinator::handleError(const QString& error)
|
||||
{
|
||||
QMutexLocker locker(&m_dataMutex);
|
||||
m_isRunning = false;
|
||||
emit errorOccurred(error);
|
||||
}
|
||||
|
||||
void MotionCaptureCoordinator::processNextPosition()
|
||||
{
|
||||
if (!m_isRunning) return;
|
||||
|
||||
if (m_currentPos > m_endPos)
|
||||
{
|
||||
m_isRunning = false;
|
||||
emit sequenceComplete();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
emit moveTo(0, m_currentPos, m_speed, 1000);
|
||||
}
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
#include <QFileDialog>
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
#include <QDateTime>
|
||||
#include <QMutex>
|
||||
|
||||
#include "ui_FocusDialog.h"
|
||||
#include "AbstractPortMiscDefines.h"
|
||||
@ -26,6 +28,71 @@
|
||||
#include "hppaConfigFile.h"
|
||||
#include "path_tc.h"
|
||||
#include "ImagerOperationBase.h"
|
||||
#include "IrisMultiMotorController.h"
|
||||
|
||||
#include <Eigen/Dense>
|
||||
#include <cmath>
|
||||
|
||||
// <20><><EFBFBD>ݼ<EFBFBD>¼<EFBFBD>ṹ<EFBFBD><E1B9B9>
|
||||
struct PositionData {
|
||||
double targetPosition; // Ŀ<><C4BF>λ<EFBFBD><CEBB>
|
||||
double actualPosition; // ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
double cameraIndex; // <20><><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>ָ<EFBFBD><D6B8>
|
||||
QDateTime timestamp; // ʱ<><CAB1><EFBFBD><EFBFBD>
|
||||
|
||||
PositionData(double target = 0, double actual = 0.0, double index = 0.0)
|
||||
: targetPosition(target), actualPosition(actual),
|
||||
cameraIndex(index), timestamp(QDateTime::currentDateTime()) {}
|
||||
};
|
||||
|
||||
// Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
class MotionCaptureCoordinator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MotionCaptureCoordinator(IrisMultiMotorController* motorCtrl,
|
||||
ImagerOperationBase* cameraCtrl,
|
||||
QObject* parent = nullptr);
|
||||
~MotionCaptureCoordinator();
|
||||
|
||||
QVector<PositionData> getAllPositionData() const;
|
||||
bool saveToCsv(const QString& filename);
|
||||
|
||||
public slots:
|
||||
void startStepMotion(double speed, int stepInterval = 100, double startPos = 0, double endPos = -1);//-1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զλ<D4B6><CEBB>
|
||||
void stopStepMotion();
|
||||
|
||||
signals:
|
||||
void progressChanged(int progress);
|
||||
void sequenceComplete();
|
||||
void sequenceStopped();
|
||||
void errorOccurred(const QString& error);
|
||||
void moveTo(int, double, double, int);
|
||||
void getFocusIndexSobel();
|
||||
|
||||
private slots:
|
||||
void handlePositionReached(int motorID, double pos);
|
||||
void handleCaptureComplete(double index);
|
||||
void handleError(const QString& error);
|
||||
|
||||
private:
|
||||
void processNextPosition();
|
||||
|
||||
IrisMultiMotorController* m_motorCtrl;
|
||||
ImagerOperationBase* m_cameraCtrl;
|
||||
QVector<PositionData> m_positionData;
|
||||
mutable QMutex m_dataMutex;
|
||||
|
||||
double m_posInternal;
|
||||
double m_currentPos;
|
||||
double m_endPos;
|
||||
bool m_isRunning;
|
||||
double m_speed;
|
||||
|
||||
int m_iStepInterval;
|
||||
int m_iStepIntervalRealTime;
|
||||
int m_counter;
|
||||
};
|
||||
|
||||
class focusWindow:public QDialog
|
||||
{
|
||||
@ -50,6 +117,21 @@ private:
|
||||
|
||||
void disableBeforeConnect(bool disable);
|
||||
|
||||
QThread m_motorThread;
|
||||
IrisMultiMotorController* m_multiAxisController;
|
||||
double m_dSpeed;
|
||||
|
||||
QThread m_MotionCaptureCoordinatorThread;
|
||||
MotionCaptureCoordinator* m_coordinator;
|
||||
|
||||
int m_iStepSize;
|
||||
double m_goodPos;
|
||||
bool m_isAutoFocusSuccess;
|
||||
bool m_isMoveAfterAutoFocus = false;
|
||||
void getGaussianInitParam(const std::vector<double>& pos, const std::vector<double>& index, double& a_init, double& mu_init, double& sigma_init, double& c_init);
|
||||
void gaussian_fit(const std::vector<double>& x_data, const std::vector<double>& y_data, double& a, double& mu, double& sigma, double& c);
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void onConnectMotor();
|
||||
void onMove2MotorLogicZero();
|
||||
@ -64,8 +146,21 @@ public Q_SLOTS:
|
||||
void onAutoFocusProgress(int progress);
|
||||
void onUltrasound_radioButton();
|
||||
|
||||
void display_x_loc(std::vector<double> loc);
|
||||
void onx_rangeMeasurement();
|
||||
|
||||
void moveAfterAutoFocus(int motorID, double location);
|
||||
|
||||
signals:
|
||||
void StartManualFocusSignal(int);//1<><31><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
void move2LocSignal(int, double, double, int);
|
||||
void move2MaxLocSignal(int, double, int);
|
||||
void rmoveSignal(int, double, double, int);
|
||||
void rangeMeasurementSignal(int, double, int);
|
||||
void zeroStartSignal(int);
|
||||
|
||||
void startStepMotion(double speed, int stepInterval = 100, double startPos = 0, double endPos = -1);
|
||||
};
|
||||
|
||||
class WorkerThread2 : public QThread
|
||||
|
||||
1215
HPPA/twoMotorControl.ui
Normal file
1215
HPPA/twoMotorControl.ui
Normal file
File diff suppressed because it is too large
Load Diff
43
cfg_file_backup/HPPA.cfg
Normal file
43
cfg_file_backup/HPPA.cfg
Normal file
@ -0,0 +1,43 @@
|
||||
SN = "2004";
|
||||
autoFocus :
|
||||
{
|
||||
PositionRestriction :
|
||||
{
|
||||
max = 1000;
|
||||
min = 120;
|
||||
};
|
||||
TuningStepSize :
|
||||
{
|
||||
coarse = 10;
|
||||
fine = 2;
|
||||
};
|
||||
FitParams :
|
||||
{
|
||||
fa = 0.0017;
|
||||
fb = 0.3277;
|
||||
};
|
||||
AutoFocusRange :
|
||||
{
|
||||
max = 688;
|
||||
min = 144;
|
||||
};
|
||||
};
|
||||
motionPlatform :
|
||||
{
|
||||
x :
|
||||
{
|
||||
StepAnglemar = 1.8;
|
||||
Lead = 1.0;
|
||||
SubdivisionMultiples = 8;
|
||||
ScaleFactor = 1.0;
|
||||
MaxRange = 30.742266;
|
||||
};
|
||||
y :
|
||||
{
|
||||
StepAnglemar = 1.8;
|
||||
Lead = 1.0;
|
||||
SubdivisionMultiples = 8;
|
||||
ScaleFactor = 1.0;
|
||||
MaxRange = 31.283163;
|
||||
};
|
||||
};
|
||||
60
cfg_file_backup/oneMotorConfigFile.cfg
Normal file
60
cfg_file_backup/oneMotorConfigFile.cfg
Normal file
@ -0,0 +1,60 @@
|
||||
SN = "0";
|
||||
motors :
|
||||
{
|
||||
motor1 :
|
||||
{
|
||||
platformParams :
|
||||
{
|
||||
hardwareParams :
|
||||
{
|
||||
StepAngle = 1.8;
|
||||
Lead = 4.0;
|
||||
ScaleFactor = 1.0;
|
||||
};
|
||||
runParams :
|
||||
{
|
||||
RecordSpeed = 1.8;
|
||||
MoveSpeed = 1.8;
|
||||
ReturnSpeed = 1.8;
|
||||
MaxRange = 120.0;
|
||||
};
|
||||
};
|
||||
motorParams :
|
||||
{
|
||||
Manufacturer = 0;
|
||||
CommunicationProtocol = 0;
|
||||
connectionParams :
|
||||
{
|
||||
SerialPortNumber = "COM10";
|
||||
BaudRate = 9600;
|
||||
};
|
||||
initParams :
|
||||
{
|
||||
limit :
|
||||
{
|
||||
msr = 1;
|
||||
msv = 0;
|
||||
psr = 2;
|
||||
psv = 0;
|
||||
};
|
||||
other :
|
||||
{
|
||||
acc = 20000.0;
|
||||
cra = 4.0;
|
||||
crh = 1.0;
|
||||
crn = 4.0;
|
||||
dec = 20000.0;
|
||||
mcs = 7;
|
||||
};
|
||||
zeroStart :
|
||||
{
|
||||
osv = 0;
|
||||
snr = 0;
|
||||
zmd = 2;
|
||||
zsd = 3000;
|
||||
zsp = 2400;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
60
cfg_file_backup/oneMotorConfigFile_focus.cfg
Normal file
60
cfg_file_backup/oneMotorConfigFile_focus.cfg
Normal file
@ -0,0 +1,60 @@
|
||||
SN = "0";
|
||||
motors :
|
||||
{
|
||||
motor1 :
|
||||
{
|
||||
platformParams :
|
||||
{
|
||||
hardwareParams :
|
||||
{
|
||||
StepAngle = 1.8;
|
||||
Lead = 1.37;
|
||||
ScaleFactor = 1.0;
|
||||
};
|
||||
runParams :
|
||||
{
|
||||
RecordSpeed = 1.0;
|
||||
MoveSpeed = 1.0;
|
||||
ReturnSpeed = 1.0;
|
||||
MaxRange = 11.559696;
|
||||
};
|
||||
};
|
||||
motorParams :
|
||||
{
|
||||
Manufacturer = 0;
|
||||
CommunicationProtocol = 1;
|
||||
connectionParams :
|
||||
{
|
||||
SerialPortNumber = "COM10";
|
||||
BaudRate = 9600;
|
||||
};
|
||||
initParams :
|
||||
{
|
||||
limit :
|
||||
{
|
||||
msr = 1;
|
||||
msv = 1;
|
||||
psr = 2;
|
||||
psv = 1;
|
||||
};
|
||||
other :
|
||||
{
|
||||
acc = 19200.0;
|
||||
cra = 0.2;
|
||||
crh = 0.0;
|
||||
crn = 0.2;
|
||||
dec = 19200.0;
|
||||
mcs = 6;
|
||||
};
|
||||
zeroStart :
|
||||
{
|
||||
osv = 1;
|
||||
snr = 0;
|
||||
zmd = 1;
|
||||
zsd = 4000;
|
||||
zsp = 2400;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user