当前位置: 首页>>代码示例>>C++>>正文


C++ CTime类代码示例

本文整理汇总了C++中CTime的典型用法代码示例。如果您正苦于以下问题:C++ CTime类的具体用法?C++ CTime怎么用?C++ CTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SG_DEBUG

SGVector<float64_t> CConjugateGradientSolver::solve(
	CLinearOperator<float64_t>* A, SGVector<float64_t> b)
{
	SG_DEBUG("CConjugateGradientSolve::solve(): Entering..\n");

	// sanity check
	REQUIRE(A, "Operator is NULL!\n");
	REQUIRE(A->get_dimension()==b.vlen, "Dimension mismatch!\n");

	// the final solution vector, initial guess is 0
	SGVector<float64_t> result(b.vlen);
	result.set_const(0.0);

	// the rest of the part hinges on eigen3 for computing norms
	Map<VectorXd> x(result.vector, result.vlen);
	Map<VectorXd> b_map(b.vector, b.vlen);

	// direction vector
	SGVector<float64_t> p_(result.vlen);
	Map<VectorXd> p(p_.vector, p_.vlen);

	// residual r_i=b-Ax_i, here x_0=[0], so r_0=b
	VectorXd r=b_map;

	// initial direction is same as residual
	p=r;

	// the iterator for this iterative solver
	IterativeSolverIterator<float64_t> it(b_map, m_max_iteration_limit,
		m_relative_tolerence, m_absolute_tolerence);

	// CG iteration begins
	float64_t r_norm2=r.dot(r);

	// start the timer
	CTime time;
	time.start();

	// set the residuals to zero
	if (m_store_residuals)
		m_residuals.set_const(0.0);

	for (it.begin(r); !it.end(r); ++it)
	{
		SG_DEBUG("CG iteration %d, residual norm %f\n",
			it.get_iter_info().iteration_count,
			it.get_iter_info().residual_norm);

		if (m_store_residuals)
		{
			m_residuals[it.get_iter_info().iteration_count]
				=it.get_iter_info().residual_norm;
		}

		// apply linear operator to the direction vector
		SGVector<float64_t> Ap_=A->apply(p_);
		Map<VectorXd> Ap(Ap_.vector, Ap_.vlen);

		// compute p^{T}Ap, if zero, failure
		float64_t p_dot_Ap=p.dot(Ap);
		if (p_dot_Ap==0.0)
			break;

		// compute the alpha parameter of CG
		float64_t alpha=r_norm2/p_dot_Ap;

		// update the solution vector and residual
		// x_{i}=x_{i-1}+\alpha_{i}p
		x+=alpha*p;

		// r_{i}=r_{i-1}-\alpha_{i}p
		r-=alpha*Ap;

		// compute new ||r||_{2}, if zero, converged
		float64_t r_norm2_i=r.dot(r);
		if (r_norm2_i==0.0)
			break;

		// compute the beta parameter of CG
		float64_t beta=r_norm2_i/r_norm2;

		// update direction, and ||r||_{2}
		r_norm2=r_norm2_i;
		p=r+beta*p;
	}

	float64_t elapsed=time.cur_time_diff();

	if (!it.succeeded(r))
		SG_WARNING("Did not converge!\n");

	SG_INFO("Iteration took %ld times, residual norm=%.20lf, time elapsed=%lf\n",
		it.get_iter_info().iteration_count, it.get_iter_info().residual_norm, elapsed);

	SG_DEBUG("CConjugateGradientSolve::solve(): Leaving..\n");
	return result;
}
开发者ID:42MachineLearning,项目名称:shogun,代码行数:97,代码来源:ConjugateGradientSolver.cpp

示例2: res

EIB_STD_EXPORT CTime operator+(const CTime& t1, const int t2)
{

	CTime res(t1.GetTime() + t2);
	return res;
}
开发者ID:Paolo-Maffei,项目名称:eibsuite,代码行数:6,代码来源:CTime.cpp

示例3: DefaultInit

