Exemplo n.º 1
0
void CShootManagerSys::LoadShootSolutionSector(int iSector, LPCTSTR szFilename)
{
	if(iSector >= m_ShootSolutionSectorArray.Num())		return;
	
	int i;
	MSXML2::IXMLDOMDocument2Ptr pDoc;
	pDoc.CreateInstance(__uuidof(DOMDocument40));
	pDoc->load((_variant_t)szFilename);
	
	
	// 성공한 슛부터 로드한다.
	MSXML2::IXMLDOMNodeListPtr pNodeListSuccess = pDoc->selectNodes(L"root/success");
	for(i=0; i<pNodeListSuccess->Getlength(); i++)
	{
		MSXML2::IXMLDOMNodePtr pNodeSuccess = pNodeListSuccess->Getitem(i);
		
		CShootSolution Solution;
		Solution.Create(pNodeSuccess, true, this);
		m_ShootSolutionSectorArray[iSector].first.push_back(Solution);
	}

	MSXML2::IXMLDOMNodeListPtr pNodeListFail = pDoc->selectNodes(L"root/fail");
	for(i=0; i<pNodeListFail->Getlength(); i++)
	{
		MSXML2::IXMLDOMNodePtr pNodeFail = pNodeListFail->Getitem(i);

		CShootSolution Solution;
		Solution.Create(pNodeFail, false, this);
		m_ShootSolutionSectorArray[iSector].second.push_back(Solution);
	}

	pDoc.Release();			
}
Exemplo n.º 2
0
MSXML2::IXMLDOMDocument2Ptr CXmlBase::GetXmlDocPtrByFile(LPCTSTR lpszXmlPathFile
	, LPCTSTR lpszNamespace)
{
	CComBSTR bstrXml;
	CString str(_T(""));
	HRESULT hr = S_OK;
	MSXML2::IXMLDOMDocument2Ptr pDoc;

	//载入到xml文档结构中
	hr = pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument40));
	if (FAILED(hr))
	{
//		WRITELOG("END, FAILED TO INVOKE pDoc.CreateInstance");
		return NULL;
	}

	pDoc->async = VARIANT_TRUE; //加载方式为“同步”
	pDoc->validateOnParse = VARIANT_FALSE; //文档结构有错误时,停止解析。

	if (VARIANT_FALSE == pDoc->load(lpszXmlPathFile))
	{
		//WRITELOG("END, FAILED TO INVOKE pDoc->load(%s)", strXmlPathFile);
		return NULL;
	}

	if (lpszNamespace != NULL)
	{
		hr = pDoc->setProperty("SelectionLanguage", "XPath");
		if (FAILED(hr)) return NULL;
		hr = pDoc->setProperty("SelectionNamespaces", lpszNamespace);
		if (FAILED(hr)) return NULL;
	}

	return pDoc;
}
Exemplo n.º 3
0
MSXML2::IXMLDOMDocument2Ptr ValidateConfigXML()
{
	wchar_t moduleFileName[MAX_PATH] = {0};
	if(0 == GetModuleFileNameW(GetModuleHandle(_T("TestConnectSdk.dll")/*"TestConnectAPITool.dll"*/), moduleFileName, MAX_PATH))
		throw Workshare::Exception(_T("Failed to obtain the filename of the current module"));
	CStdStringW schemaUrl;
	schemaUrl.Format(L"res://%s/ConnectAPITestTool.xsd", moduleFileName);

	MSXML2::IXMLDOMDocument2Ptr spConfigSchema;
	HRESULT hr = spConfigSchema.CreateInstance(__uuidof(MSXML2::DOMDocument60));
	if(FAILED(hr))
		throw Workshare::ClassNotFoundException(_T("Msxml2.DOMDocument.6.0"), _T("Failed to create an XML dom object."));
	if(VARIANT_TRUE != spConfigSchema->load(schemaUrl.c_str()))
		ThrowMSXMLParseError(spConfigSchema->parseError, _T("Failed to load 'ConnectAPITestTool.xsd'."));

	MSXML2::IXMLDOMSchemaCollection2Ptr spSchemaCollection;
	hr = spSchemaCollection.CreateInstance(__uuidof(MSXML2::XMLSchemaCache60));
	if(FAILED(hr))
		throw Workshare::ClassNotFoundException(_T("Msxml2.XMLSchemaCache.6.0"), _T("Failed to create an XML schema collection."));
	hr = spSchemaCollection->add(L"", spConfigSchema.GetInterfacePtr());
	if(S_OK != hr)
		throw Workshare::Exception(_T("Failed to add 'ConnectAPITestTool.xsd' to schema collection."));

	MSXML2::IXMLDOMDocument2Ptr spConfigXML;
	hr = spConfigXML.CreateInstance(__uuidof(MSXML2::DOMDocument60));
	if(FAILED(hr))
		throw Workshare::ClassNotFoundException(_T("Msxml2.DOMDocument.6.0"), _T("Failed to create an XML dom object."));
	spConfigXML->async = VARIANT_FALSE;
	spConfigXML->resolveExternals = VARIANT_FALSE;
	spConfigXML->validateOnParse = VARIANT_FALSE;
	spConfigXML->schemas = spSchemaCollection.GetInterfacePtr();
	if(VARIANT_TRUE != spConfigXML->load(L"ConnectAPITestTool.xml"))
		ThrowMSXMLParseError(spConfigXML->parseError, _T("Failed to load 'ConnectAPITestTool.xml'."));

	MSXML2::IXMLDOMParseErrorPtr spError = spConfigXML->validate();
	if(S_OK != spError->errorCode)
		ThrowMSXMLParseError(spError, _T("Failed to validate 'ConnectAPITestTool.xml'."));

	return spConfigXML;
}
Exemplo n.º 4
0
	MSXML2::IXMLDOMDocument2Ptr setupXMLParser(char *path)
	{
		HRESULT hr;
		MSXML2::IXMLDOMDocument2Ptr xmlDoc;
		
		hr = CoInitialize(NULL);
		hr = xmlDoc.CreateInstance(__uuidof(MSXML2::DOMDocument60), NULL, CLSCTX_INPROC_SERVER);
		if (FAILED(hr)) return NULL;

		if (xmlDoc->load(path) != VARIANT_TRUE) return NULL;

		hr = xmlDoc->setProperty("SelectionNamespaces", "xmlns:r='http://www.collada.org/2005/11/COLLADASchema'");
		hr = xmlDoc->setProperty("SelectionLanguage", "XPath");

		return xmlDoc;
	}
