void OfficeInputStream::initialize(const char *fileName, DocumentCache *cache) { PDFInputStream::initialize(NULL, cache); if (statusCode != 0) { int convTime = currentTimeMillis(); pid_t child = fork(); char *oldPath, *newPath; switch (child) { case -1: statusCode = 1; break; case 0: #if 0 oldPath = getenv("PATH"); if (oldPath == NULL) newPath = duplicateString(getenv("HOME")); else newPath = concatenateStrings(getenv("HOME"), ":", oldPath); setenv("PATH", newPath, 1); setenv("WUMPUS_CONVERSION_TARGET", tempFileName, 1); statusCode = executeCommand(OOFFICE, "-headless", "-p", fileName, NULL, INPUT_CONVERSION_TIMEOUT); #else oldPath = concatenateStrings(tempFileName, ".ps"); statusCode = executeCommand( "abiword", "--disable-crash-dialog", "-p", oldPath, fileName, INPUT_CONVERSION_TIMEOUT); if (statusCode == 0) statusCode = executeCommand( "ps2pdf", oldPath, tempFileName, INPUT_CONVERSION_TIMEOUT); if (statusCode == 0) statusCode = executeCommand( "rm", oldPath, NULL, INPUT_CONVERSION_TIMEOUT); free(oldPath); #endif exit(statusCode); default: waitpid(child, &statusCode, 0); break; } // end switch (child) if (statusCode == 0) { char *tempFile = duplicateString(tempFileName); PDFInputStream::initialize(tempFile, NULL); unlink(tempFile); free(tempFile); if ((statusCode == 0) && (cache != NULL)) { convTime = currentTimeMillis() - convTime; if (convTime < 0) convTime += 24 * 3600 * 1000; cache->addDocumentTextFromFile(originalFileName, tempFileName, convTime); } } } // end if (statusCode != 0) if (statusCode != 0) { inputFile = -1; unlink(tempFileName); } } // end of initialize(char*, DocumentCache*)
void PSInputStream::initialize(const char *fileName, DocumentCache *cache) { PDFInputStream::initialize(NULL, cache); if (statusCode != 0) { int convTime = currentTimeMillis(); statusCode = executeCommand((char*)PS2PDF, fileName, tempFileName, INPUT_CONVERSION_TIMEOUT); if (statusCode == 0) { char *tempFile = duplicateString(tempFileName); PDFInputStream::initialize(tempFile, NULL); unlink(tempFile); free(tempFile); if ((statusCode == 0) && (cache != NULL)) { convTime = currentTimeMillis() - convTime; if (convTime < 0) convTime += 24 * 3600 * 1000; cache->addDocumentTextFromFile(originalFileName, tempFileName, convTime); } } } // end if (statusCode != 0) if (statusCode != 0) { inputFile = -1; unlink(tempFileName); } } // end of initialize(char*, DocumentCache*)
static void testRusefiMethods(const int count) { time_t start, time; int tempi = 1; start = currentTimeMillis(); for (int i = 0; i < count; i++) tempi += getBaseTableFuel(testEngine.engineConfiguration, 4020, 2.21111); time = currentTimeMillis() - start; if (tempi != 0) scheduleMsg(logger, "Finished %d iterations of getBaseFuel in %dms", count, time); // start = currentTimeMillis(); // for (int i = 0; i < count; i++) // tempi += getFuelMs(1200, NULL); // todo // time = currentTimeMillis() - start; // if (tempi != 0) // scheduleMsg(logger, "Finished %d iterations of getFuelMs in %dms", count, time); start = currentTimeMillis(); for (int i = 0; i < count; i++) { testEngine.updateSlowSensors(); tempi += testEngine.engineState.clt; } time = currentTimeMillis() - start; if (tempi != 0) scheduleMsg(logger, "Finished %d iterations of updateSlowSensors in %dms", count, time); }
/** * Main program. */ int main (int argc, char **argv) { int i, r, c; long long int t1, t2; // Initialize MPI middleware. MPI_Init (&argc, &argv); world = MPI_COMM_WORLD; MPI_Comm_size (world, &size); MPI_Comm_rank (world, &rank); // Parse command line arguments. if (argc != 2) usage(); sscanf (argv[1], "%d", &n); // Allocate distance matrix. allocateDistanceMatrix(); // Run Floyd's Algorithm. // for i = 0 to N-1 // for r = 0 to N-1 // for c = 0 to N-1 // D[r,c] = min (D[r,c], D[r,i] + D[i,c]) t1 = currentTimeMillis(); for (i = 0; i < n; ++ i) { double *d_i; if (i < 0 || i >= n) outOfBounds(); d_i = d[i]; for (r = 0; r < n; ++ r) { double *d_r; if (r < 0 || r >= n) outOfBounds(); d_r = d[r]; for (c = 0; c < n; ++ c) { double d_r_c, d_r_i, d_i_c; if (c < 0 || c >= n) outOfBounds(); d_r_c = d_r[c]; if (i < 0 || i >= n) outOfBounds(); d_r_i = d_r[i]; if (c < 0 || c >= n) outOfBounds(); d_i_c = d_i[c]; if (c < 0 || c >= n) outOfBounds(); d_r[c] = min (d_r_c, d_r_i + d_i_c); } } } t2 = currentTimeMillis(); // Print running time. printf ("%lld msec\n", t2-t1); // Finalize MPI middleware. MPI_Finalize(); }
void render() { if (initialized == false) { glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); spherePositionsId = createSpherePositions(); sphereNormalsId = createSphereNormals(positions); createProgram(); startTimeMillis = currentTimeMillis(); initialized = true; } frameCount++; totalFrameCount++; long now = currentTimeMillis(); long elapsed = now - startTimeMillis; static long lastTimerCall = 0; if ((now - lastTimerCall) > 250) { timer(0); lastTimerCall = now; } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUseProgram(programId); // // calculate the ModelViewProjection and ModelViewProjection matrices // matrix44 tmp, mv, mvp, frustumMat, translateMat, rotateMat1, rotateMat2; frustum(frustumMat, left, right, bottom / aspectRatio, top / aspectRatio, nearPlane, farPlane); translate(translateMat, 0.0f, 0.0f, -3.0f); rotate(rotateMat1, 1.0f * elapsed / 50, 1.0f, 0.0f, 0.0f); rotate(rotateMat2, 1.0f * elapsed / 100, 0.0f, 1.0f, 0.0f); multm(tmp, rotateMat1, rotateMat2); multm(mv, translateMat, tmp); multm(mvp, frustumMat, mv); // set the uniforms before rendering GLuint mvpMatrixUniform = glGetUniformLocation(programId, "mvpMatrix"); GLuint mvMatrixUniform = glGetUniformLocation(programId, "mvMatrix"); GLuint colorUniform = glGetUniformLocation(programId, "color"); GLuint ambientUniform = glGetUniformLocation(programId, "ambient"); GLuint lightDirUniform = glGetUniformLocation(programId, "lightDir"); glUniformMatrix4fv(mvpMatrixUniform, 1, false, mvp); glUniformMatrix4fv(mvMatrixUniform, 1, false, mv); glUniform3f(lightDirUniform, 1.0f, -1.0f, -1.0f); glUniform4f(colorUniform, 0.5f, 0.5f, 0.5f, 1.0f); glUniform4f(ambientUniform, 0.1f, 0.1f, 0.1f, 1.0f); // render! renderSphere(); // display rendering buffer SDL_GL_SwapBuffers(); }
void WriteManager::run() { { Synchronized sync(transactionsLock); //swap the assignment and update queue volatile std::queue<NetworkTableEntry*>* tmp = incomingAssignmentQueue; incomingAssignmentQueue = outgoingAssignmentQueue; outgoingAssignmentQueue = tmp; tmp = incomingUpdateQueue; incomingUpdateQueue = outgoingUpdateQueue; outgoingUpdateQueue = tmp; } bool wrote = false; NetworkTableEntry* entry; while(!((std::queue<NetworkTableEntry*>*)outgoingAssignmentQueue)->empty()){ entry = ((std::queue<NetworkTableEntry*>*)outgoingAssignmentQueue)->front(); ((std::queue<NetworkTableEntry*>*)outgoingAssignmentQueue)->pop(); { Synchronized sync(entryStore.LOCK); entry->MakeClean(); wrote = true; receiver.offerOutgoingAssignment(entry); } } while(!((std::queue<NetworkTableEntry*>*)outgoingUpdateQueue)->empty()){ entry = ((std::queue<NetworkTableEntry*>*)outgoingUpdateQueue)->front(); ((std::queue<NetworkTableEntry*>*)outgoingUpdateQueue)->pop(); { Synchronized sync(entryStore.LOCK); entry->MakeClean(); wrote = true; receiver.offerOutgoingUpdate(entry); } } if(wrote){ receiver.flush(); lastWrite = currentTimeMillis(); } else if(currentTimeMillis()-lastWrite>keepAliveDelay) receiver.ensureAlive(); sleep_ms(20); }
void Animation::rewind() { forward = false; if (timer != NULL) { int elapsed = currentTimeMillis() - started; int remaining = duration - elapsed; started = currentTimeMillis() - remaining; } else { updateValue(1.); started = currentTimeMillis(); timer = new Timer(10, Animation_TimerCallback, (void*)this); } }
void GLTouchScreen::checkTimeout() { uint64_t time = currentTimeMillis(); if ((touchTimeout != 0) && (touchTimeout <= time)){ touchTimeout = 0; touchCancel = true; } }
void DrawBlock(int x, int y, Block* block, bool falling) { if (block->type < 0) return; const int y_cutoff = PANEL_START_Y+(PANEL_HEIGHT*BLOCK_SIZE); int draw_height = y_cutoff - y; if (draw_height > BLOCK_SIZE) draw_height = BLOCK_SIZE; if (draw_height <= 0) return; int color; BITMAP* bmp; if (falling) bmp = falling_block_bitmaps[block->type][falling_block_frame]; else if (block->popping && (((unsigned)currentTimeMillis() % (POP_FLASH_TIME*2)) < POP_FLASH_TIME)) { bmp = popping_block_bitmaps[block->type]; } else bmp = block_bitmaps[block->type]; masked_blit(bmp, buffer, 0, 0, x, y, BLOCK_SIZE, draw_height); }
/** * 'Write' command receives a single value at a given offset * @note Writing values one by one is pretty slow */ void handleWriteValueCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t page, uint16_t offset, uint8_t value) { tsState.writeValueCommandCounter++; currentPageId = page; tunerStudioDebug("got W (Write)"); // we can get a lot of these #if EFI_TUNER_STUDIO_VERBOSE // scheduleMsg(logger, "Page number %d\r\n", pageId); // we can get a lot of these #endif // int size = sizeof(TunerStudioWriteValueRequest); // scheduleMsg(logger, "Reading %d\r\n", size); if (offset > getTunerStudioPageSize(currentPageId)) { tunerStudioError("ERROR: out of range2"); scheduleMsg(&tsLogger, "ERROR offset %d", offset); offset = 0; return; } efitimems_t nowMs = currentTimeMillis(); if (nowMs - previousWriteReportMs > 5) { previousWriteReportMs = nowMs; scheduleMsg(&tsLogger, "page %d offset %d: value=%d", currentPageId, offset, value); } getWorkingPageAddr(currentPageId)[offset] = value; yellowMagic(currentPageId, offset, 1); // scheduleMsg(logger, "va=%d", configWorkingCopy.boardConfiguration.idleValvePin); }
void writeToFlash(void) { #if EFI_INTERNAL_FLASH persistentState.size = PERSISTENT_SIZE; persistentState.version = FLASH_DATA_VERSION; scheduleMsg(&logger, "flash compatible with %d", persistentState.version); crc_t result = flashStateCrc(&persistentState); persistentState.value = result; scheduleMsg(&logger, "Reseting flash: size=%d", PERSISTENT_SIZE); flashErase(FLASH_ADDR, PERSISTENT_SIZE); scheduleMsg(&logger, "Flashing with CRC=%d", result); efitimems_t nowMs = currentTimeMillis(); result = flashWrite(FLASH_ADDR, (const char *) &persistentState, PERSISTENT_SIZE); scheduleMsg(&logger, "Flash programmed in (ms): %d", currentTimeMillis() - nowMs); scheduleMsg(&logger, "Flashing result: %d", result); #endif /* EFI_INTERNAL_FLASH */ }
bool GLTouchScreen::canStartMouse() { if (touchTime == 0) { if (mouseRepeatTime == 0) return true; else { uint64_t time = currentTimeMillis(); return (time >= mouseRepeatTime + 200); } } else { uint64_t time = currentTimeMillis(); if (mouseRepeatTime == 0) return (time >= (touchTime + 1000)); else return ((time >= (touchTime + 1000)) && (time >= mouseRepeatTime + 200)); } }
// todo: re-use primary firmware implementation? int warning(obd_code_e code, const char *fmt, ...) { int now = currentTimeMillis() / 1000; if (absI(now - timeOfPreviousWarning) < 10) return TRUE; // we just had another warning, let's not spam timeOfPreviousWarning = now; printf("Warning: %s\r\n", fmt); return FALSE; }
void GLTouchScreen::onMouseOut(MotionEvent* event) { if (mouseDown) { mouseDown = false; mouseTime = currentTimeMillis(); MotionPointer* pointer = event->getPointer(0); analyze(pointer->x, pointer->y); } }
void GLTouchScreen::onTouchEnd(MotionEvent* event) { checkTimeout(); if (touchDown) { touchDown = false; touchTime = currentTimeMillis(); MotionPointer* pointer = event->getPointer(0); analyze(pointer->x, pointer->y); } }
void Animation::restart() { forward = true; updateValue(0.); started = currentTimeMillis(); if (timer == NULL) { timer = new Timer(10, Animation_TimerCallback, (void*)this); } }
/** * 'Burn' command is a command to commit the changes */ void handleBurnCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t page) { efitimems_t nowMs = currentTimeMillis(); tsState.burnCommandCounter++; tunerStudioDebug("got B (Burn)"); currentPageId = page; #if EFI_TUNER_STUDIO_VERBOSE // pointless since we only have one page now // scheduleMsg(logger, "Page number %d", currentPageId); #endif // todo: how about some multi-threading? memcpy(&persistentState.persistentConfiguration, &configWorkingCopy, sizeof(persistent_config_s)); requestBurn(); tunerStudioWriteCrcPacket(tsChannel, TS_RESPONSE_BURN_OK, NULL, 0); scheduleMsg(&tsLogger, "BURN in %dms", currentTimeMillis() - nowMs); }
static bool renderGL(void) { static const GLfloat verts[3][2] = { { -0.5, -0.5 }, { 0.5, -0.5 }, { 0.0, 0.5 } }; static const GLfloat colors[3][4] = { { 1, 0, 0, 1.0 }, { 0, 1, 0, 1.0 }, { 0, 0, 1, 1.0 } }; GLfloat angle; GLfloat matrix[4][4] = { { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } }; static const uint32_t speed_div= 5; EGLint rect[4]; glViewport( 0, 0, gDisplayWidth, gDisplayHeight ); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); gCurrTime= currentTimeMillis(); angle= ((gCurrTime-gStartTime) / speed_div) % 360 * M_PI / 180.0; matrix[0][0]= (1.0/3.0)*cos(angle); matrix[0][2]= (1.0/3.0)*sin(angle); matrix[1][1]= (1.0/3.0); matrix[2][0]= -(1.0/3.0)*sin(angle); matrix[2][2]= (1.0/3.0)*cos(angle); glUniform4f(gOffset, -0.3333+gCol*0.3333, 0.3333-gRow*0.3333, 0, 0 ); glUniformMatrix4fv(gXform, 1, GL_FALSE, (GLfloat *)matrix); glVertexAttribPointer(gPos, 2, GL_FLOAT, GL_FALSE, 0, verts); glVertexAttribPointer(gColor, 4, GL_FLOAT, GL_FALSE, 0, colors); glEnableVertexAttribArray(gPos); glEnableVertexAttribArray(gColor); glDrawArrays(GL_TRIANGLES, 0, 3); glDisableVertexAttribArray(gPos); glDisableVertexAttribArray(gColor); GLenum err= glGetError(); if ( err != GL_NO_ERROR ) { printf( "renderGL: glGetError() = %X\n", err ); } }
static void printGpsInfo(void) { scheduleMsg(&logging, "GPS RX %s", hwPortname(boardConfiguration->gps_rx_pin)); scheduleMsg(&logging, "GPS TX %s", hwPortname(boardConfiguration->gps_tx_pin)); scheduleMsg(&logging, "m=%d,e=%d: vehicle speed = %f\r\n", gpsMesagesCount, uartErrors, getCurrentSpeed()); float sec = currentTimeMillis() / 1000.0; scheduleMsg(&logging, "communication speed: %f", gpsMesagesCount / sec); print("GPS latitude = %f\r\n", GPSdata.latitude); print("GPS longitude = %f\r\n", GPSdata.longitude); }
void writeToFlashNow(void) { scheduleMsg(logger, " !!!!!!!!!!!!!!!!!!!! BE SURE NOT WRITE WITH IGNITION ON !!!!!!!!!!!!!!!!!!!!"); persistentState.size = PERSISTENT_SIZE; persistentState.version = FLASH_DATA_VERSION; scheduleMsg(logger, "flash compatible with %d", persistentState.version); crc_t crcResult = flashStateCrc(&persistentState); persistentState.value = crcResult; scheduleMsg(logger, "Reseting flash: size=%d", PERSISTENT_SIZE); flashErase(FLASH_ADDR, PERSISTENT_SIZE); scheduleMsg(logger, "Flashing with CRC=%d", crcResult); efitimems_t nowMs = currentTimeMillis(); int result = flashWrite(FLASH_ADDR, (const char *) &persistentState, PERSISTENT_SIZE); scheduleMsg(logger, "Flash programmed in %dms", currentTimeMillis() - nowMs); bool isSuccess = result == FLASH_RETURN_SUCCESS; if (isSuccess) { scheduleMsg(logger, FLASH_SUCCESS_MSG); } else { scheduleMsg(logger, "Flashing failed"); } maxLockTime = 0; }
//Funcion do GET void doGet(int socket, const char *localFilename, unsigned long size) { u_int writeBytes = 0; char *readBuffer; u_int readBytes = 0; u_long totalReadBytes = 0; int fd; int localError; u_long start; u_long end; debug(4,"Doing Get for: %s (%li)",localFilename,size); fd = open(localFilename,O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ); if(fd == -1) { //Error al crear el archivo local. localError = errno; debug(1,"Can't create Local File (%s)",strerror(localError)); return; } readBuffer = (char *) malloc(102400); start = currentTimeMillis(); while(totalReadBytes < size) { readBytes = read(socket,readBuffer,102400); if(readBytes > 0) { writeBytes = 0; while(writeBytes < readBytes) { writeBytes += write(fd,readBuffer+writeBytes,readBytes-writeBytes); } } totalReadBytes += readBytes; end = currentTimeMillis(); if(end>start) debug(4,"Get %lu/%lu ( %0.0f%% ) speed %lukbps",totalReadBytes,size,(((float)totalReadBytes/(float)size)*100),(totalReadBytes/(end-start)*1000/1024)); } free(readBuffer); close(fd); }
static void testSystemCalls(const int count) { time_t start, time; long result = 0; start = currentTimeMillis(); for (int i = 0; i < count / 2; i++) { // setPinValue(&testOutput, 0); // setPinValue(&testOutput, 1); } time = currentTimeMillis() - start; // Finished 100000 iterations of 'setPinValue()' in 120ms // prin("Finished %d iterations of 'setPinValue()' in %dms\r\n", count, time); start = currentTimeMillis(); for (int i = 0; i < count; i++) result += chTimeNow(); time = currentTimeMillis() - start; if (result != 0) { // Finished 100000 iterations of 'chTimeNow()' in 33ms scheduleMsg(logger, "Finished %d iterations of 'chTimeNow()' in %dms", count, time); } start = currentTimeMillis(); for (int i = 0; i < count; i++) { chSysLock() ; result += chTimeNow(); chSysUnlock() ; } time = currentTimeMillis() - start; if (result != 0) { // Finished 100000 iterations of 'chTimeNow()' with chSysLock in 144ms scheduleMsg(logger, "Finished %d iterations of 'chTimeNow()' with chSysLock in %dms", count, time); } start = currentTimeMillis(); for (int i = 0; i < count; i++) result += currentTimeMillis(); time = currentTimeMillis() - start; if (result != 0) scheduleMsg(logger, "Finished %d iterations of 'currentTimeMillis' in %dms", count, time); }
void ThreadScheduler::RunOnTaskThread(task_func* func, long millis, ...){ va_list ap; va_start(ap, millis); WaitingFuncTask task = WaitingFuncTask(); task.func = func; va_copy(task.args, ap); va_end(ap); task.at = currentTimeMillis() + millis; waitingFuncTasks.push_back(task); std::sort(waitingFuncTasks.begin(), waitingFuncTasks.end(), func_less_than_key()); }
int ThreadScheduler::Wait(lua_State* L, long millis){ long curTime = currentTimeMillis(); Task tsk = Task(); tsk.origin = L; tsk.at = curTime + millis; tsk.start = curTime; tsk.ref = -1; enqueue_task(tsk); return lua_yield(L, 2); }
static void autoIdle() { efitimems_t now = currentTimeMillis(); percent_t newValue = idlePositionController.getIdle(getRpmE(engine), now PASS_ENGINE_PARAMETER); if (currentIdleValve != newValue) { currentIdleValve = newValue; // todo: looks like in auto mode stepper value is not set, only solenoid? setIdleValvePwm(newValue); } }
/** * 'Burn' command is a command to commit the changes */ void handleBurnCommand(ts_response_format_e mode, uint16_t page) { efitimems_t nowMs = currentTimeMillis(); tsState.burnCommandCounter++; tunerStudioDebug("got B (Burn)"); tsState.currentPageId = page; #if EFI_TUNER_STUDIO_VERBOSE // pointless since we only have one page now // scheduleMsg(&logger, "Page number %d", tsState.currentPageId); #endif // todo: how about some multi-threading? memcpy(&persistentState.persistentConfiguration, &configWorkingCopy, sizeof(persistent_config_s)); #if EFI_INTERNAL_FLASH setNeedToWriteConfiguration(); #endif incrementGlobalConfigurationVersion(); tunerStudioWriteCrcPacket(TS_RESPONSE_BURN_OK, NULL, 0); scheduleMsg(&logger, "burned in (ms): %d", currentTimeMillis() - nowMs); }
static int recordCallback(const void *input_buffer, void *output_buffer, unsigned long frames_per_buffer, const PaStreamCallbackTimeInfo* time_info, PaStreamCallbackFlags status_flags, void *user_data) { (void)output_buffer; (void)time_info; (void)status_flags; RecordCallbackMetadata * meta_data = (RecordCallbackMetadata *)user_data; meta_data->num_frames += frames_per_buffer; long current_time = currentTimeMillis(); long delta = current_time - meta_data->start_time; if (delta >= INPUT_FORMAT_CHECK_INTERVAL) { printf("time delta: %lu, frames_per_buffer: %lu, frame delta: %lu, InputUnderflow: %d, InputOverflow: %d, OutputUnderflow: %d, OutputOverflow: %d, outputtonow: %f, nowtoinput: %f\n", delta, frames_per_buffer, meta_data->num_frames, (status_flags & paInputUnderflow) != 0, (status_flags & paInputOverflow) != 0, (status_flags & paOutputUnderflow) != 0, (status_flags & paOutputOverflow) != 0, time_info->outputBufferDacTime - time_info->currentTime, time_info->currentTime - time_info->inputBufferAdcTime ); meta_data->num_frames = 0; meta_data->start_time = current_time; } CircularBuffer * buffer = meta_data->buffer; const NUMERIC * reader = (const NUMERIC*)input_buffer; if (meta_data->stripe_input) { CircularBuffer_produce_blocking_striped(buffer, reader, frames_per_buffer, meta_data->number_of_channels, meta_data->enabled_channels); } else { CircularBuffer_produce_blocking(buffer, reader, frames_per_buffer * meta_data->number_of_channels); } return paContinue; }
static void updateTriggerShapeIfNeeded(PwmConfig *state) { if (atTriggerVersion < engine->triggerCentral.triggerShape.version) { atTriggerVersion = engine->triggerCentral.triggerShape.version; scheduleMsg(logger, "Stimulator: updating trigger shape: %d/%d %d", atTriggerVersion, getGlobalConfigurationVersion(), currentTimeMillis()); TriggerShape *s = &engine->triggerCentral.triggerShape; pin_state_t *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.waves[0].pinStates, s->wave.waves[1].pinStates, s->wave.waves[2].pinStates }; copyPwmParameters(state, s->getSize(), s->wave.switchTimes, PWM_PHASE_MAX_WAVE_PER_PWM, pinStates); state->safe.periodNt = -1; // this would cause loop re-initialization } }
static void updateTriggerShapeIfNeeded(PwmConfig *state) { if (emulatorConfigVersion.isOld()) { scheduleMsg(logger, "Stimulator: updating trigger shape: %d/%d %d", emulatorConfigVersion.getVersion(), getGlobalConfigurationVersion(), currentTimeMillis()); applyNonPersistentConfiguration(logger PASS_ENGINE_PARAMETER); TriggerShape *s = &engine->triggerShape; pin_state_t *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.waves[0].pinStates, s->wave.waves[1].pinStates, s->wave.waves[2].pinStates }; copyPwmParameters(state, s->getSize(), s->wave.switchTimes, PWM_PHASE_MAX_WAVE_PER_PWM, pinStates); state->safe.periodNt = -1; // this would cause loop re-initialization } }
void processGET(int socket, const char *localFilename, unsigned long size) { u_int writeBytes = 0,readBytes = 0; char *readBuffer; u_long totalReadBytes = 0; int fileDesc,localError; u_long inicio,fin; //Mostramos el GET con el nombre del archivo local y su tamaño en bytes fprintf(stderr,"Doing GET for: %s (%li Bytes)",localFilename,size); //abrimos el archivo recibido fileDesc = open(localFilename,O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ); if(fileDesc == -1) { //Error al crear el archivo local. localError = errno; fprintf(stderr,"Can't create Local File (%s)",strerror(localError)); return; } //Si no hubo error en la transferencia del archivo, lo escribimos en un archivo después de leerlo readBuffer = (char *) malloc(102400); inicio = currentTimeMillis(); //comienza la cuenta de milisegundos while(totalReadBytes < size) { readBytes = read(socket,readBuffer,102400); if(readBytes > 0) { writeBytes = 0; while(writeBytes < readBytes) { writeBytes += write(fileDesc,readBuffer+writeBytes,readBytes-writeBytes); } } totalReadBytes += readBytes; fin = currentTimeMillis(); //termina la cuenta if(fin>inicio) //Imprimimos la informacion de la transferencia del archivo fprintf(stderr,"Get %lu/%lu ( %0.0f%% ) speed %lukbps",totalReadBytes,size,(((float)totalReadBytes/(float)size)*100),(totalReadBytes/(fin-inicio)*1000/1024)); } free(readBuffer); //liberamos el bufer close(fileDesc); //y cerramos el archivo }