/** * \brief writes the Messages in the given list to the output file * \param[in] fileOutput Pointer to the Output file * \param[in] m_listMessages List of Message * \param[in] writeErr If true write error signals also else write only correct signals * associated with the message * \return Status code * * Writes the Messages in the given list to the output file. */ bool CMessage::writeMessageToFile(fstream& fileOutput, list<CMessage> &m_listMessages, bool writeErr) { bool bResult = true; //Write all the message list<CMessage>::iterator msg; for(msg=m_listMessages.begin(); msg!=m_listMessages.end(); ++msg) { fileOutput << T_START_MSG << " " << msg->m_acName.c_str(); fileOutput << "," << dec << msg->m_uiMsgID; fileOutput << "," << dec << msg->m_ucLength; fileOutput << "," << dec << msg->m_ucNumOfSignals; fileOutput << "," << msg->m_cDataFormat; fileOutput << "," << msg->m_cFrameFormat; fileOutput << "," << msg->m_txNode.c_str() << endl; CSignal sig; //write all related signals to the messages bResult &= sig.WriteSignaltofile(fileOutput, msg->m_listSignals, msg->m_ucLength, msg->m_cDataFormat, writeErr); fileOutput << T_END_MSG << endl; fileOutput << endl; } return bResult; }
/** * \brief Writes all the data to the output file in CANoe format * * Writes all the data to the output file in CANoe format. */ bool CDBFConverter::WriteToOutputFile(fstream& fileOutput) { bool bResult = true; // write to the output file // write header fileOutput << T_HEADER << endl; fileOutput << endl; fileOutput << T_DB_VER " " T_VER_NO << endl; fileOutput << endl; if(m_eBus == J1939) { fileOutput << T_PROTOCOL " " T_PRPTOCOL_J1939; } else { //default CAN fileOutput << T_PROTOCOL " " T_PROTOCOL_CAN; } fileOutput << endl; fileOutput << endl; //For easy replacement of version Info #define is not added fileOutput<< "[BUSMASTER_VERSION] [1.7.2]"<<endl; // number of messages fileOutput << T_NUM_OF_MSG " " << dec << m_listMessages.size() << endl; fileOutput << endl; //Write Messagess to the Output file CMessage msg; bResult &= msg.writeMessageToFile(fileOutput, m_listMessages, false, m_eBus); // write all messages, signals not associated with any Messages if(!m_listSignal.empty()) { fileOutput << T_ST_SIG_LIST << endl; CSignal sig; bResult &= sig.WriteSignaltofile(fileOutput, m_listSignal, 0, 0, false); fileOutput << T_END_SIG_LIST << endl; fileOutput << endl; } //write value table fileOutput << T_ST_VAL_TAB << endl; CValueTable temp_vtab; temp_vtab.writeValueTabToFile (fileOutput,m_vTab); fileOutput << T_END_VAL_TAB << endl; fileOutput << endl; //write list of nodes fileOutput << T_NODE " "; bool comma = false; list<string>::iterator node; for(node=m_listNode.begin(); node!=m_listNode.end(); ++node) { if(comma) { fileOutput << ","; } fileOutput << node->c_str(); comma = true; } fileOutput << endl; fileOutput << endl; //Write Comments fileOutput << T_ST_COMMENT << endl; //network comments fileOutput << T_ST_CM_NET << endl; list<CComment>::iterator cmt; for(cmt=m_cmNet.begin(); cmt!=m_cmNet.end(); ++cmt) { fileOutput << cmt->m_elementName.c_str(); fileOutput << " " << cmt->m_comment.c_str() << endl; } fileOutput << T_END_CM_NET << endl; fileOutput << endl; //node comments fileOutput << T_ST_CM_NODE << endl; for(cmt=m_cmNode.begin(); cmt!=m_cmNode.end(); ++cmt) { fileOutput << cmt->m_elementName.c_str(); fileOutput << " " << cmt->m_comment.c_str() << endl; } fileOutput << T_END_CM_NODE << endl; fileOutput << endl; //message comments fileOutput << T_ST_CM_MSG << endl; for(cmt=m_cmMsg.begin(); cmt!=m_cmMsg.end(); ++cmt) { fileOutput << cmt->m_msgID; fileOutput << " " << cmt->m_msgType; fileOutput << " " << cmt->m_comment.c_str() << endl; } fileOutput << T_END_CM_MSG << endl; fileOutput << endl; //signal comments fileOutput << T_ST_CM_SIG << endl; for(cmt=m_cmSig.begin(); cmt!=m_cmSig.end(); ++cmt) { fileOutput << cmt->m_msgID; fileOutput << " " << cmt->m_msgType; fileOutput << " " << cmt->m_elementName.c_str(); fileOutput << " " << cmt->m_comment.c_str() << endl; } fileOutput << T_END_CM_SIG << endl; fileOutput << T_END_COMMENT << endl; fileOutput << endl; //Write Parameters to the output file. fileOutput << START_PARAM_TAG << endl; fileOutput << START_NETPARAM_TAG << endl; bResult=bResult & WriteParametersToFile(fileOutput, m_listParameterArray[0]); fileOutput << END_NETPARAM_TAG << endl; fileOutput << endl; fileOutput << START_NODEPARAM_TAG << endl; bResult=bResult & WriteParametersToFile(fileOutput, m_listParameterArray[1]); fileOutput << END_NODEPARAM_TAG << endl; fileOutput << endl; fileOutput << START_MSGPARAM_TAG << endl; bResult=bResult & WriteParametersToFile(fileOutput, m_listParameterArray[2]); fileOutput << END_MSGPARAM_TAG << endl; fileOutput << endl; fileOutput << START_SIGPARAM_TAG << endl; bResult=bResult & WriteParametersToFile(fileOutput, m_listParameterArray[3]); fileOutput << END_SIGPARAM_TAG << endl; fileOutput << endl; fileOutput << START_RXPARAM_TAG << endl; bResult=bResult & WriteParametersToFile(fileOutput, m_listParameterArray[4]); fileOutput << END_RXPARAM_TAG << endl; fileOutput << endl; fileOutput << START_TXPARAM_TAG << endl; bResult=bResult & WriteParametersToFile(fileOutput, m_listParameterArray[5]); fileOutput << END_TXPARAM_TAG << endl; fileOutput << END_PARAM_TAG << endl; fileOutput << endl; //Parameter Values fileOutput << START_PARAMVAL_TAG << endl; fileOutput << START_NETVAL_TAG << endl; list<CParameter>::iterator rParam; for(rParam=m_listParameterArray[0].begin(); rParam!=m_listParameterArray[0].end(); ++rParam) { list<CParameterValues>::iterator vParam; for(vParam=rParam->m_listParamValues[0].begin(); vParam!=rParam->m_listParamValues[0].end(); ++vParam) { vParam->WriteNetValuesToFile(fileOutput, rParam->m_ParamType, rParam->m_ParamName); } } fileOutput << END_NETVAL_TAG << endl; fileOutput << endl; fileOutput << START_NODEVAL_TAG << endl; for(rParam=m_listParameterArray[1].begin(); rParam!=m_listParameterArray[1].end(); ++rParam) { list<CParameterValues>::iterator vParam; for(vParam=rParam->m_listParamValues[1].begin(); vParam!=rParam->m_listParamValues[1].end(); ++vParam) { vParam->WriteNodeValuesToFile(fileOutput, rParam->m_ParamType, rParam->m_ParamName); } } fileOutput << END_NODEVAL_TAG << endl; fileOutput << endl; fileOutput << START_MSGVAL_TAG << endl; for(rParam=m_listParameterArray[2].begin(); rParam!=m_listParameterArray[2].end(); ++rParam) { list<CParameterValues>::iterator vParam; for(vParam=rParam->m_listParamValues[2].begin(); vParam!=rParam->m_listParamValues[2].end(); ++vParam) { vParam->WriteMesgValuesToFile(fileOutput, rParam->m_ParamType, rParam->m_ParamName); } } fileOutput << END_MSGVAL_TAG << endl; fileOutput << endl; fileOutput << START_SIGVAL_TAG << endl; for(rParam=m_listParameterArray[3].begin(); rParam!=m_listParameterArray[3].end(); ++rParam) { list<CParameterValues>::iterator vParam; for(vParam=rParam->m_listParamValues[3].begin(); vParam!=rParam->m_listParamValues[3].end(); ++vParam) { vParam->WriteSigValuesToFile(fileOutput, rParam->m_ParamType, rParam->m_ParamName); } } fileOutput << END_SIGVAL_TAG << endl; fileOutput << endl; fileOutput << END_PARAMVAL_TAG << endl; fileOutput << endl; fileOutput << endl; //list of not supported fileOutput << T_ST_NOT_SUP << endl; msg.writeMessageToFile(fileOutput, m_unsupList, true, m_eBus); fileOutput << T_END_NOT_SUP << endl; fileOutput << endl; //lines that were not processed fileOutput << T_ST_NOT_PRO << endl; list<string>::iterator np; for(np=m_notProcessed.begin(); np!=m_notProcessed.end(); ++np) { fileOutput << np->c_str() << endl; } fileOutput << endl; fileOutput << T_END_NOT_PRO << endl; return bResult; }