Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 52516d2f54 | |||
| af88a6a67e | |||
| 1e0cf1aa12 | |||
| 496f61c0e1 | |||
| ac241f45cc | |||
| 1867291c9b | |||
| 48be580226 | |||
| a629115e91 | |||
| c1e4144ed6 | |||
| c2b3f131ee | |||
| 20848bef1a | |||
| f6138dd2ed | |||
| f32ade7487 | |||
| 89c701c5f2 | |||
| a7fd9e4fa9 | |||
| 5af6a039c2 | |||
| b779118d72 |
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,5 +1,10 @@
|
||||
# tc
|
||||
GeneratedFiles/
|
||||
ResononAPISetup-3.12-64bit.exe
|
||||
gdal202.dll
|
||||
*.rej
|
||||
HPPA类图.drawio
|
||||
HPPA - 副本.ui
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
10
HPPA.sln
10
HPPA.sln
@ -10,6 +10,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HPPA", "HPPA\HPPA.vcxproj",
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vincecontrol", "vincecontrol\vincecontrol.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IrisMultiMotorController", "IrisMultiMotorController\IrisMultiMotorController\IrisMultiMotorController.vcxproj", "{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
@ -34,6 +36,14 @@ Global
|
||||
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.Build.0 = Release|x64
|
||||
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32
|
||||
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32
|
||||
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Debug|x64.Build.0 = Debug|x64
|
||||
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Debug|x86.Build.0 = Debug|x64
|
||||
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Release|x64.ActiveCfg = Release|x64
|
||||
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Release|x64.Build.0 = Release|x64
|
||||
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Release|x86.ActiveCfg = Release|x64
|
||||
{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Release|x86.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
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();
|
||||
};
|
||||
158
HPPA/Corning410Imager.cpp
Normal file
158
HPPA/Corning410Imager.cpp
Normal file
@ -0,0 +1,158 @@
|
||||
#include "Corning410Imager.h"
|
||||
|
||||
Corning410Imager::Corning410Imager()
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>У<EFBFBD><D0A3>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
string CfgFile = getPathofEXE() + "\\corning410.cfg";
|
||||
m_configfile.setConfigfilePath(CfgFile);
|
||||
if (!m_configfile.isConfigfileExist())
|
||||
{
|
||||
m_configfile.createConfigFile();
|
||||
qDebug() << "create: " << QString::fromStdString(CfgFile);
|
||||
}
|
||||
m_configfile.parseConfigfile();
|
||||
qDebug() << "exist: " << QString::fromStdString(CfgFile);
|
||||
}
|
||||
|
||||
Corning410Imager::~Corning410Imager()
|
||||
{
|
||||
if (buffer != nullptr)
|
||||
{
|
||||
std::cout << "<EFBFBD>ͷŶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>" << std::endl;
|
||||
free(buffer);
|
||||
free(dark);
|
||||
free(white);
|
||||
}
|
||||
}
|
||||
|
||||
double Corning410Imager::getFramerate()
|
||||
{
|
||||
return m_imager.get_framerate();
|
||||
}
|
||||
|
||||
double Corning410Imager::getIntegrationTime()
|
||||
{
|
||||
return m_imager.get_integration_time() / 1000;
|
||||
}
|
||||
|
||||
double Corning410Imager::getGain()
|
||||
{
|
||||
return m_imager.get_gain();
|
||||
}
|
||||
|
||||
void Corning410Imager::setGain(const double gain)
|
||||
{
|
||||
m_imager.set_gain(gain);
|
||||
}
|
||||
|
||||
void Corning410Imager::setFramerate(const double frames_per_second)
|
||||
{
|
||||
m_imager.set_framerate(frames_per_second);
|
||||
m_RgbImage->m_iFramerate = frames_per_second;
|
||||
}
|
||||
|
||||
void Corning410Imager::setIntegrationTime(const double milliseconds)
|
||||
{
|
||||
m_imager.set_integration_time(milliseconds * 1000);
|
||||
}
|
||||
|
||||
int Corning410Imager::getStartBand()
|
||||
{
|
||||
return m_imager.get_start_band();
|
||||
}
|
||||
|
||||
int Corning410Imager::getEndBand()
|
||||
{
|
||||
return m_imager.get_end_band();
|
||||
}
|
||||
|
||||
void Corning410Imager::connectImager(const char* camera_sn)
|
||||
{
|
||||
m_imager.connect();
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>
|
||||
bool ret, ret1, ret2;
|
||||
|
||||
int spatialBin;
|
||||
int spectralBin;
|
||||
ret1 = m_configfile.getspatialBin(spatialBin);
|
||||
ret2 = m_configfile.getSpectralBin(spectralBin);
|
||||
if (ret1 && ret2)
|
||||
{
|
||||
bool haha = m_imager.setSpectralBin(spectralBin);
|
||||
bool haha2 = m_imager.setSpatialBin(spatialBin);
|
||||
|
||||
std::cout << "spectralBin<EFBFBD><EFBFBD>" << spectralBin << std::endl;
|
||||
std::cout << "spatialBin<EFBFBD><EFBFBD>" << spatialBin << std::endl;
|
||||
}
|
||||
|
||||
float gain, offset;
|
||||
ret = m_configfile.getGainOffset(gain, offset);
|
||||
if (ret)
|
||||
{
|
||||
m_imager.setGainOffset(gain, offset);
|
||||
}
|
||||
|
||||
int width = 0, offsetx = 0, height = 0, offsety = 0;
|
||||
ret = m_configfile.getEffectiveWindow(width, offsetx, height, offsety);
|
||||
if (ret)
|
||||
{
|
||||
m_imager.setEffectiveWindow(offsetx, width, offsety, height);
|
||||
}
|
||||
|
||||
|
||||
int bufferPolicy, acqBufferSize;
|
||||
ret1 = m_configfile.getBufferPolicy(bufferPolicy);
|
||||
if (ret1)
|
||||
{
|
||||
m_imager.setBufferPolicy(bufferPolicy);
|
||||
}
|
||||
ret1 = m_configfile.getAcqBufferSize(acqBufferSize);
|
||||
if (ret1)
|
||||
{
|
||||
m_imager.setAcqBufferSize(acqBufferSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Corning410Imager::disconnectImager()
|
||||
{
|
||||
m_imager.disconnect();
|
||||
}
|
||||
|
||||
void Corning410Imager::imagerStartCollect()
|
||||
{
|
||||
m_imager.start();
|
||||
}
|
||||
|
||||
void Corning410Imager::imagerStopCollect()
|
||||
{
|
||||
m_imager.stop();
|
||||
}
|
||||
|
||||
unsigned short* Corning410Imager::getFrame(unsigned short* buffer)
|
||||
{
|
||||
m_imager.get_frame(buffer);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void Corning410Imager::setSpectraBin(int new_spectral_bin)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
double Corning410Imager::getWavelengthAtBand(int band)
|
||||
{
|
||||
return m_imager.get_wavelength_at_band(band);
|
||||
}
|
||||
|
||||
int Corning410Imager::getBandCount()
|
||||
{
|
||||
return m_imager.get_band_count();
|
||||
}
|
||||
|
||||
int Corning410Imager::getSampleCount()
|
||||
{
|
||||
return m_imager.get_sample_count();
|
||||
}
|
||||
48
HPPA/Corning410Imager.h
Normal file
48
HPPA/Corning410Imager.h
Normal file
@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#include "ImagerOperationBase.h"
|
||||
#include "image2display.h"
|
||||
#include "fileOperation.h"
|
||||
|
||||
#include "irisximeaimager.h"
|
||||
#include "path_tc.h"
|
||||
#include "hppaConfigFile.h"
|
||||
|
||||
class Corning410Imager :public ImagerOperationBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Corning410Imager();
|
||||
~Corning410Imager();
|
||||
|
||||
Iris::IrisXimeaImager m_imager;
|
||||
|
||||
double getWavelengthAtBand(int band);
|
||||
int getBandCount();
|
||||
int getSampleCount();
|
||||
double getFramerate();
|
||||
double getIntegrationTime();
|
||||
double getGain();
|
||||
void setFramerate(const double frames_per_second);
|
||||
void setIntegrationTime(const double milliseconds);
|
||||
void setGain(const double gain);
|
||||
int getStartBand();
|
||||
int getEndBand();
|
||||
void connectImager(const char* camera_sn = NULL);
|
||||
void disconnectImager();
|
||||
void imagerStartCollect();
|
||||
void imagerStopCollect();
|
||||
unsigned short* getFrame(unsigned short* buffer);
|
||||
void setSpectraBin(int new_spectral_bin);
|
||||
|
||||
protected:
|
||||
private:
|
||||
CorningConfigfile m_configfile;
|
||||
|
||||
public slots:
|
||||
|
||||
signals:
|
||||
};
|
||||
@ -6,12 +6,12 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>332</height>
|
||||
<width>632</width>
|
||||
<height>444</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>调焦</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="HPPA.qrc">
|
||||
@ -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>
|
||||
|
||||
1536
HPPA/HPPA.cpp
1536
HPPA/HPPA.cpp
File diff suppressed because it is too large
Load Diff
127
HPPA/HPPA.h
127
HPPA/HPPA.h
@ -32,12 +32,15 @@
|
||||
#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"
|
||||
|
||||
#include "ResononNirImager.h"
|
||||
#include "Corning410Imager.h"
|
||||
|
||||
#define PI 3.1415926
|
||||
|
||||
@ -120,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
|
||||
@ -177,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>
|
||||
@ -193,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;
|
||||
@ -236,17 +181,27 @@ private:
|
||||
void getRequest(QString str);
|
||||
|
||||
QActionGroup* mImagerGroup = nullptr;
|
||||
QString imagerSelected;
|
||||
void createActionGroups();
|
||||
void selectingImager(QAction* selectedAction);
|
||||
QActionGroup* moveplatformActionGroup = nullptr;
|
||||
void createMoveplatformActionGroup();
|
||||
void selectingMoveplatform(QAction* selectedAction);
|
||||
RobotArmControl* rac;
|
||||
|
||||
PathPlan* m_pathPlan;
|
||||
OneMotorControl* omc;
|
||||
QDockWidget* dock_omc;
|
||||
|
||||
TwoMotorControl* tmc;
|
||||
QDockWidget* dock_tmc;
|
||||
|
||||
FILE* m_hTimesFile;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onPlotHyperspectralImageRgbImage();
|
||||
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>
|
||||
@ -260,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();
|
||||
@ -276,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);
|
||||
@ -332,9 +243,11 @@ public Q_SLOTS:
|
||||
|
||||
void requestFinished(QNetworkReply* reply);
|
||||
|
||||
void recordFromRobotArm(int fileCounter);
|
||||
|
||||
void createOneMotorScenario();
|
||||
signals:
|
||||
void StartFocusSignal();
|
||||
void StartLoopSignal();
|
||||
void StartRecordSignal();
|
||||
void CopyFileThreadSignal(QString, QString);
|
||||
|
||||
|
||||
993
HPPA/HPPA.ui
993
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,16 +55,16 @@
|
||||
</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;$(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;$(LibraryPath)</LibraryPath>
|
||||
<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;$(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;$(LibraryPath)</LibraryPath>
|
||||
<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'">
|
||||
<Link>
|
||||
<AdditionalDependencies>opencv_world3411.lib;opencv_world3411d.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;vincecontrol.lib;resonon-allied.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>opencv_world3411.lib;opencv_world3411d.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;vincecontrol.lib;resonon-allied.lib;xiapi64.lib;IrisMultiMotorController.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
@ -73,7 +73,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>opencv_world3411.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;resonon-allied.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>opencv_world3411.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;resonon-allied.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++.lib;xiapi64.lib;IrisMultiMotorController.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@ -86,7 +86,7 @@
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@ -106,9 +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="PathPlan.cpp" />
|
||||
<ClCompile Include="imager_base.cpp" />
|
||||
<ClCompile Include="irisximeaimager.cpp" />
|
||||
<ClCompile Include="OneMotorControl.cpp" />
|
||||
<ClCompile Include="path_tc.cpp" />
|
||||
<ClCompile Include="PowerControl.cpp" />
|
||||
<ClCompile Include="QDoubleSlider.cpp" />
|
||||
@ -116,10 +120,12 @@
|
||||
<ClCompile Include="resononImager.cpp" />
|
||||
<ClCompile Include="ResononNirImager.cpp" />
|
||||
<ClCompile Include="RgbCameraOperation.cpp" />
|
||||
<ClCompile Include="RobotArmControl.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<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" />
|
||||
@ -137,8 +143,13 @@
|
||||
<ClCompile Include="imagerSimulatioin.cpp" />
|
||||
<ClCompile Include="ImageViewer.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<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" />
|
||||
@ -152,7 +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" />
|
||||
|
||||
@ -21,6 +21,15 @@
|
||||
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
|
||||
<Extensions>ts</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\motor">
|
||||
<UniqueIdentifier>{eadfac5f-f4f9-49e2-9f99-0849bf074cf8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<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">
|
||||
@ -103,7 +112,25 @@
|
||||
<ClCompile Include="PowerControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PathPlan.cpp">
|
||||
<ClCompile Include="RobotArmControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Corning410Imager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="imager_base.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="irisximeaimager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<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>
|
||||
@ -150,7 +177,19 @@
|
||||
<QtMoc Include="PowerControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="PathPlan.h">
|
||||
<QtMoc Include="RobotArmControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="Corning410Imager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<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>
|
||||
@ -179,6 +218,12 @@
|
||||
<ClInclude Include="utility_tc.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="imager_base.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="irisximeaimager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtUic Include="FocusDialog.ui">
|
||||
@ -196,6 +241,21 @@
|
||||
<QtUic Include="PathPlan.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="RobotArmControl.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<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();
|
||||
|
||||
@ -54,9 +54,9 @@ double ImagerOperationBase::auto_exposure()
|
||||
while (true)
|
||||
{
|
||||
getFrame(buffer);
|
||||
if (GetMaxValue(buffer, m_FrameSize) >= 4095)
|
||||
if (GetMaxValue(buffer, m_FrameSize) >= 4094)
|
||||
{
|
||||
setIntegrationTime(getIntegrationTime() * 0.8);
|
||||
setIntegrationTime(getIntegrationTime() * 0.95);
|
||||
std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD>ع<EFBFBD>-----------" << std::endl;
|
||||
}
|
||||
else
|
||||
@ -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);
|
||||
@ -204,21 +233,22 @@ void ImagerOperationBase::start_record()
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryFromString();
|
||||
string imgPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter);
|
||||
|
||||
FILE* m_fImage = fopen(imgPath.c_str(), "w+b");
|
||||
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
|
||||
FILE* m_fImage = fopen(m_FileName2Save2.c_str(), "w+b");
|
||||
|
||||
size_t x;
|
||||
double pixelValueTmp;
|
||||
|
||||
string timesFile = removeFileExtension(m_FileName2Save2) + ".times";
|
||||
FILE* hTimesFile = fopen(timesFile.c_str(), "w+");
|
||||
|
||||
imagerStartCollect();
|
||||
while (m_bRecordControlState)
|
||||
{
|
||||
m_iFrameCounter++;
|
||||
|
||||
getFrame(buffer);
|
||||
long long timeOs = getNanosecondsSinceMidnight();
|
||||
|
||||
//<2F><>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӦΪbuffer<65><72>dark<72><6B><EFBFBD><EFBFBD>unsigned short<72><74><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>dark>bufferʱ<72><CAB1>buffer-dark=65535
|
||||
if (m_HasDark)
|
||||
@ -259,6 +289,7 @@ void ImagerOperationBase::start_record()
|
||||
}
|
||||
|
||||
x = fwrite(buffer, 2, m_FrameSize, m_fImage);
|
||||
fprintf(hTimesFile, "%d\n", timeOs);
|
||||
|
||||
//<2F><>rgb<67><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
||||
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
@ -268,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();
|
||||
emit PlotSignal(m_FileSavedCounter, m_iFrameCounter);
|
||||
}
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
@ -279,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();//<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();
|
||||
@ -298,6 +329,7 @@ void ImagerOperationBase::start_record()
|
||||
|
||||
//QThread::msleep(1001);
|
||||
fclose(m_fImage);
|
||||
fclose(hTimesFile);
|
||||
}
|
||||
|
||||
void ImagerOperationBase::setFrameNumber(int FrameNumber)
|
||||
@ -309,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)
|
||||
@ -332,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;
|
||||
@ -362,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;
|
||||
@ -398,17 +490,14 @@ void ImagerOperationBase::WriteHdr()
|
||||
//write an ENVI compatible header file
|
||||
using namespace std;
|
||||
|
||||
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryFromString();
|
||||
|
||||
string hdrPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".hdr";
|
||||
string hdrPath = removeFileExtension(m_FileName2Save2) + ".hdr";
|
||||
|
||||
std::ofstream outfile(hdrPath.c_str());
|
||||
outfile << "ENVI\n";
|
||||
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";
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include <string>
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include "ImagerOperationBase.h"
|
||||
#include "utility_tc.h"
|
||||
|
||||
class ImagerOperationBase :public QObject
|
||||
{
|
||||
@ -55,6 +56,7 @@ public:
|
||||
int GetFrameSize(int& iWidth, int& iHeight);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
CImage* m_RgbImage;//<2F><>ʾ<EFBFBD><CABE>rgbͼ<62><CDBC>
|
||||
bool m_bRecordControlState;//<2F>ɼ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>ֹͣ<CDA3>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
@ -65,6 +67,7 @@ protected:
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
string m_FileName2Save;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
string m_FileName2Save2;
|
||||
int m_FileSavedCounter;//<2F><><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><CBBC><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ļ<EFBFBD>
|
||||
|
||||
bool m_HasDark;//<2F><><EFBFBD>ɼ<EFBFBD><C9BC>˰<EFBFBD><CBB0><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtrue
|
||||
@ -83,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();//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>ź<EFBFBD>
|
||||
void PlotSignal(int, int);//<2F><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><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><EFBFBD><EFBFBD>-1<><31><EFBFBD><EFBFBD><EFBFBD>˴βɼ<CEB2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD><CEBB><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>
|
||||
@ -100,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>
|
||||
};
|
||||
|
||||
176
HPPA/OneMotorControl.cpp
Normal file
176
HPPA/OneMotorControl.cpp
Normal file
@ -0,0 +1,176 @@
|
||||
#include "OneMotorControl.h"
|
||||
|
||||
OneMotorControl::OneMotorControl(QWidget* parent) : QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
connect(this->ui.connect_btn, SIGNAL(pressed()), this, SLOT(onConnectMotor()));
|
||||
|
||||
}
|
||||
|
||||
OneMotorControl::~OneMotorControl()
|
||||
{
|
||||
m_motorThread.quit();
|
||||
m_motorThread.wait();
|
||||
}
|
||||
|
||||
void OneMotorControl::onConnectMotor()
|
||||
{
|
||||
try
|
||||
{
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
QString configFilePath = QString::fromStdString(directory) + "\\oneMotorConfigFile.cfg";
|
||||
|
||||
m_multiAxisController = new IrisMultiMotorController(configFilePath);
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
m_multiAxisController->moveToThread(&m_motorThread);
|
||||
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()));
|
||||
connect(this->ui.left_btn, SIGNAL(pressed()), this, SLOT(onxMotorLeft()));
|
||||
connect(this->ui.left_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
||||
|
||||
connect(this->ui.move2loc_pushButton, SIGNAL(pressed()), this, SLOT(onxMove2Loc()));
|
||||
|
||||
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(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(onx_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);
|
||||
}
|
||||
|
||||
void OneMotorControl::display_x_loc(std::vector<double> loc)
|
||||
{
|
||||
double tmp = round(loc[0] * 100) / 100;
|
||||
this->ui.realTimeLoc_lineEdit->setText(QString::number(tmp));
|
||||
}
|
||||
|
||||
void OneMotorControl::display_motors_connectivity(std::vector<int> connectivity)
|
||||
{
|
||||
//std::cout << "-----------------------------------"<<connectivity.size()<< std::endl;
|
||||
if (connectivity[0])
|
||||
{
|
||||
this->ui.motor_state_label->setStyleSheet("QLabel{background-color:rgb(0,255,0);}");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui.motor_state_label->setStyleSheet("QLabel{background-color:rgb(255,0,0);}");
|
||||
}
|
||||
}
|
||||
|
||||
void OneMotorControl::zeroStart()
|
||||
{
|
||||
zeroStartSignal(0);
|
||||
}
|
||||
|
||||
void OneMotorControl::onx_rangeMeasurement()
|
||||
{
|
||||
double s0 = ui.speed_lineEdit->text().toDouble();
|
||||
emit rangeMeasurement(0, s0, 1000);
|
||||
}
|
||||
|
||||
void OneMotorControl::onxMove2Loc()
|
||||
{
|
||||
double s = ui.speed_lineEdit->text().toDouble();
|
||||
double l = ui.move2loc_lineEdit->text().toDouble();
|
||||
|
||||
emit move2LocSignal(0, l, s, 1000);
|
||||
}
|
||||
|
||||
void OneMotorControl::onxMotorRight()
|
||||
{
|
||||
double s = ui.speed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(0, false, s, 1000);
|
||||
}
|
||||
|
||||
void OneMotorControl::onxMotorLeft()
|
||||
{
|
||||
double s = ui.speed_lineEdit->text().toDouble();
|
||||
|
||||
emit moveSignal(0, true, s, 1000);
|
||||
}
|
||||
|
||||
void OneMotorControl::onxMotorStop()
|
||||
{
|
||||
emit stopSignal(0);
|
||||
}
|
||||
|
||||
void OneMotorControl::setImager(ImagerOperationBase* imager)
|
||||
{
|
||||
m_Imager = imager;
|
||||
}
|
||||
|
||||
void OneMotorControl::record_dark()
|
||||
{
|
||||
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();
|
||||
}
|
||||
69
HPPA/OneMotorControl.h
Normal file
69
HPPA/OneMotorControl.h
Normal file
@ -0,0 +1,69 @@
|
||||
#pragma once
|
||||
#include <QThread>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "ui_oneMotorControl.h"
|
||||
|
||||
#include "IrisMultiMotorController.h"
|
||||
#include "fileOperation.h"
|
||||
#include "CaptureCoordinator.h"
|
||||
|
||||
class OneMotorControl : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OneMotorControl(QWidget* parent = nullptr);
|
||||
~OneMotorControl();
|
||||
|
||||
void setImager(ImagerOperationBase* imager);
|
||||
|
||||
void run();
|
||||
void stop();
|
||||
|
||||
void record_dark();
|
||||
void record_white();
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void onConnectMotor();
|
||||
|
||||
void display_x_loc(std::vector<double> loc);
|
||||
void display_motors_connectivity(std::vector<int> connectivity);
|
||||
void onxMove2Loc();
|
||||
void zeroStart();
|
||||
void onx_rangeMeasurement();
|
||||
|
||||
void onxMotorRight();
|
||||
void onxMotorLeft();
|
||||
void onxMotorStop();
|
||||
|
||||
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(OneMotionCapturePathLine);
|
||||
void stopStepMotionSignal();
|
||||
|
||||
void sequenceComplete();
|
||||
|
||||
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(), "r");
|
||||
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();
|
||||
};
|
||||
@ -15,19 +15,19 @@
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_16">
|
||||
@ -349,12 +349,6 @@
|
||||
<widget class="QTableWidget" name="recordLine_tableWidget"/>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>layoutWidget</zorder>
|
||||
<zorder>layoutWidget_2</zorder>
|
||||
<zorder>recordLine_tableWidget</zorder>
|
||||
<zorder>layoutWidget_3</zorder>
|
||||
<zorder>layoutWidget_4</zorder>
|
||||
<zorder>label_7</zorder>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
||||
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>
|
||||
@ -285,15 +285,15 @@ void ResononNirImager::start_record()
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryFromString();
|
||||
string imgPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter)+".bil";
|
||||
|
||||
FILE* m_fImage = fopen(imgPath.c_str(), "w+b");
|
||||
m_FileName2Save2 = m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".bil";
|
||||
FILE* m_fImage = fopen(m_FileName2Save2.c_str(), "w+b");
|
||||
|
||||
size_t x;
|
||||
double pixelValueTmp;
|
||||
|
||||
string timesFile = removeFileExtension(m_FileName2Save2) + ".times";
|
||||
FILE* hTimesFile = fopen(timesFile.c_str(), "w+");
|
||||
|
||||
reConnectImage();//nir<69>ڶ<EFBFBD><DAB6>βɼ<CEB2>ʱ<EFBFBD><CAB1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>imagerStartCollect()<29>ᱨ<EFBFBD><E1B1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
imagerStartCollect();
|
||||
while (m_bRecordControlState)
|
||||
@ -301,6 +301,8 @@ void ResononNirImager::start_record()
|
||||
m_iFrameCounter++;
|
||||
|
||||
getFrame(buffer);
|
||||
long long timeOs = getNanosecondsSinceMidnight();
|
||||
//qDebug() << "time ns-------------------: " << timeOs;
|
||||
|
||||
//<2F><>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӦΪbuffer<65><72>dark<72><6B><EFBFBD><EFBFBD>unsigned short<72><74><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>dark>bufferʱ<72><CAB1>buffer-dark=65535
|
||||
if (m_HasDark)
|
||||
@ -341,6 +343,7 @@ void ResononNirImager::start_record()
|
||||
}
|
||||
|
||||
x = fwrite(buffer, 2, m_FrameSize, m_fImage);
|
||||
fprintf(hTimesFile, "%lld\n", timeOs);
|
||||
|
||||
//<2F><>rgb<67><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
||||
m_RgbImage->FillRgbImage(buffer);//??????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
@ -350,25 +353,26 @@ 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();
|
||||
emit PlotSignal(m_FileSavedCounter, m_iFrameCounter);
|
||||
}
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
{
|
||||
break;
|
||||
//qDebug() << "<22><><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD><C9BC><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>";
|
||||
}
|
||||
|
||||
}
|
||||
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();//<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();
|
||||
@ -380,6 +384,7 @@ void ResononNirImager::start_record()
|
||||
|
||||
//QThread::msleep(1001);
|
||||
fclose(m_fImage);
|
||||
fclose(hTimesFile);
|
||||
}
|
||||
|
||||
void ResononNirImager::WriteHdr()
|
||||
@ -387,17 +392,14 @@ void ResononNirImager::WriteHdr()
|
||||
//write an ENVI compatible header file
|
||||
using namespace std;
|
||||
|
||||
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryFromString();
|
||||
|
||||
string hdrPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter) + ".hdr";
|
||||
string hdrPath = removeFileExtension(m_FileName2Save2) + ".hdr";
|
||||
|
||||
std::ofstream outfile(hdrPath.c_str());
|
||||
outfile << "ENVI\n";
|
||||
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";
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "resonon_imager_allied.h"
|
||||
#include "image2display.h"
|
||||
#include "fileOperation.h"
|
||||
#include "utility_tc.h"
|
||||
|
||||
class ResononNirImager :public ImagerOperationBase
|
||||
{
|
||||
|
||||
639
HPPA/RobotArmControl.cpp
Normal file
639
HPPA/RobotArmControl.cpp
Normal file
@ -0,0 +1,639 @@
|
||||
#include "RobotArmControl.h"
|
||||
|
||||
RobotArmControl::RobotArmControl(QWidget* parent): QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
robotController = new RobotController(this);
|
||||
|
||||
connect(ui.get_task_list_btn, SIGNAL(clicked()), this, SLOT(getTaskList()));
|
||||
connect(ui.get_pose_btn, SIGNAL(clicked()), this, SLOT(getPose()));
|
||||
connect(ui.connect2arm_btn, SIGNAL(clicked()), this, SLOT(connectRobotArm()));
|
||||
|
||||
connect(ui.execute_task_btn, SIGNAL(clicked()), this, SLOT(executeTaskWithoutHyperImager()));
|
||||
connect(ui.pause_task_btn, SIGNAL(clicked()), this, SLOT(pauseTask()));
|
||||
connect(ui.continue_task_btn, SIGNAL(clicked()), this, SLOT(continueTask()));
|
||||
|
||||
robotMonitor = new EC8056;
|
||||
connect(robotMonitor, &EC8056::dataReceived, this, &RobotArmControl::monitorRobotArm);
|
||||
|
||||
|
||||
m_pModel = new QStringListModel(ui.taskList_listView);
|
||||
|
||||
ui.taskList_listView->setModel(m_pModel);
|
||||
}
|
||||
|
||||
RobotArmControl::~RobotArmControl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RobotArmControl::monitorRobotArm(const ECData& data)
|
||||
{
|
||||
double x = data.machinePose[0];
|
||||
double y = data.machinePose[1];
|
||||
double z = data.machinePose[2];
|
||||
|
||||
ui.pose_x_label->setText(QString::number(x));
|
||||
ui.pose_y_label->setText(QString::number(y));
|
||||
ui.pose_z_label->setText(QString::number(z));
|
||||
}
|
||||
|
||||
void RobotArmControl::onCommandResponse(QString str, const QJsonObject& response)
|
||||
{
|
||||
//qDebug() << "response:" << response;
|
||||
|
||||
QString re;
|
||||
if (response.contains("result"))
|
||||
{
|
||||
re = response["result"].toVariant().toString();
|
||||
ui.textEdit->append(str + " Result: " + re);
|
||||
}
|
||||
else if (response.contains("error"))
|
||||
{
|
||||
//auto delete11 = response["error"].toObject();
|
||||
//qDebug() << "response[\"error\"]:" << delete11;
|
||||
|
||||
auto errorStr = response["error"].toObject()["message"].toString();
|
||||
|
||||
ui.textEdit->append(str + " Error: " + errorStr);
|
||||
}
|
||||
}
|
||||
|
||||
void RobotArmControl::getTaskList()
|
||||
{
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
|
||||
QString pythonScript = QString::fromStdString(directory) + "\\get_jbi_filename.py";
|
||||
|
||||
QProcess process;
|
||||
|
||||
process.start("python.exe", QStringList() << pythonScript);
|
||||
process.waitForFinished();
|
||||
QString output = process.readAllStandardOutput();
|
||||
|
||||
QStringList files;
|
||||
//files.append("tc20250324down.jbi");
|
||||
//files.append("tc20250324circle.jbi");
|
||||
//files.append("tc20250324side.jbi");
|
||||
QStringList lines = output.split('\n', QString::SkipEmptyParts);
|
||||
for (const QString& line : lines)
|
||||
{
|
||||
files.append(line.trimmed());
|
||||
}
|
||||
|
||||
////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//for (size_t i = 0; i < files.length(); i++)
|
||||
//{
|
||||
// int row = m_pModel->rowCount();
|
||||
// m_pModel->insertRow(row);
|
||||
// QModelIndex index = m_pModel->index(row);
|
||||
// m_pModel->setData(index, files[i]);
|
||||
//}
|
||||
|
||||
m_pModel->setStringList(files);
|
||||
}
|
||||
|
||||
void RobotArmControl::getPose()
|
||||
{
|
||||
QJsonObject response;
|
||||
bool x = robotController->getRobotPose(response);
|
||||
onCommandResponse("getPose", response);
|
||||
}
|
||||
|
||||
void RobotArmControl::connectRobotArm()
|
||||
{
|
||||
bool re = robotController->connectToRobot("192.168.1.100");
|
||||
robotMonitor->connectToHost("192.168.1.100");
|
||||
}
|
||||
|
||||
void RobotArmControl::executeTaskWithHyperImager()
|
||||
{
|
||||
QModelIndex index = ui.taskList_listView->currentIndex();
|
||||
if (-1 == index.row())
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>û<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>ļ<EFBFBD>
|
||||
ui.textEdit->append("Please select file on the left!");
|
||||
return;
|
||||
}
|
||||
QString fileName = index.data(Qt::DisplayRole).toString();
|
||||
|
||||
QJsonObject response;
|
||||
bool x;
|
||||
|
||||
x = robotController->checkJbiExist(fileName, response);
|
||||
onCommandResponse("checkJbiExist", response);
|
||||
if (!x)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
x = robotController->setServoStatus(1, response);
|
||||
onCommandResponse("setServoStatus", response);
|
||||
if (!x)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
x = robotController->runJbi(fileName, response, true);
|
||||
onCommandResponse("runJbi", response);
|
||||
if (!x)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void RobotArmControl::executeTaskWithoutHyperImager()
|
||||
{
|
||||
QModelIndex index = ui.taskList_listView->currentIndex();
|
||||
if (-1 == index.row())
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>û<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>ļ<EFBFBD>
|
||||
ui.textEdit->append("Please select file on the left!");
|
||||
return;
|
||||
}
|
||||
QString fileName = index.data(Qt::DisplayRole).toString();
|
||||
|
||||
QJsonObject response;
|
||||
bool x;
|
||||
|
||||
x = robotController->checkJbiExist(fileName, response);
|
||||
onCommandResponse("checkJbiExist", response);
|
||||
if (!x)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
x = robotController->setServoStatus(1, response);
|
||||
onCommandResponse("setServoStatus", response);
|
||||
if (!x)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
x = robotController->runJbi(fileName, response, false);
|
||||
onCommandResponse("runJbi", response);
|
||||
if (!x)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void RobotArmControl::pauseTask()
|
||||
{
|
||||
QJsonObject response;
|
||||
bool x;
|
||||
|
||||
x = robotController->pauseTask(response);
|
||||
onCommandResponse("pauseTask", response);
|
||||
}
|
||||
|
||||
void RobotArmControl::continueTask()
|
||||
{
|
||||
QJsonObject response;
|
||||
bool x;
|
||||
|
||||
x = robotController->continueTask(response);
|
||||
onCommandResponse("continueTask", response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RobotController::RobotController(QObject* parent) : QObject(parent), socket(new QTcpSocket(this))
|
||||
{
|
||||
//connect(socket, &QTcpSocket::readyRead, this, &RobotController::onReadyRead);
|
||||
|
||||
m_timer = new QTimer(this);
|
||||
connect(m_timer, SIGNAL(timeout()), this, SLOT(getPoint()));
|
||||
}
|
||||
|
||||
RobotController::~RobotController()
|
||||
{
|
||||
disconnectFromRobot();
|
||||
}
|
||||
|
||||
bool RobotController::connectToRobot(const QString& ip, quint16 port)
|
||||
{
|
||||
socket->setProxy(QNetworkProxy::NoProxy);
|
||||
|
||||
socket->connectToHost(ip, port);
|
||||
|
||||
if (!socket->waitForConnected(3000)) {
|
||||
qDebug() << "Connection failed:" << socket->errorString();
|
||||
return false;
|
||||
}
|
||||
qDebug() << "Connected successfully!";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RobotController::disconnectFromRobot()
|
||||
{
|
||||
if (socket->isOpen())
|
||||
{
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
|
||||
bool RobotController::processResponse(QJsonObject response, QString& result)
|
||||
{
|
||||
//qDebug() << "response:" << response;
|
||||
|
||||
if (response.contains("result"))
|
||||
{
|
||||
result = response["result"].toVariant().toString();
|
||||
|
||||
//qDebug() << "result1:" << result;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (response.contains("error"))
|
||||
{
|
||||
result = response["error"].toObject()["message"].toString();
|
||||
//qDebug() << "result2:" << result;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool RobotController::processResponse_getJbiState(QJsonObject response, QString& result)
|
||||
{
|
||||
//qDebug() << "response:" << response;
|
||||
|
||||
if (response.contains("result"))
|
||||
{
|
||||
QString resultStr = response["result"].toString();
|
||||
|
||||
QJsonDocument resultDoc = QJsonDocument::fromJson(resultStr.toUtf8());
|
||||
QJsonObject resultObj = resultDoc.object();
|
||||
//qDebug() << "resultObj:" << resultObj;
|
||||
|
||||
int runState = resultObj["runState"].toInt();
|
||||
//qDebug() << "runState:" << runState;
|
||||
|
||||
result = QString::number(runState);
|
||||
//qDebug() << "result:" << result;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (response.contains("error"))
|
||||
{
|
||||
result = response["error"].toObject()["message"].toString();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void RobotController::getPoint()
|
||||
{
|
||||
QJsonObject response;
|
||||
getJbiState(response);//0 ֹͣ״̬,1 <20><>ͣ״̬,2 <20><>ͣ״̬,3 <20><><EFBFBD><EFBFBD>״̬,4 <20><><EFBFBD><EFBFBD>״̬
|
||||
QString result;
|
||||
bool x = processResponse_getJbiState(response, result);
|
||||
//qDebug() << "getJbiState:" << result;
|
||||
|
||||
if (result.toInt() != 3)
|
||||
{
|
||||
m_timer->stop();
|
||||
|
||||
m_iCurrentJbiJobLine = 0;
|
||||
m_iFileCounter = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD>
|
||||
emit hsiRecordSignal(-1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject response2;
|
||||
getCurrentJobLine(response2);
|
||||
QString result2;
|
||||
bool x2 = processResponse(response2, result2);
|
||||
|
||||
int m_iCurrentJbiJobLine_tmp = result2.toInt();
|
||||
|
||||
|
||||
if (m_iCurrentJbiJobLine_tmp != m_iCurrentJbiJobLine)
|
||||
{
|
||||
m_iFileCounter++;
|
||||
|
||||
qDebug() << "Changed! CurrentJobLine:" << m_iCurrentJbiJobLine_tmp;
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD>
|
||||
emit hsiRecordSignal(-1);
|
||||
|
||||
m_iCurrentJbiJobLine = m_iCurrentJbiJobLine_tmp;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ɼ<EFBFBD>
|
||||
emit hsiRecordSignal(m_iFileCounter);
|
||||
}
|
||||
}
|
||||
|
||||
void RobotController::sendCommand(const QString& cmd, const QJsonValue& params, int id)
|
||||
{
|
||||
QJsonObject request;
|
||||
request["method"] = cmd;
|
||||
request["params"] = params;
|
||||
request["jsonrpc"] = "2.0";
|
||||
request["id"] = id;
|
||||
|
||||
QJsonDocument doc(request);
|
||||
QByteArray data = doc.toJson(QJsonDocument::Compact) + "\n";
|
||||
//qDebug() << "send command:" << data.constData();
|
||||
|
||||
socket->write(data);
|
||||
socket->waitForBytesWritten();
|
||||
}
|
||||
|
||||
bool RobotController::onReadyRead(QJsonObject& re)
|
||||
{
|
||||
QByteArray data = socket->readAll();
|
||||
QJsonDocument doc = QJsonDocument::fromJson(data);
|
||||
if (!doc.isNull() && doc.isObject())
|
||||
{
|
||||
re = doc.object();
|
||||
//qDebug() << "Received all:" << re;
|
||||
|
||||
if (re.contains("result"))
|
||||
{
|
||||
//qDebug() << "Received result:" << re["result"].toVariant();
|
||||
return true;
|
||||
}
|
||||
else if (re.contains("error"))
|
||||
{
|
||||
//qDebug() << "Received error:" << re["error"];
|
||||
return false;
|
||||
}
|
||||
|
||||
//emit commandResponse(true, doc.object());
|
||||
}
|
||||
else
|
||||
{
|
||||
//emit commandResponse(false, QJsonObject());
|
||||
|
||||
re = QJsonObject();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool RobotController::getRobotPose(QJsonObject& re)
|
||||
{
|
||||
sendCommand("getRobotPose");
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::getRobotState(QJsonObject& re)
|
||||
{
|
||||
sendCommand("getRobotState");
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::getJbiState(QJsonObject& re)
|
||||
{
|
||||
sendCommand("getJbiState");
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::getCurrentJobLine(QJsonObject& re)
|
||||
{
|
||||
sendCommand("getCurrentJobLine");
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::getRobotMode(QJsonObject& re)
|
||||
{
|
||||
sendCommand("getRobotMode");
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::checkJbiExist(const QString& jbiFilename, QJsonObject& re)
|
||||
{
|
||||
QJsonObject paramsRunJbi;
|
||||
paramsRunJbi["filename"] = jbiFilename;//ʹ<>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>ṹ
|
||||
|
||||
sendCommand("checkJbiExist", paramsRunJbi);
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::setServoStatus(int status, QJsonObject& re)
|
||||
{
|
||||
QJsonObject params_set_servo_status;
|
||||
params_set_servo_status["status"] = status;//ʹ<>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>ṹ
|
||||
|
||||
sendCommand("set_servo_status", params_set_servo_status);
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::runJbi(const QString& jbiFilename, QJsonObject& re, bool isRecordHsi)
|
||||
{
|
||||
QJsonObject paramsRunJbi;
|
||||
paramsRunJbi["filename"] = jbiFilename;//ʹ<>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>ṹ
|
||||
|
||||
sendCommand("runJbi", paramsRunJbi);
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
if (isRecordHsi)
|
||||
{
|
||||
m_timer->start(1000);
|
||||
}
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::pauseTask(QJsonObject& re)
|
||||
{
|
||||
sendCommand("pause");
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::run(QJsonObject& re)
|
||||
{
|
||||
sendCommand("run");
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::continueTask(QJsonObject& re)
|
||||
{
|
||||
sendCommand("run");
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::setRobotPowerStatus(int status, QJsonObject& re)
|
||||
{
|
||||
sendCommand("set_robot_power_status", QJsonArray{ status });
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
EC8056::EC8056(QObject* parent) : QObject(parent), socket(new QTcpSocket(this))
|
||||
{
|
||||
connect(socket, &QTcpSocket::readyRead, this, &EC8056::onReadyRead);
|
||||
/*connect(socket, QOverload<QAbstractSocket::SocketError>::of(&QTcpSocket::errorOccurred),
|
||||
this, &EC8056::onSocketError);*/
|
||||
//connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
|
||||
// this, SLOT(onSocketError(QAbstractSocket::SocketError)));
|
||||
}
|
||||
|
||||
void EC8056::connectToHost(const QString& host, quint16 port)
|
||||
{
|
||||
socket->setProxy(QNetworkProxy::NoProxy);
|
||||
|
||||
socket->connectToHost(QHostAddress(host), port);
|
||||
|
||||
if (!socket->waitForConnected(3000)) {
|
||||
qDebug() << "Connection failed:" << socket->errorString();
|
||||
return;
|
||||
}
|
||||
qDebug() << "Connected successfully!";
|
||||
}
|
||||
|
||||
quint8 EC8056::readUInt8(const QByteArray& buf, int& offset)
|
||||
{
|
||||
return static_cast<quint8>(buf[offset++]);
|
||||
}
|
||||
|
||||
quint32 EC8056::readUInt32(const QByteArray& buf, int& offset)
|
||||
{
|
||||
quint32 val;
|
||||
memcpy(&val, buf.constData() + offset, sizeof(val));
|
||||
offset += sizeof(val);
|
||||
return qFromBigEndian(val);
|
||||
}
|
||||
|
||||
qint32 EC8056::readInt32(const QByteArray& buf, int& offset)
|
||||
{
|
||||
qint32 val;
|
||||
memcpy(&val, buf.constData() + offset, sizeof(val));
|
||||
offset += sizeof(val);
|
||||
return qFromBigEndian(val);
|
||||
}
|
||||
|
||||
quint64 EC8056::readUInt64(const QByteArray& buf, int& offset)
|
||||
{
|
||||
quint64 val;
|
||||
memcpy(&val, buf.constData() + offset, sizeof(val));
|
||||
offset += sizeof(val);
|
||||
return qFromBigEndian(val);
|
||||
}
|
||||
|
||||
double EC8056::readDouble(const QByteArray& buf, int& offset)
|
||||
{
|
||||
QByteArray b = buf.mid(offset, sizeof(double));
|
||||
offset += sizeof(double);
|
||||
if (QSysInfo::ByteOrder == QSysInfo::LittleEndian)
|
||||
std::reverse(b.begin(), b.end());
|
||||
|
||||
double val;
|
||||
memcpy(&val, b.constData(), sizeof(double));
|
||||
return val;
|
||||
}
|
||||
|
||||
void EC8056::onReadyRead()
|
||||
{
|
||||
buffer.append(socket->readAll());
|
||||
|
||||
if (buffer.size() < 1024)
|
||||
return;
|
||||
|
||||
int offset = 0;
|
||||
ECData data;
|
||||
|
||||
data.msgSize = readUInt32(buffer, offset);
|
||||
offset = 1020;
|
||||
data.matchingWord = readUInt32(buffer, offset);
|
||||
|
||||
if ((data.msgSize == 1024)/* && (data.matchingWord == 3967833836)*/)
|
||||
{
|
||||
offset = 0;
|
||||
|
||||
data.msgSize = readUInt32(buffer, offset);
|
||||
data.timeStamp = readUInt64(buffer, offset);
|
||||
data.auto_cycle = readUInt8(buffer, offset);
|
||||
|
||||
for (int i = 0; i < 8; ++i) data.machinePos[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 6; ++i) data.machinePose[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 6; ++i) data.machineUserPose[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 8; ++i) data.torque[i] = readDouble(buffer, offset);
|
||||
|
||||
data.robotState = readUInt32(buffer, offset);
|
||||
data.servoReady = readUInt32(buffer, offset);
|
||||
data.can_motor_run = readUInt32(buffer, offset);
|
||||
|
||||
for (int i = 0; i < 8; ++i) data.motor_speed[i] = readInt32(buffer, offset);
|
||||
|
||||
data.robotMode = readUInt32(buffer, offset);
|
||||
|
||||
for (int i = 0; i < 3; ++i) data.analog_ioInput[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 5; ++i) data.analog_ioOutput[i] = readDouble(buffer, offset);
|
||||
|
||||
data.digital_ioInput = readUInt64(buffer, offset);
|
||||
data.digital_ioOutput = readUInt64(buffer, offset);
|
||||
|
||||
data.collision = readUInt8(buffer, offset);
|
||||
|
||||
for (int i = 0; i < 6; ++i) data.machineFlangePose[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 6; ++i) data.machineUserFlangePose[i] = readDouble(buffer, offset);
|
||||
|
||||
data.emergencyStopState = readUInt8(buffer, offset);
|
||||
data.tcpSpeed = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 8; ++i) data.joIntSpeed[i] = readDouble(buffer, offset);
|
||||
data.tcpAcc = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 8; ++i) data.joIntAcc[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 6; ++i) data.joIntTemperature[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 6; ++i) data.joIntTorque[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 6; ++i) data.extJoIntTorques[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 6; ++i) data.exTcpForceIntool[i] = readDouble(buffer, offset);
|
||||
|
||||
data.dragState = readUInt8(buffer, offset);
|
||||
data.sensor_connected_state = readUInt8(buffer, offset);
|
||||
data.reserved = readUInt8(buffer, offset);
|
||||
data.matchingWord = readUInt32(buffer, offset);
|
||||
|
||||
/*if (data.msgSize != 1024 || data.matchingWord != 0xec8056ec) {
|
||||
buffer.clear();
|
||||
emit errorOccurred("Invalid packet received");
|
||||
return;
|
||||
}*/
|
||||
|
||||
emit dataReceived(data);
|
||||
}
|
||||
|
||||
|
||||
buffer.clear();
|
||||
}
|
||||
|
||||
void EC8056::onSocketError(QAbstractSocket::SocketError socketError)
|
||||
{
|
||||
Q_UNUSED(socketError)
|
||||
emit errorOccurred(socket->errorString());
|
||||
}
|
||||
164
HPPA/RobotArmControl.h
Normal file
164
HPPA/RobotArmControl.h
Normal file
@ -0,0 +1,164 @@
|
||||
#pragma once
|
||||
#include <qdialog.h>
|
||||
#include <QTcpSocket>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QDebug>
|
||||
#include <QThread>
|
||||
#include <QNetworkProxy>
|
||||
#include <QtEndian>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QAuthenticator>
|
||||
#include <QDebug>
|
||||
#include <QRegularExpression>
|
||||
#include <QProcess>
|
||||
#include <QStringListModel>
|
||||
#include <QTimer>
|
||||
|
||||
#include "ui_RobotArmControl.h"
|
||||
#include "fileOperation.h"
|
||||
|
||||
|
||||
struct ECData
|
||||
{
|
||||
quint32 msgSize;
|
||||
quint64 timeStamp;
|
||||
quint8 auto_cycle;
|
||||
double machinePos[8];//<2F>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
double machinePose[6];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
double machineUserPose[6];//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
double torque[8];//<2F>ؽڶ<DAB6><EEB6A8><EFBFBD>ذٷֱ<D9B7>
|
||||
quint32 robotState;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
quint32 servoReady;//<2F>ŷ<EFBFBD>ʹ<EFBFBD><CAB9>״̬
|
||||
quint32 can_motor_run;//ͬ<><CDAC>״̬
|
||||
qint32 motor_speed[8];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>
|
||||
quint32 robotMode;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
double analog_ioInput[3];//ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
double analog_ioOutput[5];//ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
quint64 digital_ioInput;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĶ<DDB5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
||||
quint64 digital_ioOutput;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĶ<DDB5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
||||
quint8 collision;//<2F><>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD>״̬
|
||||
double machineFlangePose[6];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>µķ<C2B5><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
double machineUserFlangePose[6];//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>µķ<C2B5><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
quint8 emergencyStopState;//<2F><>ǰ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڼ<EFBFBD>ͣ״̬
|
||||
double tcpSpeed;//tcp<63>˶<EFBFBD><CBB6>ٶ<EFBFBD>
|
||||
double joIntSpeed[8];//<2F>ؽ<EFBFBD><D8BD>˶<EFBFBD><CBB6>¸<EFBFBD><C2B8>ؽ<EFBFBD><D8BD>˶<EFBFBD><CBB6>ٶ<EFBFBD>
|
||||
double tcpAcc;//tcp<63><70><EFBFBD>ٶ<EFBFBD>
|
||||
double joIntAcc[8];//<2F>ؽ<EFBFBD><D8BD>˶<EFBFBD><CBB6>¸<EFBFBD><C2B8>ؽڼ<D8BD><DABC>ٶ<EFBFBD>
|
||||
double joIntTemperature[6];//<2F>¶<EFBFBD>
|
||||
double joIntTorque[6];//<2F><><EFBFBD><EFBFBD>Ť<EFBFBD><C5A4>
|
||||
double extJoIntTorques[6];//<2F>ⲿ<EFBFBD>ؽ<EFBFBD>Ť<EFBFBD><C5A4>ֵ
|
||||
double exTcpForceIntool[6];//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>µ<EFBFBD><C2B5>ⲿĩ<E2B2BF><C4A9><EFBFBD><EFBFBD>/<2F><><EFBFBD>ع<EFBFBD><D8B9><EFBFBD>ֵ
|
||||
quint8 dragState;//<2F>϶<EFBFBD>ʹ<EFBFBD><CAB9>״̬
|
||||
quint8 sensor_connected_state;//<2F><><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
quint8 reserved;
|
||||
quint32 matchingWord;
|
||||
};
|
||||
|
||||
class EC8056 : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EC8056(QObject* parent = nullptr);
|
||||
void connectToHost(const QString& host, quint16 port= 8056);
|
||||
|
||||
signals:
|
||||
void dataReceived(const ECData& data);
|
||||
void errorOccurred(const QString& error);
|
||||
|
||||
private slots:
|
||||
void onReadyRead();
|
||||
void onSocketError(QAbstractSocket::SocketError socketError);
|
||||
|
||||
private:
|
||||
QTcpSocket* socket;
|
||||
QByteArray buffer;
|
||||
|
||||
double readDouble(const QByteArray& buf, int& offset);
|
||||
quint64 readUInt64(const QByteArray& buf, int& offset);
|
||||
quint32 readUInt32(const QByteArray& buf, int& offset);
|
||||
qint32 readInt32(const QByteArray& buf, int& offset);
|
||||
quint8 readUInt8(const QByteArray& buf, int& offset);
|
||||
};
|
||||
|
||||
class RobotController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RobotController(QObject* parent = nullptr);
|
||||
~RobotController();
|
||||
|
||||
bool connectToRobot(const QString& ip, quint16 port = 8055);
|
||||
void disconnectFromRobot();
|
||||
void sendCommand(const QString& cmd, const QJsonValue& params = QJsonArray(), int id = 1);
|
||||
bool processResponse(QJsonObject response, QString& re);
|
||||
bool processResponse_getJbiState(QJsonObject response, QString& result);
|
||||
|
||||
bool getRobotPose(QJsonObject& re);
|
||||
bool getRobotState(QJsonObject& re);//ֹͣ״̬ 0<><30><EFBFBD><EFBFBD>ͣ״̬ 1<><31><EFBFBD><EFBFBD>ͣ״̬ 2<><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ 3<><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ 4<><34><EFBFBD><EFBFBD>ײ״̬ 5
|
||||
bool getJbiState(QJsonObject& re);//0 ֹͣ״̬,1 <20><>ͣ״̬,2 <20><>ͣ״̬,3 <20><><EFBFBD><EFBFBD>״̬,4 <20><><EFBFBD><EFBFBD>״̬
|
||||
bool getCurrentJobLine(QJsonObject& re);
|
||||
bool getRobotMode(QJsonObject& re);//ʾ<><CABE>ģʽ 0<><30><EFBFBD>Զ<EFBFBD>ģʽ 1<><31>Զ<EFBFBD><D4B6>ģʽ 2
|
||||
bool checkJbiExist(const QString& jbiFilename, QJsonObject& re);
|
||||
bool setServoStatus(int status, QJsonObject& re);
|
||||
bool runJbi(const QString& jbiFilename, QJsonObject& re, bool isRecordHsi);
|
||||
bool pauseTask(QJsonObject& re);
|
||||
bool run(QJsonObject& re);
|
||||
bool continueTask(QJsonObject& re);
|
||||
bool setRobotPowerStatus(int status, QJsonObject& re);
|
||||
|
||||
bool onReadyRead(QJsonObject& re);
|
||||
|
||||
private:
|
||||
QTcpSocket* socket;
|
||||
|
||||
QTimer* m_timer;
|
||||
int m_iTimeout = 3000;
|
||||
int m_iCurrentJbiJobLine = 0;
|
||||
int m_iFileCounter = 0;
|
||||
|
||||
signals:
|
||||
void commandResponse(bool success, const QJsonObject& response);
|
||||
void hsiRecordSignal(int);
|
||||
|
||||
private slots:
|
||||
void getPoint();
|
||||
};
|
||||
|
||||
class RobotArmControl : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RobotArmControl(QWidget* parent = nullptr);
|
||||
~RobotArmControl();
|
||||
RobotController* robotController;
|
||||
|
||||
void onCommandResponse(QString str, const QJsonObject& response);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
void getTaskList();
|
||||
void getPose();
|
||||
|
||||
void connectRobotArm();
|
||||
void executeTaskWithHyperImager();
|
||||
void executeTaskWithoutHyperImager();
|
||||
void pauseTask();
|
||||
void continueTask();
|
||||
|
||||
void monitorRobotArm(const ECData& data);
|
||||
|
||||
signals:
|
||||
//void Opened();
|
||||
//void Closed();
|
||||
|
||||
private:
|
||||
Ui::RobotArmControl_UI ui;
|
||||
|
||||
EC8056* robotMonitor;
|
||||
QStringListModel* m_pModel;
|
||||
};
|
||||
138
HPPA/RobotArmControl.ui
Normal file
138
HPPA/RobotArmControl.ui
Normal file
@ -0,0 +1,138 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RobotArmControl_UI</class>
|
||||
<widget class="QDialog" name="RobotArmControl_UI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>424</width>
|
||||
<height>364</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="pause_task_btn">
|
||||
<property name="text">
|
||||
<string>暂停任务</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="connect2arm_btn">
|
||||
<property name="text">
|
||||
<string>连接机械臂</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="execute_task_btn">
|
||||
<property name="text">
|
||||
<string>执行任务</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="get_pose_btn">
|
||||
<property name="text">
|
||||
<string>获取pose</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="continue_task_btn">
|
||||
<property name="text">
|
||||
<string>继续任务</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QTextEdit" name="textEdit"/>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="6">
|
||||
<widget class="QFrame" name="frame_2">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="get_task_list_btn">
|
||||
<property name="text">
|
||||
<string>获取任务列表</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QListView" name="taskList_listView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="pose_z_label">
|
||||
<property name="text">
|
||||
<string>z</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="pose_x_label">
|
||||
<property name="text">
|
||||
<string>x</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="pose_y_label">
|
||||
<property name="text">
|
||||
<string>y</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
605
HPPA/TwoMotorControl.cpp
Normal file
605
HPPA/TwoMotorControl.cpp
Normal file
@ -0,0 +1,605 @@
|
||||
#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()));
|
||||
|
||||
connect(ui.run_btn, SIGNAL(clicked()), this, SLOT(run()));
|
||||
connect(ui.stop_btn, SIGNAL(clicked()), this, SLOT(stop()));
|
||||
}
|
||||
|
||||
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_pushButton, SIGNAL(pressed()), this, SLOT(onxMove2Loc()));
|
||||
|
||||
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::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("读取成功!"));
|
||||
}
|
||||
95
HPPA/TwoMotorControl.h
Normal file
95
HPPA/TwoMotorControl.h
Normal file
@ -0,0 +1,95 @@
|
||||
#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 onyMotorforward();
|
||||
void onyMotorbackward();
|
||||
void onyMotorStop();
|
||||
|
||||
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;
|
||||
};
|
||||
@ -9,7 +9,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>756</width>
|
||||
<width>629</width>
|
||||
<height>463</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -25,7 +25,7 @@
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>250</y>
|
||||
<width>578</width>
|
||||
<width>434</width>
|
||||
<height>134</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -70,7 +70,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>版本:1.8.2</string>
|
||||
<string>版本:2.0</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
|
||||
@ -12,6 +12,10 @@ adjustTable::adjustTable(QWidget *parent)
|
||||
connect(ui.objective_table2_up_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable2Up_btn()));
|
||||
connect(ui.objective_table2_down_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable2Down_btn()));
|
||||
connect(ui.objective_table2_stop_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable2Stop_btn()));
|
||||
|
||||
connect(ui.objective_table252_up_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable252Up_btn()));
|
||||
connect(ui.objective_table252_down_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable252Down_btn()));
|
||||
connect(ui.objective_table252_stop_btn, SIGNAL(clicked()), this, SLOT(onObjectivTable252Stop_btn()));
|
||||
}
|
||||
|
||||
adjustTable::~adjustTable()
|
||||
@ -63,3 +67,21 @@ void adjustTable::onObjectivTable2Stop_btn()
|
||||
QString xx = "http://192.168.1.254/stopnow";
|
||||
getRequest(xx);
|
||||
}
|
||||
|
||||
void adjustTable::onObjectivTable252Up_btn()
|
||||
{
|
||||
QString xx = "http://192.168.1.252/set_up";
|
||||
getRequest(xx);
|
||||
}
|
||||
|
||||
void adjustTable::onObjectivTable252Down_btn()
|
||||
{
|
||||
QString xx = "http://192.168.1.252/set_down";
|
||||
getRequest(xx);
|
||||
}
|
||||
|
||||
void adjustTable::onObjectivTable252Stop_btn()
|
||||
{
|
||||
QString xx = "http://192.168.1.252/stopnow";
|
||||
getRequest(xx);
|
||||
}
|
||||
@ -24,6 +24,10 @@ public Q_SLOTS:
|
||||
void onObjectivTable2Down_btn();
|
||||
void onObjectivTable2Stop_btn();
|
||||
|
||||
void onObjectivTable252Up_btn();
|
||||
void onObjectivTable252Down_btn();
|
||||
void onObjectivTable252Stop_btn();
|
||||
|
||||
private:
|
||||
Ui::adjustTableClass ui;
|
||||
|
||||
|
||||
@ -6,33 +6,66 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>348</width>
|
||||
<height>194</height>
|
||||
<width>687</width>
|
||||
<height>389</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>adjustTable</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_8">
|
||||
<property name="title">
|
||||
<string>252号升降台</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="objective_table252_up_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>上升</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="objective_table252_down_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>下降</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="objective_table252_stop_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>停止</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_7">
|
||||
<property name="title">
|
||||
<string>1号升降台</string>
|
||||
<string>253号升降台</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_11">
|
||||
<item row="0" column="0">
|
||||
@ -77,10 +110,10 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="0" column="2">
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="title">
|
||||
<string>2号升降台</string>
|
||||
<string>254号升降台</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_9">
|
||||
<item row="0" column="0">
|
||||
|
||||
@ -17,7 +17,7 @@ public:
|
||||
~FileOperation();
|
||||
|
||||
string getDirectoryOfExe();//getDirectoryOfExe
|
||||
string getDirectoryFromString(string directory="C:/HPPA_image");
|
||||
string getDirectoryFromString(string directory="C:\\HPPA_image");
|
||||
|
||||
|
||||
|
||||
|
||||
@ -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)
|
||||
@ -91,10 +102,42 @@ bool test(void *pCaller, int *x, int *y, void **pvdata)
|
||||
}
|
||||
|
||||
void focusWindow::onConnectMotor()
|
||||
{
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
QString configFilePath = QString::fromStdString(directory) + "\\oneMotorConfigFile_focus.cfg";
|
||||
|
||||
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();
|
||||
|
||||
//归零
|
||||
//emit zeroStartSignal(0);
|
||||
|
||||
//自动调焦逻辑
|
||||
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
|
||||
{
|
||||
if (m_ctrlFocusMotor != nullptr)
|
||||
{
|
||||
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-------------------------\n");
|
||||
printf("不能重复连接-------------------------\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -154,41 +197,96 @@ void focusWindow::onConnectMotor()
|
||||
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()
|
||||
{
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
emit zeroStartSignal(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ctrlFocusMotor->MoveToLogicZero();
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onMove2MotorMax()
|
||||
{
|
||||
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();
|
||||
|
||||
m_ctrlFocusMotor->MoveToPos(di.iAbsPosition + stepSize);
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
emit rmoveSignal(0, (double)abs(rdistance), m_dSpeed, 1000);
|
||||
}
|
||||
|
||||
void focusWindow::onSubtract()
|
||||
else
|
||||
{
|
||||
DriverInfo di;
|
||||
m_ctrlFocusMotor->GetDriverStatus(di);
|
||||
|
||||
int stepSize = ui.subtractStepSize_lineEdit->text().toInt();
|
||||
m_ctrlFocusMotor->MoveToPos(di.iAbsPosition + rdistance);
|
||||
}
|
||||
}
|
||||
|
||||
m_ctrlFocusMotor->MoveToPos(di.iAbsPosition - stepSize);
|
||||
void focusWindow::onSubtract()
|
||||
{
|
||||
double rdistance = ui.subtractStepSize_lineEdit->text().toDouble();
|
||||
|
||||
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 - rdistance);
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onAutoFocus()
|
||||
{
|
||||
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();
|
||||
|
||||
//获取马达最大位置
|
||||
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);
|
||||
@ -196,38 +294,48 @@ void focusWindow::onAutoFocus()
|
||||
connect(thread1, SIGNAL(AutoFocusFinishedSignal()), this, SLOT(onAutoFocusFinished()));
|
||||
|
||||
thread1->start();
|
||||
this->setDisabled(true);
|
||||
|
||||
WorkerThread4* progressThread = new WorkerThread4(m_ctrlFocusMotor);
|
||||
connect(progressThread, SIGNAL(AutoFocusProgressSignal(int)), this, SLOT(onAutoFocusProgress(int)));
|
||||
progressThread->start();
|
||||
ui.autoFocusProgress_progressBar->reset();
|
||||
}
|
||||
this->setDisabled(true);
|
||||
}
|
||||
|
||||
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);}");
|
||||
|
||||
@ -236,31 +344,193 @@ void focusWindow::onManualFocus()
|
||||
}
|
||||
|
||||
void focusWindow::onUpdateCurrentLocation()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void focusWindow::onAutoFocusFinished()
|
||||
{
|
||||
this->setDisabled(false);
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
//通过高斯拟合获取最佳位置
|
||||
QVector<PositionData> positionData = m_coordinator->getAllPositionData();
|
||||
|
||||
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
|
||||
|
||||
@ -397,3 +397,529 @@ bool Configfile::updateConfigFile()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
CorningConfigfile::CorningConfigfile()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorningConfigfile::setConfigfilePath(string configfilePath)
|
||||
{
|
||||
m_configfilePath = configfilePath;
|
||||
}
|
||||
|
||||
bool CorningConfigfile::isConfigfileExist()
|
||||
{
|
||||
QFileInfo info(QString::fromStdString(m_configfilePath));
|
||||
|
||||
return info.exists();
|
||||
}
|
||||
|
||||
bool CorningConfigfile::parseConfigfile()
|
||||
{
|
||||
// Read the file. If there is an error, report it and exit.
|
||||
try
|
||||
{
|
||||
cfg.readFile(m_configfilePath);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (const FileIOException& fioex)
|
||||
{
|
||||
std::cerr << "I/O error while reading file." << std::endl;
|
||||
return false;
|
||||
}
|
||||
catch (const ParseException& pex)
|
||||
{
|
||||
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
|
||||
<< " - " << pex.getError() << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CorningConfigfile::getSpectralBin(int& spectralBin)
|
||||
{
|
||||
try
|
||||
{
|
||||
spectralBin = cfg.lookup("spectralBin");
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (const SettingNotFoundException& nfex)
|
||||
{
|
||||
cerr << "No 'spectralBin' setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CorningConfigfile::getspatialBin(int& spatialBin)
|
||||
{
|
||||
try
|
||||
{
|
||||
spatialBin = cfg.lookup("spatialBin");
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (const SettingNotFoundException& nfex)
|
||||
{
|
||||
cerr << "No 'spatialBin' setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CorningConfigfile::getEffectiveWindow(int& width, int& offsetx, int& height, int& offsety)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
|
||||
try
|
||||
{
|
||||
int spatialBin;
|
||||
int spectralBin;
|
||||
getspatialBin(spatialBin);
|
||||
getSpectralBin(spectralBin);
|
||||
|
||||
string spatialBinString;
|
||||
if (spatialBin == 1)
|
||||
{
|
||||
spatialBinString = "bin1";
|
||||
}
|
||||
else
|
||||
{
|
||||
spatialBinString = "bin2";
|
||||
}
|
||||
const Setting& spatialArgument = root["effective_window"][spatialBinString]["spatial"];
|
||||
if (!(spatialArgument.lookupValue("width", width)
|
||||
&& spatialArgument.lookupValue("offsetx", offsetx)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
string spectralBinString;
|
||||
if (spectralBin == 1)
|
||||
{
|
||||
spectralBinString = "bin1";
|
||||
}
|
||||
else
|
||||
{
|
||||
spectralBinString = "bin2";
|
||||
}
|
||||
const Setting& spectralArgument = root["effective_window"][spectralBinString]["spectral"];
|
||||
if (!(spectralArgument.lookupValue("height", height)
|
||||
&& spectralArgument.lookupValue("offsety", offsety)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (const SettingNotFoundException& nfex)
|
||||
{
|
||||
// Ignore.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CorningConfigfile::getEffectiveWindowRoi(int& width, int& offsetx)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
|
||||
try
|
||||
{
|
||||
const Setting& effective_window = root["effective_window_roi"];
|
||||
int count = effective_window.getLength();
|
||||
|
||||
int spatialBin;
|
||||
getspatialBin(spatialBin);
|
||||
|
||||
string spatialBinString;
|
||||
if (spatialBin == 1)
|
||||
{
|
||||
spatialBinString = "spatialBin1";
|
||||
}
|
||||
else
|
||||
{
|
||||
spatialBinString = "spatialBin2";
|
||||
}
|
||||
|
||||
const Setting& window = effective_window[spatialBinString];
|
||||
string name = window.getName();
|
||||
|
||||
if (!(window.lookupValue("width", width)
|
||||
&& window.lookupValue("offsetx", offsetx)
|
||||
))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (const SettingNotFoundException& nfex)
|
||||
{
|
||||
// Ignore.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CorningConfigfile::getPushFlowParam(int& flowSwitch, int& rgbHeight, int& framerateVideo)
|
||||
{
|
||||
Setting& root = cfg.getRoot();
|
||||
|
||||
if (!root.exists("push_flow_param"))
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB2BB><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Setting& push_flow_param = root.add("push_flow_param", Setting::TypeGroup);
|
||||
|
||||
push_flow_param.add("flow_switch", Setting::TypeInt) = 0;
|
||||
push_flow_param.add("rgb_height", Setting::TypeInt) = 720;
|
||||
push_flow_param.add("framerate_video", Setting::TypeInt) = 5;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ĺ<DEB8><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5>ļ<EFBFBD>
|
||||
try
|
||||
{
|
||||
QList<QString> fileInfo = getFileInfo(QString::fromStdString(m_configfilePath));
|
||||
bool ret = createDir(fileInfo[0]);
|
||||
|
||||
cfg.writeFile(m_configfilePath.c_str());
|
||||
std::cout << "Config item 'push_flow_param' added." << std::endl;
|
||||
|
||||
flowSwitch = 0;
|
||||
rgbHeight = 720;
|
||||
framerateVideo = 5;
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (const libconfig::FileIOException& fioex)
|
||||
{
|
||||
std::cerr << "I/O error while writing file." << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
const Setting& push_flow_param = root["push_flow_param"];
|
||||
|
||||
if (!(push_flow_param.lookupValue("rgb_height", rgbHeight)
|
||||
&& push_flow_param.lookupValue("framerate_video", framerateVideo)
|
||||
&& push_flow_param.lookupValue("flow_switch", flowSwitch)
|
||||
))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (const SettingNotFoundException& nfex)
|
||||
{
|
||||
// Ignore.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CorningConfigfile::getWindowOffsety_HeightOfSpectral(int& offsety, int& height, string spectralBinString)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
|
||||
try
|
||||
{
|
||||
const Setting& spectralArgument = root["effective_window"][spectralBinString]["spectral"];
|
||||
if (!(spectralArgument.lookupValue("height", height)
|
||||
&& spectralArgument.lookupValue("offsety", offsety)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (const SettingNotFoundException& nfex)
|
||||
{
|
||||
// Ignore.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CorningConfigfile::getGainOffset(float& gain, float& offset)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
|
||||
try
|
||||
{
|
||||
const Setting& gainOffset = root["gainOffset"];
|
||||
int count = gainOffset.getLength();
|
||||
|
||||
int spectralBin;
|
||||
getSpectralBin(spectralBin);
|
||||
|
||||
string spectralBinString;
|
||||
if (spectralBin == 1)
|
||||
{
|
||||
spectralBinString = "spectralBin1";
|
||||
}
|
||||
else
|
||||
{
|
||||
spectralBinString = "spectralBin2";
|
||||
}
|
||||
|
||||
const Setting& gainOffsetSetting = gainOffset[spectralBinString];
|
||||
string name = gainOffsetSetting.getName();
|
||||
|
||||
if (!(gainOffsetSetting.lookupValue("gain", gain)
|
||||
&& gainOffsetSetting.lookupValue("offset", offset)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (const SettingNotFoundException& nfex)
|
||||
{
|
||||
// Ignore.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CorningConfigfile::getGainOffsetOfSpectralBin1(float& gain, float& offset)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
|
||||
try
|
||||
{
|
||||
const Setting& gainOffset = root["gainOffset"];
|
||||
int count = gainOffset.getLength();
|
||||
|
||||
string spectralBinString = "spectralBin1";
|
||||
|
||||
const Setting& gainOffsetSetting = gainOffset[spectralBinString];
|
||||
string name = gainOffsetSetting.getName();
|
||||
|
||||
if (!(gainOffsetSetting.lookupValue("gain", gain)
|
||||
&& gainOffsetSetting.lookupValue("offset", offset)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (const SettingNotFoundException& nfex)
|
||||
{
|
||||
// Ignore.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CorningConfigfile::getSN(QString& SN)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string SN_tem = cfg.lookup("SN");
|
||||
SN = QString::fromStdString(SN_tem);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (const SettingNotFoundException& nfex)
|
||||
{
|
||||
cerr << "No 'spectralBin' setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CorningConfigfile::getBufferPolicy(int& bufferPolicy)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
const Setting& ximeadll = root["ximeadll"];
|
||||
|
||||
try
|
||||
{
|
||||
if (!(ximeadll.lookupValue("buffer_policy", bufferPolicy)
|
||||
))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (const SettingNotFoundException& nfex)
|
||||
{
|
||||
cerr << "No 'spectralBin' setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CorningConfigfile::getAcqBufferSize(int& acqBufferSize)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
const Setting& ximeadll = root["ximeadll"];
|
||||
|
||||
try
|
||||
{
|
||||
if (!(ximeadll.lookupValue("acq_buffer_size", acqBufferSize)
|
||||
))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (const SettingNotFoundException& nfex)
|
||||
{
|
||||
cerr << "No 'spectralBin' setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CorningConfigfile::createConfigFile()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace libconfig;
|
||||
|
||||
Config cfg;
|
||||
|
||||
Setting& root = cfg.getRoot();
|
||||
|
||||
// Add some settings to the configuration.
|
||||
Setting& SN = root.add("SN", Setting::TypeString) = "0098";
|
||||
Setting& spatialBin = root.add("spatialBin", Setting::TypeInt) = 2;
|
||||
Setting& SpectralBin = root.add("spectralBin", Setting::TypeInt) = 2;
|
||||
|
||||
Setting& effective_window = root.add("effective_window", Setting::TypeGroup);
|
||||
Setting& effective_window_Bin1 = effective_window.add("bin1", Setting::TypeGroup);
|
||||
Setting& effective_window_Bin1_spatial = effective_window_Bin1.add("spatial", Setting::TypeGroup);
|
||||
Setting& effective_window_Bin1_Spectral = effective_window_Bin1.add("spectral", Setting::TypeGroup);
|
||||
Setting& effective_window_Bin2 = effective_window.add("bin2", Setting::TypeGroup);
|
||||
Setting& effective_window_Bin2_spatial = effective_window_Bin2.add("spatial", Setting::TypeGroup);
|
||||
Setting& effective_window_Bin2_Spectral = effective_window_Bin2.add("spectral", Setting::TypeGroup);
|
||||
|
||||
effective_window_Bin1_spatial.add("width", Setting::TypeInt) = 1368;
|
||||
effective_window_Bin1_spatial.add("offsetx", Setting::TypeInt) = 288;
|
||||
effective_window_Bin1_Spectral.add("height", Setting::TypeInt) = 300;
|
||||
effective_window_Bin1_Spectral.add("offsety", Setting::TypeInt) = 348;
|
||||
|
||||
effective_window_Bin2_spatial.add("width", Setting::TypeInt) = 688;
|
||||
effective_window_Bin2_spatial.add("offsetx", Setting::TypeInt) = 144;
|
||||
effective_window_Bin2_Spectral.add("height", Setting::TypeInt) = 150;
|
||||
effective_window_Bin2_Spectral.add("offsety", Setting::TypeInt) = 174;
|
||||
|
||||
Setting& effective_window_roi = root.add("effective_window_roi", Setting::TypeGroup);
|
||||
Setting& effective_window_roi_spatialBin1 = effective_window_roi.add("spatialBin1", Setting::TypeGroup);
|
||||
Setting& effective_window_roi_spatialBin2 = effective_window_roi.add("spatialBin2", Setting::TypeGroup);
|
||||
|
||||
effective_window_roi_spatialBin1.add("width", Setting::TypeInt) = 1364;
|
||||
effective_window_roi_spatialBin1.add("offsetx", Setting::TypeInt) = 14;
|
||||
// effective_window_roi_Bin1.add("height", Setting::TypeInt) = 300;
|
||||
// effective_window_roi_Bin1.add("offsety", Setting::TypeInt) = 348;
|
||||
|
||||
effective_window_roi_spatialBin2.add("width", Setting::TypeInt) = 682;
|
||||
effective_window_roi_spatialBin2.add("offsetx", Setting::TypeInt) = 15;
|
||||
// effective_window_roi_Bin2.add("height", Setting::TypeInt) = 151;
|
||||
// effective_window_roi_Bin2.add("offsety", Setting::TypeInt) = 174;
|
||||
|
||||
Setting& gainOffset = root.add("gainOffset", Setting::TypeGroup);
|
||||
Setting& gainOffsetSpectralBin1 = gainOffset.add("spectralBin1", Setting::TypeGroup);
|
||||
Setting& gainOffsetSpectralBin2 = gainOffset.add("spectralBin2", Setting::TypeGroup);
|
||||
|
||||
gainOffsetSpectralBin1.add("gain", Setting::TypeFloat) = 2.00313433;
|
||||
gainOffsetSpectralBin1.add("offset", Setting::TypeFloat) = -300.46283157590585;
|
||||
|
||||
gainOffsetSpectralBin2.add("gain", Setting::TypeFloat) = 4.00626868;
|
||||
gainOffsetSpectralBin2.add("offset", Setting::TypeFloat) = -299.46126663407176;
|
||||
|
||||
|
||||
Setting& ximeadll = root.add("ximeadll", Setting::TypeGroup);
|
||||
ximeadll.add("buffer_policy", Setting::TypeInt) = 0;
|
||||
ximeadll.add("acq_buffer_size", Setting::TypeInt) = 400;
|
||||
|
||||
Setting& push_flow_param = root.add("push_flow_param", Setting::TypeGroup);
|
||||
push_flow_param.add("flow_switch", Setting::TypeInt) = 1;
|
||||
push_flow_param.add("rgb_height", Setting::TypeInt) = 720;
|
||||
push_flow_param.add("framerate_video", Setting::TypeInt) = 5;
|
||||
|
||||
// Write out the new configuration.
|
||||
try
|
||||
{
|
||||
cfg.writeFile(m_configfilePath.c_str());
|
||||
cerr << "New configuration successfully written to: " << m_configfilePath.c_str() << endl;
|
||||
|
||||
}
|
||||
catch (const FileIOException& fioex)
|
||||
{
|
||||
cerr << "I/O error while writing configuration file: " << m_configfilePath.c_str() << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CorningConfigfile::updateConfigFile()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace libconfig;
|
||||
|
||||
static const char* output_file = "updated.cfg";
|
||||
|
||||
Config cfg;
|
||||
|
||||
cfg.setOptions(Config::OptionFsync
|
||||
| Config::OptionSemicolonSeparators
|
||||
| Config::OptionColonAssignmentForGroups
|
||||
| Config::OptionOpenBraceOnSeparateLine);
|
||||
|
||||
// Read the file. If there is an error, report it and exit.
|
||||
try
|
||||
{
|
||||
cfg.readFile("example.cfg");
|
||||
}
|
||||
catch (const FileIOException& fioex)
|
||||
{
|
||||
std::cerr << "I/O error while reading file." << std::endl;
|
||||
return false;
|
||||
}
|
||||
catch (const ParseException& pex)
|
||||
{
|
||||
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
|
||||
<< " - " << pex.getError() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Find the 'movies' setting. Add intermediate settings if they don't yet
|
||||
// exist.
|
||||
Setting& root = cfg.getRoot();
|
||||
|
||||
if (!root.exists("inventory"))
|
||||
root.add("inventory", Setting::TypeGroup);
|
||||
|
||||
Setting& inventory = root["inventory"];
|
||||
|
||||
if (!inventory.exists("movies"))
|
||||
inventory.add("movies", Setting::TypeList);
|
||||
|
||||
Setting& movies = inventory["movies"];
|
||||
|
||||
// Create the new movie entry.
|
||||
Setting& movie = movies.add(Setting::TypeGroup);
|
||||
|
||||
movie.add("title", Setting::TypeString) = "Buckaroo Banzai";
|
||||
movie.add("media", Setting::TypeString) = "DVD";
|
||||
movie.add("price", Setting::TypeFloat) = 12.99;
|
||||
movie.add("qty", Setting::TypeInt) = 20;
|
||||
|
||||
// Write out the updated configuration.
|
||||
try
|
||||
{
|
||||
cfg.writeFile(output_file);
|
||||
cerr << "Updated configuration successfully written to: " << output_file
|
||||
<< endl;
|
||||
|
||||
}
|
||||
catch (const FileIOException& fioex)
|
||||
{
|
||||
cerr << "I/O error while writing file: " << output_file << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -45,6 +45,36 @@ public:
|
||||
bool createConfigFile();
|
||||
bool updateConfigFile();
|
||||
|
||||
private:
|
||||
string m_configfilePath;
|
||||
Config cfg;
|
||||
};
|
||||
|
||||
class CorningConfigfile
|
||||
{
|
||||
public:
|
||||
CorningConfigfile();
|
||||
void setConfigfilePath(string configfilePath);
|
||||
bool isConfigfileExist();
|
||||
bool parseConfigfile();
|
||||
|
||||
bool getSpectralBin(int& spectralBin);
|
||||
bool getspatialBin(int& spatialBin);
|
||||
bool getEffectiveWindow(int& width, int& offsetx, int& height, int& offsety);
|
||||
bool getEffectiveWindowRoi(int& width, int& offsetx);
|
||||
bool getWindowOffsety_HeightOfSpectral(int& offsety, int& height, string spectralBinString);//spectralBinString = "bin1"<22><><EFBFBD>ߡ<EFBFBD>bin2<6E><32>
|
||||
bool getGainOffset(float& gain, float& offset);
|
||||
bool getGainOffsetOfSpectralBin1(float& gain, float& offset);
|
||||
bool getSN(QString& SN);
|
||||
|
||||
bool getBufferPolicy(int& bufferPolicy);
|
||||
bool getAcqBufferSize(int& acqBufferSize);
|
||||
|
||||
bool getPushFlowParam(int& flowSwitch, int& rgbHeight, int& framerateVideo);
|
||||
|
||||
bool createConfigFile();
|
||||
bool updateConfigFile();
|
||||
|
||||
private:
|
||||
string m_configfilePath;
|
||||
Config cfg;
|
||||
|
||||
@ -172,7 +172,7 @@ void CImage::FillFocusGrayQImage(unsigned short * datacube)
|
||||
}
|
||||
}
|
||||
|
||||
m_qimageFocusGrayImage->save("D:/delete/2222222222/test.bmp");
|
||||
//m_qimageFocusGrayImage->save("D:/delete/2222222222/test.bmp");
|
||||
|
||||
|
||||
|
||||
|
||||
165
HPPA/imager_base.cpp
Normal file
165
HPPA/imager_base.cpp
Normal file
@ -0,0 +1,165 @@
|
||||
#include "imager_base.h"
|
||||
Iris::ImagerBase::ImagerBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Iris::ImagerBase::~ImagerBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Iris::ImagerBase::set_spectral_bin(int new_spectral_bin)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_spectral_bin()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_min_spectral_bin()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_max_spectral_bin()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_start_band()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Iris::ImagerBase::set_start_band(int band)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_min_start_band()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_max_start_band()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_inc_start_band()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_end_band()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Iris::ImagerBase::set_end_band(int band)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_min_end_band()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_max_end_band()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_inc_end_band()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_start_sample()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Iris::ImagerBase::set_start_sample(int sample)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_min_start_sample()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_max_start_sample()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_inc_start_sample()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_end_sample()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Iris::ImagerBase::set_end_sample(int sample)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_min_end_sample()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_max_end_sample()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_inc_end_sample()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Iris::ImagerBase::set_gain(const double gain)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
double Iris::ImagerBase::get_gain()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
double Iris::ImagerBase::get_min_gain()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
double Iris::ImagerBase::get_max_gain()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Iris::ImagerBase::set_internal_trigger()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Iris::ImagerBase::set_external_trigger(unsigned int signal_line, bool rising_edge)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Iris::ImagerBase::is_trigger_external()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
93
HPPA/imager_base.h
Normal file
93
HPPA/imager_base.h
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Iris API
|
||||
*
|
||||
* By using this API, the user agrees to the terms and conditions as stated in the
|
||||
* document "Terms of Use", located on the Resonon website
|
||||
* at: http://www.resonon.com/downloads/Resonon_API_Terms_of_Use.pdf.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __GUARD_Iris_IMAGER_BASE_H
|
||||
#define __GUARD_Iris_IMAGER_BASE_H
|
||||
|
||||
#include <stdexcept>
|
||||
#include <cstdint>
|
||||
//#include "irisximeaimager_global.h"
|
||||
|
||||
/**
|
||||
* The Iris namespace contains all public classes.
|
||||
*/
|
||||
namespace Iris
|
||||
{
|
||||
/**
|
||||
* An abstract base class which provides a common interface for all imagers.
|
||||
*/
|
||||
class ImagerBase
|
||||
{
|
||||
public:
|
||||
ImagerBase();
|
||||
virtual ~ImagerBase();
|
||||
|
||||
|
||||
virtual void connect(const char * camera_sn=NULL)=0;
|
||||
virtual void disconnect()=0;
|
||||
virtual void start()=0;
|
||||
virtual void stop()=0;
|
||||
virtual void get_imager_type(char *buffer, int buffer_size)=0;
|
||||
virtual void get_serial_number(char *buffer, int buffer_size)=0;
|
||||
virtual void get_camera_serial_number(char *buffer, int buffer_size)=0;
|
||||
virtual void generate_configuration_report(char *buffer, int buffer_size)=0;
|
||||
virtual float get_coeff_a()=0;
|
||||
virtual float get_coeff_b()=0;
|
||||
virtual float get_coeff_c()=0;
|
||||
virtual double get_wavelength_at_band(const int band)=0;
|
||||
int get_nearest_band_to_wavelength(const double wavelength);
|
||||
virtual int get_frame_buffer_size_in_bytes()=0;
|
||||
virtual unsigned short* get_frame(unsigned short* buffer)=0;
|
||||
virtual std::uint64_t get_last_timestamp()=0;
|
||||
virtual std::uint64_t ticks_per_second()=0;
|
||||
virtual void set_spectral_bin(int new_spectral_bin);
|
||||
virtual int get_spectral_bin();
|
||||
virtual int get_min_spectral_bin();
|
||||
virtual int get_max_spectral_bin();
|
||||
virtual int get_band_count()=0;
|
||||
virtual int get_start_band();
|
||||
virtual void set_start_band(int band);
|
||||
virtual int get_min_start_band();
|
||||
virtual int get_max_start_band();
|
||||
virtual int get_inc_start_band();
|
||||
virtual int get_end_band();
|
||||
virtual void set_end_band(int band);
|
||||
virtual int get_min_end_band();
|
||||
virtual int get_max_end_band();
|
||||
virtual int get_inc_end_band();
|
||||
virtual int get_sample_count()=0;
|
||||
virtual int get_start_sample();
|
||||
virtual void set_start_sample(int sample);
|
||||
virtual int get_min_start_sample();
|
||||
virtual int get_max_start_sample();
|
||||
virtual int get_inc_start_sample();
|
||||
virtual int get_end_sample();
|
||||
virtual void set_end_sample(int sample);
|
||||
virtual int get_min_end_sample();
|
||||
virtual int get_max_end_sample();
|
||||
virtual int get_inc_end_sample();
|
||||
virtual void set_framerate(const double frames_per_second)=0;
|
||||
virtual double get_framerate()=0;
|
||||
virtual double get_min_framerate()=0;
|
||||
virtual double get_max_framerate()=0;
|
||||
virtual double get_min_integration_time()=0;
|
||||
virtual double get_max_integration_time()=0;
|
||||
virtual void set_integration_time(const double milliseconds)=0;
|
||||
virtual double get_integration_time()=0;
|
||||
virtual void set_gain(const double gain);
|
||||
virtual double get_gain();
|
||||
virtual double get_min_gain();
|
||||
virtual double get_max_gain();
|
||||
virtual void set_internal_trigger();
|
||||
virtual void set_external_trigger(unsigned int signal_line, bool rising_edge=true);
|
||||
virtual bool is_trigger_external();
|
||||
};
|
||||
} //end namespace Iris
|
||||
#endif //end ifndef __GUARD_Iris_IMAGER_BASE_H
|
||||
565
HPPA/irisximeaimager.cpp
Normal file
565
HPPA/irisximeaimager.cpp
Normal file
@ -0,0 +1,565 @@
|
||||
#include "irisximeaimager.h"
|
||||
using namespace Iris;
|
||||
|
||||
void Iris::IrisXimeaImager::setGainOffset(float gain, float offset)
|
||||
{
|
||||
m_fGain = gain;
|
||||
m_fOffset = offset;
|
||||
}
|
||||
|
||||
bool Iris::IrisXimeaImager::setSpectralBin(int spectralBin)
|
||||
{
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_SELECTOR, XI_BIN_SELECT_HOST_CPU));//用:XI_BIN_SELECT_HOST_CPU;默认为XI_BIN_SELECT_SENSOR(会报错),不可用:XI_BIN_SELECT_DEVICE_FPGA
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_VERTICAL_MODE, XI_BIN_MODE_AVERAGE));
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_VERTICAL, spectralBin));
|
||||
printf("Iris::IrisXimeaImager::setSpectralBin----2 设置bin模式为XI_PRM_BINNING_SELECTOR XI_BIN_MODE_AVERAGE !\n");
|
||||
|
||||
|
||||
// CE(xiSetParamInt(m_xiH, XI_PRM_DECIMATION_SELECTOR, XI_DEC_SELECT_SENSOR));
|
||||
// CE(xiSetParamInt(m_xiH, XI_PRM_DECIMATION_VERTICAL, spectralBin));
|
||||
|
||||
|
||||
m_iSpectralBin = spectralBin;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Iris::IrisXimeaImager::setSpatialBin(int spatialBin)
|
||||
{
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_SELECTOR, XI_BIN_SELECT_HOST_CPU));//用:XI_BIN_SELECT_HOST_CPU;默认为XI_BIN_SELECT_SENSOR(会报错),不可用:XI_BIN_SELECT_DEVICE_FPGA
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_HORIZONTAL_MODE, XI_BIN_MODE_AVERAGE));
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_HORIZONTAL, spatialBin));
|
||||
printf("Iris::IrisXimeaImager::setSpatialBin----2 设置bin模式为XI_PRM_BINNING_SELECTOR XI_BIN_MODE_AVERAGE !\n");
|
||||
|
||||
|
||||
// CE(xiSetParamInt(m_xiH, XI_PRM_DECIMATION_SELECTOR, XI_DEC_SELECT_SENSOR));
|
||||
// CE(xiSetParamInt(m_xiH, XI_PRM_DECIMATION_HORIZONTAL, spatialBin));
|
||||
|
||||
m_iSpatialBin = spatialBin;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::getSpectralBin()
|
||||
{
|
||||
int spectralBin = 0;
|
||||
CE(xiGetParamInt(m_xiH, XI_PRM_BINNING_VERTICAL, &spectralBin));
|
||||
|
||||
// CE(xiGetParamInt(m_xiH, XI_PRM_DECIMATION_VERTICAL, &spectralBin));
|
||||
|
||||
return spectralBin;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::getSpatialBin()
|
||||
{
|
||||
int spatialBin = 0;
|
||||
CE(xiGetParamInt(m_xiH, XI_PRM_BINNING_HORIZONTAL, &spatialBin));
|
||||
|
||||
// CE(xiGetParamInt(m_xiH, XI_PRM_DECIMATION_HORIZONTAL, &spatialBin));
|
||||
|
||||
return spatialBin;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::setEffectiveWindow(int OffsetX, int width, int OffsetY, int height)
|
||||
{
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_WIDTH, width));
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_OFFSET_X, OffsetX));
|
||||
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_HEIGHT, height));
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_OFFSET_Y, OffsetY));
|
||||
|
||||
m_iEffectiveWindow_OffsetX = OffsetX;
|
||||
m_iEffectiveWindow_width = width;
|
||||
m_iEffectiveWindow_OffsetY = OffsetY;
|
||||
m_iEffectiveWindow_height = height;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::setEffectiveWindowRoi(int OffsetX, int width)
|
||||
{
|
||||
m_iEffectiveWindowRoi_OffsetX = OffsetX;
|
||||
m_iEffectiveWindowRoi_width = width;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::getBufferSizeOfOneFrame()
|
||||
{
|
||||
// if(m_xiH==NULL)
|
||||
// return 0;
|
||||
//
|
||||
// start();
|
||||
//
|
||||
// //清空image缓存
|
||||
// memset(&m_image, 0, sizeof(m_image));
|
||||
// m_image.size = sizeof(XI_IMG);
|
||||
//
|
||||
// CE(xiGetImage(m_xiH, 5000, &m_image)); // getting next image from the camera opened
|
||||
//
|
||||
// stop();
|
||||
//
|
||||
// return static_cast<int>(m_image.bp_size);
|
||||
|
||||
// //比实际大小(m_iEffectiveWindow_height * m_iEffectiveWindow_width * 2)大,why?
|
||||
// int value = 0;
|
||||
// xiGetParamInt(m_xiH, XI_PRM_IMAGE_PAYLOAD_SIZE, &value);
|
||||
|
||||
|
||||
return m_iEffectiveWindow_height * m_iEffectiveWindow_width * 2;
|
||||
}
|
||||
|
||||
float Iris::IrisXimeaImager::getTemperature()
|
||||
{
|
||||
float temperature = 0.0;
|
||||
CE(xiGetParamFloat(m_xiH, XI_PRM_TEMP, &temperature));
|
||||
|
||||
return temperature;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::setBufferPolicy(int bufferPolicy)
|
||||
{
|
||||
if (bufferPolicy==0)
|
||||
{
|
||||
xiSetParamInt(m_xiH, XI_PRM_BUFFER_POLICY, XI_BP_UNSAFE);
|
||||
printf("Iris::IrisXimeaImager::connect---- XI_PRM_BUFFER_POLICY: XI_BP_UNSAFE\n");
|
||||
}
|
||||
else if (bufferPolicy==1)
|
||||
{
|
||||
xiSetParamInt(m_xiH, XI_PRM_BUFFER_POLICY, XI_BP_SAFE);
|
||||
printf("Iris::IrisXimeaImager::connect---- XI_PRM_BUFFER_POLICY: XI_BP_SAFE\n");
|
||||
}
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::setAcqBufferSize(int acqBufferSize)
|
||||
{
|
||||
XI_RETURN stat = XI_OK;
|
||||
|
||||
// set unit to 1 MiB
|
||||
xiSetParamInt(m_xiH, XI_PRM_ACQ_BUFFER_SIZE_UNIT, 1024*1024);
|
||||
int value = 0;
|
||||
xiGetParamInt(m_xiH, XI_PRM_ACQ_BUFFER_SIZE, &value);
|
||||
printf("Iris::IrisXimeaImager::connect---- XI_PRM_ACQ_BUFFER_SIZE: %d MiB.\n", value);
|
||||
|
||||
xiSetParamInt(m_xiH, XI_PRM_ACQ_BUFFER_SIZE, acqBufferSize);
|
||||
|
||||
xiGetParamInt(m_xiH, XI_PRM_ACQ_BUFFER_SIZE, &value);
|
||||
printf("Iris::IrisXimeaImager::connect---- XI_PRM_ACQ_BUFFER_SIZE: %d MiB.\n", value);
|
||||
|
||||
// set maximum number of queue
|
||||
int number_of_field_buffers = 0;
|
||||
xiGetParamInt(m_xiH, XI_PRM_BUFFERS_QUEUE_SIZE XI_PRM_INFO_MAX, &number_of_field_buffers);
|
||||
printf("Iris::IrisXimeaImager::connect---- XI_PRM_BUFFERS_QUEUE_SIZE XI_PRM_INFO_MAX: %d.\n", number_of_field_buffers);
|
||||
HandleResult(stat,"xiGetParam (number_of_field_buffers maximum)");
|
||||
xiSetParamInt(m_xiH, XI_PRM_BUFFERS_QUEUE_SIZE, number_of_field_buffers);
|
||||
HandleResult(stat,"xiSetParam (number_of_field_buffers)");
|
||||
}
|
||||
|
||||
Iris::IrisXimeaImager::IrisXimeaImager()
|
||||
{
|
||||
m_xiH=NULL;
|
||||
|
||||
//std::cout<<"ximeaControlDll 版本:"<< "21." <<std::endl;
|
||||
}
|
||||
|
||||
Iris::IrisXimeaImager::~IrisXimeaImager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::connect(const char *camera_serial_number)
|
||||
{
|
||||
printf("Iris::IrisXimeaImager::connect----1 打开相机(xiOpenDevice)\n");
|
||||
CE(xiOpenDevice(0, &m_xiH));//没有插上ximea相机,这句代码都过不去
|
||||
|
||||
//add-----------------------------------------------------------------------------------------------------------------------
|
||||
XI_RETURN stat = XI_OK;
|
||||
|
||||
int payload=0;
|
||||
stat = xiGetParamInt(m_xiH, XI_PRM_IMAGE_PAYLOAD_SIZE, &payload);
|
||||
HandleResult(stat,"xiGetParam (payload)");
|
||||
|
||||
int transport_buffer_size_default = 0;
|
||||
int transport_buffer_size_increment = 0;
|
||||
int transport_buffer_size_minimum = 0;
|
||||
// get default transport buffer size - that should be OK on all controllers
|
||||
stat = xiGetParamInt(m_xiH, XI_PRM_ACQ_TRANSPORT_BUFFER_SIZE, &transport_buffer_size_default);
|
||||
HandleResult(stat,"xiGetParamInt (transport buffer size)");
|
||||
stat = xiGetParamInt(m_xiH, XI_PRM_ACQ_TRANSPORT_BUFFER_SIZE XI_PRM_INFO_INCREMENT, &transport_buffer_size_increment);
|
||||
HandleResult(stat,"xiGetParamInt (transport buffer size increment)");
|
||||
stat = xiGetParamInt(m_xiH, XI_PRM_ACQ_TRANSPORT_BUFFER_SIZE XI_PRM_INFO_MIN, &transport_buffer_size_minimum);
|
||||
HandleResult(stat,"xiGetParamInt (transport buffer size minimum)");
|
||||
|
||||
// check if payload size is less than default transport buffer size
|
||||
if(payload < transport_buffer_size_default + transport_buffer_size_increment)
|
||||
{
|
||||
// use optimized transport buffer size, as nearest increment to payload
|
||||
int transport_buffer_size = payload;
|
||||
if (transport_buffer_size_increment)
|
||||
{
|
||||
// round up to nearest increment
|
||||
int remainder = transport_buffer_size % transport_buffer_size_increment;
|
||||
if (remainder)
|
||||
transport_buffer_size += transport_buffer_size_increment - remainder;
|
||||
}
|
||||
// check the minimum
|
||||
if (transport_buffer_size < transport_buffer_size_minimum)
|
||||
transport_buffer_size = transport_buffer_size_minimum;
|
||||
stat = xiSetParamInt(m_xiH, XI_PRM_ACQ_TRANSPORT_BUFFER_SIZE, transport_buffer_size);
|
||||
HandleResult(stat,"xiSetParam (transport buffer size)");
|
||||
}
|
||||
//add---------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// set unit to 1 MiB
|
||||
xiSetParamInt(m_xiH, XI_PRM_ACQ_BUFFER_SIZE_UNIT, 1024*1024);
|
||||
int value = 0;
|
||||
xiGetParamInt(m_xiH, XI_PRM_ACQ_BUFFER_SIZE, &value);
|
||||
printf("Iris::IrisXimeaImager::connect---- XI_PRM_ACQ_BUFFER_SIZE: %d MiB.\n", value);
|
||||
|
||||
|
||||
int NUM_THREADS = 0;
|
||||
xiGetParamInt(m_xiH, XI_PRM_PROC_NUM_THREADS, &NUM_THREADS);
|
||||
printf("Iris::IrisXimeaImager::connect---- XI_PRM_PROC_NUM_THREADS默认值为%d\n", NUM_THREADS);
|
||||
xiSetParamInt(m_xiH, XI_PRM_PROC_NUM_THREADS, 8);
|
||||
|
||||
//设置数据格式
|
||||
printf("Iris::IrisXimeaImager::connect----2 设置数据格式(xiSetParamInt)\n");
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_IMAGE_DATA_FORMAT, XI_RAW16));//Default value: XI_MONO8
|
||||
// //设置packing, 使用xiGetImage接收影像时不执行unpacking
|
||||
// CE(xiSetParamInt(m_xiH, XI_PRM_OUTPUT_DATA_BIT_DEPTH, 12));//set 12 bit transport data width
|
||||
// CE(xiSetParamInt(m_xiH, XI_PRM_OUTPUT_DATA_PACKING, XI_ON));//enable packing
|
||||
// //使用xiGetImage接收影像时不执行unpacking
|
||||
// CE(xiSetParamInt(m_xiH, XI_PRM_IMAGE_DATA_FORMAT, XI_FRM_TRANSPORT_DATA));//in this case, the function xiGetImage just set pointer to transport-buffer without any processing
|
||||
|
||||
//判断数据格式设置是否成功
|
||||
int dataFortmat;
|
||||
CE(xiGetParamInt(m_xiH, XI_PRM_IMAGE_DATA_FORMAT, &dataFortmat));
|
||||
if(dataFortmat==XI_RAW16)
|
||||
{
|
||||
printf("Iris::IrisXimeaImager::connect----当前数据格式设置成功, 设置为: XI_RAW16\n");
|
||||
}
|
||||
else if(dataFortmat==XI_FRM_TRANSPORT_DATA)
|
||||
{
|
||||
printf("Iris::IrisXimeaImager::connect----当前数据格式设置成功, 设置为: XI_FRM_TRANSPORT_DATA\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Iris::IrisXimeaImager::connect----2 数据格式设置失败!\n");
|
||||
printf("Iris::IrisXimeaImager::connect----当前数据格式为:%d\n",dataFortmat);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::disconnect()
|
||||
{
|
||||
printf("Closing camera...\n");
|
||||
CE(xiCloseDevice(m_xiH));
|
||||
|
||||
m_xiH=NULL;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::start()
|
||||
{
|
||||
CE(xiStartAcquisition(m_xiH));
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::stop()
|
||||
{
|
||||
//printf("Stopping acquisition...\n");
|
||||
CE(xiStopAcquisition(m_xiH));
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::get_imager_type(char *buffer, int buffer_size)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::get_serial_number(char *buffer, int buffer_size)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::get_camera_serial_number(char *buffer, int buffer_size)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::generate_configuration_report(char *buffer, int buffer_size)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
float Iris::IrisXimeaImager::get_coeff_a()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
float Iris::IrisXimeaImager::get_coeff_b()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
float Iris::IrisXimeaImager::get_coeff_c()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_wavelength_at_band(const int band)
|
||||
{
|
||||
//sn008
|
||||
float a=1.999564;
|
||||
float b=-279.893;
|
||||
//
|
||||
float wavelength=band*m_fGain + m_fOffset;
|
||||
return wavelength;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_frame_buffer_size_in_bytes()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned short *Iris::IrisXimeaImager::get_frame(unsigned short *buffer)
|
||||
{
|
||||
//清空image缓存
|
||||
memset(&m_image, 0, sizeof(m_image));
|
||||
m_image.size = sizeof(XI_IMG);
|
||||
|
||||
CE(xiGetImage(m_xiH, 5000, &m_image)); // getting next image from the camera opened
|
||||
|
||||
//方法1:memcpy
|
||||
memcpy(buffer,m_image.bp,m_image.bp_size);
|
||||
// //方法2:此做法是错误的,虽然是指针,也是传值!
|
||||
// buffer = (unsigned short *)m_image.bp;
|
||||
|
||||
// for(int i=0;i<m_iEffectiveWindow_height;i++)
|
||||
// {
|
||||
// memcpy(buffer+i*m_iEffectiveWindowRoi_width, (unsigned short *)m_image.bp + i*m_iEffectiveWindow_width + m_iEffectiveWindowRoi_OffsetX, m_iEffectiveWindowRoi_width*2);
|
||||
// }
|
||||
|
||||
//强制将指针从高精度(uint64_t*)转换到低精度(unsigned short *),会有精度降低的问题???????????????????????????????????????????????????
|
||||
return (unsigned short *)&m_timestampOfCamera;
|
||||
}
|
||||
|
||||
uint64_t Iris::IrisXimeaImager::get_last_timestamp()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t Iris::IrisXimeaImager::ticks_per_second()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_spectral_bin(int new_spectral_bin)
|
||||
{
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_spectral_bin()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_min_spectral_bin()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_max_spectral_bin()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_band_count()
|
||||
{
|
||||
return m_iEffectiveWindow_height;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_start_band()
|
||||
{
|
||||
int WindowStartLine;
|
||||
CE(xiGetParamInt(m_xiH, XI_PRM_OFFSET_Y, &WindowStartLine));
|
||||
|
||||
return WindowStartLine;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_start_band(int band)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_min_start_band()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_max_start_band()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_inc_start_band()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_end_band()
|
||||
{
|
||||
int height;
|
||||
CE(xiGetParamInt(m_xiH, XI_PRM_HEIGHT, &height));
|
||||
return get_start_band()+height;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_end_band(int band)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_min_end_band()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_max_end_band()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_inc_end_band()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_sample_count()
|
||||
{
|
||||
return m_iEffectiveWindow_width;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_start_sample()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_start_sample(int sample)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_min_start_sample()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_max_start_sample()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_inc_start_sample()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_end_sample()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_end_sample(int sample)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_min_end_sample()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_max_end_sample()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_inc_end_sample()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_framerate(const double frames_per_second)
|
||||
{
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_ACQ_TIMING_MODE, XI_ACQ_TIMING_MODE_FRAME_RATE_LIMIT));
|
||||
|
||||
CE(xiSetParamFloat(m_xiH, XI_PRM_FRAMERATE, frames_per_second));
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_framerate()
|
||||
{
|
||||
float framerate;
|
||||
CE(xiGetParamFloat(m_xiH, XI_PRM_FRAMERATE, &framerate));
|
||||
return framerate;
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_min_framerate()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_max_framerate()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_min_integration_time()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_max_integration_time()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_integration_time(const double microsecond)
|
||||
{
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_EXPOSURE, microsecond));//time_in_us(microseconds)
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_integration_time()
|
||||
{
|
||||
float exposureTime;
|
||||
CE(xiGetParamFloat(m_xiH, XI_PRM_EXPOSURE, &exposureTime));//time_in_us(microseconds)
|
||||
return exposureTime;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_gain(const double gain)
|
||||
{
|
||||
CE(xiSetParamFloat(m_xiH, XI_PRM_GAIN, gain));//gain_in_db
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_gain()
|
||||
{
|
||||
float gain;
|
||||
CE(xiGetParamFloat(m_xiH, XI_PRM_GAIN, &gain));
|
||||
return gain;
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_min_gain()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_max_gain()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_internal_trigger()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_external_trigger(unsigned int signal_line, bool rising_edge)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Iris::IrisXimeaImager::is_trigger_external()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
123
HPPA/irisximeaimager.h
Normal file
123
HPPA/irisximeaimager.h
Normal file
@ -0,0 +1,123 @@
|
||||
#ifndef IRISXIMEAIMAGER_H
|
||||
#define IRISXIMEAIMAGER_H
|
||||
|
||||
#include <memory.h>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
|
||||
//#include "irisximeaimager_global.h"
|
||||
#include "imager_base.h"
|
||||
#ifdef WIN32
|
||||
#include <xiApi.h> // Windows
|
||||
#else
|
||||
#include <m3api/xiApi.h> // Linux, OSX
|
||||
#endif
|
||||
|
||||
#define CE(func) {XI_RETURN stat = (func); if (XI_OK!=stat) {printf("Error:%d returned from function:"#func"\n",stat);throw stat;}}
|
||||
#define HandleResult(res,place) if (res!=XI_OK) {printf("Error after %s (%d)\n",place,res);}
|
||||
|
||||
namespace Iris
|
||||
{
|
||||
class IrisXimeaImager:public ImagerBase
|
||||
{
|
||||
public:
|
||||
HANDLE m_xiH;
|
||||
void setGainOffset(float gain, float offset);
|
||||
bool setSpectralBin(int spectralBin);
|
||||
bool setSpatialBin(int spatialBin);
|
||||
int getSpectralBin();
|
||||
int getSpatialBin();
|
||||
void setEffectiveWindow(int OffsetX, int width, int OffsetY, int height);
|
||||
void setEffectiveWindowRoi(int OffsetX, int width);
|
||||
int getBufferSizeOfOneFrame();
|
||||
float getTemperature();
|
||||
|
||||
XI_IMG m_image; // image buffer
|
||||
|
||||
void setBufferPolicy(int bufferPolicy);//0:XI_BP_UNSAFE; 1:XI_BP_SAFE;
|
||||
void setAcqBufferSize(int acqBufferSize);//单位MiB
|
||||
|
||||
public:
|
||||
//继承基类的
|
||||
IrisXimeaImager();//11111111111111111111
|
||||
virtual ~IrisXimeaImager();
|
||||
|
||||
void connect(const char * camera_serial_number=NULL);//111111111111111111111111111111111
|
||||
void disconnect();//111111111111111111111111111111
|
||||
void start();//111111111111111111111
|
||||
void stop();//1111111111111111111111
|
||||
void get_imager_type(char *buffer, int buffer_size);
|
||||
void get_serial_number(char *buffer, int buffer_size);
|
||||
void get_camera_serial_number(char *buffer, int buffer_size);
|
||||
void generate_configuration_report(char *buffer, int buffer_size);
|
||||
float get_coeff_a();
|
||||
float get_coeff_b();
|
||||
float get_coeff_c();
|
||||
double get_wavelength_at_band(const int band);//11111111111111111111
|
||||
int get_frame_buffer_size_in_bytes();
|
||||
unsigned short* get_frame(unsigned short* buffer);//11111111111111111111111
|
||||
std::uint64_t get_last_timestamp();
|
||||
std::uint64_t ticks_per_second();
|
||||
void set_spectral_bin(int new_spectral_bin);//11111111111111111111111111111111
|
||||
int get_spectral_bin();
|
||||
int get_min_spectral_bin();
|
||||
int get_max_spectral_bin();
|
||||
int get_band_count();//11111111111111111111
|
||||
int get_start_band();//对应上一版本api的函数:get_window_start_band
|
||||
void set_start_band(int band);
|
||||
int get_min_start_band();
|
||||
int get_max_start_band();
|
||||
int get_inc_start_band();
|
||||
int get_end_band();//对应上一版本api的函数:get_window_end_band
|
||||
void set_end_band(int band);
|
||||
int get_min_end_band();
|
||||
int get_max_end_band();
|
||||
int get_inc_end_band();
|
||||
int get_sample_count();//11111111111111111
|
||||
int get_start_sample();
|
||||
void set_start_sample(int sample);
|
||||
int get_min_start_sample();
|
||||
int get_max_start_sample();
|
||||
int get_inc_start_sample();
|
||||
int get_end_sample();
|
||||
void set_end_sample(int sample);
|
||||
int get_min_end_sample();
|
||||
int get_max_end_sample();
|
||||
int get_inc_end_sample();
|
||||
void set_framerate(const double frames_per_second);//11111111111111111111111111111111
|
||||
double get_framerate();//1111111111111111111111
|
||||
double get_min_framerate();
|
||||
double get_max_framerate();
|
||||
double get_min_integration_time();
|
||||
double get_max_integration_time();
|
||||
void set_integration_time(const double microsecond);//111111111111111111111
|
||||
double get_integration_time();//1111111111111111111111111111111
|
||||
void set_gain(const double gain);//111111111111
|
||||
double get_gain();//111111111111
|
||||
double get_min_gain();
|
||||
double get_max_gain();
|
||||
void set_internal_trigger();
|
||||
void set_external_trigger(unsigned int signal_line, bool rising_edge=true);
|
||||
bool is_trigger_external();
|
||||
protected:
|
||||
private:
|
||||
uint64_t m_timestampOfCamera;
|
||||
|
||||
int m_iSpectralBin;
|
||||
int m_iSpatialBin;
|
||||
|
||||
int m_iEffectiveWindow_OffsetX;
|
||||
int m_iEffectiveWindow_width;
|
||||
int m_iEffectiveWindow_OffsetY;
|
||||
int m_iEffectiveWindow_height;
|
||||
|
||||
int m_iEffectiveWindowRoi_OffsetX;
|
||||
int m_iEffectiveWindowRoi_width;
|
||||
|
||||
float m_fGain;
|
||||
float m_fOffset;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // IRISXIMEAIMAGER_H
|
||||
285
HPPA/oneMotorControl.ui
Normal file
285
HPPA/oneMotorControl.ui
Normal file
@ -0,0 +1,285 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OneMotorControl_UI</class>
|
||||
<widget class="QDialog" name="OneMotorControl_UI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>544</width>
|
||||
<height>346</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>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>返回速度</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<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="realTimeLoc_lineEdit">
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="speed_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>0.1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="return_speed_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>2</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="move2loc_lineEdit">
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="connect_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="zero_start_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="rangeMeasurement_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="move2loc_pushButton">
|
||||
<property name="text">
|
||||
<string>移动至</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>161</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="left_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>←0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="right_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>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<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="QLabel" name="motor_state_label">
|
||||
<property name="text">
|
||||
<string>马达状态</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" 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>
|
||||
1010
HPPA/twoMotorControl.ui
Normal file
1010
HPPA/twoMotorControl.ui
Normal file
File diff suppressed because it is too large
Load Diff
@ -101,6 +101,17 @@ bool createDir(QString fullPath)
|
||||
}
|
||||
}
|
||||
|
||||
std::string removeFileExtension(std::string filename)
|
||||
{
|
||||
size_t lastDot = filename.find_last_of(".");
|
||||
if (lastDot == std::string::npos) {
|
||||
// 如果没有找到后缀,返回原字符串
|
||||
return filename;
|
||||
}
|
||||
return filename.substr(0, lastDot);
|
||||
|
||||
}
|
||||
|
||||
QList<QString> getFileInfo(QString file)
|
||||
{
|
||||
QFileInfo fileInfo = QFileInfo(file);
|
||||
@ -121,3 +132,28 @@ QList<QString> getFileInfo(QString file)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
long long getNanosecondsSinceMidnight()
|
||||
{
|
||||
// 获取当前系统时间
|
||||
auto now = std::chrono::system_clock::now();
|
||||
|
||||
// 转换为 time_t(秒级别的时间戳)
|
||||
std::time_t t = std::chrono::system_clock::to_time_t(now);
|
||||
std::tm local_tm = *std::localtime(&t); // 获取本地时间结构
|
||||
|
||||
// 将时间结构调整到当天 00:00:00
|
||||
local_tm.tm_hour = 0;
|
||||
local_tm.tm_min = 0;
|
||||
local_tm.tm_sec = 0;
|
||||
local_tm.tm_isdst = -1; // 让 mktime 自动判断夏令时
|
||||
|
||||
// 获取当天 00:00:00 的时间点
|
||||
auto midnight = std::chrono::system_clock::from_time_t(std::mktime(&local_tm));
|
||||
|
||||
// 计算从当天 00:00:00 到现在的时间差
|
||||
auto nanoseconds_since_midnight = std::chrono::duration_cast<std::chrono::nanoseconds>(now - midnight);
|
||||
|
||||
// 返回纳秒数
|
||||
return nanoseconds_since_midnight.count();
|
||||
}
|
||||
|
||||
@ -3,9 +3,11 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include <chrono>
|
||||
|
||||
QString getFileNameBaseOnTime();
|
||||
|
||||
@ -17,7 +19,10 @@ void bubbleSort(unsigned short * a, int n);
|
||||
void swap(unsigned short * a, unsigned short * b);
|
||||
|
||||
bool createDir(QString fullPath);
|
||||
std::string removeFileExtension(std::string filename);
|
||||
|
||||
QList<QString> getFileInfo(QString file);
|
||||
|
||||
long long getNanosecondsSinceMidnight();
|
||||
|
||||
#endif // UTILITY_TC_H
|
||||
|
||||
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;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
28
readme.txt
Normal file
28
readme.txt
Normal file
@ -0,0 +1,28 @@
|
||||
1、HPPA拼接
|
||||
每条航线的开始帧的位置不一样,无法直接将相邻航线拼接一起,否则航向有错位。
|
||||
1.1 步骤
|
||||
(1)采集每帧的同时,获取线性平台的位置,并写入文件;
|
||||
(2)根据位置信息匹配帧号,然后进行拼接;
|
||||
1.2 存在的问题及解决办法
|
||||
(1)马达库不知道是否能够支持20hz及以上的访问频率;
|
||||
或者按照一定频率采集线性平台位置,通过时间进行插值获取每帧位置;
|
||||
(2)列之间的重叠
|
||||
通过一个可调参数进行旁向拼接设置;
|
||||
1.3 拼接后裁剪
|
||||
|
||||
1.4 根据每个像素的xy坐标进行拼接:放弃
|
||||
|
||||
2、bug修复
|
||||
(1)反射率图像条纹:白板和暗电流都采集30帧进行平均;
|
||||
(2)轨迹2位小数
|
||||
(3)速度输入接受小数
|
||||
|
||||
3、hppa升降桌无线控制模块
|
||||
如果没有配置过,那么默认ip为http://192.168.1.254,且默认wifi以iris1开头,默认wifi密码为123456789。
|
||||
配置网页为http://192.168.1.254/wificonfig.html,配置密码是licahk*******
|
||||
|
||||
如果已经配置为252,那么可用下面网址控制
|
||||
http://192.168.1.252/stopnow
|
||||
http://192.168.1.252/set_up
|
||||
http://192.168.1.252/set_down
|
||||
http://192.168.1.252/wificonfig.html
|
||||
Reference in New Issue
Block a user