📄 boardprocessor.cpp
字号:
// BoardProcessor.cpp: implementation of the CBoardProcessor class.////////////////////////////////////////////////////////////////////////#include "BoardProcessor.h"//////////////////////////////////////////////////////////////////////// Construction/Destruction//////////////////////////////////////////////////////////////////////CBoardProcessor::CBoardProcessor(){ m_lstBoardList.clear(); m_lstProcessorList.clear();}CBoardProcessor::~CBoardProcessor(){ m_lstBoardList.clear(); m_lstProcessorList.clear(); ReleaseCodeComposerSetup();}BOOL CBoardProcessor::GetAvailableBoards(){ USES_CONVERSION; long status, numofboards; BSTR BoardName; HRESULT hr; string szTempBoardName; // Instantiate the Code Composer Setup SystemSetup coclass and // obtain a pointer to the ISystemSetup interface hr = m_pISystemSetup.CreateInstance(__uuidof(CodeComposerSetup::SystemSetup)); if (FAILED(hr)) return FALSE; // Get a pointer to the IBoards interface TRY_CCAPP_FUNCTION(status = m_pISystemSetup->GetBoards(&m_pIBoards)); if (status != 0) { ReleaseCodeComposerSetup(); return FALSE; } // Get the total number of boards TRY_CCAPP_FUNCTION(status = m_pIBoards->GetCount(&numofboards)); if (status != 0) { ReleaseCodeComposerSetup(); return FALSE; } // Loop through the available boards, get the names of the boards, and // add the board names to the list for (long i=0; i<numofboards; i++) { // Get the board via index TRY_CCAPP_FUNCTION(status = m_pIBoards->GetItem(i, &m_pIBoard)); if (status != 0) { ReleaseCodeComposerSetup(); return FALSE; } // Get the board name TRY_CCAPP_FUNCTION(status = m_pIBoard->GetName(&BoardName)); if (status != 0) { ReleaseCodeComposerSetup(); return FALSE; } szTempBoardName = OLE2T(BoardName); // Insert board into list at this point m_lstBoardList.push_back(szTempBoardName); } return TRUE;}void CBoardProcessor::ReleaseCodeComposerSetup(){ if (m_pISystemSetup) m_pISystemSetup.Release(); if (m_pIBoards) m_pIBoards.Release(); if (m_pIBoard) m_pIBoard.Release(); if (m_pIProcessors) m_pIProcessors.Release(); if (m_pIProcessor) m_pIProcessor.Release();}BOOL CBoardProcessor::GetAvailableProcessors(BSTR SelectedBoardName){ USES_CONVERSION; long status, numofprocessors; BSTR ProcessorName; string szTempProcessorName; // Get a pointer to the IBoard interface for the selected board TRY_CCAPP_FUNCTION(status = m_pISystemSetup->GetBoardByName(SelectedBoardName, &m_pIBoard)); if (status != 0) { ReleaseCodeComposerSetup(); return FALSE; } // Get a pointer to the IProcessors interface TRY_CCAPP_FUNCTION(status = m_pIBoard->GetProcessors(&m_pIProcessors)); if (status != 0) { ReleaseCodeComposerSetup(); return FALSE; } // Get the total number of processors TRY_CCAPP_FUNCTION(status = m_pIProcessors->GetCount(&numofprocessors)); if (status != 0) { ReleaseCodeComposerSetup(); return FALSE; } // Loop through the available processors, get the names of the // processors, and add the processors to the list for (long i=0; i<numofprocessors; i++) { // Get the processor via index TRY_CCAPP_FUNCTION(status = m_pIProcessors->GetItem(i, &m_pIProcessor)); if (status != 0) { ReleaseCodeComposerSetup(); return FALSE; } // Get the processor name TRY_CCAPP_FUNCTION(status = m_pIProcessor->GetName(&ProcessorName)); if (status != 0) { ReleaseCodeComposerSetup(); return FALSE; } szTempProcessorName = OLE2T(ProcessorName); // Insert processor into list at this point m_lstProcessorList.push_back(szTempProcessorName); } return TRUE;}BOOL CBoardProcessor::GetBoard(TCHAR *pBoardName){ USES_CONVERSION; vector<string>::iterator iter; int RequestedBoardNumber=0,i; BOOL fItemFound=FALSE; TCHAR option='\0'; // Get the available boards if (GetAvailableBoards() == FALSE) return FALSE; do { // initialize iterator iter = m_lstBoardList.begin(); for (i=0; i<m_lstBoardList.size(); i++) { cout << i << _T(" - ") << iter[i].c_str() << _T("\n"); } cout << _T("\nSelect a board number from the list above.>"); cin >> RequestedBoardNumber; if ( (RequestedBoardNumber < 0) || (RequestedBoardNumber >= m_lstBoardList.size()) ) { cout << _T("Invalid board number.\n"); cout << _T("Do you wish to reenter board number?>"); cin >> option; if ((option != 'y') && (option != 'Y')) return fItemFound; } else { fItemFound = TRUE; // Get Board String _tcscpy(pBoardName,iter[RequestedBoardNumber].c_str()); } } while (fItemFound == FALSE); return fItemFound;}BOOL CBoardProcessor::GetProcessor(TCHAR *pBoardName, TCHAR *pProcessorName){ USES_CONVERSION; vector<string>::iterator iter; int RequestedProcessorNumber=0,i; BOOL fItemFound=FALSE; TCHAR option='\0'; // Get the available processors if (GetAvailableProcessors(T2BSTR(pBoardName)) == FALSE) return FALSE; do { // initialize iterator iter = m_lstProcessorList.begin(); for (i=0; i<m_lstProcessorList.size(); i++) { cout << i << _T(" - ") << iter[i].c_str() << _T("\n"); } cout << _T("\nSelect a processor number from the list above.>"); cin >> RequestedProcessorNumber; if ( (RequestedProcessorNumber < 0) || (RequestedProcessorNumber >= m_lstProcessorList.size()) ) { cout << _T("Invalid processor number.\n"); cout << _T("Do you wish to reenter processor number?>"); cin >> option; if ((option != 'y') && (option != 'Y')) return fItemFound; } else { fItemFound = TRUE; // Get Processor String _tcscpy(pProcessorName,iter[RequestedProcessorNumber].c_str()); } } while (fItemFound == FALSE); return fItemFound;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -