添加项目文件。
This commit is contained in:
		
							
								
								
									
										433
									
								
								Plugin/Driver/CEXMemFileQueue.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										433
									
								
								Plugin/Driver/CEXMemFileQueue.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,433 @@ | ||||
| #include "stdafx.h" | ||||
| #include "CEXMemFileQueue.h" | ||||
| #include <sys/timeb.h> | ||||
| #include <iostream> | ||||
| #include <iomanip> | ||||
| #include <sstream> | ||||
| #include <windows.h> | ||||
| #include <algorithm> | ||||
| #include <codecvt> | ||||
| #include <regex> | ||||
| #include <string> | ||||
|  | ||||
|  | ||||
| // <20><>ȡ<EFBFBD><C8A1>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>YYYYMMDDhhmmssSSS | ||||
| std::string formatTimeAsString(int lIndexEx)  | ||||
| { | ||||
| 	SYSTEMTIME st; | ||||
| 	GetLocalTime(&st); | ||||
| 	std::ostringstream oss; | ||||
| 	// <20><><EFBFBD><EFBFBD> | ||||
| 	oss << std::setw(4) << std::setfill('0') << (st.wYear % 10000); | ||||
| 	// <20>·ݺ<C2B7><DDBA><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	oss << std::setw(2) << std::setfill('0') << st.wMonth; | ||||
| 	oss << std::setw(2) << std::setfill('0') << st.wDay; | ||||
| 	// Сʱ<D0A1><CAB1><EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD><D3BA><EFBFBD> | ||||
| 	oss << std::setw(2) << std::setfill('0') << st.wHour; | ||||
| 	oss << std::setw(2) << std::setfill('0') << st.wMinute; | ||||
| 	oss << std::setw(2) << std::setfill('0') << st.wSecond; | ||||
| 	//__timeb64 tb; | ||||
| 	//_ftime64_s(&tb); // <20><>ȡ<EFBFBD><C8A1>ǰʱ<C7B0>䣬<EFBFBD><E4A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	//oss << std::setw(3) << std::setfill('0') << tb.millitm; // <20><><EFBFBD>룬<EFBFBD><EBA3AC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>ǰ<EFBFBD>油<EFBFBD><E6B2B9> | ||||
| 	oss << std::setw(6) << std::setfill('0') << lIndexEx; // <20><>ֹ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	return oss.str(); | ||||
| } | ||||
|  | ||||
| //<2F><>ȡһ<C8A1><D2BB>ָ<EFBFBD><D6B8>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> lType<70><65>ʾ<EFBFBD><CABE>ȡ<EFBFBD><C8A1><EFBFBD>ͣ<EFBFBD>1<EFBFBD><31><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>2<EFBFBD><32><EFBFBD>ļ<EFBFBD><C4BC>У<EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD> | ||||
| static void traverse_directory_ansi(const char* directory_path, std::vector<std::string>& files, int lType)  | ||||
| { | ||||
| 	char search_path[MAX_PATH]; | ||||
| 	strcpy_s(search_path, directory_path); | ||||
| 	strcat_s(search_path, "\\*"); | ||||
|  | ||||
| 	WIN32_FIND_DATAA find_data; | ||||
| 	HANDLE hFind = FindFirstFileA(search_path, &find_data); | ||||
|  | ||||
| 	if (hFind == INVALID_HANDLE_VALUE)  | ||||
| 	{ | ||||
| 		std::cerr << "Failed to open directory: " << directory_path << std::endl; | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	do  | ||||
| 	{ | ||||
| 		if (strcmp(find_data.cFileName, ".") == 0 || strcmp(find_data.cFileName, "..") == 0)  | ||||
| 		{ | ||||
| 			continue; | ||||
| 		} | ||||
|  | ||||
| 		char full_path[MAX_PATH]; | ||||
| 		strcpy_s(full_path, directory_path); | ||||
| 		strcat_s(full_path, "\\"); | ||||
| 		strcat_s(full_path, find_data.cFileName); | ||||
|  | ||||
| 		if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)  | ||||
| 		{ | ||||
| 			//<2F>ݲ<EFBFBD>֧<EFBFBD>ֵݹ<D6B5><DDB9><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> | ||||
| 			if (1 != lType) files.push_back(find_data.cFileName); | ||||
| 		} | ||||
| 		else  | ||||
| 		{ | ||||
| 			if (2 != lType) files.push_back(find_data.cFileName); | ||||
| 		} | ||||
| 	} while (FindNextFileA(hFind, &find_data) != 0); | ||||
|  | ||||
| 	FindClose(hFind); | ||||
|  | ||||
| 	// <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	std::sort(files.begin(), files.end()); | ||||
| } | ||||
|  | ||||
| CEXMemFileQueue::CEXMemFileQueue(std::string strDataDir) | ||||
| { | ||||
| 	m_strBaseDir = strDataDir; | ||||
| 	m_pWriteFileItem = NULL; | ||||
| 	m_pReadFileItem = NULL; | ||||
| 	m_lReadIndex = 0; | ||||
| 	m_lItemCount = 0; | ||||
| 	InitializeCriticalSection(&m_cs); | ||||
|  | ||||
| 	SYSTEMTIME stTime; | ||||
| 	GetLocalTime(&stTime); | ||||
| 	ChangeDataDate(stTime); | ||||
| } | ||||
|  | ||||
| CEXMemFileQueue::~CEXMemFileQueue() | ||||
| { | ||||
| 	for (int i = 0; i < (int)m_vecFile.size(); i++) | ||||
| 	{ | ||||
| 		delete m_vecFile[i]; | ||||
| 	} | ||||
| 	m_vecFile.clear(); | ||||
| } | ||||
|  | ||||
|  | ||||
| int CEXMemFileQueue::GetItemCount() | ||||
| { | ||||
| 	return m_lItemCount; | ||||
| } | ||||
|  | ||||
| int CEXMemFileQueue::GetAutoSn() | ||||
| { | ||||
| 	ThreadLock stLock(&m_cs); | ||||
| 	m_lAutoSn++; | ||||
| 	return m_lAutoSn; | ||||
| } | ||||
|  | ||||
| int CEXMemFileQueue::ReadItem(void* pData, int lIndex /* = -1 */) | ||||
| { | ||||
| 	ThreadLock stLock(&m_cs); | ||||
| 	if (lIndex > m_lItemCount) | ||||
| 	{ | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	if (lIndex >= 0) | ||||
| 	{ | ||||
| 		m_lReadIndex = lIndex; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		m_lReadIndex++; | ||||
| 	} | ||||
|  | ||||
| 	if (m_lReadIndex >= m_lItemCount) | ||||
| 	{ | ||||
| 		return -1;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	} | ||||
|  | ||||
| 	if (NULL == m_pReadFileItem || m_lReadIndex < m_pReadFileItem->lBeindIndex || m_lReadIndex > m_pReadFileItem->lEndIndex) | ||||
| 	{ | ||||
| 		m_pReadFileItem = NULL; | ||||
| 		//<2F><><EFBFBD><EFBFBD>Ѱ<EFBFBD><D1B0> | ||||
| 		for (int i = 0; i < (int)m_vecFile.size(); i++) | ||||
| 		{ | ||||
| 			if (m_lReadIndex >= m_vecFile[i]->lBeindIndex && m_lReadIndex <= m_vecFile[i]->lEndIndex) | ||||
| 			{ | ||||
| 				m_pReadFileItem = m_vecFile[i]; | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if (NULL == m_pReadFileItem) | ||||
| 	{ | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	memcpy(pData, (char*)m_pReadFileItem->pBuf + DATA_FIRST_LINE_SIZE + DATA_LINE_SIZE *(m_lReadIndex- m_pReadFileItem->lBeindIndex), DATA_LINE_SIZE); | ||||
|  | ||||
| 	return m_lReadIndex; | ||||
| } | ||||
|  | ||||
| void CEXMemFileQueue::FlushWriteFile() | ||||
| { | ||||
| 	ThreadLock stLock(&m_cs); | ||||
| 	if (NULL != m_pWriteFileItem) | ||||
| 	{ | ||||
| 		char acFirstLine[DATA_FIRST_LINE_SIZE+1] = { 0 }; | ||||
| 		sprintf_s(acFirstLine, "%-15d\n", m_pWriteFileItem->lFileSize); | ||||
| 		memcpy((char*)m_pWriteFileItem->pBuf, acFirstLine, DATA_FIRST_LINE_SIZE); | ||||
|  | ||||
| 		FlushViewOfFile(m_pWriteFileItem->pBuf, m_pWriteFileItem->lFileSize); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| int CEXMemFileQueue::WriteItem(void* pData) | ||||
| { | ||||
| 	ThreadLock stLock(&m_cs); | ||||
| 	//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	SYSTEMTIME stDate; | ||||
| 	GetLocalTime(&stDate); | ||||
| 	if (stDate.wYear != m_stDataDate.wYear || stDate.wMonth != m_stDataDate.wMonth || stDate.wDay != m_stDataDate.wDay) | ||||
| 	{ | ||||
| 		AutoCleanData(5); | ||||
| 		ChangeDataDate(stDate); | ||||
| 	} | ||||
| 	if (m_pWriteFileItem == NULL || m_pWriteFileItem->lFileSize + DATA_LINE_SIZE > DATA_FILE_SIZE) | ||||
| 	{ | ||||
| 		if (m_pWriteFileItem != NULL) | ||||
| 		{ | ||||
| 			m_pWriteFileItem->lEndIndex = m_lItemCount-1; | ||||
| 			FlushWriteFile(); | ||||
| 		} | ||||
| 		m_pWriteFileItem = new CEX_QUEUE_FILE_ITEM; | ||||
| 		m_pWriteFileItem->lBeindIndex = m_lItemCount; | ||||
|  | ||||
| 		m_pWriteFileItem->strFileName = m_strDataDir + "\\" + formatTimeAsString((int)m_vecFile.size()) + ".txt";; | ||||
|  | ||||
| 		// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>д<EFBFBD><EFBFBD><CDB9><EFBFBD> | ||||
| 		m_pWriteFileItem->hFile = CreateFileA( | ||||
| 			m_pWriteFileItem->strFileName.c_str(), | ||||
| 			GENERIC_READ | GENERIC_WRITE, | ||||
| 			FILE_SHARE_READ | FILE_SHARE_WRITE, | ||||
| 			nullptr, | ||||
| 			CREATE_ALWAYS, | ||||
| 			FILE_ATTRIBUTE_NORMAL, | ||||
| 			nullptr | ||||
| 		); | ||||
|  | ||||
| 		if (m_pWriteFileItem->hFile == INVALID_HANDLE_VALUE) | ||||
| 		{ | ||||
| 			TRACE("CreateFile failed\r\n"); | ||||
| 			delete m_pWriteFileItem; | ||||
| 			m_pWriteFileItem = NULL; | ||||
| 			return -1; | ||||
| 		} | ||||
|  | ||||
| 		// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>------<2D><>һ<EFBFBD>й̶<D0B9>ռ<EFBFBD><D5BC>16<31>ֽڼ<D6BD>¼<EFBFBD>ļ<EFBFBD>ʵ<EFBFBD>ʴ<EFBFBD>С | ||||
| 		m_pWriteFileItem->hMapFile = CreateFileMappingA(m_pWriteFileItem->hFile,nullptr,PAGE_READWRITE,	0,DATA_FILE_SIZE+16,nullptr); | ||||
| 		if (m_pWriteFileItem->hMapFile == nullptr)  | ||||
| 		{ | ||||
| 			TRACE("CreateFileMapping failed\r\n"); | ||||
| 			delete m_pWriteFileItem; | ||||
| 			m_pWriteFileItem = NULL; | ||||
| 			return -2; | ||||
| 		} | ||||
|  | ||||
| 		// <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>䵽<EFBFBD><E4B5BD><EFBFBD>̵ĵ<CCB5>ַ<EFBFBD>ռ<EFBFBD> | ||||
| 		m_pWriteFileItem->pBuf = MapViewOfFile(	m_pWriteFileItem->hMapFile,FILE_MAP_ALL_ACCESS,0,	0,DATA_FILE_SIZE+16); | ||||
| 		if (m_pWriteFileItem->pBuf == nullptr) | ||||
| 		{ | ||||
| 			TRACE("MapViewOfFile failed\r\n"); | ||||
| 			delete m_pWriteFileItem; | ||||
| 			m_pWriteFileItem = NULL; | ||||
| 			return -3; | ||||
| 		} | ||||
| 		FlushWriteFile();//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD>һ<EFBFBD>£<EFBFBD>д<EFBFBD><D0B4><EFBFBD>ļ<EFBFBD>ͷ | ||||
| 		m_vecFile.push_back(m_pWriteFileItem); | ||||
| 	} | ||||
|  | ||||
| 	//д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	memcpy((char*)m_pWriteFileItem->pBuf + m_pWriteFileItem->lFileSize, pData, DATA_LINE_SIZE); | ||||
| 	m_pWriteFileItem->lFileSize += DATA_LINE_SIZE; | ||||
| 	m_pWriteFileItem->lEndIndex = m_lItemCount; | ||||
| 	m_lItemCount++; | ||||
|  | ||||
| 	//ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD> | ||||
| 	char acFirstLine[DATA_FIRST_LINE_SIZE + 1] = { 0 }; | ||||
| 	sprintf_s(acFirstLine, "%-15d\n", m_pWriteFileItem->lFileSize); | ||||
| 	memcpy((char*)m_pWriteFileItem->pBuf, acFirstLine, DATA_FIRST_LINE_SIZE); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| //<2F>л<EFBFBD><D0BB><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD> | ||||
| void CEXMemFileQueue::ChangeDataDate(SYSTEMTIME stDate) | ||||
| { | ||||
| 	ThreadLock stLock(&m_cs); | ||||
| 	//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD> | ||||
| 	FlushWriteFile(); | ||||
| 	m_pReadFileItem = NULL; | ||||
| 	m_pWriteFileItem = NULL; | ||||
| 	for (int i = 0; i < (int)m_vecFile.size(); i++) | ||||
| 	{ | ||||
| 		delete m_vecFile[i]; | ||||
| 	} | ||||
| 	m_vecFile.clear(); | ||||
| 	m_lItemCount = 0; | ||||
|  | ||||
| 	//<2F><><EFBFBD><EFBFBD>·<EFBFBD><C2B7> | ||||
| 	m_stDataDate = stDate; | ||||
| 	char acDate[32] = { 0 }; | ||||
| 	sprintf_s(acDate, "%04d-%02d-%02d", m_stDataDate.wYear, m_stDataDate.wMonth, m_stDataDate.wDay); | ||||
| 	m_strDataDir = m_strBaseDir + "\\" + acDate; | ||||
| 	CreateDirectory(m_strDataDir.c_str(), NULL); | ||||
|  | ||||
| 	//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>У<EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	std::vector<std::string> files; | ||||
| 	traverse_directory_ansi(m_strDataDir.c_str(), files, 1); | ||||
| 	for (int i = 0; i < (int)files.size(); i++) | ||||
| 	{ | ||||
| 		CEX_QUEUE_FILE_ITEM* pTempItem = new CEX_QUEUE_FILE_ITEM; | ||||
| 		pTempItem->lBeindIndex = m_lItemCount; | ||||
|  | ||||
| 		pTempItem->strFileName = m_strDataDir + "\\" + files[i]; | ||||
|  | ||||
| 		// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>д<EFBFBD><EFBFBD><CDB9><EFBFBD> | ||||
| 		pTempItem->hFile = CreateFileA( | ||||
| 			pTempItem->strFileName.c_str(), | ||||
| 			GENERIC_READ | GENERIC_WRITE, | ||||
| 			FILE_SHARE_READ | FILE_SHARE_WRITE, | ||||
| 			nullptr, | ||||
| 			OPEN_EXISTING, | ||||
| 			FILE_ATTRIBUTE_NORMAL, | ||||
| 			nullptr | ||||
| 		); | ||||
|  | ||||
| 		if (pTempItem->hFile == INVALID_HANDLE_VALUE) | ||||
| 		{ | ||||
| 			TRACE("CreateFile failed\r\n"); | ||||
| 			delete pTempItem; | ||||
| 			pTempItem = NULL; | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
| 		// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>------<2D><>һ<EFBFBD>й̶<D0B9>ռ<EFBFBD><D5BC>16<31>ֽڼ<D6BD>¼<EFBFBD>ļ<EFBFBD>ʵ<EFBFBD>ʴ<EFBFBD>С | ||||
| 		pTempItem->hMapFile = CreateFileMappingA(pTempItem->hFile, nullptr, PAGE_READWRITE, 0, DATA_FILE_SIZE + 16, nullptr); | ||||
| 		if (pTempItem->hMapFile == nullptr) | ||||
| 		{ | ||||
| 			TRACE("CreateFileMapping failed\r\n"); | ||||
| 			delete pTempItem; | ||||
| 			pTempItem = NULL; | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
| 		// <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>䵽<EFBFBD><E4B5BD><EFBFBD>̵ĵ<CCB5>ַ<EFBFBD>ռ<EFBFBD> | ||||
| 		pTempItem->pBuf = MapViewOfFile(pTempItem->hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, DATA_FILE_SIZE + 16); | ||||
| 		if (pTempItem->pBuf == nullptr) | ||||
| 		{ | ||||
| 			TRACE("MapViewOfFile failed\r\n"); | ||||
| 			delete pTempItem; | ||||
| 			pTempItem = NULL; | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
| 		pTempItem->lFileSize = atoi((char*)pTempItem->pBuf); | ||||
| 		m_lItemCount += (pTempItem->lFileSize - DATA_FIRST_LINE_SIZE) / DATA_LINE_SIZE; | ||||
| 		pTempItem->lEndIndex = m_lItemCount - 1; | ||||
|  | ||||
|  | ||||
| 		m_vecFile.push_back(pTempItem); | ||||
| 	} | ||||
| 	m_lAutoSn = m_lItemCount; | ||||
| 	if (m_vecFile.size() > 0) | ||||
| 	{ | ||||
| 		m_pWriteFileItem = m_vecFile[m_vecFile.size() - 1]; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| static bool isValidDateFormat(const std::string& date)  | ||||
| { | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD>ʽ %04d-%02d-%02d | ||||
| 	std::regex datePattern(R"((\d{4})\-(\d{2})-(\d{2}))"); | ||||
| 	//std::regex datePattern(R"(\d{4}-\d{2}-\d{2})"); | ||||
| 	std::smatch match; | ||||
|  | ||||
| 	// <20><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> | ||||
| 	if (std::regex_match(date, match, datePattern))  | ||||
| 	{ | ||||
| 		// <20><>ȡ<EFBFBD>ꡢ<EFBFBD>¡<EFBFBD><C2A1><EFBFBD> | ||||
| 		int year = std::stoi(match[1].str()); | ||||
| 		int month = std::stoi(match[2].str()); | ||||
| 		int day = std::stoi(match[3].str()); | ||||
| 		// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>Ч<EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD>磺<EFBFBD>·<EFBFBD><C2B7><EFBFBD>1<EFBFBD><31>12֮<32>䣬<EFBFBD><E4A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31>31֮<31><D6AE><EFBFBD>ȣ<EFBFBD> | ||||
| 		if (month < 1 || month > 12 || day < 1 || day > 31)  | ||||
| 		{ | ||||
| 			return false; | ||||
| 		} | ||||
| 		return true; | ||||
| 	} | ||||
|  | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
| static bool DeleteDirectory(const std::string& dirPath)  | ||||
| { | ||||
| 	WIN32_FIND_DATA findFileData; | ||||
| 	std::string searchPath = dirPath + _T("\\*"); | ||||
| 	HANDLE hFind = FindFirstFile(searchPath.c_str(), &findFileData); | ||||
| 	if (hFind == INVALID_HANDLE_VALUE)  | ||||
| 	{ | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	do  | ||||
| 	{ | ||||
| 		std::string filePath; | ||||
| 		if (strcmp(findFileData.cFileName, _T(".")) == 0 || strcmp(findFileData.cFileName, _T("..")) == 0)  | ||||
| 		{ | ||||
| 			continue; | ||||
| 		} | ||||
|  | ||||
| 		filePath = dirPath + _T("\\") + findFileData.cFileName; | ||||
| 		if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)  | ||||
| 		{ | ||||
| 			if (!DeleteDirectory(filePath))  | ||||
| 			{ | ||||
| 				FindClose(hFind); | ||||
| 				return false; | ||||
| 			} | ||||
| 		} | ||||
| 		else  | ||||
| 		{ | ||||
| 			if (!DeleteFile(filePath.c_str()))  | ||||
| 			{ | ||||
| 				FindClose(hFind); | ||||
| 				return false; | ||||
| 			} | ||||
| 		} | ||||
| 	} while (FindNextFile(hFind, &findFileData) != 0); | ||||
|  | ||||
| 	FindClose(hFind); | ||||
| 	return RemoveDirectory(dirPath.c_str()) != 0; | ||||
| } | ||||
|  | ||||
| //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD> | ||||
| std::vector<std::string> CEXMemFileQueue::GetDataList() | ||||
| { | ||||
| 	std::vector<std::string> vecDir; | ||||
| 	traverse_directory_ansi(m_strBaseDir.c_str(), vecDir, 2); | ||||
|  | ||||
| 	std::vector<std::string> vecDate; | ||||
| 	//<2F><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD> | ||||
| 	for (int i = 0; i < (int)vecDir.size(); i++) | ||||
| 	{ | ||||
| 		if (isValidDateFormat(vecDir[i].c_str())) | ||||
| 		{ | ||||
| 			vecDate.push_back(vecDir[i].c_str()); | ||||
| 		} | ||||
| 	} | ||||
| 	return vecDate; | ||||
| } | ||||
|  | ||||
| //<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7><EFBFBD>ݣ<EFBFBD>lRecvDayΪ<79><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| void CEXMemFileQueue::AutoCleanData(int lRecvDay) | ||||
| { | ||||
| 	ThreadLock stLock(&m_cs); | ||||
| 	std::vector<std::string> vecDate = GetDataList(); | ||||
| 	for (int i = 0; i < ((int)vecDate.size()) - 5; i++) | ||||
| 	{ | ||||
| 		DeleteDirectory(m_strBaseDir + "\\" + vecDate[i]); | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										120
									
								
								Plugin/Driver/CEXMemFileQueue.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										120
									
								
								Plugin/Driver/CEXMemFileQueue.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,120 @@ | ||||
| #pragma once | ||||
| #include <vector> | ||||
| #include <string> | ||||
|  | ||||
| #define DATA_FIRST_LINE_SIZE (16) //<2F><>һ<EFBFBD>м<EFBFBD>¼<EFBFBD><C2BC>ǰ<EFBFBD>ļ<EFBFBD>ʵ<EFBFBD>ʳ<EFBFBD><CAB3><EFBFBD> | ||||
| ////////////////////////////////////////////////////////////////////////// | ||||
| // char acSeq[10]; | ||||
| // char acTime[12]; | ||||
| // unsigned char cIndex; // 0<><30>1 | ||||
| // unsigned char acTxRx; // 0:send, 1:recv | ||||
| // char acID[10]; | ||||
| // unsigned char acFrame;//0:data, 1:remote | ||||
| // unsigned char acType; //0:standard, 1:extend | ||||
| // unsigned char cDlc; | ||||
| // char acData[32]; | ||||
|  | ||||
|  | ||||
|  | ||||
| #define DATA_FILE_SIZE (89*10000) //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ֽ<EFBFBD><D6BD><EFBFBD> | ||||
|  | ||||
| class CEX_QUEUE_FILE_ITEM | ||||
| { | ||||
| public: | ||||
| 	CEX_QUEUE_FILE_ITEM() | ||||
| 	{ | ||||
| 		lFileSize = DATA_FIRST_LINE_SIZE; | ||||
| 		lBeindIndex = 0; | ||||
| 		lEndIndex = 0; | ||||
| 		hFile = INVALID_HANDLE_VALUE; | ||||
| 		hMapFile = NULL; | ||||
| 		pBuf = NULL; | ||||
| 	} | ||||
| 	~CEX_QUEUE_FILE_ITEM() | ||||
| 	{ | ||||
| 		if (NULL != pBuf) | ||||
| 		{ | ||||
| 			FlushViewOfFile(pBuf, lFileSize); | ||||
| 			UnmapViewOfFile(pBuf); | ||||
| 		} | ||||
| 		if (NULL != hMapFile) | ||||
| 		{ | ||||
| 			CloseHandle(hMapFile); | ||||
| 		} | ||||
| 		if (INVALID_HANDLE_VALUE != hFile) | ||||
| 		{ | ||||
| 			CloseHandle(hFile); | ||||
| 		} | ||||
| 	} | ||||
| 	std::string strFileName; | ||||
| 	HANDLE hFile;//<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	HANDLE hMapFile;//<2F>ļ<EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	void* pBuf;//<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	int lFileSize;//<2F><>ǰ<EFBFBD>ļ<EFBFBD><C4BC>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>е<EFBFBD>ժҪ<D5AA><D2AA>Ϣ<EFBFBD><CFA2><EFBFBD>ļ<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ȣ<EFBFBD> | ||||
| 	int lBeindIndex;//<2F><>ǰ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	int lEndIndex;//<2F><>ǰ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD> | ||||
| }; | ||||
|  | ||||
| class CEXMemFileQueue | ||||
| { | ||||
| 	class ThreadLock { | ||||
| 	public: | ||||
| 		// <20><><EFBFBD>캯<EFBFBD><ECBAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> | ||||
| 		ThreadLock(CRITICAL_SECTION* cs) | ||||
| 		{  | ||||
| 			m_cs = cs; | ||||
| 			EnterCriticalSection(m_cs);  | ||||
| 		} | ||||
| 		~ThreadLock()  | ||||
| 		{  | ||||
| 			LeaveCriticalSection(m_cs);  | ||||
| 		} | ||||
| 	private: | ||||
| 		CRITICAL_SECTION* m_cs; // <20>ٽ<EFBFBD><D9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	}; | ||||
|  | ||||
| public: | ||||
| 	CEXMemFileQueue(std::string strDataDir); | ||||
| 	~CEXMemFileQueue(); | ||||
|  | ||||
| 	//<2F><>ȡһ<C8A1><D2BB><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>ȹ̶<C8B9>ΪDATA_LINE_SIZE | ||||
| 	int ReadItem(void* pData, int lIndex = -1); | ||||
| 	//д<><D0B4>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>ȹ̶<C8B9>λDATA_LINE_SIZE | ||||
| 	int WriteItem(void* pData); | ||||
| 	//ǿ<><C7BF>ˢ<EFBFBD><CBA2><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>ļ<EFBFBD><C4BC><EFBFBD> | ||||
| 	void FlushWriteFile(); | ||||
| 	//<2F><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	int GetItemCount(); | ||||
|  | ||||
| 	int GetAutoSn(); | ||||
|  | ||||
| 	//<2F>л<EFBFBD><D0BB><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD> | ||||
| 	void ChangeDataDate(SYSTEMTIME stDate); | ||||
| 	//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD> | ||||
| 	std::vector<std::string> GetDataList(); | ||||
| 	//<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7><EFBFBD>ݣ<EFBFBD>lRecvDayΪ<79><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	void AutoCleanData(int lRecvDay); | ||||
|  | ||||
| private: | ||||
|  | ||||
| 	//<2F><><EFBFBD>ݷ<EFBFBD><DDB7>ļ<EFBFBD><C4BC>洢 | ||||
| 	std::vector<CEX_QUEUE_FILE_ITEM*> m_vecFile; | ||||
|  | ||||
| 	//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ڵ<EFBFBD> | ||||
| 	CEX_QUEUE_FILE_ITEM* m_pWriteFileItem; | ||||
| 	//<2F><>ǰ<EFBFBD><C7B0><EFBFBD>ڶ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ļ<EFBFBD><C4BC>ڵ<EFBFBD> | ||||
| 	CEX_QUEUE_FILE_ITEM* m_pReadFileItem; | ||||
|  | ||||
| 	int m_lReadIndex;//<2F><>ǰ<EFBFBD><C7B0>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ֵ | ||||
| 	int m_lItemCount;//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
| 	std::string m_strBaseDir;//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7> | ||||
| 	std::string m_strDataDir;//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7> | ||||
|  | ||||
| 	CRITICAL_SECTION m_cs; | ||||
|  | ||||
| 	int m_lAutoSn; | ||||
|  | ||||
| 	SYSTEMTIME m_stDataDate; | ||||
| }; | ||||
|  | ||||
							
								
								
									
										315
									
								
								Plugin/Driver/CEXVirtualListCtrl.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										315
									
								
								Plugin/Driver/CEXVirtualListCtrl.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,315 @@ | ||||
| // CEXVirtualListDlg.cpp: 实现文件 | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| #include "PluginDriver.h" | ||||
| #include "CEXVirtualListCtrl.h" | ||||
| #include "afxdialogex.h" | ||||
|  | ||||
| #include <iostream> | ||||
| #include <string> | ||||
| #include <sstream> | ||||
|  | ||||
| //控件ID只需要在当前窗口中唯一,这里随便写一个就好 | ||||
| #define ID_VIRTUAL_LIST_CTRL (1987) | ||||
|  | ||||
| IMPLEMENT_DYNAMIC(CEXVirtualListCtrl, CListCtrl) | ||||
|  | ||||
| CEXVirtualListCtrl::CEXVirtualListCtrl()  | ||||
| { | ||||
| 	m_pQueueData = NULL; | ||||
| 	m_lOldCount = 0; | ||||
| } | ||||
|  | ||||
| CEXVirtualListCtrl::~CEXVirtualListCtrl()  | ||||
| { | ||||
| } | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CEXVirtualListCtrl, CListCtrl) | ||||
| 	ON_NOTIFY_REFLECT(LVN_GETDISPINFO, &CEXVirtualListCtrl::OnLvnGetdispinfo) | ||||
| 	ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, &CEXVirtualListCtrl::OnNMCustomdraw) | ||||
| 	ON_WM_ERASEBKGND() | ||||
| 	ON_WM_TIMER() | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
| /* | ||||
| void CEXVirtualListCtrl::Initialize()  | ||||
| { | ||||
| 	SetExtendedStyle(GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_OWNERDATA); // 确保设置了虚拟大小样式 | ||||
| 	SetItemCountEx((int)0); | ||||
|  | ||||
| 	// 添加列(这里假设列是固定的,可以在构造函数中或这里添加) | ||||
| 	InsertColumn(0, _T("ID"), LVCFMT_LEFT, 80); | ||||
| 	InsertColumn(1, _T("Value1"), LVCFMT_LEFT, 120); | ||||
| 	InsertColumn(2, _T("Value2"), LVCFMT_LEFT, 100); | ||||
| } | ||||
| */ | ||||
|  | ||||
| void CEXVirtualListCtrl::SetData(CEXMemFileQueue* pQueue) | ||||
| { | ||||
| 	m_pQueueData = pQueue; | ||||
| 	SetItemCountEx((int)m_pQueueData->GetItemCount()); | ||||
| } | ||||
|  | ||||
| std::string getSubString(const char* input, int index) { | ||||
| 	std::vector<std::string> substrings; | ||||
| 	std::stringstream ss(input); | ||||
| 	std::string item; | ||||
|  | ||||
| 	// 使用逗号作为分隔符分割字符串 | ||||
| 	while (std::getline(ss, item, ',')) { | ||||
| 		substrings.push_back(item); | ||||
| 	} | ||||
|  | ||||
| 	// 检查索引是否有效 | ||||
| 	if (index < 0 || index >= substrings.size()) { | ||||
| 		return ""; | ||||
| 	} | ||||
|  | ||||
| 	// 返回对应的子串 | ||||
| 	return substrings[index]; | ||||
| } | ||||
|  | ||||
| void CEXVirtualListCtrl::OnLvnGetdispinfo(NMHDR* pNMHDR, LRESULT* pResult)  | ||||
| { | ||||
| 	NMLVDISPINFO* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR); | ||||
| 	LV_ITEM* pItem = &(pDispInfo)->item; | ||||
|  | ||||
| 	if (pItem->iItem >= 0 && pItem->iItem < static_cast<int>(m_pQueueData->GetItemCount()))  | ||||
| 	{ | ||||
| 		char acTemp[DATA_LINE_SIZE + 1] = { 0 }; | ||||
| 		int lIndex = m_pQueueData->ReadItem(acTemp, pItem->iItem); //pItem->iItem为行序号,即数据索引 | ||||
|  | ||||
| 		if (pItem->mask & LVIF_TEXT)  | ||||
| 		{ | ||||
| 			CString str; | ||||
| 			int lTempValue = 0; | ||||
| 			switch (pItem->iSubItem) //pItem->iSubItem为列编号,可以逐单元格设置内容; | ||||
| 			{ | ||||
| 			case 0://acSeq[10]; | ||||
| 				str= getSubString(acTemp, 0).c_str(); | ||||
| 				break; | ||||
| 			case 1://acTime[12]; | ||||
| 				str = getSubString(acTemp, 1).c_str(); | ||||
| 				break; | ||||
| 			case 2://cIndex; // 0或1 | ||||
| 				str = getSubString(acTemp, 2).c_str(); | ||||
| 				break; | ||||
| 			case 3://acTxRx; // 0:send, 1:recv | ||||
| 				lTempValue = atoi(getSubString(acTemp, 3).c_str()); | ||||
| 				str = lTempValue == 0 ? "send" : lTempValue == 1 ? "recv" : "-"; | ||||
| 				break; | ||||
| 			case 4://acID[10]; | ||||
| 				str = getSubString(acTemp, 4).c_str(); | ||||
| 				break; | ||||
| 			case 5://acFrame;//0:data, 1:remote | ||||
| 				lTempValue = atoi(getSubString(acTemp, 5).c_str()); | ||||
| 				str = lTempValue == 0 ? "data" : lTempValue == 1 ? "remote" : "-"; | ||||
| 				break; | ||||
| 			case 6:////0:standard, 1:extend | ||||
| 				lTempValue = atoi(getSubString(acTemp, 6).c_str()); | ||||
| 				str = lTempValue == 0 ? "standard" : lTempValue == 1 ? "extend" : "-"; | ||||
| 				break; | ||||
| 			case 7://cDlc; | ||||
| 				str = getSubString(acTemp, 7).c_str(); | ||||
| 				break; | ||||
| 			case 8://acData[32]; | ||||
| 				str = getSubString(acTemp, 8).c_str(); | ||||
| 				break; | ||||
| 			 | ||||
| 			} | ||||
| 			lstrcpy(pItem->pszText, str); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	*pResult = 0; | ||||
| } | ||||
| void CEXVirtualListCtrl::OnNMCustomdraw(NMHDR* pNMHDR, LRESULT* pResult) | ||||
| { | ||||
| 	LPNMLVCUSTOMDRAW pLVCD = reinterpret_cast<LPNMLVCUSTOMDRAW>(pNMHDR); | ||||
| 	*pResult = CDRF_DODEFAULT; | ||||
|  | ||||
| 	switch (pLVCD->nmcd.dwDrawStage) | ||||
| 	{ | ||||
| 	case CDDS_PREPAINT: | ||||
| 		*pResult = CDRF_NOTIFYITEMDRAW; | ||||
| 		break; | ||||
|  | ||||
| 	case CDDS_ITEMPREPAINT: | ||||
| 	{ | ||||
| 		// 获取当前项和子项的索引 | ||||
| 		int nItem = static_cast<int>(pLVCD->nmcd.dwItemSpec); | ||||
|  | ||||
| 		char acTemp[DATA_LINE_SIZE + 1] = { 0 }; | ||||
| 		m_pQueueData->ReadItem(acTemp, nItem); | ||||
| 		int lId = atoi(acTemp);//测试数据每条数据的最前面是10进制的ID,所以这里直接使用atoi了 | ||||
|  | ||||
| 		// 根据需要修改颜色 | ||||
| 		if (lId % 10 == 0) // 根据需要设定行颜色 | ||||
| 		{ | ||||
| 			pLVCD->clrText = RGB(255, 0, 0); // 红色文本 | ||||
| 			pLVCD->clrTextBk = RGB(200, 200, 255); // 浅蓝色背景 | ||||
|  | ||||
| 			//*pResult = CDRF_NEWFONT | CDRF_SKIPDEFAULT; | ||||
| 			*pResult = CDRF_NOTIFYITEMDRAW; | ||||
| 		} | ||||
| 	} | ||||
| 	break; | ||||
|  | ||||
| 	default: | ||||
| 		break; | ||||
| 	} | ||||
| } | ||||
| BOOL CEXVirtualListCtrl::OnEraseBkgnd(CDC* pDC) | ||||
| { | ||||
| 	// TODO: 在此添加消息处理程序代码和/或调用默认值 | ||||
| 	//return TRUE; //避免闪烁 | ||||
| 	return CListCtrl::OnEraseBkgnd(pDC); | ||||
| } | ||||
|  | ||||
| #define TIMER_REFRESH_LIST_ID (18989) | ||||
| void CEXVirtualListCtrl::StartAutoRefresh(int lMSecond) | ||||
| { | ||||
| 	SetTimer(TIMER_REFRESH_LIST_ID, lMSecond, NULL); | ||||
| } | ||||
| void CEXVirtualListCtrl::StopAutoRefresh() | ||||
| { | ||||
| 	KillTimer(TIMER_REFRESH_LIST_ID); | ||||
| } | ||||
| void CEXVirtualListCtrl::RefreshShow() | ||||
| { | ||||
| 	int lItemCount = m_pQueueData->GetItemCount(); | ||||
| 	if (m_lOldCount == lItemCount) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	SetItemCountEx(lItemCount, LVSICF_NOINVALIDATEALL | LVSICF_NOSCROLL); | ||||
| 	EnsureVisible(lItemCount - 1, FALSE); | ||||
|  | ||||
| 	m_lOldCount = lItemCount; | ||||
| } | ||||
|  | ||||
| void CEXVirtualListCtrl::OnTimer(UINT_PTR nIDEvent) | ||||
| { | ||||
| 	// TODO: 在此添加消息处理程序代码和/或调用默认值 | ||||
|  | ||||
| 	if (TIMER_REFRESH_LIST_ID == nIDEvent) | ||||
| 	{ | ||||
| 		if (NULL != m_pQueueData) | ||||
| 		{ | ||||
| 			RefreshShow(); | ||||
| 		} | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		//自定义定时器,无需调用基类OnTimer,否则定时器会被强制结束 | ||||
| 		CListCtrl::OnTimer(nIDEvent); | ||||
| 	} | ||||
| } | ||||
|  | ||||
|  | ||||
| #if 0 | ||||
| // CEXVirtualListDlg 对话框 | ||||
|  | ||||
| IMPLEMENT_DYNAMIC(CEXVirtualListDlg, CDialogEx) | ||||
|  | ||||
| CEXVirtualListDlg::CEXVirtualListDlg(CWnd* pParent /*=nullptr*/) | ||||
| 	: CDialogEx(IDD_CEXVirtualListDlg, pParent) | ||||
| { | ||||
| 	m_pstVirtualList = new CEXVirtualListCtrl(); | ||||
| } | ||||
|  | ||||
| CEXVirtualListDlg::~CEXVirtualListDlg() | ||||
| { | ||||
| } | ||||
|  | ||||
| void CEXVirtualListDlg::DoDataExchange(CDataExchange* pDX) | ||||
| { | ||||
| 	CDialogEx::DoDataExchange(pDX); | ||||
| 	//DDX_Control(pDX, ID_VIRTUAL_LIST_CTRL, *m_pstVirtualList); | ||||
| } | ||||
|  | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CEXVirtualListDlg, CDialogEx) | ||||
| 	ON_BN_CLICKED(IDOK, &CEXVirtualListDlg::OnBnClickedOk) | ||||
| 	ON_BN_CLICKED(IDCANCEL, &CEXVirtualListDlg::OnBnClickedCancel) | ||||
| 	ON_WM_SIZE() | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
|  | ||||
| // CEXVirtualListDlg 消息处理程序 | ||||
|  | ||||
|  | ||||
| void CEXVirtualListDlg::OnBnClickedOk() | ||||
| { | ||||
| 	// TODO: 在此添加控件通知处理程序代码 | ||||
| 	//CDialogEx::OnOK(); | ||||
| 	//屏蔽按下回车导致列表隐藏 | ||||
| } | ||||
|  | ||||
|  | ||||
| void CEXVirtualListDlg::OnBnClickedCancel() | ||||
| { | ||||
| 	// TODO: 在此添加控件通知处理程序代码 | ||||
| 	//CDialogEx::OnCancel(); | ||||
| 	//屏蔽按下ESC导致列表隐藏 | ||||
| } | ||||
|  | ||||
|  | ||||
| void CEXVirtualListDlg::OnSize(UINT nType, int cx, int cy) | ||||
| { | ||||
| 	CDialogEx::OnSize(nType, cx, cy); | ||||
|  | ||||
| 	// TODO: 在此处添加消息处理程序代码 | ||||
| 	if (NULL != m_pstVirtualList && NULL != m_pstVirtualList->m_hWnd) | ||||
| 	{ | ||||
| 		m_pstVirtualList->MoveWindow(0, 0, cx, cy); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| BOOL CEXVirtualListDlg::OnInitDialog() | ||||
| { | ||||
| 	CDialogEx::OnInitDialog(); | ||||
| 	if (!m_pstVirtualList->Create(WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_OWNERDATA | LVS_EX_DOUBLEBUFFER, CRect(0, 0, 0, 0), this, ID_VIRTUAL_LIST_CTRL)) { | ||||
| 		TRACE0("Failed to create MyVirtualListCtrl\n"); | ||||
| 		delete m_pstVirtualList; | ||||
| 		m_pstVirtualList = nullptr; | ||||
| 		return FALSE;      // 返回 FALSE  以使框架知道未成功初始化 | ||||
| 	} | ||||
|  | ||||
| 	// 设置控件的扩展样式和其他属性:整行选中、 | ||||
| 	m_pstVirtualList->SetExtendedStyle(LVS_EX_GRIDLINES | LVS_REPORT/*LVS_EX_VIRTUALSIZE*/); | ||||
|  | ||||
| 	m_pstVirtualList->Initialize(); | ||||
|  | ||||
| 	return TRUE; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CEXVirtualListDlg::SetData(CEXMemFileQueue* pQueue) | ||||
| { | ||||
| 	m_pstVirtualList->SetData(pQueue); | ||||
| } | ||||
|  | ||||
| #endif | ||||
|  | ||||
| BOOL CEXVirtualListCtrl::PreCreateWindow(CREATESTRUCT& cs) | ||||
| { | ||||
| 	// TODO: 在此添加专用代码和/或调用基类 | ||||
| 	 | ||||
|  | ||||
| 	return CListCtrl::PreCreateWindow(cs); | ||||
| } | ||||
|  | ||||
|  | ||||
| BOOL CEXVirtualListCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID) | ||||
| { | ||||
| 	// TODO: 在此添加专用代码和/或调用基类 | ||||
| 	 | ||||
| 	BOOL bRet = CListCtrl::Create(dwStyle, rect, pParentWnd, nID); | ||||
| 	SetExtendedStyle(LVS_EX_GRIDLINES | LVS_REPORT/*LVS_EX_VIRTUALSIZE*/); | ||||
| 	SetExtendedStyle(GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_OWNERDATA); // 确保设置了虚拟大小样式 | ||||
| 	SetItemCountEx((int)0); | ||||
| 	return bRet; | ||||
| } | ||||
							
								
								
									
										75
									
								
								Plugin/Driver/CEXVirtualListCtrl.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								Plugin/Driver/CEXVirtualListCtrl.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,75 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include <afxwin.h> | ||||
| #include <vector> | ||||
| #include <string> | ||||
| #include "CEXMemFileQueue.h" | ||||
|  | ||||
| struct MyListItem { | ||||
| 	int id; | ||||
| 	CString name; | ||||
| 	CString date; | ||||
| }; | ||||
|  | ||||
| class CEXVirtualListCtrl : public CListCtrl { | ||||
| 	DECLARE_DYNAMIC(CEXVirtualListCtrl) | ||||
|  | ||||
| public: | ||||
| 	CEXVirtualListCtrl(); | ||||
| 	virtual ~CEXVirtualListCtrl(); | ||||
|  | ||||
| 	//void Initialize(); | ||||
| 	void SetData(CEXMemFileQueue* pQueue); | ||||
|  | ||||
| 	void StartAutoRefresh(int lMSecond); | ||||
| 	void StopAutoRefresh(); | ||||
| 	void RefreshShow(); | ||||
|  | ||||
| protected: | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
| 	afx_msg void OnLvnGetdispinfo(NMHDR* pNMHDR, LRESULT* pResult); | ||||
| 	afx_msg void OnNMCustomdraw(NMHDR* pNMHDR, LRESULT* pResult); | ||||
|  | ||||
| private: | ||||
| 	CEXMemFileQueue* m_pQueueData; | ||||
| 	int m_lOldCount; | ||||
| public: | ||||
| 	afx_msg BOOL OnEraseBkgnd(CDC* pDC); | ||||
| 	virtual BOOL PreCreateWindow(CREATESTRUCT& cs); | ||||
| 	virtual BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID); | ||||
| 	afx_msg void OnTimer(UINT_PTR nIDEvent); | ||||
| }; | ||||
|  | ||||
|  | ||||
| // CEXVirtualListDlg 对话框 | ||||
|  | ||||
| class CEXVirtualListDlg : public CDialogEx | ||||
| { | ||||
| 	DECLARE_DYNAMIC(CEXVirtualListDlg) | ||||
|  | ||||
| public: | ||||
| 	CEXVirtualListDlg(CWnd* pParent = nullptr);   // 标准构造函数 | ||||
| 	virtual ~CEXVirtualListDlg(); | ||||
|  | ||||
| 	//给虚拟列表关联数据 | ||||
| 	void SetData(CEXMemFileQueue* pQueue); | ||||
|  | ||||
| // 对话框数据 | ||||
| #ifdef AFX_DESIGN_TIME | ||||
| 	enum { IDD = IDD_CEXVirtualListDlg }; | ||||
| #endif | ||||
|  | ||||
| 	virtual BOOL OnInitDialog(); | ||||
|  | ||||
| protected: | ||||
| 	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持 | ||||
|  | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
|  | ||||
| 	afx_msg void OnBnClickedOk(); | ||||
| 	afx_msg void OnBnClickedCancel(); | ||||
| 	afx_msg void OnSize(UINT nType, int cx, int cy); | ||||
|  | ||||
| private: | ||||
| 	CEXVirtualListCtrl* m_pstVirtualList; | ||||
| }; | ||||
							
								
								
									
										137
									
								
								Plugin/Driver/ColoredListCtrl.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								Plugin/Driver/ColoredListCtrl.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,137 @@ | ||||
| // ColoredListCtrl.cpp : implementation file | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| #include "ColoredListCtrl.h" | ||||
|  | ||||
| #ifdef _DEBUG | ||||
| #define new DEBUG_NEW | ||||
| #undef THIS_FILE | ||||
| static char THIS_FILE[] = __FILE__; | ||||
| #endif | ||||
|  | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
| // CColoredListCtrl | ||||
| CColoredListCtrl::CColoredListCtrl() | ||||
| { | ||||
| 	m_colRow1 = RGB(200,200,250); | ||||
| 	m_colRow2 = RGB(230,247,247); | ||||
|  | ||||
| //	m_colRow1 = RGB(240,247,249); | ||||
| //	m_colRow2 = RGB(229,232,239); | ||||
| } | ||||
|  | ||||
| CColoredListCtrl::~CColoredListCtrl() | ||||
| { | ||||
| } | ||||
|  | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CColoredListCtrl, CListCtrl) | ||||
| 	//{{AFX_MSG_MAP(CColoredListCtrl) | ||||
| 	ON_WM_ERASEBKGND() | ||||
| 	ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw) | ||||
| 	//}}AFX_MSG_MAP | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
| // CColoredListCtrl message handlers | ||||
|  | ||||
| void CColoredListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult) | ||||
| { | ||||
|   *pResult = 0; | ||||
|  | ||||
|   LPNMLVCUSTOMDRAW  lplvcd = (LPNMLVCUSTOMDRAW)pNMHDR; | ||||
|   int iRow = lplvcd->nmcd.dwItemSpec; | ||||
|  | ||||
|   switch(lplvcd->nmcd.dwDrawStage) | ||||
|   { | ||||
|     case CDDS_PREPAINT : | ||||
|     { | ||||
|       *pResult = CDRF_NOTIFYITEMDRAW; | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|     // Modify item text and or background | ||||
|     case CDDS_ITEMPREPAINT: | ||||
|     { | ||||
|       lplvcd->clrText = RGB(0,0,0); | ||||
|       // If you want the sub items the same as the item, | ||||
|       // set *pResult to CDRF_NEWFONT | ||||
|         if(ItemColorFlag[iRow]){ | ||||
|          lplvcd->clrTextBk = m_colRow2; | ||||
|         } | ||||
|         else{ | ||||
|           lplvcd->clrTextBk = m_colRow1; | ||||
|         } | ||||
|  | ||||
|       *pResult =CDRF_NOTIFYSUBITEMDRAW; | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|     // Modify sub item text and/or background | ||||
|     case CDDS_SUBITEM | CDDS_PREPAINT | CDDS_ITEM: | ||||
|     { | ||||
| 	/*	//if(*(ItemColorFlag+nextrow)){ | ||||
|         if(ItemColorFlag[iRow]){ | ||||
|          lplvcd->clrTextBk = m_colRow2; | ||||
|         } | ||||
|         else{ | ||||
|           lplvcd->clrTextBk = m_colRow1; | ||||
|         } | ||||
| */ | ||||
|         *pResult = CDRF_DODEFAULT; | ||||
|         return; | ||||
|     } | ||||
|   } | ||||
|   /* | ||||
|  void CCoolList::OnCustomDraw(NMHDR *pNMHDR, LRESULT *pResult){//<2F><><EFBFBD>Ͱ<EFBFBD>ȫת<C8AB><D7AA> | ||||
| NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR); | ||||
| *pResult = 0;//ָ<><D6B8><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ | ||||
| if(CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage) | ||||
| {*pResult = CDRF_NOTIFYITEMDRAW;} | ||||
| else if(CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage) | ||||
| {//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	if(pLVCD->nmcd.dwItemSpec % 2) | ||||
| 		pLVCD->clrTextBk = RGB(255, 255, 128);//ż<><C5BC><EFBFBD><EFBFBD> | ||||
| 	else  | ||||
| 		pLVCD->clrTextBk = RGB(128, 255, 255);//<2F><><EFBFBD><EFBFBD>*pResult = CDRF_DODEFAULT;}}   | ||||
| );//<2F><><EFBFBD><EFBFBD> | ||||
| *pResult = CDRF_DODEFAULT;}} | ||||
|  | ||||
| */ | ||||
| } | ||||
|  | ||||
| BOOL CColoredListCtrl::OnEraseBkgnd(CDC* pDC)  | ||||
| { | ||||
| 	// TODO: Add your message handler code here and/or call default | ||||
|  | ||||
| //return TRUE; | ||||
|  | ||||
|   CRect rect; | ||||
|   CColoredListCtrl::GetClientRect(rect); | ||||
|  | ||||
|  | ||||
| //  POINT mypoint;   | ||||
|    | ||||
|  // CBrush brush0(m_colRow1); | ||||
|   CBrush brush1(m_colRow2); | ||||
|  | ||||
|  | ||||
|   | ||||
|  int chunk_height=GetCountPerPage(); | ||||
|  pDC->FillRect(&rect,&brush1); | ||||
| /* | ||||
|  for (int i=0;i<=chunk_height;i++) | ||||
|  { | ||||
| 	GetItemPosition(i,&mypoint); | ||||
| 	rect.top=mypoint.y ; | ||||
| 	GetItemPosition(i+1,&mypoint); | ||||
| 	rect.bottom =mypoint.y; | ||||
| 	pDC->FillRect(&rect,i %2 ? &brush1 : &brush0); | ||||
|  }*/ | ||||
|  | ||||
| //  brush0.DeleteObject(); | ||||
|   brush1.DeleteObject(); | ||||
|  | ||||
|   return FALSE; | ||||
| } | ||||
							
								
								
									
										51
									
								
								Plugin/Driver/ColoredListCtrl.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								Plugin/Driver/ColoredListCtrl.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| #if !defined(AFX_COLOREDLISTCTRL_H__86FEBE8E_F6FA_429F_B740_76F1769C81C6__INCLUDED_) | ||||
| #define AFX_COLOREDLISTCTRL_H__86FEBE8E_F6FA_429F_B740_76F1769C81C6__INCLUDED_ | ||||
|  | ||||
| #if _MSC_VER > 1000 | ||||
| #pragma once | ||||
| #endif // _MSC_VER > 1000 | ||||
| // ColoredListCtrl.h : header file | ||||
| // | ||||
| extern unsigned long int nextrow; | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
| // CColoredListCtrl window | ||||
|  | ||||
| class CColoredListCtrl : public CListCtrl | ||||
| { | ||||
| // Construction | ||||
| public: | ||||
| 	CColoredListCtrl(); | ||||
|  | ||||
| // Attributes | ||||
| public: | ||||
| 	COLORREF m_colRow1; | ||||
| 	COLORREF m_colRow2; | ||||
|  | ||||
| // Operations | ||||
| public: | ||||
| 	unsigned char ItemColorFlag[60000]; | ||||
| 	 | ||||
| // Overrides | ||||
| 	// ClassWizard generated virtual function overrides | ||||
| 	//{{AFX_VIRTUAL(CColoredListCtrl) | ||||
| 	//}}AFX_VIRTUAL | ||||
|  | ||||
| // Implementation | ||||
| public: | ||||
| 	virtual ~CColoredListCtrl(); | ||||
|  | ||||
| 	// Generated message map functions | ||||
| protected: | ||||
| 	//{{AFX_MSG(CColoredListCtrl) | ||||
| 	afx_msg BOOL OnEraseBkgnd(CDC* pDC);	 | ||||
| 	//}}AFX_MSG | ||||
| 	afx_msg void CColoredListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult); | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
| }; | ||||
|  | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| //{{AFX_INSERT_LOCATION}} | ||||
| // Microsoft Visual C++ will insert additional declarations immediately before the previous line. | ||||
|  | ||||
| #endif // !defined(AFX_COLOREDLISTCTRL_H__86FEBE8E_F6FA_429F_B740_76F1769C81C6__INCLUDED_) | ||||
							
								
								
									
										302
									
								
								Plugin/Driver/CommDataDef.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										302
									
								
								Plugin/Driver/CommDataDef.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,302 @@ | ||||
|  | ||||
| #pragma once | ||||
| #pragma pack (1) | ||||
|  | ||||
| //<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>Ϣ | ||||
| #define  WM_THREAD_RECV			WM_USER + 1000 | ||||
| #define  WM_SERTHREAD_RECV		WM_USER + 2000 | ||||
|  | ||||
| #define  WP_WPARA_RECV				1001 | ||||
| #define  WP_WPARA_CLOSE				1002	//socket<65>ر<EFBFBD> | ||||
| #define  WP_WPARA_THREAD_QUIT		1005	//<2F>̹߳ر<CCB9> | ||||
|  | ||||
| #define  WP_WPARA_SERVER_RECV		2001 | ||||
| #define  WP_WPARA_SERVER_CLOSE		2002	//socket<65>ر<EFBFBD> | ||||
| #define  WP_WPARA_SERTHREAD_QUIT	2005	//<2F>̹߳ر<CCB9> | ||||
|  | ||||
| //<2F>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>ܸ<EFBFBD><DCB8><EFBFBD> | ||||
| #define  DUSTDEV_REGNUM				14     //<2F>ɼ<EFBFBD><C9BC>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܸ<EFBFBD><DCB8><EFBFBD> | ||||
|  | ||||
| //<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD> | ||||
| typedef struct __dustDevPara{ | ||||
| 	double  fDCVolt; | ||||
| 	double	fDCCurr; | ||||
| 	double	fPSVolt; | ||||
| 	double	fPSCurr; | ||||
| 	WORD	wPsFreq; | ||||
| 	double  fEnvTempr; | ||||
| 	double  fEnvHumity; | ||||
| 	double  fDcIgbtTemp; | ||||
| 	double  fPulseIgbtTemp; | ||||
| 	__dustDevPara(){ | ||||
| 		fDCVolt =0.0; | ||||
| 		fDCCurr =0.0; | ||||
| 		fPSVolt =0.0; | ||||
| 		fPSCurr =0.0; | ||||
| 		wPsFreq =0; | ||||
| 		fEnvTempr  =0.0; | ||||
| 		fEnvHumity =0.0; | ||||
| 		fDcIgbtTemp	=0.0; | ||||
| 		fPulseIgbtTemp =0.0; | ||||
| 	} | ||||
| }ST_DUSTDEV_WOORKPARA; | ||||
|  | ||||
| //Modbus<75><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6>ֵ | ||||
| typedef enum __enumFuncCode{ | ||||
| 	EN_MODBUS_READ_SINGLECOIL		=0x01,			//<2F><><EFBFBD><EFBFBD>Ȧ | ||||
| 	EN_MODBUS_READ_PERSISREG		=0x03,			//<2F><><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD> | ||||
| 	EN_MODBUS_WRITE_SINGLECOIL		=0x05,			//д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȧ | ||||
| 	EN_MODBUS_WRITE_SINGLEREG		=0x06,			//д<><D0B4><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD> | ||||
| 	EN_MODBUS_WRITE_MULTIREG		=0x10, | ||||
|  | ||||
| 	EN_MODBUS_READ_SINGLECOIL_RSPERR	=0x81, | ||||
| 	EN_MODBUS_READ_PERSISREG_RSPERR		=0x83, | ||||
| 	EN_MODBUS_WRITE_SINGLECOIL_RSPERR	=0x85, | ||||
| 	EN_MODBUS_WRITE_SINGLEREG_RSPERR	=0x86, | ||||
| 	EN_MODBUS_WRITE_MULTIREG_RSPERR		=0x90 | ||||
| }EN_NUM_MODBUS_FUNCCODE; | ||||
|  | ||||
| //<2F>Ĵ<EFBFBD><C4B4><EFBFBD>ö<EFBFBD><C3B6>ֵ(*10<31><30>ʾ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ֵΪʵ<CEAA><CAB5>ֵ<EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>) | ||||
| typedef enum  __enumRegAddr{ | ||||
| 	EN_REGADDR_DCVOLTH		=0x0000,		//ֱ<><D6B1><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9> | ||||
| 	EN_REGADDR_DCVOLTL		=0x0001,		//ֱ<><D6B1><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9> | ||||
| 	EN_REGADDR_DCCURR		=0x0002,		//ֱ<><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>		*10.0 | ||||
| 	EN_REGADDR_PULSEVOLTH	=0x0003,		//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9> | ||||
| 	EN_REGADDR_PULSEVOLTL	=0x0004,		//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9> | ||||
| 	EN_REGADDR_PULSECURR	=0x0005,		//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>		*10.0 | ||||
| 	EN_REGADDR_PULSEFREQ    =0x0006,		//<2F><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>		*10.0 | ||||
| 	EN_REGADDR_ENVTEMP		=0x0007,		//<2F><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>		*10.0 | ||||
| 	EN_REGADDR_ENVHUMITY	=0x0008,		//<2F><><EFBFBD><EFBFBD>ʪ<EFBFBD><CAAA>		*10.0 | ||||
| 	EN_REGADDR_SUPPLYVOLT	=0x0009,		//<2F>е<EFBFBD><D0B5><EFBFBD>ѹ		*10.0 | ||||
| 	EN_REGADDR_SUPPLYCURR	=0x000A,		//<2F>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>		*10.0 | ||||
| 	EN_REGADDR_ACTODCVOLT   =0x000B,		//ֱ<><D6B1><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>ѹ  *10.0 | ||||
| 	EN_REGADDR_DCIGBTTEMP	=0x000C,		//ֱ<><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IGBT<42><54><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>	  *10.0 | ||||
| 	EN_REGADDR_PULSEIGBTTEMP=0x000D			//<2F><><EFBFBD>岿<EFBFBD><E5B2BF>IGBT<42><54><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>    *10.0 | ||||
| }EN_NUM_REGADDR; | ||||
|  | ||||
| //MBAP<41><50><EFBFBD><EFBFBD>ͷ | ||||
| typedef  struct  __modbusMbapHeader{ | ||||
| 	WORD	wTransFlag; | ||||
| 	WORD	wProtocolFlag; | ||||
| 	WORD	wLen; | ||||
| 	BYTE	bUnitFlag; | ||||
| 	__modbusMbapHeader(){ | ||||
| 		wTransFlag		=0; | ||||
| 		wProtocolFlag	=0; | ||||
| 		wLen			=0; | ||||
| 		bUnitFlag		=0; | ||||
| 	} | ||||
| }ST_MODBUS_MBAP_HEADER; | ||||
|  | ||||
| //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȧ/<2F><><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>---Cient<6E><74> | ||||
| typedef  struct  __clientRqtReadFrame{ | ||||
| 	ST_MODBUS_MBAP_HEADER	stMbapHeader; | ||||
| 	BYTE					bFuncConde; | ||||
| 	WORD					wStartAddr; | ||||
| 	WORD					wRegNum; | ||||
| 	__clientRqtReadFrame() | ||||
| 	{ | ||||
| 		bFuncConde	=0x0; | ||||
| 		wStartAddr	=0; | ||||
| 		wRegNum		=0; | ||||
| 	} | ||||
| }ST_MODBUS_CLIENT_RQTREAD_FRAME; | ||||
|  | ||||
| //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȧ<EFBFBD><C8A6><EFBFBD><EFBFBD>---Cient<6E><74> | ||||
| typedef  struct  __clientRqtWrtCoilFrame{ | ||||
| 	ST_MODBUS_MBAP_HEADER	stMbapHeader; | ||||
| 	BYTE					bFuncConde; | ||||
| 	WORD					wAddr; | ||||
| 	WORD					wOutVal; | ||||
| 	__clientRqtWrtCoilFrame() | ||||
| 	{ | ||||
| 		bFuncConde	=0x05; | ||||
| 		wAddr		=0; | ||||
| 		wOutVal		=0; | ||||
| 	} | ||||
| }ST_MODBUS_CLIENT_RQTWRTCOIL_FRAME; | ||||
|  | ||||
| //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| typedef  struct  __serverRqtWrtRegFrame{ | ||||
| 	ST_MODBUS_MBAP_HEADER	stMbapHeader; | ||||
| 	BYTE					bFuncConde; | ||||
| 	WORD					wAddr; | ||||
| 	WORD					wOutVal; | ||||
| 	__serverRqtWrtRegFrame() | ||||
| 	{ | ||||
| 		bFuncConde	=0x06; | ||||
| 		wAddr		=0; | ||||
| 		wOutVal		=0; | ||||
| 	} | ||||
| }ST_MODBUS_SERVER_RQTWRTREG_FRAME; | ||||
|  | ||||
| //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>---Cient<6E><74> | ||||
| typedef  struct  __clientRqtWrtMultiRegFrame{ | ||||
| 	ST_MODBUS_MBAP_HEADER	stMbapHeader; | ||||
| 	BYTE					bFuncConde; | ||||
| 	WORD					wStartAddr; | ||||
| 	WORD					wRegNum; | ||||
| 	BYTE					bLen; | ||||
| 	BYTE					bRegVal[255]; | ||||
| 	__clientRqtWrtMultiRegFrame() | ||||
| 	{ | ||||
| 		bFuncConde	=0x10; | ||||
| 		wStartAddr	=0; | ||||
| 		wRegNum		=0; | ||||
| 		bLen		=0; | ||||
| 		memset(bRegVal,0,255); | ||||
| 	} | ||||
| }ST_MODBUS_CLIENT_RQTWRTMULTIREG_FRAME; | ||||
|  | ||||
| //<2F><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȧ/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ּĴ<D6BC><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--Server <20><> | ||||
| typedef  struct  __serveRspReadFrame{ | ||||
| 	ST_MODBUS_MBAP_HEADER	stMbapHeader; | ||||
| 	BYTE					bFuncConde; | ||||
| 	BYTE					bLen; | ||||
| 	BYTE					bRtnData[255]; | ||||
| }ST_MODBUS_SERVER_RSPREAD_FRAME; | ||||
|  | ||||
| //<2F><>Ӧд<D3A6><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȧ/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ּĴ<D6BC><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--Server <20><> | ||||
| typedef  struct  __serveRspWrtFrame{ | ||||
| 	ST_MODBUS_MBAP_HEADER	stMbapHeader; | ||||
| 	BYTE					bFuncConde; | ||||
| 	WORD					wStartAddr; | ||||
| 	WORD					wRegNum; | ||||
| }ST_MODBUS_SERVER_RSPWRT_FRAME; | ||||
|  | ||||
| //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ֡ | ||||
| typedef  struct  __serverRspErrFrame{ | ||||
| 	ST_MODBUS_MBAP_HEADER	stMbapHeader; | ||||
| 	BYTE					bFuncConde; | ||||
| 	BYTE					bErrCode; | ||||
| }ST_MODBUS_SERVER_RSPERR_FRAME; | ||||
|  | ||||
| ////=========================================================================================================== | ||||
| //------------<2D><><EFBFBD>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD>PCͨ<43><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6> | ||||
| typedef  enum   __enumpcCommFuncCode{ | ||||
| 	EN_PCCOMM_TRANSDATA			=0x51,		//HMI--->PC | ||||
| 	EN_PCCOMM_WORKPARASET		=0x52,		//PC---->HMI | ||||
| 	EN_PCCOMM_SAMPLEPARASET		=0x53,		//PC---->HMI | ||||
| 	EN_PCCOMM_DEVSTARTSTOP		=0x54,		//PC---->HMI | ||||
| 	EN_PCCOMM_HISTORYDATARQT	=0x55,		//PC---->HMI | ||||
|  | ||||
| 	EN_PCCOMM_TRANSDATA_RSP		=0x61,		//PC---->HMI | ||||
| 	EN_PCCOMM_WORKPARASET_RSP	=0x62,		//HMI--->PC | ||||
| 	EN_PCCOMM_SAMPLEPARASET_RSP =0x63,		//HMI--->PC | ||||
| 	EN_PCCOMM_DEVSTARTSTOP_RSP	=0x64		//HMI--->PC | ||||
|  | ||||
| }EN_NUM_PCCOMM_FUNCCODE; | ||||
|  | ||||
|  | ||||
| //<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9> | ||||
| typedef  struct	  __devSampleData{ | ||||
| 	int		iDevID; | ||||
| 	DWORD	dwIPAddr; | ||||
| 	WORD	wPulseFreq; | ||||
| 	float	fDcVolt; | ||||
| 	float	fDcCurr; | ||||
| 	float	fPulseVolt; | ||||
| 	float	fPulseCurr; | ||||
| 	float	fEnvTemprature; | ||||
| 	float	fEnvHumidity; | ||||
| 	float   fSupplyVolt; | ||||
| 	float	fSupplyCurr; | ||||
| 	float	fRectiferDC; | ||||
| 	float	fDcIgbtTemp; | ||||
| 	float	fPsIgbtTemp; | ||||
| 	BYTE	bSampleTime[6]; | ||||
| 	__devSampleData(){ | ||||
| 		iDevID		=0; | ||||
| 		dwIPAddr	=0; | ||||
| 		wPulseFreq	=0; | ||||
| 		fDcVolt		=0; | ||||
| 		fDcCurr		=0; | ||||
| 		fPulseVolt	=0; | ||||
| 		fPulseCurr	=0; | ||||
| 		fEnvHumidity=0; | ||||
| 		fEnvTemprature =0; | ||||
| 		fSupplyVolt	=0; | ||||
| 		fSupplyCurr =0; | ||||
| 		fRectiferDC =0; | ||||
| 		fDcIgbtTemp =0; | ||||
| 		fPsIgbtTemp =0; | ||||
| 		memset(bSampleTime,0,6); | ||||
| 	} | ||||
| }ST_DEVSAMPLE_DATA; | ||||
|  | ||||
| //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| typedef  struct  __devWorkParaFromPC{ | ||||
| 	int		iDevID; | ||||
| 	DWORD	dwIPAddr; | ||||
| 	WORD	wPulseFreq; | ||||
| 	float	fDcVolt; | ||||
| 	float	fDcCurr; | ||||
| 	float	fPulseVolt; | ||||
| 	float	fPulseCurr; | ||||
| 	char    szDevName[32]; | ||||
| 	char    szDevIPAddr[32]; | ||||
| 	__devWorkParaFromPC(){ | ||||
| 		iDevID		=0; | ||||
| 		dwIPAddr	=0; | ||||
| 		wPulseFreq	=0; | ||||
| 		fDcVolt		=0; | ||||
| 		fDcCurr		=0; | ||||
| 		fPulseVolt	=0; | ||||
| 		fPulseCurr	=0; | ||||
| 		szDevName[0] ='\0'; | ||||
| 		szDevIPAddr[0] ='\0'; | ||||
| 	} | ||||
| 	__devWorkParaFromPC& operator=(const __devWorkParaFromPC &rhs) | ||||
| 	{ | ||||
| 		this->iDevID	= rhs.iDevID; | ||||
| 		this->dwIPAddr	= rhs.dwIPAddr; | ||||
| 		this->wPulseFreq= rhs.wPulseFreq; | ||||
| 		this->fDcVolt	= rhs.fDcVolt; | ||||
| 		this->fDcCurr	= rhs.fDcCurr; | ||||
| 		this->fPulseVolt= rhs.fPulseVolt; | ||||
| 		this->fPulseCurr= rhs.fPulseCurr; | ||||
| 		strcpy(this->szDevName,rhs.szDevName); | ||||
| 		strcpy(this->szDevIPAddr,rhs.szDevIPAddr); | ||||
|  | ||||
| 		return (*this); | ||||
| 	} | ||||
| }ST_DEVWORKPARA_FROMPC,*PST_DEVWORKPARA_FROMPC; | ||||
|  | ||||
| //<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD> | ||||
| typedef  struct __devSampleParaFromPC{ | ||||
| 	WORD	wSampleIntver; | ||||
| 	BYTE	bIsSavePcOnline; | ||||
| 	__devSampleParaFromPC(){ | ||||
| 		wSampleIntver =0; | ||||
| 		bIsSavePcOnline =0; | ||||
| 	} | ||||
| }ST_SAMPLEPARA_FROMPC; | ||||
|  | ||||
| //<2F>豸<EFBFBD><E8B1B8>ͣ | ||||
| typedef struct  __devStartStopFromPC{ | ||||
| 	int		iDevID; | ||||
| 	DWORD	dwIPAddr; | ||||
| 	BYTE	bIsStart; | ||||
| 	__devStartStopFromPC(){ | ||||
| 		iDevID		=0; | ||||
| 		dwIPAddr	=0; | ||||
| 		bIsStart	=0; | ||||
| 	} | ||||
| }ST_DEVSTARTSTOP_FROMPC; | ||||
|  | ||||
| //<2F><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| typedef struct   __historyRqtFromPC{ | ||||
| 	int		iDevID; | ||||
| 	DWORD	dwIPAddr; | ||||
| 	BYTE	bStartTime[6]; | ||||
| 	BYTE	bStopTime[6]; | ||||
| 	__historyRqtFromPC(){ | ||||
| 		iDevID		=0; | ||||
| 		dwIPAddr	=0; | ||||
| 		memset(bStartTime,0,6); | ||||
| 		memset(bStopTime,0,6); | ||||
| 	} | ||||
| }ST_HISTORYRQT_FROMPC; | ||||
|  | ||||
| #pragma pack () | ||||
							
								
								
									
										
											BIN
										
									
								
								Plugin/Driver/Driver.rc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Plugin/Driver/Driver.rc
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										243
									
								
								Plugin/Driver/Driver.vcxproj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										243
									
								
								Plugin/Driver/Driver.vcxproj
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,243 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||
|   <ItemGroup Label="ProjectConfigurations"> | ||||
|     <ProjectConfiguration Include="Debug|Win32"> | ||||
|       <Configuration>Debug</Configuration> | ||||
|       <Platform>Win32</Platform> | ||||
|     </ProjectConfiguration> | ||||
|     <ProjectConfiguration Include="Release|Win32"> | ||||
|       <Configuration>Release</Configuration> | ||||
|       <Platform>Win32</Platform> | ||||
|     </ProjectConfiguration> | ||||
|     <ProjectConfiguration Include="Debug|x64"> | ||||
|       <Configuration>Debug</Configuration> | ||||
|       <Platform>x64</Platform> | ||||
|     </ProjectConfiguration> | ||||
|     <ProjectConfiguration Include="Release|x64"> | ||||
|       <Configuration>Release</Configuration> | ||||
|       <Platform>x64</Platform> | ||||
|     </ProjectConfiguration> | ||||
|   </ItemGroup> | ||||
|   <PropertyGroup Label="Globals"> | ||||
|     <ProjectGuid>{8BBB60C1-510D-47BC-8FD2-E14E9EA3A156}</ProjectGuid> | ||||
|     <RootNamespace>VcsClient</RootNamespace> | ||||
|     <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||||
|     <Keyword>MFCProj</Keyword> | ||||
|   </PropertyGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>true</UseDebugLibraries> | ||||
|     <PlatformToolset>v143</PlatformToolset> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|     <UseOfMfc>Dynamic</UseOfMfc> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>false</UseDebugLibraries> | ||||
|     <PlatformToolset>v143</PlatformToolset> | ||||
|     <WholeProgramOptimization>true</WholeProgramOptimization> | ||||
|     <CharacterSet>Unicode</CharacterSet> | ||||
|     <UseOfMfc>Dynamic</UseOfMfc> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>true</UseDebugLibraries> | ||||
|     <PlatformToolset>v143</PlatformToolset> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|     <UseOfMfc>Dynamic</UseOfMfc> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>false</UseDebugLibraries> | ||||
|     <PlatformToolset>v143</PlatformToolset> | ||||
|     <WholeProgramOptimization>true</WholeProgramOptimization> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|     <UseOfMfc>Dynamic</UseOfMfc> | ||||
|   </PropertyGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||||
|   <ImportGroup Label="ExtensionSettings"> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="Shared"> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <PropertyGroup Label="UserMacros" /> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <LinkIncremental>true</LinkIncremental> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||||
|     <LinkIncremental>true</LinkIncremental> | ||||
|     <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\Agv</OutDir> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||||
|     <LinkIncremental>false</LinkIncremental> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||||
|     <LinkIncremental>false</LinkIncremental> | ||||
|     <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\Agv</OutDir> | ||||
|   </PropertyGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <ClCompile> | ||||
|       <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <Optimization>Disabled</Optimization> | ||||
|       <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <SDLCheck>false</SDLCheck> | ||||
|       <AdditionalIncludeDirectories>E:\work\tank_svn\shiyu\project\fan\warehouse\code\cpp\vcs-client\Inc\json\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Windows</SubSystem> | ||||
|     </Link> | ||||
|     <Midl> | ||||
|       <MkTypLibCompatible>false</MkTypLibCompatible> | ||||
|       <ValidateAllParameters>true</ValidateAllParameters> | ||||
|       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|     </Midl> | ||||
|     <ResourceCompile> | ||||
|       <Culture>0x0804</Culture> | ||||
|       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ResourceCompile> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||||
|     <ClCompile> | ||||
|       <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <Optimization>Disabled</Optimization> | ||||
|       <PreprocessorDefinitions>_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <SDLCheck>false</SDLCheck> | ||||
|       <AdditionalIncludeDirectories>$(SolutionDir)3rdparty\json\inc;$(SolutionDir)CCEXPipe;$(SolutionDir)3rdparty\curl\inc;..\modbus;$(SolutionDir)3rdparty\can\inc;$(SolutionDir)3rdparty\sqlite;$(SolutionDir)3rdparty\whttp-server-core;$(SolutionDir)3rdparty\openssl\inc;$(SolutionDir)3rdparty\pthread\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Windows</SubSystem> | ||||
|       <AdditionalDependencies>libcurl.lib;ControlCAN.lib;libcrypto.lib;libssl.lib;pthreadVC2.lib</AdditionalDependencies> | ||||
|       <AdditionalLibraryDirectories>$(SolutionDir)3rdparty\curl\lib\x64;$(SolutionDir)$(Platform)\$(Configuration)\;$(SolutionDir)3rdparty\modbus\lib;$(SolutionDir)3rdparty\can\lib;$(SolutionDir)3rdparty\pthread\lib\x64;$(SolutionDir)3rdparty\openssl\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||||
|     </Link> | ||||
|     <Midl> | ||||
|       <MkTypLibCompatible>false</MkTypLibCompatible> | ||||
|       <ValidateAllParameters>true</ValidateAllParameters> | ||||
|       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|     </Midl> | ||||
|     <ResourceCompile> | ||||
|       <Culture>0x0804</Culture> | ||||
|       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ResourceCompile> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||||
|     <ClCompile> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <PrecompiledHeader>Use</PrecompiledHeader> | ||||
|       <Optimization>MaxSpeed</Optimization> | ||||
|       <FunctionLevelLinking>true</FunctionLevelLinking> | ||||
|       <IntrinsicFunctions>true</IntrinsicFunctions> | ||||
|       <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <SDLCheck>true</SDLCheck> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Windows</SubSystem> | ||||
|       <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||||
|       <OptimizeReferences>true</OptimizeReferences> | ||||
|     </Link> | ||||
|     <Midl> | ||||
|       <MkTypLibCompatible>false</MkTypLibCompatible> | ||||
|       <ValidateAllParameters>true</ValidateAllParameters> | ||||
|       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|     </Midl> | ||||
|     <ResourceCompile> | ||||
|       <Culture>0x0804</Culture> | ||||
|       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ResourceCompile> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||||
|     <ClCompile> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||||
|       <Optimization>MaxSpeed</Optimization> | ||||
|       <FunctionLevelLinking>true</FunctionLevelLinking> | ||||
|       <IntrinsicFunctions>true</IntrinsicFunctions> | ||||
|       <PreprocessorDefinitions>_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <SDLCheck>false</SDLCheck> | ||||
|       <AdditionalIncludeDirectories>$(SolutionDir)3rdparty\json\inc;$(SolutionDir)CCEXPipe;$(SolutionDir)3rdparty\curl\inc;..\modbus;$(SolutionDir)3rdparty\can\inc;$(SolutionDir)3rdparty\sqlite;$(SolutionDir)3rdparty\whttp-server-core;$(SolutionDir)3rdparty\pthread\inc;$(SolutionDir)3rdparty\openssl\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Windows</SubSystem> | ||||
|       <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||||
|       <OptimizeReferences>true</OptimizeReferences> | ||||
|       <AdditionalLibraryDirectories>$(SolutionDir)3rdparty\curl\lib\x64;$(SolutionDir)$(Platform)\$(Configuration)\;$(SolutionDir)3rdparty\modbus\lib;$(SolutionDir)3rdparty\can\lib;$(SolutionDir)3rdparty\pthread\lib\x64;$(SolutionDir)3rdparty\openssl\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||||
|       <AdditionalDependencies>libcurl.lib;ControlCAN.lib;libcrypto.lib;libssl.lib;pthreadVC2.lib</AdditionalDependencies> | ||||
|       <UACExecutionLevel>AsInvoker</UACExecutionLevel> | ||||
|     </Link> | ||||
|     <Midl> | ||||
|       <MkTypLibCompatible>false</MkTypLibCompatible> | ||||
|       <ValidateAllParameters>true</ValidateAllParameters> | ||||
|       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|     </Midl> | ||||
|     <ResourceCompile> | ||||
|       <Culture>0x0804</Culture> | ||||
|       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ResourceCompile> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemGroup> | ||||
|     <Text Include="ReadMe.txt" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="..\..\3rdparty\whttp-server-core\LockQueue.hpp" /> | ||||
|     <ClInclude Include="..\..\3rdparty\whttp-server-core\unistd.h" /> | ||||
|     <ClInclude Include="CEXMemFileQueue.h" /> | ||||
|     <ClInclude Include="CEXVirtualListCtrl.h" /> | ||||
|     <ClInclude Include="ColoredListCtrl.h" /> | ||||
|     <ClInclude Include="DriverMainDlg.h" /> | ||||
|     <ClInclude Include="Map.h" /> | ||||
|     <ClInclude Include="PluginDriver.h" /> | ||||
|     <ClInclude Include="Resource.h" /> | ||||
|     <ClInclude Include="stdafx.h" /> | ||||
|     <ClInclude Include="targetver.h" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_reader.cpp" /> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_value.cpp" /> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_writer.cpp" /> | ||||
|     <ClCompile Include="CEXMemFileQueue.cpp" /> | ||||
|     <ClCompile Include="CEXVirtualListCtrl.cpp" /> | ||||
|     <ClCompile Include="ColoredListCtrl.cpp" /> | ||||
|     <ClCompile Include="DriverMainDlg.cpp" /> | ||||
|     <ClCompile Include="PluginDriver.cpp" /> | ||||
|     <ClCompile Include="stdafx.cpp"> | ||||
|       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> | ||||
|       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> | ||||
|       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> | ||||
|       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> | ||||
|     </ClCompile> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ResourceCompile Include="Driver.rc" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <None Include="res\Driver.rc2" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Image Include="res\Driver.ico" /> | ||||
|   </ItemGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||||
|   <ImportGroup Label="ExtensionTargets"> | ||||
|   </ImportGroup> | ||||
|   <ProjectExtensions> | ||||
|     <VisualStudio> | ||||
|       <UserProperties RESOURCE_FILE="" /> | ||||
|     </VisualStudio> | ||||
|   </ProjectExtensions> | ||||
| </Project> | ||||
							
								
								
									
										50
									
								
								Plugin/Driver/Driver.vcxproj.filters
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								Plugin/Driver/Driver.vcxproj.filters
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="stdafx.cpp" /> | ||||
|     <ClCompile Include="ColoredListCtrl.cpp" /> | ||||
|     <ClCompile Include="CEXMemFileQueue.cpp" /> | ||||
|     <ClCompile Include="CEXVirtualListCtrl.cpp" /> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_reader.cpp"> | ||||
|       <Filter>json</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_value.cpp"> | ||||
|       <Filter>json</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_writer.cpp"> | ||||
|       <Filter>json</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="PluginDriver.cpp" /> | ||||
|     <ClCompile Include="DriverMainDlg.cpp" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="Resource.h" /> | ||||
|     <ClInclude Include="stdafx.h" /> | ||||
|     <ClInclude Include="targetver.h" /> | ||||
|     <ClInclude Include="ColoredListCtrl.h" /> | ||||
|     <ClInclude Include="CEXMemFileQueue.h" /> | ||||
|     <ClInclude Include="CEXVirtualListCtrl.h" /> | ||||
|     <ClInclude Include="Map.h" /> | ||||
|     <ClInclude Include="..\..\3rdparty\whttp-server-core\LockQueue.hpp" /> | ||||
|     <ClInclude Include="..\..\3rdparty\whttp-server-core\unistd.h" /> | ||||
|     <ClInclude Include="PluginDriver.h" /> | ||||
|     <ClInclude Include="DriverMainDlg.h" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ResourceCompile Include="Driver.rc" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Image Include="res\Driver.ico" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <None Include="res\Driver.rc2" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Text Include="ReadMe.txt" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Filter Include="json"> | ||||
|       <UniqueIdentifier>{263f81d2-2eb0-4ed0-aef7-dc7f1cd0dad3}</UniqueIdentifier> | ||||
|     </Filter> | ||||
|   </ItemGroup> | ||||
| </Project> | ||||
							
								
								
									
										1104
									
								
								Plugin/Driver/DriverMainDlg.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1104
									
								
								Plugin/Driver/DriverMainDlg.cpp
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										153
									
								
								Plugin/Driver/DriverMainDlg.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										153
									
								
								Plugin/Driver/DriverMainDlg.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,153 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "CEXVirtualListCtrl.h" | ||||
| #include "ControlCAN.h" | ||||
| // CCanDeviceDlg <20>Ի<EFBFBD><D4BB><EFBFBD> | ||||
|  | ||||
|  | ||||
|  | ||||
| typedef  struct ST_DRIVER_CONTROL { | ||||
| 	int Drive_Speed;         //<2F><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD> | ||||
| 	int Diversion_Position;  //ת<><D7AA><EFBFBD>Ƕ<EFBFBD> | ||||
| 	int Zero_Angle;          //ת<><D7AA><EFBFBD><EFBFBD><EFBFBD>Ƚǣ<C8BD><C7A3><EFBFBD><EFBFBD>ݻ<EFBFBD>е<EFBFBD>ṹ<EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD>Ƕȣ<C7B6> | ||||
| 	int MIX_Angle_R;		 //<2F>ֶ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>Ƕ<EFBFBD> | ||||
| 	int MAN_Angle_L;		 //<2F>ֶ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>Сת<D0A1><D7AA><EFBFBD>Ƕ<EFBFBD> | ||||
| 	int AutoMAX_Angle;		 //<2F>Զ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>Ƕ<EFBFBD>	 | ||||
| 	int AutoMIN_Angle;       //<2F>Զ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>Ƕ<EFBFBD> | ||||
| 	float SPEEDPAR;          //<2F><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>ϵ<EFBFBD><CFB5> | ||||
|  | ||||
| 	ST_DRIVER_CONTROL()  | ||||
| 	{ | ||||
| 		Drive_Speed        = 0; | ||||
| 		Zero_Angle         = 1320000;  //<2F><><EFBFBD><EFBFBD>  <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2108000  504000 | ||||
| 		MIX_Angle_R        = 504000;  // Zero_Angle + 850000; | ||||
| 		MAN_Angle_L        = 2108000; // Zero_Angle - 850000; | ||||
| 		AutoMIN_Angle      = Zero_Angle - 700000; | ||||
| 		AutoMAX_Angle      = Zero_Angle + 700000; | ||||
| 		Diversion_Position = Zero_Angle; | ||||
| 		SPEEDPAR		   = 1; | ||||
| 	} | ||||
|  | ||||
| } ST_DRIVER_CONTROL; | ||||
|  | ||||
| typedef struct ST_SENSOR_DATA { | ||||
| 	short   FMagnetism_Offset;    //ǰ<><C7B0><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	uint8_t FMagnetism_Valid;     //ǰ<><C7B0><EFBFBD><EFBFBD>1<EFBFBD><31>Ч 0<><30>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD> | ||||
| 	uint8_t FMagnetism_ALLTrue;   //16<31><36><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD><E2B5BD><EFBFBD><EFBFBD>1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>16<31><36><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2B5BD> | ||||
| 	short   BMagnetism_Offset;    //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	uint8_t BMagnetism_Valid;     //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31>Ч 0<><30>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD> | ||||
| 	uint8_t BMagnetism_ALLTrue;   //16<31><36><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD><E2B5BD><EFBFBD><EFBFBD>1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	uint8_t RFID_Point;           //RFID<49><44>ǩλ<C7A9><CEBB> | ||||
| 	uint8_t Battery_SOC;          //<2F><><EFBFBD>ص<EFBFBD><D8B5><EFBFBD> | ||||
|  | ||||
| 	ST_SENSOR_DATA()              //Ĭ<>Ϲ<EFBFBD><CFB9>캯<EFBFBD><ECBAAF> | ||||
| 	{ | ||||
| 		FMagnetism_Offset  = 0;  | ||||
| 		FMagnetism_Valid   = 0;  | ||||
| 		FMagnetism_ALLTrue = 0; | ||||
| 		BMagnetism_Offset  = 0; | ||||
| 		BMagnetism_Valid   = 0; | ||||
| 		BMagnetism_ALLTrue = 0; | ||||
| 		RFID_Point		   = 0; | ||||
| 		Battery_SOC        = 0; | ||||
| 	} | ||||
|  | ||||
| } ST_SENSOR_DATA; | ||||
|  | ||||
|  | ||||
| class CDriverMainDlg : public CDialogEx | ||||
| { | ||||
| 	DECLARE_DYNAMIC(CDriverMainDlg) | ||||
|  | ||||
| public: | ||||
| 	CDriverMainDlg(CWnd* pParent = NULL);   // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF> | ||||
| 	virtual ~CDriverMainDlg(); | ||||
|  | ||||
| // <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| #ifdef AFX_DESIGN_TIME | ||||
| 	enum { IDD = IDD_DEV_CAN_DLG }; | ||||
| #endif | ||||
|  | ||||
| protected: | ||||
| 	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV ֧<><D6A7> | ||||
| 	afx_msg void OnCheckCanrxEn(); | ||||
|  | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
| public: | ||||
| 	int     m_nSendFrameFormatIdx0; | ||||
| 	int		m_nSendFrameTypeIdx0; | ||||
| 	int     m_nSendFrameFormatIdx1; | ||||
| 	int		m_nSendFrameTypeIdx1; | ||||
| 	int		m_nSendCanIndex; | ||||
| 	int		m_nRecvCanIndex; | ||||
| 	int		m_nDevType; | ||||
| public: | ||||
| 	CString m_iniPath; | ||||
| 	int     m_DevType; | ||||
| 	int     m_DevIndex; | ||||
| 	BOOL    m_bOpenCan; | ||||
| 	BOOL    m_bCanRxEn; | ||||
| 	BOOL    m_bAutoRefresh; | ||||
| 	BOOL    m_bAutoSend; | ||||
| 	BOOL    m_bAutoSend2; | ||||
| 	CString	m_strSendID; | ||||
| 	CStatic m_txFMagneticOffset; | ||||
| 	CStatic m_txBMagneticOffset; | ||||
| 	CStatic m_txRFIDID; | ||||
| 	 | ||||
| 	CString m_strSendData; | ||||
| 	BOOL    m_StopSendFlag; | ||||
| 	BOOL    m_StopSendFlag2; | ||||
|  | ||||
| 	void	Drive_enable();  //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> | ||||
| 	void    Drive_disable(); //ʧ<><CAA7> | ||||
| 	 | ||||
| 	int    Auto_Stop(); | ||||
| 	int    Auto_Forward(float speedpar); | ||||
| 	int    Auto_Backward(float speedpar); | ||||
| 	int    Auto_EStop(); | ||||
| 	void   Control_Mode_Reset(); | ||||
|  | ||||
| 	void    ReadConfigFromIni(); | ||||
| 	void    InitVirtualList(); | ||||
| 	BOOL    OpenCanDevice(); | ||||
| 	void    UpdateCanStatue(BOOL  bStatue); | ||||
| 	void    ProcessPipeMsg(int lMsgId, char* pData, int lLen); | ||||
| 	void    SendCanData(int nDevIdx, int nCanIdx, int nFrameType, int nFrameFormat, UINT32 acFrameId, char acFrameData[8]); | ||||
| 	int     Str2Hex(CString str); | ||||
| 	int     HexChar(char c); | ||||
| 	//CPluginMainDialog  *m_pMainWnd; | ||||
| 	virtual BOOL OnInitDialog(); | ||||
| 	static  UINT ReceiveCanThread(LPVOID v); | ||||
| 	static  UINT SendCanThread(LPVOID v); | ||||
| 	static  UINT SendCanThread2(LPVOID v); | ||||
| 	void    WriteVirtualList(CString strFrameId, CString strFrameData, int nTxRx = 0, int nCanIdx = 0, int nFrameType = 0, int nFrameFormat = 0); | ||||
|  | ||||
| public: | ||||
| 	CEXVirtualListCtrl	*m_pstVirtualList; | ||||
| 	afx_msg void OnBnClickedBtnSendMan(); | ||||
| 	afx_msg void OnBnClickedAutoSend(); | ||||
|  | ||||
| 	CEXMemFileQueue* m_pQueue; | ||||
| 	CString          m_strDataDir; | ||||
|  | ||||
| 	volatile int     m_nAgvAction;         | ||||
| 	int              m_nAgvReturnState; | ||||
|  | ||||
| 	afx_msg void OnBnClickedCheckAutoRefreshShow(); | ||||
| 	afx_msg void OnBnClickedBtnSendMan2(); | ||||
| 	afx_msg void OnBnClickedAutoSend2(); | ||||
|  | ||||
| 	ST_DRIVER_CONTROL   m_stDrvierControl; | ||||
| 	ST_SENSOR_DATA      m_stSensorData; | ||||
|  | ||||
| 	void AnalysiseCanData(int nCanIndex, VCI_CAN_OBJ objCan); | ||||
| 	void CalculateAutoCanParam(); | ||||
| 	void CalculateManualCanParam(); | ||||
| 	void SendCanData(); | ||||
| 	 | ||||
| 	afx_msg void OnBnClickedButtonAgvstop(); | ||||
| 	afx_msg void OnBnClickedButtonAgvestop(); | ||||
| 	afx_msg void OnBnClickedButtonAgvforward(); | ||||
| 	afx_msg void OnBnClickedButtonAgvbackward(); | ||||
| }; | ||||
							
								
								
									
										23
									
								
								Plugin/Driver/Map.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								Plugin/Driver/Map.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "Map.h" | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| 	POS_UNLOAD                 = 1,   //AGVж<56><D0B6><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	POS_UNLOAD_SLOW_DOWN       = 2,   //ж<><D0B6><EFBFBD><EFBFBD><EFBFBD>ٵ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>״<EFBFBD> | ||||
| 	POS_CLOSE_SHOP_ROLLER_DOOR = 3,   //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD> | ||||
| 	POS_OPEN_SHOP_ROLLER_DOOR  = 4,   //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD> | ||||
| 	POS_MANHOLE_COVER_1        = 5,   //<2F><><EFBFBD><EFBFBD>#1 | ||||
| 	POS_MANHOLE_COVER_2        = 6,   //<2F><><EFBFBD><EFBFBD>#2 | ||||
| 	//POS_BOLLARD_SLOW_DOWN_1    = 6,   //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٵ<EFBFBD>#1 | ||||
| 	POS_BOLLARD_STOP_1         = 7,   //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD>#1 | ||||
| 	POS_MANHOLE_COVER_3        = 8,   //<2F><><EFBFBD><EFBFBD>#3 | ||||
| 	POS_MANHOLE_COVER_4        = 9,   //<2F><><EFBFBD><EFBFBD>#4 | ||||
| 	//POS_BOLLARD_SLOW_DOWN_2    = 10,  //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٵ<EFBFBD>#2 | ||||
| 	POS_BOLLARD_STOP_2         = 10,  //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD>#2 | ||||
| 	POS_MANHOLE_COVER_5        = 11,  //<2F><><EFBFBD><EFBFBD>#5 | ||||
| 	POS_MANHOLE_COVER_6        = 12,  //<2F><><EFBFBD><EFBFBD>#6 | ||||
| 	POS_LOAD_SLOW_DOWN         = 13,  //װ<><D7B0><EFBFBD><EFBFBD><EFBFBD>ٵ<EFBFBD> | ||||
| 	POS_LOAD                   = 14,  //װ<><D7B0><EFBFBD><EFBFBD> | ||||
| }ENUM_LOCATION_MAP; //<2F><>ͼ<EFBFBD><CDBC>λ | ||||
							
								
								
									
										164
									
								
								Plugin/Driver/PluginDriver.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										164
									
								
								Plugin/Driver/PluginDriver.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,164 @@ | ||||
|  | ||||
| // Vcs-Client.cpp : <20><><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA> | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| #include "PluginDriver.h" | ||||
| #include "DriverMainDlg.h" | ||||
|  | ||||
| #ifdef _DEBUG | ||||
| #define new DEBUG_NEW | ||||
| #endif | ||||
|  | ||||
| CCEXPipeClientBase* g_pstPipeClient = CCEXPipeClientBase::CreateObj(); | ||||
| // CVcsClientApp | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CPluginDriver, CWinApp) | ||||
| 	ON_COMMAND(ID_HELP, &CWinApp::OnHelp) | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
|  | ||||
| // CVcsClientApp <20><><EFBFBD><EFBFBD> | ||||
|  | ||||
| CPluginDriver::CPluginDriver() | ||||
| { | ||||
| 	// ֧<><D6A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; | ||||
|  | ||||
| 	// TODO: <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룬 | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> InitInstance <20><> | ||||
| } | ||||
|  | ||||
|  | ||||
| // Ψһ<CEA8><D2BB>һ<EFBFBD><D2BB> CVcsClientApp <20><><EFBFBD><EFBFBD> | ||||
|  | ||||
| CPluginDriver theApp; | ||||
| HANDLE  hmutex; | ||||
|  | ||||
| // CVcsClientApp <20><>ʼ<EFBFBD><CABC> | ||||
|  | ||||
|  | ||||
| BOOL CPluginDriver::InitInstance() | ||||
| { | ||||
| 	 | ||||
| 	hmutex = CreateMutexA(nullptr, FALSE, "agv-plugin-driver"); | ||||
| 	int err = GetLastError(); | ||||
| 	if (err == ERROR_ALREADY_EXISTS) { | ||||
| 		CloseHandle(hmutex); | ||||
| 		hmutex = nullptr; | ||||
| 		//AfxMessageBox("<22><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>."); | ||||
| 		return FALSE; | ||||
| 	} | ||||
|  | ||||
| 	CHAR dir[1000] = { 0 }; | ||||
| 	int filelen = GetModuleFileName(NULL, dir, 1000); | ||||
| 	//WriteLog(dir); | ||||
| 	int i = filelen; | ||||
| 	while (dir[i] != '\\')i--; | ||||
| 	dir[i] = '\0'; | ||||
| 	m_strModulePath = dir; | ||||
|  | ||||
|  | ||||
| 	 | ||||
| 	// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Windows XP <20>ϵ<EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD>嵥ָ<E5B5A5><D6B8>Ҫ | ||||
| 	// ʹ<><CAB9> ComCtl32.dll <20>汾 6 <20><><EFBFBD><EFBFBD><EFBFBD>߰汾<DFB0><E6B1BE><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF>ӻ<EFBFBD><D3BB><EFBFBD>ʽ<EFBFBD><CABD> | ||||
| 	//<2F><><EFBFBD><EFBFBD>Ҫ InitCommonControlsEx()<29><>  <20><><EFBFBD><EFBFBD><F2A3ACBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD> | ||||
| 	INITCOMMONCONTROLSEX InitCtrls; | ||||
| 	InitCtrls.dwSize = sizeof(InitCtrls); | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD> | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC>ࡣ | ||||
| 	InitCtrls.dwICC = ICC_WIN95_CLASSES; | ||||
| 	InitCommonControlsEx(&InitCtrls); | ||||
|  | ||||
| 	CWinApp::InitInstance(); | ||||
|  | ||||
|  | ||||
| 	AfxEnableControlContainer(); | ||||
|  | ||||
| 	// <20><><EFBFBD><EFBFBD> shell <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><D4B7>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	// <20>κ<EFBFBD> shell <20><><EFBFBD><EFBFBD>ͼ<EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD> shell <20>б<EFBFBD><D0B1><EFBFBD>ͼ<EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD> | ||||
| 	CShellManager *pShellManager = new CShellManager; | ||||
|  | ||||
| 	// <20><><EFBFBD>Windows Native<76><65><EFBFBD>Ӿ<EFBFBD><D3BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD> MFC <20>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); | ||||
|  | ||||
| 	// <20><><EFBFBD><D7BC>ʼ<EFBFBD><CABC> | ||||
| 	// <20><><EFBFBD><EFBFBD>δʹ<CEB4><CAB9><EFBFBD><EFBFBD>Щ<EFBFBD><D0A9><EFBFBD>ܲ<EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD>С | ||||
| 	// <20><><EFBFBD>տ<EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>ļ<EFBFBD><C4BC>Ĵ<EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>Ӧ<EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	// <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ض<EFBFBD><D8B6><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ洢<DAB4><E6B4A2><EFBFBD>õ<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	// TODO: Ӧ<>ʵ<EFBFBD><CAB5>ĸ<DEB8><C4B8>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>˾<EFBFBD><CBBE><EFBFBD><EFBFBD>֯<EFBFBD><D6AF> | ||||
| 	SetRegistryKey(_T("Ӧ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵı<EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD>")); | ||||
|  | ||||
|  | ||||
| 	 | ||||
|  | ||||
| 	CDriverMainDlg dlg; | ||||
| 	m_pMainWnd = &dlg; | ||||
| 	INT_PTR nResponse = dlg.DoModal(); | ||||
| 	if (nResponse == IDOK) | ||||
| 	{ | ||||
| 		// TODO: <20>ڴ˷<DAB4><CBB7>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> | ||||
| 		//  <20><>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>رնԻ<D5B6><D4BB><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD> | ||||
| 	} | ||||
| 	else if (nResponse == IDCANCEL) | ||||
| 	{ | ||||
| 		// TODO: <20>ڴ˷<DAB4><CBB7>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> | ||||
| 		//  <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>رնԻ<D5B6><D4BB><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD> | ||||
| 	} | ||||
| 	else if (nResponse == -1) | ||||
| 	{ | ||||
| 		TRACE(traceAppMsg, 0, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20>Ի<EFBFBD><D4BB><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>\n"); | ||||
| 		TRACE(traceAppMsg, 0, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶԻ<DAB6><D4BB><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> MFC <20>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS<47><53>\n"); | ||||
| 	} | ||||
|  | ||||
| 	// ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD>洴<EFBFBD><E6B4B4><EFBFBD><EFBFBD> shell <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	if (pShellManager != NULL) | ||||
| 	{ | ||||
| 		delete pShellManager; | ||||
| 	} | ||||
|  | ||||
| #ifndef _AFXDLL | ||||
| 	ControlBarCleanUp(); | ||||
| #endif | ||||
|  | ||||
| 	// <20><><EFBFBD>ڶԻ<DAB6><D4BB><EFBFBD><EFBFBD>ѹرգ<D8B1><D5A3><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD> FALSE <20>Ա<EFBFBD><D4B1>˳<EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	//  <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>á<EFBFBD> | ||||
| 	return FALSE; | ||||
| } | ||||
|  | ||||
|  | ||||
| CString CPluginDriver::SendMsg2Platform(CString strReceiver, int nMsgType, Json::Value param) | ||||
| { | ||||
| 	LogOutToFile("DRIVER::SendMsg2Platform Begin"); | ||||
|  | ||||
| 	Json::Value root; | ||||
| 	root["sender"] = "DRIVER"; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,SwingArm | ||||
| 	root["receiver"] = strReceiver.GetBuffer(); | ||||
|  | ||||
| 	/****************************************************** | ||||
| 	nMsgTypeʹ<65><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	CREATE_TASK_RET      = 2,       //WCS->WMS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	EXECUTE_TASK_RET     = 4,       //WCS->WMS ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	DEVICE_STATE_REPORT  = 5,       //WCS->WMS <20>豸״̬<D7B4>ϱ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) | ||||
| 	DEVICE_CONFIG_REQ    = 6,       //WCS->WMS <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ | ||||
| 	*******************************************************/ | ||||
|  | ||||
| 	root["type"] = nMsgType; | ||||
| 	root["params"] = param; | ||||
|  | ||||
| 	Json::FastWriter  writer; | ||||
| 	string strJson = writer.write(root); | ||||
|  | ||||
| 	g_pstPipeClient->SendeMsg(WCS_2_WMS_DATA, (char*)strJson.c_str(), strJson.length()); | ||||
|  | ||||
| 	LogOutToFile("DRIVER::SendMsg2Platform End"); | ||||
|  | ||||
| 	return ""; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										45
									
								
								Plugin/Driver/PluginDriver.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								Plugin/Driver/PluginDriver.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | ||||
|  | ||||
| // Vcs-Client.h : PROJECT_NAME Ӧ<>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> | ||||
| // | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #ifndef __AFXWIN_H__ | ||||
| 	#error "<22>ڰ<EFBFBD><DAB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>stdafx.h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> PCH <20>ļ<EFBFBD>" | ||||
| #endif | ||||
|  | ||||
| #include "resource.h"		// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| #include "CCEXPipeLib.h" | ||||
| #define WM_MSG_ROBOT_TO_MAIN  WM_USER+2000 | ||||
|  | ||||
|  | ||||
| // CVcsClientApp:  | ||||
| // <20>йش<D0B9><D8B4><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>֣<EFBFBD><D6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Vcs-Client.cpp | ||||
| // | ||||
|  | ||||
| class CPluginDriver : public CWinApp | ||||
| { | ||||
| public: | ||||
| 	CPluginDriver(); | ||||
|  | ||||
| // <20><>д | ||||
| public: | ||||
| 	virtual BOOL InitInstance(); | ||||
|  | ||||
| public: | ||||
| 	void    ReadConfigFromIni(); | ||||
|  | ||||
|  | ||||
| public: | ||||
| 	CString        m_strModulePath; | ||||
|  | ||||
| 	ST_CAN_DEVICE  m_stCanDevice; | ||||
|  | ||||
| // ʵ<><CAB5> | ||||
| 	CString SendMsg2Platform(CString strReceiver, int nMsgType, Json::Value param = NULL); | ||||
|  | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
| }; | ||||
|  | ||||
| extern CPluginDriver theApp; | ||||
| extern CCEXPipeClientBase* g_pstPipeClient; | ||||
							
								
								
									
										67
									
								
								Plugin/Driver/ReadMe.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								Plugin/Driver/ReadMe.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,67 @@ | ||||
| ================================================================================ | ||||
|     MICROSOFT 基础类库 : Vcs-Client 项目概述 | ||||
| =============================================================================== | ||||
|  | ||||
| 应用程序向导已为您创建了此 Vcs-Client 应用程序。此应用程序不仅演示 Microsoft 基础类的基本使用方法,还可作为您编写应用程序的起点。 | ||||
|  | ||||
| 本文件概要介绍组成 Vcs-Client 应用程序的每个文件的内容。 | ||||
|  | ||||
| Vcs-Client.vcxproj | ||||
|     这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 | ||||
|  | ||||
| Vcs-Client.vcxproj.filters | ||||
|     这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 | ||||
|  | ||||
| Vcs-Client.h | ||||
|     这是应用程序的主头文件。 | ||||
|     其中包括其他项目特定的标头(包括 Resource.h),并声明 CVcsClientApp 应用程序类。 | ||||
|  | ||||
| Vcs-Client.cpp | ||||
|     这是包含应用程序类 CVcsClientApp 的主应用程序源文件。 | ||||
|  | ||||
| Vcs-Client.rc | ||||
|     这是程序使用的所有 Microsoft Windows 资源的列表。它包括 RES 子目录中存储的图标、位图和光标。此文件可以直接在 Microsoft Visual C++ 中进行编辑。项目资源包含在 2052 中。 | ||||
|  | ||||
| res\Vcs-Client.ico | ||||
|     这是用作应用程序图标的图标文件。此图标包括在主资源文件 Vcs-Client.rc 中。 | ||||
|  | ||||
| res\VcsClient.rc2 | ||||
|     此文件包含不在 Microsoft Visual C++ 中进行编辑的资源。您应该将不可由资源编辑器编辑的所有资源放在此文件中。 | ||||
|  | ||||
|  | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| 应用程序向导创建一个对话框类: | ||||
|  | ||||
| Vcs-ClientDlg.h、Vcs-ClientDlg.cpp - 对话框 | ||||
|     这些文件包含 CVcsClientDlg 类。此类定义应用程序的主对话框的行为。对话框模板包含在 Vcs-Client.rc 中,该文件可以在 Microsoft Visual C++ 中编辑。 | ||||
|  | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| 其他功能: | ||||
|  | ||||
| ActiveX 控件 | ||||
|     该应用程序包含对使用 ActiveX 控件的支持。 | ||||
|  | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| 其他标准文件: | ||||
|  | ||||
| StdAfx.h, StdAfx.cpp | ||||
|     这些文件用于生成名为 Vcs-Client.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 | ||||
|  | ||||
| Resource.h | ||||
|     这是标准头文件,可用于定义新的资源 ID。Microsoft Visual C++ 将读取并更新此文件。 | ||||
|  | ||||
| Vcs-Client.manifest | ||||
| 	Windows XP 使用应用程序清单文件来描述特定版本的并行程序集的应用程序依赖项。加载程序使用这些信息来从程序集缓存中加载相应的程序集,并保护其不被应用程序访问。应用程序清单可能会包含在内,以作为与应用程序可执行文件安装在同一文件夹中的外部 .manifest 文件进行重新分发,它还可能以资源的形式包含在可执行文件中。 | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| 其他注释: | ||||
|  | ||||
| 应用程序向导使用“TODO:”来指示应添加或自定义的源代码部分。 | ||||
|  | ||||
| 如果应用程序使用共享 DLL 中的 MFC,您将需要重新分发 MFC DLL。如果应用程序所使用的语言与操作系统的区域设置不同,则还需要重新分发相应的本地化资源 mfc110XXX.DLL。 | ||||
| 有关上述话题的更多信息,请参见 MSDN 文档中有关重新分发 Visual C++ 应用程序的部分。 | ||||
|  | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
							
								
								
									
										
											BIN
										
									
								
								Plugin/Driver/res/Driver.ico
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Plugin/Driver/res/Driver.ico
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 17 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Plugin/Driver/res/Driver.rc2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Plugin/Driver/res/Driver.rc2
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Plugin/Driver/resource.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Plugin/Driver/resource.h
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										188
									
								
								Plugin/Driver/stdafx.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										188
									
								
								Plugin/Driver/stdafx.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,188 @@ | ||||
|  | ||||
| // stdafx.cpp : ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Դ<EFBFBD>ļ<EFBFBD> | ||||
| // Vcs-Client.pch <20><><EFBFBD><EFBFBD>ΪԤ<CEAA><D4A4><EFBFBD><EFBFBD>ͷ | ||||
| // stdafx.obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ | ||||
|  | ||||
| #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';//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7B7>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊԭ<CEAA><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>з<EFBFBD> | ||||
| 			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; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| // UTF8<46><38><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>(MultiByte)<29><>ת | ||||
| CString UTF8AndMB_Convert(const CString &strSource, UINT nSourceCodePage, UINT nTargetCodePage) | ||||
| { | ||||
| 	int nSourceLen = strSource.GetLength(); | ||||
| 	int nWideBufLen = MultiByteToWideChar(nSourceCodePage, 0, strSource, -1, NULL, 0); | ||||
|  | ||||
| 	wchar_t* pWideBuf = new wchar_t[nWideBufLen + 1]; | ||||
| 	memset(pWideBuf, 0, (nWideBufLen + 1) * sizeof(wchar_t)); | ||||
|  | ||||
| 	MultiByteToWideChar(nSourceCodePage, 0, strSource, -1, (LPWSTR)pWideBuf, nWideBufLen); | ||||
|  | ||||
| 	char* pMultiBuf = NULL; | ||||
| 	int nMiltiBufLen = WideCharToMultiByte(nTargetCodePage, 0, (LPWSTR)pWideBuf, -1, (char *)pMultiBuf, 0, NULL, NULL); | ||||
|  | ||||
| 	pMultiBuf = new char[nMiltiBufLen + 1]; | ||||
| 	memset(pMultiBuf, 0, nMiltiBufLen + 1); | ||||
|  | ||||
| 	WideCharToMultiByte(nTargetCodePage, 0, (LPWSTR)pWideBuf, -1, (char *)pMultiBuf, nMiltiBufLen, NULL, NULL); | ||||
|  | ||||
| 	CStringA strTarget(pMultiBuf); | ||||
|  | ||||
| 	delete[] pWideBuf; | ||||
| 	delete[] pMultiBuf; | ||||
|  | ||||
| 	return strTarget; | ||||
| } | ||||
|  | ||||
| CStringA UTF8ToMB(const CStringA& utf8Str) | ||||
| { | ||||
| 	if (IsTextUTF8(utf8Str, utf8Str.GetLength())) | ||||
| 	{ | ||||
| 		return UTF8AndMB_Convert(utf8Str, CP_UTF8, CP_ACP); | ||||
| 	} | ||||
| 	return utf8Str; | ||||
| } | ||||
|  | ||||
|  | ||||
| bool IsTextUTF8(const char* str, ULONGLONG length) | ||||
| { | ||||
| 	DWORD nBytes = 0;//UFT8<54><38><EFBFBD><EFBFBD>1-6<><36><EFBFBD>ֽڱ<D6BD><DAB1><EFBFBD>,ASCII<49><49>һ<EFBFBD><D2BB><EFBFBD>ֽ<EFBFBD> | ||||
| 	UCHAR chr; | ||||
| 	bool bAllAscii = true; //<2F><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ASCII, ˵<><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>UTF-8 | ||||
| 	for (int i = 0; i < length; i++) | ||||
| 	{ | ||||
| 		chr = *(str + i); | ||||
| 		if ((chr & 0x80) != 0) // <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ASCII<49><49><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,˵<><CBB5><EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD>UTF-8,ASCII<49><49>7λ<37><CEBB><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֽڴ<D6BD>,<2C><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϊ0,o0xxxxxxx | ||||
| 			bAllAscii = false; | ||||
| 		if (nBytes == 0) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ASCII<49><49>,Ӧ<><D3A6><EFBFBD>Ƕ<EFBFBD><C7B6>ֽڷ<D6BD>,<2C><><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD> | ||||
| 		{ | ||||
| 			if (chr >= 0x80) | ||||
| 			{ | ||||
| 				if (chr >= 0xFC && chr <= 0xFD) | ||||
| 					nBytes = 6; | ||||
| 				else if (chr >= 0xF8) | ||||
| 					nBytes = 5; | ||||
| 				else if (chr >= 0xF0) | ||||
| 					nBytes = 4; | ||||
| 				else if (chr >= 0xE0) | ||||
| 					nBytes = 3; | ||||
| 				else if (chr >= 0xC0) | ||||
| 					nBytes = 2; | ||||
| 				else | ||||
| 				{ | ||||
| 					return false; | ||||
| 				} | ||||
| 				nBytes--; | ||||
| 			} | ||||
| 		} | ||||
| 		else //<2F><><EFBFBD>ֽڷ<D6BD><DAB7>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD>ֽ<EFBFBD>,ӦΪ 10xxxxxx | ||||
| 		{ | ||||
| 			if ((chr & 0xC0) != 0x80) | ||||
| 			{ | ||||
| 				return false; | ||||
| 			} | ||||
| 			nBytes--; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if (nBytes > 0) //Υ<><CEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	{ | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	if (bAllAscii) //<2F><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ASCII, ˵<><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>UTF-8 | ||||
| 	{ | ||||
| 		return false; | ||||
| 	} | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
							
								
								
									
										169
									
								
								Plugin/Driver/stdafx.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										169
									
								
								Plugin/Driver/stdafx.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,169 @@ | ||||
|  | ||||
| // stdafx.h : <20><>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>İ<EFBFBD><C4B0><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> | ||||
| // <20><><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD> | ||||
| // <20>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>İ<EFBFBD><C4B0><EFBFBD><EFBFBD>ļ<EFBFBD> | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #ifndef VC_EXTRALEAN | ||||
| #define VC_EXTRALEAN            // <20><> Windows ͷ<><CDB7><EFBFBD>ų<EFBFBD><C5B3><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD> | ||||
| #endif | ||||
|  | ||||
| #include "targetver.h" | ||||
|  | ||||
| #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // ijЩ CString <20><><EFBFBD>캯<EFBFBD><ECBAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD> | ||||
|  | ||||
| // <20>ر<EFBFBD> MFC <20><>ijЩ<C4B3><D0A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD><C9B7>ĺ<EFBFBD><C4BA>Եľ<D4B5><C4BE><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| #define _AFX_ALL_WARNINGS | ||||
|  | ||||
| #include <afxwin.h>         // MFC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD> | ||||
| #include <afxext.h>         // MFC <20><>չ | ||||
|  | ||||
|  | ||||
| #include <afxdisp.h>        // MFC <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
|  | ||||
|  | ||||
| #ifndef _AFX_NO_OLE_SUPPORT | ||||
| #include <afxdtctl.h>           // MFC <20><> Internet Explorer 4 <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>֧<EFBFBD><D6A7> | ||||
| #endif | ||||
| #ifndef _AFX_NO_AFXCMN_SUPPORT | ||||
| #include <afxcmn.h>             // MFC <20><> Windows <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>֧<EFBFBD><D6A7> | ||||
| #endif // _AFX_NO_AFXCMN_SUPPORT | ||||
|  | ||||
| #include<afxsock.h> | ||||
| #include "json.h" | ||||
| #include <queue> | ||||
|  | ||||
| using namespace std; | ||||
|  | ||||
| #define WM_NETMESSAGE       (WM_USER+9981) | ||||
| #define NET_CONNECT_OK	0 | ||||
| #define NET_DISCONNECT	1 | ||||
| #define NET_DATA_MSG	2 | ||||
| #define CAN_DISCONNECT  3 | ||||
| #define PLC_DISCONNECT  4 | ||||
| #define APP_DATA_MSG	5 | ||||
|  | ||||
|  | ||||
| #include <afxcontrolbars.h>     // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳؼ<CDBF><D8BC><EFBFBD><EFBFBD><EFBFBD> MFC ֧<><D6A7> | ||||
| #include "../Protocol.h" | ||||
|  | ||||
| #ifdef _UNICODE | ||||
| #if defined _M_IX86 | ||||
| #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") | ||||
| #elif defined _M_X64 | ||||
| #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") | ||||
| #else | ||||
| #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
|  | ||||
| extern CString  g_strSavePath; | ||||
| extern CString  g_strCurTime; | ||||
| extern int      g_nMsgIdx; | ||||
| void LogOutToFile(const char* fmt, ...); | ||||
| string _UnicodeToUtf8(CString Unicodestr); | ||||
|  | ||||
|  | ||||
| CString UTF8AndMB_Convert(const CString &strSource, UINT nSourceCodePage, UINT nTargetCodePage); // UTF8<46><38><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>(MultiByte)<29><>ת | ||||
| CString UTF8ToMB(const CString& utf8Str); | ||||
| bool    IsTextUTF8(const char* str, ULONGLONG length); | ||||
|  | ||||
|  | ||||
| typedef struct  ST_THREAD_PARAM | ||||
| { | ||||
| 	void   * pParent; | ||||
| 	//int      nIdx; | ||||
| } | ||||
| ST_THREAD_PARAM; | ||||
|  | ||||
| typedef struct  ST_CAN_DEVICE | ||||
| { | ||||
| 	int nSendFrameFormat; | ||||
| 	int	nSendFrameType; | ||||
| 	int	nCanIndex; | ||||
| 	int	nDevType; | ||||
| } | ||||
| ST_CAN_DEVICE; | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| 	NET_WR_MSG_RET = 0, | ||||
| 	NET_RD_MSG_RET = 1 | ||||
| }NET_MSG_TYPE_ENUM; | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| 	MANUAL_MODE = 0,  //<2F>ֶ<EFBFBD>ģʽ<C4A3><CABD>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD> | ||||
| 	AUTO_MODE   = 1,  //<2F>Զ<EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ң<EFBFBD><D2A3><EFBFBD><EFBFBD> PDA<44><41><EFBFBD>ƣ<EFBFBD>PAD<41><44><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD><D4BF>Ƶ<EFBFBD>բ <20><><EFBFBD><EFBFBD> β<><CEB2>װ<EFBFBD><D7B0> | ||||
| 	DEBUG_MODE  = 2,  //PDA<44><41><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD>е<EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>ɿ<EFBFBD><C9BF><EFBFBD> | ||||
|  | ||||
| }AGV_RUN_MODE_ENUM; | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| 	RE_NORMAL_RUN   = 0,   //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	RE_UNUSUAL_STOP = 1,   //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>쳣ͣ<ECB3A3><CDA3> | ||||
| 	RE_POINT_STOP   = 2,   //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3>(<28>յ<EFBFBD>) | ||||
| 	RE_A_STOP       = 3,   //<2F>Զ<EFBFBD>ͣ<EFBFBD><CDA3> | ||||
| 	RE_E_STOP       = 4,   //<2F><><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3> | ||||
| }AGV_RUN_RESTATE_ENUM;     //<2F><><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD> | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| 	A_STOP   = 0, //<2F>Զ<EFBFBD>ͣ<EFBFBD><CDA3>	 | ||||
| 	FORWARD  = 1, //<2F><>ǰ<EFBFBD><C7B0>ʻ | ||||
| 	BACKWARD = 2, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʻ | ||||
| 	E_STOP   = 3, //<2F><><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3> | ||||
| 	INVALID_ACTION = 4,  //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чָ<D0A7>ά<EEA3AC>ֵ<EFBFBD>ǰͣ<C7B0><CDA3><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>״̬ | ||||
| }AGV_ACTION_ENUM; | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| 	LOG_ERROR  = 0, | ||||
| 	LOG_INFO   = 1 | ||||
| }LOG_TYPE_ENUM; | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| 	SEND_MSG = 0, | ||||
| 	RECV_MSG = 1 | ||||
| }CAN_MSG_ENUM; | ||||
|  | ||||
| typedef struct NET_PACKET | ||||
| { | ||||
| 	char* pData; | ||||
| 	int   lLen; | ||||
| 	int   nDevId; | ||||
| 	NET_MSG_TYPE_ENUM  enType; | ||||
| }*pNET_PACKET; | ||||
|  | ||||
|  | ||||
| #define DATA_LINE_SIZE (11+13+4+4+11+4+4+4+33) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>ֽ<EFBFBD><D6BD><EFBFBD>89 | ||||
|  | ||||
| typedef struct ST_CAN_MESSAGE | ||||
| { | ||||
| 	char acSeq[10]; | ||||
| 	char acTime[12]; | ||||
| 	unsigned char cIndex; // 0<><30>1 | ||||
| 	unsigned char acTxRx; // 0:send, 1:recv | ||||
| 	char acID[10]; | ||||
| 	unsigned char acFrame;//0:data, 1:remote | ||||
| 	unsigned char acType; //0:standard, 1:extend | ||||
| 	unsigned char cDlc; | ||||
| 	char acData[32]; | ||||
|  | ||||
| }ST_CAN_MESSAGE; | ||||
|  | ||||
|  | ||||
|  | ||||
| typedef struct APP_NET_PACKET | ||||
| { | ||||
| 	int   lFuncLen; | ||||
| 	int   lParamLen; | ||||
| 	char *pFuncData; | ||||
| 	char *pParamData; | ||||
| 	 | ||||
| }*pNET_APP_PACKET; | ||||
							
								
								
									
										8
									
								
								Plugin/Driver/targetver.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Plugin/Driver/targetver.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| #pragma once | ||||
|  | ||||
| // <20><><EFBFBD><EFBFBD> SDKDDKVer.h <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>߰汾<DFB0><E6B1BE> Windows ƽ̨<C6BD><CCA8> | ||||
|  | ||||
| // <20><><EFBFBD><EFBFBD>ҪΪ<D2AA><CEAA>ǰ<EFBFBD><C7B0> Windows ƽ̨<C6BD><CCA8><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> WinSDKVer.h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| // <20><> _WIN32_WINNT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪҪ֧<D2AA>ֵ<EFBFBD>ƽ̨<C6BD><CCA8>Ȼ<EFBFBD><C8BB><EFBFBD>ٰ<EFBFBD><D9B0><EFBFBD> SDKDDKVer.h<><68> | ||||
|  | ||||
| #include <SDKDDKVer.h> | ||||
							
								
								
									
										66
									
								
								Plugin/Fast/BaseCamera.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								Plugin/Fast/BaseCamera.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | ||||
| // MsgHandleDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD> | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| #include "Fast.h" | ||||
| #include "BaseCamera.h" | ||||
| #include "afxdialogex.h" | ||||
|  | ||||
|  | ||||
| #define TIMER_LOGIN             10 | ||||
| #define TIMER_CLEAR_RECORD      22 | ||||
|  | ||||
|  | ||||
| // CMsgHandleDlg <20>Ի<EFBFBD><D4BB><EFBFBD> | ||||
|  | ||||
| IMPLEMENT_DYNAMIC(CBaseCamera, CDialog) | ||||
|  | ||||
| CBaseCamera::CBaseCamera(int nIdx, CWnd* pParent /*=NULL*/) | ||||
| 	: CDialog(IDD_DLG_CAM, pParent) | ||||
| { | ||||
| 	m_nCameraIdx = nIdx; | ||||
| 	m_pParentWnd = pParent; | ||||
| } | ||||
|  | ||||
| CBaseCamera::~CBaseCamera() | ||||
| { | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
| void CBaseCamera::DoDataExchange(CDataExchange* pDX) | ||||
| { | ||||
| 	CDialog::DoDataExchange(pDX); | ||||
| } | ||||
|  | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CBaseCamera, CDialog) | ||||
| 	ON_WM_DESTROY() | ||||
| 	ON_WM_TIMER() | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
|  | ||||
| // CMsgHandleDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
|  | ||||
| BOOL CBaseCamera::OnInitDialog() | ||||
| { | ||||
| 	CDialog::OnInitDialog(); | ||||
| 	return TRUE;  // return TRUE unless you set the focus to a control | ||||
| } | ||||
|  | ||||
|  | ||||
| void CBaseCamera::OnDestroy() | ||||
| { | ||||
| 	CDialog::OnDestroy(); | ||||
| } | ||||
|  | ||||
| void CBaseCamera::OnTimer(UINT_PTR nIDEvent) | ||||
| { | ||||
| 	CDialog::OnTimer(nIDEvent); | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										33
									
								
								Plugin/Fast/BaseCamera.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								Plugin/Fast/BaseCamera.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| #pragma once | ||||
|  | ||||
|  | ||||
| // CMsgHandleDlg <20>Ի<EFBFBD><D4BB><EFBFBD> | ||||
| class CBaseCamera : public CDialog | ||||
| { | ||||
| 	DECLARE_DYNAMIC(CBaseCamera) | ||||
|  | ||||
| public: | ||||
| 	CBaseCamera(int nIdx, CWnd* pParent = NULL);   // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF> | ||||
| 	virtual ~CBaseCamera(); | ||||
|  | ||||
| // <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| #ifdef AFX_DESIGN_TIME | ||||
| 	enum { IDD = IDD_DLG_CAM}; | ||||
| #endif | ||||
|  | ||||
| protected: | ||||
| 	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV ֧<><D6A7> | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
|  | ||||
| public: | ||||
| 	CWnd           *m_pParentWnd; | ||||
| 	virtual BOOL    OnInitDialog(); | ||||
| 	afx_msg void    OnDestroy(); | ||||
| 	afx_msg void    OnTimer(UINT_PTR nIDEvent); | ||||
| 	virtual void    Sample() {}; | ||||
|  | ||||
| public: | ||||
| 	int             m_nCameraIdx; | ||||
| 	int             m_nCameraState; | ||||
|  | ||||
| }; | ||||
							
								
								
									
										509
									
								
								Plugin/Fast/DahuaFisheyeCamera.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										509
									
								
								Plugin/Fast/DahuaFisheyeCamera.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,509 @@ | ||||
| // MsgHandleDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD> | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| #include "afxdialogex.h" | ||||
| #include "Fast.h" | ||||
| #include "DahuaFisheyeCamera.h" | ||||
| #include "FastView.h" | ||||
| #include "dhplay.h" | ||||
|  | ||||
|  | ||||
| #define TIMER_LOGIN             10 | ||||
|  | ||||
|  | ||||
| // CMsgHandleDlg <20>Ի<EFBFBD><D4BB><EFBFBD> | ||||
|  | ||||
| IMPLEMENT_DYNAMIC(CDahuaFisheyeCamera, CBaseCamera) | ||||
|  | ||||
| CDahuaFisheyeCamera::CDahuaFisheyeCamera(CFastView * pParentWnd, int nIdx, ENUM_PLAY_TYPE enPlayType, CWnd* pParent /*=NULL*/) | ||||
| 	: CBaseCamera(IDD_DLG_CAM, pParentWnd) | ||||
| { | ||||
| 	m_nCameraIdx    = nIdx; | ||||
| 	m_nIndex        = 0; | ||||
| 	m_pParentWnd    = pParentWnd; | ||||
| 	m_hCameraHandle = NULL; | ||||
| 	m_nPlayTyp      = enPlayType; | ||||
| } | ||||
|  | ||||
| CDahuaFisheyeCamera::~CDahuaFisheyeCamera() | ||||
| { | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
| void CDahuaFisheyeCamera::DoDataExchange(CDataExchange* pDX) | ||||
| { | ||||
| 	CDialog::DoDataExchange(pDX); | ||||
| } | ||||
|  | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CDahuaFisheyeCamera, CDialog) | ||||
| 	ON_WM_DESTROY() | ||||
| 	ON_WM_TIMER() | ||||
| 	ON_MESSAGE(WM_CAMERA_SNAP, &CDahuaFisheyeCamera::OnSnap) | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
|  | ||||
| /* | ||||
| int GetDahuaCameraIdxByLoginID(CDahuaFisheyeCamera *pThis, LLONG lLoginID) | ||||
| { | ||||
| 	for (int i = 0; i < theApp.m_nCameraCount; i++) | ||||
| 	{ | ||||
| 		if (theApp.m_CameraArray[i].lLoginId == lLoginID) | ||||
| 		{ | ||||
| 			return i; | ||||
| 		} | ||||
| 	} | ||||
| 	return -1; | ||||
| } | ||||
| */ | ||||
| //<2F><><EFBFBD>ص<DFBB> | ||||
| void CALLBACK DahuaDisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser) | ||||
| { | ||||
| 	if (dwUser == 0) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	CDahuaFisheyeCamera *pThis = (CDahuaFisheyeCamera *)dwUser; | ||||
| 	TRACE("[%I64d - %d]***********************  <20>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD> *********************\r\n", lLoginID, pThis->m_hWnd); | ||||
|  | ||||
| 	HWND hWnd = pThis->GetSafeHwnd(); | ||||
| 	if (NULL == hWnd) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	//int nIdx = GetDahuaCameraIdxByLoginID(pThis, lLoginID); | ||||
| 	if (pThis->m_lLoginId == lLoginID) | ||||
| 	{ | ||||
| 		pThis->m_nCameraState = 0; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	//pThis->m_pParentWnd->RefreshCameraList(); | ||||
| 	//pThis->m_pParentWnd->VoiceReminder(); | ||||
| } | ||||
|  | ||||
| void CALLBACK DahuaReConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser) | ||||
| { | ||||
| 	if (dwUser == 0) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	CDahuaFisheyeCamera *pThis = (CDahuaFisheyeCamera *)dwUser; | ||||
| 	TRACE("[%I64d - %d]***********************  <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *********************\r\n", lLoginID, pThis->m_hWnd); | ||||
| 	HWND hWnd = pThis->GetSafeHwnd(); | ||||
| 	if (NULL == hWnd) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	if (pThis->m_lLoginId == lLoginID) | ||||
| 	{ | ||||
| 		pThis->m_nCameraState = 1; | ||||
| 	} | ||||
| 	//int nIdx = GetDahuaCameraIdxByLoginID(pThis, lLoginID); | ||||
| 	//pThis->m_nCameraState = 1; | ||||
|  | ||||
| 	//pThis->m_pParentWnd->RefreshCameraList(); | ||||
| 	//pThis->m_pParentWnd->VoiceReminder(); | ||||
| } | ||||
|  | ||||
| void CALLBACK DahuaSnapPicRet(LLONG lLoginID, BYTE *pBuf, UINT RevLen, UINT EncodeType, DWORD CmdSerial, LDWORD dwUser) | ||||
| { | ||||
|  | ||||
| 	CDahuaFisheyeCamera *pThis = (CDahuaFisheyeCamera*)dwUser; | ||||
| 	 | ||||
| 	if (pThis->m_lLoginId == lLoginID) | ||||
| 	{ | ||||
| 		CTime currentTime = CTime::GetCurrentTime(); // <20><>ȡ<EFBFBD><C8A1>ǰʱ<C7B0><CAB1> | ||||
| 		CString dateStr = currentTime.Format(_T("%Y_%m_%d")); // <20><>ʽ<EFBFBD><CABD>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> | ||||
| 		CString tiemStr = currentTime.Format(_T("%H_%M_%S")); // <20><>ʽ<EFBFBD><CABD>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> | ||||
| 		CString strPath = theApp.m_strDataPath + "\\" + dateStr; | ||||
|  | ||||
| 		if (!PathIsDirectory(strPath))//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>      | ||||
| 		{ | ||||
| 			CreateDirectory(strPath, NULL);//<2F>½<EFBFBD><C2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> | ||||
| 		} | ||||
|  | ||||
| 		//ԭͼ | ||||
| 		char acFileName[256] = ""; | ||||
| 		sprintf(acFileName, "%s\\%s-%d.jpg", strPath, tiemStr, pThis->m_nCameraIdx); | ||||
|  | ||||
| 		//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ | ||||
| 		//char acAnalysisName[256] = ""; | ||||
| 		//sprintf(acAnalysisName, "%s\\analysis-%d.JPG", strPath, 0); | ||||
|  | ||||
|  | ||||
|  | ||||
| 		/* Save image original file */ | ||||
| 		FILE *stream; | ||||
| 		if ((stream = fopen((const char*)acFileName, "wb")) != NULL) | ||||
| 		{ | ||||
| 			int numwritten = fwrite(pBuf, sizeof(char), RevLen, stream); | ||||
| 			fclose(stream); | ||||
| 		} | ||||
|  | ||||
| 		pThis->m_pParentWnd->StartPlay(acFileName); | ||||
|  | ||||
|  | ||||
| 		//theApp.m_CameraArray[nIdx].strImagePath[0] = acFileName; | ||||
| 		//theApp.m_CameraArray[nIdx].strImagePath[1] = acAnalysisName; | ||||
| 		//pThis->m_pParentWnd->ShowCameraImage(acFileName, nIdx); | ||||
| 		//SetEvent(theApp.m_EventHandles[nIdx]); | ||||
|  | ||||
| 		/*if (theApp.m_CameraArray[nIdx].bAnalysis == TRUE) | ||||
| 		{ | ||||
| 		//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD> | ||||
| 		ParseImage(pThis, acFileName, acAnalysisName, nIdx); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 		SetEvent(theApp.m_EventHandles[nIdx]); | ||||
| 		theApp.m_CameraArray[nIdx].strImagePath[0] = acFileName; | ||||
| 		theApp.m_CameraArray[nIdx].strImagePath[1] = acFileName; | ||||
| 		pThis->m_pParentWnd->ShowCameraImage(acFileName, nIdx); | ||||
| 		}*/ | ||||
| 	} | ||||
| 	return; | ||||
| } | ||||
|  | ||||
| // netsdk ʵʱ<CAB5>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD> | ||||
| void CALL_METHOD fRealDataCB(LLONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, LDWORD dwUser) | ||||
| { | ||||
|  | ||||
| 	CDahuaFisheyeCamera *pWnd = (CDahuaFisheyeCamera*)dwUser; | ||||
| 	if (pWnd->m_lRealHandle != lRealHandle)return; | ||||
|  | ||||
| 	// <20>Ѵ<EFBFBD><D1B4><EFBFBD>ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>playsdk<64><6B> | ||||
| 	PLAY_InputData(pWnd->m_nWndID, pBuffer, dwBufSize); | ||||
| 	return; | ||||
| } | ||||
|  | ||||
| // playsdk <20>ص<EFBFBD> yuv<75><76><EFBFBD><EFBFBD> | ||||
| void CALL_METHOD  fDisplayCB(LONG nPort, char * pBuf, LONG nSize, LONG nWidth, LONG nHeight, LONG nStamp, LONG nType, void* pReserved) | ||||
| { | ||||
|  | ||||
| 	CDahuaFisheyeCamera *pShowWnd = (CDahuaFisheyeCamera *)(pReserved); | ||||
|  | ||||
| 	if (pShowWnd->m_nWndID != nPort)return; | ||||
|  | ||||
| 	//TRACE("%d\n", pThis->m_nWndID); | ||||
|  | ||||
|  | ||||
| 	//if (pThis->m_nWndID > 1)return; | ||||
| 	pShowWnd->m_nIndex++; | ||||
| 	if (pShowWnd->m_nIndex == 10) | ||||
| 	{ | ||||
|  | ||||
| 		cv::Mat cv_img; | ||||
| 		cv::Mat cv_yuv(nHeight + nHeight / 2, nWidth, CV_8UC1, pBuf);//pFrameΪYUV<55><56><EFBFBD>ݵ<EFBFBD>ַ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CV_8UC1<43><31> CV_8UC3. | ||||
| 		cv_img = cv::Mat(nHeight, nWidth, CV_8UC3); | ||||
| 		cv::cvtColor(cv_yuv, cv_img, cv::COLOR_YUV2BGR_I420); //cv::COLOR_YUV2BGR_I420 | ||||
| 															  //cv::imshow("video", cv_img); | ||||
|  | ||||
| 		cv::Mat imgTmp; | ||||
|  | ||||
| 		CRect rect; | ||||
| 		pShowWnd->GetClientRect(&rect);  // <20><>ȡ<EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>С | ||||
| 		int nWidth = cv_img.cols * rect.Height() *1.0 / cv_img.rows; | ||||
|  | ||||
| 		if (rect.Width() == 0)return; | ||||
|  | ||||
|  | ||||
| 		//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƭվչƽ | ||||
| 		//if (theApp.m_bCalibrator) | ||||
| 		//{ | ||||
| 		//	cv_img = CImageCalibrator::imageCalibration(cv_img); | ||||
| 		//} | ||||
|  | ||||
| 		cv::resize(cv_img, imgTmp, cv::Size(nWidth, rect.Height()));// <20><><EFBFBD><EFBFBD>Mat<61><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
| 		pShowWnd->m_nIndex = 0; | ||||
| 		pShowWnd->m_pParentWnd->DrawMat(imgTmp, (rect.Width() - nWidth) / 2); | ||||
| 		cv::waitKey(10); | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	return; | ||||
| } | ||||
|  | ||||
| CString CDahuaFisheyeCamera::ConvertString(CString strText) | ||||
| { | ||||
| 	char *val = new char[200]; | ||||
| 	CString strIniPath, strRet; | ||||
|  | ||||
| 	memset(val, 0, 200); | ||||
| 	GetPrivateProfileString("String", strText, "", | ||||
| 		val, 200, "./langchn.ini"); | ||||
| 	strRet = val; | ||||
| 	if (strRet.GetLength() == 0) | ||||
| 	{ | ||||
| 		//If there is no corresponding string in ini file then set it to be deafault value(English). | ||||
| 		strRet = strText; | ||||
| 	} | ||||
| 	delete[] val; | ||||
| 	return strRet; | ||||
| } | ||||
|  | ||||
| //Display log in failure reason  | ||||
| void CDahuaFisheyeCamera::ShowLoginErrorReason(int nError) | ||||
| { | ||||
| 	if (1 == nError)		MessageBox(ConvertString("Invalid password!"), ConvertString("Prompt")); | ||||
| 	else if (2 == nError)	MessageBox(ConvertString("Invalid account!"), ConvertString("Prompt")); | ||||
| 	else if (3 == nError)	MessageBox(ConvertString("Timeout!"), ConvertString("Prompt")); | ||||
| 	else if (4 == nError)	MessageBox(ConvertString("The user has logged in!"), ConvertString("Prompt")); | ||||
| 	else if (5 == nError)	MessageBox(ConvertString("The user has been locked!"), ConvertString("Prompt")); | ||||
| 	else if (6 == nError)	MessageBox(ConvertString("The user has listed into illegal!"), ConvertString("Prompt")); | ||||
| 	else if (7 == nError)	MessageBox(ConvertString("The system is busy!"), ConvertString("Prompt")); | ||||
| 	else if (9 == nError)	MessageBox(ConvertString("You Can't find the network server!"), ConvertString("Prompt")); | ||||
| 	else	MessageBox(ConvertString("Login failed!"), ConvertString("Prompt")); | ||||
| } | ||||
|  | ||||
|  | ||||
| // CMsgHandleDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
|  | ||||
| BOOL CDahuaFisheyeCamera::OnInitDialog() | ||||
| { | ||||
| 	CDialog::OnInitDialog(); | ||||
| 	InitCameraSDK(); | ||||
|  | ||||
|  | ||||
| 	CString strIpAddr = "192.168.0.102"; | ||||
| 	int     nPort     = 37777; | ||||
| 	CString strUser   = "admin"; | ||||
| 	CString strPW     = "wdq@2023"; | ||||
| 	m_lLoginId = Login(strIpAddr, nPort, strUser, strPW); | ||||
|  | ||||
| 	if (m_lLoginId > 0) | ||||
| 	{ | ||||
| 		m_nCameraState = 1; | ||||
| 		KillTimer(TIMER_LOGIN); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		m_nCameraState = 0; | ||||
| 		SetTimer(TIMER_LOGIN, 10000, NULL); | ||||
| 	} | ||||
| 	return TRUE;  // return TRUE unless you set the focus to a control | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| BOOL CDahuaFisheyeCamera::InitCameraSDK() | ||||
| { | ||||
|  | ||||
| 	TRACE("[%d - %d]***********************  InitNetSDK *********************\r\n", m_nCameraIdx, this->m_hWnd); | ||||
| 	BOOL ret = CLIENT_Init(DahuaDisConnectFunc, (LDWORD)this); | ||||
| 	if (ret) | ||||
| 	{ | ||||
| 		LOG_SET_PRINT_INFO  stLogPrintInfo = { sizeof(stLogPrintInfo) }; | ||||
| 		CLIENT_LogOpen(&stLogPrintInfo); | ||||
| 		CLIENT_SetSnapRevCallBack(DahuaSnapPicRet, (LDWORD)this); | ||||
| 		CLIENT_SetAutoReconnect(DahuaReConnectFunc, (LDWORD)this); | ||||
| 		//CLIENT_SetConnectTime(0, 0); | ||||
| 		TRACE("[%d - %d]***********************  InitNetSDK SUCCEED*********************\r\n", m_nCameraIdx, this->m_hWnd); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		MessageBox(ConvertString("initialize SDK failed!"), ConvertString("prompt")); | ||||
| 	} | ||||
|  | ||||
| 	// <20><>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	NET_PARAM stuNetParam = { 0 }; | ||||
| 	// Ŀǰ<C4BF><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣʱ<CFA2>䣨<EFBFBD><E4A3A8><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⣬û<E2A3AC><C3BB><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϣ<EFBFBD> | ||||
| 	stuNetParam.nGetDevInfoTime = 3000; | ||||
| 	CLIENT_SetNetworkParam(&stuNetParam); | ||||
| 	return TRUE; | ||||
| } | ||||
|  | ||||
| LLONG   CDahuaFisheyeCamera::Login(CString strIpAddr, int nPort, CString strUser, CString strPW) | ||||
| { | ||||
| 	//<2F><><EFBFBD>ε<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>¼ID | ||||
| 	NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam; | ||||
| 	memset(&stInparam, 0, sizeof(stInparam)); | ||||
| 	stInparam.dwSize = sizeof(stInparam); | ||||
| 	strncpy(stInparam.szIP, strIpAddr.GetBuffer(), strIpAddr.GetLength()); | ||||
| 	strncpy(stInparam.szPassword, strPW.GetBuffer(), strPW.GetLength()); | ||||
| 	strncpy(stInparam.szUserName, strUser.GetBuffer(), strUser.GetLength()); | ||||
| 	stInparam.nPort = nPort; | ||||
| 	stInparam.emSpecCap = EM_LOGIN_SPEC_CAP_TCP; | ||||
|  | ||||
| 	NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam; | ||||
| 	memset(&stOutparam, 0, sizeof(stOutparam)); | ||||
| 	stOutparam.dwSize = sizeof(stOutparam); | ||||
| 	LLONG lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam); | ||||
|  | ||||
| 	if (0 == lLoginHandle) | ||||
| 	{ | ||||
| 		//Display log in failure reason | ||||
| 		//ShowLoginErrorReason(stOutparam.nError); | ||||
| 		return -1; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		if (SNAP_PICTURE == m_nPlayTyp) | ||||
| 		{ | ||||
| 			//m_LoginID = lRet; | ||||
| 			int nRetLen = 0; | ||||
| 			NET_DEV_CHN_COUNT_INFO stuChn = { sizeof(NET_DEV_CHN_COUNT_INFO) }; | ||||
| 			stuChn.stuVideoIn.dwSize = sizeof(stuChn.stuVideoIn); | ||||
| 			stuChn.stuVideoOut.dwSize = sizeof(stuChn.stuVideoOut); | ||||
| 			BOOL bRet = CLIENT_QueryDevState(lLoginHandle, DH_DEVSTATE_DEV_CHN_COUNT, (char*)&stuChn, stuChn.dwSize, &nRetLen); | ||||
| 			if (!bRet) | ||||
| 			{ | ||||
| 				DWORD dwError = CLIENT_GetLastError() & 0x7fffffff; | ||||
| 			} | ||||
| 			 | ||||
| 		} | ||||
| 		else if (RT_STREAMING == m_nPlayTyp) | ||||
| 		{ | ||||
| 			PLAY_GetFreePort(&m_nWndID); | ||||
| 			PLAY_SetStreamOpenMode(m_nWndID, STREAME_REALTIME); | ||||
| 			PLAY_OpenStream(m_nWndID, NULL, 0, 1024 * 512 * 6); | ||||
| 			//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶץͼ<D7A5>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>   <20><><EFBFBD>Իص<D4BB><D8B5><EFBFBD>YUV<55><56><EFBFBD><EFBFBD> | ||||
| 			PLAY_SetDisplayCallBack(m_nWndID, fDisplayCB, this); | ||||
| 			PLAY_Play(m_nWndID, NULL); | ||||
| 			//<2F><><EFBFBD><EFBFBD> | ||||
| 			m_lRealHandle = CLIENT_RealPlayEx(lLoginHandle, 0, 0); | ||||
| 			//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD> | ||||
| 			CLIENT_SetRealDataCallBack(m_lRealHandle, fRealDataCB, (LDWORD)this); | ||||
| 		} | ||||
| 		return lLoginHandle; | ||||
| 	} | ||||
| 	//SetWindowText(ConvertString("CapturePicture")); | ||||
|  | ||||
|  | ||||
| /* | ||||
| 	char *pchDVRIP; | ||||
| 	//CString strDvrIP = GetDvrIP(); | ||||
| 	pchDVRIP = (LPSTR)(LPCSTR)strIpAddr; | ||||
| 	WORD wDVRPort = (WORD)nPort; | ||||
| 	char *pchUserName = (LPSTR)(LPCSTR)strUser; | ||||
| 	char *pchPassword = (LPSTR)(LPCSTR)strPW; | ||||
|  | ||||
| 	 | ||||
|  | ||||
|  | ||||
| 	NET_DEVICEINFO_Ex stLoginInfo = { 0 }; | ||||
| 	int nErrcode = 0; | ||||
|  | ||||
| 	LLONG lLoginHandle = CLIENT_LoginEx2(pchDVRIP, nPort, pchUserName, pchPassword, (EM_LOGIN_SPAC_CAP_TYPE)0, NULL, &stLoginInfo, &nErrcode); | ||||
| 	if (0 == lLoginHandle) | ||||
| 	{ | ||||
| 		//cout << "Login device failed" << endl; | ||||
| 		//cin >> szIpAddr; | ||||
| 		return -1; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		//cout << "Login device success" << endl; | ||||
| 	} | ||||
|  | ||||
| 	 | ||||
|  | ||||
| 	if (0 == m_lRealHandle) | ||||
| 	{ | ||||
| 		//cout << "CLIENT_RealPlayEx fail!" << endl; | ||||
| 		Sleep(100000); | ||||
| 		return -1; | ||||
| 	} | ||||
| 	//cout << "CLIENT_RealPlayEx success!" << endl; | ||||
|  | ||||
| */ | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| LRESULT  CDahuaFisheyeCamera::OnSnap(WPARAM wParam, LPARAM lParam) | ||||
| { | ||||
| 	//AfxMessageBox("<22><><EFBFBD><EFBFBD>"); | ||||
| 	//<2F><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD> | ||||
| 	if (m_nCameraState == 0) | ||||
| 		return 0; | ||||
|  | ||||
| 	//Fill in request structure | ||||
| 	SNAP_PARAMS snapparams = { 0 }; | ||||
| 	snapparams.Channel = 0; | ||||
| 	snapparams.mode = 0; | ||||
| 	snapparams.CmdSerial = 0; | ||||
|  | ||||
| 	BOOL b = CLIENT_SnapPicture(m_lLoginId, snapparams); | ||||
| 	if (!b) | ||||
| 	{ | ||||
| 		//<2F><><EFBFBD>ӳɹ<D3B3><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽʧ<CABD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD> | ||||
| 		//MessageBox(ConvertString("begin to snap failed!"), ConvertString("prompt")); | ||||
| 	} | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CDahuaFisheyeCamera::OnTimer(UINT_PTR nIDEvent) | ||||
| { | ||||
| 	// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ | ||||
| 	if (nIDEvent == TIMER_LOGIN) | ||||
| 	{ | ||||
| 		//<2F>豸<EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><C2B4><EFBFBD> | ||||
| 	} | ||||
|  | ||||
| 	CDialog::OnTimer(nIDEvent); | ||||
| } | ||||
|  | ||||
|  | ||||
| void CDahuaFisheyeCamera::OnDestroy() | ||||
| { | ||||
| 	CDialog::OnDestroy(); | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| void CDahuaFisheyeCamera::TargetDetection(int nCameraIdx, cv::Mat &mat_img, vector<CRect> &findRects) | ||||
| { | ||||
| 	CRect  findRect; | ||||
| 	try { | ||||
| 		cv::Mat dst = mat_img; | ||||
| 		//cv::Size newSize(mat_img.size().width / 4, mat_img.size().height / 4); // <20><><EFBFBD><EFBFBD><EFBFBD>µijߴ<C4B3> | ||||
| 		//cv::resize(mat_img, dst, newSize); // <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ߴ<EFBFBD> | ||||
|  | ||||
| 		auto det_image = theApp.m_yoloV4.m_pDetector->mat_to_image_resize(dst); | ||||
|  | ||||
| 		auto start = std::chrono::steady_clock::now(); | ||||
| 		std::vector<bbox_t> result_vec = theApp.m_yoloV4.m_pDetector->detect_resized(*det_image, dst.size().width, dst.size().height); | ||||
| 		auto end = std::chrono::steady_clock::now(); | ||||
| 		std::chrono::duration<double> spent = end - start; | ||||
| 		std::cout << " Time: " << spent.count() << " sec \n"; | ||||
|  | ||||
| 		theApp.m_yoloV4.DrawObjectBoxes(dst, result_vec, theApp.m_yoloV4.m_vObjects_Names); | ||||
|  | ||||
| 		for (int i = 0; i < result_vec.size(); i++) | ||||
| 		{ | ||||
| 			bbox_t  result_area = result_vec.at(i); | ||||
| 			std::string obj_name = theApp.m_yoloV4.m_vObjects_Names[result_area.obj_id]; | ||||
| 			//if (result_area.prob >= 0.9 && (0 == obj_name.compare("up") )) | ||||
| 			{ | ||||
| 				CRect  rect; | ||||
| 				rect.left = result_area.x; | ||||
| 				rect.top = result_area.y; | ||||
| 				rect.right = result_area.x + result_area.w; | ||||
| 				rect.bottom = result_area.y + result_area.h; | ||||
| 				findRects.push_back(rect); | ||||
| 			} | ||||
|  | ||||
| 		} | ||||
| 	} | ||||
| 	catch (std::exception &e) { std::cerr << "exception: " << e.what() << "\n"; getchar(); } | ||||
| 	catch (...) { std::cerr << "unknown exception \n"; getchar(); } | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										50
									
								
								Plugin/Fast/DahuaFisheyeCamera.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								Plugin/Fast/DahuaFisheyeCamera.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "BaseCamera.h" | ||||
| #include "dhnetsdk.h" | ||||
| #include "dhconfigsdk.h" | ||||
|  | ||||
| class CFastView; | ||||
| class CDahuaFisheyeCamera : public CBaseCamera | ||||
| { | ||||
| 	DECLARE_DYNAMIC(CDahuaFisheyeCamera) | ||||
|  | ||||
| public: | ||||
| 	CDahuaFisheyeCamera(CFastView *, int nIdx, ENUM_PLAY_TYPE enPlayType, CWnd* pParent = NULL);   // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF> | ||||
| 	virtual ~CDahuaFisheyeCamera(); | ||||
|  | ||||
| // <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| #ifdef AFX_DESIGN_TIME | ||||
| 	enum { IDD = IDD_DLG_CAM}; | ||||
| #endif | ||||
|  | ||||
| protected: | ||||
| 	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV ֧<><D6A7> | ||||
|  | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
|  | ||||
| public: | ||||
| 	CFastView      *m_pParentWnd; | ||||
| 	ENUM_PLAY_TYPE  m_nPlayTyp; | ||||
| 	void*           m_hCameraHandle; | ||||
| 	virtual BOOL    OnInitDialog(); | ||||
| 	afx_msg void    OnDestroy(); | ||||
| 	afx_msg LRESULT OnSnap(WPARAM wParam, LPARAM lParam); | ||||
| 	afx_msg void    OnTimer(UINT_PTR nIDEvent); | ||||
| 	BOOL            InitCameraSDK(); | ||||
| 	CString         ConvertString(CString strText); | ||||
| 	void            ShowLoginErrorReason(int nError); | ||||
| 	LLONG           Login(CString strIpAddr, int nPort, CString strUser, CString strPW); | ||||
| 	void            TargetDetection(int nCameraIdx, cv::Mat &mat_img, vector<CRect> &findRects); | ||||
| 	void            TargetPosition(unsigned char* pDepthData, vector<CRect> &findRects, cv::Point3f& coordinate, CRect& rect) {}; | ||||
|  | ||||
| public: | ||||
| 	int     m_nCameraIdx; | ||||
| 	LLONG   m_lLoginId; | ||||
| 	LONG    m_nWndID; | ||||
| 	int     m_nIndex; | ||||
| 	LLONG   m_lRealHandle; | ||||
| 	 | ||||
|  | ||||
|  | ||||
| }; | ||||
							
								
								
									
										143
									
								
								Plugin/Fast/Fast.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										143
									
								
								Plugin/Fast/Fast.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,143 @@ | ||||
|  | ||||
| // Vcs-Client.cpp : <20><><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA> | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| #include "Fast.h" | ||||
| #include "FastMainDialog.h" | ||||
|  | ||||
|  | ||||
|  | ||||
| #ifdef _DEBUG | ||||
| #define new DEBUG_NEW | ||||
| #endif | ||||
|  | ||||
| CCEXPipeClientBase* g_pstPipeClient = CCEXPipeClientBase::CreateObj(); | ||||
| // CVcsClientApp | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CFastApp, CWinApp) | ||||
| 	ON_COMMAND(ID_HELP, &CWinApp::OnHelp) | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
|  | ||||
| // CVcsClientApp <20><><EFBFBD><EFBFBD> | ||||
|  | ||||
| CFastApp::CFastApp() | ||||
| { | ||||
| 	// ֧<><D6A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; | ||||
|  | ||||
| 	// TODO: <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룬 | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> InitInstance <20><> | ||||
| 	m_strDataPath = "d:\\"; | ||||
| } | ||||
|  | ||||
|  | ||||
| // Ψһ<CEA8><D2BB>һ<EFBFBD><D2BB> CVcsClientApp <20><><EFBFBD><EFBFBD> | ||||
|  | ||||
| CFastApp theApp; | ||||
|  | ||||
|  | ||||
| BOOL CFastApp::InitInstance() | ||||
| { | ||||
| 	// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Windows XP <20>ϵ<EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD>嵥ָ<E5B5A5><D6B8>Ҫ | ||||
| 	// ʹ<><CAB9> ComCtl32.dll <20>汾 6 <20><><EFBFBD><EFBFBD><EFBFBD>߰汾<DFB0><E6B1BE><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF>ӻ<EFBFBD><D3BB><EFBFBD>ʽ<EFBFBD><CABD> | ||||
| 	//<2F><><EFBFBD><EFBFBD>Ҫ InitCommonControlsEx()<29><>  <20><><EFBFBD><EFBFBD><F2A3ACBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD> | ||||
| 	INITCOMMONCONTROLSEX InitCtrls; | ||||
| 	InitCtrls.dwSize = sizeof(InitCtrls); | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD> | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC>ࡣ | ||||
| 	InitCtrls.dwICC = ICC_WIN95_CLASSES; | ||||
| 	InitCommonControlsEx(&InitCtrls); | ||||
| 	CWinApp::InitInstance(); | ||||
|  | ||||
| 	AfxEnableControlContainer(); | ||||
|  | ||||
| 	// <20><><EFBFBD><EFBFBD> shell <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><D4B7>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	// <20>κ<EFBFBD> shell <20><><EFBFBD><EFBFBD>ͼ<EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD> shell <20>б<EFBFBD><D0B1><EFBFBD>ͼ<EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD> | ||||
| 	CShellManager *pShellManager = new CShellManager; | ||||
| 	// <20><><EFBFBD>Windows Native<76><65><EFBFBD>Ӿ<EFBFBD><D3BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD> MFC <20>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); | ||||
|  | ||||
| 	// <20><><EFBFBD><D7BC>ʼ<EFBFBD><CABC> | ||||
| 	// <20><><EFBFBD><EFBFBD>δʹ<CEB4><CAB9><EFBFBD><EFBFBD>Щ<EFBFBD><D0A9><EFBFBD>ܲ<EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD>С | ||||
| 	// <20><><EFBFBD>տ<EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>ļ<EFBFBD><C4BC>Ĵ<EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>Ӧ<EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	// <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ض<EFBFBD><D8B6><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ洢<DAB4><E6B4A2><EFBFBD>õ<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	// TODO: Ӧ<>ʵ<EFBFBD><CAB5>ĸ<DEB8><C4B8>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>˾<EFBFBD><CBBE><EFBFBD><EFBFBD>֯<EFBFBD><D6AF> | ||||
| 	SetRegistryKey(_T("Ӧ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵı<EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD>")); | ||||
|  | ||||
| 	char acPath[2048] = { 0 }; | ||||
| 	GetModuleFileName(NULL, acPath, 2048); | ||||
| 	CString strConf(acPath); | ||||
| 	strConf = strConf.Left(strConf.ReverseFind('\\')); | ||||
| 	m_strCfgFilePath = strConf + "\\config.ini"; | ||||
|  | ||||
|  | ||||
| 	CFastMainDialog dlg; | ||||
| 	m_pMainWnd = &dlg; | ||||
| 	INT_PTR nResponse = dlg.DoModal(); | ||||
| 	if (nResponse == IDOK) | ||||
| 	{ | ||||
| 		// TODO: <20>ڴ˷<DAB4><CBB7>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> | ||||
| 		//  <20><>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>رնԻ<D5B6><D4BB><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD> | ||||
| 	} | ||||
| 	else if (nResponse == IDCANCEL) | ||||
| 	{ | ||||
| 		// TODO: <20>ڴ˷<DAB4><CBB7>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> | ||||
| 		//  <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>رնԻ<D5B6><D4BB><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD> | ||||
| 	} | ||||
| 	else if (nResponse == -1) | ||||
| 	{ | ||||
| 		TRACE(traceAppMsg, 0, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20>Ի<EFBFBD><D4BB><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>\n"); | ||||
| 		TRACE(traceAppMsg, 0, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶԻ<DAB6><D4BB><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> MFC <20>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS<47><53>\n"); | ||||
| 	} | ||||
|  | ||||
| 	// ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD>洴<EFBFBD><E6B4B4><EFBFBD><EFBFBD> shell <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	if (pShellManager != NULL) | ||||
| 	{ | ||||
| 		delete pShellManager; | ||||
| 	} | ||||
|  | ||||
| #ifndef _AFXDLL | ||||
| 	ControlBarCleanUp(); | ||||
| #endif | ||||
|  | ||||
| 	// <20><><EFBFBD>ڶԻ<DAB6><D4BB><EFBFBD><EFBFBD>ѹرգ<D8B1><D5A3><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD> FALSE <20>Ա<EFBFBD><D4B1>˳<EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	//  <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>á<EFBFBD> | ||||
| 	return FALSE; | ||||
| } | ||||
|  | ||||
| CString CFastApp::SendMsg2Platform(CString strReceiver, int nMsgType, Json::Value param) | ||||
| { | ||||
| 	LogOutToFile("FAST::SendMsg2Platform Begin"); | ||||
|  | ||||
| 	Json::Value root; | ||||
| 	root["sender"] = "FAST"; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,SwingArm | ||||
| 	root["receiver"] = strReceiver.GetBuffer(); | ||||
|  | ||||
| 	/****************************************************** | ||||
| 	nMsgTypeʹ<65><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	CREATE_TASK_RET      = 2,       //WCS->WMS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	EXECUTE_TASK_RET     = 4,       //WCS->WMS ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	DEVICE_STATE_REPORT  = 5,       //WCS->WMS <20>豸״̬<D7B4>ϱ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) | ||||
| 	DEVICE_CONFIG_REQ    = 6,       //WCS->WMS <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ | ||||
| 	*******************************************************/ | ||||
|  | ||||
| 	root["type"] = nMsgType; | ||||
| 	root["params"] = param; | ||||
|  | ||||
| 	Json::FastWriter  writer; | ||||
| 	string strJson = writer.write(root); | ||||
|  | ||||
| 	g_pstPipeClient->SendeMsg(WCS_2_WMS_DATA, (char*)strJson.c_str(), strJson.length()); | ||||
|  | ||||
| 	LogOutToFile("FAST::SendMsg2Platform End"); | ||||
|  | ||||
| 	return ""; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										43
									
								
								Plugin/Fast/Fast.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								Plugin/Fast/Fast.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,43 @@ | ||||
|  | ||||
| // Vcs-Client.h : PROJECT_NAME Ӧ<>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> | ||||
| // | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #ifndef __AFXWIN_H__ | ||||
| 	#error "<22>ڰ<EFBFBD><DAB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>stdafx.h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> PCH <20>ļ<EFBFBD>" | ||||
| #endif | ||||
|  | ||||
| #include "resource.h"		// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
| #include "CCEXPipeLib.h" | ||||
| #include "YoloV4.h" | ||||
|  | ||||
|  | ||||
| // CVcsClientApp:  | ||||
| // <20>йش<D0B9><D8B4><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>֣<EFBFBD><D6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Vcs-Client.cpp | ||||
| // | ||||
|  | ||||
| class CFastApp : public CWinApp | ||||
| { | ||||
| public: | ||||
| 	CFastApp(); | ||||
|  | ||||
| public: | ||||
| 	CString      m_strCfgFilePath; | ||||
| 	CString      m_strDataPath; | ||||
| 	CYoloV4      m_yoloV4; | ||||
| 	HWND         m_hMainWnd; | ||||
| // <20><>д | ||||
| public: | ||||
| 	virtual BOOL InitInstance(); | ||||
| 	CString SendMsg2Platform(CString strReceiver, int nMsgType, Json::Value param); | ||||
|  | ||||
|  | ||||
| // ʵ<><CAB5> | ||||
|  | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
| }; | ||||
|  | ||||
| extern CFastApp theApp; | ||||
| extern CCEXPipeClientBase* g_pstPipeClient; | ||||
							
								
								
									
										230
									
								
								Plugin/Fast/Fast.vcxproj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										230
									
								
								Plugin/Fast/Fast.vcxproj
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,230 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||
|   <ItemGroup Label="ProjectConfigurations"> | ||||
|     <ProjectConfiguration Include="Debug|Win32"> | ||||
|       <Configuration>Debug</Configuration> | ||||
|       <Platform>Win32</Platform> | ||||
|     </ProjectConfiguration> | ||||
|     <ProjectConfiguration Include="Debug|x64"> | ||||
|       <Configuration>Debug</Configuration> | ||||
|       <Platform>x64</Platform> | ||||
|     </ProjectConfiguration> | ||||
|     <ProjectConfiguration Include="Release|Win32"> | ||||
|       <Configuration>Release</Configuration> | ||||
|       <Platform>Win32</Platform> | ||||
|     </ProjectConfiguration> | ||||
|     <ProjectConfiguration Include="Release|x64"> | ||||
|       <Configuration>Release</Configuration> | ||||
|       <Platform>x64</Platform> | ||||
|     </ProjectConfiguration> | ||||
|   </ItemGroup> | ||||
|   <PropertyGroup Label="Globals"> | ||||
|     <ProjectName>Fast</ProjectName> | ||||
|     <ProjectGuid>{EDB92B51-C3C2-44DA-B21D-6BB824264D08}</ProjectGuid> | ||||
|     <RootNamespace>GrabImage_Display</RootNamespace> | ||||
|     <Keyword>Win32Proj</Keyword> | ||||
|     <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||||
|   </PropertyGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <PlatformToolset>v143</PlatformToolset> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|     <WholeProgramOptimization>true</WholeProgramOptimization> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <PlatformToolset>v143</PlatformToolset> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|     <UseOfMfc>Dynamic</UseOfMfc> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <PlatformToolset>v143</PlatformToolset> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|     <WholeProgramOptimization>true</WholeProgramOptimization> | ||||
|     <UseOfMfc>Dynamic</UseOfMfc> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <PlatformToolset>v143</PlatformToolset> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|     <UseOfMfc>Dynamic</UseOfMfc> | ||||
|   </PropertyGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||||
|   <ImportGroup Label="ExtensionSettings"> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <PropertyGroup Label="UserMacros" /> | ||||
|   <PropertyGroup> | ||||
|     <_ProjectFileVersion>14.0.23107.0</_ProjectFileVersion> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <OutDir>$(ProjectDir)$(Configuration)\</OutDir> | ||||
|     <IntDir>$(Configuration)\</IntDir> | ||||
|     <LinkIncremental>true</LinkIncremental> | ||||
|     <EmbedManifest>true</EmbedManifest> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||||
|     <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\Agv</OutDir> | ||||
|     <IntDir>$(Platform)\$(Configuration)\</IntDir> | ||||
|     <LinkIncremental>true</LinkIncremental> | ||||
|     <EmbedManifest>true</EmbedManifest> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||||
|     <OutDir>$(ProjectDir)$(Configuration)\</OutDir> | ||||
|     <IntDir>$(Configuration)\</IntDir> | ||||
|     <LinkIncremental>false</LinkIncremental> | ||||
|     <EmbedManifest>true</EmbedManifest> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||||
|     <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\Agv</OutDir> | ||||
|     <IntDir>$(Platform)\$(Configuration)\</IntDir> | ||||
|     <LinkIncremental>false</LinkIncremental> | ||||
|     <EmbedManifest>true</EmbedManifest> | ||||
|   </PropertyGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <ClCompile> | ||||
|       <Optimization>Disabled</Optimization> | ||||
|       <AdditionalIncludeDirectories>$(SolutionDir)inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|       <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <MinimalRebuild>true</MinimalRebuild> | ||||
|       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> | ||||
|       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> | ||||
|       <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <DebugInformationFormat>EditAndContinue</DebugInformationFormat> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <AdditionalDependencies>MvCameraControl.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||||
|       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile> | ||||
|       <AdditionalLibraryDirectories>$(MVCAM_COMMON_RUNENV)\Libraries\win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||||
|       <GenerateDebugInformation>true</GenerateDebugInformation> | ||||
|       <SubSystem>Console</SubSystem> | ||||
|       <TargetMachine>MachineX86</TargetMachine> | ||||
|     </Link> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||||
|     <Midl> | ||||
|       <TargetEnvironment>X64</TargetEnvironment> | ||||
|     </Midl> | ||||
|     <ClCompile> | ||||
|       <Optimization>Disabled</Optimization> | ||||
|       <AdditionalIncludeDirectories>$(SolutionDir)3rdparty\json\inc;$(SolutionDir)CCEXPipe;$(SolutionDir)3rdparty\opencv\inc;$(SolutionDir)3rdparty\yolo4\inc;$(SolutionDir)3rdparty\hikvision\rgbd_camera\inc;$(SolutionDir)3rdparty\dahua\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|       <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <MinimalRebuild>true</MinimalRebuild> | ||||
|       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> | ||||
|       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> | ||||
|       <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <AdditionalDependencies>opencv_calib3d454d.lib;opencv_core454d.lib;opencv_dnn454d.lib;opencv_features2d454d.lib;opencv_flann454d.lib;opencv_highgui454d.lib;opencv_imgcodecs454d.lib;opencv_imgproc454d.lib;opencv_ml454d.lib;opencv_video454d.lib;opencv_videoio454d.lib;opencv_face454d.lib;opencv_objdetect454d.lib;opencv_photo454d.lib;yolo_dll_cpud.lib;GdiPlus.lib;Mv3dRgbd.lib;opengl32.lib;glu32.lib;glfw3.lib;dhconfigsdk.lib;dhnetsdk.lib;dhplay.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||||
|       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile> | ||||
|       <AdditionalLibraryDirectories>$(SolutionDir)\3rdparty\opencv\lib;$(SolutionDir)\3rdparty\yolo4\lib;$(SolutionDir)$(Platform)\$(Configuration)\;$(SolutionDir)\3rdparty\hikvision\rgbd_camera\lib\x64;$(SolutionDir)\3rdparty\dahua\lib\win64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||||
|       <GenerateDebugInformation>true</GenerateDebugInformation> | ||||
|       <SubSystem>Windows</SubSystem> | ||||
|       <TargetMachine>MachineX64</TargetMachine> | ||||
|     </Link> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||||
|     <ClCompile> | ||||
|       <Optimization>MaxSpeed</Optimization> | ||||
|       <IntrinsicFunctions>false</IntrinsicFunctions> | ||||
|       <AdditionalIncludeDirectories>$(MVCAM_COMMON_RUNENV)\Includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|       <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> | ||||
|       <FunctionLevelLinking>false</FunctionLevelLinking> | ||||
|       <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <AdditionalDependencies>MvCameraControl.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||||
|       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile> | ||||
|       <AdditionalLibraryDirectories>$(MVCAM_COMMON_RUNENV)\Libraries\win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||||
|       <GenerateDebugInformation>true</GenerateDebugInformation> | ||||
|       <SubSystem>Console</SubSystem> | ||||
|       <OptimizeReferences>true</OptimizeReferences> | ||||
|       <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||||
|       <TargetMachine>MachineX86</TargetMachine> | ||||
|     </Link> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||||
|     <Midl> | ||||
|       <TargetEnvironment>X64</TargetEnvironment> | ||||
|     </Midl> | ||||
|     <ClCompile> | ||||
|       <Optimization>Disabled</Optimization> | ||||
|       <IntrinsicFunctions>false</IntrinsicFunctions> | ||||
|       <AdditionalIncludeDirectories>$(SolutionDir)3rdparty\json\inc;$(SolutionDir)CCEXPipe;$(SolutionDir)3rdparty\opencv\inc;$(SolutionDir)3rdparty\yolo4\inc;$(SolutionDir)3rdparty\hikvision\rgbd_camera\inc;$(SolutionDir)3rdparty\dahua\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|       <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> | ||||
|       <FunctionLevelLinking>false</FunctionLevelLinking> | ||||
|       <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <AdditionalDependencies>opencv_calib3d454.lib;opencv_core454.lib;opencv_dnn454.lib;opencv_features2d454.lib;opencv_flann454.lib;opencv_highgui454.lib;opencv_imgcodecs454.lib;opencv_imgproc454.lib;opencv_ml454.lib;opencv_video454.lib;opencv_videoio454.lib;opencv_face454.lib;opencv_objdetect454.lib;opencv_photo454.lib;yolo_dll_cpu.lib;GdiPlus.lib;Mv3dRgbd.lib;opengl32.lib;glu32.lib;glfw3.lib;dhconfigsdk.lib;dhnetsdk.lib;dhplay.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||||
|       <OutputFile>$(OutDir)$(ProjectName).exe</OutputFile> | ||||
|       <AdditionalLibraryDirectories>$(SolutionDir)\3rdparty\yolo4\lib;$(SolutionDir)\3rdparty\opencv\lib;$(SolutionDir)$(Platform)\$(Configuration)\;$(SolutionDir)\3rdparty\hikvision\rgbd_camera\lib\x64;$(SolutionDir)\3rdparty\dahua\lib\win64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||||
|       <GenerateDebugInformation>true</GenerateDebugInformation> | ||||
|       <SubSystem>Windows</SubSystem> | ||||
|       <OptimizeReferences>true</OptimizeReferences> | ||||
|       <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||||
|       <TargetMachine>MachineX64</TargetMachine> | ||||
|     </Link> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_reader.cpp" /> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_value.cpp" /> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_writer.cpp" /> | ||||
|     <ClCompile Include="BaseCamera.cpp" /> | ||||
|     <ClCompile Include="DahuaFisheyeCamera.cpp" /> | ||||
|     <ClCompile Include="FastMainDialog.cpp" /> | ||||
|     <ClCompile Include="FastView.cpp" /> | ||||
|     <ClCompile Include="HikRgdbCamera.cpp" /> | ||||
|     <ClCompile Include="stdafx.cpp" /> | ||||
|     <ClCompile Include="Fast.cpp" /> | ||||
|     <ClCompile Include="YoloV4.cpp" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="BaseCamera.h" /> | ||||
|     <ClInclude Include="DahuaFisheyeCamera.h" /> | ||||
|     <ClInclude Include="FastMainDialog.h" /> | ||||
|     <ClInclude Include="FastView.h" /> | ||||
|     <ClInclude Include="HikRgdbCamera.h" /> | ||||
|     <ClInclude Include="resource.h" /> | ||||
|     <ClInclude Include="stdafx.h" /> | ||||
|     <ClInclude Include="Fast.h" /> | ||||
|     <ClInclude Include="targetver.h" /> | ||||
|     <ClInclude Include="YoloV4.h" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ResourceCompile Include="Fast.rc" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Image Include="res\fast.ico" /> | ||||
|   </ItemGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||||
|   <ImportGroup Label="ExtensionTargets"> | ||||
|   </ImportGroup> | ||||
|   <ProjectExtensions> | ||||
|     <VisualStudio> | ||||
|       <UserProperties RESOURCE_FILE="Fast.rc" /> | ||||
|     </VisualStudio> | ||||
|   </ProjectExtensions> | ||||
| </Project> | ||||
							
								
								
									
										45
									
								
								Plugin/Fast/Fast.vcxproj.filters
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								Plugin/Fast/Fast.vcxproj.filters
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="FastMainDialog.cpp" /> | ||||
|     <ClCompile Include="FastView.cpp" /> | ||||
|     <ClCompile Include="stdafx.cpp" /> | ||||
|     <ClCompile Include="Fast.cpp" /> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_reader.cpp"> | ||||
|       <Filter>json</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_value.cpp"> | ||||
|       <Filter>json</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_writer.cpp"> | ||||
|       <Filter>json</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="YoloV4.cpp" /> | ||||
|     <ClCompile Include="BaseCamera.cpp" /> | ||||
|     <ClCompile Include="HikRgdbCamera.cpp" /> | ||||
|     <ClCompile Include="DahuaFisheyeCamera.cpp" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="FastMainDialog.h" /> | ||||
|     <ClInclude Include="FastView.h" /> | ||||
|     <ClInclude Include="resource.h" /> | ||||
|     <ClInclude Include="stdafx.h" /> | ||||
|     <ClInclude Include="Fast.h" /> | ||||
|     <ClInclude Include="targetver.h" /> | ||||
|     <ClInclude Include="YoloV4.h" /> | ||||
|     <ClInclude Include="BaseCamera.h" /> | ||||
|     <ClInclude Include="HikRgdbCamera.h" /> | ||||
|     <ClInclude Include="DahuaFisheyeCamera.h" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ResourceCompile Include="Fast.rc" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Filter Include="json"> | ||||
|       <UniqueIdentifier>{9b459857-43fd-4c3e-9f43-f0d28d5146bb}</UniqueIdentifier> | ||||
|     </Filter> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Image Include="res\fast.ico" /> | ||||
|   </ItemGroup> | ||||
| </Project> | ||||
							
								
								
									
										193
									
								
								Plugin/Fast/FastMainDialog.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										193
									
								
								Plugin/Fast/FastMainDialog.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,193 @@ | ||||
| // WcsMainDialog.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD> | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| #include "afxdialogex.h" | ||||
|  | ||||
| #include "Fast.h" | ||||
| #include "FastMainDialog.h" | ||||
|  | ||||
|  | ||||
|  | ||||
| // CMainDialog <20>Ի<EFBFBD><D4BB><EFBFBD> | ||||
|  | ||||
| IMPLEMENT_DYNAMIC(CFastMainDialog, CDialogEx) | ||||
|  | ||||
| CFastMainDialog::CFastMainDialog(CWnd* pParent /*=NULL*/) | ||||
| 	: CDialogEx(IDD_FAST_MAIN_DIALOG, pParent) | ||||
| { | ||||
| } | ||||
|  | ||||
| CFastMainDialog::~CFastMainDialog() | ||||
| { | ||||
|  | ||||
| } | ||||
|  | ||||
| void CFastMainDialog::DoDataExchange(CDataExchange* pDX) | ||||
| { | ||||
| 	CDialogEx::DoDataExchange(pDX); | ||||
| 	DDX_Control(pDX, IDC_STATIC_FAST1, m_FastCam[0]); | ||||
| 	DDX_Control(pDX, IDC_STATIC_FAST2, m_FastCam[1]); | ||||
| 	DDX_Control(pDX, IDC_STATIC_FAST3, m_FastCam[2]); | ||||
| 	DDX_Control(pDX, IDC_STATIC_FAST4, m_FastCam[3]); | ||||
| } | ||||
|  | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CFastMainDialog, CDialogEx) | ||||
| 	 | ||||
| 	ON_WM_TIMER() | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
|  | ||||
| // CMainDialog <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
| //<2F><>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨѶ<CDA8>Ĺܵ<C4B9><DCB5>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| void g_PipeCallBack(void* pObj, int lMsgId, WPARAM wparam, LPARAM lparam) | ||||
| { | ||||
| 	CFastMainDialog* pModule = (CFastMainDialog*)pObj; | ||||
| 	if (CEXPIPE_CONNECT_OK == lMsgId) | ||||
| 	{ | ||||
| 		//<2F><><EFBFBD>ӳɹ<D3B3> | ||||
| 		//if (FALSE == pModule->PostMessage(WM_PLATFORM_CONNECT_OK, NULL, NULL)) { LogOutToFile("g_PipeCallBack PostMessage error[%d]", lMsgId); } | ||||
| 		LogOutToFile("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̹ܵ<EFBFBD>"); | ||||
|  | ||||
| 		//<2F><>WMS<4D><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ | ||||
| 		theApp.SendMsg2Platform("WMS", DEVICE_CONFIG_REQ, NULL); | ||||
| 	} | ||||
| 	else if (CEXPIPE_DIS_CLIENT == lMsgId) | ||||
| 	{ | ||||
| 		//<2F>ܵ<EFBFBD><DCB5>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| #ifndef _DEBUG | ||||
| 		LogOutToFile("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӹܵ<EFBFBD><EFBFBD>Ͽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD>˳<EFBFBD>"); | ||||
| 		//if (FALSE == pModule->PostMessage(WM_CLOSE, NULL, NULL)) { LogOutToFile("g_PipeCallBack PostMessage error[%d]", lMsgId); } | ||||
| 		pModule->PostMessage(WM_COMMAND, MAKEWPARAM(ID_TRAY_EXIT, 0), 0); | ||||
| #endif | ||||
| 	} | ||||
| 	else if (CEXPIPE_NEW_DATA == lMsgId) | ||||
| 	{ | ||||
| 		pModule->ProcessPipeMsg(lMsgId, (char*)wparam, (int)lparam); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		; | ||||
| 	} | ||||
| } | ||||
|  | ||||
|  | ||||
| void CFastMainDialog::ProcessPipeMsg(int lMsgId, char* pData, int lLen) | ||||
| { | ||||
| 	if (lLen == 0) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	PIPE_DATA_STRUCT* pstData = (PIPE_DATA_STRUCT*)pData; | ||||
|  | ||||
| 	//ƽ̨ת<CCA8><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ | ||||
| 	if (pstData->lMsgId == MAIN_2_MODULE_WMS && pstData->lDataLen > 0) | ||||
| 	{ | ||||
| 		Json::Reader reader; | ||||
| 		Json::Value  root; | ||||
| 		if (reader.parse((char*)pstData->acData, root)) | ||||
| 		{ | ||||
| 			CString strReceiver = root["receiver"].asString().c_str(); | ||||
| 			CString strSender = root["sender"].asString().c_str(); | ||||
| 			int     nMsgType = root["type"].asInt(); | ||||
|  | ||||
|  | ||||
| 			//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD> | ||||
| 			/*if (nMsgType == DEVICE_CONFIG_RET) | ||||
| 			{ | ||||
|  | ||||
| 			} | ||||
| 			else if (nMsgType == SET_TRANS_MODE_REQ && m_bDeviceInit) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵĹ<DFB5><C4B9><EFBFBD>ģʽ | ||||
| 			{ | ||||
|  | ||||
| 			} | ||||
| 			else if (nMsgType == GET_TRANS_STATE_REQ)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ | ||||
| 			{ | ||||
|  | ||||
| 			}*/ | ||||
|  | ||||
| 		} | ||||
| 	} | ||||
| 	else if (pstData->lMsgId == MAIN_2_MODULE_SHOWWINDOW) | ||||
| 	{ | ||||
| 		//PostMessage(WM_COMMAND, MAKEWPARAM(ID_TRAY_SHOW, 0), 0); | ||||
| 		AfxGetApp()->m_pMainWnd->ShowWindow(SW_SHOWNORMAL); | ||||
| 		SetForegroundWindow(); | ||||
| 	} | ||||
|  | ||||
| 	LogOutToFile("HttpServiceListener::OnRecvRequest End"); | ||||
| } | ||||
|  | ||||
|  | ||||
| BOOL CFastMainDialog::OnInitDialog() | ||||
| { | ||||
| 	CDialogEx::OnInitDialog(); | ||||
|  | ||||
| 	theApp.m_hMainWnd = m_hWnd; | ||||
| 	//SetTimer(1, 500, NULL); | ||||
|  | ||||
| 	//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	InitLocalCamera(); | ||||
|  | ||||
| 	return TRUE;  // return TRUE unless you set the focus to a control | ||||
| 				  // <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| BOOL   CFastMainDialog::PreTranslateMessage(MSG*   pMsg) | ||||
| { | ||||
| 	if (pMsg->message == WM_KEYDOWN&&pMsg->wParam == VK_RETURN) | ||||
| 		return TRUE; | ||||
| 	if (pMsg->message == WM_KEYDOWN&&pMsg->wParam == VK_ESCAPE) | ||||
| 		return TRUE; | ||||
|  | ||||
| 	return   CDialog::PreTranslateMessage(pMsg); | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| void CFastMainDialog::OnTimer(UINT_PTR nIDEvent) | ||||
| { | ||||
| 	// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ | ||||
| 	CDialogEx::OnTimer(nIDEvent); | ||||
| } | ||||
|  | ||||
| void  CFastMainDialog::InitLocalCamera() | ||||
| { | ||||
| 	m_FastCam[0].SetCameraInfo(0, HIK_RGBD, SNAP_PICTURE); | ||||
| 	m_FastCam[1].SetCameraInfo(1, DAHUA_FISHEYE, SNAP_PICTURE, "192.168.0.124", 37777); | ||||
| 	m_FastCam[2].SetCameraInfo(2, DAHUA_FISHEYE, RT_STREAMING, "192.168.0.124", 37777); | ||||
| } | ||||
|  | ||||
| /* | ||||
| void  CFastMainDialog::InitCamereSDK() | ||||
| { | ||||
| 	MV3D_RGBD_VERSION_INFO stVersion; | ||||
| 	MV3D_RGBD_GetSDKVersion(&stVersion); | ||||
| 	MV3D_RGBD_Initialize(); | ||||
| 	int ret = MV3D_RGBD_Initialize(); | ||||
|  | ||||
| 	unsigned int nDevNum = 0; | ||||
| 	ret = MV3D_RGBD_GetDeviceNumber(DeviceType_USB, &nDevNum); | ||||
|  | ||||
| 	if (0 == nDevNum) | ||||
| 	{ | ||||
| 		//AfxMessageBox("δ<><CEB4><EFBFBD><EFBFBD><E2B5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>."); | ||||
| 		return ; | ||||
| 	} | ||||
|  | ||||
| 	MV3D_RGBD_DEVICE_INFO info; | ||||
| 	for (int i = 0; i < nDevNum; i++) | ||||
| 	{ | ||||
| 		m_CameraDev.push_back(info); | ||||
| 	} | ||||
| 	ret = MV3D_RGBD_GetDeviceList(DeviceType_USB, &m_CameraDev[0], nDevNum, &nDevNum); | ||||
| } | ||||
| */ | ||||
							
								
								
									
										38
									
								
								Plugin/Fast/FastMainDialog.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								Plugin/Fast/FastMainDialog.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| #pragma once | ||||
| #include "afxcmn.h" | ||||
| #include "afxwin.h" | ||||
| #include "FastView.h" | ||||
|  | ||||
|  | ||||
|  | ||||
| class CFastMainDialog : public CDialogEx | ||||
| { | ||||
| 	DECLARE_DYNAMIC(CFastMainDialog) | ||||
|  | ||||
| public: | ||||
| 	CFastMainDialog(CWnd* pParent = NULL);   // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF> | ||||
| 	virtual ~CFastMainDialog(); | ||||
|  | ||||
| 	// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| #ifdef AFX_DESIGN_TIME | ||||
| 	enum { IDD = IDD_MAIN_DIALOG }; | ||||
| #endif | ||||
|  | ||||
| protected: | ||||
| 	virtual void   DoDataExchange(CDataExchange* pDX);    // DDX/DDV ֧<><D6A7> | ||||
| 	virtual BOOL   PreTranslateMessage(MSG*   pMsg); | ||||
|  | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
| public: | ||||
| 	virtual BOOL    OnInitDialog(); | ||||
| 	void    InitLocalCamera(); | ||||
|  | ||||
| public: | ||||
|  | ||||
| 	CFastView      m_FastCam[4]; | ||||
| 	std::vector<MV3D_RGBD_DEVICE_INFO> m_CameraDev; | ||||
| 	 | ||||
|  | ||||
| 	afx_msg void OnTimer(UINT_PTR nIDEvent); | ||||
| 	void ProcessPipeMsg(int lMsgId, char* pData, int lLen); | ||||
| }; | ||||
							
								
								
									
										398
									
								
								Plugin/Fast/FastView.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										398
									
								
								Plugin/Fast/FastView.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,398 @@ | ||||
| // PictureView.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD> | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| #include "resource.h" | ||||
| #include "FastView.h" | ||||
| #include "DahuaFisheyeCamera.h" | ||||
| #include "HikRgdbCamera.h" | ||||
|  | ||||
| //ͼ<><CDBC><EFBFBD>ߴ<EFBFBD><DFB4><EFBFBD><EFBFBD><EFBFBD> | ||||
| enum | ||||
| { | ||||
| 	IMG_SIZE_NORMAL,					//ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD>߾<EFBFBD><DFBE>ڻ<EFBFBD>ͼ<EFBFBD><CDBC>Χ<EFBFBD><CEA7> | ||||
| 	IMG_SIZE_WIDTH_BEYOND,				//<2F><>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD>ȳ<EFBFBD><C8B3><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>Χ | ||||
| 	IMG_SIZE_HEIGHT_BEYOND,				//<2F><>ͼ<EFBFBD><CDBC><EFBFBD>߶ȳ<DFB6><C8B3><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>Χ | ||||
| 	IMG_SIZE_BOTH_BEYOND				//ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD>߾<EFBFBD><DFBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>Χ | ||||
| }; | ||||
| // CPictureView | ||||
|  | ||||
| IMPLEMENT_DYNAMIC(CFastView, CStatic) | ||||
|  | ||||
| CFastView::CFastView() | ||||
| { | ||||
| 	m_pCameraDlg = NULL; | ||||
| } | ||||
|  | ||||
| CFastView::~CFastView() | ||||
| { | ||||
| } | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CFastView, CStatic) | ||||
| 	ON_WM_PAINT() | ||||
| 	ON_WM_SIZE() | ||||
| 	ON_WM_CTLCOLOR() | ||||
| 	ON_WM_RBUTTONUP() | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
|  | ||||
|  | ||||
| // CPictureView <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| void CFastView::StartPlay(CString strFile) | ||||
| { | ||||
| 	StopPlay(); | ||||
| 	m_Image.Destroy(); | ||||
| 	ShowWindow(SW_SHOW); | ||||
| 	if (0 == strFile.GetLength()) | ||||
| 		return; | ||||
|  | ||||
| 	m_Image.Load(strFile); //<2F><><EFBFBD><EFBFBD>ͼƬ·<C6AC><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ | ||||
| 	DrawPicture(); | ||||
| 	 | ||||
|  | ||||
| } | ||||
|  | ||||
| void CFastView::StopPlay() | ||||
| { | ||||
| 	m_Image.Destroy(); | ||||
| 	UpdateWindow(); | ||||
| 	ShowWindow(SW_HIDE); | ||||
| } | ||||
|  | ||||
|  | ||||
| void CFastView::CalculateImageRect() | ||||
| {	//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰͼ<C7B0><CDBC>Ϊ<EFBFBD>գ<EFBFBD><D5A3><EFBFBD> | ||||
| 	if (m_Image.IsNull()) | ||||
| 		return; | ||||
|  | ||||
| 	CRect rectWnd; | ||||
| 	GetWindowRect(&rectWnd); | ||||
| 	int MemWidth  = rectWnd.Width(); | ||||
| 	int MemHeight = rectWnd.Height(); | ||||
|  | ||||
| 	//m_ImageRect = CRect(0, 0, MemWidth, MemHeight); //ȫ<><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	//return; | ||||
|  | ||||
| 	//<2F><>ȡͼ<C8A1><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	CRect rectImg = CRect(0, 0, m_Image.GetWidth(), m_Image.GetHeight()); | ||||
|  | ||||
| 	int ImgWidth = rectImg.Width(); | ||||
| 	int ImgHeight = rectImg.Height(); | ||||
| 	int	nImgSizeType;					//ͼ<><CDBC><EFBFBD>ߴ<EFBFBD><DFB4><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
| 										//Ĭ<>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD>ͶӰ<CDB6><D3B0><EFBFBD><EFBFBD> | ||||
| 	int nGap = 0; | ||||
|  | ||||
| 	//<2F><>ȡ<EFBFBD><C8A1>ǰͼ<C7B0><CDBC><EFBFBD>ߴ<EFBFBD><DFB4><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	if ((ImgWidth <= MemWidth - nGap) && (ImgHeight <= MemHeight - nGap)) | ||||
| 		nImgSizeType = IMG_SIZE_NORMAL; | ||||
| 	else if ((ImgWidth>MemWidth - nGap) && (ImgHeight <= MemHeight - nGap)) | ||||
| 		nImgSizeType = IMG_SIZE_WIDTH_BEYOND; | ||||
| 	else if ((ImgWidth <= MemWidth - nGap) && (ImgHeight>MemHeight - nGap)) | ||||
| 		nImgSizeType = IMG_SIZE_HEIGHT_BEYOND; | ||||
| 	else | ||||
| 		nImgSizeType = IMG_SIZE_BOTH_BEYOND; | ||||
|  | ||||
| 	//<2F>Բ<EFBFBD>ͬ<EFBFBD><CDAC>ͼ<EFBFBD><CDBC><EFBFBD>ߴ磬<DFB4><E7A3AC><EFBFBD><EFBFBD>ͶӰ<CDB6><D3B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	switch (nImgSizeType) | ||||
| 	{ | ||||
| 		float fScaleW, fScaleH;		//X<><58>Y<EFBFBD><59><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1> | ||||
| 		int nW, nH; | ||||
| 		//ֻ<>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Χ | ||||
| 	case IMG_SIZE_WIDTH_BEYOND: | ||||
| 		fScaleW = ((double)MemWidth) / ImgWidth; | ||||
| 		nW = MemWidth; | ||||
| 		nH = fScaleW*ImgHeight; | ||||
| 		m_ImageRect = CRect((MemWidth - nW) / 2 + nGap, | ||||
| 			(MemHeight - nH) / 2, | ||||
| 			(MemWidth + nW) / 2 - nGap, | ||||
| 			(MemHeight + nH) / 2); | ||||
| 		break; | ||||
| 		//ֻ<>и߳<D0B8><DFB3><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Χ | ||||
| 	case IMG_SIZE_HEIGHT_BEYOND: | ||||
| 		fScaleH = ((double)MemHeight) / ImgHeight; | ||||
| 		nW = fScaleH*ImgWidth; | ||||
| 		nH = MemHeight; | ||||
| 		m_ImageRect = CRect((MemWidth - nW) / 2, | ||||
| 			(MemHeight - nH) / 2 + nGap, | ||||
| 			(MemWidth + nW) / 2, | ||||
| 			(MemHeight + nH) / 2 - nGap); | ||||
| 		break; | ||||
| 		//<2F><><EFBFBD>߶<EFBFBD><DFB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Χ | ||||
| 		//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Χ<EFBFBD><CEA7> | ||||
| 	case IMG_SIZE_BOTH_BEYOND: | ||||
| 	case IMG_SIZE_NORMAL: | ||||
| 		fScaleW = ((double)MemWidth) / ImgWidth; | ||||
| 		fScaleH = ((double)MemHeight) / ImgHeight; | ||||
| 		float fScale = min(fScaleW, fScaleH); | ||||
| 		nW = fScale*ImgWidth; | ||||
| 		nH = fScale*ImgHeight; | ||||
| 		m_ImageRect = CRect((MemWidth - nW) / 2 + nGap, | ||||
| 			(MemHeight - nH) / 2 + nGap, | ||||
| 			(MemWidth + nW) / 2 - nGap, | ||||
| 			(MemHeight + nH) / 2 - nGap); | ||||
| 		break; | ||||
| 	} | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| void CFastView::OnPaint() | ||||
| { | ||||
| 	CPaintDC dc(this); // device context for painting | ||||
| 					   // TODO: <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 					   // <20><>Ϊ<EFBFBD><CEAA>ͼ<EFBFBD><CDBC>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD> CStatic::OnPaint() | ||||
| 	if (FALSE == m_Image.IsNull()) | ||||
| 	{ | ||||
| 		CDC *pDC = GetDC();//<2F><><EFBFBD><EFBFBD>pictrue<75>ؼ<EFBFBD><D8BC><EFBFBD>DC | ||||
| 						   //<2F><><EFBFBD><EFBFBD>CIMage<67><65><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 		SetStretchBltMode(pDC->m_hDC, HALFTONE); | ||||
| 		SetBrushOrgEx(pDC->m_hDC, 0, 0, NULL); | ||||
|  | ||||
|  | ||||
| 		CRect rectWnd = { 0 }; | ||||
| 		GetWindowRect(&rectWnd); | ||||
| 		//<2F>ػ<EFBFBD><D8BB><EFBFBD>ɫ						  | ||||
| 		pDC->FillSolidRect(CRect(0, 0, rectWnd.Width(), rectWnd.Height()), RGB(0, 0, 0)); | ||||
| 		//m_Image.StretchBlt(pDC->GetSafeHdc(), m_ImageRect, CRect(0, 0, m_Image.GetWidth(), m_Image.GetHeight())); | ||||
| 		m_Image.Draw(pDC->m_hDC, m_ImageRect); //<2F><>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD>Picture<72>ؼ<EFBFBD><D8BC><EFBFBD>ʾ<EFBFBD>ľ<EFBFBD><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 		ReleaseDC(pDC);//<2F>ͷ<EFBFBD>picture<72>ؼ<EFBFBD><D8BC><EFBFBD>DC | ||||
| 	} | ||||
| } | ||||
|  | ||||
|  | ||||
| void CFastView::OnSize(UINT nType, int cx, int cy) | ||||
| { | ||||
| 	CStatic::OnSize(nType, cx, cy); | ||||
| 	DrawPicture(); | ||||
| 	// TODO: <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| } | ||||
|  | ||||
|  | ||||
| void CFastView::DrawPicture() | ||||
| { | ||||
| 	if (FALSE == m_Image.IsNull()) | ||||
| 	{ | ||||
| 		CalculateImageRect(); | ||||
|  | ||||
| 		if (m_ImageRect.Width() <= 0) | ||||
| 			return; | ||||
|  | ||||
| 		CDC *pDC = GetDC();//<2F><><EFBFBD><EFBFBD>pictrue<75>ؼ<EFBFBD><D8BC><EFBFBD>DC | ||||
| 		CRect rectWnd; | ||||
| 		GetWindowRect(&rectWnd); | ||||
|  | ||||
| 		//<2F>ػ<EFBFBD><D8BB><EFBFBD>ɫ						  | ||||
| 		//pDC->FillSolidRect(CRect(0, 0, rectWnd.Width(), rectWnd.Height()), RGB(0, 0, 0)); | ||||
|  | ||||
| 		//<2F><><EFBFBD><EFBFBD>CIMage<67><65><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 		//SetStretchBltMode(pDC->m_hDC, HALFTONE); | ||||
| 		//SetBrushOrgEx(pDC->m_hDC, 0, 0, NULL); | ||||
| 		SetStretchBltMode(pDC->m_hDC, COLORONCOLOR); | ||||
| 		SetBrushOrgEx(pDC->m_hDC, 0, 0, NULL); | ||||
| 		//dc.SetStretchBltMode | ||||
|  | ||||
| 		//m_Image.StretchBlt(pDC->GetSafeHdc(), CRect(0, 0, m_Image.GetWidth(), m_Image.GetHeight()), m_ImageRect); | ||||
|  | ||||
|  | ||||
| 		m_Image.Draw(pDC->GetSafeHdc(), m_ImageRect); //<2F><>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD>Picture<72>ؼ<EFBFBD><D8BC><EFBFBD>ʾ<EFBFBD>ľ<EFBFBD><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 		ReleaseDC(pDC);//<2F>ͷ<EFBFBD>picture<72>ؼ<EFBFBD><D8BC><EFBFBD>DC | ||||
| 	} | ||||
|  | ||||
| } | ||||
|  | ||||
| HBRUSH CFastView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) | ||||
| { | ||||
| 	HBRUSH hbr = CStatic::OnCtlColor(pDC, pWnd, nCtlColor); | ||||
|  | ||||
| 	CBrush brush; | ||||
| 	brush.CreateSolidBrush(RGB(0, 0, 0)); | ||||
|  | ||||
| 	// TODO:  <20>ڴ˸<DAB4><CBB8><EFBFBD> DC <20><><EFBFBD>κ<EFBFBD><CEBA><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	pDC->SetBkColor(RGB(0, 0, 0)); | ||||
| 	return (HBRUSH)brush; | ||||
|  | ||||
| 	// TODO:  <20><><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϵIJ<CFB5><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>軭<EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD><F2B7B5BB><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	return hbr; | ||||
| } | ||||
|  | ||||
| UINT CFastView::CameraThreadFunc(PVOID pv) | ||||
| { | ||||
| 	//ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>Ϊÿ<CEAA><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD> | ||||
|  | ||||
| 	ST_THREAD_PARAM   *pParam = (ST_THREAD_PARAM  *)pv; | ||||
| 	CFastView *pThis = (CFastView*)pParam->pParent; | ||||
| 	int nIdx = pParam->nIdx; | ||||
| 	delete pv; | ||||
|  | ||||
| 	if (pThis->m_nCameraTyp == HIK_RGBD) | ||||
| 	{ | ||||
| 		pThis->m_pCameraDlg = new CHikRgdbCamera(pThis, nIdx); | ||||
| 		pThis->m_pCameraDlg->Create(IDD_DLG_CAM); | ||||
| 		pThis->m_pCameraDlg->ShowWindow(SW_HIDE); | ||||
| 	} | ||||
| 	else if (pThis->m_nCameraTyp == DAHUA_FISHEYE) | ||||
| 	{ | ||||
| 		pThis->m_pCameraDlg = new CDahuaFisheyeCamera(pThis, nIdx, pThis->m_nPlayTyp); | ||||
| 		pThis->m_pCameraDlg->Create(IDD_DLG_CAM); | ||||
| 		pThis->m_pCameraDlg->ShowWindow(SW_HIDE); | ||||
| 	} | ||||
| 	 | ||||
| 	/*else if (pThis->m_nCameraTyp == DAHUA_FISHEYE_LIVE) | ||||
| 	{ | ||||
| 		pThis->m_pCameraDlg = new CDahuaFisheyeLiveCamera(pThis, nIdx); | ||||
| 		pThis->m_pCameraDlg->Create(IDD_DLG_CAM); | ||||
| 		pThis->m_pCameraDlg->ShowWindow(SW_HIDE); | ||||
| 	}*/ | ||||
|  | ||||
| 	//The message loop    | ||||
| 	MSG msg; | ||||
| 	while (GetMessage(&msg, NULL, 0, 0)) | ||||
| 	{ | ||||
| 		TranslateMessage(&msg); | ||||
| 		DispatchMessage(&msg); | ||||
| 	} | ||||
|  | ||||
| 	pThis->m_pCameraDlg->DestroyWindow(); | ||||
| 	delete pThis->m_pCameraDlg; | ||||
|  | ||||
| 	TRACE(_T("<EFBFBD>ͷŶԻ<EFBFBD><EFBFBD><EFBFBD>")); | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
|  | ||||
| void  CFastView::SetCameraInfo(int nIdx, ENUM_CAMERA_TYPE enCameraType, ENUM_PLAY_TYPE enPlayType, String strIp, int nPort) | ||||
| { | ||||
| 	m_nCameraIdx = nIdx; | ||||
| 	m_nCameraTyp = enCameraType; | ||||
| 	m_nPlayTyp   = enPlayType; | ||||
| 	 | ||||
| 	ST_THREAD_PARAM  *pParam = new ST_THREAD_PARAM; | ||||
| 	pParam->nIdx             = nIdx; | ||||
| 	pParam->pParent          = this; | ||||
| 	AfxBeginThread(CFastView::CameraThreadFunc, (void*)pParam); | ||||
|  | ||||
| 	return; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| void CFastView::OnRButtonUp(UINT nFlags, CPoint point) | ||||
| { | ||||
| 	// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ | ||||
| 	// TODO: Add your message handler code here and/or call default | ||||
| 	CMenu menu; | ||||
| 	menu.CreatePopupMenu(); | ||||
| 	//<2F><><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>Dz˵<C7B2><CBB5><EFBFBD> | ||||
| 	menu.AppendMenu(MF_STRING, ID_MRU_SAMPLE, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"); | ||||
| 	//menu.AppendMenu(MF_STRING, WM TEST2, "Test item 2"); | ||||
| 	//menu.AppendMenu(MF_STRING, WM TEST3, "Test item 3"); | ||||
| 	//menu.AppendMenu(MF_STRING, WM TEST4, "Test item 4"); | ||||
| 	//<2F><><EFBFBD>һ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>·<EFBFBD>20<32><30><EFBFBD>صĵط<C4B5><D8B7><EFBFBD>ʾ<EFBFBD>˵<EFBFBD> | ||||
| 	POINT tpoint; | ||||
| 	tpoint.x = point.x; | ||||
| 	tpoint.y = point.y; | ||||
|  | ||||
| 	ClientToScreen(&tpoint); | ||||
| 	menu.TrackPopupMenu(TPM_LEFTALIGN, tpoint.x, tpoint.y + 20, this); | ||||
|  | ||||
| 	CStatic::OnRButtonDown(nFlags, point); | ||||
| } | ||||
|  | ||||
| BOOL CFastView::OnCommand(WPARAM wParam, LPARAM lParam) | ||||
| { | ||||
| 	// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>ר<EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD> | ||||
| 	switch (LOWORD(wParam)) | ||||
| 	{ | ||||
| 	case ID_MRU_SAMPLE: | ||||
| 	{ | ||||
| 		/*CString strMsg; | ||||
| 		strMsg.Format("<22><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ%d<><64><EFBFBD><EFBFBD>", m_nCameraIndex); | ||||
| 		AfxMessageBox(strMsg);*/ | ||||
| 		if (NULL != m_pCameraDlg) | ||||
| 		{ | ||||
| 			::PostMessage(m_pCameraDlg->m_hWnd, WM_CAMERA_SNAP, NULL, NULL); | ||||
| 		} | ||||
| 		//((CMainFrame*)GetParentFrame())->BeginSample(m_nCameraIndex); | ||||
| 		break; | ||||
| 	} | ||||
| 	default: | ||||
| 		break; | ||||
| 	} | ||||
| 	return CStatic::OnCommand(wParam, lParam); | ||||
| } | ||||
|  | ||||
| //<2F><><EFBFBD><EFBFBD>1<EFBFBD><31>opencv<63><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> | ||||
| //<2F><><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD>Ҫչʾ<D5B9><CABE>Picture Control<6F><6C>ID | ||||
| void CFastView::DrawMat(cv::Mat& imageMat, int nOffset) | ||||
| { | ||||
| 	/*cv::Mat img; | ||||
| 	 | ||||
| 	int nWidth = imageMat.cols * rect.Height() *1.0 / imageMat.rows; | ||||
| 	cv::resize(imageMat, img, cv::Size(nWidth, rect.Height()));// <20><><EFBFBD><EFBFBD>Mat<61><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	// תһ<D7AA>¸<EFBFBD>ʽ ,<2C><><EFBFBD>ο<EFBFBD><CEBF>Է<EFBFBD><D4B7><EFBFBD><EFBFBD><EFBFBD>,*/ | ||||
|  | ||||
| 	/*switch (imgTmp.channels()) | ||||
| 	{ | ||||
| 	case 1: | ||||
| 	cv::cvtColor(imgTmp, imgTmp, CV_GRAY2BGRA); // GRAY<41><59>ͨ<EFBFBD><CDA8> | ||||
| 	break; | ||||
| 	case 3: | ||||
| 	cv::cvtColor(imgTmp, imgTmp, CV_BGR2BGRA);  // BGR<47><52>ͨ<EFBFBD><CDA8> | ||||
| 	break; | ||||
| 	default: | ||||
| 	break; | ||||
| 	} | ||||
| 	int pixelBytes = imgTmp.channels() * (imgTmp.depth() + 1); // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6>ٸ<EFBFBD><D9B8>ֽ<EFBFBD> | ||||
| 	// <20><><EFBFBD><EFBFBD>bitmapinfo(<28><><EFBFBD><EFBFBD>ͷ) | ||||
| 	BITMAPINFO bitInfo; | ||||
| 	bitInfo.bmiHeader.biBitCount = 8 * pixelBytes; | ||||
| 	bitInfo.bmiHeader.biWidth = imgTmp.cols; | ||||
| 	bitInfo.bmiHeader.biHeight = -imgTmp.rows; | ||||
| 	bitInfo.bmiHeader.biPlanes = 1; | ||||
| 	bitInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | ||||
| 	bitInfo.bmiHeader.biCompression = BI_RGB; | ||||
| 	bitInfo.bmiHeader.biClrImportant = 0; | ||||
| 	bitInfo.bmiHeader.biClrUsed = 0; | ||||
| 	bitInfo.bmiHeader.biSizeImage = 0; | ||||
| 	bitInfo.bmiHeader.biXPelsPerMeter = 0; | ||||
| 	bitInfo.bmiHeader.biYPelsPerMeter = 0; | ||||
| 	// Mat.data + bitmap<61><70><EFBFBD><EFBFBD>ͷ -> MFC | ||||
| 	CDC* pDC = GetDC(); | ||||
| 	::StretchDIBits( | ||||
| 	pDC->GetSafeHdc(), | ||||
| 	(rect.Width()-nWidth)/2, 0, nWidth, rect.Height(), | ||||
| 	0, 0, nWidth, rect.Height(), | ||||
| 	imgTmp.data, | ||||
| 	&bitInfo, | ||||
| 	DIB_RGB_COLORS, | ||||
| 	SRCCOPY | ||||
| 	); | ||||
| 	ReleaseDC(pDC);*/ | ||||
|  | ||||
| 	CImage image; | ||||
| 	image.Create(imageMat.cols, imageMat.rows, 24); | ||||
| 	for (int y = 0; y < imageMat.rows; ++y) { | ||||
| 		const uchar* src = imageMat.ptr<uchar>(y); | ||||
| 		uchar* dst = reinterpret_cast<uchar*>(image.GetBits()) + y * image.GetPitch(); | ||||
| 		for (int x = 0; x < imageMat.cols; ++x) { | ||||
| 			dst[0] = src[0]; | ||||
| 			dst[1] = src[1]; | ||||
| 			dst[2] = src[2]; | ||||
| 			src += 3; | ||||
| 			dst += 3; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	HDC hdc = ::GetDC(m_hWnd); | ||||
|  | ||||
| 	CRect rect; | ||||
| 	GetClientRect(&rect);  // <20><>ȡ<EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>С | ||||
| 	image.Draw(hdc, rect); | ||||
| 	image.Destroy(); | ||||
| 	::ReleaseDC(m_hWnd, hdc); | ||||
|  | ||||
| } | ||||
|  | ||||
							
								
								
									
										47
									
								
								Plugin/Fast/FastView.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								Plugin/Fast/FastView.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | ||||
| #pragma once | ||||
|  | ||||
|  | ||||
| // CFastView | ||||
| class CBaseCamera; | ||||
| class CFastView : public CStatic | ||||
| { | ||||
| 	DECLARE_DYNAMIC(CFastView) | ||||
|  | ||||
| public: | ||||
| 	CFastView(); | ||||
| 	virtual ~CFastView(); | ||||
| 	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); | ||||
|  | ||||
| protected: | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
|  | ||||
| public: | ||||
| 	void     StartPlay(CString strFile); | ||||
| 	void     StopPlay(); | ||||
| 	void     DrawPicture(); | ||||
| 	void     CalculateImageRect(); | ||||
| 	CImage   m_Image; //<2F><><EFBFBD><EFBFBD>ͼƬ<CDBC><C6AC> | ||||
| 	CRect	 m_ImageRect; | ||||
| 	CBrush   m_bkBrush; | ||||
|  | ||||
| public:	 | ||||
| 	afx_msg void   OnPaint(); | ||||
| 	afx_msg void   OnSize(UINT nType, int cx, int cy); | ||||
| 	afx_msg void   OnRButtonUp(UINT nFlags, CPoint point); | ||||
| 	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); | ||||
| 	 | ||||
|  | ||||
| public: | ||||
| 	void             SetCameraInfo(int nIdx, ENUM_CAMERA_TYPE, ENUM_PLAY_TYPE, String strIp = "", int nPort = 0); | ||||
| 	void             DrawMat(cv::Mat& imageMat, int nOffset); | ||||
| 	static UINT      CameraThreadFunc(PVOID pv); | ||||
| 	CBaseCamera     *m_pCameraDlg; | ||||
| 	int              m_nCameraIdx; | ||||
| 	ENUM_CAMERA_TYPE m_nCameraTyp; | ||||
| 	ENUM_PLAY_TYPE   m_nPlayTyp; | ||||
| 	 | ||||
| 	 | ||||
| 	 | ||||
| }; | ||||
|  | ||||
|  | ||||
							
								
								
									
										295
									
								
								Plugin/Fast/HikRgdbCamera.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										295
									
								
								Plugin/Fast/HikRgdbCamera.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,295 @@ | ||||
| // MsgHandleDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD> | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| #include "Fast.h" | ||||
| #include "HikRgdbCamera.h" | ||||
| #include "afxdialogex.h" | ||||
| #include "FastView.h" | ||||
| #include "RenderImage.hpp" | ||||
|  | ||||
|  | ||||
|  | ||||
| #define IMAGE_W 1280 | ||||
| #define IMAGE_H 720 | ||||
| char rgb24[IMAGE_W * IMAGE_H * 3]; | ||||
|  | ||||
|  | ||||
| #define TIMER_LOGIN             10 | ||||
|  | ||||
|  | ||||
| // CMsgHandleDlg <20>Ի<EFBFBD><D4BB><EFBFBD> | ||||
|  | ||||
| IMPLEMENT_DYNAMIC(CHikRgdbCamera, CBaseCamera) | ||||
|  | ||||
| CHikRgdbCamera::CHikRgdbCamera(CFastView * pParentWnd, int nIdx, CWnd* pParent /*=NULL*/) | ||||
| 	: CBaseCamera(IDD_DLG_CAM, pParentWnd) | ||||
| { | ||||
| 	m_nCameraIdx    = nIdx; | ||||
| 	m_pParentWnd    = pParentWnd; | ||||
| 	m_hCameraHandle = NULL; | ||||
| } | ||||
|  | ||||
| CHikRgdbCamera::~CHikRgdbCamera() | ||||
| { | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
| void CHikRgdbCamera::DoDataExchange(CDataExchange* pDX) | ||||
| { | ||||
| 	CDialog::DoDataExchange(pDX); | ||||
| } | ||||
|  | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CHikRgdbCamera, CDialog) | ||||
| 	ON_WM_DESTROY() | ||||
| 	ON_WM_TIMER() | ||||
| 	ON_MESSAGE(WM_CAMERA_SNAP, &CHikRgdbCamera::OnSnap) | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
|  | ||||
|  | ||||
| short CHikRgdbCamera::GetPointDepth(unsigned char * pSrcData, int x, int y) | ||||
| { | ||||
| 	if (nullptr == pSrcData) | ||||
| 	{ | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	int nDepth = 0; | ||||
| 	int nMax = INT_MIN; | ||||
| 	int nMin = INT_MAX; | ||||
|  | ||||
| 	short* pValue = (short*)pSrcData; | ||||
|  | ||||
| 	if (C16_INVALID_VALUE == nDepth) | ||||
| 	{ | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	return pValue[y * IMAGE_W + x]; | ||||
| } | ||||
|  | ||||
| short CHikRgdbCamera::GeRectDepth(unsigned char * pSrcData, cv::Point2f lt, cv::Point2f rb) | ||||
| { | ||||
| 	int nMin = 999999; | ||||
| 	for (int i = lt.x; i < rb.x; i++) | ||||
| 	{ | ||||
| 		for (int j = lt.y; j < rb.y; j++) | ||||
| 		{ | ||||
| 			int depth = GetPointDepth(pSrcData, i, j); | ||||
| 			if (depth < nMin && depth > 0) | ||||
| 			{ | ||||
| 				nMin = depth; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nMin; | ||||
| } | ||||
|  | ||||
|  | ||||
| // CMsgHandleDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
|  | ||||
| BOOL CHikRgdbCamera::OnInitDialog() | ||||
| { | ||||
| 	CDialog::OnInitDialog(); | ||||
| 	InitCameraSDK(); | ||||
| 	return TRUE;  // return TRUE unless you set the focus to a control | ||||
| } | ||||
|  | ||||
|  | ||||
| BOOL CHikRgdbCamera::InitCameraSDK() | ||||
| { | ||||
|  | ||||
| 	MV3D_RGBD_VERSION_INFO stVersion; | ||||
| 	MV3D_RGBD_GetSDKVersion(&stVersion); | ||||
| 	MV3D_RGBD_Initialize(); | ||||
| 	int ret = MV3D_RGBD_Initialize(); | ||||
|  | ||||
| 	unsigned int nDevNum = 0; | ||||
| 	ret = MV3D_RGBD_GetDeviceNumber(DeviceType_USB, &nDevNum); | ||||
|  | ||||
| 	if (0 == nDevNum) | ||||
| 	{ | ||||
| 		//AfxMessageBox("δ<><CEB4><EFBFBD><EFBFBD><E2B5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>."); | ||||
| 		return FALSE; | ||||
| 	} | ||||
|  | ||||
| 	std::vector<MV3D_RGBD_DEVICE_INFO> devs(nDevNum); | ||||
| 	ret = MV3D_RGBD_GetDeviceList(DeviceType_USB, &devs[0], nDevNum, &nDevNum); | ||||
|  | ||||
| 	//<2F><><EFBFBD><EFBFBD><EFBFBD>豸 | ||||
| 	MV3D_RGBD_OpenDevice(&m_hCameraHandle, &devs[0]); | ||||
| 	//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	MV3D_RGBD_Start(m_hCameraHandle); | ||||
|  | ||||
| 	return TRUE;  // return TRUE unless you set the focus to a control | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| LRESULT  CHikRgdbCamera::OnSnap(WPARAM wParam, LPARAM lParam) | ||||
| { | ||||
| 	AfxMessageBox("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"); | ||||
| 	MV3D_RGBD_FRAME_DATA stFrameData = { 0 }; | ||||
| 	int nRet = MV3D_RGBD_FetchFrame(m_hCameraHandle, &stFrameData, 5000); | ||||
| 	CTime currentTime = CTime::GetCurrentTime(); // <20><>ȡ<EFBFBD><C8A1>ǰʱ<C7B0><CAB1> | ||||
| 	CString dateStr = currentTime.Format(_T("%Y_%m_%d")); // <20><>ʽ<EFBFBD><CABD>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> | ||||
| 	CString tiemStr = currentTime.Format(_T("%H_%M_%S")); // <20><>ʽ<EFBFBD><CABD>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> | ||||
| 	CString strPath = theApp.m_strDataPath + "\\" + dateStr; | ||||
| 	 | ||||
| 	if (MV3D_RGBD_OK == nRet) | ||||
| 	{ | ||||
| 		if (!stFrameData.nValidInfo) | ||||
| 		{ | ||||
| 			RIFrameInfo depth = { 0 }; | ||||
| 			RIFrameInfo rgb = { 0 }; | ||||
| 			RIFrameInfo rgbd = { 0 }; | ||||
| 			parseFrame(&stFrameData, &depth, &rgb, &rgbd); | ||||
|  | ||||
| 			/*for (int i = 0; i < 20; i++) | ||||
| 			{ | ||||
| 				for (int j = 0; j < 10; j++) | ||||
| 				{ | ||||
| 					int nDepth = GeRectDepth(depth.pData, cv::Point2f(i * 64, j * 72), cv::Point2f((i + 1) * 64, (j + 1) * 72)); | ||||
| 					char acDepth[32]; | ||||
| 					sprintf(acDepth, "%d", nDepth); | ||||
| 					cv::rectangle(image, cv::Point2f(i * 64, j * 72), cv::Point2f((i + 1) * 64, (j + 1) * 72), cv::Scalar(5, 5, 2555), 1, 8, 0); | ||||
| 					cv::putText(image, acDepth, cv::Point2f(i * 64, j * 72 + 20), cv::FONT_HERSHEY_COMPLEX_SMALL, 1.0, cv::Scalar(5, 5, 255), 1); | ||||
| 				} | ||||
| 			}*/ | ||||
|  | ||||
| 			if (!PathIsDirectory(strPath))//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>      | ||||
| 			{ | ||||
| 				CreateDirectory(strPath, NULL);//<2F>½<EFBFBD><C2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> | ||||
| 			} | ||||
|  | ||||
| 			char acFileName[256] = ""; | ||||
| 			sprintf(acFileName, "%s\\%s-%d.jpg", strPath, tiemStr, m_nCameraIdx); | ||||
|  | ||||
| 			vector<CRect>  targetRects; | ||||
| 			cv::Mat image(IMAGE_H, IMAGE_W, CV_8UC3, rgb.pData); //bufferΪת<CEAA><D7AA><EFBFBD><EFBFBD>rgb<67><62><EFBFBD><EFBFBD> | ||||
| 			//ʶ<><CAB6>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB> | ||||
| 			TargetDetection(m_nCameraIdx, image, targetRects); | ||||
|  | ||||
| 			//ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 			targetRects.push_back(CRect(500, 400, 900, 600)); | ||||
|  | ||||
| 			//<2F><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 			cv::Point3f  coordinate = cv::Point3f(0, 0, 99999); | ||||
| 			CRect        rect; | ||||
| 			TargetPosition(depth.pData, targetRects, coordinate, rect); | ||||
| 			if (coordinate.z != 99999) | ||||
| 			{ | ||||
| 				char acCoordinate[32]; | ||||
| 				sprintf(acCoordinate, "x:%.0f, y:%.0f, z:%.0f", coordinate.x, coordinate.y, coordinate.z); | ||||
| 				cv::rectangle(image, cv::Point2f(rect.left, rect.top), cv::Point2f(rect.right, rect.bottom), cv::Scalar(5, 5, 2555), 1, 8, 0); | ||||
| 				cv::putText(image, acCoordinate, cv::Point2f(coordinate.x, coordinate.y), cv::FONT_HERSHEY_COMPLEX_SMALL, 1.0, cv::Scalar(5, 5, 255), 1); | ||||
|  | ||||
| 				 | ||||
| 				//m_pParentWnd->CameraSnapPicRet(acFileName, m_nCameraIdx, coordinate); | ||||
| 			} | ||||
|  | ||||
| 			//<2F><><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD>ļ<EFBFBD> | ||||
| 			imwrite(acFileName, image); | ||||
| 			//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
| 			m_pParentWnd->StartPlay(acFileName); | ||||
|  | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CHikRgdbCamera::OnTimer(UINT_PTR nIDEvent) | ||||
| { | ||||
| 	// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ | ||||
| 	if (nIDEvent == TIMER_LOGIN) | ||||
| 	{ | ||||
| 		//<2F>豸<EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><C2B4><EFBFBD> | ||||
| 	} | ||||
|  | ||||
| 	CDialog::OnTimer(nIDEvent); | ||||
| } | ||||
|  | ||||
|  | ||||
| void CHikRgdbCamera::OnDestroy() | ||||
| { | ||||
| 	CDialog::OnDestroy(); | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| void CHikRgdbCamera::TargetDetection(int nCameraIdx, cv::Mat &mat_img, vector<CRect> &findRects) | ||||
| { | ||||
| 	CRect  findRect; | ||||
| 	try { | ||||
| 		cv::Mat dst = mat_img; | ||||
| 		//cv::Size newSize(mat_img.size().width / 4, mat_img.size().height / 4); // <20><><EFBFBD><EFBFBD><EFBFBD>µijߴ<C4B3> | ||||
| 		//cv::resize(mat_img, dst, newSize); // <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ߴ<EFBFBD> | ||||
|  | ||||
| 		auto det_image = theApp.m_yoloV4.m_pDetector->mat_to_image_resize(dst); | ||||
|  | ||||
| 		auto start = std::chrono::steady_clock::now(); | ||||
| 		std::vector<bbox_t> result_vec = theApp.m_yoloV4.m_pDetector->detect_resized(*det_image, dst.size().width, dst.size().height); | ||||
| 		auto end = std::chrono::steady_clock::now(); | ||||
| 		std::chrono::duration<double> spent = end - start; | ||||
| 		std::cout << " Time: " << spent.count() << " sec \n"; | ||||
|  | ||||
| 		theApp.m_yoloV4.DrawObjectBoxes(dst, result_vec, theApp.m_yoloV4.m_vObjects_Names); | ||||
|  | ||||
| 		for (int i = 0; i < result_vec.size(); i++) | ||||
| 		{ | ||||
| 			bbox_t  result_area = result_vec.at(i); | ||||
| 			std::string obj_name = theApp.m_yoloV4.m_vObjects_Names[result_area.obj_id]; | ||||
| 			//if (result_area.prob >= 0.9 && (0 == obj_name.compare("up") )) | ||||
| 			{ | ||||
| 				CRect  rect; | ||||
| 				rect.left = result_area.x; | ||||
| 				rect.top = result_area.y; | ||||
| 				rect.right = result_area.x + result_area.w; | ||||
| 				rect.bottom = result_area.y + result_area.h; | ||||
| 				findRects.push_back(rect); | ||||
| 			} | ||||
|  | ||||
| 		} | ||||
| 	} | ||||
| 	catch (std::exception &e) { std::cerr << "exception: " << e.what() << "\n"; getchar(); } | ||||
| 	catch (...) { std::cerr << "unknown exception \n"; getchar(); } | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
| void  CHikRgdbCamera::TargetPosition(unsigned char* pDepthData, vector<CRect> &findRects, cv::Point3f& coordinate, CRect& rect) | ||||
| { | ||||
| 	for (int i = 0; i < findRects.size(); i++) | ||||
| 	{ | ||||
| 		CRect  rt = findRects.at(i); | ||||
|  | ||||
| 		if (rt.Width() > rt.Height()) | ||||
| 		{ | ||||
| 			int x = (rt.left + rt.right) / 2; | ||||
| 			int y = (rt.top  + rt.bottom) / 2; | ||||
| 			int z = GetPointDepth(pDepthData, x, y); | ||||
|  | ||||
| 			if (z < coordinate.z && z > 0) | ||||
| 			{ | ||||
| 				coordinate = cv::Point3f(x, y, z); | ||||
| 				rect       = rt; | ||||
| 			} | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			//<2F><>ת90<39><30> | ||||
| 		} | ||||
| 		 | ||||
| 	} | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										41
									
								
								Plugin/Fast/HikRgdbCamera.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								Plugin/Fast/HikRgdbCamera.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "BaseCamera.h" | ||||
|  | ||||
| class CFastView; | ||||
| class CHikRgdbCamera : public CBaseCamera | ||||
| { | ||||
| 	DECLARE_DYNAMIC(CHikRgdbCamera) | ||||
|  | ||||
| public: | ||||
| 	CHikRgdbCamera(CFastView *, int nIdx, CWnd* pParent = NULL);   // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF> | ||||
| 	virtual ~CHikRgdbCamera(); | ||||
|  | ||||
| // <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| #ifdef AFX_DESIGN_TIME | ||||
| 	enum { IDD = IDD_DLG_CAM}; | ||||
| #endif | ||||
|  | ||||
| protected: | ||||
| 	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV ֧<><D6A7> | ||||
|  | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
|  | ||||
| public: | ||||
| 	CFastView      *m_pParentWnd; | ||||
| 	void*           m_hCameraHandle; | ||||
| 	virtual BOOL    OnInitDialog(); | ||||
| 	afx_msg void    OnDestroy(); | ||||
| 	afx_msg LRESULT OnSnap(WPARAM wParam, LPARAM lParam); | ||||
| 	afx_msg void    OnTimer(UINT_PTR nIDEvent); | ||||
| 	BOOL  InitCameraSDK(); | ||||
| 	short GetPointDepth(unsigned char * pSrcData, int x, int y); | ||||
| 	short GeRectDepth(unsigned char * pSrcData, cv::Point2f lt, cv::Point2f rb); | ||||
| 	void  TargetDetection(int nCameraIdx, cv::Mat &mat_img, vector<CRect> &findRects); | ||||
| 	void  TargetPosition(unsigned char* pDepthData, vector<CRect> &findRects, cv::Point3f& coordinate, CRect& rect); | ||||
|  | ||||
| public: | ||||
| 	int     m_nCameraIdx; | ||||
|  | ||||
|  | ||||
| }; | ||||
							
								
								
									
										136
									
								
								Plugin/Fast/YoloV4.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										136
									
								
								Plugin/Fast/YoloV4.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,136 @@ | ||||
|  | ||||
| // Vcs-Client.cpp : <20><><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA> | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| #include "YoloV4.h" | ||||
|  | ||||
| CYoloV4::CYoloV4() | ||||
| { | ||||
| 	InitYoloV4(); | ||||
| } | ||||
|  | ||||
| CYoloV4::~CYoloV4() | ||||
| { | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
| void   CYoloV4::InitYoloV4() | ||||
| { | ||||
| 	char path[1000]; | ||||
| 	int filelen = GetModuleFileName(NULL, path, 1000); | ||||
| 	int i = filelen; | ||||
| 	while (path[i] != '\\')i--; | ||||
| 	path[i + 1] = '\0'; | ||||
| 	CString   strModulePath = path; | ||||
|  | ||||
| 	CString   names_file   = strModulePath + "\\yolov4-tiny\\vocbox.names"; | ||||
| 	CString   cfg_file     = strModulePath + "\\yolov4-tiny\\yolov4-tiny-custom.cfg"; | ||||
| 	CString   weights_file = strModulePath + "\\yolov4-tiny\\yolov4-tiny-custom_last.weights"; | ||||
|  | ||||
| 	m_pDetector      = new Detector(cfg_file.GetBuffer(), weights_file.GetBuffer()); | ||||
| 	m_vObjects_Names = ObjectsNamesFromFile(names_file); | ||||
| } | ||||
|  | ||||
|  | ||||
| std::vector<std::string> CYoloV4::ObjectsNamesFromFile(CString  strFilename) | ||||
| { | ||||
| 	int pos = 0; | ||||
| 	CStdioFile file; | ||||
| 	CString strText = _T(""); | ||||
| 	std::vector<std::string> file_lines; | ||||
|  | ||||
| 	if (file.Open(strFilename, CFile::modeRead)) | ||||
| 	{ | ||||
| 		file.Seek(pos, CFile::begin); | ||||
| 		while (file.ReadString(strText)) | ||||
| 		{ | ||||
| 			pos = file.GetPosition();//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>; | ||||
| 			file_lines.push_back(strText.GetBuffer()); | ||||
| 		} | ||||
|  | ||||
| 		file.Close(); | ||||
| 		return file_lines; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CYoloV4::DrawObjectBoxes(cv::Mat mat_img, std::vector<bbox_t> result_vec, std::vector<std::string> obj_names, | ||||
| 	int current_det_fps, int current_cap_fps) | ||||
| { | ||||
| 	int const colors[6][3] = { { 1,0,1 },{ 0,0,1 },{ 0,1,1 },{ 0,1,0 },{ 1,1,0 },{ 1,0,0 } }; | ||||
|  | ||||
| 	for (auto &i : result_vec) { | ||||
| 		cv::Scalar color = obj_id_to_color(i.obj_id); | ||||
| 		cv::rectangle(mat_img, cv::Rect(i.x, i.y, i.w, i.h), color, 2); | ||||
| 		if (obj_names.size() > i.obj_id) { | ||||
| 			std::string obj_name = obj_names[i.obj_id]; | ||||
| 			if (i.track_id > 0) obj_name += " - " + std::to_string(i.track_id); | ||||
| 			cv::Size const text_size = getTextSize(obj_name, cv::FONT_HERSHEY_COMPLEX_SMALL, 1.2, 2, 0); | ||||
| 			int max_width = (text_size.width > i.w + 2) ? text_size.width : (i.w + 2); | ||||
| 			max_width = std::max(max_width, (int)i.w + 2); | ||||
| 			//max_width = std::max(max_width, 283); | ||||
| 			std::string coords_3d; | ||||
| 			if (!std::isnan(i.z_3d)) { | ||||
| 				std::stringstream ss; | ||||
| 				ss << std::fixed << std::setprecision(2) << "x:" << i.x_3d << "m y:" << i.y_3d << "m z:" << i.z_3d << "m "; | ||||
| 				coords_3d = ss.str(); | ||||
| 				cv::Size const text_size_3d = getTextSize(ss.str(), cv::FONT_HERSHEY_COMPLEX_SMALL, 0.8, 1, 0); | ||||
| 				int const max_width_3d = (text_size_3d.width > i.w + 2) ? text_size_3d.width : (i.w + 2); | ||||
| 				if (max_width_3d > max_width) max_width = max_width_3d; | ||||
| 			} | ||||
|  | ||||
| 			cv::rectangle(mat_img, cv::Point2f(std::max((int)i.x - 1, 0), std::max((int)i.y - 65, 0)), | ||||
| 				cv::Point2f(std::min((int)i.x + max_width, mat_img.cols - 1), std::min((int)i.y, mat_img.rows - 1)), | ||||
| 				color, CV_FILLED, 8, 0); | ||||
| 			putText(mat_img, obj_name, cv::Point2f(i.x, i.y - 16), cv::FONT_HERSHEY_COMPLEX_SMALL, 1.6, cv::Scalar(0, 0, 0), 4); | ||||
| 			if (!coords_3d.empty()) putText(mat_img, coords_3d, cv::Point2f(i.x, i.y - 1), cv::FONT_HERSHEY_COMPLEX_SMALL, 0.8, cv::Scalar(0, 0, 0), 1); | ||||
| 		} | ||||
| 	} | ||||
| 	if (current_det_fps >= 0 && current_cap_fps >= 0) { | ||||
| 		std::string fps_str = "FPS detection: " + std::to_string(current_det_fps) + "   FPS capture: " + std::to_string(current_cap_fps); | ||||
| 		putText(mat_img, fps_str, cv::Point2f(10, 20), cv::FONT_HERSHEY_COMPLEX_SMALL, 1.2, cv::Scalar(50, 255, 0), 2); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CYoloV4::TargetDetection(int nCameraIdx, cv::Mat &mat_img, vector<CRect> &findRects) | ||||
| { | ||||
| 	CRect  findRect; | ||||
| 	try { | ||||
| 		cv::Mat dst = mat_img; | ||||
| 		//cv::Size newSize(mat_img.size().width / 4, mat_img.size().height / 4); // <20><><EFBFBD><EFBFBD><EFBFBD>µijߴ<C4B3> | ||||
| 		//cv::resize(mat_img, dst, newSize); // <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ߴ<EFBFBD> | ||||
|  | ||||
| 		auto det_image = m_pDetector->mat_to_image_resize(dst); | ||||
|  | ||||
| 		auto start = std::chrono::steady_clock::now(); | ||||
| 		std::vector<bbox_t> result_vec = m_pDetector->detect_resized(*det_image, dst.size().width, dst.size().height); | ||||
| 		auto end = std::chrono::steady_clock::now(); | ||||
| 		std::chrono::duration<double> spent = end - start; | ||||
| 		std::cout << " Time: " << spent.count() << " sec \n"; | ||||
|  | ||||
| 		DrawObjectBoxes(dst, result_vec, m_vObjects_Names); | ||||
|  | ||||
| 		for (int i = 0; i < result_vec.size(); i++) | ||||
| 		{ | ||||
| 			bbox_t  result_area = result_vec.at(i); | ||||
| 			std::string obj_name = m_vObjects_Names[result_area.obj_id]; | ||||
| 			//if (result_area.prob >= 0.9 && (0 == obj_name.compare("up") )) | ||||
| 			{ | ||||
| 				CRect  rect; | ||||
| 				rect.left = result_area.x; | ||||
| 				rect.top = result_area.y; | ||||
| 				rect.right = result_area.x + result_area.w; | ||||
| 				rect.bottom = result_area.y + result_area.h; | ||||
| 				findRects.push_back(rect); | ||||
| 			} | ||||
|  | ||||
| 		} | ||||
| 	} | ||||
| 	catch (std::exception &e) { std::cerr << "exception: " << e.what() << "\n"; getchar(); } | ||||
| 	catch (...) { std::cerr << "unknown exception \n"; getchar(); } | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										23
									
								
								Plugin/Fast/YoloV4.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								Plugin/Fast/YoloV4.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| #pragma once | ||||
|  | ||||
| // CYoloV4 | ||||
| #include "yolo_v2_class.hpp" | ||||
|  | ||||
| class CYoloV4  | ||||
| { | ||||
| public: | ||||
| 	CYoloV4(); | ||||
| 	virtual ~CYoloV4(); | ||||
| 	void     InitYoloV4(); | ||||
|  | ||||
| public: | ||||
| 	 | ||||
| 	void DrawObjectBoxes(cv::Mat mat_img, std::vector<bbox_t> result_vec, std::vector<std::string> obj_names, int current_det_fps=-1, int current_cap_fps=-1); | ||||
| 	void TargetDetection(int nCameraIdx, cv::Mat &mat_img, vector<CRect> &findRects); | ||||
| 	std::vector<std::string>  ObjectsNamesFromFile(CString  strFilename); | ||||
| 	std::vector<std::string>  m_vObjects_Names;  //<2F><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	Detector  *m_pDetector; | ||||
|  | ||||
| }; | ||||
|  | ||||
|  | ||||
							
								
								
									
										
											BIN
										
									
								
								Plugin/Fast/fast.rc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Plugin/Fast/fast.rc
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Plugin/Fast/res/fast.ico
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Plugin/Fast/res/fast.ico
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 17 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Plugin/Fast/res/fast.rc2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Plugin/Fast/res/fast.rc2
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Plugin/Fast/resource.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Plugin/Fast/resource.h
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										108
									
								
								Plugin/Fast/stdafx.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										108
									
								
								Plugin/Fast/stdafx.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,108 @@ | ||||
|  | ||||
| // stdafx.cpp : ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Դ<EFBFBD>ļ<EFBFBD> | ||||
| // Vcs-Client.pch <20><><EFBFBD><EFBFBD>ΪԤ<CEAA><D4A4><EFBFBD><EFBFBD>ͷ | ||||
| // stdafx.obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ | ||||
|  | ||||
| #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; | ||||
| } | ||||
|  | ||||
| // <20><>cΪ<63><CEAA>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļн<C4BC> | ||||
| float getAngelOfTwoVector(Point2f &pt1, Point2f &pt2, Point2f &c) | ||||
| { | ||||
| 	float theta = atan2(pt1.y - c.y, pt1.x - c.x) - atan2(pt2.y - c.y, pt2.x - c.x); | ||||
| 	if (theta > CV_PI) | ||||
| 		theta -= 2 * CV_PI; | ||||
| 	if (theta < -CV_PI) | ||||
| 		theta += 2 * CV_PI; | ||||
|  | ||||
| 	theta = -1*theta * 180.0 / CV_PI; | ||||
| 	return theta; | ||||
| } | ||||
|  | ||||
|  | ||||
| //<2F>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ָ<EFBFBD> | ||||
| void splitString(const string& s, vector<string>& v, const string& c) | ||||
| { | ||||
| 	string::size_type pos1, pos2; | ||||
| 	pos2 = s.find(c); | ||||
| 	pos1 = 0; | ||||
| 	while (string::npos != pos2) | ||||
| 	{ | ||||
| 		v.push_back(s.substr(pos1, pos2 - pos1)); | ||||
| 		pos1 = pos2 + c.size(); | ||||
| 		pos2 = s.find(c, pos1); | ||||
| 	} | ||||
| 	if (pos1 != s.length()) | ||||
| 		v.push_back(s.substr(pos1)); | ||||
| } | ||||
|  | ||||
| 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';//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7B7>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊԭ<CEAA><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>з<EFBFBD> | ||||
| 			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); | ||||
| } | ||||
							
								
								
									
										92
									
								
								Plugin/Fast/stdafx.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								Plugin/Fast/stdafx.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,92 @@ | ||||
|  | ||||
| // stdafx.h : <20><>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>İ<EFBFBD><C4B0><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> | ||||
| // <20><><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD> | ||||
| // <20>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>İ<EFBFBD><C4B0><EFBFBD><EFBFBD>ļ<EFBFBD> | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #ifndef VC_EXTRALEAN | ||||
| #define VC_EXTRALEAN            // <20><> Windows ͷ<><CDB7><EFBFBD>ų<EFBFBD><C5B3><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD> | ||||
| #endif | ||||
|  | ||||
| #include "targetver.h" | ||||
|  | ||||
| #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // ijЩ CString <20><><EFBFBD>캯<EFBFBD><ECBAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD> | ||||
|  | ||||
| // <20>ر<EFBFBD> MFC <20><>ijЩ<C4B3><D0A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD><C9B7>ĺ<EFBFBD><C4BA>Եľ<D4B5><C4BE><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| #define _AFX_ALL_WARNINGS | ||||
|  | ||||
| #include <afxwin.h>         // MFC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD> | ||||
| #include <afxext.h>         // MFC <20><>չ | ||||
| #include <afxdisp.h>        // MFC <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
| #define  WM_CAMERA_SNAP   10999 | ||||
|  | ||||
|  | ||||
|  | ||||
| #ifndef _AFX_NO_OLE_SUPPORT | ||||
| #include <afxdtctl.h>           // MFC <20><> Internet Explorer 4 <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>֧<EFBFBD><D6A7> | ||||
| #endif | ||||
| #ifndef _AFX_NO_AFXCMN_SUPPORT | ||||
| #include <afxcmn.h>             // MFC <20><> Windows <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>֧<EFBFBD><D6A7> | ||||
| #endif // _AFX_NO_AFXCMN_SUPPORT | ||||
|  | ||||
| #include <afxcontrolbars.h>     // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳؼ<CDBF><D8BC><EFBFBD><EFBFBD><EFBFBD> MFC ֧<><D6A7> | ||||
|  | ||||
| #include <opencv2/opencv.hpp> | ||||
| #include <opencv2/highgui.hpp> | ||||
| #include "json.h" | ||||
| #include "../Protocol.h" | ||||
| #include <vector> | ||||
|  | ||||
| using namespace std; | ||||
| using namespace cv; | ||||
|  | ||||
| typedef struct  ST_THREAD_PARAM | ||||
| { | ||||
| 	void   * pParent; | ||||
| 	int      nIdx; | ||||
| } | ||||
| ST_THREAD_PARAM; | ||||
|  | ||||
|  | ||||
| #define COLOR_R Scalar(0, 0, 255) | ||||
| #define COLOR_B Scalar(255, 0, 0) | ||||
|  | ||||
|  | ||||
| #ifdef _UNICODE | ||||
| #if defined _M_IX86 | ||||
| #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") | ||||
| #elif defined _M_X64 | ||||
| #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") | ||||
| #else | ||||
| #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
|  | ||||
|  | ||||
| typedef  enum | ||||
| { | ||||
| 	HIK_RGBD           = 0, | ||||
| 	DAHUA_FISHEYE      = 1, | ||||
| 	DAHUA_FISHEYE_LIVE = 2 | ||||
|  | ||||
| }ENUM_CAMERA_TYPE; | ||||
|  | ||||
| typedef  enum | ||||
| { | ||||
| 	RT_STREAMING = 0, | ||||
| 	SNAP_PICTURE = 1, | ||||
|  | ||||
| }ENUM_PLAY_TYPE; | ||||
|  | ||||
|  | ||||
| float getAngelOfTwoVector(Point2f &pt1, Point2f &pt2, Point2f &c); | ||||
| void  splitString(const string& s, vector<string>& v, const string& c); | ||||
| void  LogOutToFile(const char* fmt, ...); | ||||
|  | ||||
|  | ||||
| #include "Mv3dRgbdApi.h" | ||||
| #include "Mv3dRgbdDefine.h" | ||||
| #include "Mv3dRgbdImgProc.h" | ||||
							
								
								
									
										8
									
								
								Plugin/Fast/targetver.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Plugin/Fast/targetver.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| #pragma once | ||||
|  | ||||
| // <20><><EFBFBD><EFBFBD> SDKDDKVer.h <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>߰汾<DFB0><E6B1BE> Windows ƽ̨<C6BD><CCA8> | ||||
|  | ||||
| // <20><><EFBFBD><EFBFBD>ҪΪ<D2AA><CEAA>ǰ<EFBFBD><C7B0> Windows ƽ̨<C6BD><CCA8><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> WinSDKVer.h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| // <20><> _WIN32_WINNT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪҪ֧<D2AA>ֵ<EFBFBD>ƽ̨<C6BD><CCA8>Ȼ<EFBFBD><C8BB><EFBFBD>ٰ<EFBFBD><D9B0><EFBFBD> SDKDDKVer.h<><68> | ||||
|  | ||||
| #include <SDKDDKVer.h> | ||||
							
								
								
									
										433
									
								
								Plugin/Plc/CEXMemFileQueue.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										433
									
								
								Plugin/Plc/CEXMemFileQueue.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,433 @@ | ||||
| #include "stdafx.h" | ||||
| #include "CEXMemFileQueue.h" | ||||
| #include <sys/timeb.h> | ||||
| #include <iostream> | ||||
| #include <iomanip> | ||||
| #include <sstream> | ||||
| #include <windows.h> | ||||
| #include <algorithm> | ||||
| #include <codecvt> | ||||
| #include <regex> | ||||
| #include <string> | ||||
|  | ||||
|  | ||||
| // <20><>ȡ<EFBFBD><C8A1>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>YYYYMMDDhhmmssSSS | ||||
| std::string formatTimeAsString(int lIndexEx)  | ||||
| { | ||||
| 	SYSTEMTIME st; | ||||
| 	GetLocalTime(&st); | ||||
| 	std::ostringstream oss; | ||||
| 	// <20><><EFBFBD><EFBFBD> | ||||
| 	oss << std::setw(4) << std::setfill('0') << (st.wYear % 10000); | ||||
| 	// <20>·ݺ<C2B7><DDBA><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	oss << std::setw(2) << std::setfill('0') << st.wMonth; | ||||
| 	oss << std::setw(2) << std::setfill('0') << st.wDay; | ||||
| 	// Сʱ<D0A1><CAB1><EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD><D3BA><EFBFBD> | ||||
| 	oss << std::setw(2) << std::setfill('0') << st.wHour; | ||||
| 	oss << std::setw(2) << std::setfill('0') << st.wMinute; | ||||
| 	oss << std::setw(2) << std::setfill('0') << st.wSecond; | ||||
| 	//__timeb64 tb; | ||||
| 	//_ftime64_s(&tb); // <20><>ȡ<EFBFBD><C8A1>ǰʱ<C7B0>䣬<EFBFBD><E4A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	//oss << std::setw(3) << std::setfill('0') << tb.millitm; // <20><><EFBFBD>룬<EFBFBD><EBA3AC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>ǰ<EFBFBD>油<EFBFBD><E6B2B9> | ||||
| 	oss << std::setw(6) << std::setfill('0') << lIndexEx; // <20><>ֹ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	return oss.str(); | ||||
| } | ||||
|  | ||||
| //<2F><>ȡһ<C8A1><D2BB>ָ<EFBFBD><D6B8>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> lType<70><65>ʾ<EFBFBD><CABE>ȡ<EFBFBD><C8A1><EFBFBD>ͣ<EFBFBD>1<EFBFBD><31><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>2<EFBFBD><32><EFBFBD>ļ<EFBFBD><C4BC>У<EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD> | ||||
| static void traverse_directory_ansi(const char* directory_path, std::vector<std::string>& files, int lType)  | ||||
| { | ||||
| 	char search_path[MAX_PATH]; | ||||
| 	strcpy_s(search_path, directory_path); | ||||
| 	strcat_s(search_path, "\\*"); | ||||
|  | ||||
| 	WIN32_FIND_DATAA find_data; | ||||
| 	HANDLE hFind = FindFirstFileA(search_path, &find_data); | ||||
|  | ||||
| 	if (hFind == INVALID_HANDLE_VALUE)  | ||||
| 	{ | ||||
| 		std::cerr << "Failed to open directory: " << directory_path << std::endl; | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	do  | ||||
| 	{ | ||||
| 		if (strcmp(find_data.cFileName, ".") == 0 || strcmp(find_data.cFileName, "..") == 0)  | ||||
| 		{ | ||||
| 			continue; | ||||
| 		} | ||||
|  | ||||
| 		char full_path[MAX_PATH]; | ||||
| 		strcpy_s(full_path, directory_path); | ||||
| 		strcat_s(full_path, "\\"); | ||||
| 		strcat_s(full_path, find_data.cFileName); | ||||
|  | ||||
| 		if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)  | ||||
| 		{ | ||||
| 			//<2F>ݲ<EFBFBD>֧<EFBFBD>ֵݹ<D6B5><DDB9><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> | ||||
| 			if (1 != lType) files.push_back(find_data.cFileName); | ||||
| 		} | ||||
| 		else  | ||||
| 		{ | ||||
| 			if (2 != lType) files.push_back(find_data.cFileName); | ||||
| 		} | ||||
| 	} while (FindNextFileA(hFind, &find_data) != 0); | ||||
|  | ||||
| 	FindClose(hFind); | ||||
|  | ||||
| 	// <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	std::sort(files.begin(), files.end()); | ||||
| } | ||||
|  | ||||
| CEXMemFileQueue::CEXMemFileQueue(std::string strDataDir) | ||||
| { | ||||
| 	m_strBaseDir = strDataDir; | ||||
| 	m_pWriteFileItem = NULL; | ||||
| 	m_pReadFileItem = NULL; | ||||
| 	m_lReadIndex = 0; | ||||
| 	m_lItemCount = 0; | ||||
| 	InitializeCriticalSection(&m_cs); | ||||
|  | ||||
| 	SYSTEMTIME stTime; | ||||
| 	GetLocalTime(&stTime); | ||||
| 	ChangeDataDate(stTime); | ||||
| } | ||||
|  | ||||
| CEXMemFileQueue::~CEXMemFileQueue() | ||||
| { | ||||
| 	for (int i = 0; i < (int)m_vecFile.size(); i++) | ||||
| 	{ | ||||
| 		delete m_vecFile[i]; | ||||
| 	} | ||||
| 	m_vecFile.clear(); | ||||
| } | ||||
|  | ||||
|  | ||||
| int CEXMemFileQueue::GetItemCount() | ||||
| { | ||||
| 	return m_lItemCount; | ||||
| } | ||||
|  | ||||
| int CEXMemFileQueue::GetAutoSn() | ||||
| { | ||||
| 	ThreadLock stLock(&m_cs); | ||||
| 	m_lAutoSn++; | ||||
| 	return m_lAutoSn; | ||||
| } | ||||
|  | ||||
| int CEXMemFileQueue::ReadItem(void* pData, int lIndex /* = -1 */) | ||||
| { | ||||
| 	ThreadLock stLock(&m_cs); | ||||
| 	if (lIndex > m_lItemCount) | ||||
| 	{ | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	if (lIndex >= 0) | ||||
| 	{ | ||||
| 		m_lReadIndex = lIndex; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		m_lReadIndex++; | ||||
| 	} | ||||
|  | ||||
| 	if (m_lReadIndex >= m_lItemCount) | ||||
| 	{ | ||||
| 		return -1;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	} | ||||
|  | ||||
| 	if (NULL == m_pReadFileItem || m_lReadIndex < m_pReadFileItem->lBeindIndex || m_lReadIndex > m_pReadFileItem->lEndIndex) | ||||
| 	{ | ||||
| 		m_pReadFileItem = NULL; | ||||
| 		//<2F><><EFBFBD><EFBFBD>Ѱ<EFBFBD><D1B0> | ||||
| 		for (int i = 0; i < (int)m_vecFile.size(); i++) | ||||
| 		{ | ||||
| 			if (m_lReadIndex >= m_vecFile[i]->lBeindIndex && m_lReadIndex <= m_vecFile[i]->lEndIndex) | ||||
| 			{ | ||||
| 				m_pReadFileItem = m_vecFile[i]; | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if (NULL == m_pReadFileItem) | ||||
| 	{ | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	memcpy(pData, (char*)m_pReadFileItem->pBuf + DATA_FIRST_LINE_SIZE + DATA_LINE_SIZE *(m_lReadIndex- m_pReadFileItem->lBeindIndex), DATA_LINE_SIZE); | ||||
|  | ||||
| 	return m_lReadIndex; | ||||
| } | ||||
|  | ||||
| void CEXMemFileQueue::FlushWriteFile() | ||||
| { | ||||
| 	ThreadLock stLock(&m_cs); | ||||
| 	if (NULL != m_pWriteFileItem) | ||||
| 	{ | ||||
| 		char acFirstLine[DATA_FIRST_LINE_SIZE+1] = { 0 }; | ||||
| 		sprintf_s(acFirstLine, "%-15d\n", m_pWriteFileItem->lFileSize); | ||||
| 		memcpy((char*)m_pWriteFileItem->pBuf, acFirstLine, DATA_FIRST_LINE_SIZE); | ||||
|  | ||||
| 		FlushViewOfFile(m_pWriteFileItem->pBuf, m_pWriteFileItem->lFileSize); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| int CEXMemFileQueue::WriteItem(void* pData) | ||||
| { | ||||
| 	ThreadLock stLock(&m_cs); | ||||
| 	//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	SYSTEMTIME stDate; | ||||
| 	GetLocalTime(&stDate); | ||||
| 	if (stDate.wYear != m_stDataDate.wYear || stDate.wMonth != m_stDataDate.wMonth || stDate.wDay != m_stDataDate.wDay) | ||||
| 	{ | ||||
| 		AutoCleanData(5); | ||||
| 		ChangeDataDate(stDate); | ||||
| 	} | ||||
| 	if (m_pWriteFileItem == NULL || m_pWriteFileItem->lFileSize + DATA_LINE_SIZE > DATA_FILE_SIZE) | ||||
| 	{ | ||||
| 		if (m_pWriteFileItem != NULL) | ||||
| 		{ | ||||
| 			m_pWriteFileItem->lEndIndex = m_lItemCount-1; | ||||
| 			FlushWriteFile(); | ||||
| 		} | ||||
| 		m_pWriteFileItem = new CEX_QUEUE_FILE_ITEM; | ||||
| 		m_pWriteFileItem->lBeindIndex = m_lItemCount; | ||||
|  | ||||
| 		m_pWriteFileItem->strFileName = m_strDataDir + "\\" + formatTimeAsString((int)m_vecFile.size()) + ".txt";; | ||||
|  | ||||
| 		// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>д<EFBFBD><EFBFBD><CDB9><EFBFBD> | ||||
| 		m_pWriteFileItem->hFile = CreateFileA( | ||||
| 			m_pWriteFileItem->strFileName.c_str(), | ||||
| 			GENERIC_READ | GENERIC_WRITE, | ||||
| 			FILE_SHARE_READ | FILE_SHARE_WRITE, | ||||
| 			nullptr, | ||||
| 			CREATE_ALWAYS, | ||||
| 			FILE_ATTRIBUTE_NORMAL, | ||||
| 			nullptr | ||||
| 		); | ||||
|  | ||||
| 		if (m_pWriteFileItem->hFile == INVALID_HANDLE_VALUE) | ||||
| 		{ | ||||
| 			TRACE("CreateFile failed\r\n"); | ||||
| 			delete m_pWriteFileItem; | ||||
| 			m_pWriteFileItem = NULL; | ||||
| 			return -1; | ||||
| 		} | ||||
|  | ||||
| 		// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>------<2D><>һ<EFBFBD>й̶<D0B9>ռ<EFBFBD><D5BC>16<31>ֽڼ<D6BD>¼<EFBFBD>ļ<EFBFBD>ʵ<EFBFBD>ʴ<EFBFBD>С | ||||
| 		m_pWriteFileItem->hMapFile = CreateFileMappingA(m_pWriteFileItem->hFile,nullptr,PAGE_READWRITE,	0,DATA_FILE_SIZE+16,nullptr); | ||||
| 		if (m_pWriteFileItem->hMapFile == nullptr)  | ||||
| 		{ | ||||
| 			TRACE("CreateFileMapping failed\r\n"); | ||||
| 			delete m_pWriteFileItem; | ||||
| 			m_pWriteFileItem = NULL; | ||||
| 			return -2; | ||||
| 		} | ||||
|  | ||||
| 		// <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>䵽<EFBFBD><E4B5BD><EFBFBD>̵ĵ<CCB5>ַ<EFBFBD>ռ<EFBFBD> | ||||
| 		m_pWriteFileItem->pBuf = MapViewOfFile(	m_pWriteFileItem->hMapFile,FILE_MAP_ALL_ACCESS,0,	0,DATA_FILE_SIZE+16); | ||||
| 		if (m_pWriteFileItem->pBuf == nullptr) | ||||
| 		{ | ||||
| 			TRACE("MapViewOfFile failed\r\n"); | ||||
| 			delete m_pWriteFileItem; | ||||
| 			m_pWriteFileItem = NULL; | ||||
| 			return -3; | ||||
| 		} | ||||
| 		FlushWriteFile();//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD>һ<EFBFBD>£<EFBFBD>д<EFBFBD><D0B4><EFBFBD>ļ<EFBFBD>ͷ | ||||
| 		m_vecFile.push_back(m_pWriteFileItem); | ||||
| 	} | ||||
|  | ||||
| 	//д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	memcpy((char*)m_pWriteFileItem->pBuf + m_pWriteFileItem->lFileSize, pData, DATA_LINE_SIZE); | ||||
| 	m_pWriteFileItem->lFileSize += DATA_LINE_SIZE; | ||||
| 	m_pWriteFileItem->lEndIndex = m_lItemCount; | ||||
| 	m_lItemCount++; | ||||
|  | ||||
| 	//ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD> | ||||
| 	char acFirstLine[DATA_FIRST_LINE_SIZE + 1] = { 0 }; | ||||
| 	sprintf_s(acFirstLine, "%-15d\n", m_pWriteFileItem->lFileSize); | ||||
| 	memcpy((char*)m_pWriteFileItem->pBuf, acFirstLine, DATA_FIRST_LINE_SIZE); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| //<2F>л<EFBFBD><D0BB><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD> | ||||
| void CEXMemFileQueue::ChangeDataDate(SYSTEMTIME stDate) | ||||
| { | ||||
| 	ThreadLock stLock(&m_cs); | ||||
| 	//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD> | ||||
| 	FlushWriteFile(); | ||||
| 	m_pReadFileItem = NULL; | ||||
| 	m_pWriteFileItem = NULL; | ||||
| 	for (int i = 0; i < (int)m_vecFile.size(); i++) | ||||
| 	{ | ||||
| 		delete m_vecFile[i]; | ||||
| 	} | ||||
| 	m_vecFile.clear(); | ||||
| 	m_lItemCount = 0; | ||||
|  | ||||
| 	//<2F><><EFBFBD><EFBFBD>·<EFBFBD><C2B7> | ||||
| 	m_stDataDate = stDate; | ||||
| 	char acDate[32] = { 0 }; | ||||
| 	sprintf_s(acDate, "%04d-%02d-%02d", m_stDataDate.wYear, m_stDataDate.wMonth, m_stDataDate.wDay); | ||||
| 	m_strDataDir = m_strBaseDir + "\\" + acDate; | ||||
| 	CreateDirectory(m_strDataDir.c_str(), NULL); | ||||
|  | ||||
| 	//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>У<EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	std::vector<std::string> files; | ||||
| 	traverse_directory_ansi(m_strDataDir.c_str(), files, 1); | ||||
| 	for (int i = 0; i < (int)files.size(); i++) | ||||
| 	{ | ||||
| 		CEX_QUEUE_FILE_ITEM* pTempItem = new CEX_QUEUE_FILE_ITEM; | ||||
| 		pTempItem->lBeindIndex = m_lItemCount; | ||||
|  | ||||
| 		pTempItem->strFileName = m_strDataDir + "\\" + files[i]; | ||||
|  | ||||
| 		// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>д<EFBFBD><EFBFBD><CDB9><EFBFBD> | ||||
| 		pTempItem->hFile = CreateFileA( | ||||
| 			pTempItem->strFileName.c_str(), | ||||
| 			GENERIC_READ | GENERIC_WRITE, | ||||
| 			FILE_SHARE_READ | FILE_SHARE_WRITE, | ||||
| 			nullptr, | ||||
| 			OPEN_EXISTING, | ||||
| 			FILE_ATTRIBUTE_NORMAL, | ||||
| 			nullptr | ||||
| 		); | ||||
|  | ||||
| 		if (pTempItem->hFile == INVALID_HANDLE_VALUE) | ||||
| 		{ | ||||
| 			TRACE("CreateFile failed\r\n"); | ||||
| 			delete pTempItem; | ||||
| 			pTempItem = NULL; | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
| 		// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>------<2D><>һ<EFBFBD>й̶<D0B9>ռ<EFBFBD><D5BC>16<31>ֽڼ<D6BD>¼<EFBFBD>ļ<EFBFBD>ʵ<EFBFBD>ʴ<EFBFBD>С | ||||
| 		pTempItem->hMapFile = CreateFileMappingA(pTempItem->hFile, nullptr, PAGE_READWRITE, 0, DATA_FILE_SIZE + 16, nullptr); | ||||
| 		if (pTempItem->hMapFile == nullptr) | ||||
| 		{ | ||||
| 			TRACE("CreateFileMapping failed\r\n"); | ||||
| 			delete pTempItem; | ||||
| 			pTempItem = NULL; | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
| 		// <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>䵽<EFBFBD><E4B5BD><EFBFBD>̵ĵ<CCB5>ַ<EFBFBD>ռ<EFBFBD> | ||||
| 		pTempItem->pBuf = MapViewOfFile(pTempItem->hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, DATA_FILE_SIZE + 16); | ||||
| 		if (pTempItem->pBuf == nullptr) | ||||
| 		{ | ||||
| 			TRACE("MapViewOfFile failed\r\n"); | ||||
| 			delete pTempItem; | ||||
| 			pTempItem = NULL; | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
| 		pTempItem->lFileSize = atoi((char*)pTempItem->pBuf); | ||||
| 		m_lItemCount += (pTempItem->lFileSize - DATA_FIRST_LINE_SIZE) / DATA_LINE_SIZE; | ||||
| 		pTempItem->lEndIndex = m_lItemCount - 1; | ||||
|  | ||||
|  | ||||
| 		m_vecFile.push_back(pTempItem); | ||||
| 	} | ||||
| 	m_lAutoSn = m_lItemCount; | ||||
| 	if (m_vecFile.size() > 0) | ||||
| 	{ | ||||
| 		m_pWriteFileItem = m_vecFile[m_vecFile.size() - 1]; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| static bool isValidDateFormat(const std::string& date)  | ||||
| { | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD>ʽ %04d-%02d-%02d | ||||
| 	std::regex datePattern(R"((\d{4})\-(\d{2})-(\d{2}))"); | ||||
| 	//std::regex datePattern(R"(\d{4}-\d{2}-\d{2})"); | ||||
| 	std::smatch match; | ||||
|  | ||||
| 	// <20><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> | ||||
| 	if (std::regex_match(date, match, datePattern))  | ||||
| 	{ | ||||
| 		// <20><>ȡ<EFBFBD>ꡢ<EFBFBD>¡<EFBFBD><C2A1><EFBFBD> | ||||
| 		int year = std::stoi(match[1].str()); | ||||
| 		int month = std::stoi(match[2].str()); | ||||
| 		int day = std::stoi(match[3].str()); | ||||
| 		// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>Ч<EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD>磺<EFBFBD>·<EFBFBD><C2B7><EFBFBD>1<EFBFBD><31>12֮<32>䣬<EFBFBD><E4A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31>31֮<31><D6AE><EFBFBD>ȣ<EFBFBD> | ||||
| 		if (month < 1 || month > 12 || day < 1 || day > 31)  | ||||
| 		{ | ||||
| 			return false; | ||||
| 		} | ||||
| 		return true; | ||||
| 	} | ||||
|  | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
| static bool DeleteDirectory(const std::string& dirPath)  | ||||
| { | ||||
| 	WIN32_FIND_DATA findFileData; | ||||
| 	std::string searchPath = dirPath + _T("\\*"); | ||||
| 	HANDLE hFind = FindFirstFile(searchPath.c_str(), &findFileData); | ||||
| 	if (hFind == INVALID_HANDLE_VALUE)  | ||||
| 	{ | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	do  | ||||
| 	{ | ||||
| 		std::string filePath; | ||||
| 		if (strcmp(findFileData.cFileName, _T(".")) == 0 || strcmp(findFileData.cFileName, _T("..")) == 0)  | ||||
| 		{ | ||||
| 			continue; | ||||
| 		} | ||||
|  | ||||
| 		filePath = dirPath + _T("\\") + findFileData.cFileName; | ||||
| 		if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)  | ||||
| 		{ | ||||
| 			if (!DeleteDirectory(filePath))  | ||||
| 			{ | ||||
| 				FindClose(hFind); | ||||
| 				return false; | ||||
| 			} | ||||
| 		} | ||||
| 		else  | ||||
| 		{ | ||||
| 			if (!DeleteFile(filePath.c_str()))  | ||||
| 			{ | ||||
| 				FindClose(hFind); | ||||
| 				return false; | ||||
| 			} | ||||
| 		} | ||||
| 	} while (FindNextFile(hFind, &findFileData) != 0); | ||||
|  | ||||
| 	FindClose(hFind); | ||||
| 	return RemoveDirectory(dirPath.c_str()) != 0; | ||||
| } | ||||
|  | ||||
| //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD> | ||||
| std::vector<std::string> CEXMemFileQueue::GetDataList() | ||||
| { | ||||
| 	std::vector<std::string> vecDir; | ||||
| 	traverse_directory_ansi(m_strBaseDir.c_str(), vecDir, 2); | ||||
|  | ||||
| 	std::vector<std::string> vecDate; | ||||
| 	//<2F><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD> | ||||
| 	for (int i = 0; i < (int)vecDir.size(); i++) | ||||
| 	{ | ||||
| 		if (isValidDateFormat(vecDir[i].c_str())) | ||||
| 		{ | ||||
| 			vecDate.push_back(vecDir[i].c_str()); | ||||
| 		} | ||||
| 	} | ||||
| 	return vecDate; | ||||
| } | ||||
|  | ||||
| //<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7><EFBFBD>ݣ<EFBFBD>lRecvDayΪ<79><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| void CEXMemFileQueue::AutoCleanData(int lRecvDay) | ||||
| { | ||||
| 	ThreadLock stLock(&m_cs); | ||||
| 	std::vector<std::string> vecDate = GetDataList(); | ||||
| 	for (int i = 0; i < ((int)vecDate.size()) - 5; i++) | ||||
| 	{ | ||||
| 		DeleteDirectory(m_strBaseDir + "\\" + vecDate[i]); | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										120
									
								
								Plugin/Plc/CEXMemFileQueue.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										120
									
								
								Plugin/Plc/CEXMemFileQueue.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,120 @@ | ||||
| #pragma once | ||||
| #include <vector> | ||||
| #include <string> | ||||
|  | ||||
| #define DATA_FIRST_LINE_SIZE (16) //<2F><>һ<EFBFBD>м<EFBFBD>¼<EFBFBD><C2BC>ǰ<EFBFBD>ļ<EFBFBD>ʵ<EFBFBD>ʳ<EFBFBD><CAB3><EFBFBD> | ||||
| ////////////////////////////////////////////////////////////////////////// | ||||
| // char acSeq[10]; | ||||
| // char acTime[12]; | ||||
| // unsigned char cIndex; // 0<><30>1 | ||||
| // unsigned char acTxRx; // 0:send, 1:recv | ||||
| // char acID[10]; | ||||
| // unsigned char acFrame;//0:data, 1:remote | ||||
| // unsigned char acType; //0:standard, 1:extend | ||||
| // unsigned char cDlc; | ||||
| // char acData[32]; | ||||
|  | ||||
|  | ||||
|  | ||||
| #define DATA_FILE_SIZE (89*10000) //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ֽ<EFBFBD><D6BD><EFBFBD> | ||||
|  | ||||
| class CEX_QUEUE_FILE_ITEM | ||||
| { | ||||
| public: | ||||
| 	CEX_QUEUE_FILE_ITEM() | ||||
| 	{ | ||||
| 		lFileSize = DATA_FIRST_LINE_SIZE; | ||||
| 		lBeindIndex = 0; | ||||
| 		lEndIndex = 0; | ||||
| 		hFile = INVALID_HANDLE_VALUE; | ||||
| 		hMapFile = NULL; | ||||
| 		pBuf = NULL; | ||||
| 	} | ||||
| 	~CEX_QUEUE_FILE_ITEM() | ||||
| 	{ | ||||
| 		if (NULL != pBuf) | ||||
| 		{ | ||||
| 			FlushViewOfFile(pBuf, lFileSize); | ||||
| 			UnmapViewOfFile(pBuf); | ||||
| 		} | ||||
| 		if (NULL != hMapFile) | ||||
| 		{ | ||||
| 			CloseHandle(hMapFile); | ||||
| 		} | ||||
| 		if (INVALID_HANDLE_VALUE != hFile) | ||||
| 		{ | ||||
| 			CloseHandle(hFile); | ||||
| 		} | ||||
| 	} | ||||
| 	std::string strFileName; | ||||
| 	HANDLE hFile;//<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	HANDLE hMapFile;//<2F>ļ<EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	void* pBuf;//<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	int lFileSize;//<2F><>ǰ<EFBFBD>ļ<EFBFBD><C4BC>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>е<EFBFBD>ժҪ<D5AA><D2AA>Ϣ<EFBFBD><CFA2><EFBFBD>ļ<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ȣ<EFBFBD> | ||||
| 	int lBeindIndex;//<2F><>ǰ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	int lEndIndex;//<2F><>ǰ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD> | ||||
| }; | ||||
|  | ||||
| class CEXMemFileQueue | ||||
| { | ||||
| 	class ThreadLock { | ||||
| 	public: | ||||
| 		// <20><><EFBFBD>캯<EFBFBD><ECBAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> | ||||
| 		ThreadLock(CRITICAL_SECTION* cs) | ||||
| 		{  | ||||
| 			m_cs = cs; | ||||
| 			EnterCriticalSection(m_cs);  | ||||
| 		} | ||||
| 		~ThreadLock()  | ||||
| 		{  | ||||
| 			LeaveCriticalSection(m_cs);  | ||||
| 		} | ||||
| 	private: | ||||
| 		CRITICAL_SECTION* m_cs; // <20>ٽ<EFBFBD><D9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	}; | ||||
|  | ||||
| public: | ||||
| 	CEXMemFileQueue(std::string strDataDir); | ||||
| 	~CEXMemFileQueue(); | ||||
|  | ||||
| 	//<2F><>ȡһ<C8A1><D2BB><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>ȹ̶<C8B9>ΪDATA_LINE_SIZE | ||||
| 	int ReadItem(void* pData, int lIndex = -1); | ||||
| 	//д<><D0B4>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>ȹ̶<C8B9>λDATA_LINE_SIZE | ||||
| 	int WriteItem(void* pData); | ||||
| 	//ǿ<><C7BF>ˢ<EFBFBD><CBA2><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>ļ<EFBFBD><C4BC><EFBFBD> | ||||
| 	void FlushWriteFile(); | ||||
| 	//<2F><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	int GetItemCount(); | ||||
|  | ||||
| 	int GetAutoSn(); | ||||
|  | ||||
| 	//<2F>л<EFBFBD><D0BB><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD> | ||||
| 	void ChangeDataDate(SYSTEMTIME stDate); | ||||
| 	//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD> | ||||
| 	std::vector<std::string> GetDataList(); | ||||
| 	//<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7><EFBFBD>ݣ<EFBFBD>lRecvDayΪ<79><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	void AutoCleanData(int lRecvDay); | ||||
|  | ||||
| private: | ||||
|  | ||||
| 	//<2F><><EFBFBD>ݷ<EFBFBD><DDB7>ļ<EFBFBD><C4BC>洢 | ||||
| 	std::vector<CEX_QUEUE_FILE_ITEM*> m_vecFile; | ||||
|  | ||||
| 	//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ڵ<EFBFBD> | ||||
| 	CEX_QUEUE_FILE_ITEM* m_pWriteFileItem; | ||||
| 	//<2F><>ǰ<EFBFBD><C7B0><EFBFBD>ڶ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ļ<EFBFBD><C4BC>ڵ<EFBFBD> | ||||
| 	CEX_QUEUE_FILE_ITEM* m_pReadFileItem; | ||||
|  | ||||
| 	int m_lReadIndex;//<2F><>ǰ<EFBFBD><C7B0>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ֵ | ||||
| 	int m_lItemCount;//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
| 	std::string m_strBaseDir;//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7> | ||||
| 	std::string m_strDataDir;//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7> | ||||
|  | ||||
| 	CRITICAL_SECTION m_cs; | ||||
|  | ||||
| 	int m_lAutoSn; | ||||
|  | ||||
| 	SYSTEMTIME m_stDataDate; | ||||
| }; | ||||
|  | ||||
							
								
								
									
										315
									
								
								Plugin/Plc/CEXVirtualListCtrl.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										315
									
								
								Plugin/Plc/CEXVirtualListCtrl.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,315 @@ | ||||
| // CEXVirtualListDlg.cpp: 实现文件 | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| #include "PluginPlc.h" | ||||
| #include "CEXVirtualListCtrl.h" | ||||
| #include "afxdialogex.h" | ||||
|  | ||||
| #include <iostream> | ||||
| #include <string> | ||||
| #include <sstream> | ||||
|  | ||||
| //控件ID只需要在当前窗口中唯一,这里随便写一个就好 | ||||
| #define ID_VIRTUAL_LIST_CTRL (1987) | ||||
|  | ||||
| IMPLEMENT_DYNAMIC(CEXVirtualListCtrl, CListCtrl) | ||||
|  | ||||
| CEXVirtualListCtrl::CEXVirtualListCtrl()  | ||||
| { | ||||
| 	m_pQueueData = NULL; | ||||
| 	m_lOldCount = 0; | ||||
| } | ||||
|  | ||||
| CEXVirtualListCtrl::~CEXVirtualListCtrl()  | ||||
| { | ||||
| } | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CEXVirtualListCtrl, CListCtrl) | ||||
| 	ON_NOTIFY_REFLECT(LVN_GETDISPINFO, &CEXVirtualListCtrl::OnLvnGetdispinfo) | ||||
| 	ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, &CEXVirtualListCtrl::OnNMCustomdraw) | ||||
| 	ON_WM_ERASEBKGND() | ||||
| 	ON_WM_TIMER() | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
| /* | ||||
| void CEXVirtualListCtrl::Initialize()  | ||||
| { | ||||
| 	SetExtendedStyle(GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_OWNERDATA); // 确保设置了虚拟大小样式 | ||||
| 	SetItemCountEx((int)0); | ||||
|  | ||||
| 	// 添加列(这里假设列是固定的,可以在构造函数中或这里添加) | ||||
| 	InsertColumn(0, _T("ID"), LVCFMT_LEFT, 80); | ||||
| 	InsertColumn(1, _T("Value1"), LVCFMT_LEFT, 120); | ||||
| 	InsertColumn(2, _T("Value2"), LVCFMT_LEFT, 100); | ||||
| } | ||||
| */ | ||||
|  | ||||
| void CEXVirtualListCtrl::SetData(CEXMemFileQueue* pQueue) | ||||
| { | ||||
| 	m_pQueueData = pQueue; | ||||
| 	SetItemCountEx((int)m_pQueueData->GetItemCount()); | ||||
| } | ||||
|  | ||||
| std::string getSubString(const char* input, int index) { | ||||
| 	std::vector<std::string> substrings; | ||||
| 	std::stringstream ss(input); | ||||
| 	std::string item; | ||||
|  | ||||
| 	// 使用逗号作为分隔符分割字符串 | ||||
| 	while (std::getline(ss, item, ',')) { | ||||
| 		substrings.push_back(item); | ||||
| 	} | ||||
|  | ||||
| 	// 检查索引是否有效 | ||||
| 	if (index < 0 || index >= substrings.size()) { | ||||
| 		return ""; | ||||
| 	} | ||||
|  | ||||
| 	// 返回对应的子串 | ||||
| 	return substrings[index]; | ||||
| } | ||||
|  | ||||
| void CEXVirtualListCtrl::OnLvnGetdispinfo(NMHDR* pNMHDR, LRESULT* pResult)  | ||||
| { | ||||
| 	NMLVDISPINFO* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR); | ||||
| 	LV_ITEM* pItem = &(pDispInfo)->item; | ||||
|  | ||||
| 	if (pItem->iItem >= 0 && pItem->iItem < static_cast<int>(m_pQueueData->GetItemCount()))  | ||||
| 	{ | ||||
| 		char acTemp[DATA_LINE_SIZE + 1] = { 0 }; | ||||
| 		int lIndex = m_pQueueData->ReadItem(acTemp, pItem->iItem); //pItem->iItem为行序号,即数据索引 | ||||
|  | ||||
| 		if (pItem->mask & LVIF_TEXT)  | ||||
| 		{ | ||||
| 			CString str; | ||||
| 			int lTempValue = 0; | ||||
| 			switch (pItem->iSubItem) //pItem->iSubItem为列编号,可以逐单元格设置内容; | ||||
| 			{ | ||||
| 			case 0://acSeq[10]; | ||||
| 				str= getSubString(acTemp, 0).c_str(); | ||||
| 				break; | ||||
| 			case 1://acTime[12]; | ||||
| 				str = getSubString(acTemp, 1).c_str(); | ||||
| 				break; | ||||
| 			case 2://cIndex; // 0或1 | ||||
| 				str = getSubString(acTemp, 2).c_str(); | ||||
| 				break; | ||||
| 			case 3://acTxRx; // 0:send, 1:recv | ||||
| 				lTempValue = atoi(getSubString(acTemp, 3).c_str()); | ||||
| 				str = lTempValue == 0 ? "send" : lTempValue == 1 ? "recv" : "-"; | ||||
| 				break; | ||||
| 			case 4://acID[10]; | ||||
| 				str = getSubString(acTemp, 4).c_str(); | ||||
| 				break; | ||||
| 			case 5://acFrame;//0:data, 1:remote | ||||
| 				lTempValue = atoi(getSubString(acTemp, 5).c_str()); | ||||
| 				str = lTempValue == 0 ? "data" : lTempValue == 1 ? "remote" : "-"; | ||||
| 				break; | ||||
| 			case 6:////0:standard, 1:extend | ||||
| 				lTempValue = atoi(getSubString(acTemp, 6).c_str()); | ||||
| 				str = lTempValue == 0 ? "standard" : lTempValue == 1 ? "extend" : "-"; | ||||
| 				break; | ||||
| 			case 7://cDlc; | ||||
| 				str = getSubString(acTemp, 7).c_str(); | ||||
| 				break; | ||||
| 			case 8://acData[32]; | ||||
| 				str = getSubString(acTemp, 8).c_str(); | ||||
| 				break; | ||||
| 			 | ||||
| 			} | ||||
| 			lstrcpy(pItem->pszText, str); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	*pResult = 0; | ||||
| } | ||||
| void CEXVirtualListCtrl::OnNMCustomdraw(NMHDR* pNMHDR, LRESULT* pResult) | ||||
| { | ||||
| 	LPNMLVCUSTOMDRAW pLVCD = reinterpret_cast<LPNMLVCUSTOMDRAW>(pNMHDR); | ||||
| 	*pResult = CDRF_DODEFAULT; | ||||
|  | ||||
| 	switch (pLVCD->nmcd.dwDrawStage) | ||||
| 	{ | ||||
| 	case CDDS_PREPAINT: | ||||
| 		*pResult = CDRF_NOTIFYITEMDRAW; | ||||
| 		break; | ||||
|  | ||||
| 	case CDDS_ITEMPREPAINT: | ||||
| 	{ | ||||
| 		// 获取当前项和子项的索引 | ||||
| 		int nItem = static_cast<int>(pLVCD->nmcd.dwItemSpec); | ||||
|  | ||||
| 		char acTemp[DATA_LINE_SIZE + 1] = { 0 }; | ||||
| 		m_pQueueData->ReadItem(acTemp, nItem); | ||||
| 		int lId = atoi(acTemp);//测试数据每条数据的最前面是10进制的ID,所以这里直接使用atoi了 | ||||
|  | ||||
| 		// 根据需要修改颜色 | ||||
| 		if (lId % 10 == 0) // 根据需要设定行颜色 | ||||
| 		{ | ||||
| 			pLVCD->clrText = RGB(255, 0, 0); // 红色文本 | ||||
| 			pLVCD->clrTextBk = RGB(200, 200, 255); // 浅蓝色背景 | ||||
|  | ||||
| 			//*pResult = CDRF_NEWFONT | CDRF_SKIPDEFAULT; | ||||
| 			*pResult = CDRF_NOTIFYITEMDRAW; | ||||
| 		} | ||||
| 	} | ||||
| 	break; | ||||
|  | ||||
| 	default: | ||||
| 		break; | ||||
| 	} | ||||
| } | ||||
| BOOL CEXVirtualListCtrl::OnEraseBkgnd(CDC* pDC) | ||||
| { | ||||
| 	// TODO: 在此添加消息处理程序代码和/或调用默认值 | ||||
| 	//return TRUE; //避免闪烁 | ||||
| 	return CListCtrl::OnEraseBkgnd(pDC); | ||||
| } | ||||
|  | ||||
| #define TIMER_REFRESH_LIST_ID (18989) | ||||
| void CEXVirtualListCtrl::StartAutoRefresh(int lMSecond) | ||||
| { | ||||
| 	SetTimer(TIMER_REFRESH_LIST_ID, lMSecond, NULL); | ||||
| } | ||||
| void CEXVirtualListCtrl::StopAutoRefresh() | ||||
| { | ||||
| 	KillTimer(TIMER_REFRESH_LIST_ID); | ||||
| } | ||||
| void CEXVirtualListCtrl::RefreshShow() | ||||
| { | ||||
| 	int lItemCount = m_pQueueData->GetItemCount(); | ||||
| 	if (m_lOldCount == lItemCount) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	SetItemCountEx(lItemCount, LVSICF_NOINVALIDATEALL | LVSICF_NOSCROLL); | ||||
| 	EnsureVisible(lItemCount - 1, FALSE); | ||||
|  | ||||
| 	m_lOldCount = lItemCount; | ||||
| } | ||||
|  | ||||
| void CEXVirtualListCtrl::OnTimer(UINT_PTR nIDEvent) | ||||
| { | ||||
| 	// TODO: 在此添加消息处理程序代码和/或调用默认值 | ||||
|  | ||||
| 	if (TIMER_REFRESH_LIST_ID == nIDEvent) | ||||
| 	{ | ||||
| 		if (NULL != m_pQueueData) | ||||
| 		{ | ||||
| 			RefreshShow(); | ||||
| 		} | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		//自定义定时器,无需调用基类OnTimer,否则定时器会被强制结束 | ||||
| 		CListCtrl::OnTimer(nIDEvent); | ||||
| 	} | ||||
| } | ||||
|  | ||||
|  | ||||
| #if 0 | ||||
| // CEXVirtualListDlg 对话框 | ||||
|  | ||||
| IMPLEMENT_DYNAMIC(CEXVirtualListDlg, CDialogEx) | ||||
|  | ||||
| CEXVirtualListDlg::CEXVirtualListDlg(CWnd* pParent /*=nullptr*/) | ||||
| 	: CDialogEx(IDD_CEXVirtualListDlg, pParent) | ||||
| { | ||||
| 	m_pstVirtualList = new CEXVirtualListCtrl(); | ||||
| } | ||||
|  | ||||
| CEXVirtualListDlg::~CEXVirtualListDlg() | ||||
| { | ||||
| } | ||||
|  | ||||
| void CEXVirtualListDlg::DoDataExchange(CDataExchange* pDX) | ||||
| { | ||||
| 	CDialogEx::DoDataExchange(pDX); | ||||
| 	//DDX_Control(pDX, ID_VIRTUAL_LIST_CTRL, *m_pstVirtualList); | ||||
| } | ||||
|  | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CEXVirtualListDlg, CDialogEx) | ||||
| 	ON_BN_CLICKED(IDOK, &CEXVirtualListDlg::OnBnClickedOk) | ||||
| 	ON_BN_CLICKED(IDCANCEL, &CEXVirtualListDlg::OnBnClickedCancel) | ||||
| 	ON_WM_SIZE() | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
|  | ||||
| // CEXVirtualListDlg 消息处理程序 | ||||
|  | ||||
|  | ||||
| void CEXVirtualListDlg::OnBnClickedOk() | ||||
| { | ||||
| 	// TODO: 在此添加控件通知处理程序代码 | ||||
| 	//CDialogEx::OnOK(); | ||||
| 	//屏蔽按下回车导致列表隐藏 | ||||
| } | ||||
|  | ||||
|  | ||||
| void CEXVirtualListDlg::OnBnClickedCancel() | ||||
| { | ||||
| 	// TODO: 在此添加控件通知处理程序代码 | ||||
| 	//CDialogEx::OnCancel(); | ||||
| 	//屏蔽按下ESC导致列表隐藏 | ||||
| } | ||||
|  | ||||
|  | ||||
| void CEXVirtualListDlg::OnSize(UINT nType, int cx, int cy) | ||||
| { | ||||
| 	CDialogEx::OnSize(nType, cx, cy); | ||||
|  | ||||
| 	// TODO: 在此处添加消息处理程序代码 | ||||
| 	if (NULL != m_pstVirtualList && NULL != m_pstVirtualList->m_hWnd) | ||||
| 	{ | ||||
| 		m_pstVirtualList->MoveWindow(0, 0, cx, cy); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| BOOL CEXVirtualListDlg::OnInitDialog() | ||||
| { | ||||
| 	CDialogEx::OnInitDialog(); | ||||
| 	if (!m_pstVirtualList->Create(WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_OWNERDATA | LVS_EX_DOUBLEBUFFER, CRect(0, 0, 0, 0), this, ID_VIRTUAL_LIST_CTRL)) { | ||||
| 		TRACE0("Failed to create MyVirtualListCtrl\n"); | ||||
| 		delete m_pstVirtualList; | ||||
| 		m_pstVirtualList = nullptr; | ||||
| 		return FALSE;      // 返回 FALSE  以使框架知道未成功初始化 | ||||
| 	} | ||||
|  | ||||
| 	// 设置控件的扩展样式和其他属性:整行选中、 | ||||
| 	m_pstVirtualList->SetExtendedStyle(LVS_EX_GRIDLINES | LVS_REPORT/*LVS_EX_VIRTUALSIZE*/); | ||||
|  | ||||
| 	m_pstVirtualList->Initialize(); | ||||
|  | ||||
| 	return TRUE; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CEXVirtualListDlg::SetData(CEXMemFileQueue* pQueue) | ||||
| { | ||||
| 	m_pstVirtualList->SetData(pQueue); | ||||
| } | ||||
|  | ||||
| #endif | ||||
|  | ||||
| BOOL CEXVirtualListCtrl::PreCreateWindow(CREATESTRUCT& cs) | ||||
| { | ||||
| 	// TODO: 在此添加专用代码和/或调用基类 | ||||
| 	 | ||||
|  | ||||
| 	return CListCtrl::PreCreateWindow(cs); | ||||
| } | ||||
|  | ||||
|  | ||||
| BOOL CEXVirtualListCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID) | ||||
| { | ||||
| 	// TODO: 在此添加专用代码和/或调用基类 | ||||
| 	 | ||||
| 	BOOL bRet = CListCtrl::Create(dwStyle, rect, pParentWnd, nID); | ||||
| 	SetExtendedStyle(LVS_EX_GRIDLINES | LVS_REPORT/*LVS_EX_VIRTUALSIZE*/); | ||||
| 	SetExtendedStyle(GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_OWNERDATA); // 确保设置了虚拟大小样式 | ||||
| 	SetItemCountEx((int)0); | ||||
| 	return bRet; | ||||
| } | ||||
							
								
								
									
										75
									
								
								Plugin/Plc/CEXVirtualListCtrl.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								Plugin/Plc/CEXVirtualListCtrl.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,75 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include <afxwin.h> | ||||
| #include <vector> | ||||
| #include <string> | ||||
| #include "CEXMemFileQueue.h" | ||||
|  | ||||
| struct MyListItem { | ||||
| 	int id; | ||||
| 	CString name; | ||||
| 	CString date; | ||||
| }; | ||||
|  | ||||
| class CEXVirtualListCtrl : public CListCtrl { | ||||
| 	DECLARE_DYNAMIC(CEXVirtualListCtrl) | ||||
|  | ||||
| public: | ||||
| 	CEXVirtualListCtrl(); | ||||
| 	virtual ~CEXVirtualListCtrl(); | ||||
|  | ||||
| 	//void Initialize(); | ||||
| 	void SetData(CEXMemFileQueue* pQueue); | ||||
|  | ||||
| 	void StartAutoRefresh(int lMSecond); | ||||
| 	void StopAutoRefresh(); | ||||
| 	void RefreshShow(); | ||||
|  | ||||
| protected: | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
| 	afx_msg void OnLvnGetdispinfo(NMHDR* pNMHDR, LRESULT* pResult); | ||||
| 	afx_msg void OnNMCustomdraw(NMHDR* pNMHDR, LRESULT* pResult); | ||||
|  | ||||
| private: | ||||
| 	CEXMemFileQueue* m_pQueueData; | ||||
| 	int m_lOldCount; | ||||
| public: | ||||
| 	afx_msg BOOL OnEraseBkgnd(CDC* pDC); | ||||
| 	virtual BOOL PreCreateWindow(CREATESTRUCT& cs); | ||||
| 	virtual BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID); | ||||
| 	afx_msg void OnTimer(UINT_PTR nIDEvent); | ||||
| }; | ||||
|  | ||||
|  | ||||
| // CEXVirtualListDlg 对话框 | ||||
|  | ||||
| class CEXVirtualListDlg : public CDialogEx | ||||
| { | ||||
| 	DECLARE_DYNAMIC(CEXVirtualListDlg) | ||||
|  | ||||
| public: | ||||
| 	CEXVirtualListDlg(CWnd* pParent = nullptr);   // 标准构造函数 | ||||
| 	virtual ~CEXVirtualListDlg(); | ||||
|  | ||||
| 	//给虚拟列表关联数据 | ||||
| 	void SetData(CEXMemFileQueue* pQueue); | ||||
|  | ||||
| // 对话框数据 | ||||
| #ifdef AFX_DESIGN_TIME | ||||
| 	enum { IDD = IDD_CEXVirtualListDlg }; | ||||
| #endif | ||||
|  | ||||
| 	virtual BOOL OnInitDialog(); | ||||
|  | ||||
| protected: | ||||
| 	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持 | ||||
|  | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
|  | ||||
| 	afx_msg void OnBnClickedOk(); | ||||
| 	afx_msg void OnBnClickedCancel(); | ||||
| 	afx_msg void OnSize(UINT nType, int cx, int cy); | ||||
|  | ||||
| private: | ||||
| 	CEXVirtualListCtrl* m_pstVirtualList; | ||||
| }; | ||||
							
								
								
									
										37
									
								
								Plugin/Plc/ClientSocket.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								Plugin/Plc/ClientSocket.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| // ClientSocket.cpp : implementation file | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| //#include "DustCleanHMI.h" | ||||
| #include "ClientSocket.h" | ||||
|  | ||||
| #include "CommDataDef.h" | ||||
| // CClientSocket | ||||
|  | ||||
| CClientSocket::CClientSocket() | ||||
| { | ||||
| 	m_hSocket = INVALID_SOCKET; | ||||
| } | ||||
|  | ||||
| CClientSocket::~CClientSocket() | ||||
| { | ||||
| } | ||||
|  | ||||
|  | ||||
| // CClientSocket member functions | ||||
|  | ||||
| void CClientSocket::OnReceive(int nErrorCode) | ||||
| { | ||||
| 	//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ɶ<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>̶߳<DFB3>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD> | ||||
| 	m_pThrd->PostThreadMessage(WM_THREAD_RECV,WP_WPARA_RECV,0); | ||||
|  | ||||
| 	CSocket::OnReceive(nErrorCode); | ||||
| } | ||||
|  | ||||
| void CClientSocket::OnClose(int nErrorCode) | ||||
| { | ||||
| 	//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ɶ<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>̹߳رձ<D8B1><D5B1><EFBFBD>Socket | ||||
| 	m_pThrd->PostThreadMessage(WM_THREAD_RECV, WP_WPARA_CLOSE, 0); | ||||
|  | ||||
| 	CSocket::OnClose(nErrorCode); | ||||
| } | ||||
							
								
								
									
										17
									
								
								Plugin/Plc/ClientSocket.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								Plugin/Plc/ClientSocket.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| #pragma once | ||||
|  | ||||
| // CClientSocket command target | ||||
| class CClientSocket : public CSocket | ||||
| { | ||||
| public: | ||||
| 	CClientSocket(); | ||||
| 	virtual ~CClientSocket(); | ||||
| 	virtual void OnReceive(int nErrorCode); | ||||
| 	virtual void OnClose(int nErrorCode); | ||||
|  | ||||
| public: | ||||
| 	//CDialog*			m_pMainDlg;		//<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8> | ||||
| 	CWinThread*			m_pThrd;		// <20><>CSocket<65><74><EFBFBD>ڵ<EFBFBD><DAB5>߳<EFBFBD> | ||||
| }; | ||||
|  | ||||
|  | ||||
							
								
								
									
										137
									
								
								Plugin/Plc/ColoredListCtrl.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								Plugin/Plc/ColoredListCtrl.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,137 @@ | ||||
| // ColoredListCtrl.cpp : implementation file | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| #include "ColoredListCtrl.h" | ||||
|  | ||||
| #ifdef _DEBUG | ||||
| #define new DEBUG_NEW | ||||
| #undef THIS_FILE | ||||
| static char THIS_FILE[] = __FILE__; | ||||
| #endif | ||||
|  | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
| // CColoredListCtrl | ||||
| CColoredListCtrl::CColoredListCtrl() | ||||
| { | ||||
| 	m_colRow1 = RGB(200,200,250); | ||||
| 	m_colRow2 = RGB(230,247,247); | ||||
|  | ||||
| //	m_colRow1 = RGB(240,247,249); | ||||
| //	m_colRow2 = RGB(229,232,239); | ||||
| } | ||||
|  | ||||
| CColoredListCtrl::~CColoredListCtrl() | ||||
| { | ||||
| } | ||||
|  | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CColoredListCtrl, CListCtrl) | ||||
| 	//{{AFX_MSG_MAP(CColoredListCtrl) | ||||
| 	ON_WM_ERASEBKGND() | ||||
| 	ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw) | ||||
| 	//}}AFX_MSG_MAP | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
| // CColoredListCtrl message handlers | ||||
|  | ||||
| void CColoredListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult) | ||||
| { | ||||
|   *pResult = 0; | ||||
|  | ||||
|   LPNMLVCUSTOMDRAW  lplvcd = (LPNMLVCUSTOMDRAW)pNMHDR; | ||||
|   int iRow = lplvcd->nmcd.dwItemSpec; | ||||
|  | ||||
|   switch(lplvcd->nmcd.dwDrawStage) | ||||
|   { | ||||
|     case CDDS_PREPAINT : | ||||
|     { | ||||
|       *pResult = CDRF_NOTIFYITEMDRAW; | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|     // Modify item text and or background | ||||
|     case CDDS_ITEMPREPAINT: | ||||
|     { | ||||
|       lplvcd->clrText = RGB(0,0,0); | ||||
|       // If you want the sub items the same as the item, | ||||
|       // set *pResult to CDRF_NEWFONT | ||||
|         if(ItemColorFlag[iRow]){ | ||||
|          lplvcd->clrTextBk = m_colRow2; | ||||
|         } | ||||
|         else{ | ||||
|           lplvcd->clrTextBk = m_colRow1; | ||||
|         } | ||||
|  | ||||
|       *pResult =CDRF_NOTIFYSUBITEMDRAW; | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|     // Modify sub item text and/or background | ||||
|     case CDDS_SUBITEM | CDDS_PREPAINT | CDDS_ITEM: | ||||
|     { | ||||
| 	/*	//if(*(ItemColorFlag+nextrow)){ | ||||
|         if(ItemColorFlag[iRow]){ | ||||
|          lplvcd->clrTextBk = m_colRow2; | ||||
|         } | ||||
|         else{ | ||||
|           lplvcd->clrTextBk = m_colRow1; | ||||
|         } | ||||
| */ | ||||
|         *pResult = CDRF_DODEFAULT; | ||||
|         return; | ||||
|     } | ||||
|   } | ||||
|   /* | ||||
|  void CCoolList::OnCustomDraw(NMHDR *pNMHDR, LRESULT *pResult){//<2F><><EFBFBD>Ͱ<EFBFBD>ȫת<C8AB><D7AA> | ||||
| NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR); | ||||
| *pResult = 0;//ָ<><D6B8><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ | ||||
| if(CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage) | ||||
| {*pResult = CDRF_NOTIFYITEMDRAW;} | ||||
| else if(CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage) | ||||
| {//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	if(pLVCD->nmcd.dwItemSpec % 2) | ||||
| 		pLVCD->clrTextBk = RGB(255, 255, 128);//ż<><C5BC><EFBFBD><EFBFBD> | ||||
| 	else  | ||||
| 		pLVCD->clrTextBk = RGB(128, 255, 255);//<2F><><EFBFBD><EFBFBD>*pResult = CDRF_DODEFAULT;}}   | ||||
| );//<2F><><EFBFBD><EFBFBD> | ||||
| *pResult = CDRF_DODEFAULT;}} | ||||
|  | ||||
| */ | ||||
| } | ||||
|  | ||||
| BOOL CColoredListCtrl::OnEraseBkgnd(CDC* pDC)  | ||||
| { | ||||
| 	// TODO: Add your message handler code here and/or call default | ||||
|  | ||||
| //return TRUE; | ||||
|  | ||||
|   CRect rect; | ||||
|   CColoredListCtrl::GetClientRect(rect); | ||||
|  | ||||
|  | ||||
| //  POINT mypoint;   | ||||
|    | ||||
|  // CBrush brush0(m_colRow1); | ||||
|   CBrush brush1(m_colRow2); | ||||
|  | ||||
|  | ||||
|   | ||||
|  int chunk_height=GetCountPerPage(); | ||||
|  pDC->FillRect(&rect,&brush1); | ||||
| /* | ||||
|  for (int i=0;i<=chunk_height;i++) | ||||
|  { | ||||
| 	GetItemPosition(i,&mypoint); | ||||
| 	rect.top=mypoint.y ; | ||||
| 	GetItemPosition(i+1,&mypoint); | ||||
| 	rect.bottom =mypoint.y; | ||||
| 	pDC->FillRect(&rect,i %2 ? &brush1 : &brush0); | ||||
|  }*/ | ||||
|  | ||||
| //  brush0.DeleteObject(); | ||||
|   brush1.DeleteObject(); | ||||
|  | ||||
|   return FALSE; | ||||
| } | ||||
							
								
								
									
										51
									
								
								Plugin/Plc/ColoredListCtrl.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								Plugin/Plc/ColoredListCtrl.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| #if !defined(AFX_COLOREDLISTCTRL_H__86FEBE8E_F6FA_429F_B740_76F1769C81C6__INCLUDED_) | ||||
| #define AFX_COLOREDLISTCTRL_H__86FEBE8E_F6FA_429F_B740_76F1769C81C6__INCLUDED_ | ||||
|  | ||||
| #if _MSC_VER > 1000 | ||||
| #pragma once | ||||
| #endif // _MSC_VER > 1000 | ||||
| // ColoredListCtrl.h : header file | ||||
| // | ||||
| extern unsigned long int nextrow; | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
| // CColoredListCtrl window | ||||
|  | ||||
| class CColoredListCtrl : public CListCtrl | ||||
| { | ||||
| // Construction | ||||
| public: | ||||
| 	CColoredListCtrl(); | ||||
|  | ||||
| // Attributes | ||||
| public: | ||||
| 	COLORREF m_colRow1; | ||||
| 	COLORREF m_colRow2; | ||||
|  | ||||
| // Operations | ||||
| public: | ||||
| 	unsigned char ItemColorFlag[60000]; | ||||
| 	 | ||||
| // Overrides | ||||
| 	// ClassWizard generated virtual function overrides | ||||
| 	//{{AFX_VIRTUAL(CColoredListCtrl) | ||||
| 	//}}AFX_VIRTUAL | ||||
|  | ||||
| // Implementation | ||||
| public: | ||||
| 	virtual ~CColoredListCtrl(); | ||||
|  | ||||
| 	// Generated message map functions | ||||
| protected: | ||||
| 	//{{AFX_MSG(CColoredListCtrl) | ||||
| 	afx_msg BOOL OnEraseBkgnd(CDC* pDC);	 | ||||
| 	//}}AFX_MSG | ||||
| 	afx_msg void CColoredListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult); | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
| }; | ||||
|  | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| //{{AFX_INSERT_LOCATION}} | ||||
| // Microsoft Visual C++ will insert additional declarations immediately before the previous line. | ||||
|  | ||||
| #endif // !defined(AFX_COLOREDLISTCTRL_H__86FEBE8E_F6FA_429F_B740_76F1769C81C6__INCLUDED_) | ||||
							
								
								
									
										302
									
								
								Plugin/Plc/CommDataDef.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										302
									
								
								Plugin/Plc/CommDataDef.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,302 @@ | ||||
|  | ||||
| #pragma once | ||||
| #pragma pack (1) | ||||
|  | ||||
| //<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>Ϣ | ||||
| #define  WM_THREAD_RECV			WM_USER + 1000 | ||||
| #define  WM_SERTHREAD_RECV		WM_USER + 2000 | ||||
|  | ||||
| #define  WP_WPARA_RECV				1001 | ||||
| #define  WP_WPARA_CLOSE				1002	//socket<65>ر<EFBFBD> | ||||
| #define  WP_WPARA_THREAD_QUIT		1005	//<2F>̹߳ر<CCB9> | ||||
|  | ||||
| #define  WP_WPARA_SERVER_RECV		2001 | ||||
| #define  WP_WPARA_SERVER_CLOSE		2002	//socket<65>ر<EFBFBD> | ||||
| #define  WP_WPARA_SERTHREAD_QUIT	2005	//<2F>̹߳ر<CCB9> | ||||
|  | ||||
| //<2F>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>ܸ<EFBFBD><DCB8><EFBFBD> | ||||
| #define  DUSTDEV_REGNUM				14     //<2F>ɼ<EFBFBD><C9BC>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܸ<EFBFBD><DCB8><EFBFBD> | ||||
|  | ||||
| //<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD> | ||||
| typedef struct __dustDevPara{ | ||||
| 	double  fDCVolt; | ||||
| 	double	fDCCurr; | ||||
| 	double	fPSVolt; | ||||
| 	double	fPSCurr; | ||||
| 	WORD	wPsFreq; | ||||
| 	double  fEnvTempr; | ||||
| 	double  fEnvHumity; | ||||
| 	double  fDcIgbtTemp; | ||||
| 	double  fPulseIgbtTemp; | ||||
| 	__dustDevPara(){ | ||||
| 		fDCVolt =0.0; | ||||
| 		fDCCurr =0.0; | ||||
| 		fPSVolt =0.0; | ||||
| 		fPSCurr =0.0; | ||||
| 		wPsFreq =0; | ||||
| 		fEnvTempr  =0.0; | ||||
| 		fEnvHumity =0.0; | ||||
| 		fDcIgbtTemp	=0.0; | ||||
| 		fPulseIgbtTemp =0.0; | ||||
| 	} | ||||
| }ST_DUSTDEV_WOORKPARA; | ||||
|  | ||||
| //Modbus<75><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6>ֵ | ||||
| typedef enum __enumFuncCode{ | ||||
| 	EN_MODBUS_READ_SINGLECOIL		=0x01,			//<2F><><EFBFBD><EFBFBD>Ȧ | ||||
| 	EN_MODBUS_READ_PERSISREG		=0x03,			//<2F><><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD> | ||||
| 	EN_MODBUS_WRITE_SINGLECOIL		=0x05,			//д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȧ | ||||
| 	EN_MODBUS_WRITE_SINGLEREG		=0x06,			//д<><D0B4><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD> | ||||
| 	EN_MODBUS_WRITE_MULTIREG		=0x10, | ||||
|  | ||||
| 	EN_MODBUS_READ_SINGLECOIL_RSPERR	=0x81, | ||||
| 	EN_MODBUS_READ_PERSISREG_RSPERR		=0x83, | ||||
| 	EN_MODBUS_WRITE_SINGLECOIL_RSPERR	=0x85, | ||||
| 	EN_MODBUS_WRITE_SINGLEREG_RSPERR	=0x86, | ||||
| 	EN_MODBUS_WRITE_MULTIREG_RSPERR		=0x90 | ||||
| }EN_NUM_MODBUS_FUNCCODE; | ||||
|  | ||||
| //<2F>Ĵ<EFBFBD><C4B4><EFBFBD>ö<EFBFBD><C3B6>ֵ(*10<31><30>ʾ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ֵΪʵ<CEAA><CAB5>ֵ<EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>) | ||||
| typedef enum  __enumRegAddr{ | ||||
| 	EN_REGADDR_DCVOLTH		=0x0000,		//ֱ<><D6B1><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9> | ||||
| 	EN_REGADDR_DCVOLTL		=0x0001,		//ֱ<><D6B1><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9> | ||||
| 	EN_REGADDR_DCCURR		=0x0002,		//ֱ<><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>		*10.0 | ||||
| 	EN_REGADDR_PULSEVOLTH	=0x0003,		//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9> | ||||
| 	EN_REGADDR_PULSEVOLTL	=0x0004,		//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9> | ||||
| 	EN_REGADDR_PULSECURR	=0x0005,		//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>		*10.0 | ||||
| 	EN_REGADDR_PULSEFREQ    =0x0006,		//<2F><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>		*10.0 | ||||
| 	EN_REGADDR_ENVTEMP		=0x0007,		//<2F><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>		*10.0 | ||||
| 	EN_REGADDR_ENVHUMITY	=0x0008,		//<2F><><EFBFBD><EFBFBD>ʪ<EFBFBD><CAAA>		*10.0 | ||||
| 	EN_REGADDR_SUPPLYVOLT	=0x0009,		//<2F>е<EFBFBD><D0B5><EFBFBD>ѹ		*10.0 | ||||
| 	EN_REGADDR_SUPPLYCURR	=0x000A,		//<2F>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>		*10.0 | ||||
| 	EN_REGADDR_ACTODCVOLT   =0x000B,		//ֱ<><D6B1><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>ѹ  *10.0 | ||||
| 	EN_REGADDR_DCIGBTTEMP	=0x000C,		//ֱ<><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IGBT<42><54><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>	  *10.0 | ||||
| 	EN_REGADDR_PULSEIGBTTEMP=0x000D			//<2F><><EFBFBD>岿<EFBFBD><E5B2BF>IGBT<42><54><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>    *10.0 | ||||
| }EN_NUM_REGADDR; | ||||
|  | ||||
| //MBAP<41><50><EFBFBD><EFBFBD>ͷ | ||||
| typedef  struct  __modbusMbapHeader{ | ||||
| 	WORD	wTransFlag; | ||||
| 	WORD	wProtocolFlag; | ||||
| 	WORD	wLen; | ||||
| 	BYTE	bUnitFlag; | ||||
| 	__modbusMbapHeader(){ | ||||
| 		wTransFlag		=0; | ||||
| 		wProtocolFlag	=0; | ||||
| 		wLen			=0; | ||||
| 		bUnitFlag		=0; | ||||
| 	} | ||||
| }ST_MODBUS_MBAP_HEADER; | ||||
|  | ||||
| //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȧ/<2F><><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>---Cient<6E><74> | ||||
| typedef  struct  __clientRqtReadFrame{ | ||||
| 	ST_MODBUS_MBAP_HEADER	stMbapHeader; | ||||
| 	BYTE					bFuncConde; | ||||
| 	WORD					wStartAddr; | ||||
| 	WORD					wRegNum; | ||||
| 	__clientRqtReadFrame() | ||||
| 	{ | ||||
| 		bFuncConde	=0x0; | ||||
| 		wStartAddr	=0; | ||||
| 		wRegNum		=0; | ||||
| 	} | ||||
| }ST_MODBUS_CLIENT_RQTREAD_FRAME; | ||||
|  | ||||
| //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȧ<EFBFBD><C8A6><EFBFBD><EFBFBD>---Cient<6E><74> | ||||
| typedef  struct  __clientRqtWrtCoilFrame{ | ||||
| 	ST_MODBUS_MBAP_HEADER	stMbapHeader; | ||||
| 	BYTE					bFuncConde; | ||||
| 	WORD					wAddr; | ||||
| 	WORD					wOutVal; | ||||
| 	__clientRqtWrtCoilFrame() | ||||
| 	{ | ||||
| 		bFuncConde	=0x05; | ||||
| 		wAddr		=0; | ||||
| 		wOutVal		=0; | ||||
| 	} | ||||
| }ST_MODBUS_CLIENT_RQTWRTCOIL_FRAME; | ||||
|  | ||||
| //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| typedef  struct  __serverRqtWrtRegFrame{ | ||||
| 	ST_MODBUS_MBAP_HEADER	stMbapHeader; | ||||
| 	BYTE					bFuncConde; | ||||
| 	WORD					wAddr; | ||||
| 	WORD					wOutVal; | ||||
| 	__serverRqtWrtRegFrame() | ||||
| 	{ | ||||
| 		bFuncConde	=0x06; | ||||
| 		wAddr		=0; | ||||
| 		wOutVal		=0; | ||||
| 	} | ||||
| }ST_MODBUS_SERVER_RQTWRTREG_FRAME; | ||||
|  | ||||
| //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>---Cient<6E><74> | ||||
| typedef  struct  __clientRqtWrtMultiRegFrame{ | ||||
| 	ST_MODBUS_MBAP_HEADER	stMbapHeader; | ||||
| 	BYTE					bFuncConde; | ||||
| 	WORD					wStartAddr; | ||||
| 	WORD					wRegNum; | ||||
| 	BYTE					bLen; | ||||
| 	BYTE					bRegVal[255]; | ||||
| 	__clientRqtWrtMultiRegFrame() | ||||
| 	{ | ||||
| 		bFuncConde	=0x10; | ||||
| 		wStartAddr	=0; | ||||
| 		wRegNum		=0; | ||||
| 		bLen		=0; | ||||
| 		memset(bRegVal,0,255); | ||||
| 	} | ||||
| }ST_MODBUS_CLIENT_RQTWRTMULTIREG_FRAME; | ||||
|  | ||||
| //<2F><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȧ/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ּĴ<D6BC><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--Server <20><> | ||||
| typedef  struct  __serveRspReadFrame{ | ||||
| 	ST_MODBUS_MBAP_HEADER	stMbapHeader; | ||||
| 	BYTE					bFuncConde; | ||||
| 	BYTE					bLen; | ||||
| 	BYTE					bRtnData[255]; | ||||
| }ST_MODBUS_SERVER_RSPREAD_FRAME; | ||||
|  | ||||
| //<2F><>Ӧд<D3A6><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȧ/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ּĴ<D6BC><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--Server <20><> | ||||
| typedef  struct  __serveRspWrtFrame{ | ||||
| 	ST_MODBUS_MBAP_HEADER	stMbapHeader; | ||||
| 	BYTE					bFuncConde; | ||||
| 	WORD					wStartAddr; | ||||
| 	WORD					wRegNum; | ||||
| }ST_MODBUS_SERVER_RSPWRT_FRAME; | ||||
|  | ||||
| //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ֡ | ||||
| typedef  struct  __serverRspErrFrame{ | ||||
| 	ST_MODBUS_MBAP_HEADER	stMbapHeader; | ||||
| 	BYTE					bFuncConde; | ||||
| 	BYTE					bErrCode; | ||||
| }ST_MODBUS_SERVER_RSPERR_FRAME; | ||||
|  | ||||
| ////=========================================================================================================== | ||||
| //------------<2D><><EFBFBD>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD>PCͨ<43><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6> | ||||
| typedef  enum   __enumpcCommFuncCode{ | ||||
| 	EN_PCCOMM_TRANSDATA			=0x51,		//HMI--->PC | ||||
| 	EN_PCCOMM_WORKPARASET		=0x52,		//PC---->HMI | ||||
| 	EN_PCCOMM_SAMPLEPARASET		=0x53,		//PC---->HMI | ||||
| 	EN_PCCOMM_DEVSTARTSTOP		=0x54,		//PC---->HMI | ||||
| 	EN_PCCOMM_HISTORYDATARQT	=0x55,		//PC---->HMI | ||||
|  | ||||
| 	EN_PCCOMM_TRANSDATA_RSP		=0x61,		//PC---->HMI | ||||
| 	EN_PCCOMM_WORKPARASET_RSP	=0x62,		//HMI--->PC | ||||
| 	EN_PCCOMM_SAMPLEPARASET_RSP =0x63,		//HMI--->PC | ||||
| 	EN_PCCOMM_DEVSTARTSTOP_RSP	=0x64		//HMI--->PC | ||||
|  | ||||
| }EN_NUM_PCCOMM_FUNCCODE; | ||||
|  | ||||
|  | ||||
| //<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9> | ||||
| typedef  struct	  __devSampleData{ | ||||
| 	int		iDevID; | ||||
| 	DWORD	dwIPAddr; | ||||
| 	WORD	wPulseFreq; | ||||
| 	float	fDcVolt; | ||||
| 	float	fDcCurr; | ||||
| 	float	fPulseVolt; | ||||
| 	float	fPulseCurr; | ||||
| 	float	fEnvTemprature; | ||||
| 	float	fEnvHumidity; | ||||
| 	float   fSupplyVolt; | ||||
| 	float	fSupplyCurr; | ||||
| 	float	fRectiferDC; | ||||
| 	float	fDcIgbtTemp; | ||||
| 	float	fPsIgbtTemp; | ||||
| 	BYTE	bSampleTime[6]; | ||||
| 	__devSampleData(){ | ||||
| 		iDevID		=0; | ||||
| 		dwIPAddr	=0; | ||||
| 		wPulseFreq	=0; | ||||
| 		fDcVolt		=0; | ||||
| 		fDcCurr		=0; | ||||
| 		fPulseVolt	=0; | ||||
| 		fPulseCurr	=0; | ||||
| 		fEnvHumidity=0; | ||||
| 		fEnvTemprature =0; | ||||
| 		fSupplyVolt	=0; | ||||
| 		fSupplyCurr =0; | ||||
| 		fRectiferDC =0; | ||||
| 		fDcIgbtTemp =0; | ||||
| 		fPsIgbtTemp =0; | ||||
| 		memset(bSampleTime,0,6); | ||||
| 	} | ||||
| }ST_DEVSAMPLE_DATA; | ||||
|  | ||||
| //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| typedef  struct  __devWorkParaFromPC{ | ||||
| 	int		iDevID; | ||||
| 	DWORD	dwIPAddr; | ||||
| 	WORD	wPulseFreq; | ||||
| 	float	fDcVolt; | ||||
| 	float	fDcCurr; | ||||
| 	float	fPulseVolt; | ||||
| 	float	fPulseCurr; | ||||
| 	char    szDevName[32]; | ||||
| 	char    szDevIPAddr[32]; | ||||
| 	__devWorkParaFromPC(){ | ||||
| 		iDevID		=0; | ||||
| 		dwIPAddr	=0; | ||||
| 		wPulseFreq	=0; | ||||
| 		fDcVolt		=0; | ||||
| 		fDcCurr		=0; | ||||
| 		fPulseVolt	=0; | ||||
| 		fPulseCurr	=0; | ||||
| 		szDevName[0] ='\0'; | ||||
| 		szDevIPAddr[0] ='\0'; | ||||
| 	} | ||||
| 	__devWorkParaFromPC& operator=(const __devWorkParaFromPC &rhs) | ||||
| 	{ | ||||
| 		this->iDevID	= rhs.iDevID; | ||||
| 		this->dwIPAddr	= rhs.dwIPAddr; | ||||
| 		this->wPulseFreq= rhs.wPulseFreq; | ||||
| 		this->fDcVolt	= rhs.fDcVolt; | ||||
| 		this->fDcCurr	= rhs.fDcCurr; | ||||
| 		this->fPulseVolt= rhs.fPulseVolt; | ||||
| 		this->fPulseCurr= rhs.fPulseCurr; | ||||
| 		strcpy(this->szDevName,rhs.szDevName); | ||||
| 		strcpy(this->szDevIPAddr,rhs.szDevIPAddr); | ||||
|  | ||||
| 		return (*this); | ||||
| 	} | ||||
| }ST_DEVWORKPARA_FROMPC,*PST_DEVWORKPARA_FROMPC; | ||||
|  | ||||
| //<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD> | ||||
| typedef  struct __devSampleParaFromPC{ | ||||
| 	WORD	wSampleIntver; | ||||
| 	BYTE	bIsSavePcOnline; | ||||
| 	__devSampleParaFromPC(){ | ||||
| 		wSampleIntver =0; | ||||
| 		bIsSavePcOnline =0; | ||||
| 	} | ||||
| }ST_SAMPLEPARA_FROMPC; | ||||
|  | ||||
| //<2F>豸<EFBFBD><E8B1B8>ͣ | ||||
| typedef struct  __devStartStopFromPC{ | ||||
| 	int		iDevID; | ||||
| 	DWORD	dwIPAddr; | ||||
| 	BYTE	bIsStart; | ||||
| 	__devStartStopFromPC(){ | ||||
| 		iDevID		=0; | ||||
| 		dwIPAddr	=0; | ||||
| 		bIsStart	=0; | ||||
| 	} | ||||
| }ST_DEVSTARTSTOP_FROMPC; | ||||
|  | ||||
| //<2F><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| typedef struct   __historyRqtFromPC{ | ||||
| 	int		iDevID; | ||||
| 	DWORD	dwIPAddr; | ||||
| 	BYTE	bStartTime[6]; | ||||
| 	BYTE	bStopTime[6]; | ||||
| 	__historyRqtFromPC(){ | ||||
| 		iDevID		=0; | ||||
| 		dwIPAddr	=0; | ||||
| 		memset(bStartTime,0,6); | ||||
| 		memset(bStopTime,0,6); | ||||
| 	} | ||||
| }ST_HISTORYRQT_FROMPC; | ||||
|  | ||||
| #pragma pack () | ||||
							
								
								
									
										37
									
								
								Plugin/Plc/ConfigDlg.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								Plugin/Plc/ConfigDlg.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| #pragma once | ||||
| #include "afxcmn.h" | ||||
|  | ||||
|  | ||||
| class CConfigDlg : public CDialogEx | ||||
| { | ||||
| 	DECLARE_DYNAMIC(CConfigDlg) | ||||
|  | ||||
| public: | ||||
| 	CConfigDlg(CWnd* pParent = NULL);   // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF> | ||||
| 	virtual ~CConfigDlg(); | ||||
|  | ||||
| // <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| #ifdef AFX_DESIGN_TIME | ||||
| 	enum { IDD = IDD_CONFIG_DLG}; | ||||
| #endif | ||||
|  | ||||
| protected: | ||||
| 	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV ֧<><D6A7> | ||||
|  | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
| public: | ||||
| 	virtual BOOL OnInitDialog(); | ||||
| 	void    ReadConfigFromIni(); | ||||
| 	 | ||||
|  | ||||
| 	CIPAddressCtrl m_ipAddrCtrl; | ||||
| 	 | ||||
| 	afx_msg void OnBnClickedBtnSet(); | ||||
| 	 | ||||
|  | ||||
| }; | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										101
									
								
								Plugin/Plc/ConifgDlg.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										101
									
								
								Plugin/Plc/ConifgDlg.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,101 @@ | ||||
| // PlcDeviceDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD> | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| #include "ConfigDlg.h" | ||||
| #include "afxdialogex.h" | ||||
| #include "PluginPlc.h" | ||||
| #include "resource.h" | ||||
|  | ||||
| #define  TIMER_UPDATE_TOPLC  1 | ||||
| #define  TIMER_UPDATE_TODLG  2 | ||||
| #define  TIMER_UPDATE_FROMPLC  3 | ||||
|  | ||||
|  | ||||
| // CPlcDeviceDlg <20>Ի<EFBFBD><D4BB><EFBFBD> | ||||
|  | ||||
| IMPLEMENT_DYNAMIC(CConfigDlg, CDialogEx) | ||||
|  | ||||
| CConfigDlg::CConfigDlg(CWnd* pParent /*=NULL*/) | ||||
| 	: CDialogEx(IDD_CONFIG_DLG, pParent) | ||||
| { | ||||
| 	 | ||||
| 	 | ||||
| } | ||||
|  | ||||
| CConfigDlg::~CConfigDlg() | ||||
| { | ||||
| } | ||||
|  | ||||
|  | ||||
| void CConfigDlg::DoDataExchange(CDataExchange* pDX) | ||||
| { | ||||
| 	CDialogEx::DoDataExchange(pDX); | ||||
| 	DDX_Control(pDX, IDC_IPADDRESS, m_ipAddrCtrl); | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CConfigDlg, CDialogEx) | ||||
| 	ON_BN_CLICKED(IDC_BTN_SET, &CConfigDlg::OnBnClickedBtnSet) | ||||
| 	 | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
|  | ||||
| // CPlcDeviceDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
| BOOL CConfigDlg::OnInitDialog() | ||||
| { | ||||
| 	CDialogEx::OnInitDialog(); | ||||
|  | ||||
| 	//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD> | ||||
| 	ReadConfigFromIni(); | ||||
| 	 | ||||
|  | ||||
| 	return TRUE;  // return TRUE unless you set the focus to a control | ||||
| 				  // <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE | ||||
| } | ||||
|  | ||||
| void CConfigDlg::ReadConfigFromIni() | ||||
| { | ||||
| 	CString strIniPath = theApp.m_strModulePath + "\\config.ini"; | ||||
| 	// <20><>ʼ<EFBFBD><CABC><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD> | ||||
|  | ||||
| 	char acValue[32] = ""; | ||||
| 	GetPrivateProfileString("CORE", "IP", "", acValue, 32, strIniPath); | ||||
| 	//m_strIpAddr = acValue; | ||||
| 	DWORD  dwIP = inet_addr(acValue); | ||||
| 	unsigned  char   *pIP = (unsigned   char*)&dwIP; | ||||
| 	m_ipAddrCtrl.SetAddress(*pIP, *(pIP + 1), *(pIP + 2), *(pIP + 3)); | ||||
|  | ||||
|  | ||||
|  | ||||
| 	int nPort     = GetPrivateProfileInt("CORE", "PORT", 0, strIniPath); | ||||
| 	CString strPort; | ||||
| 	strPort.Format("%d", nPort); | ||||
| 	GetDlgItem(IDC_EDIT_PORT)->SetWindowText(strPort); | ||||
| 	 | ||||
|  | ||||
| 	return;  // return TRUE unless you set the focus to a control | ||||
| 			 // <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE | ||||
| } | ||||
|  | ||||
|  | ||||
| void CConfigDlg::OnBnClickedBtnSet() | ||||
| { | ||||
| 	CString strIniPath = theApp.m_strModulePath + "\\config.ini"; | ||||
| 	BYTE nFild[4]; | ||||
| 	m_ipAddrCtrl.GetAddress(nFild[0], nFild[1], nFild[2], nFild[3]); | ||||
| 	CString strIpAddr; | ||||
| 	strIpAddr.Format("%d.%d.%d.%d", nFild[0], nFild[1], nFild[2], nFild[3]); | ||||
| 	WritePrivateProfileString("CORE", "IP", strIpAddr, strIniPath); | ||||
|  | ||||
| 	CString strPort; | ||||
| 	GetDlgItem(IDC_EDIT_PORT)->GetWindowText(strPort); | ||||
| 	WritePrivateProfileString("CORE", "PORT", strPort, strIniPath); | ||||
|  | ||||
| 	MessageBox("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѹ<EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD>."); | ||||
|  | ||||
|  | ||||
| } | ||||
|  | ||||
							
								
								
									
										273
									
								
								Plugin/Plc/Kernel.vcxproj.bak
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										273
									
								
								Plugin/Plc/Kernel.vcxproj.bak
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,273 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||
|   <ItemGroup Label="ProjectConfigurations"> | ||||
|     <ProjectConfiguration Include="Debug|Win32"> | ||||
|       <Configuration>Debug</Configuration> | ||||
|       <Platform>Win32</Platform> | ||||
|     </ProjectConfiguration> | ||||
|     <ProjectConfiguration Include="Release|Win32"> | ||||
|       <Configuration>Release</Configuration> | ||||
|       <Platform>Win32</Platform> | ||||
|     </ProjectConfiguration> | ||||
|     <ProjectConfiguration Include="Debug|x64"> | ||||
|       <Configuration>Debug</Configuration> | ||||
|       <Platform>x64</Platform> | ||||
|     </ProjectConfiguration> | ||||
|     <ProjectConfiguration Include="Release|x64"> | ||||
|       <Configuration>Release</Configuration> | ||||
|       <Platform>x64</Platform> | ||||
|     </ProjectConfiguration> | ||||
|   </ItemGroup> | ||||
|   <PropertyGroup Label="Globals"> | ||||
|     <ProjectGuid>{8BBB60C1-510D-47BC-8FD2-E14E9EA3A156}</ProjectGuid> | ||||
|     <RootNamespace>VcsClient</RootNamespace> | ||||
|     <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion> | ||||
|     <Keyword>MFCProj</Keyword> | ||||
|   </PropertyGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>true</UseDebugLibraries> | ||||
|     <PlatformToolset>v140</PlatformToolset> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|     <UseOfMfc>Dynamic</UseOfMfc> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>false</UseDebugLibraries> | ||||
|     <PlatformToolset>v140</PlatformToolset> | ||||
|     <WholeProgramOptimization>true</WholeProgramOptimization> | ||||
|     <CharacterSet>Unicode</CharacterSet> | ||||
|     <UseOfMfc>Dynamic</UseOfMfc> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>true</UseDebugLibraries> | ||||
|     <PlatformToolset>v140</PlatformToolset> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|     <UseOfMfc>Dynamic</UseOfMfc> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>false</UseDebugLibraries> | ||||
|     <PlatformToolset>v140</PlatformToolset> | ||||
|     <WholeProgramOptimization>true</WholeProgramOptimization> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|     <UseOfMfc>Dynamic</UseOfMfc> | ||||
|   </PropertyGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||||
|   <ImportGroup Label="ExtensionSettings"> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="Shared"> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <PropertyGroup Label="UserMacros" /> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <LinkIncremental>true</LinkIncremental> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||||
|     <LinkIncremental>true</LinkIncremental> | ||||
|     <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\Agv</OutDir> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||||
|     <LinkIncremental>false</LinkIncremental> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||||
|     <LinkIncremental>false</LinkIncremental> | ||||
|     <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\Agv</OutDir> | ||||
|   </PropertyGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <ClCompile> | ||||
|       <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <Optimization>Disabled</Optimization> | ||||
|       <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <SDLCheck>false</SDLCheck> | ||||
|       <AdditionalIncludeDirectories>E:\work\tank_svn\shiyu\project\fan\warehouse\code\cpp\vcs-client\Inc\json\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Windows</SubSystem> | ||||
|     </Link> | ||||
|     <Midl> | ||||
|       <MkTypLibCompatible>false</MkTypLibCompatible> | ||||
|       <ValidateAllParameters>true</ValidateAllParameters> | ||||
|       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|     </Midl> | ||||
|     <ResourceCompile> | ||||
|       <Culture>0x0804</Culture> | ||||
|       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ResourceCompile> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||||
|     <ClCompile> | ||||
|       <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <Optimization>Disabled</Optimization> | ||||
|       <PreprocessorDefinitions>_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <SDLCheck>false</SDLCheck> | ||||
|       <AdditionalIncludeDirectories>$(SolutionDir)3rdparty\json\inc;$(SolutionDir)CCEXPipe;$(SolutionDir)3rdparty\curl\inc;..\modbus;$(SolutionDir)3rdparty\can\inc;$(SolutionDir)3rdparty\sqlite;$(SolutionDir)3rdparty\whttp-server-core;$(SolutionDir)3rdparty\openssl\inc;$(SolutionDir)3rdparty\pthread\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Windows</SubSystem> | ||||
|       <AdditionalDependencies>libcurl.lib;modbus.lib;ControlCAN.lib;libcrypto.lib;libssl.lib;pthreadVC2.lib</AdditionalDependencies> | ||||
|       <AdditionalLibraryDirectories>$(SolutionDir)3rdparty\curl\lib\x64;$(SolutionDir)$(Platform)\$(Configuration)\;$(SolutionDir)3rdparty\modbus\lib;$(SolutionDir)3rdparty\can\lib;$(SolutionDir)3rdparty\pthread\lib\x64;$(SolutionDir)3rdparty\openssl\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||||
|     </Link> | ||||
|     <Midl> | ||||
|       <MkTypLibCompatible>false</MkTypLibCompatible> | ||||
|       <ValidateAllParameters>true</ValidateAllParameters> | ||||
|       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|     </Midl> | ||||
|     <ResourceCompile> | ||||
|       <Culture>0x0804</Culture> | ||||
|       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ResourceCompile> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||||
|     <ClCompile> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <PrecompiledHeader>Use</PrecompiledHeader> | ||||
|       <Optimization>MaxSpeed</Optimization> | ||||
|       <FunctionLevelLinking>true</FunctionLevelLinking> | ||||
|       <IntrinsicFunctions>true</IntrinsicFunctions> | ||||
|       <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <SDLCheck>true</SDLCheck> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Windows</SubSystem> | ||||
|       <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||||
|       <OptimizeReferences>true</OptimizeReferences> | ||||
|     </Link> | ||||
|     <Midl> | ||||
|       <MkTypLibCompatible>false</MkTypLibCompatible> | ||||
|       <ValidateAllParameters>true</ValidateAllParameters> | ||||
|       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|     </Midl> | ||||
|     <ResourceCompile> | ||||
|       <Culture>0x0804</Culture> | ||||
|       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ResourceCompile> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||||
|     <ClCompile> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||||
|       <Optimization>MaxSpeed</Optimization> | ||||
|       <FunctionLevelLinking>true</FunctionLevelLinking> | ||||
|       <IntrinsicFunctions>true</IntrinsicFunctions> | ||||
|       <PreprocessorDefinitions>_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <SDLCheck>false</SDLCheck> | ||||
|       <AdditionalIncludeDirectories>$(SolutionDir)3rdparty\json\inc;$(SolutionDir)CCEXPipe;$(SolutionDir)3rdparty\curl\inc;..\modbus;$(SolutionDir)3rdparty\can\inc;$(SolutionDir)3rdparty\sqlite;$(SolutionDir)3rdparty\whttp-server-core;$(SolutionDir)3rdparty\pthread\inc;$(SolutionDir)3rdparty\openssl\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Windows</SubSystem> | ||||
|       <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||||
|       <OptimizeReferences>true</OptimizeReferences> | ||||
|       <AdditionalLibraryDirectories>$(SolutionDir)3rdparty\curl\lib\x64;$(SolutionDir)$(Platform)\$(Configuration)\;$(SolutionDir)3rdparty\modbus\lib;$(SolutionDir)3rdparty\can\lib;$(SolutionDir)3rdparty\pthread\lib\x64;$(SolutionDir)3rdparty\openssl\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||||
|       <AdditionalDependencies>libcurl.lib;modbus.lib;ControlCAN.lib;libcrypto.lib;libssl.lib;pthreadVC2.lib</AdditionalDependencies> | ||||
|       <UACExecutionLevel>AsInvoker</UACExecutionLevel> | ||||
|     </Link> | ||||
|     <Midl> | ||||
|       <MkTypLibCompatible>false</MkTypLibCompatible> | ||||
|       <ValidateAllParameters>true</ValidateAllParameters> | ||||
|       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|     </Midl> | ||||
|     <ResourceCompile> | ||||
|       <Culture>0x0804</Culture> | ||||
|       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ResourceCompile> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemGroup> | ||||
|     <Text Include="ReadMe.txt" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="..\..\..\3rdparty\sqlite\sqlite3.h" /> | ||||
|     <ClInclude Include="..\..\..\3rdparty\sqlite\sqlite3ext.h" /> | ||||
|     <ClInclude Include="..\..\..\3rdparty\whttp-server-core\IHttpServer.h" /> | ||||
|     <ClInclude Include="..\..\..\3rdparty\whttp-server-core\LockQueue.hpp" /> | ||||
|     <ClInclude Include="..\..\..\3rdparty\whttp-server-core\mongoose.h" /> | ||||
|     <ClInclude Include="..\..\..\3rdparty\whttp-server-core\unistd.h" /> | ||||
|     <ClInclude Include="..\..\..\3rdparty\whttp-server-core\WHttpServer.h" /> | ||||
|     <ClInclude Include="..\..\..\3rdparty\whttp-server-core\WThreadPool.h" /> | ||||
|     <ClInclude Include="AppMsgHandler.h" /> | ||||
|     <ClInclude Include="CanDeviceDlg.h" /> | ||||
|     <ClInclude Include="CEXMemFileQueue.h" /> | ||||
|     <ClInclude Include="CEXVirtualListCtrl.h" /> | ||||
|     <ClInclude Include="ClientSocket.h" /> | ||||
|     <ClInclude Include="ClientSocketThread.h" /> | ||||
|     <ClInclude Include="ColoredListCtrl.h" /> | ||||
|     <ClInclude Include="CommDataDef.h" /> | ||||
|     <ClInclude Include="ConfigDlg.h" /> | ||||
|     <ClInclude Include="DatabaseMgr.h" /> | ||||
|     <ClInclude Include="FileServer.h" /> | ||||
|     <ClInclude Include="HttpService.h" /> | ||||
|     <ClInclude Include="Map.h" /> | ||||
|     <ClInclude Include="PlcDeviceDlg.h" /> | ||||
|     <ClInclude Include="Resource.h" /> | ||||
|     <ClInclude Include="stdafx.h" /> | ||||
|     <ClInclude Include="targetver.h" /> | ||||
|     <ClInclude Include="PluginMainDialog.h" /> | ||||
|     <ClInclude Include="PluginApp.h" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="..\..\..\3rdparty\json\src\json_reader.cpp" /> | ||||
|     <ClCompile Include="..\..\..\3rdparty\json\src\json_value.cpp" /> | ||||
|     <ClCompile Include="..\..\..\3rdparty\json\src\json_writer.cpp" /> | ||||
|     <ClCompile Include="..\..\..\3rdparty\sqlite\shell.c" /> | ||||
|     <ClCompile Include="..\..\..\3rdparty\sqlite\sqlite3.c" /> | ||||
|     <ClCompile Include="..\..\..\3rdparty\whttp-server-core\mongoose.cpp" /> | ||||
|     <ClCompile Include="..\..\..\3rdparty\whttp-server-core\WHttpServer.cpp" /> | ||||
|     <ClCompile Include="..\..\..\3rdparty\whttp-server-core\WThreadPool.cpp" /> | ||||
|     <ClCompile Include="AppMsgHandler.cpp" /> | ||||
|     <ClCompile Include="CanDeviceDlg.cpp" /> | ||||
|     <ClCompile Include="CEXMemFileQueue.cpp" /> | ||||
|     <ClCompile Include="CEXVirtualListCtrl.cpp" /> | ||||
|     <ClCompile Include="ClientSocket.cpp" /> | ||||
|     <ClCompile Include="ClientSocketThread.cpp" /> | ||||
|     <ClCompile Include="ColoredListCtrl.cpp" /> | ||||
|     <ClCompile Include="ConifgDlg.cpp" /> | ||||
|     <ClCompile Include="DatabaseMgr.cpp" /> | ||||
|     <ClCompile Include="FileServer.cpp" /> | ||||
|     <ClCompile Include="HttpService.cpp" /> | ||||
|     <ClCompile Include="PlcDeviceDlg.cpp" /> | ||||
|     <ClCompile Include="stdafx.cpp"> | ||||
|       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> | ||||
|       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> | ||||
|       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> | ||||
|       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="PluginMainDialog.cpp" /> | ||||
|     <ClCompile Include="PluginApp.cpp" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ResourceCompile Include="Kernel.rc" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <None Include="res\Kernel.rc2" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Image Include="res\Kernel.ico" /> | ||||
|   </ItemGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||||
|   <ImportGroup Label="ExtensionTargets"> | ||||
|   </ImportGroup> | ||||
|   <ProjectExtensions> | ||||
|     <VisualStudio> | ||||
|       <UserProperties RESOURCE_FILE="" /> | ||||
|     </VisualStudio> | ||||
|   </ProjectExtensions> | ||||
| </Project> | ||||
							
								
								
									
										23
									
								
								Plugin/Plc/Map.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								Plugin/Plc/Map.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "Map.h" | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| 	POS_UNLOAD                 = 1,   //AGVж<56><D0B6><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	POS_UNLOAD_SLOW_DOWN       = 2,   //ж<><D0B6><EFBFBD><EFBFBD><EFBFBD>ٵ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>״<EFBFBD> | ||||
| 	POS_CLOSE_SHOP_ROLLER_DOOR = 3,   //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD> | ||||
| 	POS_OPEN_SHOP_ROLLER_DOOR  = 4,   //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD> | ||||
| 	POS_MANHOLE_COVER_1        = 5,   //<2F><><EFBFBD><EFBFBD>#1 | ||||
| 	POS_MANHOLE_COVER_2        = 6,   //<2F><><EFBFBD><EFBFBD>#2 | ||||
| 	//POS_BOLLARD_SLOW_DOWN_1    = 6,   //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٵ<EFBFBD>#1 | ||||
| 	POS_BOLLARD_STOP_1         = 7,   //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD>#1 | ||||
| 	POS_MANHOLE_COVER_3        = 8,   //<2F><><EFBFBD><EFBFBD>#3 | ||||
| 	POS_MANHOLE_COVER_4        = 9,   //<2F><><EFBFBD><EFBFBD>#4 | ||||
| 	//POS_BOLLARD_SLOW_DOWN_2    = 10,  //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٵ<EFBFBD>#2 | ||||
| 	POS_BOLLARD_STOP_2         = 10,  //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD>#2 | ||||
| 	POS_MANHOLE_COVER_5        = 11,  //<2F><><EFBFBD><EFBFBD>#5 | ||||
| 	POS_MANHOLE_COVER_6        = 12,  //<2F><><EFBFBD><EFBFBD>#6 | ||||
| 	POS_LOAD_SLOW_DOWN         = 13,  //װ<><D7B0><EFBFBD><EFBFBD><EFBFBD>ٵ<EFBFBD> | ||||
| 	POS_LOAD                   = 14,  //װ<><D7B0><EFBFBD><EFBFBD> | ||||
| }ENUM_LOCATION_MAP; //<2F><>ͼ<EFBFBD><CDBC>λ | ||||
							
								
								
									
										463
									
								
								Plugin/Plc/ModbusClient.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										463
									
								
								Plugin/Plc/ModbusClient.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,463 @@ | ||||
| // ClientSocketThread.cpp : implementation file | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| #include "ModbusClient.h" | ||||
|  | ||||
|  | ||||
| // CModbusClient | ||||
| const UINT  glServerPort = 502; | ||||
|  | ||||
| #define		RECVDATA_BUFLEN		1024000			//<2F><><EFBFBD>ݽ<EFBFBD><DDBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| #define		DATALEN_PERTIME		512				//<2F><><EFBFBD>δ<EFBFBD>Scoket<65><74><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD> | ||||
| #define     DATADEAL_BUFLEN     512				//<2F><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(TCP֡<50><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>) | ||||
|  | ||||
| #define     SOCKET_TIME_OUT     500 | ||||
|  | ||||
| IMPLEMENT_DYNCREATE(CModbusClient, CWinThread) | ||||
|  | ||||
| CModbusClient::CModbusClient(CString strIp, int nPort, HWND hWnd) | ||||
| { | ||||
| 	m_pRecvDataBuffer	= NULL; | ||||
| 	m_pDealBuf			= NULL; | ||||
| 	m_iWritePos         = 0; | ||||
| 	m_iReadPos          = 0; | ||||
| 	m_llDataTotalLen    = 0; | ||||
| 	m_llReadTotal       = 0; | ||||
| 	m_strSerIP          = strIp; | ||||
| 	m_hWnd              = hWnd; | ||||
| 	m_bConnected        = FALSE; | ||||
| 	m_ReadEventHandle   = CreateEvent(NULL, TRUE, FALSE, NULL); //<2F><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>λ | ||||
| 	m_WriteEventHandle  = CreateEvent(NULL, TRUE, FALSE, NULL); //<2F><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>λ | ||||
|  | ||||
|  | ||||
| } | ||||
|  | ||||
| CModbusClient::CModbusClient() | ||||
| { | ||||
|  | ||||
| } | ||||
|  | ||||
| CModbusClient::~CModbusClient() | ||||
| { | ||||
| 	if (m_pDealBuf) | ||||
| 	{ | ||||
| 		delete m_pDealBuf; | ||||
| 		m_pDealBuf =NULL; | ||||
| 	} | ||||
|  | ||||
| 	if (m_pRecvDataBuffer) | ||||
| 	{ | ||||
| 		delete m_pRecvDataBuffer; | ||||
| 		m_pRecvDataBuffer =NULL; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| BOOL CModbusClient::InitInstance() | ||||
| { | ||||
| 	if (!AfxSocketInit()) // <20><>ʼ<EFBFBD><CABC>CSocket<65><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD> | ||||
| 	{ | ||||
| 		CWinThread::InitInstance();		//<2F><><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD> | ||||
| 		return FALSE; | ||||
| 	} | ||||
|  | ||||
| 	//<2F><><EFBFBD><EFBFBD>socket | ||||
| 	if (!m_socket.Create()) | ||||
| 	{ | ||||
| 		//<2F><><EFBFBD><EFBFBD>socketʧ<74><CAA7> | ||||
| 		CWinThread::InitInstance();		//<2F><><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD> | ||||
| 		return FALSE; | ||||
| 	} | ||||
| 	 | ||||
| 	// <20><><EFBFBD>÷<EFBFBD><C3B7>ͳ<EFBFBD>ʱʱ<CAB1>䣬<EFBFBD><E4A3AC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD> | ||||
| 	int nTimeout = SOCKET_TIME_OUT;  | ||||
| 	m_socket.SetSockOpt(SO_SNDTIMEO, (char*)&nTimeout, sizeof(nTimeout), SOL_SOCKET); | ||||
|  | ||||
| 	// <20><><EFBFBD>ý<EFBFBD><C3BD>ճ<EFBFBD>ʱʱ<CAB1>䣬<EFBFBD><E4A3AC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD> | ||||
| 	nTimeout = SOCKET_TIME_OUT; | ||||
| 	m_socket.SetSockOpt(SO_RCVTIMEO, (char*)&nTimeout, sizeof(nTimeout), SOL_SOCKET); | ||||
|  | ||||
| 	//m_socket.m_pMainDlg = m_pMainDlg; | ||||
| 	m_socket.m_pThrd	= this; | ||||
|  | ||||
| 	if (!m_socket.Connect(m_strSerIP, glServerPort)) | ||||
| 	{ | ||||
| 		CWinThread::InitInstance();		//<2F><><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD> | ||||
| 		m_bConnected = FALSE; | ||||
| 		//return FALSE; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		m_bConnected = TRUE; | ||||
| 		//<2F><><EFBFBD>ӳɹ<D3B3><C9B9><EFBFBD><EFBFBD><EFBFBD>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 		PostMessage(m_hWnd, WM_NETMESSAGE, NET_CONNECT_OK, (LPARAM)m_bDevID); | ||||
| 	} | ||||
|  | ||||
| 	m_pRecvDataBuffer  = new BYTE[RECVDATA_BUFLEN]; | ||||
| 	ASSERT(m_pRecvDataBuffer != NULL); | ||||
|  | ||||
| 	m_pDealBuf = new BYTE[DATADEAL_BUFLEN]; | ||||
| 	ASSERT(m_pDealBuf != NULL); | ||||
|  | ||||
| 	m_iWritePos =0; | ||||
| 	m_iReadPos  =0; | ||||
| 	m_llDataTotalLen =0; | ||||
| 	m_llReadTotal =0; | ||||
| 	m_wTcpID   =0; | ||||
|  | ||||
| 	 | ||||
|  | ||||
| 	return TRUE;  //<2F>̲߳<DFB3><CCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD> | ||||
| } | ||||
|  | ||||
| int CModbusClient::ExitInstance() | ||||
| { | ||||
| 	if (m_socket.m_hSocket != INVALID_SOCKET) | ||||
| 	{ | ||||
| 		m_socket.ShutDown(2); | ||||
| 		m_socket.Close(); | ||||
| 	} | ||||
|  | ||||
| 	//m_bConnected = FALSE; | ||||
| 	return CWinThread::ExitInstance(); | ||||
| } | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CModbusClient, CWinThread) | ||||
| 	ON_THREAD_MESSAGE(WM_THREAD_RECV, OnCustomMsg) | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
|  | ||||
| // CModbusClient message handlers | ||||
|  | ||||
| void CModbusClient::OnCustomMsg(WPARAM wParam,LPARAM lParam) | ||||
| { | ||||
| 	BYTE  pReadBf[DATALEN_PERTIME+1] = {0}; | ||||
| 	int iRdLen =0; | ||||
|  | ||||
| 	switch(wParam) | ||||
| 	{ | ||||
| 	case WP_WPARA_RECV: | ||||
| 		// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>Ȱѽ<C8B0><D1BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>ص<EFBFBD> | ||||
| 		m_socket.AsyncSelect(FD_CLOSE); | ||||
|  | ||||
|  | ||||
| 		//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD> | ||||
| 		iRdLen = m_socket.Receive(pReadBf,DATALEN_PERTIME); | ||||
| 		if (0 ==iRdLen) | ||||
| 		{ | ||||
| 			//ToDo:<3A>Զ˶Ͽ<CBB6><CFBF><EFBFBD><EFBFBD><EFBFBD> | ||||
| 			PostMessage(m_hWnd, WM_NETMESSAGE, NET_DISCONNECT, (LPARAM)m_bDevID); | ||||
| 			OutputDebugString(_T("CSerSocketThread:1-<2D><><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>Ϊ0<CEAA><30>TCP<43><50><EFBFBD>ӶϿ<D3B6>......")); | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>Ҫ<EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD>뻺<EFBFBD><EBBBBA><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7> | ||||
| 		if(m_iWritePos + iRdLen > RECVDATA_BUFLEN) | ||||
| 		{ | ||||
| 			int iTailLen = RECVDATA_BUFLEN - m_iWritePos; | ||||
| 			memcpy(m_pRecvDataBuffer +m_iWritePos,pReadBf,iTailLen); | ||||
|  | ||||
| 			int iHeadLen = iRdLen - iTailLen; | ||||
| 			memcpy(m_pRecvDataBuffer,pReadBf + iTailLen,iHeadLen); | ||||
|  | ||||
| 			m_iWritePos = iHeadLen; | ||||
| 		}else{ | ||||
| 			//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD>㹻<EFBFBD><E3B9BB><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 			memcpy(m_pRecvDataBuffer+m_iWritePos,pReadBf,iRdLen); | ||||
| 			m_iWritePos += iRdLen; | ||||
| 		} | ||||
|  | ||||
| 		//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD> | ||||
| 		m_llDataTotalLen += iRdLen; | ||||
| 		AnalysisRecvData(); | ||||
|  | ||||
| 		//<2F><><EFBFBD>´<C2B4><F2BFAABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD> | ||||
| 		m_socket.AsyncSelect(FD_READ|FD_CLOSE); | ||||
| 		break; | ||||
| 	case WP_WPARA_CLOSE: | ||||
| 		PostMessage(m_hWnd, WM_NETMESSAGE, NET_DISCONNECT, (LPARAM)m_bDevID); | ||||
| 		//m_socket.Close(); | ||||
|  | ||||
| 		OutputDebugString(_T("TCP<EFBFBD><EFBFBD><EFBFBD>ӶϿ<EFBFBD>......")); | ||||
| 		break; | ||||
| 	case WP_WPARA_THREAD_QUIT: | ||||
| 		PostQuitMessage(0); | ||||
| 		break; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CModbusClient::AnalysisRecvData() | ||||
| { | ||||
| 	if (m_llReadTotal + sizeof(ST_MODBUS_MBAP_HEADER) < m_llDataTotalLen)   //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3>ȴ<EFBFBD><C8B4><EFBFBD>MBAP<41><50> | ||||
| 	{ | ||||
| 		memset(m_pDealBuf,0,DATADEAL_BUFLEN); | ||||
|  | ||||
| 		//дָ<D0B4><D6B8><EFBFBD><EFBFBD>ʱ<EFBFBD>䶯<EFBFBD><E4B6AF><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>ǰλ<C7B0><CEBB> | ||||
| 		int iRdCurrPos  = m_iReadPos; | ||||
| 		int iWrtCurrPos = m_iWritePos; | ||||
|  | ||||
| 		ST_MODBUS_MBAP_HEADER  stMbap; | ||||
| 		if(iRdCurrPos  < iWrtCurrPos)  //дָ<D0B4>볬ǰ<EBB3AC><C7B0>ָ<EFBFBD><D6B8>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>֮<EFBFBD><D6AE>  | ||||
| 		{ | ||||
| 			memcpy(&stMbap,m_pRecvDataBuffer+iRdCurrPos,sizeof(ST_MODBUS_MBAP_HEADER));	 | ||||
| 			if (m_llReadTotal + sizeof(ST_MODBUS_MBAP_HEADER) +(ntohs(stMbap.wLen) -1) <= m_llDataTotalLen) | ||||
| 			{ | ||||
| 				memcpy(m_pDealBuf,m_pRecvDataBuffer+iRdCurrPos,sizeof(ST_MODBUS_MBAP_HEADER)+ ntohs(stMbap.wLen) -1); | ||||
| 				DealFrameData(m_pDealBuf); | ||||
|  | ||||
| 				m_iReadPos +=(sizeof(ST_MODBUS_MBAP_HEADER) + ntohs(stMbap.wLen) -1); | ||||
| 				m_llReadTotal += (sizeof(ST_MODBUS_MBAP_HEADER) + ntohs(stMbap.wLen) -1); | ||||
| 			}else{ | ||||
| 				return;  //<2F><><EFBFBD><EFBFBD>һ֡ | ||||
| 			} | ||||
| 		} | ||||
| 		else{//дָ<D0B4><D6B8><EFBFBD>ͺ<EFBFBD><CDBA><EFBFBD>ָ<EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2>ͷ | ||||
|  | ||||
| 			if (iRdCurrPos +sizeof(ST_MODBUS_MBAP_HEADER) <= RECVDATA_BUFLEN) | ||||
| 			{ | ||||
| 				memcpy(&stMbap,m_pRecvDataBuffer+iRdCurrPos,sizeof(ST_MODBUS_MBAP_HEADER));	 | ||||
| 				if (m_llReadTotal+sizeof(ST_MODBUS_MBAP_HEADER)+ ntohs(stMbap.wLen) -1 <= m_llDataTotalLen) | ||||
| 				{ | ||||
| 					if (iRdCurrPos + sizeof(ST_MODBUS_MBAP_HEADER) + ntohs(stMbap.wLen) -1 <= RECVDATA_BUFLEN) //дָ<D0B4><D6B8><EFBFBD>ͺ<EFBFBD><CDBA><EFBFBD>ָ<EFBFBD>룬<EFBFBD><EBA3AC>ָ<EFBFBD>뵽<EFBFBD><EBB5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD>Թ<EFBFBD>һ֡<D2BB><D6A1><EFBFBD><EFBFBD> | ||||
| 					{ | ||||
| 						memcpy(m_pDealBuf,m_pRecvDataBuffer+iRdCurrPos,sizeof(ST_MODBUS_MBAP_HEADER)+ ntohs(stMbap.wLen) -1); | ||||
| 						DealFrameData(m_pDealBuf); | ||||
|  | ||||
| 						m_iReadPos +=(sizeof(ST_MODBUS_MBAP_HEADER) + ntohs(stMbap.wLen) -1); | ||||
| 						m_llReadTotal += (sizeof(ST_MODBUS_MBAP_HEADER) +ntohs(stMbap.wLen) -1); | ||||
| 						m_iReadPos =m_iReadPos % RECVDATA_BUFLEN; | ||||
| 					}else{ | ||||
| 						//<2F><>ǰ<EFBFBD><C7B0>ָ<EFBFBD>뵽<EFBFBD><EBB5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD>MBAPͷ<50><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD> | ||||
| 						memcpy(m_pDealBuf,m_pRecvDataBuffer+iRdCurrPos,RECVDATA_BUFLEN - iRdCurrPos); | ||||
| 						memcpy(m_pDealBuf+RECVDATA_BUFLEN - iRdCurrPos,m_pRecvDataBuffer,sizeof(ST_MODBUS_MBAP_HEADER) + ntohs(stMbap.wLen) -1 -(RECVDATA_BUFLEN - iRdCurrPos)); | ||||
| 						DealFrameData(m_pDealBuf); | ||||
| 						 | ||||
| 						m_iReadPos = sizeof(ST_MODBUS_MBAP_HEADER) +ntohs(stMbap.wLen) -1 -(RECVDATA_BUFLEN - iRdCurrPos); | ||||
| 						m_llReadTotal += (sizeof(ST_MODBUS_MBAP_HEADER) + ntohs(stMbap.wLen) -1); | ||||
| 					} | ||||
| 				} | ||||
| 				else{ | ||||
| 					return;//<2F><><EFBFBD><EFBFBD>һ֡ | ||||
| 				} | ||||
|  | ||||
| 			}else{ | ||||
| 				//<2F><>ǰ<EFBFBD><C7B0>ָ<EFBFBD>뵽<EFBFBD><EBB5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD>MBAPͷ<50><CDB7><EFBFBD><EFBFBD><F3B2BFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><DABB><EFBFBD><EFBFBD><EFBFBD>ͷ | ||||
| 				memcpy(m_pDealBuf,m_pRecvDataBuffer+iRdCurrPos,RECVDATA_BUFLEN -iRdCurrPos); | ||||
| 				memcpy(m_pDealBuf+RECVDATA_BUFLEN -iRdCurrPos,m_pRecvDataBuffer,sizeof(ST_MODBUS_MBAP_HEADER) -(RECVDATA_BUFLEN - iRdCurrPos)); | ||||
|  | ||||
| 				memcpy(&stMbap,m_pDealBuf,sizeof(ST_MODBUS_MBAP_HEADER)); | ||||
| 				if (m_llReadTotal+sizeof(ST_MODBUS_MBAP_HEADER)+ ntohs(stMbap.wLen) -1 <= m_llDataTotalLen) | ||||
| 				{ | ||||
| 					memcpy(m_pDealBuf,m_pRecvDataBuffer+iRdCurrPos,RECVDATA_BUFLEN -iRdCurrPos); | ||||
| 					memcpy(m_pDealBuf+RECVDATA_BUFLEN -iRdCurrPos,m_pRecvDataBuffer,sizeof(ST_MODBUS_MBAP_HEADER) -(RECVDATA_BUFLEN - iRdCurrPos) + ntohs(stMbap.wLen) -1); | ||||
|  | ||||
| 					DealFrameData(m_pDealBuf); | ||||
| 					 | ||||
| 					m_iReadPos = sizeof(ST_MODBUS_MBAP_HEADER) -(RECVDATA_BUFLEN - iRdCurrPos) + ntohs(stMbap.wLen) -1; | ||||
| 					m_llReadTotal += (sizeof(ST_MODBUS_MBAP_HEADER) + ntohs(stMbap.wLen) -1); | ||||
| 				} | ||||
| 				else{ | ||||
| 					return;//<2F><><EFBFBD><EFBFBD>һ֡ | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
|  | ||||
| void CModbusClient::DealFrameData(BYTE* pData) | ||||
| { | ||||
| 	BYTE   bSampleData[512] ={0}; | ||||
| 	NET_PACKET* pNetPacket  = NULL; | ||||
| 	int nLen                = 0; | ||||
| 	ST_MODBUS_MBAP_HEADER  stMbap; | ||||
|  | ||||
| 	BYTE  bFuncCode = pData[sizeof(ST_MODBUS_MBAP_HEADER)]; | ||||
| 	memcpy(&stMbap,pData,sizeof(ST_MODBUS_MBAP_HEADER)); | ||||
| 	 | ||||
| 	int iFrmLen = ntohs(stMbap.wLen) +6; | ||||
| 	memcpy(bSampleData,pData,iFrmLen); | ||||
|  | ||||
| 	memset(&m_stReadRspFrm, 0, sizeof(ST_MODBUS_SERVER_RSPREAD_FRAME)); | ||||
| 	memset(&m_stWrtRspFrm, 0, sizeof(ST_MODBUS_SERVER_RSPWRT_FRAME)); | ||||
| 	memset(&m_stRspErrFrm, 0, sizeof(ST_MODBUS_SERVER_RSPERR_FRAME)); | ||||
|  | ||||
| 	int iDataLen =ntohs(stMbap.wLen) -1; | ||||
| 	switch(bFuncCode) | ||||
| 	{ | ||||
| 	case EN_MODBUS_READ_SINGLECOIL: | ||||
| 	case EN_MODBUS_READ_PERSISREG: | ||||
| 		memcpy(&m_stReadRspFrm,pData,iFrmLen);	//ST_MODBUS_SERVER_RSPREAD_FRAME<4D>ij<EFBFBD>ԱbRtnData<74><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD>255<35>ֽڣ<D6BD>ʵ<EFBFBD><CAB5>ռ<EFBFBD>ò<EFBFBD><C3B2><EFBFBD>255<35><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>sizeof<6F><66>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 		SetEvent(m_ReadEventHandle); | ||||
| 												//((CMechanicalArmOptDlg*)m_pMainDlg)->OnDevReadRspDataToBuffer(m_bDevID,stReadRspFrm); | ||||
|  | ||||
| 		/*pNetPacket                 = new NET_PACKET; | ||||
| 		pNetPacket->enType         = NET_RD_MSG_RET; | ||||
| 		pNetPacket->nDevId         = m_bDevID; | ||||
| 		pNetPacket->pData          = new char[iFrmLen + 1]; | ||||
| 		memcpy(pNetPacket->pData, pData, iFrmLen); | ||||
| 		pNetPacket->pData[iFrmLen] = '\0'; | ||||
| 		pNetPacket->lLen           = iFrmLen; | ||||
| 		PostMessage(m_hWnd, WM_NETMESSAGE, NET_DATA_MSG, (LPARAM)pNetPacket);*/ | ||||
|  | ||||
| 		//delete[] pNetPacket->pData; | ||||
| 		//delete pNetPacket; | ||||
|  | ||||
| 		break; | ||||
| 	case EN_MODBUS_WRITE_SINGLECOIL: | ||||
| 	case EN_MODBUS_WRITE_MULTIREG: | ||||
| 		memcpy(&m_stWrtRspFrm,pData,sizeof(ST_MODBUS_SERVER_RSPWRT_FRAME)); | ||||
| 		SetEvent(m_WriteEventHandle); | ||||
| 		//((CMechanicalArmOptDlg*)m_pMainDlg)->OnDevWrtRspDataToBuffer(m_bDevID,stWrtRspFrm); | ||||
| 		/*nLen                   = sizeof(ST_MODBUS_SERVER_RSPWRT_FRAME); | ||||
| 		pNetPacket             = new NET_PACKET; | ||||
| 		pNetPacket->enType     = NET_WR_MSG_RET; | ||||
| 		pNetPacket->nDevId     = m_bDevID; | ||||
| 		pNetPacket->pData      = new char[nLen + 1]; | ||||
| 		memcpy(pNetPacket->pData, pData, nLen); | ||||
| 		pNetPacket->pData[nLen] = '\0'; | ||||
| 		pNetPacket->lLen   = nLen; | ||||
| 		PostMessage(m_hWnd, WM_NETMESSAGE, NET_DATA_MSG, (LPARAM)pNetPacket);*/ | ||||
|  | ||||
| 		break; | ||||
|  | ||||
| 		//ToDo:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	case EN_MODBUS_READ_SINGLECOIL_RSPERR: | ||||
| 	case EN_MODBUS_READ_PERSISREG_RSPERR: | ||||
| 	case EN_MODBUS_WRITE_SINGLECOIL_RSPERR: | ||||
| 	case EN_MODBUS_WRITE_MULTIREG_RSPERR: | ||||
| 		memcpy(&m_stWrtRspFrm,pData,sizeof(ST_MODBUS_SERVER_RSPERR_FRAME)); | ||||
| 		break; | ||||
| 	} | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
| int CModbusClient::WriteMultipleRegisters(int nRegAddr, int nRegCnt, short * pWriteData) | ||||
| { | ||||
| 	if (m_bConnected == FALSE) | ||||
| 	{ | ||||
| 		PostMessage(m_hWnd, WM_NETMESSAGE, NET_DISCONNECT, (LPARAM)m_bDevID); | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	BYTE  bData[512] = { 0 }; | ||||
|  | ||||
| 	if (m_wTcpID + 1 == 0xFFFF) | ||||
| 	{ | ||||
| 		m_wTcpID = 1; | ||||
| 	} | ||||
| 	else { | ||||
| 		m_wTcpID++; | ||||
| 	} | ||||
|  | ||||
| 	//<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	ST_MODBUS_CLIENT_RQTWRTMULTIREG_FRAME  frame; | ||||
| 	ST_MODBUS_MBAP_HEADER        stMbapHeader; | ||||
| 	stMbapHeader.wTransFlag    = htons(m_wTcpID); | ||||
| 	stMbapHeader.wProtocolFlag = 0; | ||||
| 	stMbapHeader.wLen          = htons(7 + nRegCnt*2); | ||||
| 	stMbapHeader.bUnitFlag     = 0x01; | ||||
|  | ||||
| 	frame.stMbapHeader         = stMbapHeader; | ||||
| 	frame.bFuncConde           = 0x10;              //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	frame.wStartAddr           = htons(nRegAddr - 40001);  //<2F>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ | ||||
| 	frame.wRegNum              = htons(nRegCnt);    //<2F>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD> | ||||
| 	frame.bLen                 = nRegCnt * 2;       //<2F><><EFBFBD><EFBFBD><EFBFBD>ֽڳ<D6BD><DAB3><EFBFBD>(<28>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*2) | ||||
|  | ||||
| 	for (int i = 0; i < nRegCnt; i++) | ||||
| 	{ | ||||
| 		UINT16 uintValue = htons(*(pWriteData+i)); | ||||
| 		char* byteArray = (char*)(&uintValue); // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>4<EFBFBD>ֽڵ<D6BD><DAB5>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 		for (int j = 0; j < 2; ++j) | ||||
| 		{ | ||||
| 			frame.bRegVal[i*2 + j] = byteArray[j]; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	int iRtnsend = m_socket.Send(&frame, sizeof(ST_MODBUS_CLIENT_RQTWRTMULTIREG_FRAME) - (255 - nRegCnt * 2)); | ||||
| 	if (iRtnsend > 0) | ||||
| 	{ | ||||
| 		//<2F>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5>ź<EFBFBD><C5BA><EFBFBD> | ||||
| 		switch (::WaitForSingleObject(m_WriteEventHandle, SOCKET_TIME_OUT)) | ||||
| 		{ | ||||
| 			case WAIT_OBJECT_0: | ||||
| 			{ | ||||
| 				::ResetEvent(m_WriteEventHandle); | ||||
| 				break; | ||||
| 			} | ||||
| 			case WAIT_TIMEOUT: | ||||
| 			case WAIT_FAILED: | ||||
| 			default: | ||||
| 			{ | ||||
| 				PostMessage(m_hWnd, WM_NETMESSAGE, NET_DISCONNECT, (LPARAM)m_bDevID); | ||||
| 				break; | ||||
| 			} | ||||
| 				 | ||||
| 		} | ||||
| 	} | ||||
| 	return iRtnsend; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| int CModbusClient::ReadMultipleRegisters(int nRegAddr, int nRegCnt, short * pReadData) | ||||
| { | ||||
| 	if (m_bConnected == FALSE) | ||||
| 	{ | ||||
| 		PostMessage(m_hWnd, WM_NETMESSAGE, NET_DISCONNECT, (LPARAM)m_bDevID); | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| 	BYTE  bData[512] = { 0 }; | ||||
|  | ||||
| 	if (m_wTcpID + 1 == 0xFFFF) | ||||
| 	{ | ||||
| 		m_wTcpID = 1; | ||||
| 	} | ||||
| 	else { | ||||
| 		m_wTcpID++; | ||||
| 	} | ||||
|  | ||||
| 	//<2F><><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	ST_MODBUS_CLIENT_RQTREAD_FRAME  frame; | ||||
| 	ST_MODBUS_MBAP_HEADER        stMbapHeader; | ||||
| 	stMbapHeader.wTransFlag = htons(m_wTcpID); | ||||
| 	stMbapHeader.wProtocolFlag = 0; | ||||
| 	stMbapHeader.wLen = htons(6); | ||||
| 	stMbapHeader.bUnitFlag = 0x01; | ||||
|  | ||||
| 	frame.stMbapHeader = stMbapHeader; | ||||
| 	frame.bFuncConde   = 0x03;              //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	frame.wStartAddr   = htons(nRegAddr - 40001);                 //<2F>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ | ||||
| 	frame.wRegNum      = htons(nRegCnt);    //<2F>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD> | ||||
| 	 | ||||
|  | ||||
| 	int iRtnsend = m_socket.Send(&frame, sizeof(ST_MODBUS_CLIENT_RQTREAD_FRAME)); | ||||
|  | ||||
| 	if (iRtnsend > 0) | ||||
| 	{ | ||||
| 		//<2F>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5>ź<EFBFBD><C5BA><EFBFBD> | ||||
| 		switch (::WaitForSingleObject(m_ReadEventHandle, SOCKET_TIME_OUT)) | ||||
| 		{ | ||||
| 			case WAIT_OBJECT_0: | ||||
| 			{ | ||||
| 				short *pData = (short *)(m_stReadRspFrm.bRtnData); | ||||
| 				for (int i = 0; i < m_stReadRspFrm.bLen / 2; i++) | ||||
| 				{ | ||||
| 					pReadData[i] = htons(*(pData + i)); | ||||
| 				} | ||||
| 				::ResetEvent(m_ReadEventHandle); | ||||
| 				break; | ||||
| 			} | ||||
| 			case WAIT_TIMEOUT: | ||||
| 			case WAIT_FAILED: | ||||
| 			default: | ||||
| 			{ | ||||
| 				PostMessage(m_hWnd, WM_NETMESSAGE, NET_DISCONNECT, (LPARAM)m_bDevID); | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return iRtnsend; | ||||
| } | ||||
							
								
								
									
										51
									
								
								Plugin/Plc/ModbusClient.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								Plugin/Plc/ModbusClient.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| #pragma once | ||||
| #include "ClientSocket.h" | ||||
| #include "CommDataDef.h" | ||||
| // CClientSocketThread | ||||
| class CModbusClient : public CWinThread | ||||
| { | ||||
| 	DECLARE_DYNCREATE(CModbusClient) | ||||
|  | ||||
| public: | ||||
| 	CModbusClient(CString strIp, int nPort, HWND  hWnd);           // protected constructor used by dynamic creation | ||||
| 	CModbusClient();           // protected constructor used by dynamic creation | ||||
| 	virtual ~CModbusClient(); | ||||
|  | ||||
| public: | ||||
| 	virtual BOOL InitInstance(); | ||||
| 	virtual int  ExitInstance(); | ||||
|  | ||||
| 	void   AnalysisRecvData();          //<2F><><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD>ӿڣ<D3BF><DAA3><EFBFBD><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD> | ||||
| 	void   DealFrameData(BYTE* pData); | ||||
| 	int    WriteMultipleRegisters(int nRegAddr, int nRegCnt, short * pWriteData); | ||||
| 	int    ReadMultipleRegisters(int nRegAddr, int nRegCnt, short * pReadData); | ||||
|  | ||||
| public: | ||||
|  | ||||
| 	HWND     	    m_hWnd; | ||||
| 	CString			m_strSerIP; | ||||
| 	BYTE			m_bDevID; | ||||
| 	WORD			m_wTcpID; | ||||
| 	CClientSocket	m_socket; | ||||
| 	BOOL            m_bConnected; | ||||
| 	HANDLE          m_ReadEventHandle;  //<2F><><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>ں˶<DABA><CBB6><EFBFBD> | ||||
| 	HANDLE          m_WriteEventHandle; //д<>Ĵ<EFBFBD><C4B4><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>ں˶<DABA><CBB6><EFBFBD> | ||||
|  | ||||
| 	ST_MODBUS_SERVER_RSPREAD_FRAME m_stReadRspFrm; | ||||
| 	ST_MODBUS_SERVER_RSPWRT_FRAME  m_stWrtRspFrm; | ||||
| 	ST_MODBUS_SERVER_RSPERR_FRAME  m_stRspErrFrm; | ||||
|  | ||||
| 	BYTE*			m_pRecvDataBuffer;			 //<2F><><EFBFBD>ݽ<EFBFBD><DDBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8> | ||||
| 	BYTE*			m_pDealBuf;					 //<2F><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8> | ||||
| 	int				m_iWritePos; | ||||
| 	int				m_iReadPos; | ||||
| 	__int64			m_llDataTotalLen; | ||||
| 	__int64			m_llReadTotal; | ||||
|  | ||||
|  | ||||
| protected: | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
| 	afx_msg void OnCustomMsg(WPARAM wParam,LPARAM lParam); | ||||
| }; | ||||
|  | ||||
|  | ||||
							
								
								
									
										
											BIN
										
									
								
								Plugin/Plc/Plc.rc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Plugin/Plc/Plc.rc
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										250
									
								
								Plugin/Plc/Plc.vcxproj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										250
									
								
								Plugin/Plc/Plc.vcxproj
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,250 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||
|   <ItemGroup Label="ProjectConfigurations"> | ||||
|     <ProjectConfiguration Include="Debug|Win32"> | ||||
|       <Configuration>Debug</Configuration> | ||||
|       <Platform>Win32</Platform> | ||||
|     </ProjectConfiguration> | ||||
|     <ProjectConfiguration Include="Release|Win32"> | ||||
|       <Configuration>Release</Configuration> | ||||
|       <Platform>Win32</Platform> | ||||
|     </ProjectConfiguration> | ||||
|     <ProjectConfiguration Include="Debug|x64"> | ||||
|       <Configuration>Debug</Configuration> | ||||
|       <Platform>x64</Platform> | ||||
|     </ProjectConfiguration> | ||||
|     <ProjectConfiguration Include="Release|x64"> | ||||
|       <Configuration>Release</Configuration> | ||||
|       <Platform>x64</Platform> | ||||
|     </ProjectConfiguration> | ||||
|   </ItemGroup> | ||||
|   <PropertyGroup Label="Globals"> | ||||
|     <ProjectGuid>{CD291D2B-F677-46FC-BC5F-0C4A18CBBC11}</ProjectGuid> | ||||
|     <RootNamespace>VcsClient</RootNamespace> | ||||
|     <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||||
|     <Keyword>MFCProj</Keyword> | ||||
|   </PropertyGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>true</UseDebugLibraries> | ||||
|     <PlatformToolset>v143</PlatformToolset> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|     <UseOfMfc>Dynamic</UseOfMfc> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>false</UseDebugLibraries> | ||||
|     <PlatformToolset>v143</PlatformToolset> | ||||
|     <WholeProgramOptimization>true</WholeProgramOptimization> | ||||
|     <CharacterSet>Unicode</CharacterSet> | ||||
|     <UseOfMfc>Dynamic</UseOfMfc> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>true</UseDebugLibraries> | ||||
|     <PlatformToolset>v143</PlatformToolset> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|     <UseOfMfc>Dynamic</UseOfMfc> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>false</UseDebugLibraries> | ||||
|     <PlatformToolset>v143</PlatformToolset> | ||||
|     <WholeProgramOptimization>true</WholeProgramOptimization> | ||||
|     <CharacterSet>MultiByte</CharacterSet> | ||||
|     <UseOfMfc>Dynamic</UseOfMfc> | ||||
|   </PropertyGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||||
|   <ImportGroup Label="ExtensionSettings"> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="Shared"> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||||
|     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||||
|   </ImportGroup> | ||||
|   <PropertyGroup Label="UserMacros" /> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <LinkIncremental>true</LinkIncremental> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||||
|     <LinkIncremental>true</LinkIncremental> | ||||
|     <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\Agv</OutDir> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||||
|     <LinkIncremental>false</LinkIncremental> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||||
|     <LinkIncremental>false</LinkIncremental> | ||||
|     <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\Agv</OutDir> | ||||
|   </PropertyGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||||
|     <ClCompile> | ||||
|       <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <Optimization>Disabled</Optimization> | ||||
|       <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <SDLCheck>false</SDLCheck> | ||||
|       <AdditionalIncludeDirectories>E:\work\tank_svn\shiyu\project\fan\warehouse\code\cpp\vcs-client\Inc\json\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Windows</SubSystem> | ||||
|     </Link> | ||||
|     <Midl> | ||||
|       <MkTypLibCompatible>false</MkTypLibCompatible> | ||||
|       <ValidateAllParameters>true</ValidateAllParameters> | ||||
|       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|     </Midl> | ||||
|     <ResourceCompile> | ||||
|       <Culture>0x0804</Culture> | ||||
|       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ResourceCompile> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||||
|     <ClCompile> | ||||
|       <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <Optimization>Disabled</Optimization> | ||||
|       <PreprocessorDefinitions>_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <SDLCheck>false</SDLCheck> | ||||
|       <AdditionalIncludeDirectories>$(SolutionDir)3rdparty\json\inc;$(SolutionDir)CCEXPipe;$(SolutionDir)3rdparty\curl\inc;..\modbus;$(SolutionDir)3rdparty\can\inc;$(SolutionDir)3rdparty\sqlite;$(SolutionDir)3rdparty\whttp-server-core;$(SolutionDir)3rdparty\openssl\inc;$(SolutionDir)3rdparty\pthread\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Windows</SubSystem> | ||||
|       <AdditionalDependencies>libcurl.lib;ControlCAN.lib;libcrypto.lib;libssl.lib;pthreadVC2.lib</AdditionalDependencies> | ||||
|       <AdditionalLibraryDirectories>$(SolutionDir)3rdparty\curl\lib\x64;$(SolutionDir)$(Platform)\$(Configuration)\;$(SolutionDir)3rdparty\modbus\lib;$(SolutionDir)3rdparty\can\lib;$(SolutionDir)3rdparty\pthread\lib\x64;$(SolutionDir)3rdparty\openssl\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||||
|     </Link> | ||||
|     <Midl> | ||||
|       <MkTypLibCompatible>false</MkTypLibCompatible> | ||||
|       <ValidateAllParameters>true</ValidateAllParameters> | ||||
|       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|     </Midl> | ||||
|     <ResourceCompile> | ||||
|       <Culture>0x0804</Culture> | ||||
|       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ResourceCompile> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||||
|     <ClCompile> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <PrecompiledHeader>Use</PrecompiledHeader> | ||||
|       <Optimization>MaxSpeed</Optimization> | ||||
|       <FunctionLevelLinking>true</FunctionLevelLinking> | ||||
|       <IntrinsicFunctions>true</IntrinsicFunctions> | ||||
|       <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <SDLCheck>true</SDLCheck> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Windows</SubSystem> | ||||
|       <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||||
|       <OptimizeReferences>true</OptimizeReferences> | ||||
|     </Link> | ||||
|     <Midl> | ||||
|       <MkTypLibCompatible>false</MkTypLibCompatible> | ||||
|       <ValidateAllParameters>true</ValidateAllParameters> | ||||
|       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|     </Midl> | ||||
|     <ResourceCompile> | ||||
|       <Culture>0x0804</Culture> | ||||
|       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ResourceCompile> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||||
|     <ClCompile> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <PrecompiledHeader>NotUsing</PrecompiledHeader> | ||||
|       <Optimization>MaxSpeed</Optimization> | ||||
|       <FunctionLevelLinking>true</FunctionLevelLinking> | ||||
|       <IntrinsicFunctions>true</IntrinsicFunctions> | ||||
|       <PreprocessorDefinitions>_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <SDLCheck>false</SDLCheck> | ||||
|       <AdditionalIncludeDirectories>$(SolutionDir)3rdparty\json\inc;$(SolutionDir)CCEXPipe;$(SolutionDir)3rdparty\curl\inc;..\modbus;$(SolutionDir)3rdparty\can\inc;$(SolutionDir)3rdparty\sqlite;$(SolutionDir)3rdparty\whttp-server-core;$(SolutionDir)3rdparty\pthread\inc;$(SolutionDir)3rdparty\openssl\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <SubSystem>Windows</SubSystem> | ||||
|       <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||||
|       <OptimizeReferences>true</OptimizeReferences> | ||||
|       <AdditionalLibraryDirectories>$(SolutionDir)3rdparty\curl\lib\x64;$(SolutionDir)$(Platform)\$(Configuration)\;$(SolutionDir)3rdparty\modbus\lib;$(SolutionDir)3rdparty\can\lib;$(SolutionDir)3rdparty\pthread\lib\x64;$(SolutionDir)3rdparty\openssl\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||||
|       <AdditionalDependencies>libcurl.lib;ControlCAN.lib;libcrypto.lib;libssl.lib;pthreadVC2.lib</AdditionalDependencies> | ||||
|       <UACExecutionLevel>AsInvoker</UACExecutionLevel> | ||||
|     </Link> | ||||
|     <Midl> | ||||
|       <MkTypLibCompatible>false</MkTypLibCompatible> | ||||
|       <ValidateAllParameters>true</ValidateAllParameters> | ||||
|       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|     </Midl> | ||||
|     <ResourceCompile> | ||||
|       <Culture>0x0804</Culture> | ||||
|       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
|     </ResourceCompile> | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemGroup> | ||||
|     <Text Include="ReadMe.txt" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="..\..\3rdparty\whttp-server-core\LockQueue.hpp" /> | ||||
|     <ClInclude Include="..\..\3rdparty\whttp-server-core\unistd.h" /> | ||||
|     <ClInclude Include="CEXMemFileQueue.h" /> | ||||
|     <ClInclude Include="CEXVirtualListCtrl.h" /> | ||||
|     <ClInclude Include="ClientSocket.h" /> | ||||
|     <ClInclude Include="ColoredListCtrl.h" /> | ||||
|     <ClInclude Include="CommDataDef.h" /> | ||||
|     <ClInclude Include="ConfigDlg.h" /> | ||||
|     <ClInclude Include="Map.h" /> | ||||
|     <ClInclude Include="ModbusClient.h" /> | ||||
|     <ClInclude Include="PlcMainDlg.h" /> | ||||
|     <ClInclude Include="PluginPlc.h" /> | ||||
|     <ClInclude Include="Resource.h" /> | ||||
|     <ClInclude Include="stdafx.h" /> | ||||
|     <ClInclude Include="targetver.h" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_reader.cpp" /> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_value.cpp" /> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_writer.cpp" /> | ||||
|     <ClCompile Include="CEXMemFileQueue.cpp" /> | ||||
|     <ClCompile Include="CEXVirtualListCtrl.cpp" /> | ||||
|     <ClCompile Include="ClientSocket.cpp" /> | ||||
|     <ClCompile Include="ColoredListCtrl.cpp" /> | ||||
|     <ClCompile Include="ConifgDlg.cpp" /> | ||||
|     <ClCompile Include="ModbusClient.cpp" /> | ||||
|     <ClCompile Include="PlcMainDlg.cpp" /> | ||||
|     <ClCompile Include="PluginPlc.cpp" /> | ||||
|     <ClCompile Include="stdafx.cpp"> | ||||
|       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> | ||||
|       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> | ||||
|       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> | ||||
|       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> | ||||
|     </ClCompile> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ResourceCompile Include="Plc.rc" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <None Include="res\Plc.rc2" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Image Include="res\Plc.ico" /> | ||||
|   </ItemGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||||
|   <ImportGroup Label="ExtensionTargets"> | ||||
|   </ImportGroup> | ||||
|   <ProjectExtensions> | ||||
|     <VisualStudio> | ||||
|       <UserProperties RESOURCE_FILE="" /> | ||||
|     </VisualStudio> | ||||
|   </ProjectExtensions> | ||||
| </Project> | ||||
							
								
								
									
										70
									
								
								Plugin/Plc/Plc.vcxproj.filters
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								Plugin/Plc/Plc.vcxproj.filters
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,70 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="stdafx.cpp" /> | ||||
|     <ClCompile Include="ClientSocket.cpp"> | ||||
|       <Filter>modbus</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="ColoredListCtrl.cpp" /> | ||||
|     <ClCompile Include="CEXMemFileQueue.cpp" /> | ||||
|     <ClCompile Include="CEXVirtualListCtrl.cpp" /> | ||||
|     <ClCompile Include="ConifgDlg.cpp" /> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_reader.cpp"> | ||||
|       <Filter>json</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_value.cpp"> | ||||
|       <Filter>json</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="..\..\3rdparty\json\src\json_writer.cpp"> | ||||
|       <Filter>json</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="PlcMainDlg.cpp" /> | ||||
|     <ClCompile Include="PluginPlc.cpp" /> | ||||
|     <ClCompile Include="ModbusClient.cpp"> | ||||
|       <Filter>modbus</Filter> | ||||
|     </ClCompile> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="Resource.h" /> | ||||
|     <ClInclude Include="stdafx.h" /> | ||||
|     <ClInclude Include="targetver.h" /> | ||||
|     <ClInclude Include="ClientSocket.h"> | ||||
|       <Filter>modbus</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="CommDataDef.h"> | ||||
|       <Filter>modbus</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="ColoredListCtrl.h" /> | ||||
|     <ClInclude Include="CEXMemFileQueue.h" /> | ||||
|     <ClInclude Include="CEXVirtualListCtrl.h" /> | ||||
|     <ClInclude Include="Map.h" /> | ||||
|     <ClInclude Include="ConfigDlg.h" /> | ||||
|     <ClInclude Include="..\..\3rdparty\whttp-server-core\LockQueue.hpp" /> | ||||
|     <ClInclude Include="..\..\3rdparty\whttp-server-core\unistd.h" /> | ||||
|     <ClInclude Include="PlcMainDlg.h" /> | ||||
|     <ClInclude Include="PluginPlc.h" /> | ||||
|     <ClInclude Include="ModbusClient.h"> | ||||
|       <Filter>modbus</Filter> | ||||
|     </ClInclude> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ResourceCompile Include="Plc.rc" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Image Include="res\Plc.ico" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <None Include="res\Plc.rc2" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Text Include="ReadMe.txt" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Filter Include="json"> | ||||
|       <UniqueIdentifier>{263f81d2-2eb0-4ed0-aef7-dc7f1cd0dad3}</UniqueIdentifier> | ||||
|     </Filter> | ||||
|     <Filter Include="modbus"> | ||||
|       <UniqueIdentifier>{17681699-18ce-4ceb-a88b-62ae75356c4c}</UniqueIdentifier> | ||||
|     </Filter> | ||||
|   </ItemGroup> | ||||
| </Project> | ||||
							
								
								
									
										712
									
								
								Plugin/Plc/PlcMainDlg.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										712
									
								
								Plugin/Plc/PlcMainDlg.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,712 @@ | ||||
| // PlcDeviceDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD> | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| #include "PlcMainDlg.h" | ||||
| #include "ModbusClient.h" | ||||
| #include "afxdialogex.h" | ||||
| #include "PluginPlc.h" | ||||
| #include "resource.h" | ||||
|  | ||||
| #define  TIMER_UPDATE_TOPLC  1 | ||||
| #define  TIMER_UPDATE_TODLG  2 | ||||
| #define  TIMER_RECONNECT_PLC  3 | ||||
|  | ||||
|  | ||||
| // CPlcDeviceDlg <20>Ի<EFBFBD><D4BB><EFBFBD> | ||||
|  | ||||
| IMPLEMENT_DYNAMIC(CPlcMainDlg, CDialogEx) | ||||
|  | ||||
| CPlcMainDlg::CPlcMainDlg(CWnd* pParent /*=NULL*/) | ||||
| 	: CDialogEx(IDD_DEV_PLC_DLG, pParent) | ||||
| { | ||||
| 	m_pModbusClient    = NULL; | ||||
| 	m_bConnectServer   = FALSE; | ||||
| 	//m_pMainWnd         = (CPluginMainDialog *)pParent; | ||||
| 	 | ||||
| } | ||||
|  | ||||
| CPlcMainDlg::~CPlcMainDlg() | ||||
| { | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::DoDataExchange(CDataExchange* pDX) | ||||
| { | ||||
| 	CDialogEx::DoDataExchange(pDX); | ||||
| 	DDX_Control(pDX, IDC_IPADDRESS, m_ipAddrCtrl); | ||||
| 	DDX_Control(pDX, IDC_BTN_OPEN_FDOOR,  m_btnOpFdColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_CLOSE_FDOOR, m_btnCoFdColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_OPEN_BDOOR,  m_btnOpBdColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_CLOSE_BDOOR, m_btnCoBdColor); | ||||
|  | ||||
| 	DDX_Control(pDX, IDC_BTN_IndoorLsta, m_btnInDLRColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_IndoorRsta, m_btnInDRRColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_OutdoorLsta, m_btnOutDLRColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_OutdoorRsta, m_btnOutDRRColor); | ||||
|  | ||||
| 	DDX_Control(pDX, IDC_BTN_Fsafeside, m_btnFsafeSColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_Bsafeside, m_btnBsafeSColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_Lsafeside, m_btnLsafeSColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_Rsafeside, m_btnRsafeSColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_Fradarslow, m_btnFradarSColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_Fradarstop, m_btnFradarTColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_Bradarslow, m_btnBradarSColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_Bradarstop, m_btnBradarTColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_AGVEstop, m_btnAGVEstopColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_Shiedradar, m_btnShieldRColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_Shieldsafedside, m_btnShieldSSColor); | ||||
|  | ||||
| 	DDX_Control(pDX, IDC_BTN_LrollerFsensor, m_btnLrollerFsenColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_LrollerMsensor, m_btnLrollerMsenColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_LrollerBsensor, m_btnLrollerBsenColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_RrollerFsensor, m_btnRrollerFsenColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_RrollerMsensor, m_btnRrollerMsenColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_RrollerBsensor, m_btnRrollerBsenColor); | ||||
|  | ||||
| 	DDX_Control(pDX, IDC_BTN_FDloadSte, m_btnFDloadSteColor); | ||||
| 	DDX_Control(pDX, IDC_BTN_BDloadSte, m_btnBDloadSteColor); | ||||
| 	 | ||||
| 	DDX_Control(pDX, IDC_BTN_OpenBarrierGate, m_btnOpenBarrierGate); | ||||
| 	DDX_Control(pDX, IDC_BTN_CloseBarrierGate, m_btnCloseBarrierGate); | ||||
| 	DDX_Control(pDX, IDC_BTN_OpenShopRollDoor, m_btnOpenShopRollDoor);  | ||||
|  | ||||
| 	DDX_Control(pDX, IDC_EDIT_RemoteControl, m_txRemoteControl); | ||||
| } | ||||
|  | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CPlcMainDlg, CDialogEx) | ||||
| 	ON_BN_CLICKED(IDC_BTN_SET, &CPlcMainDlg::OnBnClickedBtnSet) | ||||
| 	ON_BN_CLICKED(IDC_BTN_OPEN_FDOOR, &CPlcMainDlg::OnBnClickedBtnOpenFdoor) | ||||
| 	ON_BN_CLICKED(IDC_BTN_CLOSE_FDOOR, &CPlcMainDlg::OnBnClickedBtnCloseFdoor) | ||||
| 	ON_BN_CLICKED(IDC_BTN_OPEN_BDOOR, &CPlcMainDlg::OnBnClickedBtnOpenBdoor) | ||||
| 	ON_BN_CLICKED(IDC_BTN_CLOSE_BDOOR, &CPlcMainDlg::OnBnClickedBtnCloseBdoor) | ||||
| 	ON_MESSAGE(WM_NETMESSAGE, OnNetMsg) | ||||
| 	ON_WM_TIMER() | ||||
| 	ON_BN_CLICKED(IDC_BTN_Lroller_F, &CPlcMainDlg::OnBnClickedBtnLrollerF) | ||||
| 	ON_BN_CLICKED(IDC_BTN_Lroller_B, &CPlcMainDlg::OnBnClickedBtnLrollerB) | ||||
| 	ON_BN_CLICKED(IDC_BTN_Lroller_Stop, &CPlcMainDlg::OnBnClickedBtnLrollerStop) | ||||
| 	ON_BN_CLICKED(IDC_BTN_Rroller_F, &CPlcMainDlg::OnBnClickedBtnRrollerF) | ||||
| 	ON_BN_CLICKED(IDC_BTN_Rroller_B, &CPlcMainDlg::OnBnClickedBtnRrollerB) | ||||
| 	ON_BN_CLICKED(IDC_BTN_Rroller_Stop, &CPlcMainDlg::OnBnClickedBtnRrollerStop) | ||||
| 	ON_BN_CLICKED(IDC_BTN_IndoorLsta, &CPlcMainDlg::OnBnClickedBtnIndoorlsta) | ||||
| 	ON_BN_CLICKED(IDC_BTN_IndoorRsta, &CPlcMainDlg::OnBnClickedBtnIndoorrsta) | ||||
| 	ON_BN_CLICKED(IDC_BTN_OutdoorLsta, &CPlcMainDlg::OnBnClickedBtnOutdoorlsta) | ||||
| 	ON_BN_CLICKED(IDC_BTN_OutdoorRsta, &CPlcMainDlg::OnBnClickedBtnOutdoorrsta) | ||||
| 	ON_BN_CLICKED(IDC_BTN_IndoorStop, &CPlcMainDlg::OnBnClickedBtnIndoorstop) | ||||
| 	ON_BN_CLICKED(IDC_BTN_OutdoorStop, &CPlcMainDlg::OnBnClickedBtnOutdoorstop) | ||||
| 	ON_BN_CLICKED(IDC_BTN_Shiedradar, &CPlcMainDlg::OnBnClickedBtnShiedradar) | ||||
| 	ON_BN_CLICKED(IDC_BTN_Shieldsafedside, &CPlcMainDlg::OnBnClickedBtnShieldsafedside) | ||||
|  | ||||
| 	ON_BN_CLICKED(IDC_BTN_OpenBarrierGate, &CPlcMainDlg::OnBnClickedBtnOpenbarriergate) | ||||
| 	ON_BN_CLICKED(IDC_BTN_CloseBarrierGate, &CPlcMainDlg::OnBnClickedBtnClosebarriergate) | ||||
| 	ON_BN_CLICKED(IDC_BTN_OpenShopRollDoor, &CPlcMainDlg::OnBnClickedBtnOpenshoprolldoor) | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
|  | ||||
| // CPlcDeviceDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
| BOOL CPlcMainDlg::OnInitDialog() | ||||
| { | ||||
| 	CDialogEx::OnInitDialog(); | ||||
|  | ||||
| 	//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD> | ||||
| 	ReadConfigFromIni(); | ||||
| 	 | ||||
| 	//<2F><><EFBFBD><EFBFBD>PLC | ||||
| 	ConnectPlcController(); | ||||
|  | ||||
| 	MfcButtonInit(); | ||||
|  | ||||
| 	SetTimer(TIMER_UPDATE_TOPLC, 100, NULL); | ||||
| 	SetTimer(TIMER_UPDATE_TODLG, 200, NULL); | ||||
|  | ||||
| 	return TRUE;  // return TRUE unless you set the focus to a control | ||||
| 				  // <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE | ||||
| } | ||||
|  | ||||
| void  CPlcMainDlg::MfcButtonInit() | ||||
| { | ||||
| 	m_btnOpFdColor.m_bTransparent = FALSE;     //<2F><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ɫ | ||||
| 	m_btnOpFdColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnCoFdColor.m_bTransparent = FALSE; | ||||
| 	m_btnCoFdColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnOpBdColor.m_bTransparent = FALSE; | ||||
| 	m_btnOpBdColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnCoBdColor.m_bTransparent = FALSE; | ||||
| 	m_btnCoBdColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnInDLRColor.m_bTransparent = FALSE; | ||||
| 	m_btnInDLRColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnInDRRColor.m_bTransparent = FALSE; | ||||
| 	m_btnInDRRColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnOutDLRColor.m_bTransparent = FALSE; | ||||
| 	m_btnOutDLRColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnOutDRRColor.m_bTransparent = FALSE; | ||||
| 	m_btnOutDRRColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnFsafeSColor.m_bTransparent = FALSE; | ||||
| 	m_btnFsafeSColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnBsafeSColor.m_bTransparent = FALSE; | ||||
| 	m_btnBsafeSColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnLsafeSColor.m_bTransparent = FALSE; | ||||
| 	m_btnLsafeSColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnRsafeSColor.m_bTransparent = FALSE; | ||||
| 	m_btnRsafeSColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnFradarSColor.m_bTransparent = FALSE; | ||||
| 	m_btnFradarSColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnFradarTColor.m_bTransparent = FALSE; | ||||
| 	m_btnFradarTColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnBradarSColor.m_bTransparent = FALSE; | ||||
| 	m_btnBradarSColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnBradarTColor.m_bTransparent = FALSE; | ||||
| 	m_btnBradarTColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnAGVEstopColor.m_bTransparent = FALSE; | ||||
| 	m_btnAGVEstopColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnShieldRColor.m_bTransparent = FALSE; | ||||
| 	m_btnShieldRColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnShieldSSColor.m_bTransparent = FALSE; | ||||
| 	m_btnShieldSSColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnLrollerFsenColor.m_bTransparent = FALSE; | ||||
| 	m_btnLrollerFsenColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnLrollerMsenColor.m_bTransparent = FALSE; | ||||
| 	m_btnLrollerMsenColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnLrollerBsenColor.m_bTransparent = FALSE; | ||||
| 	m_btnLrollerBsenColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnRrollerFsenColor.m_bTransparent = FALSE; | ||||
| 	m_btnRrollerFsenColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnRrollerMsenColor.m_bTransparent = FALSE; | ||||
| 	m_btnRrollerMsenColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnRrollerBsenColor.m_bTransparent = FALSE; | ||||
| 	m_btnRrollerBsenColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnFDloadSteColor.m_bTransparent = FALSE; | ||||
| 	m_btnFDloadSteColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnBDloadSteColor.m_bTransparent = FALSE; | ||||
| 	m_btnBDloadSteColor.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnOpenBarrierGate.m_bTransparent = FALSE; | ||||
| 	m_btnOpenBarrierGate.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnCloseBarrierGate.m_bTransparent = FALSE; | ||||
| 	m_btnCloseBarrierGate.m_bDontUseWinXPTheme = TRUE; | ||||
| 	m_btnOpenShopRollDoor.m_bTransparent = FALSE; | ||||
| 	m_btnOpenShopRollDoor.m_bDontUseWinXPTheme = TRUE; | ||||
| } | ||||
|  | ||||
| LRESULT CPlcMainDlg::OnNetMsg(WPARAM wparam, LPARAM lparam) | ||||
| { | ||||
| 	switch (wparam) | ||||
| 	{ | ||||
| 	case NET_CONNECT_OK: | ||||
| 	{ | ||||
| 		LogOutToFile("[info] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"); | ||||
| 		//m_pMainWnd->InsertLog(LOG_INFO, "The PLC Device Connect!"); | ||||
| 		KillTimer(TIMER_RECONNECT_PLC); | ||||
| 		SetTimer(TIMER_UPDATE_TOPLC, 100, NULL); | ||||
| 		m_bConnectServer = TRUE; | ||||
| 		//m_pMainWnd->UpdatePlcDeviceStatue(m_bConnectServer); | ||||
| 		break; | ||||
| 	} | ||||
| 	 | ||||
| 	case NET_DISCONNECT: | ||||
| 	{ | ||||
| 		//::PostMessage(m_pMainWnd->m_hWnd, WM_NETMESSAGE, PLC_DISCONNECT, NULL); | ||||
| 		//m_pThrdModbus->ExitInstance(); | ||||
| 		KillTimer(TIMER_UPDATE_TOPLC); | ||||
| 		SetTimer(TIMER_RECONNECT_PLC, 1000, NULL); | ||||
| 		m_bConnectServer = FALSE; | ||||
| 		//m_pMainWnd->UpdatePlcDeviceStatue(m_bConnectServer); | ||||
| 		//delete m_pThrdModbus; | ||||
| 		/*m_pThrdModbus->PostThreadMessage(WM_QUIT, 0, 0); | ||||
| 		m_pThrdModbus = NULL; | ||||
| 		ConnectPlcController();*/ | ||||
| 		break; | ||||
| 	} | ||||
| 	 | ||||
| 	case NET_DATA_MSG: | ||||
| 	{ | ||||
| 		NET_PACKET* pNetPacket = (NET_PACKET*)lparam; | ||||
|  | ||||
| 		delete[] pNetPacket->pData; | ||||
| 		delete pNetPacket; | ||||
| 		break; | ||||
| 	} | ||||
| 	 | ||||
| 	default: | ||||
| 		break; | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::ReadConfigFromIni() | ||||
| { | ||||
| 	CString strIniPath = theApp.m_strModulePath + "\\config.ini"; | ||||
| 	// <20><>ʼ<EFBFBD><CABC><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD> | ||||
|  | ||||
| 	char acValue[32] = ""; | ||||
| 	GetPrivateProfileString("PLC", "IP", "", acValue, 32, strIniPath); | ||||
| 	m_strIpAddr = acValue; | ||||
| 	DWORD  dwIP = inet_addr(acValue); | ||||
| 	unsigned  char   *pIP = (unsigned   char*)&dwIP; | ||||
| 	m_ipAddrCtrl.SetAddress(*pIP, *(pIP + 1), *(pIP + 2), *(pIP + 3)); | ||||
|  | ||||
|  | ||||
|  | ||||
| 	m_nPort     = GetPrivateProfileInt("PLC", "PORT", 0, strIniPath); | ||||
| 	CString strPort; | ||||
| 	strPort.Format("%d", m_nPort); | ||||
| 	GetDlgItem(IDC_EDIT_PORT)->SetWindowText(strPort); | ||||
| 	 | ||||
|  | ||||
| 	return;  // return TRUE unless you set the focus to a control | ||||
| 			 // <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnSet() | ||||
| { | ||||
| 	CString strIniPath = theApp.m_strModulePath + "\\config.ini"; | ||||
| 	BYTE nFild[4]; | ||||
| 	m_ipAddrCtrl.GetAddress(nFild[0], nFild[1], nFild[2], nFild[3]); | ||||
| 	CString strIpAddr; | ||||
| 	strIpAddr.Format("%d.%d.%d.%d", nFild[0], nFild[1], nFild[2], nFild[3]); | ||||
| 	WritePrivateProfileString("PLC", "IP", strIpAddr, strIniPath); | ||||
|  | ||||
| 	CString strPort; | ||||
| 	GetDlgItem(IDC_EDIT_PORT)->GetWindowText(strPort); | ||||
| 	WritePrivateProfileString("PLC", "PORT", strPort, strIniPath); | ||||
|  | ||||
| 	MessageBox("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѹ<EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD>."); | ||||
|  | ||||
|  | ||||
| } | ||||
|  | ||||
| BOOL CPlcMainDlg::ConnectPlcController() | ||||
| { | ||||
| 	m_pModbusClient = new CModbusClient(m_strIpAddr, m_nPort, this->m_hWnd); | ||||
| 	return m_pModbusClient->CreateThread(); | ||||
| } | ||||
|  | ||||
|  | ||||
| void  CPlcMainDlg::OpenFdoor() | ||||
| { | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.OpFdoor = TRUE; | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.CoFdoor = false; | ||||
| } | ||||
|  | ||||
| void  CPlcMainDlg::CloseFdoor() | ||||
| { | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.CoFdoor = TRUE; | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.OpFdoor = false; | ||||
| } | ||||
|  | ||||
| void  CPlcMainDlg::OpenBdoor() | ||||
| { | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.OpBdoor = TRUE; | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.CoBdoor = false; | ||||
| } | ||||
|  | ||||
| void  CPlcMainDlg::CloseBdoor() | ||||
| { | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.CoBdoor = TRUE; | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.OpBdoor = false; | ||||
| } | ||||
|  | ||||
| bool m = true; | ||||
| void CPlcMainDlg::OnBnClickedBtnOpenFdoor() | ||||
| { | ||||
| 	OpenFdoor(); | ||||
| 	//int nResult = MessageBox("<22><>ȷ<EFBFBD><C8B7><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>þ<EFBFBD><C3BE><EFBFBD><EFBFBD><EFBFBD>", "<22><>ʾ", MB_OKCANCEL | MB_ICONQUESTION); | ||||
| 	//if (nResult == IDOK) | ||||
| 	//{ | ||||
| 	//	OpenFdoor(); | ||||
| 	//} | ||||
| 	//else if (nResult == IDCANCEL) | ||||
| 	//{ | ||||
| 	//	// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"ȡ<><C8A1>" | ||||
| 	//} | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnCloseFdoor() | ||||
| { | ||||
| 	CloseFdoor(); | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnOpenBdoor() | ||||
| { | ||||
| 	OpenBdoor(); | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnCloseBdoor() | ||||
| { | ||||
| 	CloseBdoor(); | ||||
| } | ||||
|  | ||||
| void CPlcMainDlg::DisplayDLG() | ||||
| { | ||||
| 	if (m_stPLCTOAGVDATA.AGVstate_u.bits.FdoorOpen_ste) | ||||
| 		m_btnOpFdColor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnOpFdColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.AGVstate_u.bits.FdoorClose_ste) | ||||
| 		m_btnCoFdColor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnCoFdColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.AGVstate_u.bits.BdoorOpen_ste) | ||||
| 		m_btnOpBdColor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnOpBdColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.AGVstate_u.bits.BdoorClose_ste) | ||||
| 		m_btnCoBdColor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnCoBdColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	//װж<D7B0><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ | ||||
| 	if (m_stPLCTOAGVDATA.RollerState_u.bits.IndoorLRoller_ste) | ||||
| 		m_btnInDLRColor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnInDLRColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.RollerState_u.bits.IndoorRRoller_ste) | ||||
| 		m_btnInDRRColor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnInDRRColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.RollerState_u.bits.OutdoorLRoller_ste) | ||||
| 		m_btnOutDLRColor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnOutDLRColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.RollerState_u.bits.OutdoorRRoller_ste) | ||||
| 		m_btnOutDRRColor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnOutDRRColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.SafeState_u.bits.Fsafeside) | ||||
| 		m_btnFsafeSColor.SetFaceColor(RGB(255, 0, 0), true); | ||||
| 	else | ||||
| 		m_btnFsafeSColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.SafeState_u.bits.Bsafeside) | ||||
| 		m_btnBsafeSColor.SetFaceColor(RGB(255, 0, 0), true); | ||||
| 	else | ||||
| 		m_btnBsafeSColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.SafeState_u.bits.Lsafeside) | ||||
| 		m_btnLsafeSColor.SetFaceColor(RGB(255, 0, 0), true); | ||||
| 	else | ||||
| 		m_btnLsafeSColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.SafeState_u.bits.Rsafeside) | ||||
| 		m_btnRsafeSColor.SetFaceColor(RGB(255, 0, 0), true); | ||||
| 	else | ||||
| 		m_btnRsafeSColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.SafeState_u.bits.Fradarslow) | ||||
| 		m_btnFradarSColor.SetFaceColor(RGB(255, 133, 133), true); | ||||
| 	else | ||||
| 		m_btnFradarSColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.SafeState_u.bits.Fradarstop) | ||||
| 		m_btnFradarTColor.SetFaceColor(RGB(255, 0, 0), true); | ||||
| 	else | ||||
| 		m_btnFradarTColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.SafeState_u.bits.Bradarslow) | ||||
| 		m_btnBradarSColor.SetFaceColor(RGB(255, 133, 133), true); | ||||
| 	else | ||||
| 		m_btnBradarSColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.SafeState_u.bits.Bradarstop) | ||||
| 		m_btnBradarTColor.SetFaceColor(RGB(255, 0, 0), true); | ||||
| 	else | ||||
| 		m_btnBradarTColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.SafeState_u.bits.AGVEstop) | ||||
| 		m_btnAGVEstopColor.SetFaceColor(RGB(255, 0, 0), true); | ||||
| 	else | ||||
| 		m_btnAGVEstopColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.SafeState_u.bits.RadarShield) | ||||
| 		m_btnShieldRColor.SetFaceColor(RGB(255, 0, 0), true); | ||||
| 	else | ||||
| 		m_btnShieldRColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.SafeState_u.bits.SafeSideShield) | ||||
| 		m_btnShieldSSColor.SetFaceColor(RGB(255, 0, 0), true); | ||||
| 	else | ||||
| 		m_btnShieldSSColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.AGVstate_u.bits.LFsensor_ste) | ||||
| 		m_btnLrollerFsenColor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnLrollerFsenColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.AGVstate_u.bits.LMsensor_ste) | ||||
| 		m_btnLrollerMsenColor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnLrollerMsenColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.AGVstate_u.bits.LBsensor_ste) | ||||
| 		m_btnLrollerBsenColor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnLrollerBsenColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.AGVstate_u.bits.RFsensor_ste) | ||||
| 		m_btnRrollerFsenColor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnRrollerFsenColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.AGVstate_u.bits.RMsensor_ste) | ||||
| 		m_btnRrollerMsenColor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnRrollerMsenColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.AGVstate_u.bits.RBsensor_ste) | ||||
| 		m_btnRrollerBsenColor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnRrollerBsenColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.AGVstate_u.bits.Fdoorsenor_ste) | ||||
| 		m_btnFDloadSteColor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnFDloadSteColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.AGVstate_u.bits.Bdoorsenor_ste) | ||||
| 		m_btnBDloadSteColor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnBDloadSteColor.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if(m_stPLCTOAGVDATA.RollerState_u.bits.BarrierGateIsOpen) | ||||
| 		m_btnOpenBarrierGate.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else  | ||||
| 		m_btnOpenBarrierGate.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.RollerState_u.bits.BarrierGateIsClose) | ||||
| 		m_btnCloseBarrierGate.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnCloseBarrierGate.SetFaceColor(RGB(255, 255, 255), true); | ||||
|  | ||||
| 	if (m_stPLCTOAGVDATA.RollerState_u.bits.ShopRollerdoorIsOpen) | ||||
| 		m_btnOpenShopRollDoor.SetFaceColor(RGB(135, 206, 235), true); | ||||
| 	else | ||||
| 		m_btnOpenShopRollDoor.SetFaceColor(RGB(255, 255, 255), true); | ||||
| 	 | ||||
| 	CString nEdit; | ||||
| 	nEdit.Format(_T("0x%04x"), m_stPLCTOAGVDATA.RemoteControl_u.data);  // %x-16<31><36><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ; %d-10<31><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ | ||||
| 	m_txRemoteControl.SetWindowText(nEdit); | ||||
| /* | ||||
| 	if (m_stPLCTOAGVDATA.RemoteControl_u.bits.RemoteControl || m_pMainWnd->m_nAgvMode == DEBUG_MODE)  //<2F><><EFBFBD><EFBFBD>ң<EFBFBD><D2A3><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>ģʽ <20><><EFBFBD><EFBFBD> DEBUDģʽ<C4A3><CABD><EFBFBD><EFBFBD>PLC<4C><43><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>ſ<EFBFBD><C5BF><EFBFBD> | ||||
| 	{ | ||||
| 		m_stAGVTOPLCDATA.RunStaControl_u.bits.AUTOHandSwitch = 1; | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_OPEN_FDOOR))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_OPEN_BDOOR))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_CLOSE_FDOOR))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_CLOSE_BDOOR))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_Lroller_F))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_Lroller_B))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_Rroller_F))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_Rroller_B))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_Lroller_Stop))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_Rroller_Stop))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_IndoorLsta))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_IndoorRsta))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_IndoorStop))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_OutdoorLsta))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_OutdoorRsta))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_OutdoorStop))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_OpenBarrierGate))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_CloseBarrierGate))->EnableWindow(true); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_OpenShopRollDoor))->EnableWindow(true); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		m_stAGVTOPLCDATA.RunStaControl_u.bits.AUTOHandSwitch = 0; | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_OPEN_FDOOR))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_OPEN_BDOOR))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_CLOSE_FDOOR))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_CLOSE_BDOOR))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_Lroller_F))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_Lroller_B))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_Rroller_F))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_Rroller_B))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_Lroller_Stop))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_Rroller_Stop))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_IndoorLsta))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_IndoorRsta))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_IndoorStop))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_OutdoorLsta))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_OutdoorRsta))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_OutdoorStop))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_OpenBarrierGate))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_CloseBarrierGate))->EnableWindow(false); | ||||
| 		((CButton *)GetDlgItem(IDC_BTN_OpenShopRollDoor))->EnableWindow(false); | ||||
| 	}*/ | ||||
| } | ||||
|  | ||||
| void CPlcMainDlg::OnTimer(UINT_PTR nIDEvent) | ||||
| { | ||||
| 	int nRet = 0; | ||||
| 	//<2F><><EFBFBD><EFBFBD><EFBFBD>豸״̬ | ||||
| 	switch (nIDEvent) | ||||
| 	{ | ||||
| 		case TIMER_UPDATE_TOPLC: | ||||
| 			if (m_stPLCTOAGVDATA.SafeState_u.bits.AGVEstop)  //<2F><>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD> | ||||
| 			{ | ||||
| 				m_stAGVTOPLCDATA.AGVControl_u.data = 0;      //<2F><><EFBFBD>ع<EFBFBD>Ͳֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD>ر<EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ | ||||
| 			} | ||||
| 			nRet = m_pModbusClient->WriteMultipleRegisters(40001, 4, (short *)&(m_stAGVTOPLCDATA)); | ||||
| 			if (nRet > 0) | ||||
| 			{ | ||||
| 				m_stAGVTOPLCDATA.AGVControl_u.bits.OpFdoor = false;            //<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD> | ||||
| 				m_stAGVTOPLCDATA.AGVControl_u.bits.CoFdoor = false; | ||||
| 				m_stAGVTOPLCDATA.AGVControl_u.bits.OpBdoor = false; | ||||
| 				m_stAGVTOPLCDATA.AGVControl_u.bits.CoBdoor = false; | ||||
| 				m_stAGVTOPLCDATA.PLCControl_u.bits.OpenBarrierGate    = false; | ||||
| 				m_stAGVTOPLCDATA.PLCControl_u.bits.CloseBarrierGate   = false; | ||||
| 				m_stAGVTOPLCDATA.PLCControl_u.bits.OpenShopRollerDoor = false; | ||||
| 			} | ||||
| 			nRet = m_pModbusClient->ReadMultipleRegisters(40051, 5, (short *)&(m_stPLCTOAGVDATA)); | ||||
| 			if(nRet > 0) | ||||
| 			{ | ||||
|  | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 		case TIMER_UPDATE_TODLG: | ||||
| 			DisplayDLG(); | ||||
| 			break; | ||||
| 		case TIMER_RECONNECT_PLC: | ||||
| 			m_pModbusClient->PostThreadMessage(WM_QUIT, 0, 0); | ||||
| 			m_pModbusClient = NULL; | ||||
| 			ConnectPlcController(); | ||||
| 			break; | ||||
| 	 | ||||
| 		default: | ||||
| 			TRACE("<EFBFBD><EFBFBD>Ч\n"); | ||||
| 				 | ||||
| 	} | ||||
| 	CDialogEx::OnTimer(nIDEvent); | ||||
| } | ||||
|  | ||||
| //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ | ||||
| void CPlcMainDlg::OnBnClickedBtnLrollerF() | ||||
| { | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.LRollerF = TRUE; | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.LRollerB = false; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnLrollerB() | ||||
| { | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.LRollerB = TRUE; | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.LRollerF = false; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnLrollerStop() | ||||
| { | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.LRollerB = false; | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.LRollerF = false; | ||||
| } | ||||
|  | ||||
|  | ||||
| //<2F>Ҳ<EFBFBD><D2B2><EFBFBD>Ͳ | ||||
| void CPlcMainDlg::OnBnClickedBtnRrollerF() | ||||
| { | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.RRollerF = TRUE; | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.RRollerB = false; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnRrollerB() | ||||
| { | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.RRollerB = TRUE; | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.RRollerF = false; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnRrollerStop() | ||||
| { | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.RRollerB = false; | ||||
| 	m_stAGVTOPLCDATA.AGVControl_u.bits.RRollerF = false; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnIndoorlsta() | ||||
| { | ||||
| 	m_stAGVTOPLCDATA.PLCControl_u.bits.IndoorLRoller = TRUE; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnIndoorrsta() | ||||
| { | ||||
| 	m_stAGVTOPLCDATA.PLCControl_u.bits.IndoorRRoller = TRUE; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnOutdoorlsta() | ||||
| { | ||||
| 	m_stAGVTOPLCDATA.PLCControl_u.bits.OutdoorLRoller = TRUE; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnOutdoorrsta() | ||||
| { | ||||
| 	m_stAGVTOPLCDATA.PLCControl_u.bits.OutdoorRRoller = TRUE; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnIndoorstop() | ||||
| { | ||||
| 	m_stAGVTOPLCDATA.PLCControl_u.bits.IndoorLRoller = false; | ||||
| 	m_stAGVTOPLCDATA.PLCControl_u.bits.IndoorRRoller = false; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnOutdoorstop() | ||||
| { | ||||
| 	m_stAGVTOPLCDATA.PLCControl_u.bits.OutdoorLRoller = false; | ||||
| 	m_stAGVTOPLCDATA.PLCControl_u.bits.OutdoorRRoller = false; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnOpenbarriergate() | ||||
| { | ||||
| 	// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	m_stAGVTOPLCDATA.PLCControl_u.bits.OpenBarrierGate = true; | ||||
| 	m_stAGVTOPLCDATA.PLCControl_u.bits.CloseBarrierGate = false; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnClosebarriergate() | ||||
| { | ||||
| 	// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	m_stAGVTOPLCDATA.PLCControl_u.bits.OpenBarrierGate = false; | ||||
| 	m_stAGVTOPLCDATA.PLCControl_u.bits.CloseBarrierGate = true; | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnShiedradar()  //<2F><><EFBFBD><EFBFBD><EFBFBD>״<EFBFBD> | ||||
| { | ||||
| 	// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnShieldsafedside()  //<2F><><EFBFBD>δ<EFBFBD><CEB4><EFBFBD> | ||||
| { | ||||
| 	// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlcMainDlg::OnBnClickedBtnOpenshoprolldoor() | ||||
| { | ||||
| 	// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	m_stAGVTOPLCDATA.PLCControl_u.bits.OpenShopRollerDoor = true; | ||||
| } | ||||
							
								
								
									
										282
									
								
								Plugin/Plc/PlcMainDlg.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										282
									
								
								Plugin/Plc/PlcMainDlg.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,282 @@ | ||||
| #pragma once | ||||
| #include "afxcmn.h" | ||||
| #include "CommDataDef.h" | ||||
|  | ||||
| // CPlcDeviceDlg <20>Ի<EFBFBD><D4BB><EFBFBD> | ||||
| class CModbusClient; | ||||
| class CPluginMainDialog; | ||||
|  | ||||
| typedef struct AGV_PLC_data { | ||||
| 	union AGVIntWithBools { | ||||
| 		short data; | ||||
| 		struct { | ||||
| 			bool Brake : 1;   //ɲ<><C9B2> | ||||
| 			bool Charge : 1;  //<2F><><EFBFBD><EFBFBD> | ||||
| 			bool Reserve1 : 1; | ||||
| 			bool Reserve2 : 1; | ||||
| 			bool OpFdoor : 1; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 			bool CoFdoor : 1; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 			bool OpBdoor : 1; | ||||
| 			bool CoBdoor : 1; | ||||
| 			bool LRollerF : 1; | ||||
| 			bool LRollerB : 1; | ||||
| 			bool RRollerF : 1; | ||||
| 			bool RRollerB : 1; | ||||
| 		} bits; | ||||
| 	}AGVControl_u; | ||||
|  | ||||
| 	union PLCIntWithBools { | ||||
| 		short data; | ||||
| 		struct { | ||||
| 			bool IndoorLRoller : 1;   //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD> | ||||
| 			bool IndoorRRoller : 1;   //<2F><><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD> | ||||
| 			bool OutdoorLRoller : 1;  //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD> | ||||
| 			bool OutdoorRRoller : 1;  //<2F><><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD> | ||||
| 			bool Reserve1 : 1; | ||||
| 			bool Reserve2 : 1; | ||||
| 			bool Reserve3 : 1; | ||||
| 			bool Reserve4 : 1; | ||||
| 			bool OpenBarrierGate : 1;  //<2F><><EFBFBD><EFBFBD>բ | ||||
| 			bool CloseBarrierGate : 1; //<2F>ص<EFBFBD>բ | ||||
| 			bool OpenShopRollerDoor : 1;//<2F><><EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 		} bits; | ||||
| 	}PLCControl_u; | ||||
| 	union RunStaIntWithBools { | ||||
| 		short data; | ||||
| 		struct { | ||||
| 			bool Standby_mode : 1; | ||||
| 			bool GotoLoading : 1; | ||||
| 			bool GotoUnloading : 1; | ||||
| 			bool S_stop : 1; | ||||
| 			bool Reqloading : 1; | ||||
| 			bool ReqUnloading : 1; | ||||
| 			bool AUTOHandSwitch : 1;   //<2F><><EFBFBD>Զ<EFBFBD><D4B6>л<EFBFBD> 1<>ֶ<EFBFBD>  0<>Զ<EFBFBD> | ||||
| 			bool AGVpipelineReset : 1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߸<EFBFBD>λ | ||||
| 			bool Force_Import : 1; | ||||
| 			bool Reserve2 : 1; | ||||
| 			bool Reserve3 : 1; | ||||
| 			bool Reserve4 : 1; | ||||
| 			bool Reserve5 : 1; | ||||
| 			bool Reserve6 : 1; | ||||
| 			bool Reserve7 : 1; | ||||
| 			bool Reserve8 : 1; | ||||
|  | ||||
| 		} bits; | ||||
| 	}RunStaControl_u; | ||||
|  | ||||
| 	int HeartBeat; | ||||
|  | ||||
| 	AGV_PLC_data() | ||||
| 	{ | ||||
| 		AGVControl_u.data = 0; | ||||
| 		PLCControl_u.data = 0; | ||||
| 		RunStaControl_u.data = 0; | ||||
| 		HeartBeat = 1; | ||||
| 	} | ||||
| }ST_AGVTOPLCDATA; | ||||
|  | ||||
|  | ||||
| typedef struct PLC_AGV_data { | ||||
| 	union AGVIntWithBools { | ||||
| 		short data; | ||||
| 		struct { | ||||
| 			bool Reserve1 : 1; | ||||
| 			bool Reserve2 : 1; | ||||
| 			bool Reserve3 : 1; | ||||
| 			bool Reserve4 : 1; | ||||
| 			bool FdoorOpen_ste : 1; | ||||
| 			bool FdoorClose_ste : 1; | ||||
| 			bool BdoorOpen_ste : 1; | ||||
| 			bool BdoorClose_ste : 1; | ||||
| 			bool LFsensor_ste : 1; | ||||
| 			bool LMsensor_ste : 1; | ||||
| 			bool LBsensor_ste : 1; | ||||
| 			bool Fdoorsenor_ste : 1; | ||||
| 			bool RFsensor_ste : 1; | ||||
| 			bool RMsensor_ste : 1; | ||||
| 			bool RBsensor_ste : 1; | ||||
| 			bool Bdoorsenor_ste : 1; | ||||
| 		} bits; | ||||
| 	}AGVstate_u; | ||||
|  | ||||
| 	union RollerIntWithBools { | ||||
| 		short data; | ||||
| 		struct { | ||||
| 			bool IndoorLRoller_ste : 1; | ||||
| 			bool IndoorRRoller_ste : 1; | ||||
| 			bool OutdoorLRoller_ste : 1; | ||||
| 			bool OutdoorRRoller_ste : 1; | ||||
| 			bool OutdoorAGV_Estop : 1; | ||||
| 			bool IndoorAGV_Estop : 1; | ||||
| 			bool Reserve1 : 1; | ||||
| 			bool Reserve2 : 1; | ||||
| 			bool BarrierGateIsOpen  : 1;  //<2F><>բ<EFBFBD><D5A2><EFBFBD><EFBFBD>λ | ||||
| 			bool BarrierGateIsClose : 1;  //<2F><>բ<EFBFBD>ص<EFBFBD>λ | ||||
| 			bool ShopRollerdoorIsOpen : 1;//<2F>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ſ<EFBFBD><C5BF><EFBFBD>λ | ||||
| 		} bits; | ||||
| 	}RollerState_u; | ||||
|  | ||||
| 	union StateIntWithBools { | ||||
| 		short data; | ||||
| 		struct { | ||||
| 			bool Fsafeside : 1; | ||||
| 			bool Bsafeside : 1; | ||||
| 			bool Lsafeside : 1; | ||||
| 			bool Rsafeside : 1; | ||||
| 			bool Fradarslow : 1; | ||||
| 			bool Fradarstop : 1; | ||||
| 			bool Bradarslow : 1; | ||||
| 			bool Bradarstop : 1; | ||||
| 			bool AGVEstop : 1; | ||||
| 			bool RadarShield : 1;    //<2F>״<EFBFBD><D7B4><EFBFBD><EFBFBD><EFBFBD> | ||||
| 			bool SafeSideShield : 1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 			bool Soaking	  : 1;   //<2F><>ˮ<EFBFBD><CBAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 		} bits; | ||||
| 	}SafeState_u; | ||||
|  | ||||
| 	union RemoteCIntWithBools { | ||||
| 		short data; | ||||
| 		struct { | ||||
| 			bool RemoteControl : 1; | ||||
| 			bool Forward : 1; | ||||
| 			bool Backward : 1; | ||||
| 			bool LeftRotation : 1; | ||||
| 			bool RightRotation : 1; | ||||
| 			bool ZeroHold : 1; | ||||
| 			bool Reserve : 1; | ||||
|  | ||||
| 		} bits; | ||||
| 	}RemoteControl_u; | ||||
|  | ||||
| 	union LoadStaIntWithBools { | ||||
| 		short data; | ||||
| 		struct { | ||||
| 			bool Loading : 1; | ||||
| 			bool LoadFinish : 1; | ||||
| 			bool Unloading : 1; | ||||
| 			bool UnloadFinish : 1; | ||||
| 			bool LoadingErr : 1; | ||||
| 			bool UnloadingErr : 1; | ||||
| 		} bits; | ||||
| 	}LoadState_u; | ||||
|  | ||||
| 	PLC_AGV_data() | ||||
| 	{ | ||||
| 		AGVstate_u.data = 0; | ||||
| 		RollerState_u.data = 0; | ||||
| 		SafeState_u.data = 0; | ||||
| 		RemoteControl_u.data = 0; | ||||
| 		LoadState_u.data = 0; | ||||
| 	} | ||||
|  | ||||
| }ST_PLCTOAGVDATA; | ||||
|  | ||||
| class CPlcMainDlg : public CDialogEx | ||||
| { | ||||
| 	DECLARE_DYNAMIC(CPlcMainDlg) | ||||
|  | ||||
| public: | ||||
| 	CPlcMainDlg(CWnd* pParent = NULL);   // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF> | ||||
| 	virtual ~CPlcMainDlg(); | ||||
|  | ||||
| // <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| #ifdef AFX_DESIGN_TIME | ||||
| 	enum { IDD = IDD_DEV_PLC_DLG }; | ||||
| #endif | ||||
|  | ||||
| protected: | ||||
| 	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV ֧<><D6A7> | ||||
|  | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
| public: | ||||
| 	virtual BOOL OnInitDialog(); | ||||
| 	void    ReadConfigFromIni(); | ||||
| 	BOOL    ConnectPlcController(); | ||||
| 	void    MfcButtonInit(); | ||||
| 	void    OpenFdoor(); | ||||
| 	void    OpenBdoor(); | ||||
| 	void    CloseFdoor(); | ||||
| 	void    CloseBdoor(); | ||||
| 	void    DisplayDLG(); | ||||
|  | ||||
| 	CIPAddressCtrl m_ipAddrCtrl; | ||||
| 	CMFCButton m_btnOpFdColor; | ||||
| 	CMFCButton m_btnCoFdColor; | ||||
| 	CMFCButton m_btnOpBdColor; | ||||
| 	CMFCButton m_btnCoBdColor; | ||||
| 	CMFCButton m_btnInDLRColor; | ||||
| 	CMFCButton m_btnInDRRColor; | ||||
| 	CMFCButton m_btnOutDLRColor; | ||||
| 	CMFCButton m_btnOutDRRColor; | ||||
| 	CMFCButton m_btnFsafeSColor; | ||||
| 	CMFCButton m_btnBsafeSColor; | ||||
| 	CMFCButton m_btnLsafeSColor; | ||||
| 	CMFCButton m_btnRsafeSColor; | ||||
| 	CMFCButton m_btnFradarSColor; | ||||
| 	CMFCButton m_btnFradarTColor; | ||||
| 	CMFCButton m_btnBradarSColor; | ||||
| 	CMFCButton m_btnBradarTColor; | ||||
| 	CMFCButton m_btnAGVEstopColor; | ||||
| 	CMFCButton m_btnShieldRColor; | ||||
| 	CMFCButton m_btnShieldSSColor; | ||||
| 	CMFCButton m_btnLrollerFsenColor; | ||||
| 	CMFCButton m_btnLrollerMsenColor; | ||||
| 	CMFCButton m_btnLrollerBsenColor; | ||||
| 	CMFCButton m_btnRrollerFsenColor; | ||||
| 	CMFCButton m_btnRrollerMsenColor; | ||||
| 	CMFCButton m_btnRrollerBsenColor; | ||||
| 	CMFCButton m_btnFDloadSteColor; | ||||
| 	CMFCButton m_btnBDloadSteColor; | ||||
| 	CMFCButton m_btnOpenBarrierGate; | ||||
| 	CMFCButton m_btnCloseBarrierGate; | ||||
| 	CMFCButton m_btnOpenShopRollDoor; | ||||
|  | ||||
| 	CStatic		   m_txRemoteControl; | ||||
| 	CString        m_strIpAddr; | ||||
| 	int            m_nPort; | ||||
| 	BOOL           m_bConnectServer; | ||||
| 	afx_msg void OnBnClickedBtnSet(); | ||||
| 	afx_msg void OnBnClickedBtnOpenFdoor(); | ||||
| 	afx_msg void OnBnClickedBtnCloseFdoor(); | ||||
| 	afx_msg void OnBnClickedBtnOpenBdoor(); | ||||
| 	afx_msg void OnBnClickedBtnCloseBdoor(); | ||||
| 	afx_msg void OnTimer(UINT_PTR nIDEvent); | ||||
| 	LRESULT OnNetMsg(WPARAM wparam, LPARAM lparam); | ||||
|  | ||||
| public: | ||||
| 	CModbusClient         *m_pModbusClient; | ||||
| 	//CPluginMainDialog   *m_pMainWnd; | ||||
| 	 | ||||
| 	void OnDevReadRspDataFromPlc(BYTE nDevId, ST_MODBUS_SERVER_RSPREAD_FRAME stReadFrame); | ||||
| 	void OnDevWrtRspDataFromPlc(BYTE nDevId,  ST_MODBUS_SERVER_RSPWRT_FRAME stWriteFrame); | ||||
|  | ||||
| 	afx_msg void OnBnClickedBtnRdReg(); | ||||
| 	afx_msg void OnBnClickedBtnWrReg(); | ||||
| 	afx_msg void OnBnClickedMfcbutton1(); | ||||
| 	afx_msg void OnBnClickedBtnLrollerF(); | ||||
| 	afx_msg void OnBnClickedBtnLrollerB(); | ||||
| 	afx_msg void OnBnClickedBtnLrollerStop(); | ||||
| 	afx_msg void OnBnClickedBtnRrollerF(); | ||||
| 	afx_msg void OnBnClickedBtnRrollerB(); | ||||
| 	afx_msg void OnBnClickedBtnRrollerStop(); | ||||
| 	afx_msg void OnBnClickedBtnIndoorlsta(); | ||||
| 	afx_msg void OnBnClickedBtnIndoorrsta(); | ||||
| 	afx_msg void OnBnClickedBtnOutdoorlsta(); | ||||
| 	afx_msg void OnBnClickedBtnOutdoorrsta(); | ||||
| 	afx_msg void OnBnClickedBtnIndoorstop(); | ||||
| 	afx_msg void OnBnClickedBtnOutdoorstop(); | ||||
| 	afx_msg void OnBnClickedBtnShiedradar(); | ||||
| 	afx_msg void OnBnClickedBtnShieldsafedside(); | ||||
|  | ||||
| 	ST_AGVTOPLCDATA m_stAGVTOPLCDATA; | ||||
| 	ST_PLCTOAGVDATA m_stPLCTOAGVDATA; | ||||
|  | ||||
| 	afx_msg void OnBnClickedBtnOpenbarriergate(); | ||||
| 	afx_msg void OnBnClickedBtnClosebarriergate(); | ||||
| 	afx_msg void OnBnClickedBtnOpenshoprolldoor(); | ||||
| }; | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										164
									
								
								Plugin/Plc/PluginPlc.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										164
									
								
								Plugin/Plc/PluginPlc.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,164 @@ | ||||
|  | ||||
| // Vcs-Client.cpp : <20><><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA> | ||||
| // | ||||
|  | ||||
| #include "stdafx.h" | ||||
| #include "PluginPlc.h" | ||||
| #include "PlcMainDlg.h" | ||||
|  | ||||
| #ifdef _DEBUG | ||||
| #define new DEBUG_NEW | ||||
| #endif | ||||
|  | ||||
| CCEXPipeClientBase* g_pstPipeClient = CCEXPipeClientBase::CreateObj(); | ||||
| // CVcsClientApp | ||||
|  | ||||
| BEGIN_MESSAGE_MAP(CPluginPlc, CWinApp) | ||||
| 	ON_COMMAND(ID_HELP, &CWinApp::OnHelp) | ||||
| END_MESSAGE_MAP() | ||||
|  | ||||
|  | ||||
| // CVcsClientApp <20><><EFBFBD><EFBFBD> | ||||
|  | ||||
| CPluginPlc::CPluginPlc() | ||||
| { | ||||
| 	// ֧<><D6A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; | ||||
|  | ||||
| 	// TODO: <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룬 | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> InitInstance <20><> | ||||
| } | ||||
|  | ||||
|  | ||||
| // Ψһ<CEA8><D2BB>һ<EFBFBD><D2BB> CVcsClientApp <20><><EFBFBD><EFBFBD> | ||||
|  | ||||
| CPluginPlc theApp; | ||||
| HANDLE  hmutex; | ||||
|  | ||||
| // CVcsClientApp <20><>ʼ<EFBFBD><CABC> | ||||
|  | ||||
|  | ||||
| BOOL CPluginPlc::InitInstance() | ||||
| { | ||||
| 	 | ||||
| 	hmutex = CreateMutexA(nullptr, FALSE, "agv-plugin-plc"); | ||||
| 	int err = GetLastError(); | ||||
| 	if (err == ERROR_ALREADY_EXISTS) { | ||||
| 		CloseHandle(hmutex); | ||||
| 		hmutex = nullptr; | ||||
| 		//AfxMessageBox("<22><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>."); | ||||
| 		return FALSE; | ||||
| 	} | ||||
|  | ||||
| 	CHAR dir[1000] = { 0 }; | ||||
| 	int filelen = GetModuleFileName(NULL, dir, 1000); | ||||
| 	//WriteLog(dir); | ||||
| 	int i = filelen; | ||||
| 	while (dir[i] != '\\')i--; | ||||
| 	dir[i] = '\0'; | ||||
| 	m_strModulePath = dir; | ||||
|  | ||||
|  | ||||
| 	 | ||||
| 	// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Windows XP <20>ϵ<EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD>嵥ָ<E5B5A5><D6B8>Ҫ | ||||
| 	// ʹ<><CAB9> ComCtl32.dll <20>汾 6 <20><><EFBFBD><EFBFBD><EFBFBD>߰汾<DFB0><E6B1BE><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF>ӻ<EFBFBD><D3BB><EFBFBD>ʽ<EFBFBD><CABD> | ||||
| 	//<2F><><EFBFBD><EFBFBD>Ҫ InitCommonControlsEx()<29><>  <20><><EFBFBD><EFBFBD><F2A3ACBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD> | ||||
| 	INITCOMMONCONTROLSEX InitCtrls; | ||||
| 	InitCtrls.dwSize = sizeof(InitCtrls); | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD> | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC>ࡣ | ||||
| 	InitCtrls.dwICC = ICC_WIN95_CLASSES; | ||||
| 	InitCommonControlsEx(&InitCtrls); | ||||
|  | ||||
| 	CWinApp::InitInstance(); | ||||
|  | ||||
|  | ||||
| 	AfxEnableControlContainer(); | ||||
|  | ||||
| 	// <20><><EFBFBD><EFBFBD> shell <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><D4B7>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	// <20>κ<EFBFBD> shell <20><><EFBFBD><EFBFBD>ͼ<EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD> shell <20>б<EFBFBD><D0B1><EFBFBD>ͼ<EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD> | ||||
| 	CShellManager *pShellManager = new CShellManager; | ||||
|  | ||||
| 	// <20><><EFBFBD>Windows Native<76><65><EFBFBD>Ӿ<EFBFBD><D3BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD> MFC <20>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); | ||||
|  | ||||
| 	// <20><><EFBFBD><D7BC>ʼ<EFBFBD><CABC> | ||||
| 	// <20><><EFBFBD><EFBFBD>δʹ<CEB4><CAB9><EFBFBD><EFBFBD>Щ<EFBFBD><D0A9><EFBFBD>ܲ<EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD>С | ||||
| 	// <20><><EFBFBD>տ<EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>ļ<EFBFBD><C4BC>Ĵ<EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>Ӧ<EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	// <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ض<EFBFBD><D8B6><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ洢<DAB4><E6B4A2><EFBFBD>õ<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	// TODO: Ӧ<>ʵ<EFBFBD><CAB5>ĸ<DEB8><C4B8>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>˾<EFBFBD><CBBE><EFBFBD><EFBFBD>֯<EFBFBD><D6AF> | ||||
| 	SetRegistryKey(_T("Ӧ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵı<EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD>")); | ||||
|  | ||||
|  | ||||
| 	 | ||||
|  | ||||
| 	CPlcMainDlg dlg; | ||||
| 	m_pMainWnd = &dlg; | ||||
| 	INT_PTR nResponse = dlg.DoModal(); | ||||
| 	if (nResponse == IDOK) | ||||
| 	{ | ||||
| 		// TODO: <20>ڴ˷<DAB4><CBB7>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> | ||||
| 		//  <20><>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>رնԻ<D5B6><D4BB><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD> | ||||
| 	} | ||||
| 	else if (nResponse == IDCANCEL) | ||||
| 	{ | ||||
| 		// TODO: <20>ڴ˷<DAB4><CBB7>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> | ||||
| 		//  <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>رնԻ<D5B6><D4BB><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD> | ||||
| 	} | ||||
| 	else if (nResponse == -1) | ||||
| 	{ | ||||
| 		TRACE(traceAppMsg, 0, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20>Ի<EFBFBD><D4BB><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>\n"); | ||||
| 		TRACE(traceAppMsg, 0, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶԻ<DAB6><D4BB><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> MFC <20>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS<47><53>\n"); | ||||
| 	} | ||||
|  | ||||
| 	// ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD>洴<EFBFBD><E6B4B4><EFBFBD><EFBFBD> shell <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	if (pShellManager != NULL) | ||||
| 	{ | ||||
| 		delete pShellManager; | ||||
| 	} | ||||
|  | ||||
| #ifndef _AFXDLL | ||||
| 	ControlBarCleanUp(); | ||||
| #endif | ||||
|  | ||||
| 	// <20><><EFBFBD>ڶԻ<DAB6><D4BB><EFBFBD><EFBFBD>ѹرգ<D8B1><D5A3><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD> FALSE <20>Ա<EFBFBD><D4B1>˳<EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	//  <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>á<EFBFBD> | ||||
| 	return FALSE; | ||||
| } | ||||
|  | ||||
|  | ||||
| CString CPluginPlc::SendMsg2Platform(CString strReceiver, int nMsgType, Json::Value param) | ||||
| { | ||||
| 	LogOutToFile("PLC::SendMsg2Platform Begin"); | ||||
|  | ||||
| 	Json::Value root; | ||||
| 	root["sender"] = "PLC"; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,SwingArm | ||||
| 	root["receiver"] = strReceiver.GetBuffer(); | ||||
|  | ||||
| 	/****************************************************** | ||||
| 	nMsgTypeʹ<65><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	CREATE_TASK_RET      = 2,       //WCS->WMS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	EXECUTE_TASK_RET     = 4,       //WCS->WMS ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	DEVICE_STATE_REPORT  = 5,       //WCS->WMS <20>豸״̬<D7B4>ϱ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) | ||||
| 	DEVICE_CONFIG_REQ    = 6,       //WCS->WMS <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ | ||||
| 	*******************************************************/ | ||||
|  | ||||
| 	root["type"] = nMsgType; | ||||
| 	root["params"] = param; | ||||
|  | ||||
| 	Json::FastWriter  writer; | ||||
| 	string strJson = writer.write(root); | ||||
|  | ||||
| 	g_pstPipeClient->SendeMsg(WCS_2_WMS_DATA, (char*)strJson.c_str(), strJson.length()); | ||||
|  | ||||
| 	LogOutToFile("PLC::SendMsg2Platform End"); | ||||
|  | ||||
| 	return ""; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										45
									
								
								Plugin/Plc/PluginPlc.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								Plugin/Plc/PluginPlc.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | ||||
|  | ||||
| // Vcs-Client.h : PROJECT_NAME Ӧ<>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> | ||||
| // | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #ifndef __AFXWIN_H__ | ||||
| 	#error "<22>ڰ<EFBFBD><DAB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>stdafx.h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> PCH <20>ļ<EFBFBD>" | ||||
| #endif | ||||
|  | ||||
| #include "resource.h"		// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| #include "CCEXPipeLib.h" | ||||
| #define WM_MSG_ROBOT_TO_MAIN  WM_USER+2000 | ||||
|  | ||||
|  | ||||
| // CVcsClientApp:  | ||||
| // <20>йش<D0B9><D8B4><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>֣<EFBFBD><D6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Vcs-Client.cpp | ||||
| // | ||||
|  | ||||
| class CPluginPlc : public CWinApp | ||||
| { | ||||
| public: | ||||
| 	CPluginPlc(); | ||||
|  | ||||
| // <20><>д | ||||
| public: | ||||
| 	virtual BOOL InitInstance(); | ||||
|  | ||||
| public: | ||||
| 	void    ReadConfigFromIni(); | ||||
|  | ||||
|  | ||||
| public: | ||||
| 	CString        m_strModulePath; | ||||
|  | ||||
| 	ST_CAN_DEVICE  m_stCanDevice; | ||||
|  | ||||
| // ʵ<><CAB5> | ||||
| 	CString SendMsg2Platform(CString strReceiver, int nMsgType, Json::Value param = NULL); | ||||
|  | ||||
| 	DECLARE_MESSAGE_MAP() | ||||
| }; | ||||
|  | ||||
| extern CPluginPlc theApp; | ||||
| extern CCEXPipeClientBase* g_pstPipeClient; | ||||
							
								
								
									
										67
									
								
								Plugin/Plc/ReadMe.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								Plugin/Plc/ReadMe.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,67 @@ | ||||
| ================================================================================ | ||||
|     MICROSOFT 基础类库 : Vcs-Client 项目概述 | ||||
| =============================================================================== | ||||
|  | ||||
| 应用程序向导已为您创建了此 Vcs-Client 应用程序。此应用程序不仅演示 Microsoft 基础类的基本使用方法,还可作为您编写应用程序的起点。 | ||||
|  | ||||
| 本文件概要介绍组成 Vcs-Client 应用程序的每个文件的内容。 | ||||
|  | ||||
| Vcs-Client.vcxproj | ||||
|     这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 | ||||
|  | ||||
| Vcs-Client.vcxproj.filters | ||||
|     这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 | ||||
|  | ||||
| Vcs-Client.h | ||||
|     这是应用程序的主头文件。 | ||||
|     其中包括其他项目特定的标头(包括 Resource.h),并声明 CVcsClientApp 应用程序类。 | ||||
|  | ||||
| Vcs-Client.cpp | ||||
|     这是包含应用程序类 CVcsClientApp 的主应用程序源文件。 | ||||
|  | ||||
| Vcs-Client.rc | ||||
|     这是程序使用的所有 Microsoft Windows 资源的列表。它包括 RES 子目录中存储的图标、位图和光标。此文件可以直接在 Microsoft Visual C++ 中进行编辑。项目资源包含在 2052 中。 | ||||
|  | ||||
| res\Vcs-Client.ico | ||||
|     这是用作应用程序图标的图标文件。此图标包括在主资源文件 Vcs-Client.rc 中。 | ||||
|  | ||||
| res\VcsClient.rc2 | ||||
|     此文件包含不在 Microsoft Visual C++ 中进行编辑的资源。您应该将不可由资源编辑器编辑的所有资源放在此文件中。 | ||||
|  | ||||
|  | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| 应用程序向导创建一个对话框类: | ||||
|  | ||||
| Vcs-ClientDlg.h、Vcs-ClientDlg.cpp - 对话框 | ||||
|     这些文件包含 CVcsClientDlg 类。此类定义应用程序的主对话框的行为。对话框模板包含在 Vcs-Client.rc 中,该文件可以在 Microsoft Visual C++ 中编辑。 | ||||
|  | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| 其他功能: | ||||
|  | ||||
| ActiveX 控件 | ||||
|     该应用程序包含对使用 ActiveX 控件的支持。 | ||||
|  | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| 其他标准文件: | ||||
|  | ||||
| StdAfx.h, StdAfx.cpp | ||||
|     这些文件用于生成名为 Vcs-Client.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 | ||||
|  | ||||
| Resource.h | ||||
|     这是标准头文件,可用于定义新的资源 ID。Microsoft Visual C++ 将读取并更新此文件。 | ||||
|  | ||||
| Vcs-Client.manifest | ||||
| 	Windows XP 使用应用程序清单文件来描述特定版本的并行程序集的应用程序依赖项。加载程序使用这些信息来从程序集缓存中加载相应的程序集,并保护其不被应用程序访问。应用程序清单可能会包含在内,以作为与应用程序可执行文件安装在同一文件夹中的外部 .manifest 文件进行重新分发,它还可能以资源的形式包含在可执行文件中。 | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| 其他注释: | ||||
|  | ||||
| 应用程序向导使用“TODO:”来指示应添加或自定义的源代码部分。 | ||||
|  | ||||
| 如果应用程序使用共享 DLL 中的 MFC,您将需要重新分发 MFC DLL。如果应用程序所使用的语言与操作系统的区域设置不同,则还需要重新分发相应的本地化资源 mfc110XXX.DLL。 | ||||
| 有关上述话题的更多信息,请参见 MSDN 文档中有关重新分发 Visual C++ 应用程序的部分。 | ||||
|  | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
							
								
								
									
										
											BIN
										
									
								
								Plugin/Plc/res/Plc.ico
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Plugin/Plc/res/Plc.ico
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 17 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Plugin/Plc/res/Plc.rc2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Plugin/Plc/res/Plc.rc2
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Plugin/Plc/resource.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Plugin/Plc/resource.h
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										188
									
								
								Plugin/Plc/stdafx.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										188
									
								
								Plugin/Plc/stdafx.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,188 @@ | ||||
|  | ||||
| // stdafx.cpp : ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Դ<EFBFBD>ļ<EFBFBD> | ||||
| // Vcs-Client.pch <20><><EFBFBD><EFBFBD>ΪԤ<CEAA><D4A4><EFBFBD><EFBFBD>ͷ | ||||
| // stdafx.obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ | ||||
|  | ||||
| #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';//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7B7>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊԭ<CEAA><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>з<EFBFBD> | ||||
| 			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; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| // UTF8<46><38><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>(MultiByte)<29><>ת | ||||
| CString UTF8AndMB_Convert(const CString &strSource, UINT nSourceCodePage, UINT nTargetCodePage) | ||||
| { | ||||
| 	int nSourceLen = strSource.GetLength(); | ||||
| 	int nWideBufLen = MultiByteToWideChar(nSourceCodePage, 0, strSource, -1, NULL, 0); | ||||
|  | ||||
| 	wchar_t* pWideBuf = new wchar_t[nWideBufLen + 1]; | ||||
| 	memset(pWideBuf, 0, (nWideBufLen + 1) * sizeof(wchar_t)); | ||||
|  | ||||
| 	MultiByteToWideChar(nSourceCodePage, 0, strSource, -1, (LPWSTR)pWideBuf, nWideBufLen); | ||||
|  | ||||
| 	char* pMultiBuf = NULL; | ||||
| 	int nMiltiBufLen = WideCharToMultiByte(nTargetCodePage, 0, (LPWSTR)pWideBuf, -1, (char *)pMultiBuf, 0, NULL, NULL); | ||||
|  | ||||
| 	pMultiBuf = new char[nMiltiBufLen + 1]; | ||||
| 	memset(pMultiBuf, 0, nMiltiBufLen + 1); | ||||
|  | ||||
| 	WideCharToMultiByte(nTargetCodePage, 0, (LPWSTR)pWideBuf, -1, (char *)pMultiBuf, nMiltiBufLen, NULL, NULL); | ||||
|  | ||||
| 	CStringA strTarget(pMultiBuf); | ||||
|  | ||||
| 	delete[] pWideBuf; | ||||
| 	delete[] pMultiBuf; | ||||
|  | ||||
| 	return strTarget; | ||||
| } | ||||
|  | ||||
| CStringA UTF8ToMB(const CStringA& utf8Str) | ||||
| { | ||||
| 	if (IsTextUTF8(utf8Str, utf8Str.GetLength())) | ||||
| 	{ | ||||
| 		return UTF8AndMB_Convert(utf8Str, CP_UTF8, CP_ACP); | ||||
| 	} | ||||
| 	return utf8Str; | ||||
| } | ||||
|  | ||||
|  | ||||
| bool IsTextUTF8(const char* str, ULONGLONG length) | ||||
| { | ||||
| 	DWORD nBytes = 0;//UFT8<54><38><EFBFBD><EFBFBD>1-6<><36><EFBFBD>ֽڱ<D6BD><DAB1><EFBFBD>,ASCII<49><49>һ<EFBFBD><D2BB><EFBFBD>ֽ<EFBFBD> | ||||
| 	UCHAR chr; | ||||
| 	bool bAllAscii = true; //<2F><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ASCII, ˵<><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>UTF-8 | ||||
| 	for (int i = 0; i < length; i++) | ||||
| 	{ | ||||
| 		chr = *(str + i); | ||||
| 		if ((chr & 0x80) != 0) // <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ASCII<49><49><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,˵<><CBB5><EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD>UTF-8,ASCII<49><49>7λ<37><CEBB><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֽڴ<D6BD>,<2C><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϊ0,o0xxxxxxx | ||||
| 			bAllAscii = false; | ||||
| 		if (nBytes == 0) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ASCII<49><49>,Ӧ<><D3A6><EFBFBD>Ƕ<EFBFBD><C7B6>ֽڷ<D6BD>,<2C><><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD> | ||||
| 		{ | ||||
| 			if (chr >= 0x80) | ||||
| 			{ | ||||
| 				if (chr >= 0xFC && chr <= 0xFD) | ||||
| 					nBytes = 6; | ||||
| 				else if (chr >= 0xF8) | ||||
| 					nBytes = 5; | ||||
| 				else if (chr >= 0xF0) | ||||
| 					nBytes = 4; | ||||
| 				else if (chr >= 0xE0) | ||||
| 					nBytes = 3; | ||||
| 				else if (chr >= 0xC0) | ||||
| 					nBytes = 2; | ||||
| 				else | ||||
| 				{ | ||||
| 					return false; | ||||
| 				} | ||||
| 				nBytes--; | ||||
| 			} | ||||
| 		} | ||||
| 		else //<2F><><EFBFBD>ֽڷ<D6BD><DAB7>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD>ֽ<EFBFBD>,ӦΪ 10xxxxxx | ||||
| 		{ | ||||
| 			if ((chr & 0xC0) != 0x80) | ||||
| 			{ | ||||
| 				return false; | ||||
| 			} | ||||
| 			nBytes--; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if (nBytes > 0) //Υ<><CEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	{ | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	if (bAllAscii) //<2F><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ASCII, ˵<><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>UTF-8 | ||||
| 	{ | ||||
| 		return false; | ||||
| 	} | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
							
								
								
									
										169
									
								
								Plugin/Plc/stdafx.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										169
									
								
								Plugin/Plc/stdafx.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,169 @@ | ||||
|  | ||||
| // stdafx.h : <20><>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>İ<EFBFBD><C4B0><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> | ||||
| // <20><><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD> | ||||
| // <20>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>İ<EFBFBD><C4B0><EFBFBD><EFBFBD>ļ<EFBFBD> | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #ifndef VC_EXTRALEAN | ||||
| #define VC_EXTRALEAN            // <20><> Windows ͷ<><CDB7><EFBFBD>ų<EFBFBD><C5B3><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD> | ||||
| #endif | ||||
|  | ||||
| #include "targetver.h" | ||||
|  | ||||
| #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // ijЩ CString <20><><EFBFBD>캯<EFBFBD><ECBAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD> | ||||
|  | ||||
| // <20>ر<EFBFBD> MFC <20><>ijЩ<C4B3><D0A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD><C9B7>ĺ<EFBFBD><C4BA>Եľ<D4B5><C4BE><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| #define _AFX_ALL_WARNINGS | ||||
|  | ||||
| #include <afxwin.h>         // MFC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD> | ||||
| #include <afxext.h>         // MFC <20><>չ | ||||
|  | ||||
|  | ||||
| #include <afxdisp.h>        // MFC <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
|  | ||||
|  | ||||
| #ifndef _AFX_NO_OLE_SUPPORT | ||||
| #include <afxdtctl.h>           // MFC <20><> Internet Explorer 4 <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>֧<EFBFBD><D6A7> | ||||
| #endif | ||||
| #ifndef _AFX_NO_AFXCMN_SUPPORT | ||||
| #include <afxcmn.h>             // MFC <20><> Windows <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>֧<EFBFBD><D6A7> | ||||
| #endif // _AFX_NO_AFXCMN_SUPPORT | ||||
|  | ||||
| #include<afxsock.h> | ||||
| #include "json.h" | ||||
| #include <queue> | ||||
|  | ||||
| using namespace std; | ||||
|  | ||||
| #define WM_NETMESSAGE       (WM_USER+9981) | ||||
| #define NET_CONNECT_OK	0 | ||||
| #define NET_DISCONNECT	1 | ||||
| #define NET_DATA_MSG	2 | ||||
| #define CAN_DISCONNECT  3 | ||||
| #define PLC_DISCONNECT  4 | ||||
| #define APP_DATA_MSG	5 | ||||
|  | ||||
|  | ||||
| #include <afxcontrolbars.h>     // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳؼ<CDBF><D8BC><EFBFBD><EFBFBD><EFBFBD> MFC ֧<><D6A7> | ||||
| #include "../Protocol.h" | ||||
|  | ||||
| #ifdef _UNICODE | ||||
| #if defined _M_IX86 | ||||
| #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") | ||||
| #elif defined _M_X64 | ||||
| #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") | ||||
| #else | ||||
| #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
|  | ||||
| extern CString  g_strSavePath; | ||||
| extern CString  g_strCurTime; | ||||
| extern int      g_nMsgIdx; | ||||
| void LogOutToFile(const char* fmt, ...); | ||||
| string _UnicodeToUtf8(CString Unicodestr); | ||||
|  | ||||
|  | ||||
| CString UTF8AndMB_Convert(const CString &strSource, UINT nSourceCodePage, UINT nTargetCodePage); // UTF8<46><38><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>(MultiByte)<29><>ת | ||||
| CString UTF8ToMB(const CString& utf8Str); | ||||
| bool    IsTextUTF8(const char* str, ULONGLONG length); | ||||
|  | ||||
|  | ||||
| typedef struct  ST_THREAD_PARAM | ||||
| { | ||||
| 	void   * pParent; | ||||
| 	//int      nIdx; | ||||
| } | ||||
| ST_THREAD_PARAM; | ||||
|  | ||||
| typedef struct  ST_CAN_DEVICE | ||||
| { | ||||
| 	int nSendFrameFormat; | ||||
| 	int	nSendFrameType; | ||||
| 	int	nCanIndex; | ||||
| 	int	nDevType; | ||||
| } | ||||
| ST_CAN_DEVICE; | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| 	NET_WR_MSG_RET = 0, | ||||
| 	NET_RD_MSG_RET = 1 | ||||
| }NET_MSG_TYPE_ENUM; | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| 	MANUAL_MODE = 0,  //<2F>ֶ<EFBFBD>ģʽ<C4A3><CABD>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD> | ||||
| 	AUTO_MODE   = 1,  //<2F>Զ<EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ң<EFBFBD><D2A3><EFBFBD><EFBFBD> PDA<44><41><EFBFBD>ƣ<EFBFBD>PAD<41><44><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD><D4BF>Ƶ<EFBFBD>բ <20><><EFBFBD><EFBFBD> β<><CEB2>װ<EFBFBD><D7B0> | ||||
| 	DEBUG_MODE  = 2,  //PDA<44><41><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD>е<EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>ɿ<EFBFBD><C9BF><EFBFBD> | ||||
|  | ||||
| }AGV_RUN_MODE_ENUM; | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| 	RE_NORMAL_RUN   = 0,   //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	RE_UNUSUAL_STOP = 1,   //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>쳣ͣ<ECB3A3><CDA3> | ||||
| 	RE_POINT_STOP   = 2,   //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3>(<28>յ<EFBFBD>) | ||||
| 	RE_A_STOP       = 3,   //<2F>Զ<EFBFBD>ͣ<EFBFBD><CDA3> | ||||
| 	RE_E_STOP       = 4,   //<2F><><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3> | ||||
| }AGV_RUN_RESTATE_ENUM;     //<2F><><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD> | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| 	A_STOP   = 0, //<2F>Զ<EFBFBD>ͣ<EFBFBD><CDA3>	 | ||||
| 	FORWARD  = 1, //<2F><>ǰ<EFBFBD><C7B0>ʻ | ||||
| 	BACKWARD = 2, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʻ | ||||
| 	E_STOP   = 3, //<2F><><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3> | ||||
| 	INVALID_ACTION = 4,  //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чָ<D0A7>ά<EEA3AC>ֵ<EFBFBD>ǰͣ<C7B0><CDA3><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>״̬ | ||||
| }AGV_ACTION_ENUM; | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| 	LOG_ERROR  = 0, | ||||
| 	LOG_INFO   = 1 | ||||
| }LOG_TYPE_ENUM; | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
| 	SEND_MSG = 0, | ||||
| 	RECV_MSG = 1 | ||||
| }CAN_MSG_ENUM; | ||||
|  | ||||
| typedef struct NET_PACKET | ||||
| { | ||||
| 	char* pData; | ||||
| 	int   lLen; | ||||
| 	int   nDevId; | ||||
| 	NET_MSG_TYPE_ENUM  enType; | ||||
| }*pNET_PACKET; | ||||
|  | ||||
|  | ||||
| #define DATA_LINE_SIZE (11+13+4+4+11+4+4+4+33) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>ֽ<EFBFBD><D6BD><EFBFBD>89 | ||||
|  | ||||
| typedef struct ST_CAN_MESSAGE | ||||
| { | ||||
| 	char acSeq[10]; | ||||
| 	char acTime[12]; | ||||
| 	unsigned char cIndex; // 0<><30>1 | ||||
| 	unsigned char acTxRx; // 0:send, 1:recv | ||||
| 	char acID[10]; | ||||
| 	unsigned char acFrame;//0:data, 1:remote | ||||
| 	unsigned char acType; //0:standard, 1:extend | ||||
| 	unsigned char cDlc; | ||||
| 	char acData[32]; | ||||
|  | ||||
| }ST_CAN_MESSAGE; | ||||
|  | ||||
|  | ||||
|  | ||||
| typedef struct APP_NET_PACKET | ||||
| { | ||||
| 	int   lFuncLen; | ||||
| 	int   lParamLen; | ||||
| 	char *pFuncData; | ||||
| 	char *pParamData; | ||||
| 	 | ||||
| }*pNET_APP_PACKET; | ||||
							
								
								
									
										8
									
								
								Plugin/Plc/targetver.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Plugin/Plc/targetver.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| #pragma once | ||||
|  | ||||
| // <20><><EFBFBD><EFBFBD> SDKDDKVer.h <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>߰汾<DFB0><E6B1BE> Windows ƽ̨<C6BD><CCA8> | ||||
|  | ||||
| // <20><><EFBFBD><EFBFBD>ҪΪ<D2AA><CEAA>ǰ<EFBFBD><C7B0> Windows ƽ̨<C6BD><CCA8><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> WinSDKVer.h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| // <20><> _WIN32_WINNT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪҪ֧<D2AA>ֵ<EFBFBD>ƽ̨<C6BD><CCA8>Ȼ<EFBFBD><C8BB><EFBFBD>ٰ<EFBFBD><D9B0><EFBFBD> SDKDDKVer.h<><68> | ||||
|  | ||||
| #include <SDKDDKVer.h> | ||||
							
								
								
									
										30
									
								
								Plugin/Protocol.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								Plugin/Protocol.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
|  | ||||
| // Message.h : <20><>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>İ<EFBFBD><C4B0><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> | ||||
| // <20><><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD> | ||||
| // <20>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>İ<EFBFBD><C4B0><EFBFBD><EFBFBD>ļ<EFBFBD> | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
|  | ||||
| //WMS <---> WCS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD> | ||||
| typedef enum | ||||
| { | ||||
| 	//Plugin<->WMS | ||||
| 	DEVICE_CONFIG_REQ   = 10,       //Plugin<69><6E><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ | ||||
| 	DEVICE_CONFIG_RET   = 11,       //WMS<4D><53><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ | ||||
|  | ||||
| 	GET_TRANS_STATE_RET = 50,       //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4>ϱ<EFBFBD> | ||||
|  | ||||
| 	SET_TRANS_MODE_REQ  = 60,       //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ | ||||
| 	GET_TRANS_STATE_REQ = 61,       //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ | ||||
| 	 | ||||
| 	FAST_SAMPLE_REQ     = 71,       //<2F><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
| 	FAST_SAMPLE_RET     = 72,       //<2F><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | ||||
|  | ||||
| 	AXIS_XYZW_DATA      = 73, | ||||
| 	STATE_TASK_FINISH   = 74, | ||||
| 	 | ||||
| 	 | ||||
|  | ||||
| }EM_MSG_TYPE; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user