Exemplo n.º 5
0
CRDPConfig::CRDPConfig(const char *configFile)
{
	// Local variables and initializations
	HRESULT	hResult = S_OK;
	char	cNodeType;

	// set the defaults
	mConfigError = false;	// TODO - check for config error - report in Capture Fail
	mDrive = "C:";
	mRoot = "/DATA";		// NOTE: don't use backslash in file names
	mInfoDrive = "C:";
	mInfoRoot = "/xampp/htdocs/RDP_Data";
	mInfoFile = "messages.log";
	mMsgLogDrive = "C:";
	mMsgLogRoot = "/xampp/htdocs/RDP_Data";
	mMsgLogFile = "messages.log";
	mTestDataDrive = "C:";
	mTestDataRoot = "/DATA/TestData";
	//mTestDataEnabled = false;
	mDebugLevel = -1;

	mMSSListenerPort = 65000;
	mDrive = "C:";
	mRoot = "\\DATA\\";
	mLeadInSize = 21;
	mDataBlockSize = 150;
	mLeadOutSize = 0;
	mNoOfCards = 2;
	mNoOfPortsPerCard = 4;

	// Read the XML file and update the config values

	// Initialize the COM library
	hResult = CoInitialize(NULL);
	if (FAILED(hResult))
	{
		MsgLog::Error("RDPConfig module - Failed to initialize COM environment");
		return;
	}

	// Main try block for MSXML DOM operations
	try
	{
		// MSXML COM smart pointers
		// Use the Dccument2 class to enable schema validation
		MSXML2::IXMLDOMDocument2Ptr spDocInput;
		MSXML2::IXMLDOMNodePtr spNodeTemp;
		MSXML2::IXMLDOMElementPtr spElemTemp;
		MSXML2::IXMLDOMAttributePtr spAttrTemp;
		MSXML2::IXMLDOMNodeListPtr spNLChildren;

		// Create the COM DOM Document object
		hResult = spDocInput.CreateInstance(__uuidof(DOMDocument));

		if FAILED(hResult)
		{
			MsgLog::Error("RDPConfig module - Failed to create Document instance");
			return;
		}

		// Load the document synchronously
		spDocInput->async = VARIANT_FALSE;

		// Load input document. MSXML default for load is to
		// validate while parsing.
		hResult = spDocInput->load(configFile);

		// Check for load, parse, or validation errors
		if( hResult != VARIANT_TRUE)
		{
			MsgLog::Error("Parsing error reading config file %s", configFile);
			return;
		} else {
			MsgLog::Info("Config file %s opened successfully", configFile);
		}

		// Get document element
		spElemTemp = spDocInput->documentElement;
		if (Debug::Enabled(Debug::CONFIG))
			std::cout<<std::endl<<"Document Element name:  "<<spElemTemp->nodeName<<std::endl;

		// Walk through children of document element
		// and process according to type
		spNodeTemp = spElemTemp->firstChild;

		// TODO more checking needed for the config file
		while (spNodeTemp != NULL)
		{
			// Process node depending on type
			cNodeType = spNodeTemp->nodeType;
			switch (cNodeType)
			{
				// Comment Node
				case NODE_COMMENT:
					if (Debug::Enabled(Debug::CONFIG))
						std::cout<<"Comment Node:" << std::endl << "  "<<_bstr_t(spNodeTemp->nodeValue)<<std::endl;
					break;
				// Element Node
				case NODE_ELEMENT:
				{
					std::string	tempString;
					spElemTemp = (IXMLDOMElementPtr) spNodeTemp;
					std::string node = (const char *)spElemTemp->nodeName;
					Debug::PrintLine(Debug::CONFIG, "Processing %s", node.c_str());

					// A note on processing attributes
					// MSXML doesn't support the hasAttribute method,
					// so we'll try to get the Attribute node, then its value.
					// eg
					// spAttrTemp = spElemTemp->getAttributeNode("Attribute1");
					// if (spAttrTemp != NULL)	// test if "get" was successful
					//    ...

					if (node == "MSS") {
						spAttrTemp = spElemTemp->getAttributeNode("PORT");
						if (spAttrTemp != NULL) {
							mMSSListenerPort = (u_short)strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
							Debug::PrintLine(Debug::CONFIG, "  PORT Value:  %d", mMSSListenerPort);
						}
					} else if (node == "DISK") {
						spAttrTemp = spElemTemp->getAttributeNode("DRIVE");
						if (spAttrTemp != NULL) {
							mDrive = (char *)_bstr_t(spAttrTemp->nodeValue);
							Debug::PrintLine(Debug::CONFIG, "  DRIVE:  %s", mDrive.c_str());
						}
						spAttrTemp = spElemTemp->getAttributeNode("ROOT");
						if (spAttrTemp != NULL) {
							mRoot = (char *)_bstr_t(spAttrTemp->nodeValue);
							FixPath(mRoot);	// replace all backslashes \ with forward slashes /
							Debug::PrintLine(Debug::CONFIG, "  ROOT:  %s", mRoot.c_str());
						}
					} else if (node == "INFO") {
						spAttrTemp = spElemTemp->getAttributeNode("DRIVE");
						if (spAttrTemp != NULL) {
							mInfoDrive = (char *)_bstr_t(spAttrTemp->nodeValue);
							Debug::PrintLine(Debug::CONFIG, "  INFO DRIVE:  %s", mInfoDrive.c_str());
						}
						spAttrTemp = spElemTemp->getAttributeNode("ROOT");
						if (spAttrTemp != NULL) {
							mInfoRoot = (char *)_bstr_t(spAttrTemp->nodeValue);
							FixPath(mInfoRoot);	// replace all backslashes \ with forward slashes /
							Debug::PrintLine(Debug::CONFIG, "  INFO ROOT:  %s", mInfoRoot.c_str());
						}
						spAttrTemp = spElemTemp->getAttributeNode("FILE");
						if (spAttrTemp != NULL) {
							mInfoFile = (char *)_bstr_t(spAttrTemp->nodeValue);
							Debug::PrintLine(Debug::CONFIG, "  INFO FILE:  %s", mInfoFile.c_str());
						}
					} else if (node == "MSGLOG") {
						spAttrTemp = spElemTemp->getAttributeNode("DRIVE");
						if (spAttrTemp != NULL) {
							mMsgLogDrive = (char *)_bstr_t(spAttrTemp->nodeValue);
							Debug::PrintLine(Debug::CONFIG, "  MSGLOG DRIVE:  %s", mMsgLogDrive.c_str());
						}
						spAttrTemp = spElemTemp->getAttributeNode("ROOT");
						if (spAttrTemp != NULL) {
							mMsgLogRoot = (char *)_bstr_t(spAttrTemp->nodeValue);
							FixPath(mMsgLogRoot);	// replace all backslashes \ with forward slashes /
							Debug::PrintLine(Debug::CONFIG, "  MSGLOG ROOT:  %s", mMsgLogRoot.c_str());
						}
						spAttrTemp = spElemTemp->getAttributeNode("FILE");
						if (spAttrTemp != NULL) {
							mMsgLogFile = (char *)_bstr_t(spAttrTemp->nodeValue);
							Debug::PrintLine(Debug::CONFIG, "  MSGLOG FILE:  %s", mMsgLogFile.c_str());
						}
					} else if (node == "TESTDATA") {
						spAttrTemp = spElemTemp->getAttributeNode("DRIVE");
						if (spAttrTemp != NULL) {
							mTestDataDrive = (char *)_bstr_t(spAttrTemp->nodeValue);
							Debug::PrintLine(Debug::CONFIG, "  TESTDATA DRIVE:  %s", mTestDataDrive.c_str());
						}
						spAttrTemp = spElemTemp->getAttributeNode("ROOT");
						if (spAttrTemp != NULL) {
							mTestDataRoot = (char *)_bstr_t(spAttrTemp->nodeValue);
							FixPath(mTestDataRoot);	// replace all backslashes \ with forward slashes /
							Debug::PrintLine(Debug::CONFIG, "  MSGLOG ROOT:  %s", mTestDataRoot.c_str());
						}
						//spAttrTemp = spElemTemp->getAttributeNode("ENABLED");
						//if (spAttrTemp != NULL) {
						//	tempString = (char *)_bstr_t(spAttrTemp->nodeValue);
						//	std::transform(tempString.begin(), tempString.end(), tempString.begin(), std::toupper);
						//	mTestDataEnabled = (tempString == "YES");
						//}
					} else if (node == "DEBUG") {
						spAttrTemp = spElemTemp->getAttributeNode("LEVEL");
						if (spAttrTemp != NULL) {
							mDebugLevel = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
							Debug::PrintLine(Debug::CONFIG, "  DEBUG LEVEL:  %d", mDebugLevel);
						}
					} else if (node == "FIBREOPTICINTERFACE") {
						MSXML2::IXMLDOMNodePtr spChildNode = spNodeTemp->firstChild;
						int	noOfCards = 2;	// default to 2 cards
						int noOfPortsPerCard = 4;	// default to 4 ports per card

						while (spChildNode != NULL)
						{
							if (spChildNode->nodeType == NODE_ELEMENT)
							{
								MSXML2::IXMLDOMElementPtr spChildElem = (IXMLDOMElementPtr) spChildNode;
								std::string nodeName = (const char *)spChildNode->nodeName;
								Debug::PrintLine(Debug::CONFIG, "    Processing %s", nodeName.c_str());
								//Debug::PrintLine(Debug::CONFIG, "    Processing %s", (const char *)spChildNode->nodeName);
								if (nodeName == "HARDWARE")
								{
									// eg <HARDWARE CARDS="2" PORTS="4"/>
									spAttrTemp = spChildElem->getAttributeNode("CARDS");
									if (spAttrTemp != NULL) {
										noOfCards = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
									}
									spAttrTemp = spChildElem->getAttributeNode("PORTS");
									if (spAttrTemp != NULL) {
										noOfPortsPerCard = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
									}
								} else if (nodeName == "FORMAT")
								{
									// eg <FORMAT LEADIN="21" DATABLOCK="150" LEADOUT="0"/>
									spAttrTemp = spChildElem->getAttributeNode("LEADIN");
									if (spAttrTemp != NULL) {
										mLeadInSize = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
										if (mLeadInSize < 0) mConfigError = true;
									}
									spAttrTemp = spChildElem->getAttributeNode("DATABLOCK");
									if (spAttrTemp != NULL) {
										mDataBlockSize = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
										if (mDataBlockSize < 0) mConfigError = true;
									}
									spAttrTemp = spChildElem->getAttributeNode("LEADOUT");
									if (spAttrTemp != NULL) {
										mLeadOutSize = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
										if (mLeadOutSize < 0) mConfigError = true;
									}
									if (mLeadInSize+mDataBlockSize+mLeadOutSize > Global::MAX_IQ_SAMPLES) mConfigError = true;
								} else if (nodeName == "DEVICE")
								{
									// eg <DEVICE CARD="0" PORT="2" ID="sfm_0_sfpdp_2" READ="YES" WRITE="NO"/>
									int			card, port, fibre;
									bool		bRead, bWrite;
									std::string	id;

									spAttrTemp = spChildElem->getAttributeNode("CARD");
									if (spAttrTemp != NULL) {
										card = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
									}
									spAttrTemp = spChildElem->getAttributeNode("PORT");
									if (spAttrTemp != NULL) {
										port = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
									}
									spAttrTemp = spChildElem->getAttributeNode("FIBRE");
									// TODO check that fibre value runs from 0 up to n
									if (spAttrTemp != NULL) {
										fibre = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
									}
									spAttrTemp = spChildElem->getAttributeNode("ID");
									if (spAttrTemp != NULL) {
										id = (char *)_bstr_t(spAttrTemp->nodeValue);
									}
									spAttrTemp = spChildElem->getAttributeNode("READ");
									if (spAttrTemp != NULL) {
										tempString = (char *)_bstr_t(spAttrTemp->nodeValue);
										std::transform(tempString.begin(), tempString.end(), tempString.begin(), std::toupper);
										bRead = (tempString == "YES");
									}
									spAttrTemp = spChildElem->getAttributeNode("WRITE");
									if (spAttrTemp != NULL) {
										tempString = (char *)_bstr_t(spAttrTemp->nodeValue);
										std::transform(tempString.begin(), tempString.end(), tempString.begin(), std::toupper);
										bWrite = (tempString == "YES");
									}
									Debug::PrintLine(Debug::CONFIG, "\tCARD = %d", card);
									Debug::PrintLine(Debug::CONFIG, "\tPORT = %d", port);
									Debug::PrintLine(Debug::CONFIG, "\tFIBRE = %d", fibre);
									Debug::PrintLine(Debug::CONFIG, "\tid = %s", id.c_str());
									Debug::PrintLine(Debug::CONFIG, "\tRead? = %s", (bRead)?"Yes":"No");
									Debug::PrintLine(Debug::CONFIG, "\tWrite? = %s", (bWrite)?"Yes":"No");
									if ( (card >= 0) && (card < Global::MAX_CARDS)		// card is 0..max-1 ?
										&& (port >= 0) && (port < Global::MAX_PORTS)	// port is 0..max-1 ?
										&& (bRead || bWrite)							// either reader or writer or both ?
										) {
										CDevice	device(card, port, bRead, bWrite, fibre, id);
										mDevice.push_back(device);
									}
								} else if (nodeName == "PROCESSING")
								{
									// eg	<PROCESSING HEADERCRCCHECK="YES"
									//			DATACRCCHECK="YES"
									//			HEADERMARK="7FACE0FF"
									//		/>
									std::string	mark;

									spAttrTemp = spChildElem->getAttributeNode("HEADERCRCCHECK");
									if (spAttrTemp != NULL) {
										tempString = (char *)_bstr_t(spAttrTemp->nodeValue);
										std::transform(tempString.begin(), tempString.end(), tempString.begin(), std::toupper);
										mHeaderCRCCheck = (tempString == "YES");
									}
									spAttrTemp = spChildElem->getAttributeNode("DATACRCCHECK");
									if (spAttrTemp != NULL) {
										tempString = (char *)_bstr_t(spAttrTemp->nodeValue);
										std::transform(tempString.begin(), tempString.end(), tempString.begin(), std::toupper);
										mDataCRCCheck = (tempString == "YES");
									}
									spAttrTemp = spChildElem->getAttributeNode("HEADERMARK");
									if (spAttrTemp != NULL) {
										tempString = (char *)_bstr_t(spAttrTemp->nodeValue);
										if (tempString.length() != 8) {
											MsgLog::Error("HEADERMARK conversion error - %s", tempString.c_str());
											mConfigError = true;
										} else {
											//tempString = 
											for (int i = 0; i < sizeof(DWORD); i++) {
												int	val;
												std::string s = tempString.substr(2*i, 2);
												if (Global::FromString(val, s, std::hex)) {
													val &= 0xFF;
													Global::headerBOM1.c[i] = val;
													Global::headerBOM2.c[sizeof(DWORD) - i - 1] = val;
												} else {
													mConfigError = true;
													MsgLog::Error("HEADERMARK conversion error - %s", tempString.c_str());
												}
											}
										}
									}
									Debug::PrintLine(Debug::CONFIG, "\tHEADERCRCCHECK? = %s", (mHeaderCRCCheck)?"Yes":"No");
									Debug::PrintLine(Debug::CONFIG, "\tDATACRCCHECK? = %s", (mDataCRCCheck)?"Yes":"No");
									Debug::PrintLine(Debug::CONFIG, "\tHeader Word = 0x%02x%02x%02x%02x",
										Global::headerBOM1.c[0], Global::headerBOM1.c[1], Global::headerBOM1.c[2], Global::headerBOM1.c[3]);
								}
							}
							spChildNode = spChildNode->nextSibling;	// Get the next child of the Document Element
							//Debug::PrintLine(Debug::CONFIG, "\tlength of mDevice is %d", mDevice.size());
						}
						mNoOfCards = ( (noOfCards > 0) && (noOfCards <= Global::MAX_CARDS) ) ? noOfCards : 2;
						mNoOfPortsPerCard = ( (noOfPortsPerCard > 0) && (noOfPortsPerCard <= Global::MAX_PORTS) ) ? noOfPortsPerCard : 4;
						Debug::PrintLine(Debug::CONFIG, "Number of cards = %d", mNoOfCards);
						Debug::PrintLine(Debug::CONFIG, "Number of ports per card = %d", mNoOfPortsPerCard);
					} else {
						if (Debug::Enabled(Debug::CONFIG))
							std::cout << "Ignoring element:      " << spElemTemp->nodeName << std::endl;
					}
				}

				// Everything else allowed by the schema
				default:
					// Skip unexpected processing instructions
					// and white space text nodes
					break;
			} // End of switch block

			spNodeTemp = spNodeTemp->nextSibling;	// Get the next child of the Document Element

		} // End of while block
	} // End of try block
	catch (_com_error &e)	// Catch COM exceptions
	{
		std::cerr << "COM Error" << std::endl;
		std::cerr << "Message = " << e.ErrorMessage() << std::endl;
		return;
	}

	CoUninitialize();

	Debug::SetLevel(mDebugLevel);
}
Exemplo n.º 6
0
void CShootManagerSys::LoadShootSolutionSet(LPCTSTR szFilename)
{
	int i;
	MSXML2::IXMLDOMDocument2Ptr pDoc;
	pDoc.CreateInstance(__uuidof(DOMDocument40));
	pDoc->load((_variant_t)szFilename);


	// 시뮬레이터에서 사용하는 거리 범위들을 로드한다.
	MSXML2::IXMLDOMNodeListPtr pNodeListDistance;
	MSXML2::IXMLDOMNodePtr pNodeDistance;
	float fDistance;
	pNodeListDistance = pDoc->selectNodes(L"root/distance_range/distance");
	for(i=0; i<pNodeListDistance->Getlength(); i++)
	{
		pNodeDistance = pNodeListDistance->Getitem(i);
		_bstr_t distance = pNodeDistance->GetnodeTypedValue();
		sscanf((LPCTSTR)distance, "%f", &fDistance);
		m_DistanceList.push_back(fDistance);
	}

	
	// 시뮬레이터에서 사용하는 각도 범위들을 로드한다.
	// 여기서 각도는 (골대 - 슈터) 와 양의 z 축 사이의 각도를 말한다.
	// degree 로 저장되어 있으므로 Angle 로 변환시킨다.
	MSXML2::IXMLDOMNodeListPtr pNodeListAngle;
	MSXML2::IXMLDOMNodePtr pNodeAngle;
	float fDegree;
	int iAngle;
	pNodeListAngle = pDoc->selectNodes(L"root/angle_range/degree");
	for(i=0; i<pNodeListAngle->Getlength(); i++)
	{
		pNodeAngle = pNodeListAngle->Getitem(i);
		_bstr_t degree = pNodeAngle->GetnodeTypedValue();
		sscanf((LPCTSTR)degree, "%f", &fDegree);
		iAngle = Degree2Angle(fDegree);					// degree 에서 Angle 로 변환한다.
		m_AngleList.push_back(iAngle);
	}

	// 전체 섹터 개수를 계산하고 여기에 맞게 메모리를 생성한다.
	int iNumSector = m_DistanceList.size() * (m_AngleList.size() + 1) + 6;
	for(i=0; i<iNumSector; i++)
	{
		ShootSolutionSector *pShootSolutionSector = new (m_ShootSolutionSectorArray) ShootSolutionSector;
	}

	// 각 섹터별로 섹터안의 Shoot Solution 들을 로드한다.
	MSXML2::IXMLDOMNodeListPtr pNodeListSector = pDoc->selectNodes(L"root/sector");
	MSXML2::IXMLDOMNodePtr pNodeSector;
	MSXML2::IXMLDOMNodePtr pNodeIndex;
	MSXML2::IXMLDOMNodePtr pNodePath;
	for(i=0; i<pNodeListSector->Getlength(); i++)
	{
		pNodeSector = pNodeListSector->Getitem(i);
		pNodeIndex = pNodeSector->selectSingleNode(L"index");
		pNodePath = pNodeSector->selectSingleNode(L"path");
		_bstr_t index = pNodeIndex->GetnodeTypedValue();
		_bstr_t path = pNodePath->GetnodeTypedValue();

		int iIndex = atoi((LPCTSTR)index);
		SString sFilePath = szFilename;
		sFilePath = DGetPathOnly(sFilePath);
		sFilePath += "\\";
		sFilePath += (LPCTSTR)path;
//		sFilePath.Format("%s\\%s\\%s", g_szCurrentPath, g_szSimulatorPath, (LPCTSTR)path);

		LoadShootSolutionSector(iIndex, (LPCTSTR)sFilePath);
	}

	pDoc.Release();		
}
Exemplo n.º 7
0
bool Engine::LoadContent()
{
	// Setup our SpriteBatch.
	m_pSpriteBatch = new DirectX::SpriteBatch(d3dContext_);

	m_pFont->Initialize(d3dDevice_, std::wstring(L"Calibri18.spritefont"));
	m_pSprite->Initialize(d3dDevice_, std::wstring(L"Test.dds"), 10.0f, 10.0f); 
	
	m_textToDisplay = Text();
	m_textToDisplay.Initialize(std::wstring(L"Sarah"), DirectX::SimpleMath::Vector2(200.0f, 200.0f));

	try
	{
		MSXML2::IXMLDOMDocument2Ptr xmlDoc;
		HRESULT hr = xmlDoc.CreateInstance(__uuidof(MSXML2::DOMDocument60), NULL, CLSCTX_INPROC_SERVER);

		teamStats.InitializeTeam("Players.xml");

		// Make sure the file was loaded correctly before trying to load the players.
		if (xmlDoc->load("Players.xml") == VARIANT_TRUE)
		{
			//xmlDoc->setProperty("SelectionLanguage", "XPath");
			//teamStats.LoadPlayers(xmlDoc);
		}


		if (xmlDoc->load("input.xml") != VARIANT_TRUE)
		{
			DXTRACE_MSG("Unable to load input.xml\n");

			xmlDoc->save("input.xml");
			//xmlDoc->
		}
		else
		{
			DXTRACE_MSG("XML was successfully loaded \n");

			xmlDoc->setProperty("SelectionLanguage", "XPath");
			MSXML2::IXMLDOMNodeListPtr wheels = xmlDoc->selectNodes("/Car/Wheels/*");
			DXTRACE_MSG("Car has %u wheels\n", wheels->Getlength());
		
			DXTRACE_MSG(wheels->Getitem(0)->text);

			//ptr->

			MSXML2::IXMLDOMNodePtr node;
			node = xmlDoc->createNode(MSXML2::NODE_ELEMENT, ("Engine"), (""));
			node->text = ("Engine 1.0");
			xmlDoc->documentElement->appendChild(node);
			hr = xmlDoc->save("output.xml");

			if (SUCCEEDED(hr))
			{
				DXTRACE_MSG("output.xml successfully saved\n");
			}
		}
	}
	catch (_com_error &e)
	{
		DXTRACE_MSG(e.ErrorMessage());
	}










	return true;
}