bool CMSWindowsKeyState::fakeCtrlAltDel() { if (!m_is95Family) { // to fake ctrl+alt+del on the NT family we broadcast a suitable // hotkey to all windows on the winlogon desktop. however, the // current thread must be on that desktop to do the broadcast // and we can't switch just any thread because some own windows // or hooks. so start a new thread to do the real work. HANDLE hEvtSendSas = OpenEvent( EVENT_MODIFY_STATE, FALSE, "Global\\SendSAS" ); if ( hEvtSendSas ) { LOG((CLOG_DEBUG "found the SendSAS event - signaling my launcher to simulate ctrl+alt+del")); SetEvent( hEvtSendSas ); CloseHandle( hEvtSendSas ); } else { CThread cad(new CFunctionJob(&CMSWindowsKeyState::ctrlAltDelThread)); cad.wait(); } } else { // simulate ctrl+alt+del fakeKeyDown(kKeyDelete, KeyModifierControl | KeyModifierAlt, virtualKeyToButton(VK_DELETE)); } return true; }
bool CMSWindowsKeyState::fakeCtrlAltDel() { if (!m_is95Family) { // to fake ctrl+alt+del on the NT family we broadcast a suitable // hotkey to all windows on the winlogon desktop. however, the // current thread must be on that desktop to do the broadcast // and we can't switch just any thread because some own windows // or hooks. so start a new thread to do the real work. CThread cad(new CFunctionJob(&CMSWindowsKeyState::ctrlAltDelThread)); cad.wait(); } else { // simulate ctrl+alt+del fakeKeyDown(kKeyDelete, KeyModifierControl | KeyModifierAlt, virtualKeyToButton(VK_DELETE)); } return true; }
void Deconvoluter::process() { std::string file = FileParser::getKey("TWINNED_MTZ", std::string("")); wangEnvName = FileParser::getKey("WANG_ENVELOPE_OUTPUT", std::string("wang.env")); molUnitName = FileParser::getKey("MOL_UNIT_ENVELOPE_OUTPUT", std::string("mol_unit.env")); tempFftMapName = FileParser::getKey("TEMP_FFT_MAP", std::string("temp_fft.map")); tempAveMapName = FileParser::getKey("TEMP_AVERAGE_MAP", std::string("temp_ave.map")); tempMtzName = FileParser::getKey("TEMP_AVERAGE_MTZ", std::string("temp_ave.mtz")); tempSortedMtzName = FileParser::getKey("TEMP_AVERAGE_SORTED_MTZ", std::string("temp_sorted_ave.mtz")); cadMtzName = FileParser::getKey("TEMP_CAD_MTZ", std::string("temp_cad.mtz")); fsmeltMtzName = FileParser::getKey("TEMP_FSMELT_MTZ", std::string("temp_fsmelt.mtz")); std::string fObsLab = FileParser::getKey("LABIN_AMPLITUDES", std::string("F")); std::string fCalcLab = FileParser::getKey("LABOUT_CALC_AMPLITUDES", std::string("FC")); std::string ncsDefs = FileParser::getKey("NCS_DEFINITIONS_FILE", std::string("")); std::vector<double> ccAll, ccSinglets, rAll, rSinglets; if (ncsDefs.length() == 0) { std::cout << "Warning! NCS definitions file missing. Please specify file in GAP format using keyword NCS_DEFINITIONS_FILE" << std::endl; exit(1); } int bins = 20; int maxCycles = FileParser::getKey("MAXIMUM_CYCLES", 10); if (file == "") { std::cout << "Twinned MTZ has not been provided, please provide file path under keyword TWINNED_MTZ" << std::endl; exit(1); } // loading original, twinned MTZ into memory. originalMtz = MtzPtr(new MtzManager(file)); originalMtz->loadReflections(false); MtzManager::setReference(&*originalMtz); spaceGroup = FileParser::getKey("SPACE_GROUP", originalMtz->getLowGroup()->spg_num); std::cout << "Loaded original MTZ file " << file << std::endl; bool skipFirst = FileParser::getKey("SKIP_FIRST_CYCLE", false); int beginning = FileParser::getKey("RESUME_FROM_CYCLE", 0); if (beginning > 0) skipFirst = true; for (int i = beginning; i < maxCycles; i++) { if (i > beginning || (i == beginning && !skipFirst)) { fastFourierTransform(file, tempFftMapName, (i > 0)); gapEnvelope(tempFftMapName); gapAverage(tempFftMapName, wangEnvName, molUnitName); map_to_sf(tempAveMapName, tempMtzName); sort_mtz(tempMtzName, tempSortedMtzName); cad(tempSortedMtzName, cadMtzName); fsmelt(file, cadMtzName, fsmeltMtzName); } MtzPtr nextMtz = MtzPtr(new MtzManager(fsmeltMtzName)); nextMtz->loadReflections(true); // fc in "intensity" and f in "fc"... nextMtz->applyScaleFactorsForBins(bins); nextMtz->individualDetwinningScales((i == maxCycles - 1)); nextMtz->copyOtherAmplitudesFromReference(); file = "detwinned_cycle_" + i_to_str(i) + ".mtz"; nextMtz->writeToFile(file); std::cout << "******************************" << std::endl; std::cout << "** CORRELATION (ALL) **" << std::endl; std::cout << "******************************" << std::endl; std::cout << std::endl << "Correlation between all scaled data and original twinned data" << std::endl; std::cout << std::endl << std::setw(15) << "Low res " << std::setw(15) << "High res " << std::setw(15) << "Correl" << std::setw(15) << "Num refl" << std::endl; ccAll.push_back(nextMtz->correlationWithManager(&*originalMtz, false, false, 0, 0, bins, NULL, false)); std::cout << "*******************************" << std::endl; std::cout << "** CORRELATION (SINGLETS) **" << std::endl; std::cout << "*******************************" << std::endl; std::cout << std::endl << "Correlation between singlet scaled data and original twinned data" << std::endl; std::cout << std::endl << std::setw(15) << "Low res " << std::setw(15) << "High res " << std::setw(15) << "Correl" << std::setw(15) << "Num refl" << std::endl; ccSinglets.push_back(nextMtz->correlationWithManager(&*originalMtz, false, false, 0, 0, bins, NULL, true)); std::cout << "******************************" << std::endl; std::cout << "** R FACTOR (ALL) **" << std::endl; std::cout << "******************************" << std::endl; std::cout << std::endl << "R factor between all scaled data and original twinned data" << std::endl; std::cout << std::endl << std::setw(15) << "Low res " << std::setw(15) << "High res " << std::setw(15) << "Correl" << std::setw(15) << "Num refl" << std::endl; rAll.push_back(nextMtz->rSplitWithManager(&*originalMtz, false, false, 0, 0, bins, NULL, false)); std::cout << "*******************************" << std::endl; std::cout << "** R FACTOR (SINGLETS) **" << std::endl; std::cout << "*******************************" << std::endl; std::cout << std::endl << "R factor between singlet scaled data and original twinned data" << std::endl; std::cout << std::endl << std::setw(15) << "Low res " << std::setw(15) << "High res " << std::setw(15) << "Correl" << std::setw(15) << "Num refl" << std::endl; rSinglets.push_back(nextMtz->rSplitWithManager(&*originalMtz, false, false, 0, 0, bins, NULL, true)); } std::cout << "*******************************" << std::endl; std::cout << "** END OF DECONVOLUTION **" << std::endl; std::cout << "*******************************" << std::endl; std::cout << std::endl << "Summary of deconvolution:" << std::endl << std::endl; std::cout << "Cycle\tCCall\tCCsinglets\tRall\tRsinglets" << std::endl; for (int i = 0; i < ccAll.size(); i++) { std::cout << i << "\t" << ccAll[i] << "\t" << ccSinglets[i] << "\t" << rAll[i] << "\t" << rSinglets[i] << std::endl; } }
void Configuracion::cargarArchivoConfig(){ char chr1='\0'; char chr2='\0'; vector<string> v; ManejadorDeArchivo man(this->rutaConfig); // Salteo el texto hasta llegar a detectar una doble barra "//" o llegar al EOF while ( ( (chr1!='/') || (chr2!='/') ) && (man.fin()!= true) ){ man.leer(&chr1,1); man.leer(&chr2,1); } // Si no se acabó el archivo comienzo el parseo while(man.fin()!= true){ man.leer(&chr1,1); if ( (chr1 == '-') || (chr1 == '+') ){ // El '-' indica que viene un argumento, el '+' indica un valor string cad(""); if (chr1 == '-') cad += "-"; man.leer(&chr1,1); while( (chr1 != ' ') && (man.fin()!= true) ){ cad += chr1; man.leer(&chr1,1); } v.push_back(cad); } } // Acá ya tengo lleno el vector de strings, ahora lo paso al argc y argv int argc = v.size()+1; // El "+1" es para no usar la posición [0] int i; char** argv = new char*[argc]; argv[0] = new char[(this->rutaConfig).size()+1](); strcpy (argv[0], (this->rutaConfig).c_str() ); for(i=0; i<(int)v.size() ; i++ ){ string dato (v[i]); int size = dato.size(); argv[i+1] = new char[size+1](); // El "+1" es por el caracter de fin de string al hacer strcpy strcpy (argv[i+1], dato.c_str()); } // Ahora cargo los parámetros que se obtuvieron del archivo de configuración this->rutaArbol = ""; this->rutaHash = ""; this->rutaApellidos= ""; this->rutaDistritos = ""; this->rutaDomicilios = ""; this->rutaDomicilios = ""; this->rutaLog = ""; this->rutaNombres = ""; this->rutaInformes = ""; this->claveVigenere = ""; this->tamanioNodo = 0; this->tamanioBucket = 0; int index,c; opterr = 0; optind = 1; // Inicalo la variable para poder usar el getopt otra vez while ((c = getopt (argc, (char* const*)argv, "A:D:N:B:P:S:M:C:R:L:I:K:")) != -1) switch (c){ case 'D': this->rutaHash = optarg; break; case 'A': this->rutaArbol = optarg; break; case 'N': this->tamanioNodo = atoi(optarg); break; case 'B': this->tamanioBucket = atoi(optarg); break; case 'P': this->rutaPass = optarg; break; case 'S': this->rutaApellidos = optarg; break; case 'M': this->rutaNombres = optarg; break; case 'C': this->rutaDistritos = optarg; break; case 'R': this->rutaDomicilios = optarg; break; case 'L': this->rutaLog = optarg; break; case 'I': this->rutaInformes = optarg; break; case 'K': this->claveVigenere = optarg; break; case '?': if (optopt == 'A')fprintf (stderr, "Arch. Config. > La opción -%c requiere un argumento.\n",optopt); else if (optopt == 'D')fprintf (stderr, "Arch. Config. > La opción -%c requiere un argumento.\n",optopt); else if (optopt == 'N')fprintf (stderr, "Arch. Config. > La opción -%c requiere un argumento.\n",optopt); else if (optopt == 'B')fprintf (stderr, "Arch. Config. > La opción -%c requiere un argumento.\n",optopt); else if (optopt == 'P')fprintf (stderr, "Arch. Config. > La opción -%c requiere un argumento.\n",optopt); else if (optopt == 'S')fprintf (stderr, "Arch. Config. > La opción -%c requiere un argumento.\n",optopt); else if (optopt == 'M')fprintf (stderr, "Arch. Config. > La opción -%c requiere un argumento.\n",optopt); else if (optopt == 'C')fprintf (stderr, "Arch. Config. > La opción -%c requiere un argumento.\n",optopt); else if (optopt == 'R')fprintf (stderr, "Arch. Config. > La opción -%c requiere un argumento.\n",optopt); else if (optopt == 'L')fprintf (stderr, "Arch. Config. > La opción -%c requiere un argumento.\n",optopt); else if (optopt == 'I')fprintf (stderr, "Arch. Config. > La opción -%c requiere un argumento.\n",optopt); else if (optopt == 'K')fprintf (stderr, "Arch. Config. > La opción -%c requiere un argumento.\n",optopt); else if (isprint (optopt)) fprintf (stderr, "Arch. Config. > Opción desconocida `-%c'.\n", optopt); else fprintf (stderr,"Arch. Config. > Caracter de opción desconocida `\\x%x'.\n",optopt); break; default: cerr << "Arch. Config. > Corregir archivo. "<<endl; cerr << "Para ayuda consulte con: -h"<<endl; break; } for (index = optind; index < argc; index++) cerr << "Arch. Config. > Opción inválida: " << argv[index] << endl; if( (this->rutaArbol == "") || (this->rutaHash == "") ){ cerr << "Arch. Config. > Falta la ruta de archivo de Árbol y/o Hash."<<endl; cerr << "Para ayuda consulte con: -h\nPrograma terminado."<<endl; exit(1); } // Libero la memoria que yo instancié for(i=0; i<argc ; i++ ){ delete[] argv[i]; } delete[] argv; }
int main() { int opprincipal = 0, sair = 1, esc1 = 0, i = 0, j = 0; cadastro mPreco; system("cls"); system("color 47"); fileindice = fopen("indice.txt", "r"); fscanf(fileindice, "%d", &y); fclose(fileindice); arquivoP = fopen("produtos.txt", "rb"); rewind(arquivoP); while(j <= y && !feof(arquivoP)) { fread(&produtos[j].qtdp, sizeof(cadastro), 1, arquivoP); fread(&produtos[j].codprod, sizeof(cadastro), 1, arquivoP); fread(&produtos[j].valorprod, sizeof(cadastro), 1, arquivoP); fread(&produtos[j].nomeprod, sizeof(cadastro), 1, arquivoP); j++; } while(capax == 0) { capa(); } while(opprincipal == 0) { printf("\n_________________M&R - SISTEMA DE ESTOQUE, VENDAS E RELATORIOS_________________\n\n\n"); printf("ESCOLHA UMA DAS OPCOES ABAIXO:\n\n"); printf("[1] - GERENCIAR ESTOQUE " "[2] - VENDAS " "[3] - RELATORIOS " "[4] - SAIR \n\n"); printf("-> "); scanf("%d", &opprincipal); switch(opprincipal) { case 1: system("cls"); printf("\n____________________M&R - GERENCIADOR DE ESTOQUE____________________\n\n\n"); printf("[1] - CADASTRAR NOVO PRODUTO\n" "[2] - EXCLUIR PRODUTO\n" "[3] - ATUALIZAR PRODUTO\n" "[4] - SAIR \n\n"); printf("-> "); scanf("%d", &esc1); switch(esc1) { case 1: cad(); break; case 2: exclui(); break; case 3: atualiza(); break; case 4: main(); break; default: printf("OPCAO INVALIDA!"); getchar(); main(); break; } break; case 2: vendas(); break; case 3: system("cls"); printf("\n____________________M&R - RELATORIOS____________________\n\n\n"); printf("[1] - GERAR RELATORIO DE PRODUTO ESPECIFICO\n" "[2] - GERAR RELATORIO COMPLETO\n" "[3] - GERAR RELATORIO MAIOR PRECO\n" "[4] - GERAR RELATORIO PRECO MEDIO DO ESTOQUE\n" "[5] - SAIR\n"); printf("-> "); scanf("%d", &esc1); switch(esc1) { case 1: break; case 2: imprime(); break; case 3: maiorpreco(produtos); break; default: printf("OPCAO INVALIDA!"); break; case 4: precomedio(); break; case 5: main(); } case 4: exit(1); case 10: capa(); break; default: printf("OPCAO INVALIDA!"); getch(); main(); } } return 0; }
void cad () { int i=0; int op; int sair = 1; while(sair == 1) { if (y == x - 1) { puts("NAO E POSSIVEL CADASTRAR!"); return; } y++; cadastro prod; system("cls"); printf("\n____________________M&R - CADASTRO DE PRODUTOS____________________\n\n"); // printf("VALOR DE X: %d\n", x); printf("INFORME A QUANTIDADE DO PRODUTO QUE DESEJA CADASTRAR:\n"); scanf("%d", &prod.qtdp); if (prod.qtdp < 10 ) //Verifica se quantidade é menor que 10. { puts("QUANTIDADE NAO PODE SER MENOR QUE 10:"); printf("\n"); y--; printf ("DESEJA CONTINUAR O CADASTRO"); printf("\n"); printf("1 - SIM 2 - NAO\n"); scanf("%d",&op); if (op == 1) { return (cad()); } else main (); } printf("CODIGO DO PRODUTO: "); scanf("%d", &prod.codprod); for(i = 0; i <= y; i++) { if(prod.codprod == produtos[i].codprod) //Verificar se existe codigos iguais no vetor. { printf("\n"); puts("CODIGO JA EXISTE! FAVOR CADASTRAR NOVAMENTE."); system("pause"); cad(); } } printf("VALOR UNITARIO DO PRODUTO: "); scanf("%f", &prod.valorprod); printf("IDENTIFICACAO DO PRODUTO: "); fflush(stdin); gets(&prod.nomeprod); produtos[y] = prod; printf("\nPRODUTO CADASTRADO COM SUCESSO!\n\n"); printf("CADASTRAR OUTRO PRODUTO?\n"); printf("1 - SIM 2 - NAO\n"); scanf("%d", &sair); if(sair == 2) { fileindice = fopen("indice.txt", "w+"); fprintf(fileindice, "%d", y); fclose(fileindice); arquivoP = fopen("produtos.txt", "wb"); for(i = 0 ; i <= y; i++) { fwrite(&produtos[i].qtdp, sizeof(cadastro), 1, arquivoP); fwrite(&produtos[i].codprod, sizeof(cadastro), 1, arquivoP); fwrite(&produtos[i].valorprod, sizeof(cadastro), 1, arquivoP); fwrite(&produtos[i].nomeprod, sizeof(cadastro), 1, arquivoP); } fclose(arquivoP); main(); } } }