/* ** Filter the current selection through shell command "command". The selection ** is removed, and replaced by the output from the command execution. Failed ** command status and output to stderr are presented in dialog form. */ void FilterSelection(WindowInfo *window, const char *command, int fromMacro) { int left, right, textLen; char *text; /* Can't do two shell commands at once in the same window */ if (window->shellCmdData != NULL) { XBell(TheDisplay, 0); return; } /* Get the selection and the range in character positions that it occupies. Beep and return if no selection */ text = BufGetSelectionText(window->buffer); if (*text == '\0') { XtFree(text); XBell(TheDisplay, 0); return; } textLen = strlen(text); BufUnsubstituteNullChars(text, window->buffer); left = window->buffer->primary.start; right = window->buffer->primary.end; /* Issue the command and collect its output */ issueCommand(window, command, text, textLen, ACCUMULATE | ERROR_DIALOGS | REPLACE_SELECTION, window->lastFocus, left, right, fromMacro); }
int main() { cout << "Relational Database by Group 5 - CS 237 PA4" << endl; cout << "Bonus features implemented: Delete and FindRange" << endl; cout << "Loading database records.txt . . . " << endl; Database* db = new Database("records.txt"); cout << "Set up database and indices successfully" << endl; cout << endl; ifstream infile; string filename = "commands.txt"; infile.open(filename.c_str()); if (infile.fail()) { cerr << "Invalid commands file."; exit(1); } else { string line; while (!infile.eof()) { getline(infile, line); issueCommand(line, db); } } pause_237(false); }
void squeezeLiteGui::CliReady(void) { DEBUGF("cliConnected Slot"); m_playerInfo = new playerInfo(cli,encodedMacAddress); m_playerInfoThread = new playerInfoThread(m_playerInfo); m_playerInfo->moveToThread(m_playerInfoThread); // Error message processing connect(m_playerInfo,SIGNAL(playerInfoError(QString)), this,SLOT(ErrorMessageReceiver(QString))); connect(cli,SIGNAL(cliError(QString)), this,SLOT(ErrorMessageReceiver(QString))); // interface command issuing connect(this,SIGNAL(issueStandardCommand(CliCommand)), cli,SLOT(SendStandardCommand(CliCommand))); connect(this,SIGNAL(issueCommand(QByteArray)), cli,SLOT(SendCommand(QByteArray))); // so device can send messages connect(m_playerInfo,SIGNAL(PlayerInfoFilled()), this,SLOT(playerInfoReady())); connect(m_playerInfo,SIGNAL(PlayerStatus(PlayerState)), this,SLOT(PlayerStatus(PlayerState))); m_playerInfoThread->start(); // connect(this,SIGNAL(deviceStatusReady()),this,SLOT(initInterfaceConnections())); }
/* ** Execute the line of text where the the insertion cursor is positioned ** as a shell command. */ void ExecCursorLine(WindowInfo *window, int fromMacro) { char *cmdText; int left, right, insertPos; char *subsCommand, fullName[MAXPATHLEN]; int pos, line, column; char lineNumber[11]; /* Can't do two shell commands at once in the same window */ if (window->shellCmdData != NULL) { XBell(TheDisplay, 0); return; } /* get all of the text on the line with the insert position */ pos = TextGetCursorPos(window->lastFocus); if (!GetSimpleSelection(window->buffer, &left, &right)) { left = right = pos; left = BufStartOfLine(window->buffer, left); right = BufEndOfLine(window->buffer, right); insertPos = right; } else insertPos = BufEndOfLine(window->buffer, right); cmdText = BufGetRange(window->buffer, left, right); BufUnsubstituteNullChars(cmdText, window->buffer); /* insert a newline after the entire line */ BufInsert(window->buffer, insertPos, "\n"); /* Substitute the current file name for % and the current line number for # in the shell command */ strcpy(fullName, window->path); strcat(fullName, window->filename); TextPosToLineAndCol(window->lastFocus, pos, &line, &column); sprintf(lineNumber, "%d", line); subsCommand = shellCommandSubstitutes(cmdText, fullName, lineNumber); if (subsCommand == NULL) { DialogF(DF_ERR, window->shell, 1, "Shell Command", "Shell command is too long due to\n" "filename substitutions with '%%' or\n" "line number substitutions with '#'", "OK"); return; } /* issue the command */ issueCommand(window, subsCommand, NULL, 0, 0, window->lastFocus, insertPos+1, insertPos+1, fromMacro); free(subsCommand); XtFree(cmdText); }
/* ** Execute shell command "command", on input string "input", depositing the ** in a macro string (via a call back to ReturnShellCommandOutput). */ void ShellCmdToMacroString(WindowInfo *window, const char *command, const char *input) { char *inputCopy; /* Make a copy of the input string for issueCommand to hold and free upon completion */ inputCopy = *input == '\0' ? NULL : XtNewString(input); /* fork the command and begin processing input/output */ issueCommand(window, command, inputCopy, strlen(input), ACCUMULATE | OUTPUT_TO_STRING, NULL, 0, 0, True); }
/** * @brief Funkcija koja ceka na acknowledge signal od primaoca komande. * @param delay predstavlja broj milisekundi koliko zelimo da cekamo. * @retval Nema. * @author praetorian ( [email protected] ) */ void waitAck( CommandNameType command_name, int address, uint16_t data ) { while( TRUE ) { sleep( 25 ); if( FLAG_ackReceived ) { FLAG_ackReceived = FALSE; command_ID++; break; } issueCommand( command_name, address, data ); } }
/* ** Execute shell command "command", depositing the result at the current ** insert position or in the current selection if the window has a ** selection. */ void ExecShellCommand(WindowInfo *window, const char *command, int fromMacro) { int left, right, flags = 0; char *subsCommand, fullName[MAXPATHLEN]; int pos, line, column; char lineNumber[11]; /* Can't do two shell commands at once in the same window */ if (window->shellCmdData != NULL) { XBell(TheDisplay, 0); return; } /* get the selection or the insert position */ pos = TextGetCursorPos(window->lastFocus); if (GetSimpleSelection(window->buffer, &left, &right)) flags = ACCUMULATE | REPLACE_SELECTION; else left = right = pos; /* Substitute the current file name for % and the current line number for # in the shell command */ strcpy(fullName, window->path); strcat(fullName, window->filename); TextPosToLineAndCol(window->lastFocus, pos, &line, &column); sprintf(lineNumber, "%d", line); subsCommand = shellCommandSubstitutes(command, fullName, lineNumber); if (subsCommand == NULL) { DialogF(DF_ERR, window->shell, 1, "Shell Command", "Shell command is too long due to\n" "filename substitutions with '%%' or\n" "line number substitutions with '#'", "OK"); return; } /* issue the command */ issueCommand(window, subsCommand, NULL, 0, flags, window->lastFocus, left, right, fromMacro); free(subsCommand); }
status_t BnStreamListener::onTransact( uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { switch (code) { case QUEUE_BUFFER: { CHECK_INTERFACE(IStreamListener, data, reply); size_t index = static_cast<size_t>(data.readInt32()); size_t size = static_cast<size_t>(data.readInt32()); queueBuffer(index, size); break; } case ISSUE_COMMAND: { CHECK_INTERFACE(IStreamListener, data, reply); Command cmd = static_cast<Command>(data.readInt32()); bool synchronous = static_cast<bool>(data.readInt32()); sp<AMessage> msg; if (data.readInt32()) { msg = AMessage::FromParcel(data); } issueCommand(cmd, synchronous, msg); break; } default: return BBinder::onTransact(code, data, reply, flags); } return OK; }
bool NXTCam::disableTracking() { return issueCommand('D'); }
void squeezeLiteGui::setVolume(int vol) { QString cmd = QString("mixer volume %1 \n").arg(vol); emit issueCommand(cmd.toLatin1()); }
bool NXTCam::enableTracking() { return issueCommand('E'); }
bool NXTCam::readImageRegisters() { return issueCommand('H'); }
bool NXTCam::getColorMap() { return issueCommand('G'); }
bool NXTCam::sortSize() { return issueCommand('A'); }
int sendCommand(int* dramAddress, int busNumber, int chipNumber, int pageNumber, int offset, int operationCode, int length, int tag) { writeCommand(dramAddress, busNumber, chipNumber, pageNumber, offset, operationCode, length, tag); issueCommand(); return 0; }
bool NXTCam::sortNone() { return issueCommand('X'); }
bool PFMate::sendSignal() { return issueCommand('G'); }
bool NXTCam::pingCam() { return issueCommand('P'); }
int main( void ) { //konfiguracija taktova RCC_ADCCLKConfig(RCC_PCLK2_Div2);//konfigurisanje takta za ADC RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);//dovodjenje takta za DMA kontroler RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_TIM1 | RCC_APB2Periph_ADC1, ENABLE);//dovodjenje takta portu A, B, C, tajmeru TIM1 i ADC-u //konfiguracija portova - analogni ulazi GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOA, &GPIO_InitStructure); //konfiguracija portova - bargraph tj. DIGIO konektor GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_5 | GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_13; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOC, &GPIO_InitStructure); /* DMA1 channel1 configuration ----------------------------------------------*/ DMA_DeInit(DMA1_Channel1); DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;//adresa izvorista za dma prenos - DATA REGISTER ADC-a DMA_InitStructure.DMA_MemoryBaseAddr = (u32)ADC_RegularConvertedValueTab; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_BufferSize = 4; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel1, &DMA_InitStructure); /* Enable DMA1 channel1 */ DMA_Cmd(DMA1_Channel1, ENABLE); /* ADC1 configuration ------------------------------------------------------*/ ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; ADC_InitStructure.ADC_ScanConvMode = ENABLE; ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfChannel = 4; ADC_Init(ADC1, &ADC_InitStructure); ADC_RegularChannelConfig(ADC1, ADC_Channel_12, 1, ADC_SampleTime_1Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_13, 2, ADC_SampleTime_1Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 3, ADC_SampleTime_1Cycles5); ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 4, ADC_SampleTime_1Cycles5); ADC_ExternalTrigConvCmd(ADC1, ENABLE);//omogucavanje externog triger moda ADC_DMACmd(ADC1, ENABLE);//omogucavanje DMA prenosa za ADC ADC_Cmd(ADC1, ENABLE); ADC_ResetCalibration(ADC1);//adc kalibracija while(ADC_GetResetCalibrationStatus(ADC1)); ADC_StartCalibration(ADC1); while(ADC_GetCalibrationStatus(ADC1)); //konfiguracija tajmera TIM1 koji radi u PWM modu, i svoj izlaz koristi za trigerovanje ADC-a TIM_TimeBaseStructInit(&TIM_TimeBaseInitStruct); TIM_TimeBaseInitStruct.TIM_Period = 150 - 1; TIM_TimeBaseInitStruct.TIM_Prescaler = 0; TIM_TimeBaseInitStruct.TIM_ClockDivision = 0x0; TIM_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM1, &TIM_TimeBaseInitStruct); TIM_OCInitStruct.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStruct.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStruct.TIM_Pulse = 150 / 2; TIM_OCInitStruct.TIM_OCPolarity = TIM_OCPolarity_Low; TIM_OC1Init(TIM1, &TIM_OCInitStruct); TIM_Cmd(TIM1, ENABLE);//dozovla rada tajmera tek kada se konfigurisu i DMA i ADC TIM_CtrlPWMOutputs(TIM1, ENABLE);//generisanje PWM izlaza za tajmer 1 baterija_Acc_const=0.004032; servo_5V_const=0.004032; /* Inicijalizacija. */ InitGPIO_Pin(GPIOB, GPIO_Pin_11, GPIO_Mode_IPU, GPIO_Speed_50MHz); UsartInit(); /* Inicijalizacija glavnog tajmera. */ initTimerServo();//zbog ovoga se baterija meri i dok je prekidac uvucen /* Glavna masina stanja. */ while(1) { switch (state_robot) { /* Pocetno stanje u kome se inicijalizaciju sistemi, podesava preskaler, ukljucuje UV. */ case 0: // pocetno stanje, sve inicijalizujemo i krenemo napred if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_11)) // ako je ocitano Vcc, tj. krene se sa izvrsavanjem, u suprotnom ostajemo u // istom stanju { /* Inicijalizacija glavnog tajmera. */ initTimer90(); /* Inicijalizacija tajmera za proveru pozicije robota. */ SysTick_Config( SysTick_Config( SystemCoreClock / 1000 ) ); /* Provera koja je stategije. */ checkStrategy(); /* Zadavanje komandi. */ issueCommand( START_RUNNING, MOTION_DEVICE_ADDRESS, 30 ); waitAck( START_RUNNING, MOTION_DEVICE_ADDRESS, 30 ); issueCommand( PRESCALER, MOTION_DEVICE_ADDRESS, 1000 ); waitAck( PRESCALER, MOTION_DEVICE_ADDRESS, 1000 ); issueCommand( ULTRASOUND_ON, MOTION_DEVICE_ADDRESS, 1 ); waitAck( ULTRASOUND_ON, MOTION_DEVICE_ADDRESS, 1 ); issueCommand( MOVE_FORWARD, MOTION_DEVICE_ADDRESS, 30 ); waitAck( MOVE_FORWARD, MOTION_DEVICE_ADDRESS, 30 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 25 ); if ( FLAG_arriveOnDest ) break; sleep( 100 ); } state_robot++; sleep(100); } break; /* Blago okretanje da bi se izbegla ivica na sredini terena. */ case 1: if( FLAG_strategyLeft ) { issueCommand( ROTATE_LEFT, MOTION_DEVICE_ADDRESS, 20 ); waitAck( ROTATE_LEFT, MOTION_DEVICE_ADDRESS, 20 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 25 ); if ( FLAG_arriveOnDest ) break; sleep( 100 ); } } else { issueCommand( ROTATE_RIGHT, MOTION_DEVICE_ADDRESS, 20 ); waitAck( ROTATE_RIGHT, MOTION_DEVICE_ADDRESS, 20 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 25 ); if ( FLAG_arriveOnDest ) break; sleep( 100 ); } } state_robot++; sleep(100); break; /* Blago pomeranje napred, ka sredini terena. */ case 2: { issueCommand( MOVE_FORWARD, MOTION_DEVICE_ADDRESS, 50 ); waitAck( MOVE_FORWARD, MOTION_DEVICE_ADDRESS, 50 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } state_robot++; sleep(100); break; } /* Blaga rotacija da bi se poravnali opet. */ case 3: if( FLAG_strategyLeft ) { issueCommand( ROTATE_RIGHT, MOTION_DEVICE_ADDRESS, 25 ); waitAck( ROTATE_RIGHT, MOTION_DEVICE_ADDRESS, 25 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } } else { issueCommand( ROTATE_LEFT, MOTION_DEVICE_ADDRESS, 25 ); waitAck( ROTATE_LEFT, MOTION_DEVICE_ADDRESS, 25 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } } state_robot++; sleep(100); break; /* Blago pomeranje napred da bi pomerili kocke u sredinu terena. */ case 4: issueCommand( MOVE_FORWARD, MOTION_DEVICE_ADDRESS, 10 ); waitAck( MOVE_FORWARD, MOTION_DEVICE_ADDRESS, 10 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } state_robot++; sleep(100); break; /* Vracanje unazad. */ case 5: issueCommand( PRESCALER, MOTION_DEVICE_ADDRESS, 500 ); waitAck( PRESCALER, MOTION_DEVICE_ADDRESS, 500 ); issueCommand( MOVE_BACKWARD, MOTION_DEVICE_ADDRESS, 50 ); waitAck( MOVE_BACKWARD, MOTION_DEVICE_ADDRESS, 50 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } state_robot++; sleep(100); break; /* Okretanje ka prvoj kucici, onoj daljoj od ivice terana i gasenje senzora. */ case 6: if( FLAG_strategyLeft ) { issueCommand( ROTATE_RIGHT, MOTION_DEVICE_ADDRESS, 175 ); waitAck( ROTATE_RIGHT, MOTION_DEVICE_ADDRESS, 175 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } } else { issueCommand( ROTATE_LEFT, MOTION_DEVICE_ADDRESS, 175 ); waitAck( ROTATE_LEFT, MOTION_DEVICE_ADDRESS, 175 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } } issueCommand( ULTRASOUND_OFF, MOTION_DEVICE_ADDRESS, 1 ); waitAck( ULTRASOUND_OFF, MOTION_DEVICE_ADDRESS, 1 ); state_robot++; sleep(100); break; /* Zatvaranje prvih vrata. */ case 7: issueCommand( PRESCALER, MOTION_DEVICE_ADDRESS, 700 ); waitAck( PRESCALER, MOTION_DEVICE_ADDRESS, 700 ); issueCommand( MOVE_FORWARD, MOTION_DEVICE_ADDRESS, 100 ); waitAck( MOVE_FORWARD, MOTION_DEVICE_ADDRESS, 100 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } state_robot++; sleep(100); break; /* Vracanje unazad. */ case 8: issueCommand( ULTRASOUND_ON, MOTION_DEVICE_ADDRESS, 1 ); waitAck( ULTRASOUND_ON, MOTION_DEVICE_ADDRESS, 1 ); issueCommand( PRESCALER, MOTION_DEVICE_ADDRESS, 500 ); waitAck( PRESCALER, MOTION_DEVICE_ADDRESS, 500 ); issueCommand( MOVE_BACKWARD, MOTION_DEVICE_ADDRESS, 60 ); waitAck( MOVE_BACKWARD, MOTION_DEVICE_ADDRESS, 60 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } state_robot++; sleep(100); break; /* Okretanje za 180 stepeni ka pocetnoj poziciji. */ case 9: //issueCommand( ULTRASOUND_ON, MOTION_DEVICE_ADDRESS, 1 ); //waitAck( ULTRASOUND_ON, MOTION_DEVICE_ADDRESS, 1 ); if( FLAG_strategyLeft ) { issueCommand( ROTATE_RIGHT, MOTION_DEVICE_ADDRESS, 180 ); waitAck( ROTATE_RIGHT, MOTION_DEVICE_ADDRESS, 180 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } } else { issueCommand( ROTATE_LEFT, MOTION_DEVICE_ADDRESS, 180 ); waitAck( ROTATE_LEFT, MOTION_DEVICE_ADDRESS, 180 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } } state_robot++; sleep(100); break; /* Odlazak naspram druge kucice. */ case 10: issueCommand( MOVE_FORWARD, MOTION_DEVICE_ADDRESS, 15 ); waitAck( MOVE_FORWARD, MOTION_DEVICE_ADDRESS, 15 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } state_robot++; sleep(100); break; /* Okretanje ka kucici. */ case 11: if( FLAG_strategyLeft ) { issueCommand( ROTATE_LEFT, MOTION_DEVICE_ADDRESS, 175 ); waitAck( ROTATE_LEFT, MOTION_DEVICE_ADDRESS, 175 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } } else { issueCommand( ROTATE_RIGHT, MOTION_DEVICE_ADDRESS, 175 ); waitAck( ROTATE_RIGHT, MOTION_DEVICE_ADDRESS, 175 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } } issueCommand( ULTRASOUND_OFF, MOTION_DEVICE_ADDRESS, 1 ); waitAck( ULTRASOUND_OFF, MOTION_DEVICE_ADDRESS, 1 ); state_robot++; sleep(100); break; /* Zatvaranje druge kucice. */ case 12: issueCommand( ULTRASOUND_OFF, MOTION_DEVICE_ADDRESS, 1 ); waitAck( ULTRASOUND_OFF, MOTION_DEVICE_ADDRESS, 1 ); issueCommand( PRESCALER, MOTION_DEVICE_ADDRESS, 700 ); waitAck( PRESCALER, MOTION_DEVICE_ADDRESS, 700 ); issueCommand( MOVE_FORWARD, MOTION_DEVICE_ADDRESS, 60 ); waitAck( MOVE_FORWARD, MOTION_DEVICE_ADDRESS, 60 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } state_robot++; sleep(100); break; /* Vracanje unazad. */ case 13: issueCommand( ULTRASOUND_ON, MOTION_DEVICE_ADDRESS, 1 ); waitAck( ULTRASOUND_ON, MOTION_DEVICE_ADDRESS, 1 ); issueCommand( PRESCALER, MOTION_DEVICE_ADDRESS, 500 ); waitAck( PRESCALER, MOTION_DEVICE_ADDRESS, 500 ); issueCommand( MOVE_BACKWARD, MOTION_DEVICE_ADDRESS, 60 ); waitAck( MOVE_BACKWARD, MOTION_DEVICE_ADDRESS, 60 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } state_robot++; sleep(100); break; /* Okretanje ka centru naseg dela terena. */ case 14: if( FLAG_strategyLeft ) { issueCommand( ROTATE_LEFT, MOTION_DEVICE_ADDRESS, 270 ); waitAck( ROTATE_LEFT, MOTION_DEVICE_ADDRESS, 270 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } } else { issueCommand( ROTATE_RIGHT, MOTION_DEVICE_ADDRESS, 270 ); waitAck( ROTATE_RIGHT, MOTION_DEVICE_ADDRESS, 270 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } } state_robot++; sleep(100); break; case 15: issueCommand( MOVE_FORWARD, MOTION_DEVICE_ADDRESS, 40 ); waitAck( MOVE_FORWARD, MOTION_DEVICE_ADDRESS, 40 ); while( TRUE ) { issueCommand( CHECK_ARRIVE, MOTION_DEVICE_ADDRESS, 1 ); sleep( 100 ); if ( FLAG_arriveOnDest ) break; } state_robot++; sleep(100); break; /* Podrazumevano stanje u kome se ne radi nista. */ default: break; } } }
bool NXTCam::adpaOff() { return issueCommand('O'); }
bool NXTCam::adpaOn() { return issueCommand('N'); }
bool NXTCam::selectLineMode() { return issueCommand('L'); }
bool NXTCam::writeImageRegisters() { return issueCommand('C'); }
bool NXTPowerMeter::resetCounters() { return issueCommand('R'); }
bool NXTCam::selectObjectMode() { return issueCommand('B'); }
void RInterface::processREvalRequest (REvalRequest *request) { RK_TRACE (RBACKEND); RKGlobals::controlWindow()->addChain (request->in_chain); // clear reply object issueCommand (".rk.rkreply <- NULL", RCommand::App | RCommand::Sync, QString::null, 0, 0, request->in_chain); if (!request->call_length) { closeChain (request->in_chain); return; } QString call = request->call[0]; if (call == "get.tempfile.name") { if (request->call_length >= 3) { QString file_prefix = request->call[1]; QString file_extension = request->call[2]; QDir dir (RKSettingsModuleGeneral::filesPath ()); int i=0; while (dir.exists (file_prefix + QString::number (i) + file_extension)) { i++; } issueCommand (".rk.rkreply <- \"" + dir.filePath (file_prefix + QString::number (i) + file_extension) + "\"", RCommand::App | RCommand::Sync, QString::null, 0, 0, request->in_chain); } else { issueCommand (".rk.rkreply <- \"Too few arguments in call to get.tempfile.name.\"", RCommand::App | RCommand::Sync, QString::null, 0, 0, request->in_chain); } } else if (call == "get.output.html.file") { QDir dir (RKSettingsModuleGeneral::filesPath ()); // TODO: make more generic, get filename sanely issueCommand (".rk.rkreply <- \"" + dir.filePath ("rk_out.html") + "\"", RCommand::App | RCommand::Sync, QString::null, 0, 0, request->in_chain); } else if (call == "sync") { RObject *obj = 0; if (request->call_length >= 2) { QString object_name = request->call[1]; obj = RKGlobals::rObjectList ()->findObject (object_name); } if (obj) { RObject::ChangeSet *set = new RObject::ChangeSet; set->from_index = -1; set->to_index = -1; // for now a complete update is needed, in case new objects were added RKGlobals::rObjectList ()->updateFromR (); RKGlobals::tracker ()->objectDataChanged (obj, set); issueCommand (".rk.rkreply <- \"Sync scheduled for object '" + obj->getFullName () + "'\"", RCommand::App | RCommand::Sync, QString::null, 0, 0, request->in_chain); } else { issueCommand (".rk.rkreply <- \"Object not recognized or not specified in call to sync. Ignoring\"", RCommand::App | RCommand::Sync, QString::null, 0, 0, request->in_chain); } } else if (call == "require") { if (request->call_length >= 2) { QString lib_name = request->call[1]; issueCommand (".rk.rkreply <- NULL", RCommand::App | RCommand::Sync, QString::null, 0, 0, request->in_chain); KMessageBox::information (0, i18n ("The R-backend has indicated that in order to carry out the current task it needs the package '%1', which is not currently installed. We'll open the package-management tool, and there you can try to locate and install the needed package.").arg (lib_name), i18n ("Require package '%1'").arg (lib_name)); RKLoadLibsDialog::showInstallPackagesModal (0, request->in_chain, lib_name); issueCommand (".rk.rkreply <- \"\"", RCommand::App | RCommand::Sync, QString::null, 0, 0, request->in_chain); } else { issueCommand (".rk.rkreply <- \"Too few arguments in call to require.\"", RCommand::App | RCommand::Sync, QString::null, 0, 0, request->in_chain); } } else if (call == "quit") { RKwardApp::getApp ()->close (); // if we're still alive, quitting was cancelled issueCommand (".rk.rkreply <- \"Quitting was cancelled\"", RCommand::App | RCommand::Sync, QString::null, 0, 0, request->in_chain); #ifndef DISABLE_RKWINDOWCATCHER // does not work, yet :-( R crashes. } else if (call == "catchWindow") { // TODO: error checking/handling (wrong parameter count/type) if (request->call_length >= 3) { MUTEX_LOCK; window_catcher->catchWindow (request->call[1], QString (request->call[2]).toInt ()); MUTEX_UNLOCK; } #endif // DISABLE_RKWINDOWCATCHER } else { issueCommand (".rk.rkreply <- \"Unrecognized call '" + call + "'. Ignoring\"", RCommand::App | RCommand::Sync, QString::null, 0, 0, request->in_chain); } closeChain (request->in_chain); }
/* ** Do a shell command, with the options allowed to users (input source, ** output destination, save first and load after) in the shell commands ** menu. */ void DoShellMenuCmd(WindowInfo *window, const char *command, int input, int output, int outputReplacesInput, int saveFirst, int loadAfter, int fromMacro) { int flags = 0; char *text; char *subsCommand, fullName[MAXPATHLEN]; int left, right, textLen; int pos, line, column; char lineNumber[11]; WindowInfo *inWindow = window; Widget outWidget; /* Can't do two shell commands at once in the same window */ if (window->shellCmdData != NULL) { XBell(TheDisplay, 0); return; } /* Substitute the current file name for % and the current line number for # in the shell command */ strcpy(fullName, window->path); strcat(fullName, window->filename); pos = TextGetCursorPos(window->lastFocus); TextPosToLineAndCol(window->lastFocus, pos, &line, &column); sprintf(lineNumber, "%d", line); subsCommand = shellCommandSubstitutes(command, fullName, lineNumber); if (subsCommand == NULL) { DialogF(DF_ERR, window->shell, 1, "Shell Command", "Shell command is too long due to\n" "filename substitutions with '%%' or\n" "line number substitutions with '#'", "OK"); return; } /* Get the command input as a text string. If there is input, errors shouldn't be mixed in with output, so set flags to ERROR_DIALOGS */ if (input == FROM_SELECTION) { text = BufGetSelectionText(window->buffer); if (*text == '\0') { XtFree(text); free(subsCommand); XBell(TheDisplay, 0); return; } flags |= ACCUMULATE | ERROR_DIALOGS; } else if (input == FROM_WINDOW) { text = BufGetAll(window->buffer); flags |= ACCUMULATE | ERROR_DIALOGS; } else if (input == FROM_EITHER) { text = BufGetSelectionText(window->buffer); if (*text == '\0') { XtFree(text); text = BufGetAll(window->buffer); } flags |= ACCUMULATE | ERROR_DIALOGS; } else /* FROM_NONE */ text = NULL; /* If the buffer was substituting another character for ascii-nuls, put the nuls back in before exporting the text */ if (text != NULL) { textLen = strlen(text); BufUnsubstituteNullChars(text, window->buffer); } else textLen = 0; /* Assign the output destination. If output is to a new window, create it, and run the command from it instead of the current one, to free the current one from waiting for lengthy execution */ if (output == TO_DIALOG) { outWidget = NULL; flags |= OUTPUT_TO_DIALOG; left = right = 0; } else if (output == TO_NEW_WINDOW) { EditNewFile(GetPrefOpenInTab()?inWindow:NULL, NULL, False, NULL, window->path); outWidget = WindowList->textArea; inWindow = WindowList; left = right = 0; CheckCloseDim(); } else { /* TO_SAME_WINDOW */ outWidget = window->lastFocus; if (outputReplacesInput && input != FROM_NONE) { if (input == FROM_WINDOW) { left = 0; right = window->buffer->length; } else if (input == FROM_SELECTION) { GetSimpleSelection(window->buffer, &left, &right); flags |= ACCUMULATE | REPLACE_SELECTION; } else if (input == FROM_EITHER) { if (GetSimpleSelection(window->buffer, &left, &right)) flags |= ACCUMULATE | REPLACE_SELECTION; else { left = 0; right = window->buffer->length; } } } else { if (GetSimpleSelection(window->buffer, &left, &right)) flags |= ACCUMULATE | REPLACE_SELECTION; else left = right = TextGetCursorPos(window->lastFocus); } } /* If the command requires the file be saved first, save it */ if (saveFirst) { if (!SaveWindow(window)) { if (input != FROM_NONE) XtFree(text); free(subsCommand); return; } } /* If the command requires the file to be reloaded after execution, set a flag for issueCommand to deal with it when execution is complete */ if (loadAfter) flags |= RELOAD_FILE_AFTER; /* issue the command */ issueCommand(inWindow, subsCommand, text, textLen, flags, outWidget, left, right, fromMacro); free(subsCommand); }
void RInterface::issueCommand (const QString &command, int type, const QString &rk_equiv, RCommandReceiver *receiver, int flags, RCommandChain *chain) { RK_TRACE (RBACKEND); issueCommand (new RCommand (command, type, rk_equiv, receiver, flags), chain); }
bool NXTCam::camFirmware() { return issueCommand('V'); }
bool NXTCam::illuminationOn() { return issueCommand('I'); }