MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow),media(0) { isConnected=false; controllerConnected=false; ui->setupUi(this); this->setWindowTitle("Au2"); instance = new VlcInstance(VlcCommon::args(), this); player = new VlcMediaPlayer(instance); player->setVideoWidget(ui->video); readDataFromFile(); data[1] = 0;//hastighed data[2] = 0;//afstand data[3] = 0;//acceleration data[4] = 1;//AKS = on ui->AKS->setText("AKS-On"); updateData(); connect(ui->OpretForbindelse, SIGNAL(clicked()), this, SLOT(Au2connect())); connect(ui->KonfigurerIP, SIGNAL(clicked()), this, SLOT(konfigurerIP())); connect(ui->AKS, SIGNAL(clicked()), this, SLOT(AKSstatus())); connect(ui->IndstilMaksHastighed, SIGNAL(clicked()), this, SLOT(maksHastighed())); connect(ui->KalibrerStyretoj, SIGNAL(clicked()), this, SLOT(kalibrerStyretoj())); connect(ui->LukNed, SIGNAL(clicked()), this, SLOT(shutDown())); connect(this, SIGNAL(sig_getData()), this, SLOT(readSocket())); }
int main( int argc, char *argv[]) { char req[204800], res[204800]; int a, code; if( argc != 5) { printf( "Usage : %s <call name> <ip> <port> <data file> \n", argv[0] ); return 0; } if (apr_initialize() != APR_SUCCESS) { fprintf(stderr, "Something went wrong\n"); exit(-1); } atexit(apr_terminate); AdpClient client( argv[2], atoi(argv[3]) ); client.init( "aaa" ); UDO_Init( req, sizeof(req) ); UDO_Init( res, sizeof(res) ); readDataFromFile( req, argv[4] ); UDO_Print( req ); a = client.call( argv[1],argv[1],req, res, 100 ); printf( "======================================\n" ); printf( "call return %d", a ); if( a != 0 ) { code = client.getError(); if( code == 9 ) { printf( " and server coredump" ); } else if( code == 10 ) { printf( " and server no such function" ); } else if( code == 6 || code == 2 ) { printf( " and server not started" ); } else { printf( " error code is %d", code ); } printf( " or %s\n", strerror(errno) ); return 2; } printf( " success\n" ); printf( "======================================\n" ); UDO_Print( res ); return -1; }
// Loads the data from CSVs to the data members. Does the median thresholding void DecisionTree::LoadAllData(){ vector<raw_data> rdata; string fnm = "train.csv"; readDataFromFile(fnm, rdata); vector<double> medians; refineDataForFirstPart(rdata, train, medians, true); rdata.clear(); fnm = "validation.csv"; readDataFromFile(fnm, rdata); refineDataForFirstPart(rdata, validation, medians, false); rdata.clear(); fnm = "test.csv"; readDataFromFile(fnm, rdata); refineDataForFirstPart(rdata, test, medians, false); size = train.size(); if(__MESSAGE__) cout << " Loading data complete ... \n" << endl; }
// //========================================================================= // // We read data using a thread, so the main thread only handles decoding // without caring about data acquisition // void *readerThreadEntryPoint(void *arg) { MODES_NOTUSED(arg); if (Modes.filename == NULL) { rtlsdr_read_async(Modes.dev, rtlsdrCallback, NULL, MODES_ASYNC_BUF_NUMBER, MODES_ASYNC_BUF_SIZE); } else { readDataFromFile(); } // Signal to the other thread that new data is ready - dummy really so threads don't mutually lock pthread_cond_signal(&Modes.data_cond); pthread_mutex_unlock(&Modes.data_mutex); #ifndef _WIN32 pthread_exit(NULL); #else return NULL; #endif }
void *readerThreadEntryPoint(void *arg) { MODES_NOTUSED(arg); start_cpu_timing(&reader_thread_start); // we accumulate in rtlsdrCallback() or readDataFromFile() if (Modes.filename == NULL) { while (!Modes.exit) { rtlsdr_read_async(Modes.dev, rtlsdrCallback, NULL, MODES_RTL_BUFFERS, MODES_RTL_BUF_SIZE); if (!Modes.exit) { log_with_timestamp("Warning: lost the connection to the RTLSDR device."); rtlsdr_close(Modes.dev); Modes.dev = NULL; do { sleep(5); log_with_timestamp("Trying to reconnect to the RTLSDR device.."); } while (!Modes.exit && modesInitRTLSDR() < 0); } } if (Modes.dev != NULL) { rtlsdr_close(Modes.dev); Modes.dev = NULL; } } else { readDataFromFile(); } // Wake the main thread (if it's still waiting) pthread_mutex_lock(&Modes.data_mutex); Modes.exit = 1; // just in case pthread_cond_signal(&Modes.data_cond); pthread_mutex_unlock(&Modes.data_mutex); #ifndef _WIN32 pthread_exit(NULL); #else return NULL; #endif }
bool Projectile::initModelWithType(ProjectileTypes type) { if (BaseGameEntity::initWithControllerType(kNoController)) { // default m_bIsActive = false; m_iProjectileID = -1; m_eProjectileType = type; // Read Data CCString *typeStr = CCString::createWithFormat("projectile_%d", (int)type); readDataFromFile("projectileInfo.lua", typeStr->getCString()); // Set entity type m_eEntityType = kProjectile; return true; } return false; }
/* * this is the main function. the program starts from here. * this method: * 1- read process data from 'input.txt' * 2- calls another method to start the cpu scheduler * 3- calls another method to calculates totals and averages */ int main(void){ ProcessList *processList = malloc(sizeof(ProcessList)); int isFileExist = readDataFromFile("input.txt", processList); if(isFileExist != 1){ return -1; } //printList(intList); printf("Here is list of processes and their information that have been loaded from 'input.txt':\n"); printProcessList(processList); printf("\nNow we start the CPU scheduler using Shortest Job First Schedulling algorithm: \n"); startCPUScheduler(processList); //printProcessList(processList); calculateTotals(processList); printf("Finished\n"); return EXIT_SUCCESS; }
int main(int argc, char **argv) { IoT_Error_t rc = FAILURE; parseInputArgsForConnectParams(argc, argv); if (!readDataFromFile()) { printf("Config file '%s' not found. Robot cannot work without configuration.\n", filename); return -1; } else { if (connectToThingAndSubscribeToTopic(argc, argv)) { publishMessage(getFieldAsString()); publishRobotState(); while (true) { //Max time the yield function will wait for read messages rc = aws_iot_mqtt_yield(&mqttClient, 1000); if (NETWORK_ATTEMPTING_RECONNECT == rc) { // || NETWORK_ATTEMPTING_RECONNECT == rc1) { // If the client is attempting to reconnect we will skip the rest of the loop. continue; } sleep(3); if (currentState == GO) { if (checkNextStep()) { currentState = GO; currentSensor = NONE; makeStep(); } } } } return 0; } }
TestExitStatus FStests::testReadFile() { const Common::String &path = ConfMan.get("path"); Common::FSDirectory gameRoot(path); int numFailed = 0; if (!gameRoot.getFSNode().exists() || !gameRoot.getFSNode().isDirectory()) { Testsuite::logDetailedPrintf("game Path should be an existing directory"); return kTestFailed; } const char *dirList[] = {"test1" ,"Test2", "TEST3" , "tEST4", "test5"}; const char *file[] = {"file.txt", "File.txt", "FILE.txt", "fILe.txt", "file"}; for (unsigned int i = 0; i < ARRAYSIZE(dirList); i++) { Common::String dirName = dirList[i]; Common::String fileName = file[i]; Common::FSDirectory *directory = gameRoot.getSubDirectory(dirName); if (!directory) { Testsuite::logDetailedPrintf("Failed to open directory %s during FS tests\n", dirName.c_str()); return kTestFailed; } if (!readDataFromFile(directory, fileName.c_str())) { Testsuite::logDetailedPrintf("Reading from %s/%s failed\n", dirName.c_str(), fileName.c_str()); numFailed++; } dirName.toLowercase(); fileName.toLowercase(); delete directory; directory = gameRoot.getSubDirectory(dirName); if (!directory) { Testsuite::logDetailedPrintf("Failed to open directory %s during FS tests\n", dirName.c_str()); return kTestFailed; } if (!readDataFromFile(directory, fileName.c_str())) { Testsuite::logDetailedPrintf("Reading from %s/%s failed\n", dirName.c_str(), fileName.c_str()); numFailed++; } dirName.toUppercase(); fileName.toUppercase(); delete directory; directory = gameRoot.getSubDirectory(dirName); if (!directory) { Testsuite::logDetailedPrintf("Failed to open directory %s during FS tests\n", dirName.c_str()); return kTestFailed; } if (!readDataFromFile(directory, fileName.c_str())) { Testsuite::logDetailedPrintf("Reading from %s/%s failed\n", dirName.c_str(), fileName.c_str()); numFailed++; } delete directory; } Testsuite::logDetailedPrintf("Failed %d out of 15\n", numFailed); if (numFailed) { return kTestFailed; } else { return kTestPassed; } }
bool MRISlices::RenderTextures() { double local_max; if (glTexImage3D == NULL) glTexImage3D = (PFNGLTEXIMAGE3DPROC)wglGetProcAddress("glTexImage3D"); if (glTexImage3D == NULL) return false; double scalex = 1, scaley = 1, scalez = 1; if (loaded_files == false) { //GetFiles(); readDataFromFile(scalex, scaley, scalez); loaded_files = true; max_value = maxDataValue; } for (int i = 0; i < 111; i++) { local_max = 0.0; if ((i != 0) && (i != 110)) for (int x = 0; x < 256; x++) { for (int y = 0; y < 256; y++) { if (arrayData3D[x][y][i] > local_max) local_max = arrayData3D[x][y][i-1]; } } else local_max = 1.0; for (int x = 0; x < 256; x++) { for (int y = 0; y < 256; y++) { double value; int t_offset = ((256 * 256 * 4 * i))+ ((256 * 4) * x) + (4 * y); if ((i != 0) && (i != 110)) value = arrayData3D[x][y][i-1]; else value = 0; //double value = (double)(x + y + i) / (255.0 + 255.0 + 18.0); triple rgb; if (use_local) rgb = slicegrad->ConvertToColor(value / local_max); else rgb = slicegrad->ConvertToColor(value / max_value); tex_array[t_offset] = (unsigned char)(rgb.x * 255.0); tex_array[t_offset+1] = (unsigned char)(rgb.y * 255.0); tex_array[t_offset+2] = (unsigned char)(rgb.z * 255.0); if (use_local_alpha) tex_array[t_offset+3] = (unsigned char)((value / local_max) * max_alpha); else tex_array[t_offset+3] = (unsigned char)((value / max_value) * max_alpha); // Make borders transparent. if (x == 0 || y == 0 || x == 255 || y == 255) tex_array[t_offset+3] = 0; } } } if (!rendered || tex3D <= 0) glGenTextures(1, &tex3D); glBindTexture(GL_TEXTURE_3D, tex3D); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP); glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA8, 256, 256, 111, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex_array); return true; }
int main( int argc, char* argv[]) { #ifdef _DEBUG argc = 3; argv[1] = "dls9_count_data_Eduard"; argv[2] = "dls9_count_data_Eduard"; #endif std::stringstream sstream1; sstream1 << "123 555"; std::string str1, str2, str3; double dval = -1; sstream1 >> str1 >> str2 >> dval; if (argc != 3) { std::cerr << "Usage : program file_data_eduard file_data_stepa"; return 1; } std::string file1_name = argv[1]; std::string file2_name = argv[2]; std::vector<wu> wu_vec_1 = readDataFromFile(file1_name); std::vector<wu> wu_vec_2 = readDataFromFile(file2_name); std::sort(wu_vec_1.begin(), wu_vec_1.end(), ds_compareByFirstCells); std::sort(wu_vec_2.begin(), wu_vec_2.end(), ds_compareByFirstCells); /*std::string str; std::ifstream ifile("Zerowu.txt"); std::vector<int> check_id_vec; unsigned val; while (getline(ifile, str)) { std::istringstream(str.c_str()) >> val; check_id_vec.push_back(val); } ifile.close(); unsigned match_count = 0, unmatch_count = 0; unsigned processed_wu_vec_2 = 0; std::vector<int>::iterator it; for ( auto &x : wu_vec_2 ) { if (x.processing_time < 0) continue; std::istringstream(x.first_cells_known_values) >> val; it = find(check_id_vec.begin(), check_id_vec.end(), val); if (it != check_id_vec.end()) { if (x.dls_number == 0) match_count++; else { unmatch_count++; std::cout << "unmatch wu_vec2 " << x.first_cells_known_values << std::endl; } } processed_wu_vec_2++; if (processed_wu_vec_2 % 1000 == 0) std::cout << "processed_wu_vec_2 " << processed_wu_vec_2 << std::endl; } std::cout << "match_count " << match_count << " from " << check_id_vec.size() << std::endl; std::cout << "unmatch_count " << unmatch_count << " from " << check_id_vec.size() << std::endl;*/ bool is_calculated_results_correct = true; unsigned calculated_results_both_files = 0; double comparison_koef_sum = 0; double cur_comparison_koef; unsigned diff_results_count = 0, diff_first_cells_count = 0; double calculated_sum1_time = 0, calculated_sum2_time = 0; unsigned long long total_dls_number_1 = 0, total_dls_number_2 = 0; for (unsigned i = 0; i < wu_vec_1.size(); i++) { if (wu_vec_1[i].first_cells_known_values != wu_vec_2[i].first_cells_known_values) { std::cout << "file1 : " << wu_vec_1[i].first_cells_known_values << " " << wu_vec_1[i].dls_number << " " << wu_vec_1[i].processing_time << std::endl; std::cout << "file2 : " << wu_vec_2[i].first_cells_known_values << " " << wu_vec_2[i].dls_number << " " << wu_vec_2[i].processing_time << std::endl; std::cout << "diff_first_cells_count " << ++diff_first_cells_count << std::endl; } if ( (wu_vec_1[i].dls_number >= 0) && (wu_vec_2[i].dls_number >= 0) ) { //&& //(wu_vec_1[i].processing_time > 0) && (wu_vec_2[i].processing_time > 0)) { total_dls_number_1 += wu_vec_1[i].dls_number; total_dls_number_2 += wu_vec_2[i].dls_number; calculated_sum1_time += wu_vec_1[i].processing_time; calculated_sum2_time += wu_vec_2[i].processing_time; calculated_results_both_files++; if ((wu_vec_1[i].dls_number > 0) && (wu_vec_2[i].dls_number > 0)) cur_comparison_koef = (double)wu_vec_1[i].dls_number / (double)wu_vec_2[i].dls_number; if ( (cur_comparison_koef != 1) || (wu_vec_1[i].first_cells_known_values != wu_vec_2[i].first_cells_known_values)) { //std::cout << "cur_comparison_koef < 1 " << cur_comparison_koef << std::endl; std::cout << "file1 : " << wu_vec_1[i].first_cells_known_values << " " << wu_vec_1[i].dls_number << " " << wu_vec_1[i].processing_time << std::endl; std::cout << "file2 : " << wu_vec_2[i].first_cells_known_values << " " << wu_vec_2[i].dls_number << " " << wu_vec_2[i].processing_time << std::endl; std::cout << "diff_results_count " << ++diff_results_count << std::endl; std::cout << std::endl; } if (wu_vec_1[i].dls_number != wu_vec_2[i].dls_number) is_calculated_results_correct = false; comparison_koef_sum += cur_comparison_koef; //std::cout << "cur_comparison_koef " << cur_comparison_koef << std::endl; } } double comparison_koef_average = comparison_koef_sum / calculated_results_both_files; std::cout.precision(10); std::cout << "calculated_results_both_files " << calculated_results_both_files << std::endl; std::cout << "is_calculated_results_correct " << is_calculated_results_correct << std::endl; std::cout << "comparison_koef_average " << comparison_koef_average << std::endl; std::cout << "calculated_sum1_time " << calculated_sum1_time << std::endl; std::cout << "calculated_sum2_time " << calculated_sum2_time << std::endl; std::cout << "sum_koef (calculated_sum1_time / calculated_sum2_time) " << calculated_sum1_time / calculated_sum2_time << std::endl; std::cout << "total_dls_number_1 " << total_dls_number_1 << std::endl; std::cout << "total_dls_number_2 " << total_dls_number_2 << std::endl; return 0; }
int main(int argc, char *argv[]) { int opt; char* appName = NULL; char* resourceID = NULL; char* payloadBuffer = NULL; char* fileName = NULL; unsigned char* writeBuffer = NULL; eOperationMode opMode = modeInvalid; unsigned int user_no = 0, seat_no = 0; unsigned int ldbid = 0xFF; // default value unsigned int doHexdump = 0; printf("\n"); /// debug log and trace (DLT) setup DLT_REGISTER_APP("Ptool","persistence client library tools"); while ((opt = getopt(argc, argv, "hVo:a:u:s:r:-l:p:f:H")) != -1) { switch (opt) { case 'o': // option if(strcmp(optarg, "readkey") == 0) { opMode = modeReadKey; } else if(strcmp(optarg, "writekey") == 0) { opMode = modeWriteKey; } else if(strcmp(optarg, "deletekey") == 0) { opMode = modeDeleteKey; } else if(strcmp(optarg, "getkeysize") == 0) { opMode = modeGetKeySize; } else { printf("Unsupported Unsupported mode: %s\"\n\"", optarg); printSynopsis(); exit(EXIT_FAILURE); } break; case 'a': // application name { size_t len = strlen(optarg); appName = malloc(len + 1); if(appName != NULL) { memset(appName, 0, len + 1); strncpy(appName, optarg, len); } } break; case 'r': // resource ID { size_t len = strlen(optarg); resourceID = malloc(len + 1); if(resourceID != NULL) { memset(resourceID, 0, len + 1); strncpy(resourceID, optarg, len); } } break; case 'p': // payload to write { size_t len = strlen(optarg); payloadBuffer = malloc(len + 1); if(payloadBuffer != NULL) { memset(payloadBuffer, 0, len + 1); strncpy(payloadBuffer, optarg, len); } } break; case 'f': // filename to read data from, write data to { size_t len = strlen(optarg); fileName = malloc(len + 1); if(fileName != NULL) { memset(fileName, 0, len + 1); strncpy(fileName, optarg, len); } } break; case 'u': // user number user_no = (unsigned int)atoi(optarg); break; case 's': // seat number seat_no = (unsigned int)atoi(optarg); break; case 'l': ldbid = (unsigned int)strtol(optarg, NULL, 16); break; case 'H': // hexdump of data doHexdump = 1; break; case 'h': // help printSynopsis(); break; case 'v': // version printf("Version: %s\n", PCLT_VERSION); break; default: /* '?' */ printSynopsis(); exit(EXIT_FAILURE); break; } } if(appName != NULL && resourceID != NULL) { printf("Application name: %s\n", appName); int shutdownReg = PCL_SHUTDOWN_TYPE_NONE; (void)pclInitLibrary(appName, shutdownReg); switch(opMode) { case modeReadKey: { unsigned char* buffer = NULL; int keysize = pclKeyGetSize(ldbid, resourceID, user_no, seat_no); if(keysize > 0) { buffer = malloc((size_t)keysize + 1); if(buffer != NULL) { memset(buffer, 0, (size_t)(keysize + 1)); readKey(resourceID, user_no, seat_no, ldbid, doHexdump, buffer, keysize); if(fileName != NULL) (void)writeDataToFile(fileName, buffer, keysize); free(buffer); } } else { printf("readkey: key is empty: %d\n", keysize); } break; } case modeWriteKey: if(fileName != NULL) // if filename is available, read data from file { writeBuffer = readDataFromFile(fileName); } else { writeBuffer = (unsigned char*)payloadBuffer; // use data from payload parameter } if(writeBuffer != NULL) { writeKey(resourceID, user_no, seat_no, ldbid, writeBuffer, doHexdump); } else { printf("No Data to write to key\n"); } break; case modeDeleteKey: deletekey(resourceID, user_no, seat_no, ldbid); break; case modeGetKeySize: getkeysize(resourceID, user_no, seat_no, ldbid); break; default: printSynopsis(); break; } if(appName != NULL) free(appName); if(resourceID != NULL) free(resourceID); if(writeBuffer != NULL) free(writeBuffer); if(fileName != NULL) free(fileName); pclLifecycleSet(PCL_SHUTDOWN); pclDeinitLibrary(); } else { printf("Invalid application name or resourceID\n"); exit(EXIT_FAILURE); } // unregister debug log and trace DLT_UNREGISTER_APP(); dlt_free(); printf("\n"); return 0; }
int main( int argc, char *argv[]) { char req[204800], res[204800]; int a, code; int iActProc[MAXPROCS], ProcStatus, iLoop, i; int iProcNum, iTxNum; char aczTransFile[ 10+1 ], CommMode; int iRet; int iSucNum, icFailNum, iApErrNum; int iSumSucNum , iSumCFailNum , iSumApErrNum; double lBegTime, lEndTime, lLastTime, lMaxTime, lMinTime, lTotalTime ; double lAllMaxTime, lAllMinTime, iSumTotalTime; int iCliSerial; FILE * fp; char FileName[ 20 ] ; char aczCmd[ 30 ] , aczLineBuf[256] ; if( argc != 8) { printf( "Usage : %s <call name> <ip> <port> <data file> 并发进程数 单进程交易数 交易机构号 \n", argv[0] ); return 0; } if (apr_initialize() != APR_SUCCESS) { fprintf(stderr, "Something went wrong\n"); exit(-1); } atexit(apr_terminate); AdpClient client( argv[2], atoi(argv[3]) ); client.init( "aaa" ); UDO_Init( req, sizeof(req) ); UDO_Init( res, sizeof(res) ); readDataFromFile( req, argv[4] ); UDO_Print( req ); iProcNum = atoi (argv[5]); iTxNum = atoi (argv[6]) ; lBegTime = GetCurrentMillTime(); iCliSerial = 1;/*发送的交易流水*/ for ( iLoop = 0 ; iLoop < iProcNum ; iLoop ++ ) { /*iProcNum并发进程数*/ if ( ( iActProc[ iLoop ] = fork( ) ) == 0 ) { lMaxTime = 0; lMinTime = 100000; iSucNum = 0 ; icFailNum = 0 ; iApErrNum = 0 ; lTotalTime = 0; /*iTxNum每个子进程发送交易数*/ for ( i = 0 ; i < iTxNum ; i ++ ) { lBegTime = GetCurrentMillTime(); printf("------Do Trans------\n\n"); iRet = client.call( argv[1],argv[1],req, res, 100 ); lEndTime = GetCurrentMillTime(); if (iRet == 0) { if ( lLastTime > lMaxTime ) lMaxTime = lLastTime ; if ( lLastTime < lMinTime ) lMinTime = lLastTime ; /*该子进程下完全成功交易时间*/ lTotalTime += lLastTime ; } if ( iRet == 0 ) iSucNum ++ ; if ( iRet == -1 ) icFailNum ++ ; if ( iRet == -2 ) iApErrNum ++ ; iCliSerial = iCliSerial + 1; /*lTotalTime += lLastTime ;*/ } memset( FileName , 0 ,sizeof ( FileName ) ); sprintf( FileName , "%s/cli/log/%d" ,getenv("HOME") , getpid( ) ); /* 记录运行结果 此处统计的是每个子进程的运行结果*/ if( ( fp = fopen ( FileName , "w+" ) ) == NULL ) { perror( "open file for write : " ) ; printf("-----------lp-----------\n\n"); fprintf ( stderr , "filename [%s] \n" , FileName ); exit( -1 ) ; } fprintf ( fp , "%d %d %d %.0lf %.0lf %.0lf \n", iSucNum , icFailNum , iApErrNum , lMaxTime , lMinTime , lTotalTime ) ; /*成功交易数 通讯失败笔数 调用成功但交易失败*/ /*成功交易最大时间 最小时间 成功交易总时间*/ fflush( fp ) ; fclose( fp ) ; exit ( 0 ) ; } if ( iActProc[ iLoop ] < 0 ) perror( " Fork Error : " ) ; iCliSerial = iCliSerial + iTxNum ;/*每个子进程的流水区间为iTxNum*/ } /* 等待子进程结束 */ for ( iLoop = 0 ; iLoop < iProcNum ; iLoop ++ ) { if ( ( ProcStatus = waitpid ( iActProc[ iLoop ] , NULL , 0 ) ) != iActProc[ iLoop ] ) { fprintf ( stderr , " child process error ! \n " ); perror ( " waiting child end error : " ) ; } } lEndTime = GetCurrentMillTime(); lLastTime = lEndTime - lBegTime ; printf("\n b[%016.0lf] e[%016.0lf]\n",lEndTime,lBegTime); /* 统计运行结果 */ iSumSucNum = 0 ; iSumCFailNum = 0 ; iSumApErrNum = 0 ; iSumTotalTime = 0 ; lAllMaxTime = 0 ; lAllMinTime = 1000000 ; for ( iLoop = 0 ; iLoop < iProcNum ; iLoop ++ ) { memset( FileName , 0 ,sizeof ( FileName ) ); sprintf( FileName , "%s/cli/log/%d" ,getenv("HOME") , iActProc[iLoop ] ); /* 记录运行结果 */ if( ( fp = fopen ( FileName , "r+" ) ) == NULL ) { perror( "open file : " ) ; printf("-------------lp2-------------\n\n"); fprintf ( stderr , "filename [%s] \n", FileName ) ; continue ; } fgets ( aczLineBuf , sizeof( aczLineBuf ) , fp ) ; sscanf ( aczLineBuf , "%d %d %d %lf %lf %lf", &iSucNum , &icFailNum , &iApErrNum , &lMaxTime , &lMinTime ,&lTotalTime ) ; iSumSucNum += iSucNum ; iSumCFailNum += icFailNum ; iSumApErrNum += iApErrNum ; iSumTotalTime += lTotalTime ; /***printf("\n\n pre iSumTotalTime[%.0lf]\n\n", iSumTotalTime); printf("\n\naczLineBuf[%s]\n\n", aczLineBuf); printf("\n\niSucNum[%d]", iSucNum); printf("\n\nicFailNum[%d]", icFailNum); printf("\n\niApErrNum[%d]", iApErrNum); printf("\n\nlMaxTime[%.0lf]", lMaxTime); printf("\n\nlMinTime[%.0lf]", lMinTime); printf("\n\nlTotalTime[%.0lf]", lTotalTime); printf("\n\niSumTotalTime[%.0lf]", iSumTotalTime);***/ if ( lAllMaxTime < lMaxTime ) lAllMaxTime = lMaxTime ; if ( lAllMinTime > lMinTime ) lAllMinTime = lMinTime ; fclose( fp ) ; } fprintf ( stderr , " ================汇总统计=======================\n" ); fprintf ( stderr , " 交易总笔数 [ %d ]\n" , iProcNum * iTxNum ); fprintf ( stderr , " 完全成功交易总笔数 [ %d ]\n" , iSumSucNum ); fprintf ( stderr , " 交易调用成功总笔数[ %d ]\n" , iSumSucNum+iSumApErrNum ); fprintf ( stderr , " 交易通讯失败总笔数[ %d ]\n" , iSumCFailNum ); fprintf ( stderr , " 交易总时间 [ %.3lf ]\n" , lLastTime * 1.0 / 1000 ); fprintf ( stderr , " 交易处理吞吐量 [ %.3lf ]\n" , 1/(lLastTime * 1.0 / 1000 / (iProcNum * iTxNum)) ); if ( iSumSucNum != 0 ) { fprintf ( stderr , " 完全成功交易平均时间 [ %.3lf ]\n" , iSumTotalTime * 1.0 / 1000 / iSumSucNum ); fprintf ( stderr , " 完全成功交易最大时间 [ %.3lf ]\n" , lAllMaxTime * 1.0 / 1000 ); fprintf ( stderr , " 完全成功交易最小时间 [ %.3lf ]\n" , lAllMinTime * 1.0 / 1000 ); } else fprintf (stderr , " ################无成功的交易 ############ \n"); exit(0); #if 0 a = client.call( argv[1],argv[1],req, res, 100 ); printf( "======================================\n" ); printf( "call return %d", a ); if( a != 0 ) { code = client.getError(); if( code == 9 ) { printf( " and server coredump" ); } else if( code == 10 ) { printf( " and server no such function" ); } else if( code == 6 || code == 2 ) { printf( " and server not started" ); } else { printf( " error code is %d", code ); } printf( " or %s\n", strerror(errno) ); return 2; } printf( " success\n" ); printf( "======================================\n" ); UDO_Print( res ); #endif return -1; }