hlp:桂林国际齿轮泵代码

This commit is contained in:
kite_lucs
2026-10-09 10:25:24 +08:00
commit fd606b3c81
2447 changed files with 999531 additions and 0 deletions
@@ -0,0 +1,274 @@
#include "OtherInfo.h"
#include "ui_otherinfo.h"
#include <QMessageBox>
#include <QDebug>
#include <QDateTime>
//#define FOR_ADJUST 0
#define FOR_PHASE_ADJUST 1
OtherInfo::OtherInfo(QWidget *parent) :
QWidget(parent),
ui(new Ui::OtherInfo)
{
ui->setupUi(this);
lockPhaseFlag = false;
lockedPhase = 0;
ui->memDisplayAndEdit->setHidden(1);
ui->lab_enableChargeFullTime->setHidden(1);
ui->lab_phaseDetectDelay->setHidden(1);
ui->lab_phaseDetectVol->setHidden(1);
ui->lab_phaseHighLowRatio->setHidden(1);
ui->lab_phase_detect_pulse_num->setHidden(1);
ui->checkBoxChargeFullTime->setHidden(1);
//ui->memDisplayAndEdit->setHidden(1);
ui->pushButtonLockPhase->setHidden(1);
//ui->spinBoxLockedPhase->setHidden(1);
//ui->spinBoxPhaseDetectVoltage->setEnabled(1);
#ifndef FOR_PHASE_ADJUST
ui->lab_phaseDetectVol->setHidden(1);
ui->spinBoxPhaseDetectVoltage->setHidden(1);
ui->spinBoxPhaseDetectVoltage->setEnabled(1);
//ui->spinBoxPhaseGroupValue->setHidden(1);
//ui->labelPhaseGroups->setHidden(1);
//ui->lab_phase_detect_pulse_num->setHidden(1);
ui->labelPhaseDetectNum->setHidden(1);
ui->spinBoxPhaseDetectDotNum->setHidden(1);
//ui->lab_phaseDetectDelay->setHidden(1);
ui->labelPhaseDetectDelay->setHidden(1);
ui->spinBoxPhaseDetectDelay->setHidden(1);
#else
#endif
}
OtherInfo::~OtherInfo()
{
delete ui;
}
void OtherInfo::OtherupdateSysParaToUI(){
updateSysParaToUI();
}
#define PHASE_BY_HAND_DIV 8 //相位会在逻辑里面放大
void OtherInfo::bindSysPara(SysPara *sysPara){
this->sysPara = sysPara;
ui->phaseGraphic->bindSysPara(sysPara);
ui->memDisplayAndEdit->bindSysPara(sysPara);
lockPhaseFlag = sysPara->para.phaseByHand != 0;
updateLockPhaseWidgets();
}
void OtherInfo::updateSysParaToUI(){
if(sysPara){
ui->spinBoxHighLowRatio->setValue(sysPara->para.phaseHighLowRatio);
ui->spinBoxPhaseDetectDotNum->setValue(sysPara->para.phase_detect_pulse_num);
ui->spinBoxPhaseDetectVoltage->setValue(sysPara->para.phaseDetectVol);
ui->spinBoxPhaseDetectDelay->setValue(sysPara->para.phaseDetectDelay);
ui->spinBoxPhaseShift->setValue(sysPara->para.phaseShift);
ui->spinBoxBlickLightPeriod->setValue(sysPara->para.blinkLightPeriod);
ui->checkBoxChargeFullTime->setChecked(sysPara->para.enableChargeFullTime);
}
}
void OtherInfo::onAuthChanged(int auth){
//ui->memDisplayAndEdit->setShown(auth & AUTH_SUPER_USER2);
//ui->pushButtonLockPhase->setEnabled(auth & AUTH_SUPER_USER2);
//ui->pushButtonLockPhase->setShown(auth & AUTH_SUPER_USER2);
//ui->spinBoxLockedPhase->setShown(auth & AUTH_SUPER_USER2);
//ui->lab_enableChargeFullTime->setShown(auth & AUTH_SUPER_USER2);
//ui->lab_phaseDetectDelay->setShown(auth & AUTH_SUPER_USER2);
//ui->lab_phaseDetectVol->setShown(auth & AUTH_SUPER_USER2);
//ui->lab_phaseHighLowRatio->setShown(auth & AUTH_SUPER_USER2);
//ui->lab_phase_detect_pulse_num->setShown(auth & AUTH_SUPER_USER2);
}
void OtherInfo::applyUIPara(){
if(sysPara){
sysPara->para.phaseHighLowRatio = ui->spinBoxHighLowRatio->value();//界面上是相检, 占空比
//sysPara->para.phase_detect_pulse_num = 6;// ui->spinBoxPhaseDetectDotNum->value();
sysPara->para.phase_detect_pulse_num = ui->spinBoxPhaseDetectDotNum->value();
#ifndef FOR_PHASE_ADJUST
sysPara->para.phase_detect_pulse_num = 7;
sysPara->para.phaseDetectVol = 35; //ui->spinBoxPhaseDetectVoltage->value();
sysPara->para.phaseDetectDelay = 100;// ui->spinBoxPhaseDetectDelay->value();
#else
sysPara->para.phaseDetectVol = ui->spinBoxPhaseDetectVoltage->value();
sysPara->para.phaseDetectDelay = ui->spinBoxPhaseDetectDelay->value();
sysPara->para.phase_detect_pulse_num = ui->spinBoxPhaseDetectDotNum->value();
#endif
sysPara->para.phaseShift = ui->spinBoxPhaseShift->value();
//qDebug()<<"shift:"<<sysPara->para.phaseShift;
//qDebug()<<"shift:0x"<<QString("%1").arg(sysPara->para.phaseShift, 0, 16);
sysPara->para.blinkLightPeriod = ui->spinBoxBlickLightPeriod->value();
sysPara->para.enableChargeFullTime = 1;//ui->checkBoxChargeFullTime->isChecked()?1:0;
// 由FPGA 设置
if(sysPara->devOp->writeFpgaPrintPara() != -1)
QMessageBox::information(this,tr("提示"),tr("应用成功"));
}
}
void OtherInfo::phaseDetectResultRecord(void){
if(!memcmp(lastPhaseChargeReulse,sysPara->status.phaseChargeResult,sizeof(sysPara->status.phaseChargeResult))){
return;
}
sysPara->devOp->readPhaseDetectHighTm();
QFile phaseRecordFile("/home/plg/doc/phaseDetectResultRecord.txt");
if (!phaseRecordFile.exists()) {
if (phaseRecordFile.open(QFile::WriteOnly | QFile::Truncate)) {
QTextStream out(&phaseRecordFile);
out << "time"<< ","
<< "flight_tm"<< ","
<< "phase"<< ","
<< "curr_charge_phase"<< ","
<< "ink_dot_number"<< ","
<< "high_sig_cnt"<< ","
<< "reg_phase_shift"<< ","
<< "phase_detect_dot_num"<< ","
<< "phase_charge_result_bit"
<< "\n";
phaseRecordFile.close();
}
}
if (phaseRecordFile.open(QFile::WriteOnly | QFile::Append)) {
QTextStream out(&phaseRecordFile);
// out << "flight_tm"
// << "phase"
// << "curr_charge_phase"
// << "ink_dot_number"
// << "high_sig_cnt"
// << "reg_phase_shift"
// << "phase_detect_dot_num"
// << "phase_charge_result_bit"
// << "\n";
out << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss ") << "," // "flight_tm"
<< sysPara->status.flightTm << "," // "flight_tm"
<< "None" << "," //"phase"
<< sysPara->status.phase << "," //"curr_charge_phase"
<< sysPara->status.ink_dot_num << "," //"ink_dot_number"
<< sysPara->para.phase_detect_high_cnt<< "," //"high_sig_cnt"
<< sysPara->para.phaseShift<< "," //"reg_phase_shift"
<< sysPara->para.phase_detect_pulse_num<< "," //"phase_detect_dot_num"
;
for (quint8 i = 0; i < sizeof(sysPara->status.phaseDetectHighTm); ++i) {
out << sysPara->status.phaseDetectHighTm[i];// << ","; // "phase_charge_result_bit"
if (i < sizeof(sysPara->status.phaseDetectHighTm) - 1) {
out << ",";
}
}
out << "\n";
phaseRecordFile.close();
}
}
void OtherInfo::updateSysStatusToUI(){
if(sysPara){
if(memcmp(lastPhaseChargeReulse,sysPara->status.phaseChargeResult,sizeof(sysPara->status.phaseChargeResult))){
sysPara->devOp->readPhaseDetectHighTm();
ui->phaseGraphic->updateSysStatusToUI();
}
memcpy(lastPhaseChargeReulse,sysPara->status.phaseChargeResult,sizeof(sysPara->status.phaseChargeResult));
ui->labelFlightTm->setText(QString::number(sysPara->status.flightTm*2) + "|" + QString::number(sysPara->status.ink_dot_num) + tr("点")); //逻辑里面已经除以2
ui->labelPhasePosition->setText(QString::number(sysPara->status.phase));
//ui->lab_enableChargeFullTime->setText(sysPara->para.enableChargeFullTime?"FULL":"0");
ui->lab_phaseDetectDelay->setText( QString("%1").arg(sysPara->para.phaseDetectDelay));
ui->lab_phaseDetectVol->setText(QString("%1").arg(sysPara->para.phaseDetectVol));
ui->lab_phaseHighLowRatio->setText(QString("%1").arg(sysPara->para.phaseHighLowRatio));
//ui->lab_phase_detect_pulse_num->setText(QString("%1").arg(sysPara->para.phase_detect_pulse_num));
ui->memDisplayAndEdit->updateSysStatusToUI();
/* if(ui->checkBoxChargeFullTime->isChecked()){
ui->spinBoxHighLowRatio->setEnabled(false);
}
else */
//ui->spinBoxHighLowRatio->setEnabled(true);
}
}
void OtherInfo::on_pushButtonApply_pressed()
{
applyUIPara();
if(sysPara){
sysPara->saveParaToFile();
//qDebug()<<"save OtherInfo para.";
}
OtherInfoLog();
}
void OtherInfo::OtherInfoLog(){
qDebug()<<QString("OtherInfo 频闪灯周期: %1").arg(ui->spinBoxBlickLightPeriod->value());
qDebug()<<QString("OtherInfo 相位检测电压: %1").arg(ui->spinBoxPhaseDetectVoltage->value());
qDebug()<<QString("OtherInfo 检测墨点数量: %1").arg(ui->spinBoxPhaseDetectDotNum->value());
qDebug()<<QString("OtherInfo 相位偏移: %1").arg(ui->spinBoxPhaseShift->value());
qDebug()<<QString("OtherInfo 相检: %1").arg(ui->spinBoxHighLowRatio->value());
qDebug()<<QString("OtherInfo 检测延时: %1").arg(ui->spinBoxPhaseDetectDelay->value());
}
void OtherInfo::updateLockPhaseWidgets(){
if(sysPara){
if(lockPhaseFlag)
ui->pushButtonLockPhase->setText(tr("解锁相位"));
else
ui->pushButtonLockPhase->setText(tr("锁定相位"));
if(lockPhaseFlag){
//ui->spinBoxLockedPhase->setMaximum(sysPara->para.divideRatio*2 - 1);
//ui->spinBoxLockedPhase->setSingleStep(sysPara->para.divideRatio/32);
sysPara->devOp->setPhaseByHand(sysPara->status.phase/PHASE_BY_HAND_DIV);
//ui->spinBoxLockedPhase->setEnabled(true);
//ui->spinBoxLockedPhase->setValue(sysPara->status.phase);
ui->phaseGraphic->setLockedPhase(true,sysPara->status.phase);
}
else{
sysPara->devOp->setPhaseByHand(0);
//ui->spinBoxLockedPhase->setEnabled(false);
//ui->spinBoxLockedPhase->setValue(0);
ui->phaseGraphic->setLockedPhase(false,0);
}
ui->phaseGraphic->updateSysStatusToUI();
}
}
void OtherInfo::on_pushButtonLockPhase_pressed()
{
lockPhaseFlag = !lockPhaseFlag;
updateLockPhaseWidgets();
}
void OtherInfo::on_spinBoxHighLowRatio_valueChanged(int dutyCycle)
{
if(sysPara){
sysPara->devOp->setPhaseDetectVoltageDutyCycle(dutyCycle);
}
}
void OtherInfo::on_spinBoxLockedPhase_valueChanged(int newPhase)
{
if(sysPara){
sysPara->devOp->setPhaseByHand(newPhase/PHASE_BY_HAND_DIV);
ui->phaseGraphic->setLockedPhase(true,newPhase);
ui->phaseGraphic->updateSysStatusToUI();
}
}
void OtherInfo::on_spinBoxBlickLightPeriod_editingFinished()
{
if(sysPara){
sysPara->devOp->setBlickLightPeriod(ui->spinBoxBlickLightPeriod->value());
}
}