void CWizDocumentStatusChecker::initialise() { // qDebug() << "CWizDocumentStatusChecker thread id : "; m_timeOutTimer = new QTimer(this); connect(m_timeOutTimer, SIGNAL(timeout()), SLOT(onTimeOut())); // m_loopCheckTimer = new QTimer(this); // connect(m_loopCheckTimer, SIGNAL(timeout()), SLOT(recheck())); }
GetUrl::GetUrl(QObject *parent) : QObject(parent) { reply = NULL; callbackFunc = NULL; data = NULL; timer = new QTimer(this); timer->setSingleShot(true); connect(timer, SIGNAL(timeout()), this, SLOT(onTimeOut())); exc_GetUrlError = PyErr_NewException("moonplayer.GetUrlError", NULL, NULL); }
Connector::Connector() { //readOp = {0x09, 0xAC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x02}; readOp[0] = 0x09; // 数据总数 readOp[1] = 0xAC; // 读数据 readOp[2] = 0xFF; // 密码 readOp[3] = 0xFF; readOp[4] = 0xFF; readOp[5] = 0xFF; readOp[6] = 0xFF; readOp[7] = 0xFF; readOp[8] = 0x01; // 起始扇区 readOp[9] = 0x02; // 扇区数(最多5) //waitOp = {0x01, 0xAD}; waitOp[0] = 0x01; // 数据总数 waitOp[1] = 0xAD; // 关射频 //writeOp = {0x09, 0xAB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x02}; writeOp[0] = 0x09; // 数据总数 writeOp[1] = 0xAB; // 写数据 writeOp[2] = 0xFF; // 密码 writeOp[3] = 0xFF; writeOp[4] = 0xFF; writeOp[5] = 0xFF; writeOp[6] = 0xFF; writeOp[7] = 0xFF; writeOp[8] = 0x01; // 起始扇区 writeOp[9] = 0x02; // 扇区数 //后面跟数据,最长240byte //读取数据的返回头 returnHead[0] = 0x5A; returnHead[1] = 0x59; returnHead[2] = 0x48; returnHead[3] = 0x02; setPortName("/dev/ttyO5"); setBaudRate(QSerialPort::Baud9600); setDataBits(QSerialPort::Data8); setStopBits(QSerialPort::OneStop); setParity(QSerialPort::NoParity); open(QIODevice::ReadWrite); timer.setInterval(2000); connect(&timer, SIGNAL(timeout()), this, SLOT(onTimeOut())); connect(this, SIGNAL(readOK(QByteArray)), this, SLOT(onReadOK(QByteArray))); startRead(1, 4); }
void MusicAudioRecorderWidget::onReadMore() { //Return if audio input is nullptr if(!m_mpAudioInputSound) { return; } //Check the number of samples in input buffer qint64 len = m_mpAudioInputSound->bytesReady(); //Limit sample size if(len > 4096) { len = 4096; } //Read sound samples from input device to buffer qint64 l = m_mpInputDevSound->read(m_mBuffer.data(), len); if(l > 0) { //Assign sound samples to short array short* resultingData = (short*)m_mBuffer.data(); short *outdata=resultingData; outdata[ 0 ] = resultingData [ 0 ]; int iIndex; if(false) { //Remove noise using Low Pass filter algortm[Simple algorithm used to remove noise] for ( iIndex=1; iIndex < len; iIndex++ ) { outdata[ iIndex ] = 0.333 * resultingData[iIndex ] + ( 1.0 - 0.333 ) * outdata[ iIndex-1 ]; } } m_miMaxValue = 0; for ( iIndex=0; iIndex < len; iIndex++ ) { //Cange volume to each integer data in a sample int value = applyVolumeToSample( outdata[ iIndex ]); outdata[ iIndex ] = value; m_miMaxValue = m_miMaxValue >= value ? m_miMaxValue : value; } //write modified sond sample to outputdevice for playback audio m_mpOutputDevSound->write((char*)outdata, len); QTimer::singleShot(1000, this, SLOT(onTimeOut())); } }
void *TimerTask (void * arg){ int i; while(1){ // Controle succesivement les timers for(i=0;i<10;i++){ if(myTimer[i][STOPTIME]!=0){ // Timer Actif (!=0) if(timeNow >= myTimer[i][STOPTIME]){ onTimeOut(myTimer[i][PTRFUNC], myTimer[i][ACTIONID],myTimer[i][WHEEL]); // Appelle la fonction callback myTimer[i][STOPTIME]=0; } } } timeNow++; usleep(1000); } pthread_exit (0); }
FFmpegTestWindow::FFmpegTestWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::FFmpegTestWindow), _pFormatContext(NULL), _videoStream(NULL), _pCodecContext(NULL), _pFrame(NULL), _pSwsCtx(NULL), _image(NULL), _rgb(NULL), _currentFrame(0), _rate(0) { ui->setupUi(this); av_register_all(); connect(&_timer, SIGNAL(timeout()), this, SLOT(onTimeOut())); _timer.start(40); }
/** * 从控机底层网络连接类定义 * @author 冯明晨 * @author 熊雪 * @author 范翔 * @date 2014-2-12 * @version 1.0.0 */ Client::Client(QString masterip, bool autoconnect, QObject *parent) { qDebug() << tr("构造Client"); // 是否自动连接,若isautoconnect == true,每次连接断开后自动发起连接,else断开就断开 isautoconnect = autoconnect; // @author 范翔添加 // 配置一次多次调用 masterIPAddress = QHostAddress(masterip); //【方案二】 /**********************/ m_tcpSocket = new QTcpSocket(); connect(m_tcpSocket, SIGNAL(connected()), this, SLOT(onConnected())); connect(m_tcpSocket, SIGNAL(disconnected()), this, SLOT(onDisconnected())); connect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(readMsgFromMaster())); connect(m_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(displayError(QAbstractSocket::SocketError))); m_bConnected = false; /**********************/ // 多文件发送类(串行发送) fileListSender = new FileListSender(); connect(fileListSender, SIGNAL(error_openfile(QString, QString, int)), this, SLOT(fileopenError(QString, QString,int))); connect(fileListSender, SIGNAL(current_progress(QString, QString, qint64, qint64, int)), this, SLOT(updateClientProgress(QString, QString, qint64, qint64,int))); connect(fileListSender, SIGNAL(error_transfer(QString, QString, QString, int)), this, SLOT(fileError(QString, QString, QString, int))); connect(fileListSender, SIGNAL(end_transfer(QString, QString, int, int, int)), this, SLOT(fileend(QString, QString, int, int, int))); // 多文件接收类,多线程并行接收不同主机发来的文件 fileReceiverServer = new FileReceiverServer(8888); connect(fileReceiverServer, SIGNAL(error_openfile(QString, QString, int)), this, SLOT(fileopenError(QString, QString,int))); connect(fileReceiverServer, SIGNAL(current_progress(QString, QString, qint64, qint64, int)), this, SLOT(updateClientProgress(QString, QString, qint64, qint64,int))); connect(fileReceiverServer, SIGNAL(error_transfer(QString, QString, QString, int)), this, SLOT(fileError(QString, QString, QString, int))); connect(fileReceiverServer, SIGNAL(end_transfer(QString, QString, int, int, int)), this, SLOT(fileend(QString, QString, int, int, int))); // 心跳发包 timer = new QTimer(); timer->setInterval(100000); connect(timer, SIGNAL(timeout()), this, SLOT(onTimeOut())); timer->start(); }
void CWizDocumentStatusCheckThread::run() { // int idleCounter = 0; while (1) { ////// { QMutexLocker lock(&m_mutexWait); if (!m_needRecheck) { // m_wait.wait(&m_mutexWait); } else { m_needRecheck = false; } // if (m_stop) return; m_strCurKbGUID = m_strKbGUID; m_strCurGUID = m_strGUID; } // if (!m_timer) { m_timer = new QTimer(0); m_timer->setSingleShot(true); m_timer->moveToThread(this); connect(m_timer, SIGNAL(timeout()), SLOT(onTimeOut())); } // QTimer::singleShot(5000, this, SLOT(onTimeOut())); // if (idleCounter >= 60 || m_checkNow || m_stop) { m_checkNow = false; idleCounter = 0; if (m_stop) return; m_timer->start(5000); // qDebug() << "after qtimer started."; // qDebug() << "start to check document changed on server , guid : " << m_strCurGUID; // bool changed = checkDocumentChangedOnServer(m_strCurKbGUID, m_strCurGUID); // qDebug() << "check finished, document changed : " << changed; // emit checkDocumentChangedFinished(m_strCurGUID, changed); // qDebug() << "start to check document edit status"; // checkDocumentEditStatus(m_strCurKbGUID, m_strCurGUID); // m_timer->stop(); } else { sleep(1); idleCounter ++; } } }
void Request::send(QString req){ rep=manager.get(QNetworkRequest(QUrl(req))); connect(rep,SIGNAL(finished()),this,SLOT(readData())); connect(rep,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(smError(QNetworkReply::NetworkError))); QTimer::singleShot(TIME_OUT,this,SLOT(onTimeOut())); }
O2Reply::O2Reply(QNetworkReply *r, int timeOut, QObject *parent): QTimer(parent), reply(r) { setSingleShot(true); // connect(this, SIGNAL(error(QNetworkReply::NetworkError)), reply, SIGNAL(error(QNetworkReply::NetworkError)), Qt::QueuedConnection); connect(this, SIGNAL(timeout()), this, SLOT(onTimeOut()), Qt::QueuedConnection); start(timeOut); }