#include "mainwindow.h" #include "ui_mainwindow.h" #include "qtmessagedef.h" #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); setWindowIcon(QIcon("./Resource/log.jpg")); } MainWindow::~MainWindow() { delete ui; } void MainWindow::AddLog(std::string log) { if(ui->m_log_list->count()>50) ui->m_log_list->clear(); char buf[255]={0}; time_t tt = time(0);//时间cuo struct tm* t = localtime(&tt); memset(buf,0,255); sprintf(buf, "%d-%02d-%02d %02d:%02d:%02d %s", t->tm_year + 1900, t->tm_mon + 1,t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec,log.c_str()); ui->m_log_list->insertItem(ui->m_log_list->count(),buf); ui->m_log_list->scrollToBottom(); } void MainWindow::ProcessSlot(QVariant var) { QtMessageData data=var.value(); if(data.msg_type==ePlcSignal) { static unsigned short last_data[255]={0}; for(int i=0;i %d",i,last_data[i],data.plc_data[i]); AddLog(buf); } } } else if(data.msg_type==eMeasure) { std::string msgstr="Laser ID : "; char buf[255]; memset(buf,0,255); std::vector IDS; for(int i=0;i<16;++i) { if((0x01<m_measure_result->setText(msgstr.c_str()); } } #include "qmessagebox.h" #include "src/pathcreator.h" void MainWindow::on_m_test_btn_clicked() { PathCreator pathCreator; pathCreator.CreateDatePath("/home/zx/data"); } #include "Process.h" extern CProcess* m_pProcess; void MainWindow::on_m_add_clicked() { m_pProcess->PushTask(0x01,1,false); AddLog(" test tsak "); }