Beispiel #1
0
void ToxTunBase::promiseCleanupTimeout()
{
    QTimer *timer = (QTimer*)sender();
    QVariant vchan = timer->property("chan");
    ToxTunChannel *chan = (ToxTunChannel*)vchan.value<void*>();
    qDebug()<<timer<<chan<<chan->m_conid;
    this->promiseChannelCleanup(chan);
}
void    Btowngtw::receiveCMD(QString value, QString key) {
    qDebug() << m_gtwID << " Receive command from Gateway: " << value;
    PlantMessage myMsg;
    SysError theSysError;
    if(OpenMsg::parse(value, myMsg)) {

        QTimer *timer = new QTimer(this);
        connect(timer, SIGNAL(timeout()), this, SLOT(stopTimer()));
        timer->setSingleShot(true);
        int msgID = qrand() % ((MAX_TIMER_ID + 1) - 0) + 0;
        m_timeoutMap.insert(msgID, key);
        timer->setProperty(TIMER_ID.toStdString().c_str(), msgID);
        timer->setProperty(TYPE.toStdString().c_str(), sender()->property(TYPE.toStdString().c_str()).toString());
        timer->setProperty(FRAME_TYPE.toStdString().c_str(), OpenMsg::getFrameType(value));
        qDebug() << " timer getProperty: " << sender()->property(TYPE.toStdString().c_str()).toString() << " " << timer->property(TYPE.toStdString().c_str()).toString();
        timer->start(TIMEOUT);

        qDebug() << m_gtwID << " Parsing ok, emit sendCommand Signal";
        myMsg.setSourceAddr(QPair<QString, QString>(PlantMessage::EXTERNAL, key), true);
        myMsg.setDestAddr(QPair<QString, QString>(PlantMessage::INTERNAL, PlantMessage::DEVICE), true);
        myMsg.setType(sender()->property(TYPE.toStdString().c_str()).toString());
        myMsg.setId(msgID);
        emit ReleaseMessage(myMsg, theSysError);
    }
    else {
        qDebug() << m_gtwID << " Receive command from Gateway is WRONG FORMAT";
    }
}