本文整理汇总了C++中CTimeSpan::GetTotalSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ CTimeSpan::GetTotalSeconds方法的具体用法?C++ CTimeSpan::GetTotalSeconds怎么用?C++ CTimeSpan::GetTotalSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTimeSpan
的用法示例。
在下文中一共展示了CTimeSpan::GetTotalSeconds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckSocketStatus
/*********************************************************
函数名称:CheckSocketStatus
功能描述:检查每个Socket 将其中空的和超时的删除掉
创建时间:2016-08-19
参数说明:
返 回 值:
*********************************************************/
int CSocketServerDlg::CheckSocketStatus(void)
{
POSITION pos = m_listSocketChat.GetHeadPosition();
while(pos != NULL)
{
CChatSocket* p = m_listSocketChat.GetNext(pos);
// 删除空Socket
if(p == NULL)
{
if(pos == NULL)
{// 空Socket位于链表末尾
m_listSocketChat.RemoveTail();
break;
}
else
{
POSITION posTemp = pos;
m_listSocketChat.GetPrev(posTemp);
m_listSocketChat.RemoveAt(posTemp);
}
continue;
}
// 删除超过时间没有通信的Socket
int nMaxSec = 30; // 等待的最大时间
CTimeSpan tmsp;
tmsp = CTime::GetCurrentTime() - p->m_tmLastMsg;
TRACE("%d\n", tmsp.GetTotalSeconds());
if(tmsp.GetTotalSeconds() >= nMaxSec || tmsp.GetSeconds() < 0)
{
CString csOutMsg;
CString csID;
csID = p->m_userID;
csOutMsg.Format(_T("用户%s连接超时"), csID);
OutputInfo(csOutMsg);
m_data.SetUserStatus(p->m_userID, IDS_STATUS_OFFLINE);
p->Close(); // 关闭连接
delete p; // 释放内存
// 删除元素
if(pos == NULL)
{// 空Socket位于链表末尾
m_listSocketChat.RemoveTail();
break;
}
else
{
POSITION posTemp = pos;
m_listSocketChat.GetPrev(posTemp);
m_listSocketChat.RemoveAt(posTemp);
}
continue;
}
}
return 0;
}
示例2:
void CMainFrame::OnTimer
(
UINT nIDEvent
)
{
CTimeSpan timeLeft = 0;
LONG minLeft = 0;
LONG secLeft = 0;
CMainFrame *hWnd = NULL;
char *szSubj = NULL;
log_printf("CMainFrame::OnTimer: entered.\n");
//#if 0 ///////////////////////////////////////////////////////
hWnd = (CMainFrame *)theApp.m_pMainWnd;
get_cert_time_left(szCertRealm, &timeLeft); // returns 0 if no realm or cert
minLeft = timeLeft.GetTotalMinutes();
// Set TrayIcon to reflect status of cert (if any)
if (minLeft >= CERT_DYING)
hWnd->m_trayIcon.ChangeSysTrayIcon(IDI_AUTH);
else
{
if (minLeft < CERT_DYING)
{
szSubj = get_cert_subj(szCertRealm);
// If null Subject, then no cert exists so change to Un-authenticated Icon
if (!szSubj)
hWnd->m_trayIcon.ChangeSysTrayIcon(IDI_UNAUTH);
else
{
// Alternate TrayIcons 'tween DEAD & DYING
secLeft = (int)timeLeft.GetTotalSeconds();
if ((secLeft % 2))
hWnd->m_trayIcon.ChangeSysTrayIcon(IDI_DEAD);
else
hWnd->m_trayIcon.ChangeSysTrayIcon(IDI_AUTH);
free(szSubj);
}
}
else
hWnd->m_trayIcon.ChangeSysTrayIcon(IDI_DEAD);
log_printf("CMainFrame::OnTimer: gszHardErrorMsg=%s.\n", gszHardErrorMsg);
if (bkx509busy == FALSE)
{
bkx509busy = TRUE;
kx509_main(kx509_argc, kx509_argv);
bkx509busy = FALSE;
}
}
//#endif // 0 //////////////////////////////////////////////////////////////////
// Do above check every 5 seconds
(void)SetTimer(ID_SAMPLE_RATE, 5*1000, NULL);
CFrameWnd::OnTimer(nIDEvent);
}
示例3: setTimer
static void setTimer(CTime &t)
{
CTime cur = CTime::GetCurrentTime();
if (t >= cur) {
KillTimer(NULL, timerID);
CTimeSpan span = t - cur;
timerID = SetTimer(NULL, 0, span.GetTotalSeconds() * 1000, onTimer);
}
}
示例4: TimerAfterBidProc
void CALLBACK CAuctionServerDoc::TimerAfterBidProc(void* p)
{
CTime lastTxTime = GetRecentTransactionTime(m_dwAuctionID);
CTime now = CTime::GetCurrentTime();
CTimeSpan ts = now - lastTxTime;
TRACE(L"\nDiff of Tx = %I64d\n", ts.GetTotalSeconds() );
CBroadcastState state;
if (ts.GetTotalSeconds() > WAITINGTIME)
{
state.SetState(E_NONE);
}
else
{
state.SetState(E_AUCTION);
}
BroadcastBuffer(state);
}
示例5: GetLeftDate
//006bc300
unsigned long CPeriodItemEx::GetLeftDate(long lExpireDate) //OK
{
unsigned long dwReturnValue = 0;
CTime tExpireTime(lExpireDate);
CTime tCurrentTime(CTime::GetTickCount());
CTimeSpan tSpanTime;
tSpanTime = tExpireTime - tCurrentTime;
dwReturnValue = tSpanTime.GetTotalSeconds();
return dwReturnValue;
}
示例6: GetRunningTime
//此函数暂时不使用
CString CMainFrame::GetRunningTime()
{
CTimeSpan tSpan;
tSpan = CTime::GetCurrentTime() - m_StartTime;
LONGLONG totalSeconds = tSpan.GetTotalSeconds();
LONGLONG totalMinutes = tSpan.GetTotalMinutes();
LONGLONG totalHours = tSpan.GetTotalHours();
CString strRet="";
strRet.Format("%d天%02d时%02d分%02d秒",totalHours / 24,totalHours % 24,totalMinutes % 60,totalSeconds % 60);
return strRet;
}
示例7: l_FileListCompare
/*===========================================================================
*
* Function - int l_FileListCompare (lParam1, lParam2, lParamSort);
*
*=========================================================================*/
int CALLBACK l_FileListCompare (LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) {
srloaddlgfileinfo_t* pData1 = (srloaddlgfileinfo_t *) lParam1;
srloaddlgfileinfo_t* pData2 = (srloaddlgfileinfo_t *) lParam2;
srloadfilesortinfo_t* pSortData = (srloadfilesortinfo_t *) lParamSort;
int Result = 0;
if (pData1 == NULL || pData2 == NULL || pSortData == NULL) return (0);
switch (pSortData->SortType) {
case SRFILELIST_FILENAME:
Result = _tcsicmp(pData2->FindData.cFileName, pData1->FindData.cFileName);
break;
case SRFILELIST_DATE: {
CTime Time1(pData1->FindData.ftLastWriteTime);
CTime Time2(pData2->FindData.ftLastWriteTime);
CTimeSpan TimeDiff = Time2 - Time1;
Result = (int)(TimeDiff.GetTotalSeconds());
break; }
case SRFILELIST_SIZE:
Result = pData2->FindData.nFileSizeHigh - pData1->FindData.nFileSizeHigh;
if (Result == 0) Result = pData1->FindData.nFileSizeLow - pData2->FindData.nFileSizeLow;
break;
case SRFILELIST_DEFAULTSORT: {
if (pData1->IsMaster != pData2->IsMaster) {
Result = pData2->IsMaster - pData1->IsMaster;
}
else {
CTime Time1(pData1->FindData.ftLastWriteTime);
CTime Time2(pData2->FindData.ftLastWriteTime);
CTimeSpan TimeDiff = Time2 - Time1;
Result = (int) (TimeDiff.GetTotalSeconds());
}
break; }
}
if (pSortData->Reverse) return (-Result);
return (Result);
}
示例8: PaintHost
void CActivityView::PaintHost(CBrother *b,CDC *pDC,CRect& rc,CTime *bTime,CTimeSpan *tSpan)
{
ASSERT(b);
if(b->m_Log.IsEmpty())
return;
CBigBrotherDoc* pDoc = (CBigBrotherDoc*)GetDocument();
ASSERT(pDoc);
ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CBigBrotherDoc)));
ULONG rttMax = b->m_TimeOut;
CTime beginTime;
CTimeSpan ts;
if(bTime && tSpan){
beginTime= *bTime;
ts = *tSpan;
}else{
beginTime = b->m_Log.GetHead()->m_Time;
CTime endTime = b->m_Log.GetTail()->m_Time;
ts = endTime-beginTime;
if(ts<pDoc->m_MaxLogTime)
ts = pDoc->m_MaxLogTime;
}
POSITION p = b->m_Log.GetHeadPosition();
ASSERT(p);
CLogEntry *le = b->m_Log.GetNext(p);
ASSERT(le);
int x = rc.left+(le->m_Time-beginTime).GetTotalSeconds()*rc.Width()/ts.GetTotalSeconds();
while(p){
le = b->m_Log.GetNext(p);
ASSERT(le);
int newx=rc.left+(le->m_Time-beginTime).GetTotalSeconds()*rc.Width()/ts.GetTotalSeconds();
if(!(le->flags&CLogEntry::flagsSeparator)){
UINT size = le->m_bReached?min(rttMax,le->m_RTT):rttMax;
int drawSize=(rttMax-size)*rc.Height()/rttMax;
COLORREF color=le->m_bReached?((size<(rttMax/3))?m_Green:((size<(rttMax*2/3))?m_Yellow:m_Red)):m_Dim;
pDC->FillSolidRect(x,rc.bottom-drawSize,newx-x,drawSize,color);
}
x=newx;
}
}
示例9: OnTimer
void SaveBinaryNoParsingDlg::OnTimer(UINT_PTR nIDEvent)
{
char drive[3] = {0};
drive[0] = filePath[0];
drive[1] = filePath[1];
CTimeSpan ts = CTime::GetCurrentTime() - startTime;
ShowDuration(ts, IDC_DURATION);
ShowSize(buffer.totalWriteSize, IDC_TOTAL_SIZE);
ULARGE_INTEGER p1;
if(GetDiskFreeSpaceEx(drive, &p1, NULL, NULL))
{
ShowSize(p1.QuadPart, IDC_TOTAL_FREE);
if(ts.GetTotalSeconds() > 5 && buffer.totalWriteSize > 0)
{
int estSec = (int)(p1.QuadPart / (buffer.totalWriteSize / ts.GetTotalSeconds()));
//IDC_EST_TIME
CTimeSpan estTs(0, 0, 0, estSec);
ShowDuration(estTs, IDC_EST_TIME);
}
}
if(buffer.alreadyAck)
{
GetDlgItem(IDC_PROMPT)->SetWindowText("HostLog starts.");
}
else
{
if(--noAckAlerm == 0)
{
KillTimer(DisplayInfoTimerId);
::AfxMessageBox("HostLog restart timeout!");
SetTimer(DisplayInfoTimerId, 1000, NULL);
}
}
CDialog::OnTimer(nIDEvent);
}
示例10: l_SortLoadInfosByDate
/*===========================================================================
*
* Function - int l_SortLoadInfosByDate (lParam1, lParam2, lParamSort);
*
*=========================================================================*/
int __stdcall l_SortLoadInfosByDate (long lParam1, long lParam2, long lParamSort)
{
srloaddlgfileinfo_t* pFileInfo1 = (srloaddlgfileinfo_t *) lParam1;
srloaddlgfileinfo_t* pFileInfo2 = (srloaddlgfileinfo_t *) lParam2;
/* Special case for Skyrim.esm to ensure it is loaded first */
if (stricmp(pFileInfo1->FindData.cFileName, "Skyrim.esm") == 0) return -1;
if (stricmp(pFileInfo2->FindData.cFileName, "Skyrim.esm") == 0) return 1;
if (pFileInfo1 == NULL || pFileInfo2 == NULL) return (0);
CTime Time1(pFileInfo1->FindData.ftLastWriteTime);
CTime Time2(pFileInfo2->FindData.ftLastWriteTime);
CTimeSpan TimeDiff = Time1 - Time2;
return(int) TimeDiff.GetTotalSeconds();
}
示例11: Send
//sends a message, or part of one
int CPassiveSock::Send(const void * const lpBuf, const int Len)
{
WSAOVERLAPPED os;
WSABUF buffers[2];
WSAEVENT hEvents[2] = {NULL,NULL};
DWORD
dwWait,
bytes_sent=0,
msg_flags = 0;
// Setup up the events to wait on
hEvents[1] = write_event;
hEvents[0] = m_hStopEvent;
// Setup the buffers array
buffers[0].buf = (char *)lpBuf;
buffers[0].len = Len;
msg_flags = 0;
dwWait = 0;
int rc;
LastError = 0;
// Create the overlapped I/O event and structures
memset(&os, 0, sizeof(OVERLAPPED));
os.hEvent = write_event;
WSAResetEvent(read_event);
rc = WSASend(ActualSocket, buffers, 1, &bytes_sent, 0, &os, NULL);
LastError=WSAGetLastError();
if ((rc == SOCKET_ERROR) && (LastError == WSA_IO_PENDING)) // Write in progress
{
CTimeSpan TimeLeft = SendEndTime - CTime::GetCurrentTime();
dwWait = WaitForMultipleObjects(2, hEvents, false, (DWORD)TimeLeft.GetTotalSeconds()*1000);
if (dwWait == WAIT_OBJECT_0+1) // I/O completed
{
if (WSAGetOverlappedResult(ActualSocket, &os, &bytes_sent, true, &msg_flags))
return bytes_sent;
}
}
else if (!rc) // if rc is zero, the read was completed immediately
{
if (WSAGetOverlappedResult(ActualSocket, &os, &bytes_sent, true, &msg_flags))
return bytes_sent;
}
return SOCKET_ERROR;
}
示例12: OnLoad
void CXfilterDlg::OnLoad()
{
IpFilterDriver.init(IP_FILTER_DRIVER_NAME, FILE_ATTRIBUTE_NORMAL);
CString s;
CTime time = CTime::GetCurrentTime();
CTimeSpan ts;
CTime t(0);
ts = time - t;
s.Format("CurrentTime: %u, %s DayCount:%u, TotalSec:%u, Week: %u\n"
, CTime::GetCurrentTime().GetTime()
, time.Format("%Y-%m-%d %H:%M:%S")
, ts.GetDays()
, ts.GetTotalSeconds()
, time.GetDayOfWeek());
// OutputDebugString(s);
if (IpFilterDriver.getError() != NO_ERROR)
AfxMessageBox(_T("Can't load IpFilter Driver"));
}
示例13: stopFlightExperiment
void CLeftView::stopFlightExperiment(void)
{
char command[2];
__int16 *c = (__int16 *)command;
c[0] = TFT_STOPTASK;
CNetCln* cln = ((CGTApp*)AfxGetApp())->getCln();
cln->SendSvr(command, sizeof(command));
// Update...
endTime = CTime::GetCurrentTime();
CTimeSpan tof = endTime - startTime;
ed.tof = tof.GetTotalSeconds();
// Force to serialize
serialize(TRUE);
((CMainFrame*)AfxGetMainWnd())->enableMenuItems(TRUE);
}
示例14: ReceiveFrame
int CPacket::ReceiveFrame(CSerialPort &port)
{
char c=0;
strData.Empty();
do
{
int n=port.Read(&c,1);
if (n<0)
return -1;
else if(n==0)
return 0;
}while(c != STX);
strData+=c;
CTime start = CTime::GetCurrentTime();
CTime now;
CTimeSpan pause;
do
{
int n = port.Read(&c,1);
if (n<0)
return -1;
else if (n)
{
start = CTime::GetCurrentTime();
strData+=c;
}
now = CTime::GetCurrentTime();
pause = now - start;
if (pause.GetTotalSeconds() > 5)
{
strData.Empty();
return 0;
}
}while(c!=ETX);
return strData.GetLength();
}
示例15: UpdateDuration
void CAddTimer::UpdateDuration()
{
CTimeSpan aday(1,0,0,0);
CTimeSpan tempduration;
CTime end, start;
UpdateData(TRUE);
//m_endtime.GetTime(end);
//m_starttime.GetTime(start);
end = m_endtimex;
start = m_starttimex;
if (end < start) end += aday;
tempduration = end - start;
//Only enable ok button if duration is greater than 0
if((tempduration.GetTotalSeconds() > 0) && (m_channellist.GetCurSel() != LB_ERR)){
m_ok.EnableWindow(TRUE);
}else{
m_ok.EnableWindow(FALSE);
}
CString temp;
if(tempduration.GetHours()>0) temp += tempduration.Format("%Hhr");
if(tempduration.GetMinutes()>0) temp += tempduration.Format("%Mmin");
//temp += duration.Format("%Ssec");
m_duration = temp;
//Get programme name from guide
CProgGuideDlg pgdlg(NULL,NULL);
m_progname = pgdlg.getProg(m_channellist.GetCurSel(),m_starttimex);
UpdateData(FALSE);
}