#include "bridge.h"
#include <QDebug>
extern QString DataBase_ServerIP;
extern QString DataBase_ServerProt;
extern QString DataBase_ComName;
extern QString DataBase_ComBund;
Bridge::Bridge(QObject *parent) : QObject(parent)
{
    m_ReadEPCControl = new ReadEPCControl();
    m_ReadEPCControl_thread = new QThread;
    m_ReadEPCControl->moveToThread(m_ReadEPCControl_thread);
    m_ReadEPCControl_thread->start();
    connect(this,&Bridge::SendToReadEPCControl_Connect,m_ReadEPCControl,[=](){
        qDebug()<<"串口启动";
        m_ReadEPCControl->setComm(DataBase_ComName,DataBase_ComBund.toLong());
    });
    connect(m_ReadEPCControl,&ReadEPCControl::SendToBridge,this,[=](QByteArray data){
        QString str;
        str = data.toHex();
        qDebug()<< str;
        if(str.size() == 16){
            str = str.mid(8,4);
            qDebug()<< str;
            bool ok;
            int hexnum = str.toInt(&ok,16); // 表示以16进制方式读取字符串
            emit SendToWindow(QString::number(hexnum));
        }
    });
}
