//Goes to the end of the file, checks the length, and then goes to the start. unsigned long long FileIO::getFileLength() { fileLength = 0; unsigned long long returnInt; if(!isBinary){//Not a binary file, therefore it is a text file goStart(1); std::string line; while (std::getline(myfile, line)){ fileLength = fileLength + line.length() + 1;//Length of string plus null terminator } goStart(1); } if (isBinary){ std::streampos fsize = 0; goEnd(1); fileLength = myfile.tellg() - fsize; goStart(1); } returnInt = fileLength; return returnInt; }
boost_ec UdpPointImpl::Send(const void* data, size_t bytes) { boost_ec ec; if (!init_) { ec = goStart(local_addr_); if (ec) return ec; } std::size_t n = socket_->send(buffer(data, bytes), 0, ec); if (ec) return ec; if (n < bytes) return MakeNetworkErrorCode(eNetworkErrorCode::ec_half); return boost_ec(); }
boost_ec UdpPointImpl::Connect(endpoint addr) { boost_ec ec; if (!init_) { ec = goStart(local_addr_); if (ec) return ec; } socket_->connect(addr, ec); if (!ec) { remote_addr_ = addr; if (opt_.connect_cb_) opt_.connect_cb_(GetSession()); } return ec; }
void RecipeView::update(){ //console() << ":::TIMED OUT:::" << endl; if((curStep==0 && stepState==0) || stepState==1){ // it's already at the start, or if it's on a video... delayTimeOut(); } else { double curTime = getElapsedSeconds(); if((curTime-lastTouched)>timeOut){ console() << "going to start: " << recipeModel.name << endl; goStart(); } } for(int i=0;i<videos.size();i++){ if(i!=curStep){ // videos.at(i).stop(); } } if(stepState==1){ if(videos.size()>curStep){ videos.at(curStep).update(); if(videos.at(curStep).isDone()) forwardRelease(); } } char buffer [40]; sprintf (buffer, "curStep: %i \n stepState: %i", curStep, stepState); TextLayout layout; layout.clear( ColorA( 0.5f, 0.5f, 0.5f, 0.5f ) ); layout.setFont( Font( "Arial", 18 ) ); layout.setColor( Color( 1, 1, 1 ) ); layout.addLine(recipeModel.name.c_str()); layout.addLine( buffer); Surface8u rendered = layout.render( true, false ); text_texture = gl::Texture( rendered ); // this needs work here.... // this is specifically to handle a goStart() situation... if(prevStepState==0 && stepState == 0 && prevStep!=curStep){ console() << "THIS SHOULD BE FIRING on TIMEOUT >>> " << recipeModel.name << endl; if(images.size()>prevStep) images.at(prevStep).hide(); if(images.size()>curStep) images.at(curStep).show(); prevStep = curStep; } else { if(prevStep!=curStep){ // moved from video to new start image // load both the image and the video for the new step if(prevStep>-1) videos.at(prevStep).stop(); prevStep = curStep; } if(prevStepState!=stepState){ // moved from start image to video if(stepState==1){ if(videos.size()>curStep) videos.at(curStep).show(); if(images.size()>curStep) images.at(curStep).hide(); if(videos.size()>curStep) videos.at(curStep).play(); } else { if(images.size()>curStep) images.at(curStep).show(); if(videos.size()>curStep) videos.at(curStep).hide(); if(videos.size()>curStep) videos.at(curStep).stop(); } prevStepState = stepState; } } }
// constructor // ------------------------------------------------------------------ rigctl::rigctl(QWidget * parent) : QDialog(parent), settings(QSettings::IniFormat, QSettings::UserScope,"QtLog", "qtlog") { setupUi(this); int n = settings.value("FontSize").toString().toInt(); QFont font; font.setPointSize(n); setFont(font); connect(ButtonESC, SIGNAL(pressed()), this, SLOT(goExit())); connect(ButtonHilfe, SIGNAL(pressed()), this, SLOT(goHilfe())); connect(ButtonRigList, SIGNAL(pressed()), this, SLOT(showRigList())); connect(ButtonInit, SIGNAL(pressed()), this, SLOT(hamlibServerInit())); connect(ButtonStart, SIGNAL(pressed()), this, SLOT(goStart())); connect(ButtonStop, SIGNAL(pressed()), this, SLOT(goStop())); connect(buttonReturn, SIGNAL(pressed()), this, SLOT(showRigPage())); connect(InterfaceBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(intefaceBoxChanged(QString))); connect(wrigList, SIGNAL(itemClicked(QTreeWidgetItem *,int)), this, SLOT(itemClickedCb(QTreeWidgetItem *,int))); tcpSocket = new QTcpSocket(this); // tspSocket connect(tcpSocket, SIGNAL(connected()), this, SLOT(sentCommand())); connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readRigReply())); connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError))); QString home = getenv("HOME"); // lade alle devices s = "ls /dev/ttyS* > "+home+"/.qtlog/rigstatus"; i = system(s.toAscii()); // suche device ttyS0 .. n home += "/.qtlog/rigstatus"; // prüfe rigstatus QFile iniFile(home); iniFile.open(QIODevice::ReadOnly); QTextStream istream( &iniFile); // lese device_file RigDevBox->clear(); PttBitDevBox->clear(); i = 0; while(istream.atEnd() != true) { // RigBox_dev füllen s = istream.readLine(0); RigDevBox->insertItem(i,s); PttBitDevBox->insertItem(i++,s); } iniFile.close(); home = getenv("HOME"); s = "ls /dev/ttyU* > "+home+"/.qtlog/rigstatus"; n = system(s.toAscii()); // suche device ttyUSB0 .. n home += "/.qtlog/rigstatus"; QFile inuFile(home); inuFile.open(QIODevice::ReadOnly); QTextStream iustream( &inuFile); // oeffne device_file while(iustream.atEnd() != true) { s = iustream.readLine(0); RigDevBox->insertItem(i,s); // alle vorhndenen USB0 .. n devices übenehmen PttBitDevBox->insertItem(i++,s); } inuFile.close(); Retry = 0; Runing = 0; r = 0; Runing = -1; i = getRigModell(); // lade alle Rig_Modelle if(i != 0) { // falls hamlib installiert ist - lade Rig_Modelle if(settings.value("RigPid").toString().count() != 0) { // und Rig configuriert wurde QSqlQuery query; // hole config_parameter_discriptor qy = "SELECT * FROM wproz WHERE rigpid='"+settings.value("RigPid").toString()+"'"; query.exec(qy); while(query.next()) { proz = query.value(r++).toString(); // proz owner = query.value(r++).toString(); // owner editRig->setText(query.value(r++).toString()); // Rig editPid->setText(query.value(r++).toString()); // Pid editRetry->setText(query.value(r++).toString()); // retry Retry = editRetry->text().toInt(); i = RigDevBox->findText(query.value(r++).toString()); RigDevBox->setCurrentIndex(i); // Rig_device_Box i = BaudBox->findText(query.value(r++).toString()); BaudBox->setCurrentIndex(i); // Baud_device_box // - i = InterfaceBox->findText(query.value(r++).toString()); // FAM_Interface ONE InterfaceBox->setCurrentIndex(i); i = PttBitDevBox->findText(query.value(r++).toString()); PttBitDevBox->setCurrentIndex(i); // PTT_device_Box editRts->setText(query.value(r++).toString()); // RTS = OFF editDtr->setText(query.value(r++).toString()); // DTR = OFF editCts->setText(query.value(r++).toString()); // CTS = OFF // - if(InterfaceBox->currentText().compare("NO") == 0) { PttBitDevBox->setEnabled(FALSE); editRts->setEnabled(FALSE); editDtr->setEnabled(FALSE); editCts->setEnabled(FALSE); } editHost->setText(query.value(r++).toString()); // localhost editPort->setText(query.value(r++).toString()); // port Runing = query.value(r).toInt(); // runing_bit } } updateFlg = 0; // alles ok if( Runing == -1 ) ButtonInit->setPalette( QPalette(QColor(180, 210, 200))); // grün else if( Runing ) ButtonStop->setPalette( QPalette(QColor(180, 210, 200))); // STOP grün else ButtonStart->setPalette( QPalette(QColor(180, 210, 200))); // grün } else QTimer::singleShot(10, this, SLOT(hlibNoInstalled())); // Hamlib nicht installiert }