void SInteractorCreatePolyline::mouseMoveEvent ( QGraphicsSceneMouseEvent * event ) { if (_managerPoints->isCreationInProgress()) { if (_waitForNextPoint) pushCommand(_managerPoints->addPoint(event->scenePos())); else pushCommand(_managerPoints->moveLastPoint(event->scenePos())); _waitForNextPoint = false; } else if (_mousePressed && pushCommand(_managerPoints->moveSelectedPoint(event->scenePos()))) { } else if (_managerPoints->hoverPoint(event->scenePos())) { _scene->hoverGraphicsItem(0); } else if (_managerPoints->aboveShapeCurrentItem(event->scenePos())) { _scene->hoverGraphicsItem(0); // add point } else { SGraphicsItem* item = _scene->aboveGraphicsItem(event->scenePos(), 10); _scene->hoverGraphicsItem(item); } }
void FFmpegPlayer::seek(double time) { const PlayingStatus prevStatus = get_status(); m_seek_time = time; pushCommand(CMD_SEEK); // Continue playback if it was playing before seeking if (prevStatus == PLAYING) pushCommand(CMD_PLAY); }
void CSVWorld::GenericCreator::create() { if (!mLocked) { std::string id = getId(); std::unique_ptr<CSMWorld::CreateCommand> command; if (mCloneMode) { command.reset (new CSMWorld::CloneCommand ( dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel(mListId)), mClonedId, id, mClonedType)); } else { command.reset (new CSMWorld::CreateCommand ( dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel (mListId)), id)); } configureCreateCommand (*command); pushCommand (std::move(command), id); emit done(); emit requestFocus(id); } }
Command *CommandManager::membersAuth(const QString &login, const QString &password) { QVariantMap args; args.insert("login", login); args.insert("password", password); return pushCommand("members", "auth", args); }
AREXPORT void ArServerClient::handleRequests(void) { if (myState != STATE_CONNECTED) return; std::list<ArServerClientData *>::iterator it; ArServerClientData *data; ArServerData *serverData; ArTime lastSent; // walk through our list for (it = myRequested.begin(); it != myRequested.end(); ++it) { data = (*it); lastSent = data->getLastSent(); // see if this needs to be called if (data->getMSec() != -1 && (data->getMSec() == 0 || lastSent.mSecSince() > data->getMSec())) { serverData = data->getServerData(); // call it, then set it so we know we did pushCommand(serverData->getCommand()); pushForceTcpFlag(false); if (serverData->getFunctor() != NULL) serverData->getFunctor()->invoke(this, data->getPacket()); popCommand(); popForceTcpFlag(); data->setLastSentToNow(); } } }
//-------------------------------------------------------------- void ofxThreadedVideo::setAudioTrackToChannel(int trackIndex, int oldChannelLabel, int newChannelLabel){ ofxThreadedVideoCommand c("setAudioTrackToChannel", instanceID); c.setArgument(trackIndex); c.setArgument(oldChannelLabel); c.setArgument(newChannelLabel); pushCommand(c); }
static char cmdPushCommand( tPSStackItem **topStack, void* cmd, const char* /*path*/ ) { tPSCommand *command = (tPSCommand*)cmd; if( !command ) return FALSE; pushCommand( topStack, command ); return TRUE; }
/** Check if result is plausible. If it is, an ok is send and the command is stored in queue. If not, a resend and ok is send. */ void GCode::checkAndPushCommand() { if(hasM()) { if(M==110) // Reset line number { lastLineNumber = actLineNumber; Com::printFLN(Com::tOk); waitingForResend = -1; return; } if(M==112) // Emergency kill - freeze printer { Commands::emergencyStop(); } #ifdef DEBUG_COM_ERRORS if(M==666) { lastLineNumber++; return; } #endif // DEBUG_COM_ERRORS } if(hasN()) { if((((lastLineNumber+1) & 0xffff)!=(actLineNumber&0xffff))) { if(waitingForResend<0) // after a resend, we have to skip the garbage in buffers, no message for this { if(Printer::debugErrors()) { Com::printF(Com::tExpectedLine,lastLineNumber+1); Com::printFLN(Com::tGot,actLineNumber); } requestResend(); // Line missing, force resend } else { --waitingForResend; commandsReceivingWritePosition = 0; Com::printFLN(Com::tSkip,actLineNumber); Com::printFLN(Com::tOk); } return; } lastLineNumber = actLineNumber; } pushCommand(); #ifdef ACK_WITH_LINENUMBER Com::printFLN(Com::tOkSpace,actLineNumber); #else Com::printFLN(Com::tOk); #endif wasLastCommandReceivedAsBinary = sendAsBinary; waitingForResend = -1; // everything is ok. }
//to rotate a page in a pdf file, clockwise direction bool PDFJam::rotatePage(int fileIndex,int rotatedPageIndex,int degree){ if ((degree!=90) && (degree!=180) && (degree!=270)){ return false; } QString rtTemp = "pdf%1 /tmp/pdffactory/%2/%3.pdf --outfile /tmp/pdffactory/%4/%5.pdf "; QString cmd = rtTemp.arg(QString::number(degree)).arg(QString::number(fileIndex)).arg(QString::number(rotatedPageIndex)).arg(QString::number(fileIndex)).arg(QString::number(rotatedPageIndex)); pushCommand(cmd); }
//-------------------------------------------------------------- void ofxThreadedVideo::setFade(int frameStart, int durationMillis, float fadeTarget, bool fadeSound, bool fadeVideo, bool fadeOnce){ ofxThreadedVideoCommand c("setFade", instanceID); c.setArgument(frameStart); c.setArgument(durationMillis); c.setArgument(fadeTarget); c.setArgument(fadeSound); c.setArgument(fadeVideo); c.setArgument(fadeOnce); pushCommand(c); }
Command *CommandManager::subtitlesShowByFile(const QString &showId, const QString &fileName, const QString &language) { QVariantMap args; args.insert("file", fileName); if (!language.isEmpty()) args.insert("language", language); return pushCommand("subtitles/show", showId, args); }
void FFmpegPlayer::quit(bool waitForThreadToExit) { // Stop control thread if (isRunning()) { pushCommand(CMD_STOP); if (waitForThreadToExit) join(); } }
void LandscapeModel::setupMyPlayer() { PlayersMapIterator begin = m_players.begin() , end = m_players.end(); for ( ; begin != end; ++begin ) { if ( PlayerType::isFree( begin->second->getType() ) ) { pushCommand( Command( CommandId::ChangePlayerType ).pushArgument( begin->first ).pushArgument( PlayerType::Player ) ); pushCommand( Command( CommandId::ChangePlayerName ).pushArgument( begin->first ).pushArgument( m_environment.getString( Resources::Properties::PlayerName ) ) ); m_myPlayerId = begin->first; break; } } assert( m_myPlayerId != Tools::Core::Generators::IGenerator::ms_wrongId ); } // LandscapeModel::setupMyPlayer
void FFmpegPlayer::play() { pushCommand(CMD_PLAY); #if 0 // Wait for at least one frame to be published before returning the call TScopedLock<Mutex> lock(m_mutex); while (duration() > 0 && ! m_frame_published_flag) m_frame_published_cond.wait(&m_mutex); #endif }
void PDFJam::pastePage(int fileIndex,int numPages, int pageIndex, int slot=0){ QString cmd = ""; QString mvTemp = "mv /tmp/pdffactory/%1/%2.pdf /tmp/pdffactory/%3/%4.pdf "; for (int i = numPages-1; i >= pageIndex; i--) { cmd += mvTemp.arg(QString::number(fileIndex)).arg(QString::number(i)).arg(QString::number(fileIndex)).arg(QString::number(i+1)); if (i>pageIndex) cmd+=" && "; } QString pasteTemp = "cp /tmp/pdffactory/clipboard%1.pdf /tmp/pdffactory/%2/%3.pdf "; cmd += " && " + pasteTemp.arg(QString::number(slot)).arg(QString::number(fileIndex)).arg(QString::number(pageIndex)); pushCommand(cmd); }
Command *CommandManager::subtitlesShow(const QString &showId, int season, int episode, const QString &language) { QVariantMap args; if (season >= 0) args.insert("season", season); if (episode >= 0) args.insert("episode", episode); if (!language.isEmpty()) args.insert("language", language); return pushCommand("subtitles/show", showId, args); }
void SInteractorCreatePolyline::mousePressEvent ( QGraphicsSceneMouseEvent * event ) { _mousePressed = true; if (_managerPoints->isCreationInProgress()) { switch (event->button()) { case Qt::LeftButton: // wait for one more point _waitForNextPoint = true; break; case Qt::RightButton: // no more points _managerPoints->stopCreation(); break; default: break; } } else if (event->button()== Qt::LeftButton) { if (! _managerPoints->selectPoint(event->scenePos())) { SGraphicsItem* item = _scene->aboveGraphicsItem(event->scenePos(), 10); if (item) pushCommand(new SCmdGraphicsSelect(_managerPoints, _managerPoints->currentItem(), item)); else { // create new polyline pushCommand(new SCmdGraphicsAdd(_scene, _managerPoints, _managerPoints->currentItem(), new SPolyline())); _managerPoints->startCreation(); pushCommand(_managerPoints->addPoint(event->scenePos())); // first point _waitForNextPoint = true; // wait for one more point _waitForFirstRelease = true; } } } }
void inboundBufferMaintenance(void) { int i; for ( i = 0; i < RAW_PACKET_BUFFER_SIZE; i++ ) { if ( rawPacketStatus[i] == READY && checkPacket(rawPackets[i]) ) { struct command* cmd = createCommand( rawPackets[i] ); if ( cmd ) { // create command was successful ? pushCommand( cmd ); // queue it up rawPacketStatus[i] = EMPTY; // buffer is now good for writing another packet } } } if ( rawPacketStatus[0] == EMPTY ) { rawPacketStatus[0] = BUSY; } }
//to remove a page in a pdf file bool PDFJam::removePage(int fileIndex,int numPages, int deletedPageIndex){ if ((deletedPageIndex<0)||(deletedPageIndex>=numPages)) { return false; } //QString temp = "file1.pdf '-' file2.pdf '1,2' file3.pdf '2-' --outfile output.pdf" QString rmTemp = "rm /tmp/pdffactory/%1/%2.pdf "; QString cmd = rmTemp.arg(QString::number(fileIndex)).arg(QString::number(deletedPageIndex)); QString temp = "mv /tmp/pdffactory/%1/%2.pdf /tmp/pdffactory/%3/%4.pdf "; for (int i = deletedPageIndex+1; i < numPages; i++) { cmd += "&& " + temp.arg(QString::number(fileIndex)).arg(QString::number(i)).arg(QString::number(fileIndex)).arg(QString::number(i-1)); } pushCommand(cmd); }
Command *CommandManager::showsEpisodes(const QString &showId, int season, int episode, bool summary, bool hide_notes) { QVariantMap args; QUrlQuery query = forgeQuery("/shows/episodes/", showId); if (season >= 0) args.insert("season", season); if (episode >= 0) args.insert("episode", episode); if (summary) args.insert("summary", true); if (hide_notes) args.insert("hide_notes", true); return pushCommand("shows/episodes", showId, args); }
void PDFJam::loadFile(QString fileName, int fileIndex,Poppler::Document* pd){ int numPages = pd->numPages(); QString path= "/tmp/pdffactory/%1/"; path = path.arg(QString::number(fileIndex)); makeCleanFolder(path); QString temp = "pdfjam %1 %2 --outfile %3%4.pdf %5"; QString cmd=""; for (int i = 0; i < numPages; i++) { QString orientation = " --no-landscape "; QSizeF pageSize = pd->page(i)->pageSizeF(); if(pageSize.width() > pageSize.height()){ orientation = " --landscape "; } cmd += temp.arg(fileName).arg(QString::number(i+1)).arg(path).arg(QString::number(i)).arg(orientation) + " ; "; } pushCommand(cmd); }
void CStdinMonitorThread::run () { while(!feof(stdin)) { // wait for the main thread to deal with the previous command while (commandWaiting()) { NLMISC::nlSleep(1); } // get the next command from the command line std::string theCommand; theCommand.resize(1024,0); fgets((char*)theCommand.c_str(),theCommand.size()-1,stdin); theCommand.resize(strlen(theCommand.c_str())); // push the command to allow reader thread to deal with it pushCommand(theCommand); } }
void ILI9341_kbv::setRotation(uint8_t r) { uint8_t mac = 0x00; Adafruit_GFX::setRotation(r & 3); switch (rotation) { case 0: mac = 0x08; break; case 1: //LANDSCAPE 90 degrees mac = 0x68; break; case 2: mac = 0xD8; break; case 3: mac = 0xB8; break; } pushCommand(ILI9341_CMD_MEMORY_ACCESS_CONTROL, &mac, 1); }
//to export file number "fileIndex" to destination //support n-up, orientation, offset options void PDFJam::exportFile(int fileIndex,int numPages, QString dest, bool isNup,QSize nup, bool isLandscape , bool hasTwoSidedOffset, int leftOffset){ QString cmd = "pdfjam "; QString temp = "/tmp/pdffactory/%1/%2.pdf '-' "; for (int i = 0; i < numPages; i++) { cmd += temp.arg(QString::number(fileIndex)).arg(QString::number(i)); } QString orientation = isLandscape?" --landscape ": " --no-landscape "; cmd += orientation; if (isNup) { QString nupTemp = " --nup '%1x%2' --frame true "; cmd += nupTemp.arg(QString::number(nup.width())).arg(QString::number(nup.height())); } //offset if(hasTwoSidedOffset){ //pipe to another pdfjam to do offset, after other things are done QString outStdout = " --outfile /dev/stdout | pdfjam "; cmd += outStdout.arg(dest); cmd+=" --twoside "; QString offsetTemp =" --offset \"%1cm 0cm\" "; cmd+=offsetTemp.arg(QString::number(leftOffset)); //TODO - extension: 2 orientations, this one is after n-up, can extend later QString orientation = isLandscape?" --landscape ": " --no-landscape "; cmd += orientation; } QString outTemp = " --outfile %1 "; cmd += outTemp.arg(dest); pushCommand(cmd); }
RemoveDataCommand::RemoveDataCommand(serialization::DataBase* a_pDataBase, const vector<uint>& a_Guids) : DataBaseCommand(a_pDataBase) { m_Guids = a_Guids; setName("Remove"); vector<phantom::data> allData; m_pDataBase->rootNode()->fetchDataCascade(allData); for(size_t i = 0; i<m_Guids.size(); ++i) { phantom::data d = m_pDataBase->getData(m_Guids[i]); o_assert(!d.isNull()); for(auto it = allData.begin(); it != allData.end(); ++it) { if(m_pDataBase->getComponentDataOwner(*it) == d) m_Guids.push_back(m_pDataBase->getGuid(*it)); } } std::sort(m_Guids.begin(), m_Guids.end()); m_Guids.resize(std::unique(m_Guids.begin(), m_Guids.end())-m_Guids.begin()); for(auto it = m_Guids.begin(); it != m_Guids.end(); ++it) { pushCommand(o_new(UndoCommand)((m_pDataBase->getNode(*it) ? "Node '" : "Data '") + m_pDataBase->getAttributeValues(m_pDataBase->getData(*it).address())[0] + "' ("+lexical_cast<string>((void*)(*it))+")" )); } }
/** \brief Read from serial console or sdcard. This function is the main function to read the commands from serial console or from sdcard. It must be called frequently to empty the incoming buffer. */ void GCode::readFromSerial() { if(bufferLength>=GCODE_BUFFER_SIZE) return; // all buffers full if(waitUntilAllCommandsAreParsed && bufferLength) return; waitUntilAllCommandsAreParsed=false; millis_t time = HAL::timeInMilliseconds(); if(!HAL::serialByteAvailable()) { if((waitingForResend>=0 || commandsReceivingWritePosition>0) && time-timeOfLastDataPacket>200) { requestResend(); // Something is wrong, a started line was not continued in the last second timeOfLastDataPacket = time; } #ifdef WAITING_IDENTIFIER else if(bufferLength == 0 && time-timeOfLastDataPacket>1000) // Don't do it if buffer is not empty. It may be a slow executing command. { #if !SUPPORT_CURA Com::printFLN(Com::tWait); // Unblock communication in case the last ok was not received correct. #endif // !SUPPORT_CURA timeOfLastDataPacket = time; } #endif } while(HAL::serialByteAvailable() && commandsReceivingWritePosition < MAX_CMD_SIZE) // consume data until no data or buffer full { #if FEATURE_WATCHDOG HAL::pingWatchdog(); #endif // FEATURE_WATCHDOG timeOfLastDataPacket = time; //HAL::timeInMilliseconds(); commandReceiving[commandsReceivingWritePosition++] = HAL::serialReadByte(); // first lets detect, if we got an old type ascii command if(commandsReceivingWritePosition==1) { if(waitingForResend>=0 && wasLastCommandReceivedAsBinary) { if(!commandReceiving[0]) waitingForResend--; // Skip 30 zeros to get in sync else waitingForResend = 30; commandsReceivingWritePosition = 0; continue; } if(!commandReceiving[0]) // Ignore zeros { commandsReceivingWritePosition = 0; continue; } sendAsBinary = (commandReceiving[0] & 128)!=0; } if(sendAsBinary) { if(commandsReceivingWritePosition < 2 ) continue; if(commandsReceivingWritePosition == 5 || commandsReceivingWritePosition == 4) binaryCommandSize = computeBinarySize((char*)commandReceiving); if(commandsReceivingWritePosition == binaryCommandSize) { GCode *act = &commandsBuffered[bufferWriteIndex]; if(act->parseBinary(commandReceiving,true)) // Success act->checkAndPushCommand(); else requestResend(); commandsReceivingWritePosition = 0; return; } } else // Ascii command { char ch = commandReceiving[commandsReceivingWritePosition-1]; if(ch == 0 || ch == '\n' || ch == '\r' || (!commentDetected && ch == ':')) // complete line read { //Com::printF(PSTR("Parse ascii"));Com::print((char*)commandReceiving);Com::println(); commandReceiving[commandsReceivingWritePosition-1]=0; commentDetected = false; if(commandsReceivingWritePosition==1) // empty line ignore { commandsReceivingWritePosition = 0; continue; } GCode *act = &commandsBuffered[bufferWriteIndex]; if(act->parseAscii((char *)commandReceiving,true)) // Success act->checkAndPushCommand(); else requestResend(); commandsReceivingWritePosition = 0; return; } else { if(ch == ';') commentDetected = true; // ignore new data until lineend if(commentDetected) commandsReceivingWritePosition--; } } if(commandsReceivingWritePosition == MAX_CMD_SIZE) { requestResend(); return; } } #if SDSUPPORT if(!sd.sdmode || commandsReceivingWritePosition!=0) // not reading or incoming serial command return; while( sd.filesize > sd.sdpos && commandsReceivingWritePosition < MAX_CMD_SIZE) // consume data until no data or buffer full { #if FEATURE_WATCHDOG HAL::pingWatchdog(); #endif // FEATURE_WATCHDOG timeOfLastDataPacket = HAL::timeInMilliseconds(); int n = sd.file.read(); #if FEATURE_WATCHDOG HAL::pingWatchdog(); #endif // FEATURE_WATCHDOG if(n==-1) { Com::printFLN(Com::tSDReadError); UI_ERROR("SD Read Error"); // Second try in case of recoverable errors sd.file.seekSet(sd.sdpos); n = sd.file.read(); #if FEATURE_WATCHDOG HAL::pingWatchdog(); #endif // FEATURE_WATCHDOG if(n==-1) { Com::printErrorFLN(PSTR("SD error did not recover!")); sd.sdmode = false; break; } UI_ERROR("SD error fixed"); } sd.sdpos++; // = file.curPosition(); commandReceiving[commandsReceivingWritePosition++] = (uint8_t)n; // first lets detect, if we got an old type ascii command if(commandsReceivingWritePosition==1) { sendAsBinary = (commandReceiving[0] & 128)!=0; } if(sendAsBinary) { if(commandsReceivingWritePosition < 2 ) continue; if(commandsReceivingWritePosition == 4 || commandsReceivingWritePosition == 5) binaryCommandSize = computeBinarySize((char*)commandReceiving); if(commandsReceivingWritePosition==binaryCommandSize) { GCode *act = &commandsBuffered[bufferWriteIndex]; if(act->parseBinary(commandReceiving,false)) // Success, silently ignore illegal commands pushCommand(); commandsReceivingWritePosition = 0; return; } } else { char ch = commandReceiving[commandsReceivingWritePosition-1]; bool returnChar = ch == '\n' || ch == '\r'; if(returnChar || sd.filesize == sd.sdpos || (!commentDetected && ch == ':') || commandsReceivingWritePosition >= (MAX_CMD_SIZE - 1) ) // complete line read { if(returnChar || ch == ':') commandReceiving[commandsReceivingWritePosition-1]=0; else commandReceiving[commandsReceivingWritePosition]=0; commentDetected = false; if(commandsReceivingWritePosition==1) // empty line ignore { commandsReceivingWritePosition = 0; continue; } GCode *act = &commandsBuffered[bufferWriteIndex]; if(act->parseAscii((char *)commandReceiving,false)) // Success pushCommand(); commandsReceivingWritePosition = 0; return; } else { if(ch == ';') commentDetected = true; // ignore new data until lineend if(commentDetected) commandsReceivingWritePosition--; } } } sd.sdmode = false; Com::printFLN(Com::tDonePrinting); commandsReceivingWritePosition = 0; commentDetected = false; Printer::setMenuMode(MENU_MODE_SD_PRINTING,false); BEEP_STOP_PRINTING #endif }
//-------------------------------------------------------------- void ofxThreadedVideo::setPaused(bool b){ ofxThreadedVideoCommand c("setPaused", instanceID); c.setArgument(b); pushCommand(c); }
//-------------------------------------------------------------- void ofxThreadedVideo::resetAnchor(){ ofxThreadedVideoCommand c("resetAnchor", instanceID); pushCommand(c); }
//-------------------------------------------------------------- void ofxThreadedVideo::setAnchorPoint(float x, float y){ ofxThreadedVideoCommand c("setAnchorPoint", instanceID); c.setArgument(x); c.setArgument(y); pushCommand(c); }
//-------------------------------------------------------------- void ofxThreadedVideo::setAnchorPercent(float xPct, float yPct){ ofxThreadedVideoCommand c("setAnchorPercent", instanceID); c.setArgument(xPct); c.setArgument(yPct); pushCommand(c); }