/******************************************************************************
    Function Name    :  vCalculateAndFormatTM
    Input(s)         :  bExprnFlag - Details of time mode
                        TimeStamp - Msg time stamp, Rel time in case of Rel. mode
                        acTime - Buffer to store formatted time
    Output           :
    Functionality    :  Format time details
    Member of        :  CFormatMsgCommon
    Friend of        :      -
    Author(s)        :  Anish kumar
    Date Created     :  01.04.2010
******************************************************************************/
void CFormatMsgCommon::vCalculateAndFormatTM(BYTE bExprnFlag, UINT64 TimeStamp,
        char acTime[])
{
    /* In order to make this function work properly ENSURE bExprnFlag has ONLY
    1 time mode bit up */

    DWORD dwTSTmp = 0; // temporary time stamp

    if (IS_TM_SYS_SET(bExprnFlag))
    {
        dwTSTmp = (DWORD) ((TimeStamp - m_qwAbsBaseTime) + m_qwRefSysTime);
    }
    else if (IS_TM_REL_SET(bExprnFlag))
    {

        dwTSTmp = (DWORD) TimeStamp;
    }
    else if (IS_TM_ABS_SET(bExprnFlag))
    {
        dwTSTmp = (DWORD) (TimeStamp - m_qwAbsBaseTime);
    }
    else
    {
        ASSERT(FALSE);
    }
    vFormatTimeStamp(dwTSTmp, acTime);
}
예제 #2
0
/*******************************************************************************
  Function Name  : vFormatTime
  Input(s)       : -
  Output         : -
  Functionality  : Format Time
  Member of      : CFormatMsgCAN
  Author(s)      : Ratnadip
  Date Created   : 8.7.2009
  Modifications  :
*******************************************************************************/
void CFormatMsgCAN::vFormatTime(BYTE bExprnFlag,
                                SFORMATTEDDATA_CAN* CurrDataCAN)
{
    BYTE bTmpExprnFlag = bExprnFlag;
    if (IS_TM_ABS_SET(bExprnFlag))
    {
        CLEAR_EXPR_TM_BITS(bTmpExprnFlag);
        SET_TM_ABS(bTmpExprnFlag);
        vCalculateAndFormatTM(bTmpExprnFlag, CurrDataCAN->m_u64TimeStamp,
                              CurrDataCAN->m_acTimeAbs);
    }

    if (IS_TM_REL_SET(bExprnFlag))
    {
        CLEAR_EXPR_TM_BITS(bTmpExprnFlag);
        SET_TM_REL(bTmpExprnFlag);
        vCalculateAndFormatTM(bTmpExprnFlag, CurrDataCAN->m_u64TimeStamp,
                              CurrDataCAN->m_acTimeRel);
    }

    if (IS_TM_SYS_SET(bExprnFlag))
    {
        CLEAR_EXPR_TM_BITS(bTmpExprnFlag);
        SET_TM_SYS(bTmpExprnFlag);
        vCalculateAndFormatTM(bTmpExprnFlag, CurrDataCAN->m_u64TimeStamp,
                              CurrDataCAN->m_acTimeSys);
    }
}
예제 #3
0
/******************************************************************************
    Function Name    :  vGetUpdatedCurrDataPtrArray
    Input(s)         :
    Output           :
    Functionality    :  Provide format data structure pointers to the user
    Member of        :  CMsgContainerJ1939
    Friend of        :      -
    Author(s)        :  Arun kumar K
    Date Created     :  20.01.2011
******************************************************************************/
void CMsgContainerJ1939::vGetUpdatedCurrDataPtrArray(SMSGWNDHDRCOL& sHdrColStruct,
        char* pomDataPtrArr[MAX_MSG_WND_COL_CNT],
        BYTE bExprnFlag_Disp)
{
    //Time mode
    if (IS_TM_ABS_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byTimePos] = m_sOutFormattedData.m_acTimeAbs;
    }

    else if (IS_TM_REL_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byTimePos] = m_sOutFormattedData.m_acTimeRel;
    }

    else if (IS_TM_SYS_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byTimePos] = m_sOutFormattedData.m_acTimeSys;
    }

    // Dec/Hex mode for DATA and ID
    if (IS_NUM_HEX_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byDataPos] = m_sOutFormattedData.m_pcDataHex;
        pomDataPtrArr[sHdrColStruct.m_byIDPos]   = m_sOutFormattedData.m_acMsgIDHex;
        pomDataPtrArr[sHdrColStruct.m_byPGNPos]  = m_sOutFormattedData.m_acPGNHex;
        pomDataPtrArr[sHdrColStruct.m_bySrcPos]  = m_sOutFormattedData.m_acSrcHex;
        pomDataPtrArr[sHdrColStruct.m_byDestPos] = m_sOutFormattedData.m_acDestHex;
    }
    else if (IS_NUM_DEC_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byDataPos] = m_sOutFormattedData.m_pcDataDec;
        pomDataPtrArr[sHdrColStruct.m_byIDPos]   = m_sOutFormattedData.m_acMsgIDDec;
        pomDataPtrArr[sHdrColStruct.m_byPGNPos]  = m_sOutFormattedData.m_acPGNDec;
        pomDataPtrArr[sHdrColStruct.m_bySrcPos]  = m_sOutFormattedData.m_acSrcDec;
        pomDataPtrArr[sHdrColStruct.m_byDestPos] = m_sOutFormattedData.m_acDestDec;
    }

    //Rest will always be same
    pomDataPtrArr[sHdrColStruct.m_byDLCPos]       = m_sOutFormattedData.m_acDataLen;
    pomDataPtrArr[sHdrColStruct.m_byMsgTypePos]   = m_sOutFormattedData.m_acMsgType;
    pomDataPtrArr[sHdrColStruct.m_byRxTxPos]      = m_sOutFormattedData.m_acMsgDir;
    pomDataPtrArr[sHdrColStruct.m_byChannel]      = m_sOutFormattedData.m_acChannel;
    pomDataPtrArr[sHdrColStruct.m_byPriorityPos]  = m_sOutFormattedData.m_acPriority;
    pomDataPtrArr[sHdrColStruct.m_byCodeNamePos]  = m_sOutFormattedData.m_acMsgName;
}
예제 #4
0
/******************************************************************************
    Function Name    :  vGetUpdatedCurrDataPtrArray
    Input(s)         :
    Output           :
    Functionality    :  Provide format data structure pointers to the user
    Member of        :  CMsgContainerLIN
    Friend of        :      -
    Author(s)        :  Anish kumar
    Date Created     :  01.04.2010
******************************************************************************/
void CMsgContainerLIN::vGetUpdatedCurrDataPtrArray(SMSGWNDHDRCOL& sHdrColStruct,
        char* pomDataPtrArr[MAX_MSG_WND_COL_CNT],
        BYTE bExprnFlag_Disp)
{
    //Time mode
    if (IS_TM_ABS_SET(bExprnFlag_Disp)) //for Absolute non-reset timestamp
    {
        pomDataPtrArr[sHdrColStruct.m_byTimePos] = m_sOutFormattedData.m_acTimeAbs;
    }

    else if (IS_TM_REL_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byTimePos] = m_sOutFormattedData.m_acTimeRel;
    }

    else if (IS_TM_SYS_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byTimePos] = m_sOutFormattedData.m_acTimeSys;
    }

    // Dec/Hex mode for DATA and ID
    if (IS_NUM_HEX_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byDataPos] = m_sOutFormattedData.m_acDataHex;
        pomDataPtrArr[sHdrColStruct.m_byIDPos]   = m_sOutFormattedData.m_acMsgIDHex;
    }
    else if (IS_NUM_DEC_SET(bExprnFlag_Disp))
    {
        pomDataPtrArr[sHdrColStruct.m_byDataPos] = m_sOutFormattedData.m_acDataDec;
        pomDataPtrArr[sHdrColStruct.m_byIDPos]   = m_sOutFormattedData.m_acMsgIDDec;
    }

    //Rest will always be same
    pomDataPtrArr[sHdrColStruct.m_byDLCPos]       = m_sOutFormattedData.m_acDataLen;
    pomDataPtrArr[sHdrColStruct.m_byMsgTypePos]   = m_sOutFormattedData.m_acType;
    pomDataPtrArr[sHdrColStruct.m_byRxTxPos]      = m_sOutFormattedData.m_acMsgDir;
    pomDataPtrArr[sHdrColStruct.m_byCodeNamePos]  = m_sOutFormattedData.m_acMsgDesc;
    pomDataPtrArr[sHdrColStruct.m_byChannel]      = m_sOutFormattedData.m_acChannel;
    pomDataPtrArr[sHdrColStruct.m_byChecksumPos]  = m_sOutFormattedData.m_acChecksum;
}
예제 #5
0
void CFormatMsgJ1939::vFormatTime(BYTE bExprnFlag,
                                  PSTJ1939_MSG psJ1939BData,
                                  PSFORMATTEDATA_J1939 psJ1939FData)
{
    BYTE bTmpExprnFlag = bExprnFlag;
    if (IS_TM_ABS_RES(bExprnFlag))//for Absolute reset timestamp
    {
        CLEAR_EXPR_TM_BITS(bTmpExprnFlag);
        SET_TM_ABS_RES(bTmpExprnFlag);
        vCalculateAndFormatTM(bTmpExprnFlag, psJ1939BData->m_sMsgProperties.m_un64TimeStamp,
                              psJ1939FData->m_acTimeAbsReset);
    }
    if (IS_TM_ABS_SET(bExprnFlag))
    {
        CLEAR_EXPR_TM_BITS(bTmpExprnFlag);
        SET_TM_ABS(bTmpExprnFlag);
        vCalculateAndFormatTM(bTmpExprnFlag, psJ1939BData->m_sMsgProperties.m_un64TimeStamp,
                              psJ1939FData->m_acTimeAbs);
    }

    if (IS_TM_REL_SET(bExprnFlag))
    {
        CLEAR_EXPR_TM_BITS(bTmpExprnFlag);
        SET_TM_REL(bTmpExprnFlag);
        vCalculateAndFormatTM(bTmpExprnFlag, psJ1939BData->m_sMsgProperties.m_un64TimeStamp,
                              psJ1939FData->m_acTimeRel);
    }

    if (IS_TM_SYS_SET(bExprnFlag))
    {
        CLEAR_EXPR_TM_BITS(bTmpExprnFlag);
        SET_TM_SYS(bTmpExprnFlag);
        vCalculateAndFormatTM(bTmpExprnFlag, psJ1939BData->m_sMsgProperties.m_un64TimeStamp,
                              psJ1939FData->m_acTimeSys);
    }
}
예제 #6
0
void CFormatMsgCommon::vCalculateAndFormatTM(BYTE bExprnFlag, UINT64 TimeStamp,
        char acTime[])
{
    /* In order to make this function work properly ENSURE bExprnFlag has ONLY
    ONE time mode bit up */

    DWORD dwTSTmp = 0; // temporary time stamp
    UINT64 qwRefSysTime, qwAbsBaseTime;
    m_ouRefTimeKeeper.vGetTimeParams(qwRefSysTime, qwAbsBaseTime);

    if (IS_TM_SYS_SET(bExprnFlag))
    {
        dwTSTmp = (DWORD) ((TimeStamp - qwAbsBaseTime) + qwRefSysTime);
    }
    else if (IS_TM_REL_SET(bExprnFlag))
    {
        if (m_qwRelBaseTime == 0)
        {
            m_qwRelBaseTime = TimeStamp;
        }
        //Time difference should be +ve value
        if(TimeStamp >= m_qwRelBaseTime)
        {
            dwTSTmp = (DWORD) (TimeStamp - m_qwRelBaseTime);
        }
        else
        {
            dwTSTmp = (DWORD) (m_qwRelBaseTime - TimeStamp);
        }

        m_qwRelBaseTime = TimeStamp;
    }
    else if (IS_TM_ABS_SET(bExprnFlag))
    {
        //Time difference should be +ve value
        if(TimeStamp >= qwAbsBaseTime)
        {
            dwTSTmp = (DWORD) (TimeStamp - qwAbsBaseTime);
        }
        else
        {
            dwTSTmp = (DWORD) (qwAbsBaseTime - TimeStamp);
        }

    }
    else if (IS_TM_ABS_RES(bExprnFlag))
    {
        if(m_bResetMsgAbsTime == TRUE)
        {
            //reset the time for new logging session
            SYSTEMTIME LocalCurrTime;
            GetLocalTime(&LocalCurrTime);

            UINT64 RefCurrTime = (LocalCurrTime.wHour * 3600 + LocalCurrTime.wMinute * 60 +
                                  + LocalCurrTime.wSecond) * 10000 + (LocalCurrTime.wMilliseconds * 10);

            UINT64 RefLogTime = (m_LogSysTime.wHour * 3600 + m_LogSysTime.wMinute * 60 +
                                 + m_LogSysTime.wSecond) * 10000 + (m_LogSysTime.wMilliseconds * 10);

            m_qwLogDelayTime = (DWORD)(RefCurrTime - RefLogTime);//for log & msg delay time

            if(TimeStamp >= qwAbsBaseTime)//Time difference should be +ve value
            {
                m_qwResTime = TimeStamp - qwAbsBaseTime;
            }
            else
            {
                m_qwResTime = qwAbsBaseTime - TimeStamp;
            }
            m_bResetMsgAbsTime = FALSE;
        }
        //Time difference should be +ve value
        if(TimeStamp >= (qwAbsBaseTime + m_qwResTime))
        {
            dwTSTmp = (DWORD) (TimeStamp - qwAbsBaseTime - m_qwResTime );
        }
        else
        {
            dwTSTmp = (DWORD) (m_qwResTime + qwAbsBaseTime - TimeStamp );
        }

        dwTSTmp = dwTSTmp + m_qwLogDelayTime; //add msg delay time

    }
    else
    {
        ASSERT(FALSE);
    }

    vFormatTimeStamp(dwTSTmp, acTime);
}
예제 #7
0
void CFormatMsgCommon::vCalculateAndFormatTM(BYTE bExprnFlag, UINT64 TimeStamp, char acTime[], int bufferSize)
{
    UINT64 qwRefSysTime, qwAbsBaseTime;
    m_ouRefTimeKeeper.vGetTimeParams(qwRefSysTime, qwAbsBaseTime);

    /* temporary time stamp */
    DWORD dwTSTmp = 0;
    if (IS_TM_SYS_SET(bExprnFlag))
    {
        dwTSTmp = (DWORD) ((TimeStamp - qwAbsBaseTime) + qwRefSysTime);
    }
    else if (IS_TM_REL_SET(bExprnFlag))
    {
        if (m_qwRelBaseTime == 0)
        {
            m_qwRelBaseTime = TimeStamp;
        }

        /* Time difference should be +ve value */
        if(TimeStamp >= m_qwRelBaseTime)
        {
            dwTSTmp = (DWORD) (TimeStamp - m_qwRelBaseTime);
        }
        else
        {
            dwTSTmp = (DWORD) (m_qwRelBaseTime - TimeStamp);
        }

        m_qwRelBaseTime = TimeStamp;
    }
    else if (IS_TM_ABS_SET(bExprnFlag))
    {
        /* Time difference should be +ve value */
        if(TimeStamp >= qwAbsBaseTime)
        {
            dwTSTmp = (DWORD) (TimeStamp - qwAbsBaseTime);
        }
        else
        {
            dwTSTmp = (DWORD) (qwAbsBaseTime - TimeStamp);
        }

    }
    else if (IS_TM_ABS_RES(bExprnFlag))
    {
        if(m_bResetMsgAbsTime == TRUE)
        {
            /* reset the time for new logging session */
            SYSTEMTIME LocalCurrTime;
            GetLocalTime(&LocalCurrTime);

            UINT64 RefCurrTime =
                LocalCurrTime.wHour         * 36000000 +
                LocalCurrTime.wMinute       *   600000 +
                LocalCurrTime.wSecond       *    10000 +
                LocalCurrTime.wMilliseconds *       10;

            UINT64 RefLogTime =
                m_LogSysTime.wHour         * 36000000 +
                m_LogSysTime.wMinute       *   600000 +
                m_LogSysTime.wSecond       *    10000 +
                m_LogSysTime.wMilliseconds *       10;

            /* for log & msg delay time */
            m_qwLogDelayTime = (DWORD)(RefCurrTime - RefLogTime);

            /* Time difference should be +ve value */
            if(TimeStamp >= qwAbsBaseTime)
            {
                m_qwResTime = TimeStamp - qwAbsBaseTime;
            }
            else
            {
                m_qwResTime = qwAbsBaseTime - TimeStamp;
            }
            m_bResetMsgAbsTime = FALSE;
        }

        /* Time difference should be +ve value */
        if(TimeStamp >= (qwAbsBaseTime + m_qwResTime))
        {
            dwTSTmp = (DWORD) (TimeStamp - qwAbsBaseTime - m_qwResTime );
        }
        else
        {
            dwTSTmp = (DWORD) (m_qwResTime + qwAbsBaseTime - TimeStamp );
        }

        /* add msg delay time */
        dwTSTmp = dwTSTmp + m_qwLogDelayTime;

    }
    else
    {
        ASSERT(false);
    }

    vFormatTimeStamp(dwTSTmp, acTime, bufferSize);
}