96 lines
2.1 KiB
C++
96 lines
2.1 KiB
C++
|
|
// stdafx.cpp : 只包括标准包含文件的源文件
|
|
// Vcs-Client.pch 将作为预编译头
|
|
// stdafx.obj 将包含预编译类型信息
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
|
|
#define MIN_XYZ_VALUE (-999999)
|
|
float* g_xys = new float[3000 * 3000 * 2];
|
|
int g_xyz_flag = 0;
|
|
|
|
|
|
#define Q_R 1500
|
|
#define X0 1500
|
|
#define Y0 1500
|
|
|
|
inline float abs_m(float lf)
|
|
{
|
|
if (lf < 0) lf *= -1;
|
|
return lf;
|
|
}
|
|
|
|
|
|
|
|
CString g_strSavePath = "";
|
|
CString g_strCurTime = "";
|
|
|
|
void LogOutToFile(const char* fmt, ...)
|
|
{
|
|
static CRITICAL_SECTION stCritical;
|
|
static BOOL bInit = FALSE;
|
|
static CString strLogPath;
|
|
if (FALSE == bInit)
|
|
{
|
|
bInit = TRUE;
|
|
GetModuleFileName(NULL, strLogPath.GetBuffer(2048), 2047);
|
|
strLogPath.ReleaseBuffer();
|
|
strLogPath = strLogPath.Left(strLogPath.ReverseFind('\\'));
|
|
strLogPath += "\\log\\runtime.log";
|
|
|
|
InitializeCriticalSection(&stCritical);
|
|
}
|
|
|
|
EnterCriticalSection(&stCritical);
|
|
|
|
va_list ap;
|
|
va_start(ap, fmt);
|
|
char pBuffer[800] = "";
|
|
if (vsnprintf_s(pBuffer, 796, _TRUNCATE, fmt, ap) > 0)
|
|
{
|
|
|
|
if (strlen(pBuffer) == 0 || pBuffer[strlen(pBuffer) - 1] != '\n')
|
|
{
|
|
pBuffer[strlen(pBuffer) + 1] = '\0';//最后再追加一个结束符,因为原结束符需要修改为换行符
|
|
pBuffer[strlen(pBuffer)] = '\n';
|
|
}
|
|
}
|
|
va_end(ap);
|
|
|
|
TRACE("%s\n", pBuffer);
|
|
|
|
FILE* pFile = NULL;
|
|
fopen_s(&pFile, strLogPath.GetBuffer(), "ab+");
|
|
if (NULL != pFile)
|
|
{
|
|
char acTime[32] = { 0 };
|
|
SYSTEMTIME stTime;
|
|
GetLocalTime(&stTime);
|
|
sprintf_s(acTime, 32, "[%02d-%02d %02d:%02d:%02d.%03d] ", stTime.wMonth, stTime.wDay, stTime.wHour, stTime.wMinute, stTime.wSecond, stTime.wMilliseconds);
|
|
|
|
fwrite(acTime, 1, strlen(acTime), pFile);
|
|
fwrite(pBuffer, 1, strlen(pBuffer), pFile);
|
|
fwrite("\r\n", 1, strlen("\r\n"), pFile);
|
|
fclose(pFile);
|
|
}
|
|
|
|
LeaveCriticalSection(&stCritical);
|
|
}
|
|
|
|
int g_nMsgIdx = 998;
|
|
|
|
string _UnicodeToUtf8(CString Unicodestr)
|
|
{
|
|
wchar_t* unicode = Unicodestr.AllocSysString();
|
|
int len;
|
|
len = WideCharToMultiByte(CP_UTF8, 0, unicode, -1, NULL, 0, NULL, NULL);
|
|
char *szUtf8 = (char*)malloc(len + 1);
|
|
memset(szUtf8, 0, len + 1);
|
|
WideCharToMultiByte(CP_UTF8, 0, unicode, -1, szUtf8, len, NULL, NULL);
|
|
string result = szUtf8;
|
|
free(szUtf8);
|
|
return result;
|
|
}
|