static int motorAxisSetDouble(AXIS_HDL pAxis, motorAxisParam_t function, double value) { int ret_status = MOTOR_AXIS_ERROR; double deviceValue; char buff[100]; if (pAxis == NULL) return MOTOR_AXIS_ERROR; else { epicsMutexLock(pAxis->mutexId); switch (function) { case motorAxisPosition: { deviceValue = value*pAxis->stepSize; sprintf(buff, "%dSH%.*f;%dDH;%dSH%.*f", pAxis->axis+1, pAxis->maxDigits, deviceValue, pAxis->axis+1, pAxis->axis+1, pAxis->maxDigits, pAxis->homePreset); ret_status = sendOnly(pAxis->pController, buff); break; } case motorAxisEncoderRatio: { PRINT(pAxis->logParam, MOTOR_ERROR, "motorAxisSetDouble: MM4000 does not support setting encoder ratio\n"); break; } case motorAxisResolution: { PRINT(pAxis->logParam, MOTOR_ERROR, "motorAxisSetDouble: MM4000 does not support setting resolution\n"); break; } case motorAxisLowLimit: { deviceValue = value*pAxis->stepSize; sprintf(buff, "%dSL%.*f", pAxis->axis+1, pAxis->maxDigits, deviceValue); ret_status = sendOnly(pAxis->pController, buff); break; } case motorAxisHighLimit: { deviceValue = value*pAxis->stepSize; sprintf(buff, "%dSR%.*f", pAxis->axis+1, pAxis->maxDigits, deviceValue); ret_status = sendOnly(pAxis->pController, buff); break; } case motorAxisPGain: { PRINT(pAxis->logParam, MOTOR_ERROR, "MM4000 does not support setting proportional gain\n"); break; } case motorAxisIGain: { PRINT(pAxis->logParam, MOTOR_ERROR, "MM4000 does not support setting integral gain\n"); break; } case motorAxisDGain: { PRINT(pAxis->logParam, MOTOR_ERROR, "MM4000 does not support setting derivative gain\n"); break; } default: PRINT(pAxis->logParam, MOTOR_ERROR, "motorAxisSetDouble: unknown function %d\n", function); break; } if (ret_status == MOTOR_AXIS_OK ) { motorParam->setDouble(pAxis->params, function, value); motorParam->callCallback(pAxis->params); } epicsMutexUnlock(pAxis->mutexId); } return ret_status; }
void AbstractFileInterfaceNode::Start( bigtime_t performance_time) { PRINT("AbstractFileInterfaceNode::Start(pt=%lld)\n",performance_time); BMediaEventLooper::Start(performance_time); }
static void dump_cook_context(COOKContext *q) { //int i=0; #define PRINT(a, b) av_dlog(q->avctx, " %s = %d\n", a, b); av_dlog(q->avctx, "COOKextradata\n"); av_dlog(q->avctx, "cookversion=%x\n", q->subpacket[0].cookversion); if (q->subpacket[0].cookversion > STEREO) { PRINT("js_subband_start", q->subpacket[0].js_subband_start); PRINT("js_vlc_bits", q->subpacket[0].js_vlc_bits); } av_dlog(q->avctx, "COOKContext\n"); PRINT("nb_channels", q->avctx->channels); PRINT("bit_rate", q->avctx->bit_rate); PRINT("sample_rate", q->avctx->sample_rate); PRINT("samples_per_channel", q->subpacket[0].samples_per_channel); PRINT("subbands", q->subpacket[0].subbands); PRINT("js_subband_start", q->subpacket[0].js_subband_start); PRINT("log2_numvector_size", q->subpacket[0].log2_numvector_size); PRINT("numvector_size", q->subpacket[0].numvector_size); PRINT("total_subbands", q->subpacket[0].total_subbands); }
void FlipTransition::stopFilter() { PRINT(("FlipTransition::stopFilter()\n")); }
static void DoMacro( char *line) /* The line of text that contains the macro * invocation. */ { char *p, *end; int quote; /* * If there is no macro name, then just skip the whole line. */ if ((line[1] == 0) || (isspace(line[1]))) { return; } PRINT(("macro")); if (*line != '.') { PRINT(("2")); } /* * Parse the arguments to the macro (including the name), in order. */ p = line+1; while (1) { PRINTC(' '); if (*p == '"') { /* * The argument is delimited by quotes. */ for (end = p+1; *end != '"'; end++) { if (*end == 0) { fprintf(stderr, "Unclosed quote in macro call on line %d.\n", lineNumber); status = 1; break; } } QuoteText(p+1, (end-(p+1))); } else { quote = 0; for (end = p+1; (*end != 0) && (quote || !isspace(*end)); end++) { if (*end == '\'') { quote = !quote; } } QuoteText(p, end-p); } if (*end == 0) { break; } p = end+1; while (isspace(*p)) { /* * Skip empty space before next argument. */ p++; } if (*p == 0) { break; } } PRINTC('\n'); }
void SER_AB8500_CORE_Init() { t_gic_error gic_error; t_uint32 old_datum,i; t_ser_ab8500_core_error ab8500_error; t_uint8 data_out[24], data_in[24]; t_gic_config_cntrl gic_config; (gic_config.prio_level) = GIC_PR_LEVEL_0; (gic_config.it_sec) = GIC_IT_NON_SEC; (gic_config.it_config) = GIC_IT_EDGE_SENSITIVE; (gic_config.cpu_num) = GIC_CPU_CORE_0; gic_error = GIC_DisableItLine(GIC_IRQ_N_LINE); if (gic_error != GIC_OK) { PRINT("GIC Disabling AB8500 Line error - %d\n", gic_error); } gic_error = GIC_DisableItLine(GIC_PRCMU_NON_SECURE_LINE); if (gic_error != GIC_OK) { PRINT("GIC Disabling PRCMU Line error - %d\n", gic_error); } gic_error = GIC_ConfigureIrqLine(GIC_IRQ_N_LINE, (t_gic_func_ptr) SER_AB8500_CORE_InterruptHandler, &gic_config); if (gic_error != GIC_OK) { PRINT("GIC Interrupt Handler Binding error - %d\n", gic_error); } gic_error = GIC_ChangeDatum(GIC_PRCMU_NON_SECURE_LINE, (t_gic_func_ptr) SER_AB8500_CORE_PRCMUInterruptHandler, (t_gic_func_ptr *)&old_datum); if (gic_error != GIC_OK) { PRINT("GIC Interrupt Handler Binding error - %d\n", gic_error); } for(i=0;i<0x17;i++) data_out[i]=0xFF; /* Disable all masks */ if(SER_AB8500_CORE_OK != SER_AB8500_CORE_Write(AB8500_CORE_INTERRUPT_BLOCK, AB8500_CORE_IT_MASK_1_REGISTER, 22, data_out)) { PRINT("SER_AB8500_CORE_Write(AB8500_CORE_INTERRUPT_BLOCK, AB8500_CORE_IT_MASK_1_REGISTER, 10, data_out) FAILED!!!."); return; } /* Read to clear all latches */ /*coverity[uninit_use_in_call]*/ if(SER_AB8500_CORE_OK != SER_AB8500_CORE_Read(AB8500_CORE_INTERRUPT_BLOCK, AB8500_CORE_IT_LATCH_1_REGISTER, 22, data_in, data_out)) { PRINT("SER_AB8500_CORE_Read(AB8500_CORE_INTERRUPT_BLOCK, AB8500_CORE_IT_LATCH_1_REGISTER, 24, data_in, data_out) FAILED!!!."); return; } #if 0 /* For USB */ /* Enable all reqd USB masks */ data_out[0]=0x00; if(SER_AB8500_CORE_OK != SER_AB8500_CORE_Write(0x0E, 0x69, 0x1, data_out)) { PRINT("SER_AB8500_CORE_Write(0x0E, 0x40, 0x17, data_out) FAILED!!!."); return; } data_out[0]=0x00; if(SER_AB8500_CORE_OK != SER_AB8500_CORE_Write(0x0E, 0x6F, 0x1, data_out)) { PRINT("SER_AB8500_CORE_Write(0x0E, 0x40, 0x17, data_out) FAILED!!!."); return; } data_out[0]=0x00; if(SER_AB8500_CORE_OK != SER_AB8500_CORE_Write(0x0E, 0x72, 0x1, data_out)) { PRINT("SER_AB8500_CORE_Write(0x0E, 0x40, 0x17, data_out) FAILED!!!."); return; } /* Watchdog settings: Enable*/ /* Watchdog settings: Enable */ data_out = 0x00; if(SER_AB8500_CORE_OK != SER_AB8500_CORE_Write(0x03, 0x2F, 0x01, &data_out)) { PRINT("SER_AB8500_CORE_Write(0x02, 0x01, 0x01, data_out) FAILED for data_out 0x01!!!"); return; } /* Watchdog settings: Kick */ data_out = 0x04; if(SER_AB8500_CORE_OK != SER_AB8500_CORE_Write(0x02, 0x2F, 0x01, &data_out)) { PRINT("SER_AB8500_CORE_Write(0x02, 0x01, 0x01, data_out) FAILED for data_out 0x03!!!."); return; } /* Watchdog settings: Disable */ data_out = 0x02; if(SER_AB8500_CORE_OK != SER_AB8500_CORE_Write(0x03, 0x2F, 0x01, &data_out)) { PRINT("SER_AB8500_CORE_Write(0x02, 0x01, 0x01, data_out) FAILED for data_out 0x00!!!."); return; } /* Set UsbDeviceModeEna in USBPhyCtrl Register */ data_out[0] = 0x01; /* Make this 2 for Host */ if(SER_AB8500_CORE_OK != SER_AB8500_CORE_Write(0x05, 0x8A, 0x01, data_out)) { PRINT("SER_AB8500_CORE_Write(0x05, 0x8A, 0x01, data_out) FAILED for data_out 0x02!!!."); return; } #endif gic_error = GIC_EnableItLine(GIC_IRQ_N_LINE); if (gic_error != GIC_OK) { PRINT("GIC Enabling AB8500 Line error - %d\n", gic_error); } // gic_error = GIC_EnableItLine(GIC_PRCMU_NON_SECURE_LINE); // if (gic_error != GIC_OK) // { // PRINT("GIC Enabling PRCMU Line error - %d\n", gic_error); // } ab8500_error = ab8500_set_default_config(); if(SER_AB8500_CORE_OK!=ab8500_error) { PRINT("\r\nSSP Configurations not set properly. Returned error %d\r\n", ab8500_error); } }
void FlipTransition::handleStopEvent( const media_timed_event* pEvent) { PRINT(("FlipTransition::handleStopEvent\n")); stopFilter(); }
void handle_device(AMDeviceRef device) { if (found_device) return; // handle one device only CFStringRef found_device_id = AMDeviceCopyDeviceIdentifier(device); PRINT ("found device id\n"); if (device_id != NULL) { if(strcmp(device_id, CFStringGetCStringPtr(found_device_id, CFStringGetSystemEncoding())) == 0) { found_device = true; } else { return; } } else { if (operation == OP_LIST_DEVICES) { printf ("%s\n", CFStringGetCStringPtr(found_device_id, CFStringGetSystemEncoding())); CFRetain(device); // don't know if this is necessary? return; } found_device = true; } CFRetain(device); // don't know if this is necessary? PRINT("[ 0%%] Found device (%s), beginning install\n", CFStringGetCStringPtr(found_device_id, CFStringGetSystemEncoding())); AMDeviceConnect(device); assert(AMDeviceIsPaired(device)); assert(AMDeviceValidatePairing(device) == 0); assert(AMDeviceStartSession(device) == 0); CFStringRef path = CFStringCreateWithCString(NULL, app_path, kCFStringEncodingASCII); CFURLRef relative_url = CFURLCreateWithFileSystemPath(NULL, path, kCFURLPOSIXPathStyle, false); CFURLRef url = CFURLCopyAbsoluteURL(relative_url); CFRelease(relative_url); int afcFd; int startServiceAFCRetval = AMDeviceStartService(device, CFSTR("com.apple.afc"), (service_conn_t *) &afcFd, NULL); printf("trying to start com.apple.afc : %d\n", startServiceAFCRetval); if( startServiceAFCRetval ) { sleep(1); //printf("trying to start com.apple.afc\n"); startServiceAFCRetval = AMDeviceStartService(device, CFSTR("com.apple.afc"), (service_conn_t *) &afcFd, NULL); } printf("trying to start com.apple.afc : %d\n", startServiceAFCRetval); assert(startServiceAFCRetval == 0); assert(AMDeviceStopSession(device) == 0); assert(AMDeviceDisconnect(device) == 0); if (operation == OP_INSTALL) { assert(AMDeviceTransferApplication(afcFd, path, NULL, transfer_callback, NULL) == 0); close(afcFd); } CFStringRef keys[] = { CFSTR("PackageType") }; CFStringRef values[] = { CFSTR("Developer") }; CFDictionaryRef options = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); AMDeviceConnect(device); assert(AMDeviceIsPaired(device)); assert(AMDeviceValidatePairing(device) == 0); assert(AMDeviceStartSession(device) == 0); int installFd; assert(AMDeviceStartService(device, CFSTR("com.apple.mobile.installation_proxy"), (service_conn_t *) &installFd, NULL) == 0); //assert(AMDeviceStopSession(device) == 0); //assert(AMDeviceDisconnect(device) == 0); if (operation == OP_INSTALL) { mach_error_t result = AMDeviceSecureInstallApplication(0, device, url, options, &operation_callback, 0); //mach_error_t result = AMDeviceInstallApplication(installFd, path, options, operation_callback, NULL); if (result != 0) { PRINT("AMDeviceInstallApplication failed: %d\n", result); exit(EXIT_FAILURE); } } else if (operation == OP_UNINSTALL) { mach_error_t result = AMDeviceUninstallApplication (installFd, path, NULL, operation_callback, NULL); if (result != 0) { PRINT("AMDeviceUninstallApplication failed: %d\n", result); exit(EXIT_FAILURE); } } assert(AMDeviceStopSession(device) == 0); assert(AMDeviceDisconnect(device) == 0); close(installFd); CFRelease(path); CFRelease(options); if (operation == OP_INSTALL) PRINT("[100%%] Installed package %s\n", app_path); else if (operation == OP_UNINSTALL) PRINT("[100%%] Uninstalled package %s\n", app_path); if (!debug) exit(EXIT_SUCCESS); // no debug phase AMDeviceConnect(device); assert(AMDeviceIsPaired(device)); assert(AMDeviceValidatePairing(device) == 0); assert(AMDeviceStartSession(device) == 0); PRINT("------ Debug phase ------\n"); mount_developer_image(device); // put debugserver on the device start_remote_debug_server(device); // start debugserver write_gdb_prep_cmds(device, url); // dump the necessary gdb commands into a file CFRelease(url); PRINT("[100%%] Connecting to remote debug server\n"); PRINT("-------------------------\n"); signal(SIGHUP, gdb_ready_handler); pid_t parent = getpid(); int pid = fork(); if (pid == 0) { system(GDB_SHELL); // launch gdb kill(parent, SIGHUP); // "No. I am your father." _exit(EXIT_SUCCESS); } }
void timeout_callback(CFRunLoopTimerRef timer, void *info) { if (!found_device) { PRINT("Timed out waiting for device.\n"); exit(EXIT_FAILURE); } }
void load_rom(struct mmu_t *mmu, const char *path) { FILE *romfile = fopen(path, "rb"); if(romfile == NULL) { ERROR("File error: does not exist?\n"); exit(1); } // Get file size fseek(romfile, 0L, SEEK_END); long size = ftell(romfile); fseek(romfile, 0L, SEEK_SET); INFO("File size is %ld\n", size); mmu->rom = (byte *)malloc(size * sizeof(byte)); if(mmu->rom == NULL) { ERROR("Memory error: unable to allocate enough ram\n"); exit(2); } long result = fread(mmu->rom, sizeof(byte), size, romfile); /* INFO("Result is %ld\n", result); */ if(result != size) { ERROR("Reading error\n"); exit(3); } fclose(romfile); // Allocate ERAM based on rom values at specific addresses and size of rom INFO("Internal RAM: "); switch(mmu->rom[0x0149]) { case 0: // No RAM // Optionally allocate 8 KB external ram PRINT("No internal RAM\n"); break; case 1: // 2 KB = 1 Bank PRINT("1 Bank (2 KB)\n"); mmu->eram = (byte *)malloc(2048 * sizeof(byte)); break; case 2: // 8 KB = 1 Bank PRINT("1 Bank (8 KB)\n"); mmu->eram = (byte *)malloc(8192 * sizeof(byte)); break; case 3: // 32 KB = 4 Banks PRINT("4 Banks (32 KB)\n"); mmu->eram = (byte *)malloc(32768 * sizeof(byte)); break; case 4: // 128 KB = 16 Banks PRINT("16 Banks (128 KB)\n"); mmu->eram = (byte *)malloc(128 * 1024 * sizeof(byte)); break; } // Set cartridge types mmu->rom_type = mmu->rom[0x0147]; #ifdef DEBUG INFO("Rom type: "); switch(mmu->rom_type) { case ROM_ONLY: // ROM Only PRINT("ROM only\n"); break; case MBC1: // ROM + MBC1 PRINT("MBC1\n"); break; case MBC1_RAM: // ROM + MBC1 + RAM PRINT("MBC1 + RAM\n"); break; case MBC1_RAM_BATT: // ROM + MBC1 + RAM + BATT PRINT("MBC1 + RAM + BATT\n"); break; case MBC2: // ROM + MBC2 PRINT("MBC2\n"); break; case MBC2_BATT: // ROM + MBC2 + BATT PRINT("MBC2 + BATT\n"); break; case RAM: // ROM + RAM PRINT("RAM\n"); break; case RAM_BATT: // ROM + RAM + BATT PRINT("RAM + BATT\n"); break; case MMMO1: // ROM + MMMO1 PRINT("MMMO1\n"); break; case MMMO1_SRAM: // ROM + MMMO1 + SRAM PRINT("MMMO1 + SRAM\n"); break; case 0xD: // ROM + MMMO1 + SRAM + BATT PRINT("MMMO1 + SRAM + BATT\n"); break; case 0xF: // ROM + MBC3 + TIMER + BATT PRINT("MBC3 + TIMER + BATT\n"); break; case 0x10: // ROM + MBC3 + TIMER + RAM + BATT PRINT("MBC3 + TIMER + RAM + BATT\n"); break; case 0x11: // ROM + MBC3 PRINT("MBC3\n"); break; case 0x12: // ROM + MBC3 + RAM PRINT("MBC3 + RAM\n"); break; case 0x13: // ROM + MBC3 + RAM + BATT PRINT("MBC3 + RAM + BATT\n"); break; case 0x19: // ROM + MBC5 PRINT("MBC5\n"); break; case 0x1A: // ROM + MBC5 + RAM PRINT("MBC5 + RAM\n"); break; case 0x1B: // ROM + MBC5 + RAM + BATT PRINT("MBC5 + RAM + BATT\n"); break; case 0x1C: // ROM + MBC5 + RUMBLE PRINT("MBC5 + RUMBLE\n"); break; case 0x1D: // ROM + MBC5 + RUMBLE + SRAM PRINT("MBC5 + RUMBLE + SRAM\n"); break; case 0x1E: // ROM + MBC% + RUMBLE + SRAM + BATT PRINT("MBC5 + RUMBLE + SRAM + BATT\n"); break; case 0xFC: // Pocket Camera PRINT("Pocket Camera\n"); break; case 0xFD: // Bandai TAMA5 PRINT("Bandai TAMA5\n"); break; case 0xFE: // Hudson HuC-3 PRINT("Hudson HuC-3\n"); break; case 0xFF: // Hudson HuC-1 PRINT("Hudson HuC-1\n"); break; default: PRINT("Unknown 0x%02X\n", mmu->rom_type); } #endif }
/* * Inverts a square matrix (stored as a 1D float array) * * actualsize - the dimension of the matrix * * written by Mike Dinolfo 12/98 * version 1.0 */ void invert_cpu(float* data, int actualsize, float* log_determinant) { int maxsize = actualsize; int n = actualsize; *log_determinant = 0.0; /*DEBUG("\n\nR matrix before inversion:\n"); for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { DEBUG("%.4f ",data[i*n+j]); } DEBUG("\n"); }*/ if (actualsize == 1) { // special case, dimensionality == 1 *log_determinant = logf(data[0]); data[0] = 1.0 / data[0]; } else if(actualsize >= 2) { // dimensionality >= 2 for (int i=1; i < actualsize; i++) data[i] /= data[0]; // normalize row 0 for (int i=1; i < actualsize; i++) { for (int j=i; j < actualsize; j++) { // do a column of L float sum = 0.0; for (int k = 0; k < i; k++) sum += data[j*maxsize+k] * data[k*maxsize+i]; data[j*maxsize+i] -= sum; } if (i == actualsize-1) continue; for (int j=i+1; j < actualsize; j++) { // do a row of U float sum = 0.0; for (int k = 0; k < i; k++) sum += data[i*maxsize+k]*data[k*maxsize+j]; data[i*maxsize+j] = (data[i*maxsize+j]-sum) / data[i*maxsize+i]; } } for(int i=0; i<actualsize; i++) { *log_determinant += log10(fabs(data[i*n+i])); //printf("log_determinant: %e\n",*log_determinant); } //printf("\n\n"); for ( int i = 0; i < actualsize; i++ ) // invert L for ( int j = i; j < actualsize; j++ ) { float x = 1.0; if ( i != j ) { x = 0.0; for ( int k = i; k < j; k++ ) x -= data[j*maxsize+k]*data[k*maxsize+i]; } data[j*maxsize+i] = x / data[j*maxsize+j]; } for ( int i = 0; i < actualsize; i++ ) // invert U for ( int j = i; j < actualsize; j++ ) { if ( i == j ) continue; float sum = 0.0; for ( int k = i; k < j; k++ ) sum += data[k*maxsize+j]*( (i==k) ? 1.0 : data[i*maxsize+k] ); data[i*maxsize+j] = -sum; } for ( int i = 0; i < actualsize; i++ ) // final inversion for ( int j = 0; j < actualsize; j++ ) { float sum = 0.0; for ( int k = ((i>j)?i:j); k < actualsize; k++ ) sum += ((j==k)?1.0:data[j*maxsize+k])*data[k*maxsize+i]; data[j*maxsize+i] = sum; } /*DEBUG("\n\nR matrix after inversion:\n"); for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { DEBUG("%.2f ",data[i*n+j]); } DEBUG("\n"); }*/ } else { PRINT("Error: Invalid dimensionality for invert(...)\n"); } }
VOID APIENTRY BuildDocumentString() { register LPSTR p; register INT len; INT lenDocs; CHAR szT[10]; INT i; HKEY hk; ENTER("BuildDocumentString"); len = 32; /* Get all of the "Documents=" stuff. */ szDocuments = (LPSTR)LocalAlloc(LPTR, len); if (!szDocuments) return; while ((lenDocs = GetProfileString(szWindows, "Documents", szNULL, szDocuments, len-1)) == len-1) { len += 32; szDocuments = (LPSTR)LocalReAlloc((HANDLE)szDocuments, len, LMEM_MOVEABLE); if (!szDocuments) { LEAVE("BuildDocumentString"); return; } } lstrcat(szDocuments, szBlank); lenDocs++; p = (LPSTR)(szDocuments + lenDocs); /* Read all of the [Extensions] keywords into 'szDocuments'. */ while ((INT)GetProfileString(szExtensions, NULL, szNULL, p, len-lenDocs) > (len-lenDocs-3)) { len += 32; szDocuments = (LPSTR)LocalReAlloc((HANDLE)szDocuments, len, LMEM_MOVEABLE); if (!szDocuments) { LEAVE("BuildDocumentString"); return; } p = (LPSTR)(szDocuments + lenDocs); } /* Step through each of the keywords in 'szDocuments' changing NULLS into * spaces until a double-NULL is found. */ p = szDocuments; while (*p) { /* Find the next NULL. */ while (*p) p++; /* Change it into a space. */ *p = ' '; p++; } if (RegOpenKey(HKEY_CLASSES_ROOT,szNULL,&hk) == ERROR_SUCCESS) { /* now enumerate the classes in the registration database and get all * those that are of the form *.ext */ for (i = 0; RegEnumKey(hk,(DWORD)i,szT,sizeof(szT)) == ERROR_SUCCESS; i++) { if (szT[0] != '.' || (szT[1] && szT[2] && szT[3] && szT[4])) { /* either the class does not start with . or it has a greater * than 3 byte extension... skip it. */ continue; } if (FindExtensionInList(szT+2,szDocuments)) { // don't add it if it's already there! continue; } len += 4; szDocuments = (PSTR)LocalReAlloc((HANDLE)szDocuments, len, LMEM_MOVEABLE); if (!szDocuments) break; lstrcat(szDocuments, szT+1); lstrcat(szDocuments, szBlank); } RegCloseKey(hk); } PRINT(BF_PARMTRACE, "OUT: szDocuments=%s", szDocuments); LEAVE("BuildDocumentString - ok"); return; }
void UrlWrapper::ArgvReceived(int32 argc, char** argv) { if (argc <= 1) return; const char* failc = " || read -p 'Press any key'"; const char* pausec = " ; read -p 'Press any key'"; char* args[] = { (char *)"/bin/sh", (char *)"-c", NULL, NULL}; status_t err; BUrl url(argv[1]); BString full = BUrl(url).SetProtocol(BString()).UrlString(); BString proto = url.Protocol(); BString host = url.Host(); BString port = BString() << url.Port(); BString user = url.UserInfo(); BString pass = url.Password(); BString path = url.Path(); if (!url.IsValid()) { fprintf(stderr, "malformed url: '%s'\n", url.UrlString().String()); return; } // XXX: debug PRINT(("PROTO='%s'\n", proto.String())); PRINT(("HOST='%s'\n", host.String())); PRINT(("PORT='%s'\n", port.String())); PRINT(("USER='******'\n", user.String())); PRINT(("PASS='******'\n", pass.String())); PRINT(("PATH='%s'\n", path.String())); if (proto == "about") { app_info info; BString sig; // BUrl could get an accessor for the full - proto part... sig = host << "/" << path; BMessage msg(B_ABOUT_REQUESTED); if (be_roster->GetAppInfo(sig.String(), &info) == B_OK) { BMessenger msgr(sig.String()); msgr.SendMessage(&msg); return; } if (be_roster->Launch(sig.String(), &msg) == B_OK) return; be_roster->Launch("application/x-vnd.Haiku-About"); return; } if (proto == "telnet") { BString cmd("telnet "); if (url.HasUserInfo()) cmd << "-l " << user << " "; cmd << host; if (url.HasPort()) cmd << " " << port; PRINT(("CMD='%s'\n", cmd.String())); cmd << failc; args[2] = (char*)cmd.String(); be_roster->Launch(kTerminalSig, 3, args); return; } // see draft: // http://tools.ietf.org/wg/secsh/draft-ietf-secsh-scp-sftp-ssh-uri/ if (proto == "ssh") { BString cmd("ssh "); if (url.HasUserInfo()) cmd << "-l " << user << " "; if (url.HasPort()) cmd << "-oPort=" << port << " "; cmd << host; PRINT(("CMD='%s'\n", cmd.String())); cmd << failc; args[2] = (char*)cmd.String(); be_roster->Launch(kTerminalSig, 3, args); // TODO: handle errors return; } if (proto == "ftp") { BString cmd("ftp "); cmd << proto << "://"; /* if (user.Length()) cmd << "-l " << user << " "; cmd << host; */ cmd << full; PRINT(("CMD='%s'\n", cmd.String())); cmd << failc; args[2] = (char*)cmd.String(); be_roster->Launch(kTerminalSig, 3, args); // TODO: handle errors return; } if (proto == "sftp") { BString cmd("sftp "); //cmd << url; if (url.HasPort()) cmd << "-oPort=" << port << " "; if (url.HasUserInfo()) cmd << user << "@"; cmd << host; if (url.HasPath()) cmd << ":" << path; PRINT(("CMD='%s'\n", cmd.String())); cmd << failc; args[2] = (char*)cmd.String(); be_roster->Launch(kTerminalSig, 3, args); // TODO: handle errors return; } if (proto == "finger") { BString cmd("/bin/finger "); if (url.HasUserInfo()) cmd << user; if (url.HasHost() == 0) host = "127.0.0.1"; cmd << "@" << host; PRINT(("CMD='%s'\n", cmd.String())); cmd << pausec; args[2] = (char*)cmd.String(); be_roster->Launch(kTerminalSig, 3, args); // TODO: handle errors return; } if (proto == "http" || proto == "https" /*|| proto == "ftp"*/) { BString cmd("/bin/wget "); //cmd << url; cmd << proto << "://"; if (url.HasUserInfo()) cmd << user << "@"; cmd << full; PRINT(("CMD='%s'\n", cmd.String())); cmd << pausec; args[2] = (char*)cmd.String(); be_roster->Launch(kTerminalSig, 3, args); // TODO: handle errors return; } if (proto == "file") { BMessage m(B_REFS_RECEIVED); entry_ref ref; _DecodeUrlString(path); if (get_ref_for_path(path.String(), &ref) < B_OK) return; m.AddRef("refs", &ref); be_roster->Launch(kTrackerSig, &m); return; } // XXX:TODO: split options if (proto == "query") { // mktemp ? BString qname("/tmp/query-url-temp-"); qname << getpid() << "-" << system_time(); BFile query(qname.String(), O_CREAT|O_EXCL); // XXX: should check for failure BString s; int32 v; _DecodeUrlString(full); // TODO: handle options (list of attrs in the column, ...) v = 'qybF'; // QuerY By Formula XXX: any #define for that ? query.WriteAttr("_trk/qryinitmode", B_INT32_TYPE, 0LL, &v, sizeof(v)); s = "TextControl"; query.WriteAttr("_trk/focusedView", B_STRING_TYPE, 0LL, s.String(), s.Length()+1); s = full; PRINT(("QUERY='%s'\n", s.String())); query.WriteAttr("_trk/qryinitstr", B_STRING_TYPE, 0LL, s.String(), s.Length()+1); query.WriteAttr("_trk/qrystr", B_STRING_TYPE, 0LL, s.String(), s.Length()+1); s = "application/x-vnd.Be-query"; query.WriteAttr("BEOS:TYPE", 'MIMS', 0LL, s.String(), s.Length()+1); BEntry e(qname.String()); entry_ref er; if (e.GetRef(&er) >= B_OK) be_roster->Launch(&er); return; } if (proto == "sh") { BString cmd(full); if (_Warn(url.UrlString()) != B_OK) return; PRINT(("CMD='%s'\n", cmd.String())); cmd << pausec; args[2] = (char*)cmd.String(); be_roster->Launch(kTerminalSig, 3, args); // TODO: handle errors return; } if (proto == "beshare") { team_id team; BMessenger msgr(kBeShareSig); // if no instance is running, or we want a specific server, start it. if (!msgr.IsValid() || url.HasHost()) { be_roster->Launch(kBeShareSig, (BMessage*)NULL, &team); msgr = BMessenger(NULL, team); } if (url.HasHost()) { BMessage mserver('serv'); mserver.AddString("server", host); msgr.SendMessage(&mserver); } if (url.HasPath()) { BMessage mquery('quer'); mquery.AddString("query", path); msgr.SendMessage(&mquery); } // TODO: handle errors return; } if (proto == "icq" || proto == "msn") { // TODO team_id team; be_roster->Launch(kIMSig, (BMessage*)NULL, &team); BMessenger msgr(NULL, team); if (url.HasHost()) { BMessage mserver(B_REFS_RECEIVED); mserver.AddString("server", host); msgr.SendMessage(&mserver); } // TODO: handle errors return; } if (proto == "mms" || proto == "rtp" || proto == "rtsp") { args[0] = (char*)url.UrlString().String(); be_roster->Launch(kVLCSig, 1, args); return; } if (proto == "nfs") { BString parameter(host); _DecodeUrlString(path); if (url.HasPort()) parameter << ":" << port; //XXX: should not always be absolute! FIXME parameter << ":/" << path; BString prettyPath(path); prettyPath.Remove(0, prettyPath.FindLast("/") + 1); if (path == "" || path == "/") prettyPath = "root"; prettyPath << " on " << host; prettyPath.Prepend("/"); if (mkdir(prettyPath.String(), 0755) < 0) { perror("mkdir"); return; } dev_t volume; uint32 flags = 0; fprintf(stderr, "parms:'%s'\n", parameter.String()); volume = fs_mount_volume(prettyPath.String(), NULL, "nfs4", flags, parameter.String()); if (volume < B_OK) { fprintf(stderr, "fs_mount_volume: %s\n", strerror(volume)); return; } BMessage m(B_REFS_RECEIVED); entry_ref ref; if (get_ref_for_path(prettyPath.String(), &ref) < B_OK) return; m.AddRef("refs", &ref); be_roster->Launch(kTrackerSig, &m); return; } if (proto == "doi") { BString url("http://dx.doi.org/"); BString mimetype; url << full; BUrl u(url.String()); args[0] = const_cast<char*>("urlwrapper"); //XXX args[1] = (char*)u.UrlString().String(); args[2] = NULL; mimetype = kURLHandlerSigBase; mimetype += u.Protocol(); err = be_roster->Launch(mimetype.String(), 1, args + 1); if (err != B_OK && err != B_ALREADY_RUNNING) err = be_roster->Launch(kAppSig, 1, args + 1); // TODO: handle errors return; } /* More ? cf. http://en.wikipedia.org/wiki/URI_scheme cf. http://www.iana.org/assignments/uri-schemes.html Audio: (SoundPlay specific, identical to http:// to a shoutcast server) vnc: ? irc: ? im: http://tools.ietf.org/html/rfc3860 svn: handled by checkitout cvs: handled by checkitout git: handled by checkitout rsync: handled by checkitout - http://tools.ietf.org/html/rfc5781 smb: cifsmount ? nfs: mount_nfs ? http://tools.ietf.org/html/rfc2224 ipp: http://tools.ietf.org/html/rfc3510 mailto: ? Mail & Beam both handle it already (not fully though). imap: to describe mail accounts ? http://tools.ietf.org/html/rfc5092 pop: http://tools.ietf.org/html/rfc2384 mid: cid: as per RFC 2392 http://www.rfc-editor.org/rfc/rfc2392.txt query MAIL:cid message:<MID> http://daringfireball.net/2007/12/message_urls_leopard_mail itps: pcast: podcast: s//http/ + parse xml to get url to mp3 stream... audio: s//http:/ + default MediaPlayer -- see http://forums.winamp.com/showthread.php?threadid=233130 gps: ? I should submit an RFC for that one :) webcal: (is http: to .ics file) data: (but it's dangerous) */ }
static void MM4000Poller(MM4000Controller *pController) { /* This is the task that polls the MM4000 */ double timeout; AXIS_HDL pAxis; int status; int itera, j; int axisDone; int offset; int anyMoving; int comStatus; int forcedFastPolls=0; char *p, *tokSave; char statusAllString[BUFFER_SIZE]; char positionAllString[BUFFER_SIZE]; char buff[BUFFER_SIZE]; timeout = pController->idlePollPeriod; epicsEventSignal(pController->pollEventId); /* Force on poll at startup */ while (1) { if (timeout != 0.) status = epicsEventWaitWithTimeout(pController->pollEventId, timeout); else status = epicsEventWait(pController->pollEventId); if (status == epicsEventWaitOK) { /* We got an event, rather than a timeout. This is because other software * knows that an axis should have changed state (started moving, etc.). * Force a minimum number of fast polls, because the controller status * might not have changed the first few polls */ forcedFastPolls = 10; } anyMoving = 0; /* Lock all the controller's axis. */ for (itera = 0; itera < pController->numAxes; itera++) { pAxis = &pController->pAxis[itera]; if (!pAxis->mutexId) break; epicsMutexLock(pAxis->mutexId); } comStatus = sendAndReceive(pController, "MS;", statusAllString, sizeof(statusAllString)); if (comStatus == 0) comStatus = sendAndReceive(pController, "TP;", positionAllString, sizeof(positionAllString)); for (itera=0; itera < pController->numAxes; itera++) { pAxis = &pController->pAxis[itera]; if (!pAxis->mutexId) break; if (comStatus != 0) { PRINT(pAxis->logParam, MOTOR_ERROR, "MM4000Poller: error reading status=%d\n", comStatus); motorParam->setInteger(pAxis->params, motorAxisCommError, 1); } else { PARAMS params = pAxis->params; int intval, axisStatus; motorParam->setInteger(params, motorAxisCommError, 0); /* * Parse the status string * Status string format: 1MSx,2MSy,3MSz,... where x, y and z are the status * bytes for the motors */ offset = pAxis->axis*5 + 3; /* Offset in status string */ axisStatus = pAxis->axisStatus = statusAllString[offset]; if (axisStatus & MM4000_MOVING) { axisDone = 0; anyMoving = 1; } else axisDone = 1; motorParam->setInteger(params, motorAxisDone, axisDone); motorParam->setInteger(params, motorAxisHomeSignal, (axisStatus & MM4000_HOME)); motorParam->setInteger(params, motorAxisHighHardLimit, (axisStatus & MM4000_HIGH_LIMIT)); motorParam->setInteger(params, motorAxisLowHardLimit, (axisStatus & MM4000_LOW_LIMIT)); motorParam->setInteger(params, motorAxisDirection, (axisStatus & MM4000_DIRECTION)); motorParam->setInteger(params, motorAxisPowerOn, !(axisStatus & MM4000_POWER_OFF)); /* * Parse motor position * Position string format: 1TP5.012,2TP1.123,3TP-100.567,... * Skip to substring for this motor, convert to double */ strcpy(buff, positionAllString); tokSave = NULL; p = epicsStrtok_r(buff, ",", &tokSave); for (j=0; j < pAxis->axis; j++) p = epicsStrtok_r(NULL, ",", &tokSave); pAxis->currentPosition = atof(p+3); motorParam->setDouble(params, motorAxisPosition, (pAxis->currentPosition/pAxis->stepSize)); motorParam->setDouble(params, motorAxisEncoderPosn, (pAxis->currentPosition/pAxis->stepSize)); PRINT(pAxis->logParam, IODRIVER, "MM4000Poller: axis %d axisStatus=%x, position=%f\n", pAxis->axis, pAxis->axisStatus, pAxis->currentPosition); /* We would like a way to query the actual velocity, but this is not possible. If we could we could * set the direction, and Moving flags */ /* Check for controller error. */ comStatus = sendAndReceive(pController, "TE;", buff, sizeof(statusAllString)); if (buff[2] == '@') intval = 0; else { intval = 1; PRINT(pAxis->logParam, MOTOR_ERROR, "MM4000Poller: controller error %s\n", buff); } motorParam->setInteger(params, motorAxisProblem, intval); } motorParam->callCallback(pAxis->params); } /* Next axis */ /* UnLock all the controller's axis. */ for (itera = 0; itera < pController->numAxes; itera++) { pAxis = &pController->pAxis[itera]; if (!pAxis->mutexId) break; epicsMutexUnlock(pAxis->mutexId); } if (forcedFastPolls > 0) { timeout = pController->movingPollPeriod; forcedFastPolls--; } else if (anyMoving) timeout = pController->movingPollPeriod; else timeout = pController->idlePollPeriod; } /* End while */ }
PUBLIC t_ser_ab8500_core_error SER_AB8500_CORE_Read ( IN t_uint8 block_add, IN t_uint8 register_offset, IN t_uint8 count, IN t_uint8 *p_data_in, OUT t_uint8 *p_data_out ) { t_ser_ab8500_core_error error_ab8500 = SER_AB8500_CORE_OK; #ifndef __PRCM_HWI2C t_ssp_error error_ssp = SSP_OK; t_ssp_device_id ssp_device_id = SSP_DEVICE_ID_0; t_uint32 rx_element,index = 0x00; t_uint32 data_packet=0x00; if(SSP_OK != SSP_Enable(ssp_device_id, SSP_DISABLE_RX_TX)) { return(SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED); } /* flush receive fifo */ ser_ab8500_core_FlushRecieveFifo(); if(count <= SER_AB8500_CORE_SSPFIFO) { /* Perform Dummy read for first 0x00 data read with SSP */ error_ab8500 = ser_ab8500_ReadSingleFifoTransaction(0x01, 0x00, 1, p_data_in, p_data_out); if(SER_AB8500_CORE_OK != error_ab8500) { return(error_ab8500); } /* Now perform proper read */ error_ab8500 = ser_ab8500_ReadSingleFifoTransaction(block_add, register_offset, count, p_data_in, p_data_out); if(SER_AB8500_CORE_OK != error_ab8500) { return(error_ab8500); } } else { /* Perform Dummy read for first 0x00 data read with SSP */ error_ab8500 = ser_ab8500_ReadSingleFifoTransaction(0x01, 0x00, 1, p_data_in, p_data_out); if(SER_AB8500_CORE_OK != error_ab8500) { return(error_ab8500); } /* Now perform proper read */ while ((index < SER_AB8500_CORE_SSPFIFO) && (SSP_OK == error_ssp)) { /* Data transmitted is write command and block address */ block_add = (t_uint8)((MASK_BIT5) & block_add); data_packet = ((block_add << SHIFT_BYTE1) | register_offset); /* Tx FIFO is filled before enabling SSP */ data_packet = ((data_packet << SHIFT_AB8500_DATA) | *p_data_in); error_ssp = SSP_SetData(ssp_device_id,data_packet); p_data_in++; register_offset++; index++; } count = count - SER_AB8500_CORE_SSPFIFO; if(SSP_OK != error_ssp) { PRINT("SSP0 Error %d", error_ssp); return(SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED); } /* SSP is enabled */ if(SSP_OK != SSP_Enable(ssp_device_id, SSP_ENABLE_RX_TX)) { PRINT("SSP0 Error SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED"); return(SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED); } /* Data recieved */ index = 0; while (index < SER_AB8500_CORE_SSPFIFO) { if(SSP_OK != SSP_GetData(ssp_device_id,&rx_element)) { PRINT("SSP0 Error SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED"); return(SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED); } *p_data_out = (rx_element & MASK_ALL8); p_data_out++; index++; } while(count) { /* Data transmitted is write command and block address */ block_add = (t_uint8)((MASK_BIT5) & block_add); data_packet = ((block_add << SHIFT_BYTE1) | register_offset); /* Tx FIFO is filled before enabling SSP */ data_packet = ((data_packet << SHIFT_AB8500_DATA) | *p_data_in); if(SSP_OK != SSP_SetData(ssp_device_id,data_packet)) { PRINT("SSP0 Error SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED"); return(SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED); } p_data_in++; count--; if(SSP_OK != SSP_GetData(ssp_device_id,&rx_element)) { PRINT("SSP0 Error SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED"); return(SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED); } *p_data_out = (rx_element & MASK_ALL8); p_data_out++; register_offset++; } } if(SSP_OK != SSP_Enable(ssp_device_id, SSP_DISABLE_RX_TX)) { return(SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED); } #else error_ab8500 = SER_AB8500_CORE_ReadThruHWI2C(block_add, register_offset, count, p_data_in, p_data_out); #endif return(error_ab8500); }
int main(int argc, char *argv[]) { static struct option global_longopts[]= { { "quiet", no_argument, NULL, 'q' }, { "verbose", no_argument, NULL, 'v' }, { "timeout", required_argument, NULL, 't' }, { "id", required_argument, NULL, 'i' }, { "bundle", required_argument, NULL, 'b' }, { "debug", no_argument, NULL, 'd' }, { "args", required_argument, NULL, 'a' }, { NULL, 0, NULL, 0 }, }; char ch; while ((ch = getopt_long(argc, argv, "qvtibda:", global_longopts, NULL)) != -1) { switch (ch) { case 'q': quiet = 1; break; case 'v': verbose = 1; break; case 'd': debug = 1; break; case 't': timeout = atoi(optarg); break; case 'b': app_path = optarg; break; case 'a': args = optarg; break; case 'i': device_id = optarg; break; default: usage(argv[0]); return 1; } } if (optind >= argc) { usage(argv [0]); exit(EXIT_SUCCESS); } operation = OP_NONE; if (strcmp (argv [optind], "install") == 0) { operation = OP_INSTALL; } else if (strcmp (argv [optind], "uninstall") == 0) { operation = OP_UNINSTALL; } else if (strcmp (argv [optind], "list-devices") == 0) { operation = OP_LIST_DEVICES; } else { usage (argv [0]); exit(EXIT_SUCCESS); } if (operation != OP_LIST_DEVICES && !app_path) { usage(argv[0]); exit(EXIT_SUCCESS); } if (operation == OP_INSTALL) assert(access(app_path, F_OK) == 0); AMDSetLogLevel(1+4+2+8+16+32+64+128); // otherwise syslog gets flooded with crap if (timeout > 0) { CFRunLoopTimerRef timer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent() + timeout, 0, 0, 0, timeout_callback, NULL); CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopCommonModes); PRINT("[....] Waiting up to %d seconds for iOS device to be connected\n", timeout); } else { PRINT("[....] Waiting for iOS device to be connected\n"); } struct am_device_notification *notify; AMDeviceNotificationSubscribe(&device_callback, 0, 0, NULL, ¬ify); CFRunLoopRun(); }
void SER_AB8500_CORE_InterruptHandler(t_uint32 irq) { t_uint8 interrupt_source[22]; t_uint8 dummy_source[22]; t_ser_ab8500_core_param ab8500_param; t_gic_error gic_error; t_uint32 i; gic_error = GIC_DisableItLine(GIC_IRQ_N_LINE); if (gic_error != GIC_OK) { PRINT("GIC Disabling Genepi Line error - %d\n", gic_error); return; } for(i=0;i<22;i++) { interrupt_source[i]=0x00; } /*coverity[uninit_use_in_call]*/ if(SER_AB8500_CORE_OK !=SER_AB8500_CORE_Read(AB8500_CORE_INTERRUPT_BLOCK, AB8500_CORE_IT_LATCH_1_REGISTER, 22, dummy_source, interrupt_source)) { PRINT("SER_AB8500_CORE_Read error - \n"); return; } if (g_callback_ab8500_core.fct != 0) { if(SER_AB8500_CORE_TEST_BIT(interrupt_source[0],AB8500_CORE_IT_USBSUS_DETECT)) { ab8500_param.irq_src_register = AB8500_CORE_IT_LATCH_9_REGISTER; ab8500_param.irq_src = interrupt_source[0]; g_callback_ab8500_core.fct(g_callback_ab8500_core.param, &ab8500_param); } if(SER_AB8500_CORE_TEST_BIT(interrupt_source[0],AB8500_CORE_IT_USBCHARGER_DETECT)) { ab8500_param.irq_src_register = AB8500_CORE_IT_LATCH_9_REGISTER; ab8500_param.irq_src = interrupt_source[0]; g_callback_ab8500_core.fct(g_callback_ab8500_core.param, &ab8500_param); } if(SER_AB8500_CORE_TEST_BIT(interrupt_source[1],AB8500_CORE_IT_VBUS_DETECTR)) { ab8500_param.irq_src_register = AB8500_CORE_IT_LATCH_18_REGISTER; ab8500_param.irq_src = interrupt_source[1]; g_callback_ab8500_core.fct(g_callback_ab8500_core.param, &ab8500_param); } if(SER_AB8500_CORE_TEST_BIT(interrupt_source[1],AB8500_CORE_IT_VBUS_DETECTF)) { ab8500_param.irq_src_register = AB8500_CORE_IT_LATCH_18_REGISTER; ab8500_param.irq_src = interrupt_source[1]; g_callback_ab8500_core.fct(g_callback_ab8500_core.param, &ab8500_param); } } gic_error = GIC_EnableItLine(GIC_IRQ_N_LINE); if (gic_error != GIC_OK) { PRINT("GIC Enabling AB8500 Line error - %d\n", gic_error); } return; }
AppWindow::AppWindow(BMessage* archive) : BWindow(archive) { PRINT(("AppWindow::AppWindow(BMessage*)\n")); InitWindow(); }
void CCalibrateKinect::locate2DCorners ( const std::vector< cv::Mat >& vImages_, const int& nX_, const int& nY_, std::vector< std::vector<cv::Point2f> >* pvv2DCorners_, int nPatternType_ ) const //nPatternType_ = SQUARE { CHECK ( !vImages_.empty(), "locate2DCorners(): no images.\n" ); if ( SQUARE == nPatternType_ ) { std::cout << " locate chessboard corners.\n "; pvv2DCorners_->clear(); cv::Size patternSize ( nX_, nY_ ); for ( unsigned int i = 0; i < vImages_.size(); i++ ) { const cv::Mat& cvFrame = vImages_[i] ; std::vector<cv::Point2f> vCurrentCorners;//float 2d point is required by the OpenCV API. //locate corners roughly bool _bChessBoardCornersFoundThisFrame = cv::findChessboardCorners ( cvFrame, patternSize, vCurrentCorners, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS ); CHECK ( _bChessBoardCornersFoundThisFrame, " No corners are found.\n" ); PRINT( vCurrentCorners.size() ); //locate corners in sub-pixel level cv::Mat cvFrameGrey; cv::cvtColor ( cvFrame, cvFrameGrey, CV_BGR2GRAY ); cv::cornerSubPix ( cvFrameGrey, vCurrentCorners, cv::Size ( 9, 9 ), cv::Size ( -1, -1 ), cv::TermCriteria ( CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 30, 0.1 ) ); //store the corners inpto a std::vector pvv2DCorners_->push_back ( vCurrentCorners ); } } else if ( CIRCLE == nPatternType_ ) { std::cout << "locate circle centers.\n" ; pvv2DCorners_->clear(); PRINT( nX_ ); PRINT( nY_ ); cv::Size patternSize ( nX_, nY_ ); for ( unsigned int i = 0; i < vImages_.size(); i++ ) { const cv::Mat& cvFrame = vImages_[i] ; cv::Mat cvmTmp; cv::cvtColor ( cvFrame, cvmTmp, CV_RGB2GRAY ); std::vector<cv::Point2f> vCurrentCorners;//float 2d point is required by the OpenCV API. //locate corners roughly bool _bChessBoardCornersFoundThisFrame = cv::findCirclesGrid ( cvmTmp, patternSize, vCurrentCorners, cv::CALIB_CB_ASYMMETRIC_GRID ); PRINT( vCurrentCorners.size() ); //CHECK ( _bChessBoardCornersFoundThisFrame, " No corners are found.\n" ); //store the corners inpto a std::vector pvv2DCorners_->push_back ( vCurrentCorners ); } } return; }
AppWindow::~AppWindow() { PRINT(("AppWindow::~AppWindow()\n")); }
void FlipTransition::ignoreEvent(const media_timed_event* pEvent) { PRINT(("FlipTransition::ignoreEvent\n")); }
void AppWindow::InitWindow() { PRINT(("AppWindow::InitWindow()\n")); fOpenPanel = new BFilePanel(B_OPEN_PANEL, NULL, NULL, B_FILE_NODE, true, NULL, NULL, false, true); m_menu_bar = new BMenuBar("menuBar"); //create file menu m_file_menu = new BMenu(FILE_MENU); m_open_menu_item = new BMenuItem(OPEN_ITEM, new BMessage(MSG_FILE_OPEN), OPEN_SHORTCUT); m_about_menu_item = new BMenuItem(ABOUT_ITEM, new BMessage(B_ABOUT_REQUESTED)); m_quit_menu_item = new BMenuItem(QUIT_ITEM, new BMessage(B_QUIT_REQUESTED), QUIT_SHORTCUT); m_file_menu->AddItem(m_open_menu_item); m_file_menu->AddSeparatorItem(); m_file_menu->AddItem(m_about_menu_item); m_file_menu->AddSeparatorItem(); m_file_menu->AddItem(m_quit_menu_item); m_menu_bar->AddItem(m_file_menu); //create edit menu m_edit_menu = new BMenu(EDIT_MENU); m_cut_menu_item = new BMenuItem(CUT_ITEM, new BMessage(MSG_EDIT_CUT), CUT_ITEM_SHORTCUT); m_copy_menu_item = new BMenuItem(COPY_ITEM, new BMessage(MSG_EDIT_COPY), COPY_ITEM_SHORTCUT); m_paste_menu_item = new BMenuItem(PASTE_ITEM, new BMessage(MSG_EDIT_PASTE), PASTE_ITEM_SHORTCUT); m_select_all_menu_item = new BMenuItem(SELECT_ALL_ITEM, new BMessage(MSG_SELECT_ALL), SELECT_ALL_SHORTCUT); m_select_all_unsupported_menu_item = new BMenuItem(SELECT_ALL_UNSUPPORTED_ITEM, new BMessage(MSG_SELECT_ALL_UNSUPPORTED), SELECT_ALL_SHORTCUT, B_SHIFT_KEY); m_first_file_menu_item = new BMenuItem(FIRST_FILE_ITEM, new BMessage(MSG_FIRST_FILE), FIRST_FILE_SHORTCUT); m_last_file_menu_item = new BMenuItem(LAST_FILE_ITEM, new BMessage(MSG_LAST_FILE), LAST_FILE_SHORTCUT); m_previous_file_menu_item = new BMenuItem(PREVIOUS_FILE_ITEM, new BMessage(MSG_PREVIOUS_FILE), PREVIOUS_FILE_SHORTCUT); m_next_file_menu_item = new BMenuItem(NEXT_FILE_ITEM, new BMessage(MSG_NEXT_FILE), NEXT_FILE_SHORTCUT); m_reset_menu_item = new BMenuItem(RESET_ITEM, new BMessage(MSG_RESET), RESET_SHORTCUT); m_clear_list_menu_item = new BMenuItem(CLEAR_LIST_ITEM, new BMessage(MSG_CLEAR_LIST), CLEAR_LIST_SHORTCUT); m_edit_menu->AddItem(m_cut_menu_item); m_edit_menu->AddItem(m_copy_menu_item); m_edit_menu->AddItem(m_paste_menu_item); m_edit_menu->AddSeparatorItem(); m_edit_menu->AddItem(m_select_all_menu_item); m_edit_menu->AddItem(m_select_all_unsupported_menu_item); m_edit_menu->AddSeparatorItem(); m_edit_menu->AddItem(m_first_file_menu_item); m_edit_menu->AddItem(m_last_file_menu_item); m_edit_menu->AddSeparatorItem(); m_edit_menu->AddItem(m_previous_file_menu_item); m_edit_menu->AddItem(m_next_file_menu_item); m_edit_menu->AddSeparatorItem(); m_edit_menu->AddItem(m_reset_menu_item); m_edit_menu->AddItem(m_clear_list_menu_item); m_menu_bar->AddItem(m_edit_menu); //create mode menu m_mode_menu = new BMenu(MODE_MENU); m_mode_menu->AddItem(new BMenuItem(PREVIOUS_MODE_NAME, new BMessage(MSG_PREVIOUS_MODE), PREVIOUS_MODE_SHORTCUT)); m_mode_menu->AddItem(new BMenuItem(NEXT_MODE_NAME, new BMessage(MSG_NEXT_MODE), NEXT_MODE_SHORTCUT)); m_mode_menu->AddSeparatorItem(); m_mode_menu->AddItem(new BMenuItem(EDITOR_MODE_NAME, new BMessage(MSG_EDITOR_MODE), '1')); m_mode_menu->AddItem(new BMenuItem(TA_MODE_NAME, new BMessage(MSG_TA_MODE), '2')); m_mode_menu->AddItem(new BMenuItem(NA_MODE_NAME, new BMessage(MSG_NA_MODE), '3')); m_mode_menu->AddSeparatorItem(); m_mode_menu->AddItem(new BMenuItem(MPEG_MODE_NAME, new BMessage(MSG_MPEG_MODE), '4')); #ifdef _TTE_ m_mode_menu->AddSeparatorItem(); m_mode_menu->AddItem(new BMenuItem(TT_INFO_MODE_NAME, new BMessage(MSG_TT_INFO_MODE), '5')); #endif m_menu_bar->AddItem(m_mode_menu); m_help_menu = new BMenu(HELP_MENU); m_readme_item = new BMenuItem(README_ITEM, new BMessage(MSG_README)); m_changelog_item = new BMenuItem(CHANGELOG_ITEM, new BMessage(MSG_CHANGELOG)); m_help_menu->AddItem(m_readme_item); m_help_menu->AddItem(m_changelog_item); m_menu_bar->AddItem(m_help_menu); // create options menu /* m_options_menu = new BMenu(OPTIONS_MENU); m_beep_menu_item = new BMenuItem(BEEP_ON_UNSUPPORTED, new BMessage(MSG_BEEP_ON_UNSUPPORTED)); m_options_menu->AddItem(m_beep_menu_item); m_menu_bar->AddItem(m_options_menu); */ // add m_app_view below menu bar SetKeyMenuBar(m_menu_bar); m_app_view = new AppView(); BLayoutBuilder::Group<>(this, B_VERTICAL) .Add(m_menu_bar) .Add(m_app_view); ResizeToPreferred(); }
void FlipTransition::BufferReceived(BBuffer* pBuffer) { ASSERT(pBuffer); // check buffer destination if ((pBuffer->Header()->destination != first_input.destination.id) && (pBuffer->Header()->destination != second_input.destination.id)) { PRINT(("FlipTransition::BufferReceived():\n" "\tBad destination.\n")); pBuffer->Recycle(); return; } if ((RunMode() != B_OFFLINE) && (pBuffer->Header()->time_source != TimeSource()->ID())) { PRINT(("* timesource mismatch\n")); } // check output if (m_output.destination == media_destination::null || !m_outputEnabled) { pBuffer->Recycle(); return; } if (pBuffer->Header()->destination != first_input.destination.id) {// buffer vient de la premiere entree firstInputBufferHere = true; firstBuffer = pBuffer; PRINT(("First Buffer Received\n")); } else {// buffer vient de la 2eme entree secondInputBufferHere = true; secondBuffer = pBuffer; PRINT(("Second Buffer Received\n")); } if (firstInputBufferHere && secondInputBufferHere) // que ce passe-t-il si l'un des producteurs n'est plus valable ? { // process and retransmit buffer MakeTransition(firstBuffer, secondBuffer); status_t err = SendBuffer(transitionBuffer, m_output.source, m_output.destination); if (err < B_OK) { PRINT(("FlipTransition::BufferReceived():\n" "\tSendBuffer() failed: %s\n", strerror(err))); transitionBuffer->Recycle(); } firstBuffer->Recycle(); secondBuffer->Recycle(); firstInputBufferHere = false; secondInputBufferHere = false; if (RunMode() == B_OFFLINE) { SetOfflineTime(transitionBuffer->Header()->start_time); // RequestAdditionalBuffer(first_input.source, OfflineTime()); // RequestAdditionalBuffer(second_input.source, OfflineTime()); } // sent! } }
// Force Exit due to FATAL ERROR!! void FATAL_ERROR() { PRINT("FATAL ERROR OCCURS!\n"); FinalizeTPMDOS(); exit(-1); }
static void DoText( char *line) /* The line of text. */ { char *p, *end; /* * Divide the line up into pieces consisting of backslash sequences, tabs, * and other text. */ p = line; while (*p != 0) { if (*p == '\t') { PRINT(("tab\n")); p++; } else if (*p != '\\') { /* * Ordinary text. */ for (end = p+1; (*end != '\\') && (*end != 0); end++) { /* Empty loop body. */ } PRINT(("text ")); QuoteText(p, end-p); PRINTC('\n'); p = end; } else { /* * A backslash sequence. There are particular ones that we * understand; output an error message for anything else and just * ignore the backslash. */ p++; if (*p == 'f') { /* * Font change. */ PRINT(("font %c\n", p[1])); p += 2; } else if (*p == '-') { PRINT(("dash\n")); p++; } else if (*p == 'e') { PRINT(("text \\\\\n")); p++; } else if (*p == '.') { PRINT(("text .\n")); p++; } else if (*p == '&') { p++; } else if (*p == '0') { PRINT(("text { }\n")); p++; } else if (*p == '(') { if ((p[1] == 0) || (p[2] == 0)) { fprintf(stderr, "Bad \\( sequence on line %d.\n", lineNumber); status = 1; } else { PRINT(("char {\\(%c%c}\n", p[1], p[2])); p += 3; } } else if (*p == 'N' && *(p+1) == '\'') { int ch; p += 2; sscanf(p,"%d",&ch); PRINT(("text \\u%04x\n", ch)); while(*p&&*p!='\'') p++; p++; } else if (*p != 0) { PRINT(("char {\\%c}\n", *p)); p++; } } } PRINT(("newline\n")); }
PUBLIC t_ser_ab8500_core_error SER_AB8500_CORE_Write ( IN t_uint8 block_add, IN t_uint8 register_offset, IN t_uint8 count, IN t_uint8 *p_data ) { t_ser_ab8500_core_error error_ab8500 = SER_AB8500_CORE_OK; #ifndef __PRCM_HWI2C t_uint32 delay = 0; t_uint32 data_packet = 0; t_ssp_error error_ssp = SSP_OK; t_uint32 index; t_ssp_device_id ssp_device_id = SSP_DEVICE_ID_0; error_ssp = SSP_Enable(ssp_device_id, SSP_DISABLE_RX_TX); if(SSP_OK != error_ssp) { error_ab8500 = SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED; return(error_ab8500); } /* flush receive fifo */ ser_ab8500_core_FlushRecieveFifo(); /* Fill the Tx FIFO */ index = 0; if(count <= SER_AB8500_CORE_SSPFIFO) { while ((index < count) && (SSP_OK == error_ssp)) { /* Data transmitted is write command and block address */ block_add = (t_uint8)((~MASK_BIT5) & block_add); data_packet = ((block_add << SHIFT_BYTE1) | register_offset); /* Tx FIFO is filled before enabling SSP */ data_packet = ((data_packet << SHIFT_AB8500_DATA) | *p_data); error_ssp = SSP_SetData(ssp_device_id,data_packet); if(SSP_OK != error_ssp) { PRINT("SSP0 Error %d", error_ssp); error_ab8500 = SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED; return(error_ab8500); } p_data++; register_offset++; index++; for(delay=0; delay<AB8500_CORE_MAX_SSPWRITE_DELAY; delay++); } /* SSP is enabled */ error_ssp = SSP_Enable(ssp_device_id, SSP_ENABLE_RX_TX); if(SSP_OK != error_ssp) { error_ab8500 = SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED; PRINT("SSP0 Error %d", error_ssp); return(error_ab8500); } } else { while ((index < SER_AB8500_CORE_SSPFIFO) && (SSP_OK == error_ssp)) { /* Data transmitted is write command and block address */ block_add = (t_uint8)((~MASK_BIT5) & block_add); data_packet = ((block_add << SHIFT_BYTE1) | register_offset); /* Tx FIFO is filled before enabling SSP */ data_packet = ((data_packet << SHIFT_AB8500_DATA) | *p_data); error_ssp = SSP_SetData(ssp_device_id,data_packet); p_data++; register_offset++; index++; } count = count - SER_AB8500_CORE_SSPFIFO; if(SSP_OK != error_ssp) { PRINT("SSP0 Error %d", error_ssp); error_ab8500 = SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED; return(error_ab8500); } /* SSP is enabled */ error_ssp = SSP_Enable(ssp_device_id, SSP_ENABLE_RX_TX); if(SSP_OK != error_ssp) { error_ab8500 = SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED; PRINT("SSP0 Error %d", error_ssp); return(error_ab8500); } while(count) { /* Data transmitted is write command and block address */ block_add = (t_uint8)((~MASK_BIT5) & block_add); data_packet = ((block_add << SHIFT_BYTE1) | register_offset); /* Tx FIFO is filled before enabling SSP */ data_packet = ((data_packet << SHIFT_AB8500_DATA) | *p_data); error_ssp = SSP_SetData(ssp_device_id,data_packet); p_data++; register_offset++; count--; } /* SSP is enabled */ error_ssp = SSP_Enable(ssp_device_id, SSP_ENABLE_RX_TX); if(SSP_OK != error_ssp) { error_ab8500 = SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED; PRINT("SSP0 Error %d", error_ssp); return(error_ab8500); } } /* flush receive fifo */ ser_ab8500_core_FlushRecieveFifo(); for(delay=0; delay<AB8500_CORE_MAX_SSPWRITE_DELAY; delay++); if(SER_AB8500_CORE_OK == error_ab8500) { error_ssp = SSP_Enable(ssp_device_id, SSP_DISABLE_RX_TX); if(SSP_OK != error_ssp) { error_ab8500 = SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED; return(error_ab8500); } } #else error_ab8500 = SER_AB8500_CORE_WriteThruHWI2C(block_add, register_offset, count, p_data); #endif return(error_ab8500); }
void AbstractFileInterfaceNode::SetRunMode( run_mode mode) { PRINT("AbstractFileInterfaceNode::SetRunMode(%i)\n",mode); BMediaEventLooper::SetRunMode(mode); }
PRIVATE t_ser_ab8500_core_error ser_ab8500_ReadSingleFifoTransaction ( IN t_uint8 block_add, IN t_uint8 register_offset, IN t_uint32 count, IN t_uint8 *p_data_in, OUT t_uint8 *p_data_out ) { t_uint32 index=0x00, rx_element=0x0; t_uint32 data_packet=0x00, delay=0x00; t_ssp_error error_ssp = SSP_OK; while ((index < count) && (SSP_OK == error_ssp)) { /* Data transmitted is write command and block address */ block_add =(t_uint8) (MASK_BIT5 | block_add); data_packet = ((block_add << SHIFT_BYTE1) | register_offset); /* Tx FIFO is filled before enabling SSP */ data_packet = ((data_packet << SHIFT_AB8500_DATA) | *p_data_in); /* Dummy Data */ error_ssp = SSP_SetData(SSP_DEVICE_ID_0,data_packet); p_data_in++; register_offset++; index++; for(delay=0; delay<AB8500_CORE_MAX_SSPWRITE_DELAY; delay++); } for(delay=0; delay<AB8500_CORE_MAX_SSPWRITE_DELAY; delay++); /* SSP is enabled */ if(SSP_OK != SSP_Enable(SSP_DEVICE_ID_0, SSP_ENABLE_RX_TX)) { PRINT("SSP0 Error SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED"); return(SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED); } for(delay=0; delay<AB8500_CORE_MAX_SSPWRITE_DELAY; delay++); /* Data recieved */ index = 0; while ((index < count) && (SSP_OK == error_ssp)) { error_ssp = SSP_GetData(SSP_DEVICE_ID_0,&rx_element); *p_data_out = (rx_element & MASK_ALL8); p_data_out++; index++; if(SSP_OK != error_ssp) { PRINT("SSP0 Error %d", error_ssp); return(SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED); } for(delay=0; delay<AB8500_CORE_MAX_SSPWRITE_DELAY; delay++); } return(SER_AB8500_CORE_OK); }
void App::onGraphics (RenderDevice *rd, Array< SurfaceRef > &posed3D, Array< Surface2DRef > &posed2D) { rd->setColorClearValue(Color3::white()); rd->clear(); doFunStuff(); rd->push2D(); int w = rd->width(); int h = rd->height(); /////////////////////////////////////// // Left panel # define LABEL(str) p.y += titleFont->draw2D(rd, str, p - Vector2((float)w * 0.0075f, 0), s * 2, Color3::white() * 0.4f).y # define PRINT(str) p.y += reportFont->draw2D(rd, str, p, s, Color3::black()).y int x0 = int(w * 0.015f); // Cursor position Vector2 p(x0, h * 0.02f); // Font size float s = w * 0.013; LABEL("Shaders"); PRINT(std::string("Combiners: ") + combineShader); PRINT(std::string("Assembly: ") + asmShader); PRINT(std::string("GLSL: ") + glslShader); p.y += s * 2; LABEL("Extensions"); PRINT(std::string("FSAA: ") + ((GLCaps::supports("WGL_ARB_multisample") || GLCaps::supports("GL_ARB_multisample")) ? "Yes" : "No")); PRINT(std::string("Two-sided Stencil: ") + ((GLCaps::supports_two_sided_stencil() ? "Yes" : "No"))); PRINT(std::string("Stencil Wrap: ") + (GLCaps::supports("GL_EXT_stencil_wrap") ? "Yes" : "No")); PRINT(std::string("Texture Compression: ") + (GLCaps::supports("GL_EXT_texture_compression_s3tc") ? "Yes" : "No")); PRINT(std::string("Shadow Maps: ") + (GLCaps::supports("GL_ARB_shadow") ? "Yes" : "No")); PRINT(std::string("Frame Buffer Object: ") + (GLCaps::supports("GL_EXT_framebuffer_object") ? "Yes" : "No")); PRINT(std::string("Vertex Arrays: ") + (GLCaps::supports_GL_ARB_vertex_buffer_object() ? "Yes" : "No")); /////////////////////////////////////// // Right Panel x0 = int(w * 0.6f); // Cursor position p = Vector2(x0, h * 0.02f); // Graphics Card LABEL("Graphics Card"); rd->setTexture(0, cardLogo); Draw::rect2D(Rect2D::xywh(p.x - s * 6, p.y, s * 5, s * 5), rd); rd->setTexture(0, NULL); PRINT(GLCaps::vendor().c_str()); PRINT(GLCaps::renderer().c_str()); PRINT(format("Driver Version %s", GLCaps::driverVersion().c_str())); # ifdef G3D_WIN32 PRINT(format("%d MB Video RAM", DXCaps::videoMemorySize() / (1024 * 1024))); { uint32 ver = DXCaps::version(); PRINT(format("DirectX %d.%d", ver/100, ver%100)); } # endif p.y += s * 2; // Processor LABEL("Processor"); rd->setTexture(0, chipLogo); Draw::rect2D(Rect2D::xywh(p.x - s * 6, p.y, s * 5, s * 5), rd); rd->setTexture(0, NULL); PRINT(System::cpuVendor().c_str()); PRINT(System::cpuArchitecture().c_str()); Array<std::string> features; if (System::has3DNow()) { features.append("3DNow"); } if (System::hasMMX()) { features.append("MMX"); } if (System::hasSSE()) { features.append("SSE"); } if (System::hasSSE2()) { features.append("SSE2"); } if (chipSpeed != "") { PRINT(chipSpeed + " " + stringJoin(features, '/')); } else { PRINT(stringJoin(features, '/')); } p.y += s * 2; // Operating System LABEL("OS"); rd->setTexture(0, osLogo); Draw::rect2D(Rect2D::xywh(p.x - s * 6, p.y - s * 2, s * 5, s * 5), rd); rd->setTexture(0, NULL); if (beginsWith(System::operatingSystem(), "Windows 5.0")) { PRINT("Windows 2000"); } else if (beginsWith(System::operatingSystem(), "Windows 5.1")) { PRINT("Windows XP"); } PRINT(System::operatingSystem().c_str()); p.y += s * 3; x0 = int(w - s * 10); titleFont->draw2D(rd, "Features", p - Vector2(w * 0.0075f, 0), s * 2, Color3::white() * 0.4f); p.y += reportFont->draw2D(rd, format("f%d", featureRating), Vector2(x0, p.y), s*2, Color3::red() * 0.5).y; drawBar(rd, featureRating, p); // Designed to put NV40 at 50 performanceRating = log(rd->stats().frameRate) * 15.0f; p.y += s * 4; performanceButton = Rect2D::xywh(p, titleFont->draw2D(rd, "Speed", p - Vector2(w * 0.0075f, 0), s * 2, Color3::white() * 0.4f)); { float spd = iRound(performanceRating * 10) / 10.0f; p.y += reportFont->draw2D(rd, format("%5.1f", spd), Vector2(x0 - s*2, p.y), s*2, Color3::red() * 0.5).y; } drawBar(rd, (int)min(performanceRating, 100.0f), p); p.y += s * 4; titleFont->draw2D(rd, "Quality", p - Vector2(w * 0.0075f, 0), s * 2, Color3::white() * 0.4f); p.y += reportFont->draw2D(rd, quality(bugCount), Vector2(x0, p.y), s*2, Color3::red() * 0.5f).y; drawBar(rd, iClamp(100 - bugCount * 10, 0, 100), p); # undef PRINT p.y = h - 50; # define PRINT(str) p.y += reportFont->draw2D(rd, str, p, 8, Color3::black()).y; PRINT("These ratings are based on the performance of G3D apps."); PRINT("They may not be representative of overall 3D performance."); PRINT("Speed is based on both processor and graphics card. Upgrading"); PRINT("your graphics driver may improve Quality and Features."); # undef PRINT # undef LABEL switch (popup) { case NONE: break; case PERFORMANCE: { // Draw the popup box Rect2D box = drawPopup("Performance Details"); p.x = box.x0() + 10; p.y = box.y0() + 30; Vector2 spacing(box.width() / 6.5, 0); std::string str; float factor = 3 * vertexPerformance.numTris / 1e6; # define PRINT(cap, val) \ reportFont->draw2D(rd, cap, p, s, Color3::black());\ reportFont->draw2D(rd, (vertexPerformance.val[0] > 0) ? \ format("%5.1f", vertexPerformance.val[0]) : \ std::string("X"), p + spacing * 3, s, Color3::red() * 0.5, Color4::clear(), GFont::XALIGN_RIGHT);\ reportFont->draw2D(rd, (vertexPerformance.val[0] > 0) ? \ format("%5.1f", factor * vertexPerformance.val[0]) : \ std::string("X"), p + spacing * 4, s, Color3::red() * 0.5, Color4::clear(), GFont::XALIGN_RIGHT);\ reportFont->draw2D(rd, (vertexPerformance.val[1] > 0) ? \ format("%5.1f", vertexPerformance.val[1]) : \ std::string("X"), p + spacing * 5, s, Color3::red() * 0.5, Color4::clear(), GFont::XALIGN_RIGHT);\ p.y += reportFont->draw2D(rd, (vertexPerformance.val[1] > 0) ? \ format("%5.1f", factor * vertexPerformance.val[1]) : \ std::string("X"), p + spacing * 6, s, Color3::red() * 0.5, Color4::clear(), GFont::XALIGN_RIGHT).y; reportFont->draw2D(rd, "Incoherent", p + spacing * 3.5, s, Color3::black(), Color4::clear(), GFont::XALIGN_RIGHT); p.y += reportFont->draw2D(rd, "Coherent", p + spacing * 5.5, s, Color3::black(), Color4::clear(), GFont::XALIGN_RIGHT).y; reportFont->draw2D(rd, "FPS*", p + spacing * 3, s, Color3::black(), Color4::clear(), GFont::XALIGN_RIGHT); reportFont->draw2D(rd, "MVerts/s", p + spacing * 4, s, Color3::black(), Color4::clear(), GFont::XALIGN_RIGHT); reportFont->draw2D(rd, "FPS*", p + spacing * 5, s, Color3::black(), Color4::clear(), GFont::XALIGN_RIGHT).y; p.y += reportFont->draw2D(rd, "MVerts/s", p + spacing * 6, s, Color3::black(), Color4::clear(), GFont::XALIGN_RIGHT).y; PRINT("glBegin/glEnd", beginEndFPS); PRINT("glDrawElements", drawElementsRAMFPS); PRINT(" + VBO", drawElementsVBOFPS); PRINT(" + uint16", drawElementsVBO16FPS); PRINT(" + gl interleave", drawElementsVBOIFPS); PRINT(" + manual interleave", drawElementsVBOIMFPS); PRINT(" (without shading)", drawElementsVBOPeakFPS); reportFont->draw2D(rd, "glDrawArrays", p, s, Color3::black()); reportFont->draw2D(rd, (vertexPerformance.drawArraysVBOPeakFPS > 0) ? \ format("%5.1f", vertexPerformance.drawArraysVBOPeakFPS) : \ std::string("X"), p + spacing * 5, s, Color3::red() * 0.5, Color4::clear(), GFont::XALIGN_RIGHT);\ p.y += reportFont->draw2D(rd, (vertexPerformance.drawArraysVBOPeakFPS > 0) ? \ format("%5.1f", factor * vertexPerformance.drawArraysVBOPeakFPS) : \ std::string("X"), p + spacing * 6, s, Color3::red() * 0.5, Color4::clear(), GFont::XALIGN_RIGHT).y; # undef PRINT p.y += s; p.y += reportFont->draw2D(rd, format("* FPS at %d k polys/frame.", iRound(vertexPerformance.numTris / 1000.0)), p + Vector2(20, 0), s, Color3::black()).y; } } rd->pop2D(); }
void message_read(MSGQ_info ** msgq_info,int no_of_msgq) { char buf[MSGSIZE+1]={0}; struct mq_attr attr, old_attr; fd_set trans_fdset; struct timeval timeout; struct timeval start,end,diff; FD_ZERO(&trans_fdset); trans_fdset = read_fdset; timeout.tv_sec = 10; timeout.tv_usec = 0; int q_count=0; int ret=0; int i=0,prio; memset(&attr,0,sizeof(struct mq_attr)); memset(&old_attr,0,sizeof(struct mq_attr)); while(1) { gettimeofday(&start,NULL); if((ret = select((mq_info[no_of_msgq-1]).mq_des +1 ,&trans_fdset,NULL,NULL,NULL))>0) { for (i=0;i<no_of_msgq;i++) { PRINT(LOG_CRITICAL,"QUEUE No:%d\n",i); if(FD_ISSET(mq_info[i].mq_des,&trans_fdset)) { PRINT(LOG_DEBUG,"QUEUE No:%d\n",i); mq_getattr (mq_info[i].mq_des, &attr); printf ("%d messages are currently on the queue.\n", attr.mq_curmsgs); if ( attr.mq_curmsgs != 0) { /* There are some messages on this queue. First set the queue to not block any calls */ attr.mq_flags = O_NONBLOCK ;//MQ_NONBLOCK; mq_setattr (mq_info[i].mq_des, &attr, &old_attr); PRINT(LOG_CRITICAL,"\n %d %d ",old_attr.mq_maxmsg,old_attr.mq_msgsize); while (mq_receive (mq_info[i].mq_des, &buf, MSGSIZE+1, &prio) != -1) { MSG_DATA *msg =(MSG_DATA *)&buf; msg->data[msg->len]='\0'; PRINT(LOG_CRITICAL,"Received a message with priority %d.\n", prio); PRINT(LOG_CRITICAL,"Message %s.:length %d\n", msg->data,msg->len); memset(buf,0,sizeof(buf)); } } if (errno != EAGAIN) { perror ("mq_receive()"); exit (-1); } /* Now restore the old attributes */ FD_ZERO(&trans_fdset); mq_setattr (mq_info[i].mq_des, &old_attr, 0); } } trans_fdset = read_fdset; } gettimeofday(&end,NULL); diff = time_diff(start,end); printf ("DIFF::%llu.%.6llu",(unsigned long long)diff.tv_sec, (unsigned long long)diff.tv_usec); } }