BOOL CServerDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    g_pMain = this;

    // Default Init ...
    DefaultInit();

    //----------------------------------------------------------------------
    //	Sets a random number starting point.
    //----------------------------------------------------------------------
    SetTimer( CHECK_ALIVE, 10000, NULL );
    srand( (unsigned)time(NULL) );

    InitializeCriticalSection( &g_region_critical );
    InitializeCriticalSection( &g_User_critical );
    m_sMapEventNpc = 0;
    m_bFirstServerFlag = FALSE;

    // User Point Init
    for(int i=0; i<MAX_USER; i++)
        m_pUser[i] = NULL;

    // Server Start
    CTime time = CTime::GetCurrentTime();
    AddToList("[AI ServerStart - %d-%d-%d, %02d:%02d]", time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute() );

    //----------------------------------------------------------------------
    //	DB part initialize
    //----------------------------------------------------------------------
    GetServerInfoIni();

    if(m_byZone == UNIFY_ZONE)	m_strStatus.Format("Server zone: ALL");
    else if(m_byZone == KARUS_ZONE)	m_strStatus.Format("Server zone: KARUS");
    else if(m_byZone == ELMORAD_ZONE) m_strStatus.Format("Server zone: EL MORAD");
    else if(m_byZone == BATTLE_ZONE) m_strStatus.Format("Server zone: BATTLE");

    //----------------------------------------------------------------------
    //	DB part initialize
    //----------------------------------------------------------------------


    //----------------------------------------------------------------------
    //	Communication Part Initialize ...
    //----------------------------------------------------------------------

    uint16 sPort = BATTLE_ZONE;
    if (m_byZone == KARUS_ZONE || m_byZone == UNIFY_ZONE)
        sPort = AI_KARUS_SOCKET_PORT;
    else if (m_byZone == ELMORAD_ZONE)
        sPort = AI_ELMO_SOCKET_PORT;

    if (!s_socketMgr.Listen(sPort, MAX_SOCKET))
    {
        EndDialog(IDCANCEL);
        return FALSE;
    }

    //----------------------------------------------------------------------
    //	Load tables
    //----------------------------------------------------------------------
    if (!GetMagicTableData()
            || !GetMagicType1Data()
            || !GetMagicType2Data()
            || !GetMagicType3Data()
            || !GetMagicType4Data()
            || !GetNpcItemTable()
            || !GetMakeWeaponItemTableData()
            || !GetMakeDefensiveItemTableData()
            || !GetMakeGradeItemTableData()
            || !GetMakeLareItemTableData()
            || !GetNpcTableData(false)
            || !GetNpcTableData(true)
            // Load maps
            || !MapFileLoad()
            // Spawn NPC threads
            || !CreateNpcThread())
    {
        EndDialog(IDCANCEL);
        return FALSE;
    }

    //----------------------------------------------------------------------
    //	Start NPC THREAD
    //----------------------------------------------------------------------
    ResumeAI();

    UpdateData(FALSE);
    return TRUE;  // return TRUE  unless you set the focus to a control
}
开发者ID:jakenewby,项目名称:snoxd-koserver-1,代码行数:91,代码来源:ServerDlg.cpp

示例4:

CTime::CTime(const CTime& time)
{
	_time_val = time.GetTime();
}
开发者ID:Paolo-Maffei,项目名称:eibsuite,代码行数:4,代码来源:CTime.cpp

示例5: SG_DEBUG

