91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 136KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-01
  • 語言: C/C++
  • 標簽: PTP??時間同步??

資源簡介

使用PTP協議實現時間同步,精確到毫秒級

資源截圖

代碼片段和文件信息


#include?“timeProc.h“
#include?

//?創建校時開始信息
int?MakeTS_Start(char*?buf)
{
unsigned?short?tskind?=?TS_Start;

memcpy(buf?(void*)&tskind?sizeof(tskind));

return?2;
}

//?創建Sync信息
int?MakeTS_Sync(char*?buf?unsigned?short?seq)
{
unsigned?short?tskind?=?TS_Sync;
char*?bufTMP?=?buf;

memcpy(bufTMP?(void*)&tskind?sizeof(tskind));
bufTMP?+=?sizeof(tskind);
memcpy(bufTMP?(void*)&seq?sizeof(seq));?//?序號
bufTMP?+=?sizeof(seq);

return?bufTMP?-?buf;
}

//?創建FollowUp信息
int?MakeTS_FollowUp(char*?buf?unsigned?short?seq?long?long?t)
{
unsigned?short?tskind?=?TS_FollowUp;
char*?bufTMP?=?buf;

memcpy(bufTMP?(void*)&tskind?sizeof(tskind));
bufTMP?+=?sizeof(tskind);
memcpy(bufTMP?(void*)&seq?sizeof(seq));?//?序號
bufTMP?+=?sizeof(seq);
memcpy(bufTMP?(void*)&t?sizeof(t));?//?時間戳
bufTMP?+=?sizeof(t);

return?bufTMP?-?buf;
}

//?創建OK信息
int?MakeTS_OK(char*?buf?unsigned?short?seq)
{
unsigned?short?tskind?=?TS_OK;
char*?bufTMP?=?buf;

memcpy(bufTMP?(void*)&tskind?sizeof(tskind));
bufTMP?+=?sizeof(tskind);
memcpy(bufTMP?(void*)&seq?sizeof(seq));?//?序號
bufTMP?+=?sizeof(seq);

return?bufTMP?-?buf;
}

//?創建DelayReq信息
int?MakeTS_DelayReq(char*?buf)
{
unsigned?short?tskind?=?TS_DelayReq;
char*?bufTMP?=?buf;

memcpy(bufTMP?(void*)&tskind?sizeof(tskind));
bufTMP?+=?sizeof(tskind);

return?bufTMP?-?buf;
}

//?創建DelayResp信息
int?MakeTS_DelayResp(char*?buf?long?long?t)
{
unsigned?short?tskind?=?TS_DelayResp;
char*?bufTMP?=?buf;

memcpy(bufTMP?(void*)&tskind?sizeof(tskind));
bufTMP?+=?sizeof(tskind);
memcpy(bufTMP?(void*)&t?sizeof(t));?//?時間戳
bufTMP?+=?sizeof(t);

return?bufTMP?-?buf;
}

//?SYSTIME轉毫秒
long?long?SYSTime2MS(SYSTEMTIME?time)
{
tm?t;
t.tm_year?=?time.wYear?-?1900;
t.tm_mon?=?time.wMonth?-?1;
t.tm_mday?=?time.wDay;
t.tm_hour?=?time.wHour;
t.tm_min?=?time.wMinute;
t.tm_sec?=?time.wSecond;

long?long?time_ret?=?_mktime64(&t);?//?轉為1900年開始的秒數
time_ret?=?time_ret?*?1000?+?time.wMilliseconds;?//?計算毫秒

return?time_ret;
}

//?毫秒轉SYSTIME
SYSTEMTIME?MS2SYSTime(long?long?time)
{
long?long?t?=?time?/?1000;?//?轉成秒
tm*?tm_t?=?_localtime64(&t);?//?轉成1900年開始的時間

SYSTEMTIME?systime;?//?轉成systime
systime.wYear?=?tm_t->tm_year?+?1900;
systime.wMonth?=?tm_t->tm_mon?+?1;
systime.wDay?=?tm_t->tm_mday;
systime.wHour?=?tm_t->tm_hour;
systime.wMinute?=?tm_t->tm_min;
systime.wSecond?=?tm_t->tm_sec;
systime.wMilliseconds?=?time?%?1000;

return?systime;
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????2630??2015-07-23?17:12??ptp\common\src\timeProc.cpp

?????文件????????855??2015-07-23?17:12??ptp\common\src\timeProc.h

?????文件???????2032??2015-07-23?17:12??ptp\PTPClient\PTPClient\PTPClient.cpp

?????文件????????460??2015-07-23?17:12??ptp\PTPClient\PTPClient\PTPClient.h

?????文件??????10636??2015-07-23?17:12??ptp\PTPClient\PTPClient\PTPClient.rc

?????文件???????6303??2015-07-23?17:12??ptp\PTPClient\PTPClient\PTPClient.vcxproj

?????文件???????2218??2015-07-23?17:12??ptp\PTPClient\PTPClient\PTPClient.vcxproj.filters

?????文件??????12660??2015-07-24?11:04??ptp\PTPClient\PTPClient\PTPClientDlg.cpp

?????文件???????1958??2015-07-23?18:02??ptp\PTPClient\PTPClient\PTPClientDlg.h

?????文件???????3051??2015-07-23?17:12??ptp\PTPClient\PTPClient\ReadMe.txt

?????文件??????67777??2015-07-23?17:12??ptp\PTPClient\PTPClient\res\PTPClient.ico

?????文件????????674??2015-07-23?17:12??ptp\PTPClient\PTPClient\res\PTPClient.rc2

?????文件???????2100??2015-07-23?17:12??ptp\PTPClient\PTPClient\resource.h

?????文件????????142??2015-07-23?17:12??ptp\PTPClient\PTPClient\stdafx.cpp

?????文件???????1632??2015-07-23?17:12??ptp\PTPClient\PTPClient\stdafx.h

?????文件????????234??2015-07-23?17:12??ptp\PTPClient\PTPClient\targetver.h

?????文件????????894??2015-07-23?17:12??ptp\PTPClient\PTPClient.sln

?????文件???????2032??2015-07-23?17:12??ptp\PTPServer\PTPServer\PTPServer.cpp

?????文件????????460??2015-07-23?17:12??ptp\PTPServer\PTPServer\PTPServer.h

?????文件???????8778??2015-07-23?17:12??ptp\PTPServer\PTPServer\PTPServer.rc

?????文件???????6301??2015-07-23?17:12??ptp\PTPServer\PTPServer\PTPServer.vcxproj

?????文件???????2218??2015-07-23?17:12??ptp\PTPServer\PTPServer\PTPServer.vcxproj.filters

?????文件????????143??2015-07-23?17:12??ptp\PTPServer\PTPServer\PTPServer.vcxproj.user

?????文件???????6208??2015-07-24?11:04??ptp\PTPServer\PTPServer\PTPServerDlg.cpp

?????文件???????1033??2015-07-24?11:04??ptp\PTPServer\PTPServer\PTPServerDlg.h

?????文件???????3051??2015-07-23?17:12??ptp\PTPServer\PTPServer\ReadMe.txt

?????文件??????67777??2015-07-23?17:12??ptp\PTPServer\PTPServer\res\PTPServer.ico

?????文件????????674??2015-07-23?17:12??ptp\PTPServer\PTPServer\res\PTPServer.rc2

?????文件???????1180??2015-07-23?17:12??ptp\PTPServer\PTPServer\resource.h

?????文件????????142??2015-07-23?17:12??ptp\PTPServer\PTPServer\stdafx.cpp

............此處省略15個文件信息

評論

共有 條評論