Newer
Older
ZXSSCJ / DeviceHub / FrequencyTuningForm.cpp
tan yue on 13 Nov 2021 3 KB 20211113 freq tun device command
#include "FrequencyTuningForm.h"
#include "ui_FrequencyTuningForm.h"
#include "DeviceHubWindow.h"

FrequencyTuningForm::FrequencyTuningForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FrequencyTuningForm)
{
    ui->setupUi(this);
}

FrequencyTuningForm::~FrequencyTuningForm()
{
    delete ui;
}

void FrequencyTuningForm::on_freqTunButt_clicked()
{
    // 获取设备对象
    int devIndex = ((DeviceHubWindow *) this->parent()->parent())->currentDevIndex;
    FrequencyTuning * device = (FrequencyTuning *) ((DeviceHubWindow *) this->parent()->parent())->allTypeDevList.value("03").at(devIndex);
    device->mockReceivData();
}

void FrequencyTuningForm::drawDeviceFrameOnForm(DeviceFrameBaseDto * frameData)
{
    // 当前显示的设备编号
    if (frameData->frameType == "0301")
    {
        FrequencyTuningStatusFreqDto * freqFrameDto = (FrequencyTuningStatusFreqDto *) frameData;
        ui->ftDevStatus->setText(freqFrameDto->devStatus == "1" ? "正常" : "异常");
        ui->ftInputValid->setText(freqFrameDto->inputValid == "1" ? "有效" : "无效");
        ui->ftInputTimeType->setText(freqFrameDto->inputTimeType == "1" ? "5MHz" : "10MHz");
        ui->ftFreqAdjustAcc->setText(QString("%1 pHz").arg(freqFrameDto->freqAdjustAcc));
        ui->ftPulseAdjustAcc->setText(QString("%1 fs").arg((float) freqFrameDto->pulseAdjustAcc * 0.1));
    } else if (frameData->frameType == "0302")
    {
        FrequencyTuningStatusPulseDto * pulseFrameDto = (FrequencyTuningStatusPulseDto *) frameData;
        ui->ftSynchStatus->setText(pulseFrameDto->synchStatus == "1" ? "正常" : "异常");
        ui->ftRefValid->setText(pulseFrameDto->refValid == "1" ? "有效" : "无效");
        ui->ftSecondDiff->setText(QString("%1 ns").arg(pulseFrameDto->secondDiff));
        ui->ftPhaseShiftAcc->setText(QString("%1 ps").arg(pulseFrameDto->phaseShiftAcc));
        ui->ftPulseWidth->setText(QString("%1 ns").arg(pulseFrameDto->pulseWidth));
    }
}

void FrequencyTuningForm::displayDeviceCommandOnForm(QJsonObject command)
{
    QString deviceId = command.value("deviceId").toString();
    QList<DeviceBase *> typeDevList = ((DeviceHubWindow *) this->parent()->parent())->allTypeDevList.value("03");
    for (int i = 0; i < ((DeviceHubWindow *)this->parent()->parent())->getDevTypeSelect()->count(); i++)
    {
        if (((DeviceHubWindow *)this->parent()->parent())->getDevTypeSelect()->itemData(i) == "03")
        {
            ((DeviceHubWindow *)this->parent()->parent())->getDevTypeSelect()->setCurrentIndex(i);
        }
    }
    for (int i = 0; i < typeDevList.size(); i++)
    {
        if (typeDevList.at(i)->getDeviceId() == command.value("deviceId").toString())
        {
            ((DeviceHubWindow *)this->parent()->parent())->getDevSelect()->setCurrentIndex(i);
        }
    }

    QString commandType = command.value("command").toString();
    if (commandType == "GLF,20")
    {
        ui->ftSetFreqTurn->setText(command.value("params").toString());
        ui->ftSetFreqTurnRaw->setText(command.value("rawCommand").toString());
    } else if (commandType == "GLF,21")
    {
        ui->ftSetPhaseTunn->setText(command.value("params").toString());
        ui->ftSetPhaseTunnRaw->setText(command.value("rawCommand").toString());
    } else if (commandType == "GLP,01")
    {
        ui->ftSetPhaseShift->setText(command.value("params").toString());
        ui->ftSetPhaseShiftRaw->setText(command.value("rawCommand").toString());
    } else if (commandType == "GLP,02")
    {
        ui->ftSetSynch->setText(command.value("params").toString());
        ui->ftSetSynchRaw->setText(command.value("rawCommand").toString());
    } else if (commandType == "GLP,03")
    {
        ui->ftSetPulseWidth->setText(command.value("params").toString());
        ui->ftSetPulseWidthRaw->setText(command.value("rawCommand").toString());
    }
}