|
|
|
|
#include "AdvanceSetupWidget.h"
|
|
|
|
|
#include "ui_AdvanceSetupWidget.h"
|
|
|
|
|
#include "Common.h"
|
|
|
|
|
#include <QRegExpValidator>
|
|
|
|
|
#include "frame/Frame.h"
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
#include <QDoubleValidator>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include "device/DeviceManager.h"
|
|
|
|
|
#include "logger/LogManager.h"
|
|
|
|
|
#include "data/DateTimeData.h"
|
|
|
|
|
#include "data/StringData.h"
|
|
|
|
|
//#include "data/StructData.h"
|
|
|
|
|
#include "data/TorqueModeStructData.h"
|
|
|
|
|
#include "data/BoltModeStructData.h"
|
|
|
|
|
#include "data/AngleModeStructData.h"
|
|
|
|
|
#include "data/GearModeStructData.h"
|
|
|
|
|
#include "data/SensorModeStructData.h"
|
|
|
|
|
#include "data/FallbackStructData.h"
|
|
|
|
|
#include "SetupService.h"
|
|
|
|
|
#include "Utils.h"
|
|
|
|
|
#include <Qtxlsx>
|
|
|
|
|
#include "TmsKey.h"
|
|
|
|
|
|
|
|
|
|
extern double gZoomValue;
|
|
|
|
|
extern unsigned char m_currType; // 当前类型 23.8.30
|
|
|
|
|
|
|
|
|
|
static QString BsBoltDiameterToStr(QString diameter)
|
|
|
|
|
{
|
|
|
|
|
QString strDiameter;
|
|
|
|
|
if(diameter.compare("1⁄4") == 0) { strDiameter = "1/4"; }
|
|
|
|
|
else if(diameter.compare("5⁄16") == 0) { strDiameter = "5/16"; }
|
|
|
|
|
else if(diameter.compare("3⁄8") == 0) { strDiameter = "3/8"; }
|
|
|
|
|
else if(diameter.compare("7⁄16") == 0) { strDiameter = "7/16"; }
|
|
|
|
|
else if(diameter.compare("½") == 0) { strDiameter = "1/2"; }
|
|
|
|
|
else if(diameter.compare("⁹/1₆") == 0) { strDiameter = "9/16"; }
|
|
|
|
|
else if(diameter.compare("⅝") == 0) { strDiameter = "5/8"; }
|
|
|
|
|
else if(diameter.compare("¾") == 0) { strDiameter = "3/4"; }
|
|
|
|
|
else if(diameter.compare("⅞") == 0) { strDiameter = "7/8"; }
|
|
|
|
|
else if(diameter.compare("1") == 0) { strDiameter = "1"; }
|
|
|
|
|
else if(diameter.compare("1⅛") == 0) { strDiameter = "1_1/8"; }
|
|
|
|
|
else if(diameter.compare("1¼") == 0) { strDiameter = "1_1/4"; }
|
|
|
|
|
else if(diameter.compare("1⅜") == 0) { strDiameter = "1_3/8"; }
|
|
|
|
|
else if(diameter.compare("1½") == 0) { strDiameter = "1_1/2"; }
|
|
|
|
|
else if(diameter.compare("1¾") == 0) { strDiameter = "1_3/4"; }
|
|
|
|
|
else if(diameter.compare("2") == 0) { strDiameter = "2"; }
|
|
|
|
|
else if(diameter.compare("2¼") == 0) { strDiameter = "2_1/4"; }
|
|
|
|
|
else if(diameter.compare("2½") == 0) { strDiameter = "2_1/2"; }
|
|
|
|
|
else if(diameter.compare("2¾") == 0) { strDiameter = "2_3/4"; }
|
|
|
|
|
else if(diameter.compare("3") == 0) { strDiameter = "3"; }
|
|
|
|
|
else if(diameter.compare("3¼") == 0) { strDiameter = "3_1/4"; }
|
|
|
|
|
else if(diameter.compare("3½") == 0) { strDiameter = "3_1/2"; }
|
|
|
|
|
else if(diameter.compare("3¾") == 0) { strDiameter = "3_3/4"; }
|
|
|
|
|
else if(diameter.compare("4") == 0) { strDiameter = "4"; }
|
|
|
|
|
else { strDiameter = diameter; }
|
|
|
|
|
|
|
|
|
|
return strDiameter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AdvanceSetupWidget::AdvanceSetupWidget(QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
, ui(new Ui::AdvanceSetupWidget)
|
|
|
|
|
, m_fallbackAngle("")
|
|
|
|
|
, m_fallbackAmpere("")
|
|
|
|
|
, m_fallbackAmpere_2("")
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
|
|
init();
|
|
|
|
|
//showType1();
|
|
|
|
|
|
|
|
|
|
// 测试:
|
|
|
|
|
#ifdef _HOME_TEST_
|
|
|
|
|
ui->lineEditTorqueModeSettingsFilePath->setText("D:/06_yinuo/MyWork/博霆科技/电动扳手/02设计/扳手扭矩模式.xlsx");
|
|
|
|
|
ui->lineEditBoltModeSettingsFilePath->setText("D:/06_yinuo/MyWork/博霆科技/电动扳手/02设计/扳手螺栓模式.xlsx");
|
|
|
|
|
ui->lineEditAngleModeSettingsFilePath->setText("D:/06_yinuo/MyWork/博霆科技/电动扳手/02设计/扳手角度模式.xlsx");
|
|
|
|
|
ui->lineEditGearPresetModeSettingsFilePath->setText("D:/06_yinuo/MyWork/博霆科技/电动扳手/02设计/扳手档位模式.xlsx");
|
|
|
|
|
ui->lineEditSensorModeSettingsFilePath->setText("D:/06_yinuo/MyWork/博霆科技/电动扳手/02设计/扳手传感器模式.xlsx");
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef _YN_TEST_
|
|
|
|
|
ui->lineEditTorqueModeSettingsFilePath->setText("E:/MyWork/博霆科技/电动扳手/02设计/扳手扭矩模式.xlsx");
|
|
|
|
|
ui->lineEditBoltModeSettingsFilePath->setText("E:/MyWork/博霆科技/电动扳手/02设计/扳手螺栓模式.xlsx");
|
|
|
|
|
ui->lineEditAngleModeSettingsFilePath->setText("E:/MyWork/博霆科技/电动扳手/02设计/扳手角度模式.xlsx");
|
|
|
|
|
ui->lineEditGearPresetModeSettingsFilePath->setText("E:/MyWork/博霆科技/电动扳手/02设计/扳手档位模式.xlsx");
|
|
|
|
|
ui->lineEditSensorModeSettingsFilePath->setText("E:/MyWork/博霆科技/电动扳手/02设计/扳手传感器模式.xlsx");
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AdvanceSetupWidget::~AdvanceSetupWidget()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 初始化高级功能区域
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::init()
|
|
|
|
|
{
|
|
|
|
|
// 控件大小
|
|
|
|
|
int nLabelWidth = 150 * gZoomValue;
|
|
|
|
|
int nLabelHeight = gnDefaultLabelHeight * gZoomValue;
|
|
|
|
|
ui->labelTorqueModeSettings->setFixedSize(nLabelWidth, nLabelHeight);
|
|
|
|
|
ui->labelBoltModeSettings->setFixedSize(nLabelWidth, nLabelHeight);
|
|
|
|
|
ui->labelAngleModeSettings->setFixedSize(nLabelWidth, nLabelHeight);
|
|
|
|
|
ui->labelGearPresetModeSettings->setFixedSize(nLabelWidth, nLabelHeight);
|
|
|
|
|
ui->labelSensorModeSettings->setFixedSize(nLabelWidth, nLabelHeight);
|
|
|
|
|
ui->labelFallbackSettings->setFixedSize(nLabelWidth, nLabelHeight);
|
|
|
|
|
ui->labelFallbackAngle->setFixedSize(68 * gZoomValue, nLabelHeight);
|
|
|
|
|
ui->labelFallbackAnglecoefficient->setFixedSize(52 * gZoomValue, nLabelHeight);
|
|
|
|
|
ui->labelFallbackAnglecoefficient_2->setFixedSize(53 * gZoomValue, nLabelHeight);
|
|
|
|
|
ui->labelFallbackAngleUnit->setFixedSize(10 * gZoomValue, nLabelHeight);
|
|
|
|
|
//ui->labelFallbackAmpereUnit->setFixedSize(10 * gZoomValue, nLabelHeight);
|
|
|
|
|
ui->labelMenuInterfaceSettings->setFixedSize(nLabelWidth, nLabelHeight);
|
|
|
|
|
ui->labelToolsLockSettings->setFixedSize(nLabelWidth, nLabelHeight);
|
|
|
|
|
ui->labelUsageCount->setFixedSize(68 * gZoomValue, nLabelHeight);
|
|
|
|
|
ui->labelPassword->setFixedSize(50 * gZoomValue, nLabelHeight);
|
|
|
|
|
|
|
|
|
|
int nLineEditHeight = gnDefaultLineEditHeight * gZoomValue;
|
|
|
|
|
int nWidgetHeight = nLineEditHeight;
|
|
|
|
|
ui->widgetTorqueModeSettings->setFixedHeight(nWidgetHeight);
|
|
|
|
|
ui->widgetBoltModeSettings->setFixedHeight(nWidgetHeight);
|
|
|
|
|
ui->widgetAngleModeSettings->setFixedHeight(nWidgetHeight);
|
|
|
|
|
ui->widgetGearPresetModeSettings->setFixedHeight(nWidgetHeight);
|
|
|
|
|
ui->widgetSensorModeSettings->setFixedHeight(nWidgetHeight);
|
|
|
|
|
ui->widgetMenuInterfaceSettings->setFixedHeight(nWidgetHeight);
|
|
|
|
|
ui->widgetFallbackSettings->setFixedHeight(nWidgetHeight);
|
|
|
|
|
ui->widgetFallbackAngleSettings->setFixedHeight(nWidgetHeight);
|
|
|
|
|
ui->widgetFallbackAnglecoefficientSettings->setFixedHeight(nWidgetHeight);
|
|
|
|
|
ui->widgetToolsLockSettings->setFixedHeight(nWidgetHeight);
|
|
|
|
|
ui->widgetUsageCount->setFixedHeight(nWidgetHeight);
|
|
|
|
|
ui->widgetPassword->setFixedHeight(nWidgetHeight);
|
|
|
|
|
ui->lineEditTorqueModeSettingsFilePath->setFixedHeight(nLineEditHeight);
|
|
|
|
|
ui->lineEditBoltModeSettingsFilePath->setFixedHeight(nLineEditHeight);
|
|
|
|
|
ui->lineEditAngleModeSettingsFilePath->setFixedHeight(nLineEditHeight);
|
|
|
|
|
ui->lineEditGearPresetModeSettingsFilePath->setFixedHeight(nLineEditHeight);
|
|
|
|
|
ui->lineEditSensorModeSettingsFilePath->setFixedHeight(nLineEditHeight);
|
|
|
|
|
ui->lineEditMenuInterfaceSettingsFilePath->setFixedHeight(nLineEditHeight);
|
|
|
|
|
ui->lineEditFallbackAngle->setFixedHeight(nLineEditHeight);
|
|
|
|
|
ui->lineEditFallbackAnglecoefficient->setFixedHeight(nLineEditHeight);
|
|
|
|
|
ui->lineEditFallbackAnglecoefficient_2->setFixedHeight(nLineEditHeight);
|
|
|
|
|
ui->lineEditUsageCount->setFixedHeight(nLineEditHeight);
|
|
|
|
|
ui->lineEditPassword->setFixedHeight(nLineEditHeight);
|
|
|
|
|
|
|
|
|
|
int nPushButtonOpenFileWidth = nLineEditHeight;
|
|
|
|
|
int nPushButtonOpenFileHeight = nLineEditHeight;
|
|
|
|
|
ui->pushButtonTorqueModeSettingsOpenFile->setFixedSize(nPushButtonOpenFileWidth, nPushButtonOpenFileHeight);
|
|
|
|
|
ui->pushButtonBoltModeSettingsOpenFile->setFixedSize(nPushButtonOpenFileWidth, nPushButtonOpenFileHeight);
|
|
|
|
|
ui->pushButtonAngleModeSettingsOpenFile->setFixedSize(nPushButtonOpenFileWidth, nPushButtonOpenFileHeight);
|
|
|
|
|
ui->pushButtonGearPresetModeSettingsOpenFile->setFixedSize(nPushButtonOpenFileWidth, nPushButtonOpenFileHeight);
|
|
|
|
|
ui->pushButtonSensorModeSettingsOpenFile->setFixedSize(nPushButtonOpenFileWidth, nPushButtonOpenFileHeight);
|
|
|
|
|
ui->pushButtonMenuInterfaceSettingsOpenFile->setFixedSize(nPushButtonOpenFileWidth, nPushButtonOpenFileHeight);
|
|
|
|
|
|
|
|
|
|
int nPushButtonWidth = 100 * gZoomValue;
|
|
|
|
|
int nPushButtonHeight = gnDefaultPushButtonHeight * gZoomValue;
|
|
|
|
|
ui->pushButtonTorqueModeSettings->setFixedSize(nPushButtonWidth, nPushButtonHeight);
|
|
|
|
|
ui->pushButtonBoltModeSettings->setFixedSize(nPushButtonWidth, nPushButtonHeight);
|
|
|
|
|
ui->pushButtonAngleModeSettings->setFixedSize(nPushButtonWidth, nPushButtonHeight);
|
|
|
|
|
ui->pushButtonGearPresetModeSettings->setFixedSize(nPushButtonWidth, nPushButtonHeight);
|
|
|
|
|
ui->pushButtonSensorModeSettings->setFixedSize(nPushButtonWidth, nPushButtonHeight);
|
|
|
|
|
ui->pushButtonMenuInterfaceSettings->setFixedSize(nPushButtonWidth, nPushButtonHeight);
|
|
|
|
|
ui->pushButtonFallbackSettings->setFixedSize(nPushButtonWidth, nPushButtonHeight);
|
|
|
|
|
ui->pushButtonToolsLockSettings->setFixedSize(nPushButtonWidth, nPushButtonHeight);
|
|
|
|
|
|
|
|
|
|
// 控件字体
|
|
|
|
|
QString strStyleSheet = gstrStyleSheet.arg(gnFontSize * gZoomValue);
|
|
|
|
|
ui->lineEditTorqueModeSettingsFilePath->setStyleSheet(strStyleSheet);
|
|
|
|
|
ui->lineEditBoltModeSettingsFilePath->setStyleSheet(strStyleSheet);
|
|
|
|
|
ui->lineEditAngleModeSettingsFilePath->setStyleSheet(strStyleSheet);
|
|
|
|
|
ui->lineEditGearPresetModeSettingsFilePath->setStyleSheet(strStyleSheet);
|
|
|
|
|
ui->lineEditSensorModeSettingsFilePath->setStyleSheet(strStyleSheet);
|
|
|
|
|
ui->lineEditMenuInterfaceSettingsFilePath->setStyleSheet(strStyleSheet);
|
|
|
|
|
ui->lineEditFallbackAngle->setStyleSheet(strStyleSheet);
|
|
|
|
|
ui->lineEditFallbackAnglecoefficient->setStyleSheet(strStyleSheet);
|
|
|
|
|
ui->lineEditFallbackAnglecoefficient_2->setStyleSheet(strStyleSheet);
|
|
|
|
|
ui->lineEditUsageCount->setStyleSheet(strStyleSheet);
|
|
|
|
|
ui->lineEditPassword->setStyleSheet(strStyleSheet);
|
|
|
|
|
|
|
|
|
|
// 定义只能输入数字的正则表达式
|
|
|
|
|
QRegExp regx("[0-9]+$");
|
|
|
|
|
QValidator *validator = new QRegExpValidator(regx);
|
|
|
|
|
|
|
|
|
|
// 设置密码最多输入8位密码
|
|
|
|
|
ui->lineEditPassword->setMaxLength(8);
|
|
|
|
|
ui->lineEditPassword->setValidator(validator);
|
|
|
|
|
// 设置使用次数最多99999999
|
|
|
|
|
ui->lineEditUsageCount->setValidator(new QIntValidator(0, 99999999));
|
|
|
|
|
// // 回退角度:0-360度
|
|
|
|
|
// ui->lineEditFallbackAngle->setValidator(new QIntValidator(0, 999));
|
|
|
|
|
// // 回退电流:0.1-10A
|
|
|
|
|
// QDoubleValidator* v = new QDoubleValidator(0, 10, 1);
|
|
|
|
|
// v->setRange(0, 10);
|
|
|
|
|
// v->setNotation(QDoubleValidator::StandardNotation);
|
|
|
|
|
// ui->lineEditFallbackAmpere->setValidator(v);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 扭矩模式
|
|
|
|
|
connect(ui->pushButtonTorqueModeSettingsOpenFile, SIGNAL(clicked()), this, SLOT(slot_pushButtonTorqueModeSettingsOpenFile_clicked()));
|
|
|
|
|
connect(ui->pushButtonTorqueModeSettings, SIGNAL(clicked()), this, SLOT(slot_pushButtonTorqueModeSettings_clicked()));
|
|
|
|
|
// 螺栓模式
|
|
|
|
|
connect(ui->pushButtonBoltModeSettingsOpenFile, SIGNAL(clicked()), this, SLOT(slot_pushButtonBoltModeSettingsOpenFile_clicked()));
|
|
|
|
|
connect(ui->pushButtonBoltModeSettings, SIGNAL(clicked()), this, SLOT(slot_pushButtonBoltModeSettings_clicked()));
|
|
|
|
|
// 角度模式
|
|
|
|
|
connect(ui->pushButtonAngleModeSettingsOpenFile, SIGNAL(clicked()), this, SLOT(slot_pushButtonAngleModeSettingsOpenFile_clicked()));
|
|
|
|
|
connect(ui->pushButtonAngleModeSettings, SIGNAL(clicked()), this, SLOT(slot_pushButtonAngleModeSettings_clicked()));
|
|
|
|
|
// 档位预设模式
|
|
|
|
|
connect(ui->pushButtonGearPresetModeSettingsOpenFile, SIGNAL(clicked()), this, SLOT(slot_pushButtonGearPresetModeSettingsOpenFile_clicked()));
|
|
|
|
|
connect(ui->pushButtonGearPresetModeSettings, SIGNAL(clicked()), this, SLOT(slot_pushButtonGearPresetModeSettings_clicked()));
|
|
|
|
|
// 传感器模式
|
|
|
|
|
connect(ui->pushButtonSensorModeSettingsOpenFile, SIGNAL(clicked()), this, SLOT(slot_pushButtonSensorModeSettingsOpenFile_clicked()));
|
|
|
|
|
connect(ui->pushButtonSensorModeSettings, SIGNAL(clicked()), this, SLOT(slot_pushButtonSensorModeSettings_clicked()));
|
|
|
|
|
// 菜单界面设置
|
|
|
|
|
connect(ui->pushButtonMenuInterfaceSettingsOpenFile, SIGNAL(clicked()), this, SLOT(slot_pushButtonMenuInterfaceSettingsOpenFile_clicked()));
|
|
|
|
|
connect(ui->pushButtonMenuInterfaceSettings, SIGNAL(clicked()), this, SLOT(slot_pushButtonMenuInterfaceSettings_clicked()));
|
|
|
|
|
// 回退设置
|
|
|
|
|
connect(ui->pushButtonFallbackSettings, SIGNAL(clicked()), this, SLOT(slot_pushButtonFallbackSettings_clicked()));
|
|
|
|
|
// 工具锁定设置
|
|
|
|
|
connect(ui->pushButtonToolsLockSettings, SIGNAL(clicked()), this, SLOT(slot_pushButtonToolsLockSettings_clicked()));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 扭矩模式 -- 打开文件按钮点击事件
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::slot_pushButtonTorqueModeSettingsOpenFile_clicked()
|
|
|
|
|
{
|
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
|
|
|
this,
|
|
|
|
|
tr("打开文件(open a file)"),
|
|
|
|
|
"C:/",
|
|
|
|
|
tr("Excel files(*.xls *.xlsx);;text files(*.csv);;All files(*.*)"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->lineEditTorqueModeSettingsFilePath->setText(fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 扭矩模式 -- 确定按钮点击事件
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::slot_pushButtonTorqueModeSettings_clicked()
|
|
|
|
|
{
|
|
|
|
|
QString fileName = ui->lineEditTorqueModeSettingsFilePath->text();
|
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "Warning!", "请选择文件!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QFileInfo file(fileName);
|
|
|
|
|
if(file.exists()==false)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "Warning!", "文件不存在!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QXlsx::Document xlsx(fileName);
|
|
|
|
|
QXlsx::Workbook *workBook = xlsx.workbook();
|
|
|
|
|
QXlsx::Worksheet *workSheet = static_cast<QXlsx::Worksheet*>(workBook->sheet(0));
|
|
|
|
|
int nRows = workSheet->dimension().rowCount();
|
|
|
|
|
int nCols = workSheet->dimension().columnCount();
|
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("行数:%1, 列数:%2").arg(nRows).arg(nCols));
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
TorqueModeParam_t tParam;
|
|
|
|
|
|
|
|
|
|
// 从第二行开始,读取前两列,Excel索引从1开始
|
|
|
|
|
for(int i=2; i<=nRows; i++)
|
|
|
|
|
{
|
|
|
|
|
if(workSheet->cellAt(i, 1) == nullptr||workSheet->cellAt(i, 2) == nullptr||workSheet->cellAt(i, 3) == nullptr)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "Warning!", "文件格式错误!", QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string name = workSheet->cellAt(i, 1)->value().toString().toStdString();
|
|
|
|
|
int value = workSheet->cellAt(i, 2)->value().toString().toDouble() * 10000; // 扭矩系数值乘以10000后取整传递
|
|
|
|
|
|
|
|
|
|
unsigned short valueAmpere;
|
|
|
|
|
if(m_type == 4||m_type == 8)
|
|
|
|
|
valueAmpere = workSheet->cellAt(i, 3)->value().toString().toDouble(); //液压与气动扳手
|
|
|
|
|
else
|
|
|
|
|
valueAmpere = workSheet->cellAt(i, 3)->value().toString().toDouble() * 1000; // 电流值乘以1000后取整传递
|
|
|
|
|
|
|
|
|
|
if(name.length() > 0)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("Name:%1, Value:%2, ValueAmpere:%3")
|
|
|
|
|
.arg(workSheet->cellAt(i, 1)->value().toString())
|
|
|
|
|
.arg(workSheet->cellAt(i, 2)->value().toString())
|
|
|
|
|
.arg(workSheet->cellAt(i, 3)->value().toString()));
|
|
|
|
|
#endif
|
|
|
|
|
//param.datas.insert(std::make_pair(name, value)); // std::map
|
|
|
|
|
TorqueModeParam param(name, value, valueAmpere);
|
|
|
|
|
tParam.datas.push_back(param);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置参数
|
|
|
|
|
#if 0
|
|
|
|
|
TorqueModeStructData *data = new TorqueModeStructData(&tParam);
|
|
|
|
|
#else
|
|
|
|
|
TorqueModeStructData *data = new TorqueModeStructData();
|
|
|
|
|
data->setData(tParam);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// 设置参数数据可能会比较多。按照1条数据100毫秒来设置接收数据超时时间
|
|
|
|
|
// 超时时间范围为1秒至30秒
|
|
|
|
|
int msec = 100 * tParam.datas.size();
|
|
|
|
|
msec = msec > 1000 ? msec : 1000;
|
|
|
|
|
msec = msec < 30000 ? msec : 30000;
|
|
|
|
|
SetupService::GetInstance()->SendData(FRAME_CMD_SET_PARAM_TORQUE, data->toByteStr(), msec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 螺栓模式 -- 打开文件按钮点击事件
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::slot_pushButtonBoltModeSettingsOpenFile_clicked()
|
|
|
|
|
{
|
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
|
|
|
this,
|
|
|
|
|
tr("打开文件(open a file)"),
|
|
|
|
|
"C:/",
|
|
|
|
|
tr("Excel files(*.xls *.xlsx);;text files(*.csv);;All files(*.*)"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->lineEditBoltModeSettingsFilePath->setText(fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 螺栓模式 -- 确定按钮点击事件
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::slot_pushButtonBoltModeSettings_clicked()
|
|
|
|
|
{
|
|
|
|
|
QString fileName = ui->lineEditBoltModeSettingsFilePath->text();
|
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "Warning!", "请选择文件!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QFileInfo file(fileName);
|
|
|
|
|
if(file.exists()==false)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "Warning!", "文件不存在!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QXlsx::Document xlsx(fileName);
|
|
|
|
|
QXlsx::Workbook *workBook = xlsx.workbook();
|
|
|
|
|
|
|
|
|
|
BoltModeParam_t *param = new BoltModeParam_t();
|
|
|
|
|
|
|
|
|
|
// 默认第一个sheet为公制,第二个sheet为英制
|
|
|
|
|
for(int fmtIndex=0; fmtIndex<2; fmtIndex++)
|
|
|
|
|
{
|
|
|
|
|
QXlsx::Worksheet *workSheet = static_cast<QXlsx::Worksheet*>(workBook->sheet(fmtIndex));
|
|
|
|
|
int nRows = workSheet->dimension().rowCount();
|
|
|
|
|
int nCols = workSheet->dimension().columnCount();
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("行数:%1, 列数:%2").arg(nRows).arg(nCols));
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// 读取扳手名称
|
|
|
|
|
if(workSheet->cellAt(5, 1) == nullptr||workSheet->cellAt(1, 3) == nullptr)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "Warning!", "文件格式错误!", QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
|
delete param;
|
|
|
|
|
param = nullptr;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
param->name = workSheet->cellAt(5, 1)->value().toString().toStdString();
|
|
|
|
|
// 制式
|
|
|
|
|
QString strFormat = workSheet->cellAt(1, 3)->value().toString();
|
|
|
|
|
if(workSheet->cellAt(1, 3) == nullptr)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "Warning!", "文件格式错误!", QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
|
delete param;
|
|
|
|
|
param = nullptr;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//param->format = (format->dynamicCall("Value").toString().compare("公制") == 0) ? 0 : 1;
|
|
|
|
|
unsigned char format = (strFormat.compare("公制") == 0) ? 0 : 1;
|
|
|
|
|
//QMessageBox::warning(this, "Warning!", strFormat, QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
|
|
|
|
|
|
// 判断直径数量
|
|
|
|
|
unsigned char diameterCount = 0;
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
// if(5 + diameterCount >= nRows)
|
|
|
|
|
// {
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
if(workSheet->cellAt(5 + diameterCount, 3) == nullptr)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
QString strDiameter = workSheet->cellAt(5 + diameterCount, 3)->value().toString();
|
|
|
|
|
if(strDiameter.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
std::string strDiameter1 = strDiameter. toStdString();
|
|
|
|
|
if(format == 1)
|
|
|
|
|
{
|
|
|
|
|
strDiameter1 = BsBoltDiameterToStr(strDiameter).toStdString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
param->format[fmtIndex].diameterList.push_back(strDiameter1);
|
|
|
|
|
diameterCount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 判断强度等级数量
|
|
|
|
|
unsigned char typeCount = 0;
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
// if(4 + 2 * typeCount >= nCols)
|
|
|
|
|
// {
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
if(workSheet->cellAt(2, 4 + 2 * typeCount) == nullptr)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
QString strType = workSheet->cellAt(2, 4 + 2 * typeCount)->value().toString();
|
|
|
|
|
if(strType.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
param->format[fmtIndex].typeList.push_back(strType.remove(QRegExp("\\s")).toStdString()); // 去除其中空格
|
|
|
|
|
typeCount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 扭矩
|
|
|
|
|
for(int j=0; j<typeCount; j++)
|
|
|
|
|
{
|
|
|
|
|
for(int i=0; i<diameterCount; i++)
|
|
|
|
|
{
|
|
|
|
|
// 取N.m
|
|
|
|
|
param->format[fmtIndex].torqueList.push_back(workSheet->cellAt(5+i, 4 + 2 * j + 1)->value().toInt());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////
|
|
|
|
|
// 测试打印
|
|
|
|
|
// QString str;
|
|
|
|
|
// for(int i=0; i<2; i++)
|
|
|
|
|
// {
|
|
|
|
|
// str.append(tr("name : %1\n").arg(QString::fromStdString(param->name)));
|
|
|
|
|
// //str.append(tr("format : %1\n").arg(param->format));
|
|
|
|
|
// str.append(tr("format : %1\n").arg(i));
|
|
|
|
|
|
|
|
|
|
// str.append(tr("diameterCount : %1\n").arg(param->format[i].diameterList.size()));
|
|
|
|
|
// std::list<std::string>::iterator diameterIter = param->format[i].diameterList.begin();
|
|
|
|
|
// while(diameterIter != param->format[i].diameterList.end())
|
|
|
|
|
// {
|
|
|
|
|
// str.append(tr("%1,").arg(QString::fromStdString(*diameterIter)));
|
|
|
|
|
// diameterIter++;
|
|
|
|
|
// }
|
|
|
|
|
// str.append(tr("\n"));
|
|
|
|
|
|
|
|
|
|
// str.append(tr("typeCount : %1\n").arg(param->format[i].typeList.size()));
|
|
|
|
|
// std::list<std::string>::iterator typeIter = param->format[i].typeList.begin();
|
|
|
|
|
// while(typeIter != param->format[i].typeList.end())
|
|
|
|
|
// {
|
|
|
|
|
// str.append(tr("%1,").arg(QString::fromStdString(*typeIter)));
|
|
|
|
|
// typeIter++;
|
|
|
|
|
// }
|
|
|
|
|
// str.append(tr("\n"));
|
|
|
|
|
|
|
|
|
|
// std::list<int>::iterator torqueIter = param->format[i].torqueList.begin();
|
|
|
|
|
// while(torqueIter != param->format[i].torqueList.end())
|
|
|
|
|
// {
|
|
|
|
|
// str.append(tr("%1,").arg(*torqueIter));
|
|
|
|
|
// torqueIter++;
|
|
|
|
|
// }
|
|
|
|
|
// str.append(tr("\n"));
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// QMessageBox::warning(this, "Warning!", str, QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
BoltModeStructData *data = new BoltModeStructData();
|
|
|
|
|
data->setData(param);
|
|
|
|
|
|
|
|
|
|
// 超时时间设置为5秒
|
|
|
|
|
SetupService::GetInstance()->SendData(FRAME_CMD_SET_PARAM_BOLT, data, 5000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 角度模式
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::slot_pushButtonAngleModeSettingsOpenFile_clicked()
|
|
|
|
|
{
|
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
|
|
|
this,
|
|
|
|
|
tr("打开文件(open a file)"),
|
|
|
|
|
"C:/",
|
|
|
|
|
tr("Excel files(*.xls *.xlsx);;text files(*.csv);;All files(*.*)"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->lineEditAngleModeSettingsFilePath->setText(fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 角度模式
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::slot_pushButtonAngleModeSettings_clicked()
|
|
|
|
|
{
|
|
|
|
|
QString fileName = ui->lineEditAngleModeSettingsFilePath->text();
|
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "Warning!", "请选择文件!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QFileInfo file(fileName);
|
|
|
|
|
if(file.exists()==false)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "Warning!", "文件不存在!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QXlsx::Document xlsx(fileName);
|
|
|
|
|
QXlsx::Workbook *workBook = xlsx.workbook();
|
|
|
|
|
QXlsx::Worksheet *workSheet = static_cast<QXlsx::Worksheet*>(workBook->sheet(0));
|
|
|
|
|
int nRows = workSheet->dimension().rowCount();
|
|
|
|
|
int nCols = workSheet->dimension().columnCount();
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("行数:%1, 列数:%2").arg(nRows).arg(nCols));
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if(workSheet->cellAt(2, 1) == nullptr)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "Warning!", "文件格式错误!", QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
|
logInfo("文件格式错误!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
std::list<short> param;
|
|
|
|
|
param.push_back( workSheet->cellAt(2, 1)->value().toInt());
|
|
|
|
|
|
|
|
|
|
if(workSheet->cellAt(3, 1) != nullptr)
|
|
|
|
|
{
|
|
|
|
|
param.push_back( workSheet->cellAt(3, 1)->value().toInt());
|
|
|
|
|
}
|
|
|
|
|
/////////
|
|
|
|
|
// 测试打印
|
|
|
|
|
// QString str;
|
|
|
|
|
// str.append(tr("angle : %1\n").arg(param));
|
|
|
|
|
// QMessageBox::warning(this, "Warning!", str, QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
AngleModeStructData *data = new AngleModeStructData();
|
|
|
|
|
data->setData(param);
|
|
|
|
|
|
|
|
|
|
// 超时时间设置为1秒
|
|
|
|
|
SetupService::GetInstance()->SendData(FRAME_CMD_SET_PARAM_ANGLE, data->toByteStr(), 2000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 档位模式
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::slot_pushButtonGearPresetModeSettingsOpenFile_clicked()
|
|
|
|
|
{
|
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
|
|
|
this,
|
|
|
|
|
tr("打开文件(open a file)"),
|
|
|
|
|
"C:/",
|
|
|
|
|
tr("Excel files(*.xls *.xlsx);;text files(*.csv);;All files(*.*)"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->lineEditGearPresetModeSettingsFilePath->setText(fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 档位预设模式确认按钮点击
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::slot_pushButtonGearPresetModeSettings_clicked()
|
|
|
|
|
{
|
|
|
|
|
QString fileName = ui->lineEditGearPresetModeSettingsFilePath->text();
|
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "Warning!", "请选择文件!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QFileInfo file(fileName);
|
|
|
|
|
if(file.exists()==false)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "Warning!", "文件不存在!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QXlsx::Document xlsx(fileName);
|
|
|
|
|
QXlsx::Workbook *workBook = xlsx.workbook();
|
|
|
|
|
QXlsx::Worksheet *workSheet = static_cast<QXlsx::Worksheet*>(workBook->sheet(0));
|
|
|
|
|
int nRows = workSheet->dimension().rowCount();
|
|
|
|
|
int nCols = workSheet->dimension().columnCount();
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("行数:%1, 列数:%2").arg(nRows).arg(nCols));
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
GearModeParam_t *param = new GearModeParam_t();
|
|
|
|
|
|
|
|
|
|
int nLevelIndex = 0;
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
if(workSheet->cellAt(2 + nLevelIndex, 1) == nullptr || workSheet->cellAt(2 + nLevelIndex, 2) == nullptr)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString strLevel = workSheet->cellAt(2 + nLevelIndex, 1)->value().toString();
|
|
|
|
|
QString strValue = workSheet->cellAt(2 + nLevelIndex, 2)->value().toString();
|
|
|
|
|
if(strLevel.isEmpty() || strValue.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
unsigned int nLevel = (unsigned char)strLevel.toUInt();
|
|
|
|
|
if(nLevel > 255)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "Warning!", tr("数据错误!"), QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
|
delete param;
|
|
|
|
|
param = nullptr;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
unsigned int nValue = strValue.toDouble() * 10000; // 档位值需乘以10000
|
|
|
|
|
|
|
|
|
|
GearModeParam gearModeParam((unsigned char)nLevel, nValue);
|
|
|
|
|
|
|
|
|
|
param->datas.push_back(gearModeParam);
|
|
|
|
|
|
|
|
|
|
if(m_currType != 2 && workSheet->cellAt(2 + nLevelIndex, 3) != nullptr) //m_currType = 2是充电扳手 23.8.30
|
|
|
|
|
{
|
|
|
|
|
QString strValue1;
|
|
|
|
|
unsigned int nValue1 = 0;
|
|
|
|
|
strValue1 = workSheet->cellAt(2 + nLevelIndex, 3)->value().toString();
|
|
|
|
|
nValue1=strValue1.toDouble()*10000;
|
|
|
|
|
GearModeParam gearModeParam1((unsigned char)nLevel, nValue1);
|
|
|
|
|
param->datas.push_back(gearModeParam1);
|
|
|
|
|
}
|
|
|
|
|
nLevelIndex++;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GearModeStructData *data = new GearModeStructData(param);
|
|
|
|
|
|
|
|
|
|
// 超时时间设置为2秒
|
|
|
|
|
SetupService::GetInstance()->SendData(FRAME_CMD_SET_PARAM_GEAR, data, 2000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 传感器模式打开文件按钮点击
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::slot_pushButtonSensorModeSettingsOpenFile_clicked()
|
|
|
|
|
{
|
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
|
|
|
this,
|
|
|
|
|
tr("打开文件(open a file)"),
|
|
|
|
|
"C:/",
|
|
|
|
|
tr("Excel files(*.xls *.xlsx);;text files(*.csv);;All files(*.*)"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->lineEditSensorModeSettingsFilePath->setText(fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 传感器模式确认按钮点击
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::slot_pushButtonSensorModeSettings_clicked()
|
|
|
|
|
{
|
|
|
|
|
QString fileName = ui->lineEditSensorModeSettingsFilePath->text();
|
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "Warning!", "请选择文件!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QFileInfo file(fileName);
|
|
|
|
|
if(file.exists()==false)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "Warning!", "文件不存在!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QXlsx::Document xlsx(fileName);
|
|
|
|
|
QXlsx::Workbook *workBook = xlsx.workbook();
|
|
|
|
|
QXlsx::Worksheet *workSheet = static_cast<QXlsx::Worksheet*>(workBook->sheet(0));
|
|
|
|
|
int nRows = workSheet->dimension().rowCount();
|
|
|
|
|
int nCols = workSheet->dimension().columnCount();
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("行数:%1, 列数:%2").arg(nRows).arg(nCols));
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
SensorModeParam_t tParam;
|
|
|
|
|
|
|
|
|
|
// 从第二行开始,读取前两列,Excel索引从1开始
|
|
|
|
|
for(int i=2; i<=nRows; i++)
|
|
|
|
|
{
|
|
|
|
|
if(workSheet->cellAt(i, 1) == nullptr || workSheet->cellAt(i, 2) == nullptr)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this, "Warning!", "文件格式错误!", QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QString strName = workSheet->cellAt(i, 1)->value().toString();
|
|
|
|
|
QString strValue = workSheet->cellAt(i, 2)->value().toString();
|
|
|
|
|
|
|
|
|
|
std::string name = strName.toStdString();
|
|
|
|
|
int value = strValue.toInt();
|
|
|
|
|
if(name.length() > 0)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("%1:%2")
|
|
|
|
|
.arg(strName)
|
|
|
|
|
.arg(strValue));
|
|
|
|
|
#endif
|
|
|
|
|
//param.datas.insert(std::make_pair(name, value)); // std::map
|
|
|
|
|
SensorModeParam param(name, value);
|
|
|
|
|
tParam.datas.push_back(param);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置参数
|
|
|
|
|
SensorModeStructData *data = new SensorModeStructData();
|
|
|
|
|
data->setData(tParam);
|
|
|
|
|
|
|
|
|
|
// 超时时间范围为2秒
|
|
|
|
|
SetupService::GetInstance()->SendData(FRAME_CMD_SET_PARAM_SENSOR, data, 2000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::slot_pushButtonMenuInterfaceSettingsOpenFile_clicked()
|
|
|
|
|
{
|
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
|
|
|
this,
|
|
|
|
|
tr("打开文件(open a file)"),
|
|
|
|
|
"C:/",
|
|
|
|
|
tr("Excel files(*.xls *.xlsx);;text files(*.csv);;All files(*.*)"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->lineEditMenuInterfaceSettingsFilePath->setText(fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::slot_pushButtonMenuInterfaceSettings_clicked()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::slot_pushButtonFallbackSettings_clicked()
|
|
|
|
|
{
|
|
|
|
|
FallbackParam_t tParam;
|
|
|
|
|
|
|
|
|
|
tParam.angle = ui->lineEditFallbackAngle->text().toUShort();
|
|
|
|
|
tParam.ampere = (unsigned int)(ui->lineEditFallbackAnglecoefficient->text().toDouble()*100);
|
|
|
|
|
tParam.ampere2 = (unsigned int)(ui->lineEditFallbackAnglecoefficient_2->text().toDouble()*100);
|
|
|
|
|
|
|
|
|
|
// 设置参数
|
|
|
|
|
FallbackStructData *data = new FallbackStructData();
|
|
|
|
|
data->setData(tParam);
|
|
|
|
|
|
|
|
|
|
// 超时时间范围为1秒
|
|
|
|
|
SetupService::GetInstance()->SendData(FRAME_CMD_SET_PARAM_FALLBACK, data, 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 等待空闲
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::waitForIdle()
|
|
|
|
|
{
|
|
|
|
|
while(SetupService::GetInstance()->currStatus() == SYS_STATUS_BUSY)
|
|
|
|
|
{
|
|
|
|
|
Utils::Sleep(10);
|
|
|
|
|
}//{QThread::msleep(5); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 工具锁定设置确定按钮,包含三个指令:1. 使用次数设置、密码设置、工具锁定设置
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::slot_pushButtonToolsLockSettings_clicked()
|
|
|
|
|
{
|
|
|
|
|
logInfo(tr("请求设置使用次数..."));
|
|
|
|
|
SetupService::GetInstance()->SendData(FRAME_CMD_SET_USAGE_COUNT, Utils::intToByteStr(ui->lineEditUsageCount->text().toInt()));
|
|
|
|
|
|
|
|
|
|
waitForIdle();
|
|
|
|
|
|
|
|
|
|
logInfo(tr("请求设置密码..."));
|
|
|
|
|
SetupService::GetInstance()->SendData(FRAME_CMD_SET_PASSWORD, ui->lineEditPassword->text().toStdString());
|
|
|
|
|
|
|
|
|
|
waitForIdle();
|
|
|
|
|
|
|
|
|
|
logInfo(tr("请求设置锁定..."));
|
|
|
|
|
char c[2] = {0};
|
|
|
|
|
c[0] = 0x01; // 0x00 解锁,0x01加锁
|
|
|
|
|
c[1] = '\0';
|
|
|
|
|
std::string s;
|
|
|
|
|
s.append(c, 1);
|
|
|
|
|
// 锁定不需要密码,本地也没有保存密码
|
|
|
|
|
//s.append(ui->lineEditToolsUnlock->text().toStdString());
|
|
|
|
|
SetupService::GetInstance()->SendData(FRAME_CMD_SET_LOCK_STATUS, s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::slot_recvData(QString portName, unsigned char cmd, QByteArray recvData)
|
|
|
|
|
{
|
|
|
|
|
//QMessageBox::warning(this, "Warning!", "AdvanceSetupWidget::slot_recvData", QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logInfo(tr("PORT:%1 >> Recv Data: CMD=[%2]%3").arg(portName).arg(cmd).arg(QString::fromStdString(getCmdName(cmd))));
|
|
|
|
|
#else
|
|
|
|
|
logInfo(tr("PORT:%1 >> Recv Data: CMD=%2").arg(portName).arg(QString::fromStdString(getCmdName(cmd))));
|
|
|
|
|
#endif
|
|
|
|
|
switch(cmd)
|
|
|
|
|
{
|
|
|
|
|
case FRAME_CMD_SET_LOCK_STATUS : processSetLockStatusRsp(portName, recvData); break;
|
|
|
|
|
case FRAME_CMD_SET_PASSWORD : processSetPasswordRsp(portName, recvData); break;
|
|
|
|
|
case FRAME_CMD_SET_USAGE_COUNT : processSetUsageCountRsp(portName, recvData); break;
|
|
|
|
|
case FRAME_CMD_SET_PARAM_FALLBACK: processSetParamFallbackRsp(portName, recvData); break;
|
|
|
|
|
case FRAME_CMD_SET_PARAM_TORQUE : processSetParamTorqueRsp(portName, recvData); break;
|
|
|
|
|
case FRAME_CMD_SET_PARAM_BOLT : processSetParamBoltRsp(portName, recvData); break;
|
|
|
|
|
case FRAME_CMD_SET_PARAM_ANGLE : processSetParamAngleRsp(portName, recvData); break;
|
|
|
|
|
case FRAME_CMD_SET_PARAM_GEAR : processSetParamGearRsp(portName, recvData); break;
|
|
|
|
|
case FRAME_CMD_SET_PARAM_SENSOR : processSetParamSensorRsp(portName, recvData); break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
logInfo(tr("PORT:%1 >> Unsupported CMD Of Advance Setup[%2]!").arg(portName).arg(cmd));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 设置密码响应
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::processSetPasswordRsp(QString portName, QByteArray data)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("PORT:%1 >> SET PASSWORD SUCCESS[%2]").arg(portName).arg(Utils::strToHexStr(data.toStdString()).c_str()));
|
|
|
|
|
#else
|
|
|
|
|
logInfo(tr("PORT:%1 >> SET PASSWORD SUCCESS").arg(portName));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 设置使用次数响应
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::processSetUsageCountRsp(QString portName, QByteArray data)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("PORT:%1 >> SET USAGE COUNT SUCCESS[%2]").arg(portName).arg(Utils::strToHexStr(data.toStdString()).c_str()));
|
|
|
|
|
#else
|
|
|
|
|
logInfo(tr("PORT:%1 >> SET USAGE COUNT SUCCESS").arg(portName));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 设置参数响应
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::processSetParamRsp(QString portName, QByteArray data)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("PORT:%1 >> SET PARAM SUCCESS[%2]").arg(portName).arg(Utils::strToHexStr(data.toStdString()).c_str()));
|
|
|
|
|
#else
|
|
|
|
|
logInfo(tr("PORT:%1 >> SET PARAM SUCCESS").arg(portName));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::processSetParamTorqueRsp(QString portName, QByteArray data)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("PORT:%1 >> SET PARAM TORQUE SUCCESS[%2]").arg(portName).arg(Utils::strToHexStr(data.toStdString()).c_str()));
|
|
|
|
|
#else
|
|
|
|
|
logInfo(tr("PORT:%1 >> SET PARAM TORQUE SUCCESS").arg(portName));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::processSetParamBoltRsp(QString portName, QByteArray data)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("PORT:%1 >> SET PARAM BOLT SUCCESS[%2]").arg(portName).arg(Utils::strToHexStr(data.toStdString()).c_str()));
|
|
|
|
|
#else
|
|
|
|
|
logInfo(tr("PORT:%1 >> SET PARAM BOLT SUCCESS").arg(portName));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::processSetParamAngleRsp(QString portName, QByteArray data)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("PORT:%1 >> SET PARAM ANGLE SUCCESS[%2]").arg(portName).arg(Utils::strToHexStr(data.toStdString()).c_str()));
|
|
|
|
|
#else
|
|
|
|
|
logInfo(tr("PORT:%1 >> SET PARAM ANGLE SUCCESS").arg(portName));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::processSetParamGearRsp(QString portName, QByteArray data)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("PORT:%1 >> SET PARAM GEAR SUCCESS[%2]").arg(portName).arg(Utils::strToHexStr(data.toStdString()).c_str()));
|
|
|
|
|
#else
|
|
|
|
|
logInfo(tr("PORT:%1 >> SET PARAM GEAR SUCCESS").arg(portName));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::processSetParamSensorRsp(QString portName, QByteArray data)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("PORT:%1 >> SET PARAM SENSOR SUCCESS[%2]").arg(portName).arg(Utils::strToHexStr(data.toStdString()).c_str()));
|
|
|
|
|
#else
|
|
|
|
|
logInfo(tr("PORT:%1 >> SET PARAM SENSOR SUCCESS").arg(portName));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::processSetParamFallbackRsp(QString portName, QByteArray data)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("PORT:%1 >> SET PARAM FALLBACK SUCCESS[%2]").arg(portName).arg(Utils::strToHexStr(data.toStdString()).c_str()));
|
|
|
|
|
#else
|
|
|
|
|
logInfo(tr("PORT:%1 >> SET PARAM FALLBACK SUCCESS").arg(portName));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 设置锁状态响应
|
|
|
|
|
//
|
|
|
|
|
void AdvanceSetupWidget::processSetLockStatusRsp(QString portName, QByteArray data)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
logDebug(tr("PORT:%1 >> SET LOCK STATUS SUCCESS[%2]").arg(portName).arg(Utils::strToHexStr(data.toStdString()).c_str()));
|
|
|
|
|
#else
|
|
|
|
|
logInfo(tr("PORT:%1 >> SET LOCK STATUS SUCCESS").arg(portName));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::showTypeDefault()
|
|
|
|
|
{
|
|
|
|
|
ui->labelMenuInterfaceSettings->show();
|
|
|
|
|
ui->widgetMenuInterfaceSettings->show();
|
|
|
|
|
ui->pushButtonMenuInterfaceSettings->show();
|
|
|
|
|
|
|
|
|
|
ui->labelFallbackSettings->hide();
|
|
|
|
|
ui->widgetFallbackSettings->hide();
|
|
|
|
|
ui->pushButtonFallbackSettings->hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::showType1()
|
|
|
|
|
{
|
|
|
|
|
ui->labelMenuInterfaceSettings->hide();
|
|
|
|
|
ui->widgetMenuInterfaceSettings->hide();
|
|
|
|
|
ui->pushButtonMenuInterfaceSettings->hide();
|
|
|
|
|
|
|
|
|
|
ui->labelFallbackSettings->show();
|
|
|
|
|
ui->widgetFallbackSettings->show();
|
|
|
|
|
ui->pushButtonFallbackSettings->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::showType2()
|
|
|
|
|
{
|
|
|
|
|
ui->labelMenuInterfaceSettings->hide();
|
|
|
|
|
ui->widgetMenuInterfaceSettings->hide();
|
|
|
|
|
ui->pushButtonMenuInterfaceSettings->hide();
|
|
|
|
|
|
|
|
|
|
ui->labelFallbackSettings->show();
|
|
|
|
|
ui->widgetFallbackSettings->show();
|
|
|
|
|
ui->pushButtonFallbackSettings->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::showType4()
|
|
|
|
|
{
|
|
|
|
|
showTypeDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::showType8()
|
|
|
|
|
{
|
|
|
|
|
showTypeDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::setType(int type)
|
|
|
|
|
{
|
|
|
|
|
if(type == 1)
|
|
|
|
|
{
|
|
|
|
|
showType1();
|
|
|
|
|
}
|
|
|
|
|
else if(type == 2)
|
|
|
|
|
{
|
|
|
|
|
showType2();
|
|
|
|
|
}
|
|
|
|
|
else if(type == 4)
|
|
|
|
|
{
|
|
|
|
|
showType4();
|
|
|
|
|
}
|
|
|
|
|
else if(type == 8)
|
|
|
|
|
{
|
|
|
|
|
showType8();
|
|
|
|
|
}
|
|
|
|
|
m_type = type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::on_lineEditFallbackAngle_textChanged(const QString &arg1)
|
|
|
|
|
{
|
|
|
|
|
if(arg1.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
m_fallbackAngle = "";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(arg1.contains(QRegExp("^\\d+$"))) // 纯数字
|
|
|
|
|
{
|
|
|
|
|
if(arg1.toInt() >= 0 && arg1.toInt() <= 360)
|
|
|
|
|
{
|
|
|
|
|
if(arg1.length() > 1 && arg1.at(0).toLatin1() == '0')
|
|
|
|
|
{
|
|
|
|
|
m_fallbackAngle = arg1.right(arg1.length() - 1);
|
|
|
|
|
ui->lineEditFallbackAngle->setText(m_fallbackAngle);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_fallbackAngle = arg1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ui->lineEditFallbackAngle->setText(m_fallbackAngle); // 恢复原样
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ui->lineEditFallbackAngle->setText(m_fallbackAngle); // 恢复原样
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::on_lineEditFallbackAnglecoefficient_textChanged(const QString &arg1)
|
|
|
|
|
{
|
|
|
|
|
if(arg1.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
m_fallbackAmpere = "";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//if(arg1.contains(QRegExp("^(0?[0-9]|1[0-9])(\.([0-9]{1})?)?$")))
|
|
|
|
|
//if(arg1.contains(QRegExp("^(0?[0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9][0-9][0-9]|1[0-9][0-9][0-9][0-9])(\.([0-9]{1})?)?$")))
|
|
|
|
|
if(arg1.contains(QRegExp("^(0?[0-9]{1,4}|1[0-9][0-9][0-9][0-9])(\.([0-9]{0,2})?)?$")))
|
|
|
|
|
{
|
|
|
|
|
if(arg1.toDouble() >= 0.0 && arg1.toDouble() <= 10000.0)
|
|
|
|
|
{
|
|
|
|
|
m_fallbackAmpere = arg1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ui->lineEditFallbackAnglecoefficient->setText(m_fallbackAmpere); // 恢复原样
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ui->lineEditFallbackAnglecoefficient->setText(m_fallbackAmpere); // 恢复原样
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AdvanceSetupWidget::on_lineEditFallbackAnglecoefficient_2_textChanged(const QString &arg1)
|
|
|
|
|
{
|
|
|
|
|
if(arg1.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
m_fallbackAmpere_2 = "";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//if(arg1.contains(QRegExp("^(0?[0-9]|1[0-9])(\.([0-9]{1})?)?$")))
|
|
|
|
|
//if(arg1.contains(QRegExp("^(0?[0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9][0-9][0-9]|1[0-9][0-9][0-9][0-9])(\.([0-9]{1})?)?$")))
|
|
|
|
|
if(arg1.contains(QRegExp("^(0?[0-9]{1,4}|1[0-9][0-9][0-9][0-9])(\.([0-9]{0,2})?)?$")))
|
|
|
|
|
{
|
|
|
|
|
if(arg1.toDouble() >= 0.0 && arg1.toDouble() <= 10000.0)
|
|
|
|
|
{
|
|
|
|
|
m_fallbackAmpere_2 = arg1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ui->lineEditFallbackAnglecoefficient_2->setText(m_fallbackAmpere_2); // 恢复原样
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ui->lineEditFallbackAnglecoefficient_2->setText(m_fallbackAmpere_2); // 恢复原样
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|