2025-03-19T11:19:52
This commit is contained in:
parent
6a52420417
commit
6cc70a2327
@ -19,7 +19,7 @@ void writeExperimentFile(const CommonData &cd)
|
|||||||
}
|
}
|
||||||
QTextStream out(&_expeFile);
|
QTextStream out(&_expeFile);
|
||||||
out.setRealNumberPrecision(3); // 设置精度为三位小数
|
out.setRealNumberPrecision(3); // 设置精度为三位小数
|
||||||
out.setRealNumberNotation(QTextStream::FixedNotation);
|
out.setRealNumberNotation(QTextStream::FixedNotation);
|
||||||
|
|
||||||
out << cd.sample_temp << " "
|
out << cd.sample_temp << " "
|
||||||
<< cd.dsc << endl;
|
<< cd.dsc << endl;
|
||||||
@ -34,8 +34,7 @@ void createExperimentFile()
|
|||||||
|
|
||||||
fileName.append("_");
|
fileName.append("_");
|
||||||
if(_expeInfo.date.isEmpty()){
|
if(_expeInfo.date.isEmpty()){
|
||||||
// fileName.append(QDateTime::currentDateTime().toUTC().toString("yyyyMMdd_HHmmss"));
|
fileName.append(QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss"));
|
||||||
fileName.append(QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss"));
|
|
||||||
}else{
|
}else{
|
||||||
fileName.append(_expeInfo.date);
|
fileName.append(_expeInfo.date);
|
||||||
}
|
}
|
||||||
@ -63,9 +62,9 @@ void test()
|
|||||||
|
|
||||||
void fileClose()
|
void fileClose()
|
||||||
{
|
{
|
||||||
if(_expeFile.isOpen()){
|
if(_expeFile.isOpen()){
|
||||||
_expeFile.close();
|
_expeFile.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -121,6 +121,7 @@ void MainWindow::on_actionConnectToDev_triggered()
|
|||||||
{
|
{
|
||||||
setActionEnable(true);
|
setActionEnable(true);
|
||||||
Global::instance()->setMode(Global::Mode::ConnectedToDev);
|
Global::instance()->setMode(Global::Mode::ConnectedToDev);
|
||||||
|
|
||||||
QByteArray ba = DataParser::inquirePhaseInfo();
|
QByteArray ba = DataParser::inquirePhaseInfo();
|
||||||
SerialPort::instance()->sendData(ba);
|
SerialPort::instance()->sendData(ba);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,14 @@
|
|||||||
#pragma pack(push)
|
#pragma pack(push)
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
|
||||||
|
enum DeviceRunStatus{
|
||||||
|
Idle,
|
||||||
|
Heat,
|
||||||
|
ConstantTemp,
|
||||||
|
Cooling,
|
||||||
|
HeatingReteSelfTunning
|
||||||
|
};
|
||||||
|
|
||||||
enum DeviceStartMode{
|
enum DeviceStartMode{
|
||||||
Stop,
|
Stop,
|
||||||
Start,
|
Start,
|
||||||
|
|||||||
@ -101,6 +101,7 @@ void SerialPort::slotReadData()
|
|||||||
#if 1
|
#if 1
|
||||||
QString hexData = ba.toHex(' '); // ' ' 作为分隔符,可选参数
|
QString hexData = ba.toHex(' '); // ' ' 作为分隔符,可选参数
|
||||||
qDebug() << "receive info (hex):" << hexData;
|
qDebug() << "receive info (hex):" << hexData;
|
||||||
|
return;
|
||||||
#endif
|
#endif
|
||||||
SerialPortProtocol *spp = (SerialPortProtocol *)ba.data();
|
SerialPortProtocol *spp = (SerialPortProtocol *)ba.data();
|
||||||
if (FRANE_HEAD != spp->head)
|
if (FRANE_HEAD != spp->head)
|
||||||
@ -123,10 +124,12 @@ void SerialPort::slotReadData()
|
|||||||
|
|
||||||
if (WRITE_CMD == spp->cmd)
|
if (WRITE_CMD == spp->cmd)
|
||||||
{
|
{
|
||||||
writeCmdHandle(dataLength, spp->addr, cd);
|
commonDataParser(dataLength, spp->addr, cd);
|
||||||
}
|
}
|
||||||
else if (READ_CMD == spp->cmd)
|
else if (READ_CMD == spp->cmd)
|
||||||
{
|
{
|
||||||
|
// judge the device status.
|
||||||
|
commonDataParser(dataLength, spp->addr, cd);
|
||||||
// read data
|
// read data
|
||||||
if (spp->addr == 0)
|
if (spp->addr == 0)
|
||||||
{
|
{
|
||||||
@ -140,8 +143,8 @@ void SerialPort::slotReadData()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SerialPort::writeCmdHandle(const int dataLength, const u16 addr,
|
void SerialPort::commonDataParser(const int dataLength, const u16 addr,
|
||||||
const CommonData &cd)
|
const CommonData &cd)
|
||||||
{
|
{
|
||||||
int localLength = dataLength;
|
int localLength = dataLength;
|
||||||
int localAddr = addr;
|
int localAddr = addr;
|
||||||
@ -155,7 +158,7 @@ void SerialPort::writeCmdHandle(const int dataLength, const u16 addr,
|
|||||||
phase.temp_flow = cd.phase_data[index].temp_flow;
|
phase.temp_flow = cd.phase_data[index].temp_flow;
|
||||||
phase.cutoff_temp = cd.phase_data[index].cutoff_temp;
|
phase.cutoff_temp = cd.phase_data[index].cutoff_temp;
|
||||||
phase.constant_temp_time_min =
|
phase.constant_temp_time_min =
|
||||||
cd.phase_data[index].constant_temp_time_min;
|
cd.phase_data[index].constant_temp_time_min;
|
||||||
|
|
||||||
localLength -= phaseByteSize;
|
localLength -= phaseByteSize;
|
||||||
localAddr += phaseByteSize;
|
localAddr += phaseByteSize;
|
||||||
@ -165,6 +168,20 @@ void SerialPort::writeCmdHandle(const int dataLength, const u16 addr,
|
|||||||
{
|
{
|
||||||
switch (localAddr)
|
switch (localAddr)
|
||||||
{
|
{
|
||||||
|
case offsetof(CommonData, run_type): // 运行状态
|
||||||
|
{
|
||||||
|
switch(cd.run_type){
|
||||||
|
case DeviceRunStatus::Cooling:
|
||||||
|
Global::instance()->setMode(Global::Mode::Analysis);
|
||||||
|
break;
|
||||||
|
default:break;
|
||||||
|
}
|
||||||
|
|
||||||
|
localAddr += 1;
|
||||||
|
localLength -= 1;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
case offsetof(CommonData, current_gas): // 当前气氛
|
case offsetof(CommonData, current_gas): // 当前气氛
|
||||||
// gas_type_set(dev->temp, msg_data.current_gas);
|
// gas_type_set(dev->temp, msg_data.current_gas);
|
||||||
localAddr += 1;
|
localAddr += 1;
|
||||||
@ -414,6 +431,7 @@ void SerialPort::parserTest()
|
|||||||
|
|
||||||
void SerialPort::slotDeliverData(const QByteArray &ba)
|
void SerialPort::slotDeliverData(const QByteArray &ba)
|
||||||
{
|
{
|
||||||
|
qDebug()<<"slotDeliverData...";
|
||||||
openSp();
|
openSp();
|
||||||
|
|
||||||
slotSendData(ba);
|
slotSendData(ba);
|
||||||
@ -421,13 +439,6 @@ void SerialPort::slotDeliverData(const QByteArray &ba)
|
|||||||
|
|
||||||
void SerialPort::slotSendData(const QByteArray &ba)
|
void SerialPort::slotSendData(const QByteArray &ba)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
if (WRITE_CMD == ba.at(3))
|
|
||||||
{
|
|
||||||
_lastWriteBa = ba;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
qDebug() << "slotSendData:" << ba.size();
|
qDebug() << "slotSendData:" << ba.size();
|
||||||
QString hexData = ba.toHex(' '); // ' ' 作为分隔符,可选参数
|
QString hexData = ba.toHex(' '); // ' ' 作为分隔符,可选参数
|
||||||
|
|||||||
@ -23,7 +23,7 @@ public:
|
|||||||
~SerialPort();
|
~SerialPort();
|
||||||
|
|
||||||
void sendData(const QByteArray &data)
|
void sendData(const QByteArray &data)
|
||||||
{slotSendData(data); }
|
{ slotSendData(data); }
|
||||||
void sendCmd(const E_CMD_TYPE e);
|
void sendCmd(const E_CMD_TYPE e);
|
||||||
static void parserTest();
|
static void parserTest();
|
||||||
bool openSp();
|
bool openSp();
|
||||||
@ -43,7 +43,7 @@ private slots:
|
|||||||
void slotReadData();
|
void slotReadData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void writeCmdHandle(const int dataLength, const u16 addr, const CommonData &cd);
|
void commonDataParser(const int dataLength, const u16 addr, const CommonData &cd);
|
||||||
void to_hex(char *in_char, int char_length, char *out_char);
|
void to_hex(char *in_char, int char_length, char *out_char);
|
||||||
void displayPortInfo();
|
void displayPortInfo();
|
||||||
|
|
||||||
|
|||||||
@ -35,6 +35,11 @@ CentralWidget::CentralWidget(QWidget *parent)
|
|||||||
// startTimer(1000);
|
// startTimer(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CentralWidget::~CentralWidget()
|
||||||
|
{
|
||||||
|
FileManager::fileClose();
|
||||||
|
}
|
||||||
|
|
||||||
void CentralWidget::slotModeModify(const Global::Mode mode)
|
void CentralWidget::slotModeModify(const Global::Mode mode)
|
||||||
{
|
{
|
||||||
if (Global::Mode::ExperimentStart == mode)
|
if (Global::Mode::ExperimentStart == mode)
|
||||||
@ -51,6 +56,8 @@ void CentralWidget::slotModeModify(const Global::Mode mode)
|
|||||||
}
|
}
|
||||||
else if (Global::Mode::Analysis == mode)
|
else if (Global::Mode::Analysis == mode)
|
||||||
{
|
{
|
||||||
|
qDebug()<<"file close...";
|
||||||
|
FileManager::fileClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ class CentralWidget:public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
CentralWidget(QWidget *parent = nullptr);
|
CentralWidget(QWidget *parent = nullptr);
|
||||||
|
~CentralWidget();
|
||||||
public slots:
|
public slots:
|
||||||
void slotModeModify(const Global::Mode);
|
void slotModeModify(const Global::Mode);
|
||||||
void slotRevCommonData(const CommonData&);
|
void slotRevCommonData(const CommonData&);
|
||||||
|
|||||||
@ -354,6 +354,54 @@ void ExperimentSettingForm::slotConnectToDevice()
|
|||||||
phaseVtr.push_back(phase);
|
phaseVtr.push_back(phase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ui->checkBox_phase_3->checkState())
|
||||||
|
{
|
||||||
|
Phase phase;
|
||||||
|
phase.onoff = 1;
|
||||||
|
phase.cutoff_temp = ui->phase_3_cutoff_temp->text().toFloat();
|
||||||
|
phase.temp_flow = ui->phase_3_scan_rate->text().toFloat();
|
||||||
|
phase.constant_temp_time_min = (uint16_t)ui->phase_3_constant_temp->text().toInt();
|
||||||
|
phase.gas = GasType::N2;
|
||||||
|
|
||||||
|
phaseVtr.push_back(phase);
|
||||||
|
}
|
||||||
|
if (ui->checkBox_phase_4->checkState())
|
||||||
|
{
|
||||||
|
Phase phase;
|
||||||
|
phase.onoff = 1;
|
||||||
|
phase.cutoff_temp = ui->phase_4_cutoff_temp->text().toFloat();
|
||||||
|
phase.temp_flow = ui->phase_4_scan_rate->text().toFloat();
|
||||||
|
phase.constant_temp_time_min = (uint16_t)ui->phase_4_constant_temp->text().toInt();
|
||||||
|
// phase.gas = ui->comboBox_phase_1_atmosphere->currentIndex();
|
||||||
|
phase.gas = GasType::N2;
|
||||||
|
|
||||||
|
phaseVtr.push_back(phase);
|
||||||
|
}
|
||||||
|
if (ui->checkBox_phase_5->checkState())
|
||||||
|
{
|
||||||
|
Phase phase;
|
||||||
|
phase.onoff = 1;
|
||||||
|
phase.cutoff_temp = ui->phase_5_cutoff_temp->text().toFloat();
|
||||||
|
phase.temp_flow = ui->phase_5_scan_rate->text().toFloat();
|
||||||
|
phase.constant_temp_time_min = (uint16_t)ui->phase_5_constant_temp->text().toInt();
|
||||||
|
// phase.gas = ui->comboBox_phase_1_atmosphere->currentIndex();
|
||||||
|
phase.gas = GasType::N2;
|
||||||
|
|
||||||
|
phaseVtr.push_back(phase);
|
||||||
|
}
|
||||||
|
if (ui->checkBox_phase_6->checkState())
|
||||||
|
{
|
||||||
|
Phase phase;
|
||||||
|
phase.onoff = 1;
|
||||||
|
phase.cutoff_temp = ui->phase_6_cutoff_temp->text().toFloat();
|
||||||
|
phase.temp_flow = ui->phase_6_scan_rate->text().toFloat();
|
||||||
|
phase.constant_temp_time_min = (uint16_t)ui->phase_6_constant_temp->text().toInt();
|
||||||
|
// phase.gas = ui->comboBox_phase_1_atmosphere->currentIndex();
|
||||||
|
phase.gas = GasType::N2;
|
||||||
|
|
||||||
|
phaseVtr.push_back(phase);
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray ba = DataParser::connectToDevice(phaseVtr);
|
QByteArray ba = DataParser::connectToDevice(phaseVtr);
|
||||||
qDebug() << "ba size:" << ba.size();
|
qDebug() << "ba size:" << ba.size();
|
||||||
emit sigDeliverData(ba);
|
emit sigDeliverData(ba);
|
||||||
@ -464,7 +512,7 @@ void ExperimentSettingForm::slotRecvPhaseInfo(const QByteArray &ba)
|
|||||||
QString checkBoxName = QString("checkBox_phase_%1").arg(i);
|
QString checkBoxName = QString("checkBox_phase_%1").arg(i);
|
||||||
QCheckBox *checkBox_phase = qobject_cast<QCheckBox*>(this->findChild<QObject*>(checkBoxName));
|
QCheckBox *checkBox_phase = qobject_cast<QCheckBox*>(this->findChild<QObject*>(checkBoxName));
|
||||||
if (checkBox_phase) {
|
if (checkBox_phase) {
|
||||||
checkBox_phase->setTristate(true);
|
checkBox_phase->setChecked(true);
|
||||||
qDebug()<<"found...";
|
qDebug()<<"found...";
|
||||||
}else{
|
}else{
|
||||||
qDebug()<<"not found...";
|
qDebug()<<"not found...";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user