Пример #1
0
void CTestSetBatchView::Test20M()
{

	CAdcTestPlatDoc* pDoc = (CAdcTestPlatDoc*)GetDocument();
	if ( pDoc != NULL )
	{				

		DWORD dwCmd = (CMD_RESET << 16); 
		pDoc->SendCommand( dwCmd ); 
		
		dwCmd = (CMD_MODE << 16) 
				+ (0 << 8) //m_nStart
				+ (0 << 6) //m_nM0
				+ (1 << 5) //m_nChanConfigCtrl  
				+ (0 << 4) //m_nDataOutModelSel  lvds
				+ (1 << 3) //m_nParaSerSel
				+ (1 << 1) //m_nLvdsAck
				+ 0; //m_nTest
		pDoc->SendCommand( dwCmd ); 
		// 自动载入配置文件param_20m.dat, ?????
		LoadParamFile( m_str20MFileName );
		dwCmd = (CMD_MODE << 16) 
				+ (1 << 8) //m_nStart
				+ (1 << 6) //m_nM0
				+ (1 << 5) //m_nChanConfigCtrl  
				+ (0 << 4) //m_nDataOutModelSel  lvds
				+ (1 << 3) //m_nParaSerSel
				+ (1 << 1) //m_nLvdsAck
				+ 0; //m_nTest
		pDoc->SendCommand( dwCmd ); 

		// r值的作用80/20/2
		SetR( 2 );

		// 设置alg显示
		CMainFrame* pFrame = (CMainFrame*)GetParentFrame();
		if ( pFrame != NULL )
		{
			pFrame->m_bTestADCBatch = TRUE;
			pFrame->m_bTestADC = FALSE;
			pFrame->m_bTestAlg = TRUE;
		}

		// 选择alg模式
		pDoc->m_nTestModeSel = 6;
		// 上次的采集完成后,可以建立新线程,采集和计算
		if ( pDoc->m_bTestComp )
		{			
			// 第二个参数不能像doc里面直接使用this, 切记
			AfxBeginThread( pDoc->TestAndCalc, pDoc );
		}
		// 打开定时器1, 每隔2s采集一次
		SetTimer( 1, 2000, NULL );
	}
}
InstallLogger::InstallLogger(int argc,char* const argv[]) :
  ule(ule_default_init), init_done(0) {
  ClearUniLoggerSpaceStruct(0);
  if (argc==1) {
    usage();
    return;
  }

  Encoding encoding_output = DEFAULT_ENCODING_OUTPUT;
  int bom_output = DEFAULT_BOM_OUTPUT;
  int mask_encoding_compatibility_input = DEFAULT_MASK_ENCODING_COMPATIBILITY_INPUT;
  int val,index=-1;
  bool only_verify_arguments = false;
  UnitexGetOpt options;
  while (EOF!=(val=options.parse_long(argc,argv,optstring_CreateLog,lopts_CreateLog,&index))) {
     switch(val) {
       case 'V': only_verify_arguments = true;
                 break;
       case 'h': usage();
                 return;
       case 'n': ule.store_file_in_content = 0;
                 break;
       case 'i': ule.store_file_in_content = 1;
                 break;
       case 'o': ule.store_file_out_content = 1;
                 break;
       case 'u': ule.store_file_out_content = 0;
                 break;
       case 's': ule.store_list_file_in_content = 1;
                 break;
       case 't': ule.store_list_file_in_content = 0;
                 break;
       case 'r': ule.store_list_file_out_content = 1;
                 break;
       case 'f': ule.store_list_file_out_content = 0;
                 break;
       case ':': index==-1 ? error("Missing argument for option -%c\n",options.vars()->optopt) :
                             error("Missing argument for option --%s\n",lopts_CreateLog[index].name);
                 return;            
       case 'k': if (options.vars()->optarg[0]=='\0') {
                    error("Empty input_encoding argument\n");
                    return;
                 }
                 decode_reading_encoding_parameter(&mask_encoding_compatibility_input,options.vars()->optarg);
                 break;
       case 'q': if (options.vars()->optarg[0]=='\0') {
                    error("Empty output_encoding argument\n");
                    return;
                 }
                 decode_writing_encoding_parameter(&encoding_output,&bom_output,options.vars()->optarg);
                 break;
       case 'g': ClearUniLoggerSpaceStruct(1);
                 return;
       case 'p': if (options.vars()->optarg[0]=='\0') {
                    error("You must specify a non empty param file\n");
                    return;
                 }
                 ClearUniLoggerSpaceStruct(1);
                 LoadParamFile(options.vars()->optarg);
                 return;
       case 'l': if (options.vars()->optarg[0]=='\0') {
                    error("You must specify a non empty log filename\n");
                    return;
                 }
                 if (ule.szNameLog != NULL) {
                     free((void*)ule.szNameLog);
                 }
                 ule.szNameLog = strdup(options.vars()->optarg);
                 break;
     
       case 'd': if (options.vars()->optarg[0]=='\0') {
                    error("You must specify a non empty directory\n");
                    return;
                 }
                 if (ule.szPathLog != NULL) {
                     free((void*)ule.szPathLog);
                 }    
                 ule.szPathLog = strdup(options.vars()->optarg);
                 break;

       case '?': index==-1 ? error("Invalid option -%c\n",options.vars()->optopt) :
                             error("Invalid option --%s\n",options.vars()->optarg);
                 return;
     }
     index=-1;
  }

  if (options.vars()->optind!=argc-1) {
  }

  if (only_verify_arguments) {
    // freeing all allocated memory
    return;
  }

  if (AddActivityLogger(&ule) != 0) {
    init_done = 1;
  } else {
    ClearUniLoggerSpaceStruct(1);
  }
}
InstallLogger::InstallLogger(const char* parameter_filename) :
    ule(ule_default_init),init_done(0) {
    LoadParamFile(parameter_filename);
}