bool CLogObjectLIN::bLogData(const SFORMATTEDDATA_LIN& sDataLIN) { // Multiple return statements are used to keep the code precise. SFRAMEINFO_BASIC_LIN LINInfo_Basic = { sDataLIN.m_dwMsgID, sDataLIN.m_eChannel, sDataLIN.m_eDirection, sDataLIN.m_byMsgType, sDataLIN.m_eEventType }; // Assign appropriate values to FrameInfo_Basic if (bToBeLogged(LINInfo_Basic) == false) { return false; } CString omLogText = ""; char* pTimeData = nullptr; char* pId = nullptr; char* pData = nullptr; char acChecksum[LENGTH_STR_CHKSUM_LIN]; char* pChkType=nullptr; switch (m_sLogInfo.m_eLogTimerMode) // Time Mode { case TIME_MODE_ABSOLUTE: { if(m_sLogInfo.m_bResetAbsTimeStamp) { pTimeData = (char*) (sDataLIN.m_acTimeAbsReset); } else { pTimeData = (char*) (sDataLIN.m_acTimeAbs); } } break; case TIME_MODE_RELATIVE: { pTimeData = (char*) (sDataLIN.m_acTimeRel); } break; case TIME_MODE_SYSTEM: { pTimeData = (char*) (sDataLIN.m_acTimeSys); } break; default: ASSERT(false); break; } switch (m_sLogInfo.m_eNumFormat) { case HEXADECIMAL: { pId = (char*) (sDataLIN.m_acMsgIDHex); BYTE CurrDat = sDataLIN.m_byChecksum; sprintf(acChecksum, FORMAT_STR_CHECKSUM_HEX, CurrDat); { pData = (char*) (sDataLIN.m_acDataHex); } } break; case DEC: { pId = (char*) (sDataLIN.m_acMsgIDDec); BYTE CurrDat = sDataLIN.m_byChecksum; sprintf(acChecksum, FORMAT_STR_CHECKSUM_DEC, CurrDat); { pData = (char*) (sDataLIN.m_acDataDec); } } break; default: ASSERT(false); break; } if(sDataLIN.m_byMsgType == LIN_MSG) { //pChecksum = (char*) (sDataLIN.m_byChecksum); if(sDataLIN.m_byChecksumType == 0) { pChkType="Classic"; } else { pChkType="Enhanced"; } // First put everything in a string to get the length omLogText.Format( "%s %s %s %s %s %s %s(%s) \n", pTimeData, sDataLIN.m_acMsgDir, sDataLIN.m_acChannel, pId, sDataLIN.m_acDataLen, pData,acChecksum,pChkType); vWriteTextToFile(omLogText, LIN); } else if(sDataLIN.m_byMsgType == LIN_EVENT ) { omLogText.Format("%s %s %s %s %s %s %s %s(%s) \n", pTimeData, sDataLIN.m_acType,sDataLIN.m_acMsgDir, sDataLIN.m_acChannel,sDataLIN.m_acDataLen, pId,pData,acChecksum,pChkType ); vWriteTextToFile(omLogText, LIN); } return true; }
BOOL CLogObjectCAN::bLogData(const SFORMATTEDDATA_CAN& sDataCAN) { // Multiple return statements are used to keep the code precise. SFRAMEINFO_BASIC_CAN CANInfo_Basic = { sDataCAN.m_dwMsgID, sDataCAN.m_eChannel, sDataCAN.m_eDirection, sDataCAN.m_byIDType, sDataCAN.m_byMsgType }; // Assign appropriate values to FrameInfo_Basic if (bToBeLogged(CANInfo_Basic) == FALSE) { return FALSE; } CString omLogText = ""; char* pTimeData = NULL; char* pId = NULL; char* pData = NULL; switch (m_sLogInfo.m_eLogTimerMode) // Time Mode { case TIME_MODE_ABSOLUTE: { if(m_sLogInfo.m_bResetAbsTimeStamp) { pTimeData = (char*) (sDataCAN.m_acTimeAbsReset); } else { pTimeData = (char*) (sDataCAN.m_acTimeAbs); } } break; case TIME_MODE_RELATIVE: { pTimeData = (char*) (sDataCAN.m_acTimeRel); } break; case TIME_MODE_SYSTEM: { pTimeData = (char*) (sDataCAN.m_acTimeSys); } break; default: ASSERT(FALSE); break; } switch (m_sLogInfo.m_eNumFormat) { case HEXADECIMAL: { pId = (char*) (sDataCAN.m_acMsgIDHex); pData = (char*) (sDataCAN.m_acDataHex); } break; case DEC: { pId = (char*) (sDataCAN.m_acMsgIDDec); pData = (char*) (sDataCAN.m_acDataDec); } break; default: ASSERT(FALSE); break; } // First put everything in a string to get the length omLogText.Format( "%s %s %s %s %s %s %s\n", pTimeData, sDataCAN.m_acMsgDir, sDataCAN.m_acChannel, pId, sDataCAN.m_acType, sDataCAN.m_acDataLen, pData); vWriteTextToFile(omLogText, CAN); return TRUE; }
BOOL CLogObjectJ1939::bLogData(const SFORMATTEDATA_J1939& sDataJ1939) { // Multiple return statements are used to keep the code precise. SFRAMEINFO_BASIC_J1939 J1939Info_Basic = { sDataJ1939.m_dwPGN }; // Assign appropriate values to FrameInfo_Basic if (bToBeLogged(J1939Info_Basic) == FALSE) { return FALSE; } CString omLogText = ""; char* pTimeData = NULL; char acID[16] = {'\0'}; char* pPGN = NULL; char* pData = NULL; char* psSrcNode = NULL; char* psDestNode = NULL; switch (m_sLogInfo.m_eLogTimerMode) // Time Mode { case TIME_MODE_ABSOLUTE: { if(m_sLogInfo.m_bResetAbsTimeStamp) { pTimeData = (char*) (sDataJ1939.m_acTimeAbsReset); } else { pTimeData = (char*) (sDataJ1939.m_acTimeAbs); } } break; case TIME_MODE_RELATIVE: { pTimeData = (char*) (sDataJ1939.m_acTimeRel); } break; case TIME_MODE_SYSTEM: { pTimeData = (char*) (sDataJ1939.m_acTimeSys); } break; default: ASSERT(FALSE); break; } switch (m_sLogInfo.m_eNumFormat) { case HEXADECIMAL: { sprintf_s(acID, "%x", sDataJ1939.m_dwMsgID); pPGN = (char*) (sDataJ1939.m_acPGNHex); pData = (char*) (sDataJ1939.m_pcDataHex); psSrcNode = (char*) (sDataJ1939.m_acSrcHex); psDestNode = (char*) (sDataJ1939.m_acDestHex); } break; case DEC: { sprintf_s(acID, "%d", sDataJ1939.m_dwMsgID); pPGN = (char*) (sDataJ1939.m_acPGNDec); pData = (char*) (sDataJ1939.m_pcDataDec); psSrcNode = (char*) (sDataJ1939.m_acSrcDec); psDestNode = (char*) (sDataJ1939.m_acDestDec); } break; default: ASSERT(FALSE); break; } // First put everything in a string to get the length // <Time> <Channel> <ID> <PGN> <Type> <Src Node> <Dest Node> <Priority> <Direction> <DLC> <Data> omLogText.Format( _T("%s %s %s %s %s %s %s %s %s %s %s\n"), pTimeData, sDataJ1939.m_acChannel, acID, pPGN, sDataJ1939.m_acMsgType, psSrcNode, psDestNode, sDataJ1939.m_acPriority, sDataJ1939.m_acMsgDir, sDataJ1939.m_acDataLen, pData); vWriteTextToFile(omLogText, J1939); return TRUE; }