Example #1
0
TelaDeProducao::TelaDeProducao(Producao *producao, QSqlDatabase conn) {
    db = conn;
    gravaTempoProducao = new QTimer();
    atualizaTempoDeProducaoTela = new QTimer();
    gravaTempoProducao->start(10000);
    atualizaTempoDeProducaoTela->start(1000);
    tempoDeProducao = QTime();
    tempoDeProducao.setHMS(0,0,0,0);
    this->producao = new Producao(producao);

    ProducaoDAO * proDAO = new ProducaoDAO(db);
    QDate DatIni;
    QTime horIni;
    int qtdMin = (horIni.currentTime().hour() * 60 * 60) + (horIni.currentTime().minute() * 60) + horIni.currentTime().second();

    this->producao->setDataInicio(DatIni.currentDate());
    this->producao->setHoraInicio(qtdMin);

    Producao * dialog = new Producao(this->producao);
    proDAO->insereProducao(dialog);
    delete dialog;
    delete proDAO;

    connect(gravaTempoProducao, SIGNAL(timeout()), this, SLOT(gravaProducao()));
    connect(atualizaTempoDeProducaoTela, SIGNAL(timeout()), this, SLOT(atualizaTela()));
}
Example #2
0
QString D3Cam::getCurrentTime()
{
	QTime time;
	int hour = time.currentTime().hour();
	int minute = time.currentTime().minute();
	int second = time.currentTime().second();
	int msec = time.currentTime().msec();

	return QString("%1:%2:%3.%4> ").arg(hour).arg(minute).arg(second).arg(msec, 3);
}
Example #3
0
QString D3Cam::getCurrentTime2()
{
	QTime time;
	QDate date;

	int year = date.currentDate().year();
	int month = date.currentDate().month();
	int day = date.currentDate().day();
	int hour = time.currentTime().hour();
	int minute = time.currentTime().minute();
	int second = time.currentTime().second();

	return QString("%1-%2-%3 %4-%5-%6").arg(year).arg(month).arg(day).arg(hour).arg(minute).arg(second);
}
Example #4
0
void TelaDeProducao::gravaProducao() {
    ProducaoDAO * proDAO = new ProducaoDAO(db);
    QDate DatFim;
    QTime horFim;
    int qtdMin = (horFim.currentTime().hour() * 60 * 60) + (horFim.currentTime().minute() * 60) + horFim.currentTime().second();

    this->producao->setDataFim(DatFim.currentDate());
    this->producao->setHoraFim(qtdMin);

    Producao * dialog = new Producao(this->producao);

    proDAO->atualizaProducao(dialog);

    delete dialog;
    delete proDAO;
}
QString DatabaseController::makeQueryResultString(const QSqlQuery& query, int iNbRowsSelected)
{
	QString szResultString;
	QTime time;

	int iNbRow = 0;
	if(query.isSelect()){
		iNbRow = query.size();
		if(iNbRow == -1){
			iNbRow = iNbRowsSelected;
		}
	} else {
		iNbRow = query.numRowsAffected();
	}

	// Write the time
	szResultString += time.currentTime().toString()+" => ";
	// Write sql error
	if(query.lastError().isValid()){
		szResultString += "Query executed with error(s) (" + query.lastError().text() + "): \n";
	}else{
		szResultString += "Query executed successfully: ";
	}
	// Write number of rows
	szResultString += QString::number(iNbRow)+" row(s) selected/affected\n";
	// Write query
	if(!query.lastQuery().isEmpty()){
		szResultString += query.lastQuery() + "\n";
	}
	szResultString += "\n";

	return szResultString;
}
Example #6
0
void Test::slotMessage(QtRedis::Reply reply)
{
    QTime time;
    qDebug() << time.currentTime();
    qDebug() << "Channel:" << reply.channel << "Pattern:" << reply.pattern;
    qDebug() << reply.value.toString();
}
Example #7
0
void TelaPrincipal::startaTempoDeProducao() {
    OrdemDeProducao * op = ops.at(0);
    portaDeComunicacao->setaQuanidadePedida(op->getQuantidadeProgramada());
    QDate datIni;
    QDate datFim;
    QTime horIni;
    estaNaProducao = true;
    Maquina * maq = new Maquina(op->getMaquina());
    int qtdHor = (horIni.currentTime().hour() * 60 * 60) + (horIni.currentTime().minute() * 60) + horIni.currentTime().second();
    producao = new Producao(maq,op,usuAtu,datIni.currentDate(),qtdHor,0,datFim,qtdHor,0);

    tempoDeProducao = new TelaDeProducao(producao,db);

    connect(tempoDeProducao, SIGNAL(atualizaTelaPrincipal(QTime)), this, SLOT(atualizaTempoDeProducao(QTime)));

}
Example #8
0
void compose::contextSaveButton()
{
    QString From=from->currentText();
    QString To=Toedit->text();
    QString Subject=Subjectedit->text();
    QString content=letter->toPlainText();
    QStringList attachments;
    for(int i=0;i< attachlist->count();++i){
        attachments.append(attachlist->item(i)->text());
    }

    QDateTime dt;
    QTime time;
    QDate date;
    dt.setTime(time.currentTime());
    dt.setDate(date.currentDate());
    QString currentDate = dt.toString("yyyy-MM-dd-hh-mm-ss");
    qDebug()<<currentDate;

    QFile file(From+"/draft/"+currentDate+".txt");
    if(!file.open(QIODevice::WriteOnly))
        qDebug("open file failed");

    file.write("RCPT TO: "+To.toUtf8()+"\r\n");
    file.write("SUBJECT: "+Subject.toLocal8Bit()+"\r\n");
    file.write("DATE: "+currentDate.toUtf8()+"\r\n");
    file.write("CONTENT: "+content.toLocal8Bit()+"\r\n");


    for(int i=0;i<attachments.count();i++){
        file.write("ATTACHMENT. "+QString::number(i,10).toUtf8()+". "+attachments.at(i).toUtf8()+"\r\n");
    }
    file.close();
}
Example #9
0
void Connection::processData()
{
    buffer = read(numBytesForCurrentDataType);
    if (buffer.size() != numBytesForCurrentDataType)
    {
        abort();
        return;
    }

    QTime time;
    sendtime = time.currentTime().toString("HH:mm:ss");

    switch (currentDataType)
    {
    case PlainText:
        emit newMessage(username, QString::fromUtf8(buffer), sendtime);
        break;
    case Ping:
        write("PONG 1 p");
        break;
    case Pong:
        pongTime.restart();
        break;
    default:
        break;
    }

    currentDataType = Undefined;
    numBytesForCurrentDataType = 0;
    buffer.clear();
}
//更新时间函数
void Add_user_data::timedate()
{
    QDateTime dt;
    QTime time;
    QDate date;
    dt.setTime(time.currentTime());
    dt.setDate(date.currentDate());
    currentDate = dt.toString("yyyyMMddhhmmss");
}
Example #11
0
void MainWindow::updateTime()
{
    QTime time;
    time = time.currentTime();
    qDebug() << time.toString("hh:mm:ss");

    timeSequence.append(time.toString("hh:mm:ss"));


}
ExtDateTime ExtDateTime::currentDateTime( Qt::TimeSpec ts )
{
    ExtDateTime dt;
    dt.setDate( ExtDate::currentDate(ts) );
    QTime t = t.currentTime(ts);
    if ( t.hour()==0 && t.minute()==0 )         // midnight or right after?
        dt.setDate( ExtDate::currentDate(ts) ); // fetch date again
    dt.setTime( t );
    return dt;
}
Example #13
0
int main(int argc, char *argv[])
{
	QCoreApplication app(argc, argv);
	QTime time;
	qDebug() <<__FILE__ << __LINE__ << __func__ << time.currentTime().toString(); 
	time.start();
	for (int i=0; i < 100; ++i) {
		for (int j=0; j<100; ++j)
		{
			int m = i*8+j;
			if (j % 10) 
			{
				qDebug() <<__FILE__ << __LINE__ << __func__;	
			}
		}
	}
	qDebug() <<__FILE__ << __LINE__ << __func__ << time.currentTime().toString(); 
	qDebug() <<__FILE__ << __LINE__ << __func__ << time.elapsed();	
 //  	return app.exec();
}
Example #14
0
void MainWindow::updateStatusbarTime()
{
    QDateTime dt;
    QTime curTime;
    QDate curData;
    dt.setDate(curData.currentDate());
    dt.setTime(curTime.currentTime());
    QString currentDate = dt.toString("yyyy/MM/dd HH:mm:ss");

    m_statustimeLb->setText(" Time: "+ currentDate );
}
Example #15
0
void AbstractScene::timeout()
{
    QTime time;
    m_currentSecond++;
    qDebug() << "Scene " << m_name << " is at second " << m_currentSecond
             << " of " << m_length << "at " << time.currentTime().toString()
             << " polling is on = " << m_polling;
    emit secondTick(this);
    if (m_currentSecond == m_length) {       
        end();
    }
}
Example #16
0
void GraphTest::loadTest(int nvtxs, int nedges, int niters)
{
	std::cout << "Load test\n";
	std::cout << "Creating graph with " << nvtxs << " vertexes and "
			  << nedges << " edges... " << std::flush;
	QTime t;
	t.start();
	TestGraph g(nvtxs, nedges, DIRECTED, GRAPH_REPR);
	std::cout << "took " << t.elapsed() << " ms" << std::endl;
	assert(g.vertexCount() == nvtxs);
	assert(g.edgeCount() == nedges);

	t.start();
	std::cout << "Iterating over vertexes... " << std::flush;
	QList<Vertex_t *> vtxs;
	TestGraph::VertexIterator vi;
	for(vi = g.vertexBegin(); vi != g.vertexEnd(); ++vi)
		vtxs.push_back(*vi);
	std::cout << "took " << t.elapsed() << " ms" << std::endl;
	assert(vtxs.size() == nvtxs);

	t.currentTime();
	qsrand((uint) t.msec());

	std::cout << "Main loop start" << std::endl;

	t.start();
	for(int i = 0, prog = 0; i < niters; ++i)
	{
		Vertex_t *v1 = g.insertVertex();
		Vertex_t *v2 = g.insertVertex();
		int from, to;

		do
		{
			from = qrand() % nvtxs;
			to = qrand() % nvtxs;
		} while(!g.insertEdge(vtxs[from], vtxs[to]));

		g.deleteEdge(v1, v2);
		g.deleteEdge(vtxs[from], vtxs[to]);
		g.deleteVertex(v1);
		g.deleteVertex(v2);

		if(100*i/niters != prog)
		{
			prog = 100*i/niters;
			std::cout << prog << "%" << std::endl;
		}
	}
	std::cout << "took " << t.elapsed() << " ms" << std::endl;
}
Example #17
0
 void TelaPrincipal::leDados() {
     OrdemDeProducao * op = ops.at(0);
     if (estaNoSetup) {
         if (portaDeComunicacao->terminouSetup()) {
             tempoDeSetup->acabouSetup();
             apontamento->setTempoDeSetup(setup->getHoraFim() - setup->getHoraInicio());
             delete tempoDeSetup;
             delete setup;
             estaNoSetup = false;
             startaTempoDeProducao();
         } else {
             QTime horFim;
             setup->setHoraFim((horFim.currentTime().hour() * 60 * 60) + (horFim.currentTime().minute() * 60) + horFim.currentTime().second());
         }
     } else if (estaNaProducao) {
         if (portaDeComunicacao->terminouProducao(op->getQuantidadeProgramada())){
             tempoDeProducao->acabouProducao();
             tempoDeProducao->setaStatus(3);
             tempoDeProducao->gravaProducao();
             leDadosImpressora->stop();
             apontamento->setTempoDeProducao(producao->getHoraFim() - producao->getHoraInicio());
             //std::cout << "Tempo de Producao: " << producao->getHoraInicio() << " - " << producao->getHoraFim() << std::endl;
             apontamento->setQuantidadeProduzida(portaDeComunicacao->solicitaLeituraQtdTotal());
             ApontamentoDAO * apoDAO = new ApontamentoDAO(db);
             Maquina * maq = new Maquina(producao->getMaquina());
             apontamento->setMaquina(maq);
             apoDAO->insereApontamento(*apontamento);
             delete tempoDeProducao;
             delete producao;
             estaNaProducao = false;
             carrgaFilaDeProducao();
         } else {
             QTime horFim;
             producao->setHoraFim((horFim.currentTime().hour() * 60 * 60) + (horFim.currentTime().minute() * 60) + horFim.currentTime().second());
             producao->setContagem(portaDeComunicacao->solicitaLeituraQtdTotal());
         }
     }
 }
Example #18
0
/*
==============
<SLOTS>
==============
*/
void Qthreadcomport::newDataInPortSlot(int count)
{
	if ((bytesAvailable() == 0) || (!(isOpen()))) return; 
	const int size = 4096;
	char data[size];
    int readcount = readData(data, count);
	QTime timedb;
	timedb = timedb.currentTime();
	qDebug()<<"readData"<<"time= "<<"\t\t\t"<<timedb.second()<<" "<<timedb.msec();
	data[readcount] = '\0';
	
	unsigned char *dataPtr;
	dataPtr = (unsigned char *)&data;
	emit newDataInPortSignal(timedb, dataPtr,readcount);
}
void ScreenCap::LogInitLog()
{
#ifdef SC_LOG  //将发送网络的数据有效信息进行保存
    QDate date;
    QTime time;
    logfilename = date.currentDate().toString("sclogyyyy-MM-dd");
    logfilename += time.currentTime().toString("_HH-mm-ss");
    logfilename +=".log";
    plogFile = new QFile(logfilename);
    if(!plogFile)
    {
        qDebug() <<"Open file Err:" << logfilename;
        return ;
    }


    LogWriteFile("\nTcpWrite NetData Log!!\n==============>>>>Starting:\n");
    qDebug() <<"Log file:" << logfilename;
#endif


#ifdef SC_DATASTREAM_LOG  //将发送数据的内容进行保存,以二进制形式
    datafilename = date.currentDate().toString("scDatyyyy-MM-dd");
    datafilename += time.currentTime().toString("_HH-mm-ss");
    datafilename +=".mpg";
    pdataFile = new QFile(datafilename);
    if(!pdataFile)
    {
        qDebug() <<"Open file Err:" << datafilename;
        return ;
    }
    LogWriteDataFile("FFFEFFFE");
    qDebug() <<"Log file:" << datafilename;

#endif
}
Example #20
0
File: log.cpp Project: roiso/unisys
void Log::limpiarLabel(){
    ui->txtUsuario->clear();
    ui->txtPais->clear();
    ui->txtOwner->clear();
    ui->txtNego->clear();
    ui->txtContinente->clear();
    QDate local;
    local.setDate(local.currentDate().year(), local.currentDate().month(), local.currentDate().day());
    QTime hora;
    hora.currentTime();
    ui->date->setDate(QDate(local));
    ui->time->setTime(QTime(hora));
    ui->spinPlazas->cleanText();
    ui->txtOficina->clear();
    ui->labelEstado->clear();
}
Example #21
0
QString Patient:: getCurrentTime()
{
    QTime time;
    QDate date;
    QDate cDate = date.currentDate();
    QTime cTime = time.currentTime();
    QString year = QString("%1").arg(cDate.year(),4,10,QChar('0'));
    QString mon = QString("%1").arg(cDate.month(),2,10,QChar('0'));

    QString day = QString("%1").arg(cDate.day(),2,10,QChar('0'));
    QString hour = QString("%1").arg(cTime.hour(),2,10,QChar('0'));
    QString min = QString("%1").arg(cTime.minute(),2,10,QChar('0'));
    QString sec = QString("%1").arg(cTime.second(),2,10,QChar('0'));
    QString Time = QString("%1/%2/%3 %4:%5:%6").arg(year,mon,day,hour,min,sec);
    return Time;
}
Example #22
0
QString Patient::getPatientID()
{
    QTime time;
    QDate date;
    QDate cDate = date.currentDate();
    QTime cTime = time.currentTime();
    QString year = QString("%1").arg(cDate.year(),4,10,QChar('0'));
    QString mon = QString("%1").arg(cDate.month(),2,10,QChar('0'));

    QString day = QString("%1").arg(cDate.day(),2,10,QChar('0'));
    QString hour = QString("%1").arg(cTime.hour(),2,10,QChar('0'));
    QString min = QString("%1").arg(cTime.minute(),2,10,QChar('0'));
    QString sec = QString("%1").arg(cTime.second(),2,10,QChar('0'));
    QString patientID = QString("%1%2%3-%4%5%6").arg(year,mon,day,hour,min,sec);
    return patientID;
}
void MainWindow::image1(QImage image)
{

    //Modificar (pintar) la imagen para imprimirla en el label
    QTime time;
    QTime currenTime= time.currentTime();
    QString stringTime=currenTime.toString(); //hora actual pasado a cadena para poder pintarlo

    QPixmap pixmap(QPixmap::fromImage(image));

    QPainter painter(&pixmap); //convertimos el pixmap en un objeto QPainter para poder dibujar en el
    painter.setPen(Qt::white);
    painter.setFont(QFont("Arial", 15));
    painter.drawText(0, 0,pixmap.width(), pixmap.height(), Qt::AlignBottom, stringTime,0);

    ui_->label->setPixmap(pixmap); //establece la imagen pintada en el label

    if(connectedServer_)
    {
        //Codificar la imagen para enviarla por la red
        QBuffer buffer;
        QImageWriter writer(&buffer, "jpeg"); //Para controlar el nivel de compresión, el de gamma o algunos otros parámetros específicos del formato, tendremos que emplear un objeto QImageWriter.

        QImage imageSend; //creación de la imagen a enviar
        imageSend=pixmap.toImage(); //conversión del pixmap (con la hora pintada) en un QImage
        writer.setCompression(70);//codifica la imagen
        writer.write(imageSend); //aplicar lo anterior a la imagen

        QByteArray bytes = buffer.buffer();
        int sizeImg=bytes.size(); //tamaño de la imagen

        QString clientName = setting_->value("Client", "Leo").toString();
        QByteArray name;
        name.append(clientName); //nombre del cliente convertido a String para poder enviarlo

        qint64 timestamp = QDateTime::currentMSecsSinceEpoch(); //tiempo en milisegundos desde EPOC hasta el instante de la imagen

        //Envio de los distintos campos separados por \n
        tcpSocket_->write(name);
        tcpSocket_->write("\n");
        tcpSocket_->write(QByteArray::number(timestamp));
        tcpSocket_->write("\n");
        tcpSocket_->write(QByteArray::number(sizeImg));
        tcpSocket_->write("\n");
        tcpSocket_->write(bytes);
    }
}
Example #24
0
/*QReceiveThread*/
void ReceiveThread::run()
{
	int count;
	forever 
	{
		msleep(1);
		mutex.lock();
		count = comport->bytesAvailable();
		mutex.unlock();
		if (0 < count)
		{
			emit newDataInPortThread(count);
			QTime timedb;
			qDebug()<<"thread count= "<<count<<"time= "<<"\t"<<timedb.currentTime().second()<<" "<<timedb.currentTime().msec();
		}
	}
}
void Widget::pressedSend()
{
    if(ui->lineEdit->text() != "")
    {
        QString text, temp;
        QTime time;
        text = ui->lineEdit->text();
        ui->lineEdit->clear();
        time = time.currentTime();
        temp = time.toString("HH:mm:ss") + ":  " + text;
        temp.push_front("<b>");
        temp.append("</b>");
        ui->textBrowser->append(temp);

        // Send the message to all threads
        emit message(temp);
    }
}
Example #26
0
void MainWindow::on_Enter_clicked()
{
    todolist = ui->lineEdit->text();
    totaltoString = datetoString + '\0' + timetoString  + '\0' + todolist;
    ui->textBrowser->append(totaltoString);


    clock = new QTimer;
    clock->setInterval(1000);
    connect(clock, SIGNAL(timeout()), this, SLOT(updateTime()));

    current_time = current_time.currentTime();
    clock->start();

    QFile nfile("todolist.txt");
    if(nfile.open(QFile::Append|QFile::Text))
    {
        QTextStream out(&nfile);
        out << totaltoString << endl;
    }
}
Example #27
0
void Logger::printLog(const char *content, const LogType logType) {
    if (logType >= Logger::DEBUG_LOG) {
        std::ofstream out;

//        QString outPath = QString(global::OUTPUT_PATH);
//        outPath = outPath + "/" + id_ + ".log.txt";
        out.open(QDir::toNativeSeparators(outputPath_).toStdString().c_str(), std::ofstream::out | std::ofstream::app);
        std::string msg("");
        switch (logType) {
        case Logger::DEBUG_LOG:
            msg = "[DEBUG]";
            break;
        case Logger::INFO_LOG:
            msg = "[INFO]";
            break;
        case Logger::WARN_LOG:
            msg = "[WARN]";
            break;
        case Logger::ERROR_LOG:
            msg = "[ERROR]";
            break;
        default:
            break;
        }
        if (!tip_.isEmpty()) {
            msg = msg.append("[").append(tip_.toStdString()).append("]");
        }
        QTime time;
        out << time.currentTime().toString("hh:mm:ss:zzz").toStdString()
            << " : "
            << msg
            << " "
            << content
            << std::endl;
        out.close();
    }
    if (logType == Logger::ERROR_LOG) {
        QCoreApplication::exit();
    }
}
Example #28
0
void MainWindow::on_pushButton_load_clicked()
{
    QFile file("todo.txt");
    if(file.open(QIODevice::ReadOnly))
    {

        QString line;
        QTextStream in(&file);
        while(!in.atEnd())
        {
            line=in.readLine();
            QStringList strList = line.split(",");
            //qDebug() << strList[0] <<strList[1] <<strList[2];
            QDate date;
            date = QDate::fromString(strList[0],"yyyy/MM/dd");
            //qDebug() << date;
            QTime time;
            time = QTime::fromString(strList[1],"HH:mm");
            QDate nowdate;
            nowdate=nowdate.currentDate();
            QTime nowtime;
            nowtime=nowtime.currentTime();
            ui->textBrowser_2->append(line);
            if(date==nowdate&&time.addSecs(-30*60)<nowtime&&time>nowtime)
            {
                //ui->textBrowser_2->clear();
                ui->textBrowser_2->setTextColor(2000);
                ui->textBrowser_2->append("It's time to "+  strList[2]);
                qDebug() << "It's time to " << strList[2];
                ui->textBrowser_2->setTextColor(1);


        }
        }
    }
    else{
    qDebug() << "Fail";
  }
}
Example #29
0
bool DeviceTestTab::compressANDUploadLogFileSlot()
{
	//打包文件夹
	username = QString::fromStdString((RunningProfile::getInstance()->user_uri()));
	int index = username.indexOf( "@" );
	if( index > 0 )
		username = username.left( index );
	
	QDateTime dt;  
	QTime time;  
	QDate date;  
	dt.setTime(time.currentTime());  
	dt.setDate(date.currentDate());  
	compressFileName = username+"_"+ dt.toString("yyyy_MM_dd_hh_mm_ss")+".zip";
	//QString fileName = username+".zip";

	int result=-1;
	
	ui.testResultText->setText(QString::fromLocal8Bit("打包文件中......"));

	result=zip.Create(compressFileName);
	if(result<0)
	{
		ui.testResultText->setText(QString::fromLocal8Bit("创建打包文件失败"));

		return false;
	}

	result=zip.Add("log", "log");
	if(result<0)
	{
		ui.testResultText->setText(QString::fromLocal8Bit("打包失败"));
		return false;
	}
		
	zip.Close();
	return true;
}
Example #30
0
void MainWindow::updateTime()
{

    time = time.currentTime();
    qDebug() << time.toString("hh:mm:ss.zzz");

    //timeSequence.append(time.toString("hh:mm:ss.zzz"));

    t = choose_time.addSecs(-60*30);

    //qDebug() << choose_time.toString("hh:mm:ss.zzz");
    //qDebug() << t;
    //qDebug() << current_time.toString("hh:mm:ss");
    //clock->start();
    if(time >= t)
    {
        clock->stop();
        ui->warning->append("warning!!!");
    }
    //QDateTime date;
    //date = date.currentDateTime();
    //qDebug() << date.toString("yyyy-MM-dd");
}