#include "mainwindow.h"
#include <QApplication>
#include "net_thread.h"
#include <QLoggingCategory>
#include "applive.h"
#include <QTextCodec>
#include "MCU_ARM.h"
#include "uart.h"
#include "uart1.h"
#include "mcu_arm1.h"
#include "ui_mainwindow.h"
#include <QProgressBar>

extern bool kaiji_flag_ok;

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QLoggingCategory::defaultCategory()->setEnabled(QtDebugMsg, true);//QT在linux下打印
    QApplication::setOverrideCursor(Qt::BlankCursor);//隐藏鼠标指针

    UART *uart0 = new UART;
    UART1 *uart1 = new UART1;

    MainWindow w;
    QObject::connect(uart1, SIGNAL(sigAlarmMonitor(uint32_t)),
            &w, SLOT(onAlarmCheck(uint32_t)));
    QObject::connect(uart1, SIGNAL(sigSelfTestMonitor(uint32_t)),
            &w, SLOT(onSelfTestCheck(uint32_t)));
    ledcontrol *ledctl;
    QThread threadLed;

    ledctl = new ledcontrol();
    ledctl->moveToThread(&threadLed);
    threadLed.start();

    QObject::connect(ledctl, SIGNAL(SilencingKeyClick()),
            &w, SLOT(OnSilencingKeyClick()));
    QObject::connect(uart1, SIGNAL(sigLedControl(int)),
            ledctl, SLOT(onLedControl(int)));

    w.show();

    uart0->uart_init("ttymxc1",6); //打开MCU-4G串口
    uart1->uart_init("ttymxc2",6); //打开MCU-ARM串口
#ifdef LINUX
    std::system("ifconfig eth0 192.168.1.1");//修改热像仪所接网卡IP

    w.fun_4G_start();

    std::system("/home/hotplugwatcher_linux_arm &");//启动U盘检测
#endif

    w.kaiji->close();

    w.pProgressBar->close();
    w.ui->pushButton_zhujiemian->show();
    w.ui->pushButton_canshushezhi->show();
    w.ui->pushButton_wangluoxinxi->show();
    w.ui->pushButton_xitongshezhi->show();
    w.ui->label_1->show();

    w.timer->start(1500);
    
    return a.exec();
}
