📄 testicanglobal.cpp
字号:
// TestICANGlobal.cpp: implementation of the CTestICANGlobal class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "testicandll.h"
#include "TestICANGlobal.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
#define SEC_CFG "CONFIG"
#define KEY_SYSCFG "syscfg"
CTestICANGlobal::CTestICANGlobal()
{
}
CTestICANGlobal::~CTestICANGlobal()
{
}
void CTestICANGlobal::Init()
{
m_syscfg.routecfg.iCardType=VCI_PCI9820;
m_syscfg.routecfg.iCardInd=0;
m_syscfg.routecfg.iCANInd=0;
m_syscfg.routecfg.wCANBaud=0x001c;
m_syscfg.routecfg.wMasterID=0;
m_syscfg.routecfg.iMasterCycle=500;
CString str;
GetModuleFileName(NULL,str.GetBuffer(MAX_PATH),MAX_PATH);
str.ReleaseBuffer();
str=str.Left(str.ReverseFind('\\')+1);
str+="set.ini";
m_ini.SetIni((LPTSTR)(LPCTSTR)str);
char sztmp[1024];
if(m_ini.Read(SEC_CFG,KEY_SYSCFG,sztmp,1024)==1)
{
STRTOCFG(sztmp,m_syscfg);
}
ROUTECFG cfg;
cfg.iCardType=m_syscfg.routecfg.iCardType;
cfg.iCardInd=m_syscfg.routecfg.iCardInd;
cfg.iCANInd=m_syscfg.routecfg.iCANInd;
cfg.wCANBaud=m_syscfg.routecfg.wCANBaud;
cfg.iMasterCycle=m_syscfg.routecfg.iMasterCycle;
cfg.wMasterID=m_syscfg.routecfg.wMasterID;
Mgr_AddRoute(cfg,&m_hRoute);
}
void CTestICANGlobal::Uninit()
{
char sztmp[1024];
CFGTOSTR(m_syscfg,sztmp);
m_ini.Write(SEC_CFG,KEY_SYSCFG,sztmp);
}
int CTestICANGlobal::GetCANCount(int devtype)
{
switch(devtype)
{
case VCI_PC104CAN:
case VCI_PCI9810:
return 1;
break;
case VCI_PCI9820:
case VCI_USBCAN2:
case VCI_PCI5121:
return 2;
break;
case VCI_PCI9840:
return 4;
break;
default:
return 0;
}
}
CString CTestICANGlobal::DatatoStr(BYTE *pdata, int len)
{
CString strtmp;
CString str1;
for(int i=0;i<len;i++)
{
str1.Format("%02X ",pdata[i]);
strtmp+=str1;
}
return strtmp;
}
SYSTEMTIME CTestICANGlobal::GetTime()
{
SYSTEMTIME systime;
FILETIME filetime,filetime1;
GetSystemTimeAsFileTime(&filetime);
FileTimeToLocalFileTime(&filetime,&filetime1);
FileTimeToSystemTime(&filetime1,&systime);
return systime;
}
CString CTestICANGlobal::ConvertTimeToStr(SYSTEMTIME tm)
{
CString str;
str.Format("%02d:%02d:%02d.%03d",tm.wHour,
tm.wMinute,
tm.wSecond, tm.wMilliseconds);
return str;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -