⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 messagemanager.cpp

📁 mtk simulator v2 new source code
💻 CPP
📖 第 1 页 / 共 4 页
字号:
								DataListNameStatus=1;
								break;							
							}
						}
						if(DataListNameStatus==0) // Datalist does not exists
						{
							m_XMLErrors = m_XMLErrors+CString("ERROR : [Format - ")+pFormat->GetName()+CString("] DataList Name not found in DataLists\n");
							ErrorStatus=1;
						}


					}
					else // if datlist is not there
					{
					
					}
				}
				else // format is there but datalist name is not there
				{
					m_XMLErrors = m_XMLErrors+CString("ERROR : [Format - ")+pFormat->GetName()+CString("] Invalid DataList Name\n");
					ErrorStatus=1;
				}
				
				
				inputmode = pFormat->GetInputMode(); // get the input mode
				if(inputmode.GetLength()==0) // Input  mode is empty
				{
					m_XMLErrors = m_XMLErrors+CString("ERROR : [Format - ")+pFormat->GetName()+CString("] InputMode not defined\n");
					ErrorStatus=1;
				}
				else
				{
					if((inputmode.CompareNoCase(CString("Dialog"))) && (inputmode.CompareNoCase(CString("Dataset")))) // Input mode is something other than Dialog,Dataset
					{
						m_XMLErrors = m_XMLErrors+CString("ERROR : [Format - ")+pFormat->GetName()+CString("] InputMode can be Dialog or Dataset\n");
						ErrorStatus=1;
					}
				}
			}
			else
			{
				m_XMLErrors = m_XMLErrors+CString("ERROR : [Format - ")+pFormat->GetName()+CString("] Format is defined without name\n");
				ErrorStatus=1;
			}
		}
	}
	else
	{
		m_XMLErrors = m_XMLErrors+CString("ERROR : Format List is not available\n");
		ErrorStatus=1;

	}

	if(ErrorStatus==1)
	{
		return 0; // Some error occur
	}
	else
	{
		return 1; // No Error Occure
	}

			
	
}

int CMessageManager::VerifyDataList()
{
	//take a datalist object from the list of datalist
	//there must be some name for every datalist object
	//there must be some text in the defaulf tag, i can never be "" (empty)
	//if it have some text the two cases are there as follow
	//1.) the text could be "NULL"(<- is tag text), then leave to search it in dataset list, its ok
	//2.) text is not empty, and not "NULL", then there must be some dataset against
	//    this name in the list of dataset

	int ErrorStatus=0;//ErrorStatus will be one even if single error occur
	CDataList cdatalist,*ptrdatalist; 
	int DataSetNameStatus;
	
	CData dataObj;


	if(m_pDataList && m_pDataList->GetCount())
	{
		
		for(POSITION pos = m_pDataList->GetHeadPosition(); pos != NULL;) 
		{
			ptrdatalist = (	CDataList*) m_pDataList->GetNext( pos ); // ptrdatalist  is having first node
		
			if((ptrdatalist->GetName()).GetLength()) // name tag of datalist object itself should be there 
			{
				if((ptrdatalist->GetDefault()).GetLength() >0)
				{
					if((ptrdatalist->GetDefault()).CompareNoCase(CString("NULL")))// data set is not having "NULL" tag
					{
						CList<CData,CData&>& datasetlist = ptrdatalist->GetData(); //data set list, now we have to search that dafault
						       							   // tag in the list of dataset and it should be there	
						if(datasetlist.GetCount()) // Dataset list is there
						{					
							for( POSITION datapos = datasetlist.GetHeadPosition(); datapos != NULL;)
							{
								DataSetNameStatus=0;
								dataObj = (datasetlist.GetNext( datapos ));
								if(!dataObj.GetName().CompareNoCase(ptrdatalist->GetDefault())) // 
								{
									DataSetNameStatus=1;
									break;
								}
							}

							if(DataSetNameStatus==0)
                            {
								m_XMLErrors = m_XMLErrors+CString("ERROR : [DataList - ")+ptrdatalist->GetName()+CString("] Default Dataset is not there in the list of Dataset\n");		
								ErrorStatus=1;
							}
						}
						else
						{
							//m_XMLErrors = m_XMLErrors+CString("ERROR : [DataList - ")+cdatalist.GetName()+CString("] Dataset list is not there\n");
						}

					}
					
				}
				else // default tag is empty
				{
					m_XMLErrors = m_XMLErrors+CString("ERROR : [DataList - ")+ptrdatalist->GetName()+CString("] DataList's Default tag can'nt be Empty\n");
					ErrorStatus=1;
				}
			}
			else // datalist name tag  is not there
			{
				m_XMLErrors = m_XMLErrors+CString("ERROR : DataList is there, but with out name\n");		
				ErrorStatus=1;
			}
		}

	}
	else
	{
		m_XMLErrors = m_XMLErrors+CString("ERROR : DataList is Empty\n");	
		ErrorStatus=1;
	}
	
	if(ErrorStatus==1)
	{
		return 0; // Some error occur
	}
	else
	{
		return 1; // No Error Occure
	}

}

int CMessageManager::VerifyAsyncMsg()
{
	CAsyncMessageSeq *ptrAsyncMsgSeq;
	UINT32 msgid;
	int msgidvalidstatus =0,ErrorStatus=0;
	COutgoingMessage *outgoing_msg; 
	for(POSITION pos = m_plstAsyncMsg->GetHeadPosition(); pos != NULL;) 
	{
		ptrAsyncMsgSeq = (CAsyncMessageSeq*) m_plstAsyncMsg->GetNext(pos); 
		CList<UINT32,UINT32&>& asyncmsgseq = ptrAsyncMsgSeq->GetMessageList();
		if(asyncmsgseq.GetCount())
		{
			
			for( POSITION datapos = asyncmsgseq.GetHeadPosition(); datapos != NULL;)
			{
				msgid = (asyncmsgseq.GetNext( datapos ));
				if(m_plstOutGoingMsg)
				{
					msgidvalidstatus = 0;
					for(POSITION pos=m_plstOutGoingMsg->GetHeadPosition();pos!=NULL;)
					{
						outgoing_msg = (COutgoingMessage*)m_plstOutGoingMsg->GetNext(pos);
						if(outgoing_msg->GetMessageId() ==msgid)
						{
							msgidvalidstatus=1; // Response Message id is there, its ok
							break;			// break the loop
						}
					}

					if(msgidvalidstatus ==0) // ionvalid msg id
					{
						m_XMLErrors = m_XMLErrors+CString("ERROR : ")+CString("[MsgId - ")+LongToCString(msgid)+CString("] Message Id not found, Invalid Async Message Sequence - ")+LongToCString(ptrAsyncMsgSeq->GetMessageId())+CString("\n") ;
						ErrorStatus=1;
					}
				}
			}		
		}
	}
		if(ErrorStatus==1)
		{
			return 0; // Some error occur
		}
		else
		{
			return 1; // No Error Occure
		}
	
	
}


int CMessageManager::VerifyAppList()		
{return 1;}

int CMessageManager::VerifyBootupList()	
{
	CBootUpMsg *ptrBootUpMsgSeq;
	UINT32 msgid;
	int msgidvalidstatus =0,ErrorStatus=0;
	COutgoingMessage *outgoing_msg; 
	for(POSITION pos = m_pBootupList->GetHeadPosition(); pos != NULL;) 
	{
		ptrBootUpMsgSeq = (CBootUpMsg*) m_pBootupList->GetNext(pos); 
		CList<UINT32,UINT32>& bootupmsglst = ptrBootUpMsgSeq->GetBootMessageList();
		if(bootupmsglst.GetCount())
		{
			
			for( POSITION datapos = bootupmsglst.GetHeadPosition(); datapos != NULL;)
			{
				msgid = (bootupmsglst.GetNext( datapos ));
				if(m_plstOutGoingMsg)
				{
					msgidvalidstatus = 0;
					for(POSITION pos=m_plstOutGoingMsg->GetHeadPosition();pos!=NULL;)
					{
						outgoing_msg = (COutgoingMessage*)m_plstOutGoingMsg->GetNext(pos);
						if(outgoing_msg->GetMessageId() ==msgid)
						{
							msgidvalidstatus=1; // Response Message id is there, its ok
							break;			// break the loop
						}
					}

					if(msgidvalidstatus ==0) // ionvalid msg id
					{
						m_XMLErrors = m_XMLErrors+CString("ERROR : ")+CString("[MsgId - ")+LongToCString(msgid)+CString("] Message Id not found, Invalid Boot Up Sequence - ")+LongToCString(ptrBootUpMsgSeq->GetMessageId())+CString("\n") ;
						ErrorStatus=1;
					}
				}
			}		
		}
	}
	if(ErrorStatus==1)
	{
		return 0; // Some error occur
	}
	else
	{
		return 1; // No Error Occure
	}
}

int CMessageManager::VerifyFreqList()	
{
	CFreqUsedMsg *ptrFreqUsedMsgSeq;
	UINT32 seqid;
	int seqidvalidstatus =0,ErrorStatus=0;
	CAsyncMessageSeq *sequence; 
	for(POSITION pos = m_pFreqList->GetHeadPosition(); pos != NULL;) 
	{
		ptrFreqUsedMsgSeq = (CFreqUsedMsg*) m_pFreqList->GetNext(pos); 
		CList<UINT32,UINT32>& frequsedmsglst = ptrFreqUsedMsgSeq->GetFreqUsedMessageList();
		if(frequsedmsglst.GetCount())
		{

			for( POSITION datapos = frequsedmsglst.GetHeadPosition(); datapos != NULL;)
			{
				seqid = (frequsedmsglst.GetNext( datapos ));
				if(m_plstAsyncMsg)
{
					seqidvalidstatus = 0;
					for(POSITION pos=m_plstAsyncMsg->GetHeadPosition();pos!=NULL;)
	{
						sequence = (CAsyncMessageSeq*)m_plstAsyncMsg->GetNext(pos);
						if(sequence->GetMessageId() ==seqid)
		{		
							seqidvalidstatus=1; // Sequence id is there, its ok
							break;			// break the loop
		}
					}

					if(seqidvalidstatus ==0) // ionvalid sequence id
					{
						m_XMLErrors = m_XMLErrors+CString("ERROR : ")+CString("[seqid - ")+LongToCString(seqid)+CString(" ]Sequence Id not found")+CString("\n") ;
						ErrorStatus=1;
					}
				}
			}		
		}
	}
	if(ErrorStatus==1)
	{
		return 0; // Some error occur
	}
	else
	{
		return 1; // No Error Occure
	}
}

/*void* CMessageManager::GetDataMemoryForMessage(CMessage *pMessage,UINT32 *iSize,CString strDataSet)
{
	void *vTempRet= NULL;
	//return the void * for the 
	CFormat *pFormat;// = new CFormat();	
	CDataList dataList;	
	CData dataObj;		
	pFormat = GetFormatForMessage(pMessage);
	if(pFormat!=NULL)
	{
		if(!(pMessage->GetFormat().CompareNoCase(pFormat->GetName())))				
		{
			//the format is found 
			//now check if the input mode is dialog and also the dataset name is not there...then we 
			//have to pop up a generic dialog...
			if(pFormat->GetInputMode().CompareNoCase(_T("DataSet")) && (!strDataSet.CompareNoCase(_T(""))))
			{
  				/*CGenericInput gen_input_dlg;
				if(parent_ptr)
					INPTRLIST * IncomingMessagePtr = parent_ptr->SendMessage(WM_GET_INC_MSG_FOR_OUT,0,0);
  				//INPTRLIST * IncomingMessagePtr = (INPTRLIST *) m_IncomingMsgDataList->GetTail() ;
  				gen_input_dlg.OutGoingMsgPtr = (COutgoingMessage *)pMessage; 
  				gen_input_dlg.IncomingMsgID =  IncomingMessagePtr->stMessage.nMsgType;
  				gen_input_dlg.DoModal();
  				if(!gen_input_dlg.data_set_to_be_sent.GetName().CompareNoCase(_T("")))
  					return(NULL);
  				vTempRet = GetBufferForSocket(pMessage,gen_input_dlg.data_set_to_be_sent,GetFormatForMessage(gen_input_dlg.OutGoingMsgPtr)->GetVarList(),iSize);
  					return vTempRet;*/
			/*}
			else
			{
				CList<CVar,CVar&>& varList = pFormat->GetVarList();
				dataList = pFormat->GetDataList();
				CList<CData,CData&>& data= dataList.GetData();				
				if((data.GetCount() > 0) && (varList.GetCount() > 0))
				{					
					for( POSITION datapos = data.GetHeadPosition(); datapos != NULL;)
					{
						dataObj = (data.GetNext( datapos ));
						if(strDataSet.GetLength())
						{
							if(!dataObj.GetName().CompareNoCase(strDataSet))
							{
								vTempRet = GetBufferForSocket(pMessage,dataObj,varList,iSize);//matched the data list
								return vTempRet;
							}
						}
						else if(!dataObj.GetName().CompareNoCase(dataList.GetDefault()))
						{
							//default data object stuffing to be done
							vTempRet = GetBufferForSocket(pMessage,dataObj,varList,iSize);
							return vTempRet;
						}
						
					}
					//handle the case in case both the above condition becomes false
					vTempRet = GetBufferForSocket(pMessage,dataObj,varList,iSize);
					return vTempRet;
								
				}//end of type check
			}//end of check dialog
		}//		
	}
	else
		AMLOGERROR(_T("GetData Memory for  Message error"));
	return  vTempRet;
}*/