SGVector<complex128_t> CCGMShiftedFamilySolver::solve_shifted_weighted(
	CLinearOperator<SGVector<float64_t>, SGVector<float64_t> >* A, SGVector<float64_t> b,
	SGVector<complex128_t> shifts, SGVector<complex128_t> weights)
{
	SG_DEBUG("Entering\n");

	// sanity check
	REQUIRE(A, "Operator is NULL!\n");
	REQUIRE(A->get_dimension()==b.vlen, "Dimension mismatch! [%d vs %d]\n",
		A->get_dimension(), b.vlen);
	REQUIRE(shifts.vector,"Shifts are not initialized!\n");
	REQUIRE(weights.vector,"Weights are not initialized!\n");
	REQUIRE(shifts.vlen==weights.vlen, "Number of shifts and number of "
		"weights are not equal! [%d vs %d]\n", shifts.vlen, weights.vlen);

	// the solution matrix, one column per shift, initial guess 0 for all
	MatrixXcd x_sh=MatrixXcd::Zero(b.vlen, shifts.vlen);
	MatrixXcd p_sh=MatrixXcd::Zero(b.vlen, shifts.vlen);

	// non-shifted direction
	SGVector<float64_t> p_(b.vlen);

	// the rest of the part hinges on eigen3 for computing norms
	Map<VectorXd> b_map(b.vector, b.vlen);
	Map<VectorXd> p(p_.vector, p_.vlen);

	// residual r_i=b-Ax_i, here x_0=[0], so r_0=b
	VectorXd r=b_map;

	// initial direction is same as residual
	p=r;
	p_sh=r.replicate(1, shifts.vlen).cast<complex128_t>();

	// non shifted initializers
	float64_t r_norm2=r.dot(r);
	float64_t beta_old=1.0;
	float64_t alpha=1.0;

	// shifted quantities
	SGVector<complex128_t> alpha_sh(shifts.vlen);
	SGVector<complex128_t> beta_sh(shifts.vlen);
	SGVector<complex128_t> zeta_sh_old(shifts.vlen);
	SGVector<complex128_t> zeta_sh_cur(shifts.vlen);
	SGVector<complex128_t> zeta_sh_new(shifts.vlen);

	// shifted initializers
	zeta_sh_old.set_const(1.0);
	zeta_sh_cur.set_const(1.0);

	// the iterator for this iterative solver
	IterativeSolverIterator<float64_t> it(r, m_max_iteration_limit,
		m_relative_tolerence, m_absolute_tolerence);

	// start the timer
	CTime time;
	time.start();

	// set the residuals to zero
	if (m_store_residuals)
		m_residuals.set_const(0.0);

	// CG iteration begins
	for (it.begin(r); !it.end(r); ++it)
	{

		SG_DEBUG("CG iteration %d, residual norm %f\n",
				it.get_iter_info().iteration_count,
				it.get_iter_info().residual_norm);

		if (m_store_residuals)
		{
			m_residuals[it.get_iter_info().iteration_count]
				=it.get_iter_info().residual_norm;
		}

		// apply linear operator to the direction vector
		SGVector<float64_t> Ap_=A->apply(p_);
		Map<VectorXd> Ap(Ap_.vector, Ap_.vlen);

		// compute p^{T}Ap, if zero, failure
		float64_t p_dot_Ap=p.dot(Ap);
		if (p_dot_Ap==0.0)
			break;

		// compute the beta parameter of CG_M
		float64_t beta=-r_norm2/p_dot_Ap;

		// compute the zeta-shifted parameter of CG_M
		compute_zeta_sh_new(zeta_sh_old, zeta_sh_cur, shifts, beta_old, beta,
			alpha, zeta_sh_new);

		// compute beta-shifted parameter of CG_M
		compute_beta_sh(zeta_sh_new, zeta_sh_cur, beta, beta_sh);

		// update the solution vector and residual
		for (index_t i=0; i<shifts.vlen; ++i)
			x_sh.col(i)-=beta_sh[i]*p_sh.col(i);

		// r_{i}=r_{i-1}+\beta_{i}Ap
		r+=beta*Ap;
//.........这里部分代码省略.........
开发者ID:DrahmA,项目名称:shogun,代码行数:101,代码来源:CGMShiftedFamilySolver.cpp

示例6: tPeriod

void CVersionChecker::SetNextCheck(int nDays)
{
	CTimeSpan tPeriod( nDays, 0, 0, 0 );
	CTime tNextCheck = CTime::GetCurrentTime() + tPeriod;
	theApp.WriteProfileInt( _T("VersionCheck"), _T("NextCheck"), (DWORD)tNextCheck.GetTime() );
}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:6,代码来源:VersionChecker.cpp

示例7: GetFormatedTime

CString MyTools::GetFormatedTime(CTime time){
	CString str = time.Format("%X");
	return str;
}
开发者ID:fdiskcn,项目名称:DASSimulationProj,代码行数:4,代码来源:MyTools.cpp

示例8: m

void SVDLinearSolver<TMatrix,TVector>::solve(Matrix& M, Vector& x, Vector& b)
{
#ifdef SOFA_DUMP_VISITOR_INFO
    simulation::Visitor::printComment("SVD");
#endif
#ifdef DISPLAY_TIME
    CTime timer;
    double time1 = (double) timer.getTime();
#endif
    const bool verbose  = f_verbose.getValue();

    /// Convert the matrix and the right-hand vector to Eigen objects
    Eigen::MatrixXd m(M.rowSize(),M.colSize());
    Eigen::VectorXd rhs(M.rowSize());
    for(unsigned i=0; i<(unsigned)M.rowSize(); i++ )
    {
        for( unsigned j=0; j<(unsigned)M.colSize(); j++ )
            m(i,j) = M[i][j];
        rhs(i) = b[i];
    }

    msg_info_when(verbose) << "solve, Here is the matrix m:  "
                           << m ;

    /// Compute the SVD decomposition and the condition number
    Eigen::JacobiSVD<Eigen::MatrixXd> svd(m, Eigen::ComputeThinU | Eigen::ComputeThinV);
    f_conditionNumber.setValue( (Real)(svd.singularValues()(0) / svd.singularValues()(M.rowSize()-1)) );



    if(verbose)
    {
        msg_info() << "solve, the singular values are:" << sendl << svd.singularValues()  << msgendl
                   << "Its left singular vectors are the columns of the thin U matrix: " << msgendl
                   << svd.matrixU() << msgendl
                   << "Its right singular vectors are the columns of the thin V matrix:" msgendl
                   << svd.matrixV() ;
    }else{
        msg_info() << "solve, the singular values are:" << sendl << svd.singularValues()  << msgendl;
    }

    /// Solve the equation system and copy the solution to the SOFA vector
//    Eigen::VectorXd solution = svd.solve(rhs);
//    for(unsigned i=0; i<M.rowSize(); i++ ){
//        x[i] = solution(i);
//    }
    Eigen::VectorXd Ut_b = svd.matrixU().transpose() *  rhs;
    Eigen::VectorXd S_Ut_b(M.colSize());
    for( unsigned i=0; i<(unsigned)M.colSize(); i++ )   /// product with the diagonal matrix, using the threshold for near-null values
    {
        if( svd.singularValues()[i] > f_minSingularValue.getValue() )
            S_Ut_b[i] = Ut_b[i]/svd.singularValues()[i];
        else
            S_Ut_b[i] = (Real)0.0 ;
    }
    Eigen::VectorXd solution = svd.matrixV() * S_Ut_b;
    for(unsigned i=0; i<(unsigned)M.rowSize(); i++ )
    {
        x[i] = (Real) solution(i);
    }

#ifdef DISPLAY_TIME
        time1 = (double)(((double) timer.getTime() - time1) * timeStamp / (nb_iter-1));
        dmsg_info() << " solve, SVD = "<<time1;
#endif
        dmsg_info() << "solve, rhs vector = " << msgendl << rhs.transpose() << msgendl
                    << " solution =   \n" << msgendl << x << msgendl
                    << " verification, mx - b = " << msgendl << (m * solution - rhs ).transpose() << msgendl;
}
开发者ID:fredroy,项目名称:sofa,代码行数:69,代码来源:SVDLinearSolver.cpp

示例9: GetFormatedDate

CString MyTools::GetFormatedDate(CTime time){
	CString str = time.Format("%Y-%m-%d");
	return str;
}
开发者ID:fdiskcn,项目名称:DASSimulationProj,代码行数:4,代码来源:MyTools.cpp

示例10: HashThreadFunc


//.........这里部分代码省略.........

		int position = 0; // 进度条位置

        result.enumState = RESULT_PATH;
        
		uiBridge->showFileName(result);

		//Calculating begins
#if defined (WIN32)
		CFileException fExc;
#else
		char fExc[1024] = {0};
#endif
		OsFile osFile(path);
		if(osFile.openRead((void *)&fExc)) 
		{
			MD5Init(&mdContext, 0); // MD5开始
			sha1.Reset(); // SHA1开始
			sha256_init(&sha256Ctx); // SHA256开始
			crc32Init(&ulCRC32); // CRC32开始

			uiBridge->updateProg(0);

			/*
			// get file size - start //
			fsize=thrdData->File.GetLength();
			tsize+=fsize;
			// get file size - end //
			*/

			// get file status //
			tstring tstrLastModifiedTime;
#if defined (WIN32)
			CTime ctModifedTime;
#else
			struct timespec ctModifedTime;
#endif
			if(osFile.getModifiedTime((void *)&ctModifedTime))
			{
#if defined (WIN32)
				tstrLastModifiedTime = ctModifedTime.Format("%Y-%m-%d %H:%M").GetString();
#else
				time_t ttModifiedTime;
				struct tm *tmModifiedTime;
				
				ttModifiedTime = ctModifedTime.tv_sec;
				tmModifiedTime = localtime(&ttModifiedTime);
				
				char szTmBuf[1024] = {0};
				strftime(szTmBuf, 1024, "%Y-%m-%d %H:%M", tmModifiedTime);
				
				tstrLastModifiedTime = strtotstr(string(szTmBuf));
#endif
				result.tstrMDate = tstrLastModifiedTime;
			}
			
			fsize = osFile.getLength(); // Fix 4GB file
			result.ulSize = fsize;
			
			if(!isSizeCaled) // 如果没有计算过大小
			{
				thrdData->totalSize += fsize;
			}
			else
			{
				thrdData->totalSize = thrdData->totalSize + fsize - fSizes[i]; // 修正总大小
开发者ID:touchao123,项目名称:fhash,代码行数:67,代码来源:HashEngine.cpp

示例11: s_TestMisc

static void s_TestMisc(int idx)
{
    // AsString()
    {{
        CTime t1;
        assert(t1.AsString() == "");

        CTime t2(2000, 365 / 2);
        t2.SetFormat("M/D/Y h:m:s");
        assert(t2.AsString() == "06/30/2000 00:00:00");
    }}
    
    // Year 2000 problem
    {{
        CTime t(1999, 12, 30); 
        t.SetFormat("M/D/Y");
        t.AddDay();
        assert(t.AsString() == "12/31/1999");
        t.AddDay();
        assert(t.AsString() == "01/01/2000");
        t.AddDay();
        assert(t.AsString() == "01/02/2000");
        t="02/27/2000";
        t.AddDay();
        assert(t.AsString() == "02/28/2000");
        t.AddDay();
        assert(t.AsString() == "02/29/2000");
        t.AddDay();
        assert(t.AsString() == "03/01/2000");
        t.AddDay();
        assert(t.AsString() == "03/02/2000");
    }}

    // String assignment
    {{
        CTime::SetFormat("M/D/Y h:m:s");
        CTime t("02/15/2000 01:12:33");
        assert(t.AsString() == "02/15/2000 01:12:33");
        t = "3/16/2001 02:13:34";
        assert(t.AsString() == "03/16/2001 02:13:34");
    }}

    CTime::SetFormat("M/D/Y h:m:s.S");

    // Adding Nanoseconds
    {{
        CTime t;
        for (CTime ti(1999, 12, 31, 23, 59, 59, 999999995);
             ti <= CTime(2000, 1, 1, 0, 0, 0, 000000003);
             t = ti, ti.AddNanoSecond(2)) {
        }
        assert(t.AsString() == "01/01/2000 00:00:00.000000003");
    }}

    CTime::SetFormat("M/D/Y h:m:s");

    // Adding seconds
    {{
        CTime t;
        for (CTime ti(1999, 12, 31, 23, 59, 5);
             ti <= CTime(2000, 1, 1, 0, 1, 20);
             t = ti, ti.AddSecond(11)) {
        }
        assert(t.AsString() == "01/01/2000 00:01:17");
    }}

    // Adding minutes
    {{
        CTime t;
        for (CTime ti(1999, 12, 31, 23, 45);
             ti <= CTime(2000, 1, 1, 0, 15);
             t = ti, ti.AddMinute(11)) {
        }
        assert(t.AsString() == "01/01/2000 00:07:00");
    }}

    // Adding hours
    {{
        CTime t;
        for (CTime ti(1999, 12, 31); ti <= CTime(2000, 1, 1, 15);
             t = ti, ti.AddHour(11)) {
        }
        assert(t.AsString() == "01/01/2000 09:00:00");
    }}

    // Adding months
    {{
        CTime t;
        for (CTime ti(1998, 12, 29); ti <= CTime(1999, 4, 1);
             t = ti, ti.AddMonth()) {
        }
        assert(t.AsString() == "03/28/1999 00:00:00");
    }}
    
    // Difference
    {{
        CTime t1(2000, 10, 1, 12, 3, 45,1);
        CTime t2(2000, 10, 2, 14, 55, 1,2);

        assert((t2.DiffDay(t1)-1.12) < 0.01);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例12: s_TestGMT

static void s_TestGMT(int idx)
{
    // Write time in timezone format
    {{   
        CTime::SetFormat("M/D/Y h:m:s Z");
        CTime t1(2001, 3, 12, 11, 22, 33, 999, CTime::eGmt);
        assert(t1.AsString() == "03/12/2001 11:22:33 GMT");
        CTime t2(2001, 3, 12, 11, 22, 33, 999, CTime::eLocal);
        assert(t2.AsString() == "03/12/2001 11:22:33 ");
    }}

    // Process timezone string
    {{   
        CTime t;
        t.SetFormat("M/D/Y h:m:s Z");
        t="03/12/2001 11:22:33 GMT";
        assert(t.AsString() == "03/12/2001 11:22:33 GMT");
        t="03/12/2001 11:22:33 ";
        assert(t.AsString() == "03/12/2001 11:22:33 ");
    }}

    // Day of week
    {{   
        CTime t(2001, 4, 1);
        t.SetFormat("M/D/Y h:m:s w");
        int i;
        for (i=0; t<=CTime(2001, 4, 10); t.AddDay(),i++) {
            assert(t.DayOfWeek() == (i%7));
        }
    }}

    // Test GetTimeT
    {{  
        time_t timer = time(0);
        CTime tgmt(CTime::eCurrent, CTime::eGmt, CTime::eTZPrecisionDefault);
        CTime tloc(CTime::eCurrent, CTime::eLocal, CTime::eTZPrecisionDefault);
        CTime t(timer);
        // Set the same time to all time objects
        tgmt.SetTimeT(timer);
        tloc.SetTimeT(timer);

        assert(timer == t.GetTimeT());
        assert(timer == tgmt.GetTimeT());
        // On the day of changing to summer/winter time, the local time
        // converted to GMT may differ from the value returned by time(0),
        // because in the common case API don't know if DST is in effect for
        // specified local time or not (see mktime()).
        time_t l_ = tloc.GetTimeT();
        if (timer != l_ ) {
            if ( abs((int)(timer - l_)) > 3600 )
                assert(timer == l_);
        }
    }}

    // Test TimeZoneOffset (1) -- EST timezone only
    {{   
        CTime tw(2001, 1, 1, 12); 
        CTime ts(2001, 6, 1, 12);
        assert(tw.TimeZoneOffset() / 3600 == -5);
        assert(ts.TimeZoneOffset()/3600 == -4);
    }}

    // Test TimeZoneOffset (2) -- EST timezone only
    {{   
        CTime tw(2001, 6, 1, 12); 
        CTime ts(2002, 1, 1, 12);
        assert(tw.TimeZoneOffset() / 3600 == -4);
        assert(ts.TimeZoneOffset() / 3600 == -5);
    }}

    // Test AdjustTime
    {{   
        CTime::SetFormat("M/D/Y h:m:s");
        CTime t("03/11/2007 01:01:00");
        CTime tn;
        t.SetTimeZonePrecision(CTime::eTZPrecisionDefault);

        // GMT
        t.SetTimeZone(CTime::eGmt);
        tn = t;
        tn.AddDay(5);  
        assert(tn.AsString() == "03/16/2007 01:01:00");
        tn = t;
        tn.AddDay(40); 
        assert(tn.AsString() == "04/20/2007 01:01:00");

        // Local eNone
        t.SetTimeZone(CTime::eLocal);
        t.SetTimeZonePrecision(CTime::eNone);
        tn = t;
        tn.AddDay(5);
        assert(tn.AsString() == "03/16/2007 01:01:00");
        tn = t;
        tn.AddDay(40);
        assert(tn.AsString() == "04/20/2007 01:01:00");

        //Local eMonth
        t.SetTimeZonePrecision(CTime::eMonth);
        tn = t;
        tn.AddDay(5);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例13: MessageBeep

void CFirstPageDlg::OnFpTest()
{

	if(bRecording==FALSE){
		//mean that stay in the state of Stop.
		//click the button can triger the behavior of record.
		pBuffer1=(PBYTE)malloc(INP_BUFFER_SIZE);
		pBuffer2=(PBYTE)malloc(INP_BUFFER_SIZE);
		if (!pBuffer1 || !pBuffer2) {
			if (pBuffer1) free(pBuffer1);
			if (pBuffer2) free(pBuffer2);
			MessageBeep(MB_ICONEXCLAMATION);
			AfxMessageBox(TEXT("Memory erro!"));//TEXT()
			return ;
		}
	
		//open waveform audo for input
		//fill in the structure WAVEFORMATEX
		waveform.wFormatTag=WAVE_FORMAT_PCM; //PCM pulse code modulation
		waveform.nChannels=1;
		waveform.nSamplesPerSec=11025;//sample rate =25khz
		waveform.nAvgBytesPerSec=11025;//ave data rate = 25khz
		waveform.nBlockAlign=1;
		waveform.wBitsPerSample=8; //8 bits per sample
		waveform.cbSize=0;

	
		if (waveInOpen(&hWaveIn,WAVE_MAPPER,&waveform,(DWORD)this->m_hWnd,NULL,CALLBACK_WINDOW)) {
			free(pBuffer1);
			free(pBuffer2);
			MessageBeep(MB_ICONEXCLAMATION);
			AfxMessageBox(_T("Audio can not be open!"));
		}
		//PWAVEHDR pWaveHdr1,pWaveHdr2;
		pWaveHdr1->lpData=(LPSTR)pBuffer1;
		pWaveHdr1->dwBufferLength=INP_BUFFER_SIZE;
		pWaveHdr1->dwBytesRecorded=0;
		pWaveHdr1->dwUser=0;
		pWaveHdr1->dwFlags=0;
		pWaveHdr1->dwLoops=1;
		pWaveHdr1->lpNext=NULL;
		pWaveHdr1->reserved=0;
	
		waveInPrepareHeader(hWaveIn,pWaveHdr1,sizeof(WAVEHDR));
	
		pWaveHdr2->lpData=(LPSTR)pBuffer2;
		pWaveHdr2->dwBufferLength=INP_BUFFER_SIZE;
		pWaveHdr2->dwBytesRecorded=0;
		pWaveHdr2->dwUser=0;
		pWaveHdr2->dwFlags=0;
		pWaveHdr2->dwLoops=1;
		pWaveHdr2->lpNext=NULL;
		pWaveHdr2->reserved=0;
	
		waveInPrepareHeader(hWaveIn,pWaveHdr2,sizeof(WAVEHDR));
	
		//////////////////////////////////////////////////////////////////////////
		pSaveBuffer = (PBYTE)realloc (pSaveBuffer, 1) ;
		// Add the buffers
	
		waveInAddBuffer (hWaveIn, pWaveHdr1, sizeof (WAVEHDR)) ;
		waveInAddBuffer (hWaveIn, pWaveHdr2, sizeof (WAVEHDR)) ;
	
		// Begin sampling
		this->showMsg+=_T("Recording...\r\n");
		((CEdit *)GetDlgItem(IDC_FP_TESTOUT))->SetWindowText(this->showMsg);
		dwDataLength = 0 ;
		
		waveInStart (hWaveIn) ;

	}
	else{
		//bRecording == TRUE
		//Recording state,click the button will stop recording and finish the Test.
		if(bRecording){
			//bEnding=TRUE;
			waveInReset(hWaveIn);//stop the record!
		}
		bRecording = FALSE;
		CString filepath;
		filepath = _T("E:\\Speechdata\\Test");
		//find the directory
		if(!PathIsDirectory(filepath)){
			CreateDirectory(filepath,NULL);
		}
		//set the test filename
		CTime current = CTime::GetCurrentTime();
		CString filename;
		int y = current.GetYear();
		int m = current.GetMonth();
		int d = current.GetDay();
		int h = current.GetHour();
		int min = current.GetMinute();
		int s = current.GetSecond();
		filename.Format(_T("%d%d%d%d%d%d"),y,m,d,h,min,s);
		filename+=".wav";
		filepath+=_T("\\")+filename; 
		
		CFileFind find;
		if(!find.FindFile(filepath)){
//.........这里部分代码省略.........
开发者ID:jltong,项目名称:SignerSystem,代码行数:101,代码来源:FirstPageDlg.cpp

示例14: DrawGameView

//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	CString strFile,strTemp;
	CTime tmCur = CTime::GetCurrentTime();
	CString strTime = tmCur.Format("%m%d");
	strFile.Format("log\\%sDrawGameView.log",strTime);

	if (nWidth > 0 && nWidth < 1500)
	{
		if (xOffInt != nWidth)
		{
			xOffInt=nWidth;
			yOffInt=nHeight;

			AfxGetMainWnd()->SendMessage(IDM_RESET_UI, nWidth, nHeight);
		}

	}
	//绘画背景
	DrawViewImage(pDC,m_ImageBack,enMode_Spread);
	int iXPos;
	int iYPos;
	for (int i=0; i < GAME_PLAYER; i++)
	{
		iXPos=	m_PtVideo[i].x;
		iYPos=m_PtVideo[i].y;

		if ( 1 == m_uVideoInt[i])
		DrawOtherVideoPic(  pDC,  iXPos,  iYPos);
	}//End for

	//自己
	int myX,myY,myW,myH;
	myW= MYSLEF_VIDEO_W;
	myH= MYSLEF_VIDEO_H;
	myX=  10-3;//
	myY=  nHeight-myH-10-35; 
	DrawMyselfVideoPic( pDC,  myX,  myY);
	//绘画用户
	pDC->SetTextColor(RGB(255,255,0));
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		const tagUserData * pUserData=GetUserInfo(i);
		if (pUserData!=NULL)
		{
			//用户名字
			pDC->SetTextAlign((i==1)?(TA_RIGHT|TA_TOP):(TA_LEFT|TA_TOP));
			DrawTextString(pDC,pUserData->szName,RGB(240,240,240),RGB(50,50,50),m_ptNameNew[i].x,m_ptName[i].y);

			if( m_tDice>0 && m_tDice<12)
			{
				ActionDice1( pDC,m_tDice);

				strTemp.Format("ActionDice1 ");
				theApp.WriteLog(strFile, strTemp);

			}
			else
			{
				if( m_tDice== 12)
				{
					ActionDice2( pDC,m_nDiceCount1,m_nDiceCount2);
					strTemp.Format("ActionDice2  m_nDiceCount1=%d,m_nDiceCount2=%d", m_nDiceCount1,m_nDiceCount2);
					theApp.WriteLog(strFile, strTemp);
		//	m_tDice++;
				}//End if
			}//End if
			//其他信息
			WORD wUserTimer=GetUserTimer(i);
			if (wUserTimer!=0) DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
			if (pUserData->cbUserStatus==US_READY) DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
			//DrawUserFace(pDC,pUserData->wFaceID,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE);
			//画听标记
			if( m_bTingFlag[i] )
			{
				ShowTingPic( pDC, m_ptFace[i].x,m_ptFace[i].y);
			}//End if
		}
	}

	//用户标志
	if (m_wBankerUser!=INVALID_CHAIR)
	{
		//加载位图
		CImageHandle ImageHandle(&m_ImageUserFlag);
		int nImageWidth=m_ImageUserFlag.GetWidth()/4;
		int nImageHeight=m_ImageUserFlag.GetHeight();

		//绘画标志
		for (WORD i=0;i<GAME_PLAYER;i++)
		{
			WORD wIndex=((i+GAME_PLAYER)-m_wBankerUser)%GAME_PLAYER;
			m_ImageUserFlag.BitBlt(pDC->m_hDC,m_UserFlagPos[i].x,m_UserFlagPos[i].y,nImageWidth,nImageHeight,nImageWidth*wIndex,0);
		}
	}

	//桌面麻将
	for (WORD i=0;i<4;i++)
//.........这里部分代码省略.........
开发者ID:275958081,项目名称:netfox,代码行数:101,代码来源:GameClientView.cpp

示例15: GetDlgItem

//把录像文件按时间逆序,然后反应到控件上  yjj 090304
void CAppealDlg::ProcessRecordFile(const CString& strUserName)
{
    if (strUserName == "")
    {
        return;
    }
    GetDlgItem(IDC_EDIT_USERNAME)->SetWindowText(strUserName);
    GetDlgItem(IDC_EDIT_PHONE_NUM)->SetWindowText("");
    GetDlgItem(IDC_EDIT_APPEAL_EMAIL)->SetWindowText("");
    GetDlgItem(IDC_EDIT_APPEAL_CONTENT)->SetWindowText("");



    CString strPath = CBcfFile::GetAppPath(); //得到当前的目录

    strPath += "log";
    strPath += "\\";

    CString gamenamefile = strPath + "gamename.bcf";
    DWORD dwHandle = cfgOpenFile(gamenamefile);

    if(dwHandle < 0x10)
        return;

    strPath += "log_";
    strPath += strUserName;
    strPath += "\\";

    CTime tCurTime = CTime::GetCurrentTime();
    CString direct = tCurTime.Format("%Y-%m-%d");

    CString strCurDir = strPath + direct;

    strCurDir += "\\";
    CFileFind finder;
    strCurDir += _T("*.*");
    int iFindFileCount = 0;
    m_fileList.clear();

    //从当前,向前找6个目录
    for (int i=0; i<6; i++)
    {
        BOOL bWorking = finder.FindFile(strCurDir);
        while (bWorking)
        {
            bWorking = finder.FindNextFile();
            if (finder.IsDots())
                continue;




            //找到一个文件
            //CString sFileName = finder.GetFileName();
            //CString sFilePath = finder.GetFilePath();
            RecordFileStruct recordfile;

            recordfile.strWholeName = finder.GetFilePath(); //得到完整名字
            recordfile.strFileName = finder.GetFileName();     //得到文件名字

            //wushuqun 2009.5.20
            recordfile.strGamePath = finder.GetFilePath();

            //if (recordfile.strFileName.Find(".zxh") == -1)
            //{
            //	continue;
            //}
            CString strNameId = GetFileNameID(recordfile.strFileName);
            recordfile.strGameName = GetGameName(dwHandle,strNameId); //得到游戏名字

            if (recordfile.strGameName == "")
            {
                continue;
            }
            finder.GetCreationTime(recordfile.timeCreatTime);    //得到创建文件时间
            recordfile.strGameTime = recordfile.timeCreatTime.Format("%m-%d %H:%M ");
            m_fileList.push_back(recordfile);  //把文件信息加入链表
            iFindFileCount ++;
        }
        //找完整个目录
        if (iFindFileCount >= 20)
        {
            break;
        }
        //
        CTimeSpan ts(1,   0,   0,   0);
        tCurTime -= ts;
        direct = tCurTime.Format("%Y-%m-%d");
        strCurDir = strPath + direct;

        strCurDir += "\\";
        strCurDir +=_T("*.*");
        //找上一天的目录
    }

    //按升序排列



//.........这里部分代码省略.........
开发者ID:lincoln56,项目名称:robinerp,代码行数:101,代码来源:AppealDlg.cpp


注:本文中的CTime类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。