2023-04-14 19:30:30 +08:00
|
|
|
#include "CharacteristicList.h"
|
|
|
|
|
#include "ui_CharacteristicList.h"
|
|
|
|
|
|
|
|
|
|
CCharacteristicList::CCharacteristicList(QWidget *parent) :
|
|
|
|
|
QWidget(parent),
|
|
|
|
|
ui(new Ui::CCharacteristicList)
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
ui->widget->setProperty("flag", "Title2");
|
|
|
|
|
ui->widget_2->setProperty("flag", "Title2");
|
|
|
|
|
InitTable();
|
|
|
|
|
id1 = startTimer(1000); //参数1 间隔 单位 毫秒
|
|
|
|
|
//定时器第二种方式
|
|
|
|
|
QTimer * timer = new QTimer(this);
|
|
|
|
|
//启动定时器
|
|
|
|
|
timer->start(500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CCharacteristicList::~CCharacteristicList()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CCharacteristicList::timerEvent(QTimerEvent *ev)
|
|
|
|
|
{
|
|
|
|
|
if(ev->timerId() == id1)
|
|
|
|
|
{
|
|
|
|
|
DisPlayCharacteristic();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void CCharacteristicList::InitTable()
|
|
|
|
|
{
|
|
|
|
|
headerStr = QObject::tr("通道名称,单位,通频值,峰峰值,1X幅值,1X相位,平均工作位置,间隙,安装角度,状态");
|
2023-04-17 17:40:26 +08:00
|
|
|
ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
|
2023-04-14 19:30:30 +08:00
|
|
|
model = new QStandardItemModel(ui->tableView);
|
|
|
|
|
ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows); //选中行
|
|
|
|
|
QStringList headerList = headerStr.split(",");
|
|
|
|
|
model->setHorizontalHeaderLabels(headerList);
|
|
|
|
|
model->setColumnCount(headerList.size());
|
|
|
|
|
ui->tableView->setModel(model);
|
|
|
|
|
ui->tableView->setAlternatingRowColors(true);
|
|
|
|
|
ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
2023-04-17 17:40:26 +08:00
|
|
|
ui->tableView->setColumnWidth(0, 300);
|
2023-04-14 19:30:30 +08:00
|
|
|
ui->tableView->setColumnWidth(6, 200);
|
|
|
|
|
|
|
|
|
|
// for (int i = 0;i < g_ChannelView.size(); i++)
|
|
|
|
|
// {
|
|
|
|
|
// model->setData(model->index(i,0,QModelIndex()),g_ChannelView[i].channelName);
|
|
|
|
|
// model->setData(model->index(i,1,QModelIndex()),g_ChannelView[i].channelUnit);
|
|
|
|
|
// model->item(i, 0)->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
// model->item(i, 1)->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CCharacteristicList::DisPlayCharacteristic()
|
|
|
|
|
{
|
|
|
|
|
//if(g_Charateristic.size() > 0 && g_ChannelView.size() <= g_Charateristic.size())
|
|
|
|
|
{
|
|
|
|
|
model->removeRows(0, model->rowCount());
|
|
|
|
|
model->setRowCount( g_Charateristic.size());
|
|
|
|
|
for (int i = 0; i < g_ChannelBaseInfo.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < g_Charateristic.size(); j++) {
|
|
|
|
|
if(g_Charateristic[j].ChannelID == g_ChannelBaseInfo[i].channelID)
|
|
|
|
|
{
|
|
|
|
|
model->setData(model->index(j,0,QModelIndex()),g_Charateristic[j].ChannelName);
|
|
|
|
|
model->setData(model->index(j,1,QModelIndex()),g_Charateristic[j].SensorEngineeringUnit);
|
|
|
|
|
if(g_ChannelBaseInfo[i].defaultDisplay == "峰峰值"){
|
|
|
|
|
model->setData(model->index(j,2,QModelIndex()),g_Charateristic[j].MonitorPk2Pk);
|
|
|
|
|
}else if(g_ChannelBaseInfo[i].defaultDisplay == "有效值"){
|
|
|
|
|
model->setData(model->index(j,2,QModelIndex()),g_Charateristic[j].IntegratRMS);
|
|
|
|
|
}else if(g_ChannelBaseInfo[i].defaultDisplay == "峰值"){
|
|
|
|
|
model->setData(model->index(j,2,QModelIndex()),g_Charateristic[j].DerivedPeak);
|
|
|
|
|
}else if(g_ChannelBaseInfo[i].defaultDisplay == "平均值"){
|
|
|
|
|
model->setData(model->index(j,2,QModelIndex()),g_Charateristic[j].DCValues);
|
2023-04-27 19:48:15 +08:00
|
|
|
}else if(g_ChannelBaseInfo[i].defaultDisplay == "转速"){
|
|
|
|
|
model->setData(model->index(j,2,QModelIndex()),g_Charateristic[j].speedRPM);
|
2023-04-14 19:30:30 +08:00
|
|
|
}
|
2023-04-27 19:48:15 +08:00
|
|
|
//qDebug() << g_ChannelBaseInfo[i].boardType << g_Charateristic[j].DCValues <<endl;
|
|
|
|
|
if(g_ChannelBaseInfo[i].boardType == "5"){
|
|
|
|
|
model->setData(model->index(j,2,QModelIndex()),g_Charateristic[j].DCValues);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 19:30:30 +08:00
|
|
|
|
|
|
|
|
model->setData(model->index(j,3,QModelIndex()),QString::number(g_Charateristic[j].MonitorPk2Pk,'f',2));
|
|
|
|
|
model->setData(model->index(j,4,QModelIndex()),g_Charateristic[j].Amp1x);
|
|
|
|
|
model->setData(model->index(j,5,QModelIndex()),g_Charateristic[j].Phase1x);
|
|
|
|
|
model->setData(model->index(j,6,QModelIndex()),g_Charateristic[j].xFullScalePosition);
|
|
|
|
|
model->setData(model->index(j,7,QModelIndex()),g_Charateristic[j].Gap);
|
|
|
|
|
model->setData(model->index(j,8,QModelIndex()),g_Charateristic[j].ZeroScalePosition);
|
|
|
|
|
model->setData(model->index(j,9,QModelIndex()),g_Charateristic[j].SensorStatus);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|