Example #1
0
//------------------------------------------------------------------------------------
bool CAutoRegisterConfig::SetTimeRange( 
	CDateTimeCtrl& start, CDateTimeCtrl& end, 
	CString& strStartMin, CString& strEndMin, 
	int nStartHour, int nEndHour )
{
	SYSTEMTIME smStart, smEnd;
	start.GetTime(&smStart);
	end.GetTime(&smEnd);
	
	m_startTime.SetDateTime(smStart.wYear, smStart.wMonth, smStart.wDay,nStartHour,
		_ttoi(strStartMin), 0);

	m_endTime.SetDateTime(smEnd.wYear, smEnd.wMonth, smEnd.wDay,nEndHour,
		_ttoi(strEndMin), 0);

	COleDateTimeSpan dtSpan = m_endTime - m_startTime;

	if (dtSpan.GetTotalSeconds() <= 0)
	{
		AfxMessageBox(_T("结束时间不得小于起始时间"));
		return false;
	}
	COleDateTime dtEnd, dtStart;
	dtStart.SetDate(m_startTime.GetYear(), m_startTime.GetMonth(), m_startTime.GetDay());
	dtEnd.SetDate(m_endTime.GetYear(), m_endTime.GetMonth(), m_endTime.GetDay());
	COleDateTimeSpan dtSpan2;
	if(dtSpan2.GetTotalDays() > m_array24Amount.size())
	{
		AfxMessageBox(_T("开始时间和结束时间之间的天数不能大于每天开户金额的天数"));
		return false;
	}
	
	return true;
}
Example #2
0
BOOL CNDCheckInDlg::CheckTakeUp(CString strTermId)
{
	//查询该终端是否被占用
	BOOL bTakeUp = FALSE;

	CLastUserInfo LastUserInfo;

	if (CIBADAL::GetInstance()->GetLastUserInfo(LastUserInfo, 0, strTermId))
	{
		if (LastUserInfo.GetSuspend())//挂机
		{
			bTakeUp = TRUE;
		}
		else//非挂机
		{
			COleDateTime updateTime;
			updateTime.ParseDateTime(LastUserInfo.GetUpdateTime());
			COleDateTimeSpan interval = COleDateTime::GetCurrentTime() - updateTime;
			
			if (interval.GetTotalMinutes() < 10)//被占用,并且用户还有效
			{
				bTakeUp = TRUE;
			} 
		}
	}

	return bTakeUp;
}
Example #3
0
CString CActiveMember::GetUseTimeAsString()
{
	CString strTmp;

	if ( GetIsOnLine() )
	{
		COleDateTime dtNow = COleDateTime::GetCurrentTime();

		COleDateTimeSpan dts = dtNow - CheckInTime;

		//系统时间跟中心事件有差错时,可能存在为负的情况
		if (dts < COleDateTimeSpan(0, 0, 0, 0))//时间为负
		{
			strTmp.Format(_T("%.2d:%.2d"), 0, 0);
		}
		else//正常
		{
			//{ 2011/04/22-gxx: 修改原来支持最大时长24小时为总时长, GetHours()-->GetTotalHours()
			int nHours = (int)dts.GetTotalHours();
			strTmp.Format(_T("%.2d:%.2d"), nHours, dts.GetMinutes());
			//}		
		}
	}

	return strTmp;
}
// Start the server. This blocks until the server stops.
void AgentConfigurationEx::start ( )
{
  GLogger.Fatal("AgentConfigurationEx::start\n");

  for ( int i = 0; i < _devices.size( ); i++ )
  {
    ABBAdapter *_cmdHandler = new ABBAdapter(this, config, _devices[i]);
    _cncHandlers.push_back(_cmdHandler);
    _group.create_thread(boost::bind(&ABBAdapter::Cycle, _cncHandlers[i]) );
  }

  if ( Globals.ResetAtMidnight )
  {
    COleDateTime     now          = COleDateTime::GetCurrentTime( );
    COleDateTimeSpan tilnextreset = COleDateTimeSpan(0, 1, 0, 0);
    GLogger.Fatal(StdStringFormat("Agent will Reset from now  %8.4f\n", ( tilnextreset.GetTotalSeconds( ) / 3600.00 ) ) );

    _resetthread.Initialize( );

    _resetthread.AddTimer(
      (long) tilnextreset.GetTotalSeconds( ) * 1000,
      &_ResetThread,
      ( DWORD_PTR ) this,
      &_ResetThread._hTimer        // stored newly created timer handle
      );
  }

  AgentConfigurationT::start( );  // does not return
}
// NOTE: Windows SCM more tolerant of slow starting processes than terminating processes.
void MtcOpcAdapter::start()
{
 	static char name[] = "MtcOpcAdapter::start";
	_bRunning=true; 
	if(_bResetAtMidnight)
	{
		COleDateTime now = COleDateTime::GetCurrentTime();
		COleDateTime date2 =  COleDateTime(now.GetYear(), now.GetMonth(), now.GetDay(), 0, 0, 0) +  COleDateTimeSpan(1, 0, 0, 1);
		//COleDateTime date2 =  now +  COleDateTimeSpan(0, 0, 2, 0); // testing reset time - 2 minutes

		COleDateTimeSpan tilmidnight = date2-now;
		_resetthread.Initialize();
		_resetthread.AddTimer(
			(long) tilmidnight.GetTotalSeconds() * 1000,
			&_ResetThread,
			(DWORD_PTR) this,
			&_ResetThread._hTimer  // stored newly created timer handle
			) ;

		GLogger << INFO << "Adapter will Reset At Midnight " << date2.Format() << std::endl;
	}

	if(_bOPCEnabled)
	{
		_workerthread.Initialize();
		::SetEvent (_StartThread._hEvent); // start OPC thread
		_workerthread.AddHandle(_StartThread._hEvent, &_StartThread,(DWORD_PTR) this);
	}

	// This goes last... never returns
	startServer();
}
Example #6
0
static void __stdcall ActivityCallback(ConversionActivity* activity, void* userData)
{
	COleDateTimeSpan ts;

	ts.SetDateTimeSpan(0, 0, 0, activity->ElapsedTimeSpanInSeconds);

	char spinner[] = {'-', '\\', '|', '/'};

	if (_spinnerIndex++ >= 3) _spinnerIndex = 0;

	TCHAR output1[128];
	TCHAR output2[128];
	TCHAR output3[128];

	_stprintf_s(output1, _T(" %c %s converted: %sK d/l'ed:"),
		spinner[_spinnerIndex],
		ts.Format(_T("%H:%M:%S")),
		CommaSeparate((ULONGLONG)activity->CurrentFileSize / 1024));

	_stprintf_s(output2, _T("%sK"),
		CommaSeparate((ULONGLONG)activity->DownloadCurrent / 1024));

	_stprintf_s(output3, _T("/ %sK"),
		CommaSeparate((ULONGLONG)activity->DownloadTotal / 1024));

	_tprintf_s(_T("%s %s %s\r"), output1, output2, output3);
}
void CDefineBundleTimeDlg::OnEndTimeChanged()
{
	COleDateTime startTime;
	startTime.ParseDateTime(m_btnStartTime.ToString());

	COleDateTime endTime;
	endTime.ParseDateTime(m_btnEndTime.ToString());

	if (endTime <= startTime)
	{
		m_btnEndTime.SetDate(startTime);
		endTime.ParseDateTime(m_btnEndTime.ToString());
	}

	COleDateTimeSpan sp = endTime - startTime;

	INT nHours = (long)sp.GetTotalHours();
	INT nMinutes = sp.GetMinutes();

	CString strTmp;
	strTmp.Format(_T("%d"), nHours);
	m_edtHours.SetWindowText(strTmp);

	strTmp.Format(_T("%d"), nMinutes);
	m_edtMinutes.SetWindowText(strTmp);

	TRACE("OnEndTimeChanged\n");
}
// Start the server. This blocks until the server stops.
void AgentConfigurationEx::start()
{
	GLogger.LogMessage(StdStringFormat("AgentConfigurationEx::start()\n"));
	getAgent()->set_listening_port(Globals.HttpPort);
	MTConnectService::setName(Globals.ServerName);

	for(int i=0; i< _ipaddrs.size(); i++)
	{
		COpcAdapter *  _cmdHandler = new COpcAdapter(this, config, _ipaddrs[i], _devices[i], _tags[i]);
		_cncHandlers.push_back(_cmdHandler);
		GLogger.LogMessage(StdStringFormat("AgentConfigurationEx::start COpcAdapter::Cycle() %x\n",_ipaddrs[i]), DBUG);
		_group.create_thread(boost::bind(&COpcAdapter::Cycle, _cncHandlers[i]));
	}
	GLogger.LogMessage(StdStringFormat("Call AgentConfiguration::start() ed \n"));

	if(Globals.ResetAtMidnight)
	{
		COleDateTime now = COleDateTime::GetCurrentTime();
		COleDateTime date2 =  COleDateTime(now.GetYear(), now.GetMonth(), now.GetDay(), 0, 0, 0) +  COleDateTimeSpan(1, 0, 0, 1);
		//COleDateTime date2 =  now +  COleDateTimeSpan(0, 0, 2, 0); // testing reset time - 2 minutes
		COleDateTimeSpan tilmidnight = date2-now;
		_resetthread.Initialize();
		_resetthread.AddTimer(
			(long) tilmidnight.GetTotalSeconds() * 1000,
			&_ResetThread,
			(DWORD_PTR) this,
			&_ResetThread._hTimer  // stored newly created timer handle
			) ;

		GLogger.LogMessage(StdStringFormat("Agent will Reset At Midnight %s \n", (LPCSTR) date2.Format()), DBUG);
	}

	AgentConfiguration::start(); // does not return
}
Example #9
0
BOOL CActiveMember::IsOffLinePossibility()
{
	if ( GetIsOnLine() )
	{
		COleDateTimeSpan dtSpan = COleDateTime::GetCurrentTime() - UpdateDataTime;

		// 2014-1-10-qsc 把6m30s改成2m30s
		return dtSpan.GetTotalSeconds() > (2 * 60 + 30); //上一次的更新时间和当前时间的间隔>2m30s
		// 可以认为可能离线了。
	}
	
	return FALSE;
}
Example #10
0
double CChartAxis::GetNextTickValue(double Previous)
{
	double NewTick = 0;
	switch (m_AxisType)
	{
	case atStandard:
		NewTick = Previous + m_TickIncrement;
		break;

	case atLogarithmic:
		NewTick = Previous * m_TickIncrement;
		break;

	case atDateTime:
		{
			COleDateTime dtTick((DATE)Previous);
			COleDateTimeSpan dtSpan;
			switch (m_BaseInterval)
			{
			case tiSecond:
				dtSpan.SetDateTimeSpan(0,0,0,m_iDTTickIntervalMult);
				dtTick += dtSpan;
				break;
			case tiMinute:
				dtSpan.SetDateTimeSpan(0,0,m_iDTTickIntervalMult,0);
				dtTick += dtSpan;
				break;
			case tiHour:
				dtSpan.SetDateTimeSpan(0,m_iDTTickIntervalMult,0,0);
				dtTick += dtSpan;
				break;
			case tiDay:
				dtSpan.SetDateTimeSpan(m_iDTTickIntervalMult,0,0,0);
				dtTick += dtSpan;
				break;
			case tiMonth:
				{
					dtTick = AddMonthToDate(dtTick,m_iDTTickIntervalMult);
				}
				break;
			case tiYear:
				break;
			}

			NewTick = (DATE)dtTick;
		}
		break;
	}

	return NewTick;
}
Example #11
0
CString FiletimeAsTimeSpan(const PROPVARIANT& propVar)
{
   FILETIME ftNull;
   ftNull.dwLowDateTime = 0;
   ftNull.dwHighDateTime = 0;

   COleDateTime coledtNull(ftNull);
   COleDateTime coledtEditTime(propVar.filetime);
   COleDateTimeSpan coledtsTotalEditTime = coledtEditTime - coledtNull;

   CString sPropValue;
   sPropValue.Format(_T("%.0f"), coledtsTotalEditTime.GetTotalMinutes());
   return sPropValue;
}
Example #12
0
void CSystemTray::OnTimer(UINT nIDEvent) 
{
    ASSERT(nIDEvent == m_nIDEvent);

    COleDateTime CurrentTime = COleDateTime::GetCurrentTime();
    COleDateTimeSpan period = CurrentTime - m_StartTime;
    if (m_nAnimationPeriod > 0 && m_nAnimationPeriod < period.GetTotalSeconds())
    {
        StopAnimation();
        return;
    }

    StepAnimation();
}
void CDefineBundleTimeDlg::OnBnClickedOk()
{
	CString strRet;

	COleDateTime startTime;
	startTime.ParseDateTime(m_btnStartTime.ToString());
	
	COleDateTime endTime;
	endTime.ParseDateTime(m_btnEndTime.ToString());

	COleDateTimeSpan sp = endTime - startTime;

	UINT nAllMinites = (LONG)sp.GetTotalMinutes();

	if (nAllMinites <= 0)
	{
		strRet = _T("包时时间有误,请重新选择!");
		SetToolTipPos(IDOK);
		ShowToolTip(strRet);
		return;
	}

	CString strMoney;
	m_edtBundTimeMoney.GetWindowText(strMoney);

	if (strMoney.IsEmpty())
	{
		GetDlgItem(IDC_EDIT_BUNDTIMEMONEY)->SetFocus();
		return;
	}
	
	CWaitCursor Wait;

	double dBundTimeMoney = _tstof(strMoney);
	UINT nBundTimeMoney = (dBundTimeMoney + 0.005) * 100;	//作舍入转换
	INT nIdx = m_cboArea.GetCurSel();

	//2011-4-18-gxx: 保存开户时自定义包时的参数设置
	m_BundleTimeInfo.TimeId = 9999;
	m_BundleTimeInfo.BeginTime = startTime.Format(_T("%Y%m%d%H%M%S"));
	m_BundleTimeInfo.TimePass = nAllMinites;
	m_BundleTimeInfo.Amount = nBundTimeMoney;
	m_BundleTimeInfo.PcClass = m_cboArea.GetItemData(nIdx);
	m_BundleTimeInfo.AccountType = m_cboAccountType.GetCurSel();
	
	m_BundleTimeInfo.bIsSelected = TRUE;

	OnOK();

}
void TestDominoDocArtifact::TestModifiedTime()
{
	COleDateTime currentTime = COleDateTime::GetCurrentTime();
	DomDocHelper domDocHelper(TEST_ARTIFACT_FILE);  
	DominoDocArtifact validArtifact(m_spLibrary, domDocHelper.DocumentId, domDocHelper.GetVersionLabel());

	COleDateTime dominoDocmodifiedTime = validArtifact.ModifiedTime;
	assertTest(COleDateTime::invalid != dominoDocmodifiedTime.GetStatus());
	assertTest(COleDateTime::null != dominoDocmodifiedTime.GetStatus());

	COleDateTimeSpan OleDateTimeSpan = dominoDocmodifiedTime - currentTime;
	assertTest(0 == OleDateTimeSpan.GetHours());
	assertTest(2 >= OleDateTimeSpan.GetMinutes());
}
BOOL COptionsStats::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();

	CTime time(CGetSetOptions::GetTotalDate());
	m_eAllDate = time.Format("%m/%d/%Y %I:%M %p");
	m_eAllCopies.Format(_T("%d"), CGetSetOptions::GetTotalCopyCount());
	m_eAllPastes.Format(_T("%d"), CGetSetOptions::GetTotalPasteCount());

	CTime time2(CGetSetOptions::GetTripDate());
	m_eTripDate = time2.Format("%m/%d/%Y %I:%M %p");
	m_eTripCopies.Format(_T("%d"), CGetSetOptions::GetTripCopyCount());
	m_eTripPastes.Format(_T("%d"), CGetSetOptions::GetTripPasteCount());

	m_eClipsSent.Format(_T("%d"), theApp.m_lClipsSent);
	m_eClipsRecieved.Format(_T("%d"), theApp.m_lClipsRecieved);
	m_eLastStarted = theApp.m_oldtStartUp.Format(_T("%m/%d/%y %I:%M:%S"));
	if(theApp.m_oldtStartUp.GetHour() > 12)
		m_eLastStarted += " PM";
	else
		m_eLastStarted += " AM";

	COleDateTimeSpan span = COleDateTime::GetCurrentTime() - theApp.m_oldtStartUp;

	CString csSpan;
	csSpan.Format(_T("  -  %d.%d.%d (D.H.M)"), (long)span.GetTotalDays(), span.GetHours(), span.GetMinutes());
	m_eLastStarted += csSpan;

	try
	{
		m_eSavedCopies.Format(_T("%d"), theApp.m_db.execScalar(_T("SELECT COUNT(lID) FROM Main")));
		m_eSavedCopyData.Format(_T("%d"), theApp.m_db.execScalar(_T("SELECT COUNT(lID) FROM Data")));
	}
	CATCH_SQLITE_EXCEPTION
	
	__int64 size = FileSize(GetDBName());			

	const int MAX_FILE_SIZE_BUFFER = 255;
	TCHAR szFileSize[MAX_FILE_SIZE_BUFFER];
	StrFormatByteSize(size, szFileSize, MAX_FILE_SIZE_BUFFER);

	m_eDatabaseSize = szFileSize;

	UpdateData(FALSE);

	theApp.m_Language.UpdateOptionStats(this);
		
	return TRUE;
}
bool AgentConfigurationEx::ResetAtMidnite ( )
{
  COleDateTime now   = COleDateTime::GetCurrentTime( );
  COleDateTime date2 = COleDateTime(now.GetYear( ), now.GetMonth( ), now.GetDay( ), 0, 0, 0) + COleDateTimeSpan(1, 0, 0, 1);

  // COleDateTime date2 =  now +  COleDateTimeSpan(0, 0, 2, 0); // testing reset time - 2 minutes
  COleDateTimeSpan tilmidnight = date2 - now;

  _resetthread.Initialize( );
  _resetthread.AddTimer(
    (long) tilmidnight.GetTotalSeconds( ) * 1000,
    &_ResetThread,
    ( DWORD_PTR ) this,
    &_ResetThread._hTimer      // stored newly created timer handle
    );
  return true;
}
Example #17
0
BOOL CActiveMember::IsNeedToQuery()
{
	if (GetStatus() == EStatus_LocalOnline) //本地在线
	{
		return IsOffLinePossibility();
	}
	else if (GetStatus() == EStatus_CenterOnLine) //中心在线
	{
		return COleDateTime::GetCurrentTime() >= UpdateDataTime;
	}
	else if (GetStatus() == EStatus_AutoReturn) //待退款
	{
		if (UpdateDataTime.GetStatus() != COleDateTime::valid)
		{
			return TRUE;
		}

		COleDateTimeSpan dtSpan = COleDateTime::GetCurrentTime() - UpdateDataTime; 

		if (dtSpan.GetTotalMinutes() >= GetRefundmentTime())
		{
			return TRUE;
		}
	}
	//{ 2011/11/01-8210-gxx: 
	else if (GetStatus() == EStatus_RoomAutoReturn) 
	{
		if (UpdateDataTime.GetStatus() != COleDateTime::valid)
		{
			return TRUE;
		}

		COleDateTimeSpan dtSpan = COleDateTime::GetCurrentTime() - UpdateDataTime; 

		if (dtSpan.GetTotalMinutes() >= 2.0) // 超过2分钟,主账号就可以自动退款了
		{
			return TRUE;
		}
	}
	//}

	return FALSE;
}
Example #18
0
void  VirtualMeasurement::UpdateDischargeDate()
{
	//if (_iMPMeasurementType == AssemblyVerification)
	{
		if (_fMPCoolingTime < 0.0f)
			_fMPCoolingTime = 0.0;

		// change discharge date to conform to the cooling time
		// cooling time is in years
		COleDateTimeSpan coolings;
		int secs = int(24.0*60.0*60.0 * 365.0 * _fMPCoolingTime);
		coolings.SetDateTimeSpan(0, 0, 0, secs);

		COleDateTime dd = _iMPMeasurementDateTime - coolings;
		_iMPDischargeDateYear = dd.GetYear();
		_iMPDischargeDateMonth = dd.GetMonth();
		_iMPDischargeDateDay = dd.GetDay();

	}
}
Example #19
0
int CNetworkTree::OnReadGroup(_RecordsetPtr xRecordset, CString& xUserGrp, CString& xGroupId)
{
	_variant_t TheValue = xRecordset->GetCollect( "xentercode" );
	ASSERT( VT_NULL != TheValue.vt ); xGroupId = (LPCTSTR)(_bstr_t)TheValue;
	
	TheValue = xRecordset->GetCollect( "xentername" );
	if ( VT_NULL == TheValue.vt ) xUserGrp = _T("<NULL>");
	else	xUserGrp = (LPCTSTR)(_bstr_t)TheValue;
	
	TheValue = xRecordset->GetCollect( "xexpiredate" );
	if ( VT_NULL != TheValue.vt )
	{
		COleDateTime tt = TheValue; tt.SetTime( 0, 0, 0 );
		
		COleDateTimeSpan tSpan = COleDateTime::GetCurrentTime() - tt;
		if ( tSpan.GetTotalDays() > 0 ) return EBase_NoPay;
	}
	
	return 0;
}
bool AgentConfigurationEx::ResetAtMidnite ( )
{
	COleDateTime now   = COleDateTime::GetCurrentTime( );
#ifndef RESETTEST
	COleDateTime date2 = COleDateTime(now.GetYear( ), now.GetMonth( ), now.GetDay( ), 0, 0, 0) + COleDateTimeSpan(1, 0, 0, 1);
#else
	COleDateTime date2 =  now +  COleDateTimeSpan(0, 0, 2, 0); // testing reset time - 2 minutes
#endif
	COleDateTimeSpan tilmidnight = date2 - now;
	GLogger.Fatal(StdStringFormat("Agent will Reset at  %s\n", date2.Format("%A, %B %d, %Y %H:%M:%S")  ) );
	GLogger.Fatal(StdStringFormat("Agent will Reset %8.4f hours::min from now\n", ( tilmidnight.GetTotalSeconds( ) / 3600.00 ) ) );

	_resetthread.Initialize( );
	_resetthread.AddTimer(
		(long) tilmidnight.GetTotalSeconds( ) * 1000,
		&_ResetThread,
		( DWORD_PTR ) this,
		&_ResetThread._hTimer      // stored newly created timer handle
		);
	return true;
}
Example #21
0
// DateTimeSpan math
CmcDateTimeSpan CmcDateTime::operator-(const CmcDateTime& date) const
  {
	COleDateTimeSpan spanResult;

	// If either operand NULL, result NULL
	if (GetStatus() == null || date.GetStatus() == null)
	{
		spanResult.SetStatus(COleDateTimeSpan::null);
		return (double)spanResult;
	}

	// If either operand invalid, result invalid
	if (GetStatus() == invalid || date.GetStatus() == invalid)
	{
		spanResult.SetStatus(COleDateTimeSpan::invalid);
		return (double)spanResult;
	}

	// Return result (span can't be invalid, so don't check range)
	return m_dt - date.m_dt;

  }