void* CMessageManager::GetBufferForSocket(CMessage *pMessage,CData& dataObj,CList<CVar,CVar&>& varList,UINT32 *iSize)
{
	UINT32 iTotalSize = GetTotalSizeOfVariable(varList);
	*iSize = iTotalSize;
	//void* buffer1 = malloc(iTotalSize);
	void* buffer1 = MyMallocDataPtr(iTotalSize);
	void* buffer = buffer1;	
	memset(buffer,'k',iTotalSize);
	//CDataType datatype;
	CString strEval;
	INT16 iNoOfElements;
	for( POSITION pos = varList.GetHeadPosition(); pos != NULL;)
	{
		CVar&  cVar = (CVar&)(varList.GetNext( pos )) ;
		CList<CValue,CValue&>& valueList= dataObj.GetValueList();
		for( POSITION valpos = valueList.GetHeadPosition(); valpos != NULL;)
		//matched the name
		{
			CValue& valueObj = (CValue&)(valueList.GetNext( valpos )) ;			
			if(valueObj.GetName() == cVar.GetName())
			{
				//name matched 
				CDataType& datatype = cVar.GetDataType();
				CString cVarName = datatype.GetName();
				////get the type of the data
				BYTE type = valueObj.GetSourceType();
				////if 0 than constant
				if(type == 0)
				{
					if(cVarName.Find(_T("array")) > 0)
					{
						iNoOfElements = cVar.GetCount();
						UINT32 arraySize;// = (iNoOfElements)*(cVar.GetValueSize());
						strEval = valueObj.GetSourceValue();					
						if(cVarName.Find(_T("nt"),0) > 0)
						{
							int* Array = (int*)malloc(iNoOfElements*datatype.GetSize());
							int* back = Array;
							arraySize =	iNoOfElements*datatype.GetSize();
							memset(Array,'0',arraySize);						
							strEval.Insert((strEval.GetLength()+1),',');
							//its the integer array
							for(int iCount=0;iCount < iNoOfElements ;iCount++)
							{
								//this is the number of elements exist in the array
								//so look out for the number 
								CString First = strEval;
								int TotalLen = First.GetLength();
								int iComma = strEval.Find(_T(","),0);
								First = First.Left(iComma);							
								int value = _ttoi(First);
								//Array[iCount] = _ttoi(First);
								memcpy(Array,&value,datatype.GetSize());
								if((iCount+1) < iNoOfElements)
								++Array;
								strEval = strEval.Right((TotalLen - (iComma+1)));
							}
							memcpy(buffer,back,arraySize);
							//buffer = Array;						
							buffer = (char*)buffer+arraySize;
							break;
								
						}
						else if(cVarName.Find(_T("te"),0) > 0)
						{
							char* Array = (char*)malloc(iNoOfElements*datatype.GetSize());
							char* back = Array;
							arraySize =	iNoOfElements*datatype.GetSize();
							memset(Array,'0',arraySize);						
							strEval.Insert((strEval.GetLength()+1),',');
							//its the integer array
							//int n = 22
							//	memset(buffer,22,22);
							//	buffer = (char*)buffer+arraySize;
							//	break;
							for(int iCount=0;iCount < iNoOfElements ;iCount++)
							{
								//this is the number of elements exist in the array
								//so look out for the number 
								CString First = strEval;
								int TotalLen = First.GetLength();
								int iComma = strEval.Find(_T(","),0);
								CString First1 = First.Left(iComma);							
								char value = _ttoi(First1);
								*Array = value;//Array[iCount] = _ttoi(First);
								//memcpy(Array,&value,datatype.GetSize());
								if((iCount+1) < iNoOfElements)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -