/** Trato de instalarla automaticamente el ghostscript*/ void GsRenderEngine::install(){ QProcess proc; QString txt=tr("No se enconcuentra %1. Proceda instalar manualmente").arg(m_strInstaller); if (!QFile::exists(m_strInstaller)){ QMessageBox::information(0,"ERROR",txt,QMessageBox::Ok); return; } proc.start(m_strInstaller); if (proc.waitForStarted()){ if (proc.waitForFinished()){ txt=tr("Instalado %1").arg(m_strInstaller); QMessageBox::information(0,"INFO",txt,QMessageBox::Ok); emit SendDebugInfo(LOGGER_DEBUG,txt); } else{ txt=tr("No pudo finalizar %1").arg(m_strInstaller); QMessageBox::information(0,"ERROR",txt,QMessageBox::Ok); emit SendDebugInfo(LOGGER_DEBUG,txt); } } else{ txt=tr("No pudo iniciarse %1").arg(m_strInstaller); QMessageBox::information(0,"ERROR",txt,QMessageBox::Ok); emit SendDebugInfo(LOGGER_DEBUG,txt); } }
/** Flanco en secuencia_On*/ void In2GestorMaquina::_sltOPCSecuenciaOn(){ //Comienza la impresion if (m_memoryMap->m_mapa.m_maquina.secuencia_on){ emit SendDebugInfo(LOGGER_WARNING,"_sltOPCSecuenciaOn 1"); m_gestorMaquina->sltHabilitarFreno(true); m_memoryMap->m_mapa.m_maquina.InicioSecuenciaAutomatico=0x01; m_memoryMap->m_mapa.m_maquina.EstadoSecuenciaAutomatico=0x01; m_memoryMap->m_mapa.m_maquina.ParadaDiametro=false; bool condiciones=ComprobacionesPreviasImpresion(); if (condiciones){ //Tiene que haber imagen enviada if (m_memoryMap->m_ImagenEnviada==false) { int respuesta=QMessageBox::question(0,"ATENCION","No hay imagen enviada\n¿Está seguro que desea continuar?","Si","No",QString::null, 0, 1 ); if (respuesta==0){ //En eset caso obviamos el filtro de maculas //m_memoryMap->m_mapa.m_impresion.m_fltrMacula.bMonitorMacula=false; sltLaunchPrint(); } else{ //Tiramos de nuevo las condiciones de movimiento m_gestorMaquina->sltEnableCondicionesMovimiento(); } } else{ sltLaunchPrint(); } } else{ //No se dan las condiciones de impresion //Tiramos de nuevo las condiciones de movimiento m_gestorMaquina->sltEnableCondicionesMovimiento(); } } else{ //Paramos //emit sgnInitImpresion(false); emit SendDebugInfo(LOGGER_WARNING,"_sltOPCSecuenciaOn 0"); m_memoryMap->m_ImagenEnviada=false; m_startDelayed=false; //Es un softstop if (m_memoryMap->m_mapa.m_maquina.codigo_parada==0){ //Aqui softstopear SoftStop(); } else{ //Es una parada de emergencia //QString valor_codigo_parada=QString("%1").arg(m_memoryMap->m_mapa.m_maquina.codigo_parada); //emit SendDebugInfo(LOGGER_WARNING,QString("Realizando parada %1").arg(valor_codigo_parada)); //Insertar_Evento(ERROR_MAQUINA,valor_codigo_parada); EmergencyStop(FIN_EMERGENCIA); //Se quitan los jogs por si acasol GestorMaquina *gM= GestorMaquina::request(this); if (gM){ gM->sltJogMenosOff(); gM->sltJogMenosOff(); } } } }
/** Comienza la impresion*/ void In2GestorMaquina::sltLaunchPrint(){ emit SendDebugInfo(LOGGER_WARNING,"sltLaunchImpresion"); emit sgnChangeState(THEME_PRINTING); m_Printing=true; m_elapsedTimer.start(); m_memoryMap->m_mapa.m_maquina.metros_Offset=m_memoryMap->m_mapa.m_maquina.metros_trabajo; //Un primer diametro correcto /*if (m_memoryMap->m_mapa.m_maquina.diametro_bobina_salida<DIAMETRO_ARRANQUE){ m_gestorMaquina->sltSetDiametroSalida(DIAMETRO_ARRANQUE); }*/ //m_gestorMaquina->sltSetDiametroSalida(DIAMETRO_ARRANQUE); In2ManagerDiametros *manager=In2ManagerDiametros::request(0); MonitorDiametro *m=manager->getMonitor(IN2MANAGER_DIN); if (!m->isEnabled()){ m_gestorMaquina->sltSetDiametroEntrada(DIAMETRO_ARRANQUE); } m=manager->getMonitor(IN2MANAGER_DOUT); if (!m->isEnabled()){ m_gestorMaquina->sltSetDiametroSalida(DIAMETRO_ARRANQUE); } QTimer::singleShot(1000,m_gestorMaquina,SLOT(initImpresion())); //m_gestorMaquina->initImpresion(); QTimer::singleShot(1250,this,SLOT(sltEnableMonitoring())); }
/** Condicion de fichero*/ bool In2SaiControl::testCondicionFichero(){ bool rtn=false; if (QFile::exists(m_strFile)) { QFile::remove(m_strFile); emit SendDebugInfo(LOGGER_ERROR,QString("SAIControl->Condicion de fichero")); rtn=true; } return rtn; }
/** Chequea el Scan*/ void In2ColaImpresionMono::_sltCheckAndLoad(){ MemoryMap *memoryMap=MemoryMap::request(0); QString scan=ui->m_leScanBarcode->text(); In2ManagerERP *erp=In2ManagerERP::request(0); QString req=erp->getValueFromERP(in_COD_BULTO_PADRE); if (!req.compare(scan)){ QString txt=QString("Generando Imagen...por favor espere"); ui->m_pbExit->setEnabled(false); ui->m_pbLoad->setEnabled(false); ui->m_pbLoadScan->setEnabled(false); ui->m_pbLog->setEnabled(false); QApplication::setOverrideCursor(Qt::BusyCursor); QCoreApplication::processEvents(); sltInfoMessage(txt); setCheckERP(false); deleteTempGSFile(); memoryMap->JumpToTempWorld(); In2ImageCreator p; p.Convert(); p.sltGenerateImage(); m_workLoaded=true; //if (!erp->orderPending()) if (!m_pedingOrder) erp->sltWriteAnswerToBBDD(SGL_STATE_FIN,""); txt=tr("Trabajo %1 cargado").arg(memoryMap->m_mapa.m_variables.NombreRutaIni); emit SendDebugInfo(LOGGER_STORE,txt) ; QApplication::restoreOverrideCursor(); ui->m_pbExit->setEnabled(true); ui->m_pbLoad->setEnabled(true); ui->m_pbLoadScan->setEnabled(true); ui->m_pbLog->setEnabled(true); QTimer::singleShot(0,this,SLOT(sltShowImage())); //QTimer::singleShot(0,this,SLOT(sltExit())); //Cargar trabajo } else{ QString txt=tr("Error Scan ,leido %1, esperado %2").arg(scan).arg(req); sltInfoMessage(txt); emit SendDebugInfo(LOGGER_ERROR,txt); } m_pendingScan=false; }
/** Apagado de maquina*/ void In2SaiControl::shutdown(){ ClienteOPC *opc=ClienteOPC::request(0); opc->setEnabled(false); //Deshabilito el cliente OPC In2GestorFluidica *gestor=In2GestorFluidica::request(0); for (int x=0;x<gestor->numEquipos();x++){ gestor->ShutdownEquipo(x); emit SendDebugInfo(LOGGER_ERROR,QString("Apagando equipo %1").arg(x)); } m_bMonitor=false; //Ya no monitorizamos mas emit sgnSAIActive(); }
/** Devuelve datos*/ QStringList In2Counters::getRecord(QString query){ QStringList data; QString strPath=QString("%1\\Database\\%2").arg(QApplication::applicationDirPath()).arg(DEFAULT_COUNTERS_FILE); if (m_db.open(QString("QSQLITE"),QString("In2Counter"),strPath)){ QString tmp=QString("%1").arg(query); emit SendDebugInfo(LOGGER_WARNING,tmp); if (m_db.exec(tmp)){ data=m_db.m_Tabla; } else { QString error=m_db.getLastError(); emit SendDebugInfo(LOGGER_ERROR,error); } m_db.close(); } else{ emit SendDebugInfo(LOGGER_ERROR,"No se pudo abrir In2Counter.sqlite"); } return data; }
/** Añade un record*/ bool In2Counters::addRecord(QString path,int time,int meters,int count,QString txt,QString OT){ bool rtn=false; struct In2counterRecord record; QString strPath=QString("%1\\Database\\%2").arg(QApplication::applicationDirPath()).arg(DEFAULT_COUNTERS_FILE); if (m_db.open(QString("QSQLITE"),QString("In2Counter"),strPath)){ /*QString tmp=QString("select * from Trabajos"); m_db.exec(tmp.toAscii().data());*/ QDateTime dateTime=QDateTime::currentDateTime(); record.m_path=path; record.m_meters=QString("%1").arg(meters); record.m_count=QString("%1").arg(count); record.m_finishComment=txt; record.m_elapsedTime=QString("%1").arg(time); record.m_PrintDate=dateTime.toString("yyyy-MM-dd hh:mm:ss"); record.m_InitDate=dateTime.addMSecs((-1)*time).toString("yyyy-MM-dd hh:mm:ss"); record.m_OT=OT; QString tmp=QString("insert into %1 ('Path','Inicio','Fin','Metros','Impresiones','Comentario','OT') Values ('%2','%3','%4','%5','%6','%7','%8')") .arg(TABLA_IN2TRABAJOS) .arg(record.m_path) .arg(record.m_InitDate) .arg(record.m_PrintDate) .arg(record.m_meters) .arg(record.m_count) .arg(record.m_finishComment) .arg(record.m_OT); emit SendDebugInfo(LOGGER_WARNING,tmp); if (m_db.exec(tmp)) rtn=true; else { QString error=m_db.getLastError(); emit SendDebugInfo(LOGGER_ERROR,error); } m_db.close(); } else{ emit SendDebugInfo(LOGGER_ERROR,"No se pudo abrir In2Counter.sqlite"); } return rtn; }
/** Genear y ejecuta el comando*/ int GsRenderEngine::render(){ int rtn=-1; QFileInfo info(m_strInputFile); QString suffix=info.completeSuffix(); //Si es un pdf procedo como siempre a renderizar if (!suffix.compare("pdf",Qt::CaseInsensitive)){ if (testGsInstallation()){ QString tmp=m_strOutputFile; if (m_doubleRes){ //Si es con doble resolucion, lo hago en dos pasos QFile::remove(TEMP_GS_FILE); m_strOutputFile=TEMP_GS_FILE; } m_command=QString("\"%1\" -sOutputFile=\"%2\" -r%3 -sDEVICE=%4 -sOutputICCProfile=\"%5\" -dNOPAUSE -dBATCH %6 \"%7\"").arg(m_strExecutable).arg(m_strOutputFile).arg(m_strResolution).arg(m_strDevice).arg(m_strICCFile).arg(m_strExtraOptions).arg(m_strInputFile); //m_command=QString("\"%1\" -sOutputFile=\"%2\" -r%3 -sDEVICE=%4 -sOutputICCProfile=\"%5\" -dNOPAUSE -dBATCH %6 \"%7\"").arg(m_strExecutable).arg(outputFoo).arg(m_strResolution).arg(m_strDevice).arg(m_strICCFile).arg(m_strExtraOptions).arg(localFile); //emit SendDebugInfo(LOGGER_ERROR,tr("%1 - %2").arg(localFile).arg(outputFoo)); QProcess convertgs; rtn=convertgs.execute(m_command); qDebug()<<m_command; emit SendDebugInfo(LOGGER_WARNING,m_command); if (m_doubleRes){ QImage *tmpImage=new QImage(m_strOutputFile); m_strOutputFile=tmp; int width=tmpImage->width(); int height=tmpImage->height(); QImage *dest=new QImage(width/2,height,tmpImage->format()); dest->fill(Qt::white); for (int x=0;x<width;x=x+2){ for (int y=0;y<height;y++){ dest->setPixel(x/2,y,tmpImage->pixel(x,y)); } } dest->save(m_strOutputFile); delete (dest); delete (tmpImage); } } } //Detecto que es una imagen else if ((!suffix.compare("png",Qt::CaseInsensitive))|| (!suffix.compare("jpeg",Qt::CaseInsensitive))||(!suffix.compare("jpg",Qt::CaseInsensitive))||(!suffix.compare("bmp",Qt::CaseInsensitive))||(!suffix.compare("tif",Qt::CaseInsensitive))){ //Si es un archivo de imagen QPixmap dummy=QPixmap(m_strInputFile); if (!dummy.isNull()){ dummy.save(QString("%1").arg(m_strOutputFile),"bmp"); rtn=1; } } return rtn; }
void ReadHeight(void) { while(TMR5GIF == 0); TMR5GIF = 0; time_height = 0; time_height = TMR5H; time_height <<= 8; time_height |= TMR5L; TMR5L = 0; TMR5H = 0; a_frame[0].height = time_height; #ifdef DEBUG //SendDebugInfo(time_height); SendDebugInfo(a_actors[0].thro); #endif a_frame_dif[0].dif_height = a_frame[1].height - a_frame[0].height; Trigger = 1; }
/** Vienen datos del ERP (tabla de salida)*/ void In2ColaImpresionMono::sltDataFromERPOut(const QStringList & p){ In2ManagerERP *gestor=In2ManagerERP::request(0); QStringList data=p; if (data.count()){ ui->m_twDataOut->clearContents(); QStringList strlstHeaders=gestor->getItem(ERP_FIELDS_BBDD_OUT).split("@"); int nHeaders=strlstHeaders.count(); if (nHeaders<=p.count()){ ui->m_twDataOut->setRowCount(nHeaders); ui->m_twDataOut->setVerticalHeaderLabels(strlstHeaders); for (int x=0;x<nHeaders;x++){ QTableWidgetItem *item=new QTableWidgetItem(p.at(x)); Qt::ItemFlags flags=0; item->setFlags(flags); ui->m_twDataOut->setItem(x,0,item); } } else{ emit SendDebugInfo(LOGGER_ERROR,tr("sltDataFromERPOut expected %1 items got %2").arg(nHeaders).arg(p.count())); emit } }
/** Condiciones de control*/ bool In2SaiControl::testCondicionRed(){ bool rtn=false; static int counter=0; In2Ping foo; if (!foo.ping(IP_CONTROL)){ emit SendDebugInfo(LOGGER_ERROR,QString("SAIControl->Condicion de red")); counter++; m_timer=TIMEOUT_TEST_SAI_FAST; if (counter==NET_WARNING){ rtn=true; } } else{ counter=0; m_timer=TIMEOUT_TEST_SAI; } QTime time=QTime::currentTime(); int marca=time.msec(); if (marca==TIMEOUT_SAVE) emit sgnError(0xFF); return rtn; }
/** Flanco en codigo de parada*/ void In2GestorMaquina::_sltOPCCodigoParada(){ //Es diferente de cero...emergencia if (m_memoryMap->m_mapa.m_maquina.codigo_parada){ //El codigo viene del reves unsigned char cCodigoParada=(unsigned char)((m_memoryMap->m_mapa.m_maquina.codigo_parada&0xFF00)>>8); unsigned char cCodigoParada2=(unsigned char)(((char)m_memoryMap->m_mapa.m_maquina.codigo_parada&0x00FF)); unsigned int code=cCodigoParada+(cCodigoParada2*256); m_gestorMaquina->sltHabilitarCalculoDiametro(0); //Deshabilitra por sia acaso m_gestorMaquina->sltSetCondicionesIniciales(); //Quitamos imagen ante una emergencia GestorImpresion *gI=GestorImpresion::request(0); gI->FullDisablePrintMode(); if (code&EMERGENCIA_SETA) emit SendDebugInfo(LOGGER_ERROR,QString("Seta de emergencia [%1]").arg(code)); else{ if (code&EMERGENCIA_VARSALIDA) emit SendDebugInfo(LOGGER_ERROR,QString("Fallo en variador salida [%1]").arg(code)); if (code&EMERGENCIA_VARENTRADA) emit SendDebugInfo(LOGGER_ERROR,QString("Fallo en variador entrada [%1]").arg(code)); if (code&EMERGENCIA_ARRASTRE) emit SendDebugInfo(LOGGER_ERROR,QString("Fallo en arrastre [%1]").arg(code)); if (code&EMERGENCIA_BANDEJA) emit SendDebugInfo(LOGGER_ERROR,QString("Bandeja fuera de posición [%1]").arg(code)); if (code&EMERGENCIA_MESA) emit SendDebugInfo(LOGGER_ERROR,QString("Mesa de impresión fuera de posición [%1]").arg(code)); if (code&EMERGENCIA_CAPOTA) emit SendDebugInfo(LOGGER_ERROR,QString("Capota abierta [%1]").arg(code)); if (code&EMERGENCIA_PRESION) emit SendDebugInfo(LOGGER_ERROR,QString("Presión de aire insuficiente [%1]").arg(code)); if (code&EMERGENCIA_LAMPARA_ELECTRICO) emit SendDebugInfo(LOGGER_ERROR,QString("Fallo eléctrico de lámpara [%1]").arg(code)); if (code&EMERGENCIA_LAMPARA_APAGADA) emit SendDebugInfo(LOGGER_ERROR,QString("Lámpara apagada [%1]").arg(code)); if (code&EMERGENCIA_DESPLAZADOR_LAMPARA) emit SendDebugInfo(LOGGER_ERROR,QString("Desplazador lámpara [%1]").arg(code)); } //QString valor_codigo_parada=QString("%1").arg(code); //Insertar_Evento(PARO_MAQUINA,valor_codigo_parada); emit sgnShowLog(); //ChangeStyle(THEME_EMERGENCY); emit sgnChangeState(THEME_EMERGENCY); }
In2ColaImpresionMono::In2ColaImpresionMono(QWidget *parent) : ui(new Ui::In2ColaImpresionMono) { ui->setupUi(this); this->setWindowFlags(Qt::CustomizeWindowHint); this->setWindowModality(Qt::ApplicationModal); m_parent=parent; m_actualOT.clear(); In2ManagerERP *p=In2ManagerERP::request(0); connect(p,SIGNAL(sgnERPWorkLoaded(int)),this,SLOT(sltWorkLoaded(int))); connect(p,SIGNAL(sgnMessage(QString)),this,SLOT(sltInfoMessage(QString))); ui->m_gbTableIn->setTitle(p->getItem(ERP_TABLE_IN)); ui->m_gbTableOut->setTitle(p->getItem(ERP_TABLE_OUT)); ui->m_twData->setColumnCount(1); QString name=p->getItem(ERP_TABLE_IN); ui->m_twData->setHorizontalHeaderLabels(QStringList()<<name); ui->m_twCurrentData->setColumnCount(1); name=p->getItem(ERP_TABLE_IN); ui->m_twData->setHorizontalHeaderLabels(QStringList()<<name); ui->m_twDataOut->setColumnCount(1); name=p->getItem(ERP_TABLE_OUT); ui->m_twDataOut->setHorizontalHeaderLabels(QStringList()<<name); #if QT_VERSION>=0x050000 ui->m_twData->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::Stretch ); ui->m_twDataOut->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); #else ui->m_twData->horizontalHeader()->setResizeMode( 0, QHeaderView::Stretch ); ui->m_twDataOut->horizontalHeader()->setResizeMode(QHeaderView::Stretch); ui->m_twCurrentData->horizontalHeader()->setResizeMode(QHeaderView::Stretch); #endif m_pendingScan=false; m_workLoaded=false; //Cargamos el scene y el view m_view=new In2GraphicsView(ui->m_gv); m_scene=NULL; m_scene=new In2GraphicsScene(0,0,0,0); In2GraphicsPixmapItem *item=new In2GraphicsPixmapItem(0,0,false); m_scene->addItem(item); ui->m_gv->setScene(m_scene); ui->m_gv->fitInView(item,Qt::KeepAspectRatio); ui->m_gv->show(); connect(ui->m_pbExit,SIGNAL(clicked()),this,SLOT(sltExit())); connect(ui->m_pbLoad,SIGNAL(clicked()),this,SLOT(sltLoad())); connect(ui->m_pbClearInfoMessage,SIGNAL(clicked()),this,SLOT(sltClearInfoMessage())); InkjetDebug *inkjetDebug=InkjetDebug::request(0); connect(ui->m_pbLog,SIGNAL(clicked()),inkjetDebug,SLOT(showLog())); //connect(ui->actionERP) connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(sltExit())); connect(ui->actionLoad_Config,SIGNAL(triggered()),this,SLOT(sltLoad())); connect(ui->actionShow_Log,SIGNAL(triggered()),inkjetDebug,SLOT(showLog())); connect(ui->m_pbLoadScan,SIGNAL(clicked()), this,SLOT(sltFocusScan())); connect(ui->m_leScanBarcode,SIGNAL(textEdited(QString)),this,SLOT(sltCheckAndLoad())); //ui->m_leScanBarcode->setFocus(); ui->m_leScanBarcode->setEnabled(false); ui->m_pbLoadScan->setEnabled(false); Qt::WindowFlags flags=this->windowFlags(); flags|=Qt::CustomizeWindowHint; this->setWindowFlags(flags); m_bCheckERP=true; m_pedingOrder=false; In2ManagerERP *erp=In2ManagerERP::request(0); if (erp->orderPending()){ m_pedingOrder=true; QStringList data=erp->lstOrderPending(); if (data.count()){ ui->m_twCurrentData->clearContents(); QStringList strlstHeaders=erp->getItem(ERP_FIELDS_BBDD_IN).split("@"); int nHeaders=strlstHeaders.count(); if (nHeaders<=data.count()){ ui->m_twCurrentData->setRowCount(nHeaders); ui->m_twCurrentData->setVerticalHeaderLabels(strlstHeaders); for (int x=0;x<nHeaders;x++){ QTableWidgetItem *item=new QTableWidgetItem(data.at(x)); Qt::ItemFlags flags=0; item->setFlags(flags); ui->m_twCurrentData->setItem(x,0,item); } } else{ emit SendDebugInfo(LOGGER_ERROR,tr("sltDataFromPendingOrder expected %1 items got %2").arg(nHeaders).arg(data.count())); //emit } } } else{ QTimer::singleShot(0,this,SLOT(sltCheckERP())); QTimer::singleShot(0,this,SLOT(sltCheckERPOut())); } this->show(); //QTimer::singleShot(0,this,SLOT(_sltCheckAndLoad())); }