void CBCGPPlannerViewMonth::SetDateInterval (const COleDateTime& date1, const COleDateTime& date2)
{
	ASSERT (date1 <= date2);

	COleDateTimeSpan duration (date2 - date1);

	m_nDuration = ((int)(duration.GetTotalDays () / 7.0)) * 7;
	if (m_nDuration < duration.GetTotalDays ())
	{
		m_nDuration += 7;
	}

	if (m_nDuration < 14)
	{
		m_nDuration = 14;
	}
	else if (m_nDuration > 42)
	{
		m_nDuration = 42;
	}

	COleDateTime _date1 (date1);

	if (IsCompressWeekend () &&
		CBCGPPlannerManagerCtrl::GetFirstDayOfWeek () == 0)
	{
		_date1 += COleDateTimeSpan (1, 0, 0, 0);
	}

	m_DateStart = GetFirstWeekDay2 (_date1, CBCGPPlannerManagerCtrl::GetFirstDayOfWeek () + 1);
	m_DateEnd   = m_DateStart + COleDateTimeSpan (m_nDuration - 1, 23, 59, 59);

	if (m_DateEnd < m_Date || m_Date < m_DateStart)
	{
		m_Date = m_DateStart;
	}

	SetDate (m_Date);
}
bool CChartDateTimeAxis::GetNextTickValue(double dCurrentTick, double& dNextTick) const
{
	if (m_MinValue == m_MaxValue)
		return false;

	COleDateTime dtTick((DATE)dCurrentTick);
	COleDateTimeSpan dtSpan;
	switch (m_BaseInterval)
	{
	case tiSecond:
		dtSpan.SetDateTimeSpan(0,0,0,m_iDTTickIntervalMult);
		dtTick += dtSpan;
		break;
	case tiMinute:
		dtSpan.SetDateTimeSpan(0,0,m_iDTTickIntervalMult,0);
		dtTick += dtSpan;
		break;
	case tiHour:
		dtSpan.SetDateTimeSpan(0,m_iDTTickIntervalMult,0,0);
		dtTick += dtSpan;
		break;
	case tiDay:
		dtSpan.SetDateTimeSpan(m_iDTTickIntervalMult,0,0,0);
		dtTick += dtSpan;
		break;
	case tiMonth:
		dtTick = AddMonthToDate(dtTick,m_iDTTickIntervalMult);
		break;
	case tiYear:
		dtTick = AddMonthToDate(dtTick,12*m_iDTTickIntervalMult);
		break;
	}

	dNextTick = (DATE)dtTick;
	if (dNextTick <= m_MaxValue)
		return true;
	else
		return false;
}
Example #24
0
CString CComputerInfo::GetUseTimeAsString()
{
	CString strTmp;

	// 2011/07/11-8201-gxx: 
	if (m_CheckInTime.GetStatus() == COleDateTime::invalid ||
		m_CheckInTime.GetStatus() == COleDateTime::null)
	{
		return strTmp;
	}

	if (m_bHasUserInfo || ECS_UNLOCK == m_ComputerStatus)
	{
		COleDateTime dtNow = COleDateTime::GetCurrentTime();
		
		COleDateTimeSpan dts = dtNow - m_CheckInTime;

		//系统时间跟中心事件有差错时,可能存在为负的情况
		if (dts < COleDateTimeSpan(0, 0, 0, 0))//时间为负
		{
			strTmp.Format(_T("%.2d:%.2d"), 0, 0);
		}
		else if( m_CheckInTime == 0 ) // 上机时间为0,表示没有上机
		{
			strTmp = _T("");
			return strTmp;
		}
		else//正常
		{
			//{ 2011/04/22-gxx: 修改原来支持最大时长24小时为总时长, GetHours()-->GetTotalHours()
			int nHours = (int)dts.GetTotalHours();
			strTmp.Format(_T("%.2d:%.2d"), nHours, dts.GetMinutes());
			//}			
		}
	}

	return strTmp;
}
Example #25
0
void VirtualMeasurement::FinishMeasurement(COleDateTime odtMTime)
{

	_iMPMeasurementDateYear = odtMTime.GetYear();
	_iMPMeasurementDateMonth = odtMTime.GetMonth();
	_iMPMeasurementDateDay = odtMTime.GetDay();

	_fMPNChanA = (float)_dAve.val[NeutA];
	_fMPNChanB = (float)_dAve.val[NeutB];
	_fMPNChanC = (float)_dAve.val[NeutC];
	_fMPGDose1 = (float)_dAve.val[Gamma1];
	_fMPGDose2 = (float)_dAve.val[Gamma2];

	COleDateTimeSpan delta = odtMTime;
	delta -= delta.GetDays();

	_fMPNChanBThresh = (float)delta.GetTotalSeconds();

	CalcCoolingTime();
	ApplyAdjustments();
	//SetDetectorID();

	Certify();
}
double CChartDateTimeAxis::GetFirstTickValue() const
{
	double dRetVal = m_dFirstTickValue;
	if (m_bDiscrete)
	{
		COleDateTime dtTick((DATE)m_dFirstTickValue);
		COleDateTimeSpan dtSpan;
		switch (m_BaseInterval)
		{
		case tiSecond:
			dtSpan.SetDateTimeSpan(0,0,0,m_iDTTickIntervalMult);
			dtTick -= dtSpan;
			break;
		case tiMinute:
			dtSpan.SetDateTimeSpan(0,0,m_iDTTickIntervalMult,0);
			dtTick -= dtSpan;
			break;
		case tiHour:
			dtSpan.SetDateTimeSpan(0,m_iDTTickIntervalMult,0,0);
			dtTick -= dtSpan;
			break;
		case tiDay:
			dtSpan.SetDateTimeSpan(m_iDTTickIntervalMult,0,0,0);
			dtTick -= dtSpan;
			break;
		case tiMonth:
			dtTick = AddMonthToDate(dtTick,-m_iDTTickIntervalMult);
			break;
		case tiYear:
			dtTick = AddMonthToDate(dtTick,-12*m_iDTTickIntervalMult);
			break;
		}
	}
	return dRetVal;

}
Example #27
0
void
CEOSSPropertySheet::WriteToFile(int ToWhom, int Type, CJulianTime* Time, char* Msg)
{
	FILE *File;
	char Message[256];
	fpos_t position;
	Message[0] = NULL;
	COleDateTime TC = COleDateTime::GetCurrentTime();
	COleDateTime TG;
	COleDateTimeSpan TS;
	CString ArchiveFileName;

//	if (m_pParent->m_bBlockWrite) 
//		return;

	//default to the provided EOSS time
	if (Time)
	{
		int Year,Month,Day,Hour,Minute,Second;
		Year = Time->Year();
		Month = Time->Month();
		Day = Time->Day();
		Hour = Time->Hour();
		Minute = Time->Minute();
		Second = Time->Second();
		if (Year	< 100)  Year	= 1900;//COleDateTime limits year 100-9999
		if (Year    > 9999) Year    = 9999;//COleDateTime limits year 100-9999
		if (Month	< 1)	Month	= 1;
		if (Day		< 1)	Day		= 1;
		if (Hour	< 0)	Hour	= 0;
		if (Minute	< 0)	Minute	= 0;
		if (Second	< 0)	Second	= 0;
		TG = COleDateTime(Year, Month, Day, Hour, Minute, Second);
	}
	//if that wasn't available then get the computer time
	//this is the case in all TYPE_COMP messages
	else
	{
		TG = COleDateTime::GetCurrentTime();
	}

	if (ToWhom == TO_DMP)
	{
		//	build new file name and save it
		if (m_pParent->m_bUseShortFilename)
		{
			char cYear;
			int iYear = TC.GetYear();
			if ((iYear < 1990) || (iYear > 2025))
				cYear = '#';
			else if (iYear < 2000)
				cYear = (char)('0' + iYear - 1990);
			else 
				cYear = (char)('A' + iYear - 2000);

			sprintf(m_szCurrentFileName,"%s\\%s%c%c%c%c%02d.",
				m_pParent->m_szSaveLoc,	
				m_pParent->m_pID,
	//			((TC.GetYear()-1990)<10)?
	//				((TC.GetYear()-1990<0)?'#':'0'+(TC.GetYear()-1990)):
	//				'A'+(TC.GetYear()-2000),
				cYear,
				((TC.GetMonth()<10)?
					'0'+(TC.GetMonth()):
					'A'+(TC.GetMonth()-10)),
				((TC.GetDay()  <10)?
					'0'+(TC.GetDay()):
					'A'+(TC.GetDay()  -10)),
				'A',0);
		}
		else
		{
			CString cResult;
			BuildFileName(cResult,
				m_pParent->m_csLongNameFormatString,
				m_pParent->m_szSaveLoc,"EO",
				m_pParent->m_pID,TC.GetYear(),TC.GetMonth(),TC.GetDay(),0,0,0,"",".");
			strcpy(m_szCurrentFileName,cResult);
		}
	}
	else
	{
		if (m_pParent->m_bUseShortFilename)
		{
			//	build new file name and save it
			char cYear;
			int iYear = TG.GetYear();
			if ((iYear < 1990) || (iYear > 2025))
				cYear = '#';
			else if (iYear < 2000)
				cYear = (char)('0' + iYear - 1990);
			else 
				cYear = (char)('A' + iYear - 2000);

			sprintf(m_szCurrentFileName,"%s\\%s%c%c%c%c%02d.",
				((CEOSSInstrument*)m_pParent)->m_szSaveLoc,	
				((CEOSSInstrument*)m_pParent)->m_pID,
				cYear,
				((TG.GetMonth()<10)?
					'0'+(TG.GetMonth()):
					'A'+(TG.GetMonth()-10)),
				((TG.GetDay()  <10)?
					'0'+(TG.GetDay()):
					'A'+(TG.GetDay()  -10)),
				'A',0);
		}
		else
		{
			CString cResult;
			BuildFileName(cResult,
				m_pParent->m_csLongNameFormatString,
				m_pParent->m_szSaveLoc,"EO",
				m_pParent->m_pID,TG.GetYear(),TG.GetMonth(),TG.GetDay(),0,0,0,"",".");
			strcpy(m_szCurrentFileName,cResult);
		}

	}	

	//format string to send
	switch (Type){

	case TYPE_DUMP:
		sprintf(Message,"%4d.%02d.%02d %02d:%02d:%02d %s\n",
			TC.GetYear(),TC.GetMonth(),TC.GetDay(),
			TC.GetHour(),TC.GetMinute(),TC.GetSecond(),
			Msg);
//		strcpy(Message,Msg);
		break;

	case TYPE_INST:
		//	message = Time::YY.MM.DD HH:MM:SS G (MESSAGE==NULL)?\r:MESSAGE

		sprintf(Message,"%04d.%02d.%02d %02d:%02d:%02d E %s\n",
			TG.GetYear(),
			TG.GetMonth(),	TG.GetDay(),
			TG.GetHour(),	TG.GetMinute(),	TG.GetSecond(),
			Msg[0]==NULL?"":Msg);
		break;

	case TYPE_COMP:
		//	message = MICTIME::YY.MM.DD HH:MM:SS C (MESSAGE==NULL)?\r:MESSAGE
		sprintf(Message,"%04d.%02d.%02d %02d:%02d:%02d C %s\n",
			TC.GetYear(),
			TC.GetMonth(),	TC.GetDay(),
			TC.GetHour(),TC.GetMinute(),TC.GetSecond(),Msg[0]==NULL?"":Msg);
		break;

	case TYPE_GID2:
	case TYPE_TIME:
		//	message = Time::YY.MM.DD HH:MM:SS EOSS Time   "+
		//					"YY.MM.DD HH:MM:SS Computer Time   C - E = xxxx\r"
		//computer time
		//EOSS time
		TS = TC - TG;  // Subtract 2 COleDateTimes
		TS += HALF_SECOND;
		sprintf(Message,"%04d.%02d.%02d %02d:%02d:%02d E 47326 EOSS Time %04d.%02d.%02d %02d:%02d:%02d Computer Time   C - E = %.0f seconds\n",
			TG.GetYear(),	TG.GetMonth(),	TG.GetDay(),
			TG.GetHour(),	TG.GetMinute(),	TG.GetSecond(),
			TC.GetYear(),	TC.GetMonth(),	TC.GetDay(),
			TC.GetHour(),	TC.GetMinute(),	TC.GetSecond(),
			TS.GetTotalSeconds());
		break;

	case TYPE_INVTIME:
		//	message = "INVALID TIME  "+
		//		"Previous Record Time Saved::YY.MM.DD HH:MM:SS "+
		//		"Current Record Time Time::YY.MM.DD HH:MM:SS\r"
		sprintf(Message,"%04d.%02d.%02d %02d:%02d:%02d I 47327 EOSS INVALID TIME %04d.%02d.%02d %02d:%02d:%02d\n",
			((CJulianTime*)Msg)->Year(),	((CJulianTime*)Msg)->Month(),	((CJulianTime*)Msg)->Day(),
			((CJulianTime*)Msg)->Hour(),		((CJulianTime*)Msg)->Minute(),	((CJulianTime*)Msg)->Second(),
			TG.GetYear(),	TG.GetMonth(),	TG.GetDay(),
			TG.GetHour(),	TG.GetMinute(),	TG.GetSecond());
		break;

	case TYPE_START:
	//  message = MICTIME::YY.MM.DD HH:MM:SS C EOSS COLLECT Version %s<VERSION> started\r"
		sprintf(Message,"%04d.%02d.%02d %02d:%02d:%02d C 47411 EOSS COLLECT Version %s started\n",
			TC.GetYear(),	TC.GetMonth(),	TC.GetDay(),
			TC.GetHour(),	TC.GetMinute(),	TC.GetSecond(),
			m_pParent->m_csVersion);
		break;

	case TYPE_ABNORMAL:
	//  message = MICTIME::YY.MM.DD HH:MM:SS C EOSS COLLECT Version %s<VERSION> started\r"
		sprintf(Message,"%04d.%02d.%02d %02d:%02d:%02d C 47412 EOSS COLLECT Version %s started from abnormal shutdown\n",
			TC.GetYear(),	TC.GetMonth(),	TC.GetDay(),
			TC.GetHour(),	TC.GetMinute(),	TC.GetSecond(),
			m_pParent->m_csVersion);
		break;

	case TYPE_DELETE:
	//	message = MICNOW::YY.MM.DD HH:MM:SS C file %s<MESSAGE> deleted\r"
		sprintf(Message,"%04d.%02d.%02d %02d:%02d:%02d C 47413 EOSS File %s deleted\n",
			TC.GetYear(),	TC.GetMonth(),	TC.GetDay(),
			TC.GetHour(),	TC.GetMinute(),	TC.GetSecond(),
			Msg);
		break;

	//just in case
	default:
		sprintf(Message,"%04d.%02d.%02d %02d:%02d:%02d C 47328 EOSS Unknown TYPE %s\n",
			TC.GetYear(),	TC.GetMonth(),	TC.GetDay(),
			TC.GetHour(),	TC.GetMinute(),	TC.GetSecond(),
			Msg);
	}

	//if to dmp do the write to todays file and get out
	if (ToWhom == TO_DMP)
	{
		//	open filename+dmp
		CString fn(m_szCurrentFileName);
		fn += DMP_SUFFIX;
//		CString ArchiveFileNameEx = ArchiveFileName + DMP_SUFFIX;
		if (_access(fn,0) != 0)
		{
//			if (_access(ArchiveFileNameEx,0)!=-1)
//				MoveFileEx(ArchiveFileNameEx,fn,
//					MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH );
			//make sure path exists
			MakeMyPath(fn);
		}

		if ((File = fopen(fn,"at+")) != NULL)
		{
			//	send string
			fprintf(File,Message);
			//	close cev
			fclose(File);
		}
		return;
	}

	//if to cev
	if (ToWhom & TO_CEV)
	{
		//	open filename+cev
		CString fn(m_szCurrentFileName);
		fn += CEV_SUFFIX;

		//if fn does not exist (it may have been moved or we have a new day)
		if (_access(fn,0) != 0)
		{
			//make sure path exists
			MakeMyPath(fn);

			if (m_pParent->m_bUseShortFilename)
			{
				//build archive path\name
				char cYear;
				int iYear = TC.GetYear();
				if ((iYear < 1990) || (iYear > 2025))
					cYear = '#';
				else if (iYear < 2000)
					cYear = (char)('0' + iYear - 1990);
				else 
					cYear = (char)('A' + iYear - 2000);

				ArchiveFileName.Format("%s\\archive\\%s%c%c%c%c%02d.%s",
				((CEOSSInstrument*)m_pParent)->m_szSaveLoc,
				((CEOSSInstrument*)m_pParent)->m_pID,
				cYear,
	//			((TC.GetYear()-1990)<10)?
	//				((TC.GetYear()-1990<0)?'#':'0'+(TC.GetYear()-1990)):
	//				'A'+(TC.GetYear()-2000),
				((TC.GetMonth()<10)?
					'0'+(TC.GetMonth()):
					'A'+(TC.GetMonth()-10)),
				((TC.GetDay()  <10)?
					'0'+(TC.GetDay()):
					'A'+(TC.GetDay()  -10)),
				'A',0,CEV_SUFFIX);
			}
			else
			{
				CString cTemp;
				cTemp = m_pParent->m_szSaveLoc;
				cTemp += "\\archive\\";
				BuildFileName(ArchiveFileName,
					m_pParent->m_csLongNameFormatString,
					cTemp,"EO",
					m_pParent->m_pID,TC.GetYear(),TC.GetMonth(),TC.GetDay(),0,0,0,"",CEV_SUFFIX);
			}

			//if it exists in the subdirectory "archive" then move it and use it
			if (_access(ArchiveFileName,0)==0)
				MoveFileEx(ArchiveFileName,fn,
					MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH );
		}

		if ((File = fopen(fn,"at+")) != NULL)
		{
			//if new file do stuff
			fseek(File,0,SEEK_END);
			fgetpos(File,&position);
			if (position==0)
			{
				m_bStartOfFile	= true;
			}

			//	send string
			fprintf(File,Message);
			//	close cev
			fclose(File);
		}
	}

	//if to pfm
	if (ToWhom & TO_PFM)
	{
		//	open filename+pfm
		CString fn(m_szCurrentFileName);
		fn += PFM_SUFFIX;

//		CString ArchiveFileNameExt = ArchiveFileName + PFM_SUFFIX;

		//if fn does not exist (it may have been moved or we have a new day)
		if (_access(fn,0) != 0)
		{
			//make sure path exists
			MakeMyPath(fn);

			//check if it is in the archive directory
			//build file name
			if (m_pParent->m_bUseShortFilename)
			{
				char cYear;
				int iYear = TC.GetYear();
				if ((iYear < 1990) || (iYear > 2025))
					cYear = '#';
				else if (iYear < 2000)
					cYear = (char)('0' + iYear - 1990);
				else 
					cYear = (char)('A' + iYear - 2000);

				ArchiveFileName.Format("%s\\archive\\%s%c%c%c%c%02d.%s",
				m_pParent->m_szSaveLoc,
				m_pParent->m_pID,
				cYear,
	//			((TC.GetYear()-1990)<10)?
	//				((TC.GetYear()-1990<0)?'#':'0'+(TC.GetYear()-1990)):
	//				'A'+(TC.GetYear()-2000),
				((TC.GetMonth()<10)?
					'0'+(TC.GetMonth()):
					'A'+(TC.GetMonth()-10)),
				((TC.GetDay()  <10)?
					'0'+(TC.GetDay()):
					'A'+(TC.GetDay()  -10)),
				'A',0,PFM_SUFFIX);
			}
			else
			{
				CString cTemp;
				cTemp = ((CEOSSInstrument*)m_pParent)->m_szSaveLoc;
				cTemp += "\\archive\\";
				BuildFileName(ArchiveFileName,
					m_pParent->m_csLongNameFormatString,
					cTemp,"EO",
					m_pParent->m_pID,TC.GetYear(),TC.GetMonth(),TC.GetDay(),0,0,0,"",PFM_SUFFIX);
			}

			//if it exists in the subdirectory "archive" then move it and use it
			if (_access(ArchiveFileName,0)==0)
				MoveFileEx(ArchiveFileName,fn,
					MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH );
		}

		if ((File = fopen(fn,"at+")) != NULL)
		{
			//if new file do stuff
			fseek(File,0,SEEK_END);
			fgetpos( File, &position );
			if (position==0)
			{
				m_bStartOfFile	= true;
			}
			//	send string
			fprintf(File,Message);
			//	close pfm
			fclose(File);
		}
	}

}
/**
 *	Generates a display string showing the relative time between the two given times as COleDateTimes
 */
