コード例 #1
0
/*******************************************************************************
 Function Name  : n64GetPos
 Input(s)       :   -
 Output         : __int64 - 64 bit int value of for the text box
 Functionality  : This method get the current 64 bit int value of the spin
                  button.
 Member of      : CNumSpinCtrl
 Friend of      :
 Author(s)      : Raja N
 Date Created   : 30.07.2004
 Modifications  :
*******************************************************************************/
__int64 CNumSpinCtrl::n64GetPos()
{
    __int64 n64Val = 0;
    // Get the text control first to get the value
    CWnd* pomEdit = GetBuddy();
    // If the buddy is set then proceed
    if (pomEdit != NULL )
    {
        CString omStrText;
        // Get the text
        pomEdit->GetWindowText (omStrText);
        // This can be used for both decimal and hex mode. So base check is not
        // required
        // Convert the text in to 64bit integer
        BOOL bSuccess =
            bConvertStringToInt64( omStrText,n64Val, GetBase());
        // Set the default value here incase of failure
        if( bSuccess == FALSE )
        {
            n64Val = 0;
        }
        // Extend the sign bit to get the actual value
        // If the value before is FF ( that is -1 )and data length is 8 bits
        // after extending the sign bit this will become FFFFFFFFFFFFFFFF
        // which is again -1 but the length is 64 bits
        if( m_bSigned == TRUE )
        {
            vExtendSignBit( n64Val, m_nDataLength);
        }
    }
    // Return calculated value
    return n64Val;
}
コード例 #2
0
void ITxFormView::vOnSignalItemChanged(int nRow, int nColumn)
{
    if (nullptr == m_pouTxDataStore)
    {
        return;
    }

    CString omStrSigName = m_omLctrSigList.GetItemText(nRow, eSigColName);
    ITxMsgItem* pouMsgItem = nullptr;
    int nIndex = m_lstMsg.GetSelectionMark();
    if (-1 == nIndex)
    {
        return;
    }

    m_pouTxDataStore->GetMsgItem(nIndex, pouMsgItem);

    if (nullptr == pouMsgItem)
    {
        return;
    }
    SIG_DETAILS ouSignalDetails;
    pouMsgItem->GetSignal(m_pouIBMNetwork, m_bHexMode,std::string(omStrSigName), ouSignalDetails);

    // If it is a valid signal
    if (ouSignalDetails.Signal.first != nullptr)
    {
        // Get the Signal Raw Value
        CString omStr = m_omLctrSigList.GetItemText(nRow, nColumn);
        unsigned __int64 un64Min, un64Max;
        unsigned __int64 unI64RawValue = 0;
        __int64 nI64TempRawValue;
        double dwPhyVal = 0;
        int nBase = m_bHexMode ? defBASE_HEX : defBASE_DEC;


        switch (nColumn)
        {
            case eSigColPhyVal:
                dwPhyVal = atof(omStr);
                ouSignalDetails.Signal.first->GetRawValueFromEng(dwPhyVal, unI64RawValue);
                break;
            case eSigColRawVal:
                bConvertStringToInt64(omStr, nI64TempRawValue, nBase);
                unI64RawValue = nI64TempRawValue;
                break;
        }

        ouSignalDetails.Signal.first->GetMinMaxValue(un64Min, un64Max);

        eSignalDataType eDataType = eUnsigned;
        ouSignalDetails.Signal.first->GetDataType(eDataType);
        if (eUnsigned == eDataType)
        {
            GetRawValueInRange<unsigned __int64>(unI64RawValue, un64Min, un64Max);
        }
        else if (eSigned == eDataType)
        {
            unsigned int unSiglength = 0;
            ouSignalDetails.Signal.first->GetLength(unSiglength);
            __int64 nI64RawValue = static_cast<__int64>(FormatValue(eSigned,unSiglength,unI64RawValue));
            __int64 n64Min = static_cast<__int64>(un64Min);
            __int64 n64Max = static_cast<__int64>(un64Max);
            GetRawValueInRange<__int64>(nI64RawValue, n64Min, n64Max);
            unI64RawValue = static_cast<unsigned __int64>(nI64RawValue);
        }

        vGetDataBytesFromSignal(unI64RawValue, ouSignalDetails.Signal, pouMsgItem->MsgDetails.nDLC, pouMsgItem->MsgDetails.pchData);

        m_pouTxDataStore->SetMsgItem(nIndex, pouMsgItem);

        std::list<SIG_DETAILS> lstSignalDetails;
        pouMsgItem->GetSignalList(m_pouIBMNetwork, m_bHexMode,lstSignalDetails);
        UpdateDataAndSignalView(pouMsgItem->MsgDetails.pchData, pouMsgItem->MsgDetails.nDLC, lstSignalDetails);
    }
}