void startwindow::on_pushButton_clicked() { if(*comPortUserp==PDCCOMPORTFREE||*comPortUserp==PDCCOMPORTUSER) { if(portOn) opi_closeucd_com(&com); if(!firstfile) fclose(file); firstfile=true; *comPortUserp = PDCCOMPORTFREE; hide_check_pdn(); portOn = false; if(opi_openucd_com(&com)==0) { portOn = true; *comPortUserp = PDCCOMPORTUSER; get_opipkt_total=opiucd_getPDN(); if(!get_opipkt_total) { show_message.setText("there is no pdn devices"); show_message.show(); show_message.exec(); } else show_check_pdn(); //after open comport if no pdn is showing then close the comport if(pdnshowcountp==0) { if(portOn) opi_closeucd_com(&com); portOn=false; *comPortUserp = PDCCOMPORTFREE; if(!firsttimer) this->killTimer(timeid); if(!firstfile) fclose(file); firsttimer=true; firstfile=true; } } else { portOn = false; *comPortUserp = PDCCOMPORTFREE; show_message.setText("Connect the Device again"); show_message.show(); show_message.exec(); } }//other device doesn't use comport else //other device uses comport { show_message.setText("Comport is busy,try again later"); show_message.show(); show_message.exec(); } }
void startwindow::showEvent(QShowEvent *) { if(*comPortUserp==PDCCOMPORTFREE||*comPortUserp==PDCCOMPORTUSER) { if(portOn) opi_closeucd_com(&com); hide_check_pdn(); portOn = false; if(opi_openucd_com(&com)==0) { portOn = true; *comPortUserp = PDCCOMPORTUSER; get_opipkt_total=opiucd_getPDN(); if(!get_opipkt_total) { show_message.setText("there is no pdn devices"); show_message.show(); show_message.exec(); } else show_check_pdn(); } else { portOn = false; *comPortUserp = PDCCOMPORTFREE; show_message.setText("Connect the Device again"); show_message.show(); show_message.exec(); } //if all showdatawindow are close then close the comport if(!sdw[0]->isVisible()&&!sdw[1]->isVisible()&&!sdw[2]->isVisible()&&!sdw[3]->isVisible()&&!sdw[4]->isVisible()) { if(portOn) opi_closeucd_com(&com); if(!firstfile) fclose(file); firstfile=true; portOn = false; *comPortUserp = PDCCOMPORTFREE; } }//comport free for pdc else { show_message.setText("Comport is busy,try again later"); show_message.show(); show_message.exec(); } }
void startwindowbf::on_pushButton_2_clicked() { OPIPKT_t opipkttmp; quint8 tempui8arr[512]; int i; //re open the comport if((*comPortUserp==BFCOMPORTFREE||*comPortUserp==BFCOMPORTUSER)&&(!gamemode)) { if(portOn) opi_closeucd_com(&com); if(!firstfile) fclose(file); firstfile=true; *comPortUserp = BFCOMPORTFREE; hide_check_pdn(); portOn = false; if(opi_openucd_com(&com)==0) { portOn = true; *comPortUserp = BFCOMPORTUSER; get_opipkt_total=opiucd_getPDN(); if(!get_opipkt_total) { show_message.setText("there is no pdn devices"); show_message.show(); show_message.exec(); return ; } else show_check_pdn(); } else { portOn = false; *comPortUserp = BFCOMPORTFREE; show_message.setText("Connect the Device again"); show_message.show(); show_message.exec(); return ; } }//other device doesnt use comport else if((*comPortUserp==BFCOMPORTFREE||*comPortUserp==TGCOMPORTUSER)&&(gamemode)) { if(portOn) opi_closeucd_com(&com); if(!firstfile) fclose(file); firstfile=true; *comPortUserp = BFCOMPORTFREE; hide_check_pdn(); portOn = false; if(opi_openucd_com(&com)==0) { portOn = true; *comPortUserp = TGCOMPORTUSER; get_opipkt_total=opiucd_getPDN(); if(!get_opipkt_total) { show_message.setText("there is no pdn devices"); show_message.show(); show_message.exec(); return ; } else show_check_pdn(); } else { portOn = false; *comPortUserp = BFCOMPORTFREE; show_message.setText("Connect the Device again"); show_message.show(); show_message.exec(); return ; } }//other device doesnt use comport else { show_message.setText("Comport is busy,try again later"); show_message.show(); show_message.exec(); return ; } //re open the comport end if(!(portOn)) { *comPortUserp = BFCOMPORTFREE; show_message.setText("You have to connect a Device"); show_message.show(); show_message.exec(); return ; } else if(Show_count==0) { show_message.setText("You have to choose Devices"); show_message.show(); show_message.exec(); return ; } else { if(!gamemode) *comPortUserp = BFCOMPORTUSER; else *comPortUserp = TGCOMPORTUSER; //if user show the showdatawindow,user can't control whether write file or not ui->checkWriteFileBox->setDisabled(true); if(!firstfile) fclose(file); //regulatefilename = userfilename; opiucd_status(&com, &opipkttmp); // should have opened device successfully before QDateTime stDT = QDateTime::currentDateTime(); regulatefilename = QString("D%1_ALL").arg(stDT.toString("yyyyMMdd_hhmmss")); if(ui->checkWriteFileBox->isChecked()) //if true then write it { firstfile=false; file = fopen(regulatefilename.append(".opi").toAscii().data(), "wb+"); // write opihdr information fwrite(opipkttmp.payload, 1, OPIUCDSTLEN-1, file); for(i = 0; i < (512-(OPIUCDSTLEN-1)); i++) tempui8arr[i] = 0xFF; fwrite(tempui8arr, 1, (512-(OPIUCDSTLEN-1)), file); } else firstfile=true; //check which the pdn the user what to show for(i=1;i<OPIWANT_MAX_BF+1;i++) { if(pdnOn[i]) //if the user choose the pdn then we open the showdatawindow { qDebug()<<"sdw "<<i<<"= "<<sdw[i]; if(!sdw[i]->already_open) //if already open we will not open and reset again { firstpdn[i]=false; sdw[i]->reset(gamemode); sdw[i]->setPdnNum(PDN_NUMBER[i]); if(gamemode) { sdw[i]->showgamewindow(PDN_NUMBER[i]); sdw[i]->secretstart(gamemode); } else sdw[i]->show(); } } else //if the user don't choose the pdn then we close the showdatawindow { if(sdw[i]->isVisible()) { sdw[i]->close(); sdw[i]->already_open=false; } } } //to avoid reopening timer if(firsttimer) { timeid=QObject::startTimer(startwindow_fresh_time_BF); firsttimer=false; } } }