CString CAppUtils::ToRelativeTimeString(COleDateTime time,COleDateTime RelativeTo)
{
	CString answer;
	COleDateTimeSpan ts = RelativeTo - time;
	//years
	if(fabs(ts.GetTotalDays()) >= 3*365)
	{
		answer = ExpandRelativeTime( (int)ts.GetTotalDays()/365, IDS_YEAR_AGO, IDS_YEARS_AGO );
	}
	//Months
	if(fabs(ts.GetTotalDays()) >= 60)
	{
		answer = ExpandRelativeTime( (int)ts.GetTotalDays()/30, IDS_MONTH_AGO, IDS_MONTHS_AGO );
		return answer;
	}
	//Weeks
	if(fabs(ts.GetTotalDays()) >= 14)
	{
		answer = ExpandRelativeTime( (int)ts.GetTotalDays()/7, IDS_WEEK_AGO, IDS_WEEKS_AGO );
		return answer;
	}
	//Days
	if(fabs(ts.GetTotalDays()) >= 2)
	{
		answer = ExpandRelativeTime( (int)ts.GetTotalDays(), IDS_DAY_AGO, IDS_DAYS_AGO );
		return answer;
	}
	//hours
	if(fabs(ts.GetTotalHours()) >= 2)
	{
		answer = ExpandRelativeTime( (int)ts.GetTotalHours(), IDS_HOUR_AGO, IDS_HOURS_AGO );
		return answer;
	}
	//minutes
	if(fabs(ts.GetTotalMinutes()) >= 2)
	{
		answer = ExpandRelativeTime( (int)ts.GetTotalMinutes(), IDS_MINUTE_AGO, IDS_MINUTES_AGO );
		return answer;
	}
	//seconds
		answer = ExpandRelativeTime( (int)ts.GetTotalSeconds(), IDS_SECOND_AGO, IDS_SECONDS_AGO );
	return answer;
}
BOOL CXTPCalendarRemindersManager::StartMonitoring(CXTPCalendarResources* pResources, COleDateTimeSpan spPeriod2Cache)
{
	if (!GetSafeHwnd())
	{
		if (!_CreateWnd())
		{
			ASSERT(FALSE);
			return FALSE;
		}
	}

	//***********************************
	if (IsMonitoringRunning())
	{
		StopMonitoring();
	}

	//***********************************
	RemoveAll();
	XTP_SAFE_CALL1(m_pResourcesNf, RemoveAll());
	m_Sink.UnadviseAll();

	//-----------------------------------
	ASSERT(pResources);
	ASSERT(CXTPCalendarUtils::GetTotalSeconds(spPeriod2Cache) > 0);

	if (!pResources || !m_pResourcesNf)
	{
		return FALSE;
	}

	DBG_REMINDERS_TRACE(_T("%s - CXTPCalendarRemindersManager::StartMonitoring(). period = %d min \n"),
						(LPCTSTR)CXTPCalendarUtils::GetCurrentTime().Format(),
						(int)spPeriod2Cache.GetTotalMinutes());

	m_pResourcesNf->Append(pResources);
	m_spPeriod2Cache = spPeriod2Cache;

	//------------------------------------
	// Advise to Data Provider notifications
	CXTPNotifyConnection* pConnRC = m_pResourcesNf->GetConnection();
	ASSERT(pConnRC);

	if (pConnRC)
	{
		m_Sink.Advise(pConnRC, XTP_NC_CALENDAREVENTWASADDED, &CXTPCalendarRemindersManager::OnEventChanged);
		m_Sink.Advise(pConnRC, XTP_NC_CALENDAREVENTWASDELETED, &CXTPCalendarRemindersManager::OnEventChanged);
		m_Sink.Advise(pConnRC, XTP_NC_CALENDAREVENTWASCHANGED, &CXTPCalendarRemindersManager::OnEventChanged);
	}
	m_pResourcesNf->ReBuildInternalData();

	//------------------------------------
	COleDateTime dtNow = CXTPCalendarUtils::GetCurrentTime();
	UpdateDataFromDP(dtNow, m_spPeriod2Cache);

	SetTimer(TIMERID_RMD_REFRESH, XTP_CALENDAR_RMD_REFRESH_TIMEOUT, NULL);

	//--------------------------------------------------------
	m_bMonitoringRunning = TRUE;
	NotifyReminders(xtpCalendarRemindersMonitoringStarted);

	return TRUE;
}
Example #30
0
void CChartAxis::CalculateTickIncrement()
{
	if (!m_bAutoTicks)
		return;

	if (m_MaxValue == m_MinValue)
	{
		m_iDTTickIntervalMult = 0;
		m_TickIncrement = 0;
		return;
	}

	int PixelSpace;
	if (m_bIsHorizontal)
	{
		if (m_AxisType == atDateTime)
			PixelSpace = 60;
		else
			PixelSpace = 30;
	}
	else
		PixelSpace = 20;

	int MaxTickNumber = (int)fabs((m_EndPos-m_StartPos)/PixelSpace * 1.0);

	//Calculate the appropriate TickSpace (1 tick every 30 pixel +/-)
	switch (m_AxisType)
	{
	case atLogarithmic:
	   m_TickIncrement = 10;
	   break;

	case atStandard:
		{
	   		//Temporary tick increment
    		double TickIncrement = (m_MaxValue-m_MinValue)/MaxTickNumber;
	    
    		// Calculate appropriate tickSpace (not rounded on 'strange values' but 
    		// on something like 1, 2 or 5*10^X  where X is optimalized for showing the most
    		// significant digits)
    		int Zeros = (int)floor(log10(TickIncrement));
    		double MinTickIncrement = pow(10.0,Zeros);
	    
    		int Digits = 0;
    		if (Zeros<0)		
    		{
				//We must set decimal places. In the other cases, Digits will be 0.
    			Digits = (int)fabs(Zeros*1.0);
    		}
	    
    		if (MinTickIncrement>=TickIncrement)
    		{
    			m_TickIncrement = MinTickIncrement;
    			SetDecimals(Digits);
    		}
    		else if (MinTickIncrement*2>=TickIncrement)
    		{
    			m_TickIncrement = MinTickIncrement*2;
    			SetDecimals(Digits);
    		}
    		else if (MinTickIncrement*5>=TickIncrement)
    		{
    			m_TickIncrement = MinTickIncrement*5;
    			SetDecimals(Digits);
    		}
    		else if (MinTickIncrement*10>=TickIncrement)
    		{
    			m_TickIncrement = MinTickIncrement*10;
    			if (Digits)
    				SetDecimals(Digits-1);
    			else
    				SetDecimals(Digits);
    		}
		}
		break;

	case atDateTime:
		{
			COleDateTime StartDate(m_MinValue);
			COleDateTime EndDate(m_MaxValue);

			COleDateTimeSpan minTickInterval = (EndDate - StartDate)/MaxTickNumber;
			double Seconds = minTickInterval.GetTotalSeconds();
			double Minutes = minTickInterval.GetTotalMinutes();
			double Hours = minTickInterval.GetTotalHours();
			double Days = minTickInterval.GetTotalDays();
			if (Seconds < 60)
			{
				m_BaseInterval = tiSecond;
				if (Seconds > 30)
				{
					m_BaseInterval = tiMinute;
					m_iDTTickIntervalMult = 1;
				}
				else if (Seconds > 10)
					m_iDTTickIntervalMult = 30;
				else if (Seconds > 5)
					m_iDTTickIntervalMult = 10;
				else if (Seconds > 2)
					m_iDTTickIntervalMult = 5;
				else 
					m_iDTTickIntervalMult = 1;
			}
			else if (Minutes < 60)
			{
				m_BaseInterval = tiMinute;
				if (Minutes > 30)
				{
					m_BaseInterval = tiHour;
					m_iDTTickIntervalMult = 1;
				}
				else if (Minutes > 10)
					m_iDTTickIntervalMult = 30;
				else if (Minutes > 5)
					m_iDTTickIntervalMult = 10;
				else if (Minutes > 2)
					m_iDTTickIntervalMult = 5;
				else 
					m_iDTTickIntervalMult = 2;
			}
			else if (Hours < 24)
			{
				m_BaseInterval = tiHour;
				if (Hours > 12)
				{
					m_BaseInterval = tiDay;
					m_iDTTickIntervalMult = 1;
				}
				else if (Hours > 6)
					m_iDTTickIntervalMult = 12;
				else if (Hours > 2)
					m_iDTTickIntervalMult = 6;
				else 
					m_iDTTickIntervalMult = 2;
			}
			else if (Days < 31)
			{
				m_BaseInterval = tiDay;
				if (Days > 7)
				{
					m_BaseInterval = tiMonth;
					m_iDTTickIntervalMult = 1;
				}
				else if (Days > 2)
				{
					m_BaseInterval = tiDay;
					m_iDTTickIntervalMult = 7;
				}
				else 
					m_iDTTickIntervalMult = 2;
			}
			else if (Days < 365)
			{
				m_BaseInterval = tiMonth;
				if (Days > 186)	 // Approx 6 months
				{
					m_BaseInterval = tiYear;
					m_iDTTickIntervalMult = 1;
				}
				else if (Days > 124)
					m_iDTTickIntervalMult = 6;
				else if (Days > 62)
					m_iDTTickIntervalMult = 4;
				else
					m_iDTTickIntervalMult = 2;
			}
			else
			{
				m_BaseInterval = tiYear;
				m_iDTTickIntervalMult = (int)Days/365 + 1;
			}

			if (m_bAutoTickFormat)
				RefreshDTTickFormat();
		}
		break;
	}
}