Exemple #1
0
/**
 * \brief Populate Tree
 *
 * This function will populate the tree with database
 * messages.
 */
BOOL CMsgSgTreeView::bPopulateTree()
{
    // Insert the database filename as the root item
    //    CMainFrame* pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
    BOOL bReturnValue = TRUE;
    CMsgSignal* pTempMsgSg = NULL;
    pTempMsgSg = *((CMsgSignal**)m_sDbParams.m_ppvActiveDB);
    // Get reference to the tree control
    CTreeCtrl& om_tree = GetTreeCtrl();
    //
    om_tree.DeleteAllItems();
    om_tree.SetTextColor( BLUE_COLOR );
    CString omStrDatabaseFilename = m_omCurrDbName;

    if ( omStrDatabaseFilename.IsEmpty() )
    {
        bReturnValue = FALSE;
        AfxMessageBox(MSG_DB_NOT_FOUND, MB_OK);
    }
    else
    {
        //        om_tree.DeleteAllItems();
        // Insert database filename
        HTREEITEM hRootItem = om_tree.InsertItem( omStrDatabaseFilename );
        om_tree.SetItemImage(hRootItem, 0, 0);
        CStringList omMessageNames;
        // Clean the list
        omMessageNames.RemoveAll();
        // Get all the database message names
        pTempMsgSg->omStrListGetMessageNamesInactive(omMessageNames);
        POSITION pos = omMessageNames.GetHeadPosition();
        BOOL bSelFirstChild = FALSE;

        // Insert all message names
        while ( pos != NULL )
        {
            CString omStrMsgName = omMessageNames.GetNext(pos);
            HTREEITEM hMsg = om_tree.InsertItem( omStrMsgName, hRootItem  );

            if(bSelFirstChild != TRUE )
            {
                om_tree.SelectItem( hMsg );
                bSelFirstChild = TRUE;
            }

            om_tree.SetItemImage(hMsg, 1, 1);
        }

        // Expand the root
        om_tree.Expand( hRootItem, TVE_EXPAND );

        if(bSelFirstChild != TRUE )
        {
            // Select the root item
            om_tree.SelectItem( hRootItem );
        }
    }

    return (bReturnValue);
}
BOOL CValueDescriptionDlg::OnInitDialog()
{
    CDialog::OnInitDialog();
    // Get appropriate msg structure ptr
    CMsgSignal* pTempMsgSg = NULL;
    pTempMsgSg = *((CMsgSignal**)(m_sDbParams.m_ppvActiveDB));

    CString strMinVal = STR_EMPTY;
    CString strMaxVal = STR_EMPTY ;
    BYTE bSignalType;
    if ( pTempMsgSg != NULL )
    {
        pTempMsgSg->vGetSignalValidRange(m_omStrMessageCode,
                                         m_omStrSgName, strMinVal, strMaxVal);

    }
    CString strRange;
    strRange.Format("(Decimal range %s To %s)", strMinVal, strMaxVal);

    GetDlgItem(IDC_STAT_RANGE)->SetWindowText(strRange);

    if ( m_bMode == MD_EDIT )
    {
        m_omStrPrevDesc         = m_omStrDescriptor;
        m_omStrPrevSignalVal    = m_omStrValue;
    }

    return TRUE;  // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
}
Exemple #3
0
/**
 * \brief Add Edit Message
 *
 * Displays message detials dialog to add new message
 * or edit selecetd message base on the parameter passed.
 */
void CMsgSgTreeView::vAddEditMessage(BOOL bMode)
{
    CMsgSignal* pTempMsgSg = NULL;
    CMsgSgDetView* pMsgSgDetView = NULL;
    pTempMsgSg = *((CMsgSignal**)m_sDbParams.m_ppvActiveDB);
    sMESSAGE* pMsg =    NULL;

    // For Edit mode
    if ( bMode == TRUE )
    {
        CTreeCtrl& omTree = GetTreeCtrl();
        HTREEITEM hItem =
            omTree.GetSelectedItem();

        if (hItem != NULL)
        {
            CString omStr = omTree.GetItemText(hItem);
            pMsg =
                pTempMsgSg->psGetMessagePointerInactive( omStr );
        }
    }

    // End Edit mode
    CMessageDetailsDlg odMsgDlg(m_sDbParams, pMsg,NULL);

    if (odMsgDlg.DoModal() == IDOK )
    {
        vSetMessageName(odMsgDlg.m_omStrMessageName);
        vSetTextBold();
        // Get message pointer
        sMESSAGE* pMsg =
            pTempMsgSg->psGetMessagePointerInactive(odMsgDlg.m_omStrMessageName);
        CMainFrame* pMainFrm = static_cast<CMainFrame*> (AfxGetApp()->m_pMainWnd);

        if ( pMainFrm != NULL )
        {
            pMsgSgDetView =
                pMainFrm->podGetMsgSgDetView(m_sDbParams.m_eBus);

            if ( pMsg != NULL && pMsgSgDetView != NULL )
            {
                // check if the controls in the form view are hidden
                if ( pMsgSgDetView->bGetControlStatus() == TRUE )//  TRUE - Hidden
                {
                    // Controls are hidden, unhide
                    pMsgSgDetView->vHideControls(SW_SHOW);
                }

                pMsgSgDetView->vDisplayMsgSgInformation( pMsg );
            }
        }
    }
}
Exemple #4
0
/**
 * \brief On Selection Change
 *
 * Called by the frame work when an item selection is
 * changed. Updates message information on the right pane
 * depending on the selected item
 */
void CMsgSgTreeView::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
    NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
    // TODO: Add your control notification handler code here
    *pResult = 0;
    // check if any data in the form view
    // is missing. If yes,
    // don't let the user to select any item
    // from the tree view
    CMsgSgDetView* pMsgSgDetView = NULL;
    CTreeCtrl& om_tree = GetTreeCtrl();
    sMESSAGE* pMsg = NULL;
    CMsgSignal* pTempMsgSg = NULL;
    pTempMsgSg = *((CMsgSignal**)m_sDbParams.m_ppvActiveDB);
    CMainFrame* pMainFrm = static_cast<CMainFrame*> (AfxGetApp()->m_pMainWnd);

    if ( pMainFrm != NULL )
    {
        pMsgSgDetView =
            pMainFrm->podGetMsgSgDetView(m_sDbParams.m_eBus);

        if ( pMsgSgDetView != NULL)
        {
            if ( pMsgSgDetView->bGetControlStatus() == FALSE )//  TRUE - Hidden
            {
                if (pMsgSgDetView->
                        GetDlgItem(IDC_EDIT_MSG_NAME)->
                        GetWindowTextLength() == 0 )
                {
                    pMsgSgDetView->m_omStrMessageName
                        = m_omSelectedItemText;
                    om_tree.SetItemText( m_hTreeItem,m_omSelectedItemText );
                    pMsgSgDetView->UpdateData(TRUE);
                }

                if ( pMsgSgDetView->
                        GetDlgItem(IDC_EDIT_MSGCODE)->
                        GetWindowTextLength() == 0 )
                {
                    pMsg = pTempMsgSg->psGetMessagePointerInactive(
                               pMsgSgDetView->m_omStrMessageName );

                    if (pMsg != NULL)
                        pMsgSgDetView->m_omStrMessageCode.
                        Format( "%x", pMsg->m_unMessageCode);

                    pMsgSgDetView->UpdateData(TRUE);
                }
            }
        }
    }

    // Get handle to selected item
    HTREEITEM hSelectedItem = pNMTreeView->itemNew.hItem;

    if ( (hSelectedItem != NULL) && (pMsgSgDetView != NULL) )
    {
        if ( !om_tree.ItemHasChildren(hSelectedItem))// only for message names
        {
            CString omStrMsgName = om_tree.GetItemText( hSelectedItem );
            m_omSelectedItemText = omStrMsgName;
            // Get message pointer from the data structure
            // corresponding to the message selected name
            sMESSAGE* pMsg =
                pTempMsgSg->psGetMessagePointerInactive( omStrMsgName );

            if ( pMsg != NULL )
            {
                // check if the controls in the form view are hidden
                if ( pMsgSgDetView->bGetControlStatus() == TRUE )//  TRUE - Hidden
                {
                    // Controls are hidden, unhide
                    pMsgSgDetView->vHideControls(SW_SHOW);
                }

                // Fill the msg signals details for this message
                pMsgSgDetView->vDisplayMsgSgInformation( pMsg );
            }
        }
        else
        {
            // Item is root
            // Hide all controls
            pMsgSgDetView->vHideControls(SW_HIDE);
        }
    }
}
Exemple #5
0
/**
 * \brief On Delete Message
 *
 * Deletes the selected message from the tree view and
 * from the data structure.
 */
void CMsgSgTreeView::OnDeleteMessage()
{
    CTreeCtrl& om_tree = GetTreeCtrl();
    HTREEITEM hItem = om_tree.GetSelectedItem();

    if ( hItem != NULL )
    {
        int nReturnVal = AfxMessageBox(MSG_DELETE_CONFMN, MB_YESNO|MB_ICONQUESTION);

        if ( nReturnVal == IDYES )
        {
            // Delete the message from the data structure
            CString omStrSelecetedText = om_tree.GetItemText(hItem);
            // Get appropriate msg pinter
            CMsgSignal* pTempMsgSg = NULL;
            //CMsgSgDetView* pMsgSgDetView = NULL;
            pTempMsgSg = *((CMsgSignal**)m_sDbParams.m_ppvActiveDB);

            // delete
            if ( !pTempMsgSg->bDeleteMsg( omStrSelecetedText ))
            {
                AfxMessageBox("Could not delete seleceted message!", MB_OK|MB_ICONINFORMATION);
            }
            else
            {
                m_hTreeItem = NULL;
                // Get previous sibbling item
                HTREEITEM hPrevItem = om_tree.GetPrevSiblingItem( hItem );
                // Remove the item from the tree
                om_tree.DeleteItem( hItem );
                CMainFrame* pMainFrm = static_cast<CMainFrame*> (AfxGetApp()->m_pMainWnd);

                if (pMainFrm != NULL)
                {
                    // Get form view pointer
                    CMsgSgDetView* pMsgSgDetView = pMainFrm->podGetMsgSgDetView(m_sDbParams.m_eBus);

                    if (hPrevItem != NULL )
                    {
                        // Select prev item
                        om_tree.SelectItem( hPrevItem );
                        CString omStrPrev = om_tree.GetItemText( hPrevItem );
                        // Get message pointer
                        sMESSAGE* pMsg = pTempMsgSg->
                                         psGetMessagePointerInactive(omStrPrev);

                        if ( pMsg != NULL && pMsgSgDetView != NULL )
                        {
                            pMsgSgDetView->vDisplayMsgSgInformation( pMsg );
                        }
                    }// no message left
                    else
                    {
                        // Select root item
                        om_tree.SelectItem(om_tree.GetRootItem());

                        // check if the controls in the form view are hidden
                        if ( pMsgSgDetView->bGetControlStatus() == FALSE )//  TRUE - Hidden
                        {
                            // Controls are not hidden, hide
                            pMsgSgDetView->vHideControls(SW_HIDE);
                        }
                    }
                }
            }
        }
    }
}
Exemple #6
0
/**
 * \brief On Right Click Tree Item
 *
 * Displays pop up menu depending on the selected item
 */
void CMsgSgTreeView::OnRightClickTreeItem(NMHDR* /*pNMHDR*/, LRESULT* pResult)
{
    UINT uFlags = 0;
    CTreeCtrl& om_Tree = GetTreeCtrl();
    CMenu* m_pomContextMenu = new CMenu;
    HTREEITEM hSelectedItem = om_Tree.HitTest( m_omRightClickPoint, &uFlags );
    CMsgSgDetView* pMsgSgDetView = NULL;
    sMESSAGE* pMsg = NULL;
    CMainFrame* pMainFrm = static_cast<CMainFrame*> (AfxGetApp()->m_pMainWnd);

    if ( pMainFrm != NULL )
    {
        pMsgSgDetView =
            pMainFrm->podGetMsgSgDetView(m_sDbParams.m_eBus);
    }

    if ( uFlags != TVHT_ONITEMICON && uFlags != TVHT_ONITEMLABEL )
    {
        hSelectedItem = NULL ;
    }
    else
    {
        om_Tree.SelectItem( hSelectedItem );
        // Display the selected message details in the
        // right view
        CMsgSignal* pTempMsgSg = NULL;
        pTempMsgSg = *((CMsgSignal**)m_sDbParams.m_ppvActiveDB);

        if ( !om_Tree.ItemHasChildren(hSelectedItem))// only for message names
        {
            CString omStrMsgName = om_Tree.GetItemText( hSelectedItem );
            m_omSelectedItemText = omStrMsgName;

            // Get message pointer from the data structure
            // corresponding to the message selected name
            if ( pMsgSgDetView != NULL )
            {
                pMsg =
                    pTempMsgSg->psGetMessagePointerInactive( omStrMsgName );
            }

            if ( pMsg != NULL )
            {
                // check if the controls in the form view are hidden
                if ( pMsgSgDetView->bGetControlStatus() == TRUE )//  TRUE - Hidden
                {
                    // Controls are hidden, unhide
                    pMsgSgDetView->vHideControls(SW_SHOW);
                }

                // Fill the msg signals details for this message
                pMsgSgDetView->vDisplayMsgSgInformation( pMsg );
            }
        }
        else
        {
            // Item is root
            // Hide all controls
            pMsgSgDetView->vHideControls(SW_HIDE);
        }

        // Get the parent of selected item to identify
        // whether it is a Message name or the root
        HTREEITEM hParentItem = om_Tree.GetParentItem( hSelectedItem );
        // Load the Menu from the resource
        m_pomContextMenu->DestroyMenu();
        m_pomContextMenu->LoadMenu(IDM_MSG_OPN_MENU);
        CMenu* pomSubMenu = m_pomContextMenu->GetSubMenu(0);

        if ( hParentItem == NULL && m_pomContextMenu != NULL ) // Selected item corresponds to root
        {
            pomSubMenu->EnableMenuItem(IDM_NEW_MSG, MF_BYCOMMAND | MF_ENABLED   );
            pomSubMenu->EnableMenuItem(IDM_DELETE_MSG, MF_BYCOMMAND | MF_DISABLED |MF_GRAYED );
            pomSubMenu->EnableMenuItem(IDM_EDIT_MSG, MF_BYCOMMAND | MF_DISABLED |MF_GRAYED );
        }
        else
        {
            pomSubMenu->EnableMenuItem(IDM_NEW_MSG, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
            pomSubMenu->EnableMenuItem(IDM_DELETE_MSG, MF_BYCOMMAND | MF_ENABLED);
            pomSubMenu->EnableMenuItem(IDM_EDIT_MSG, MF_BYCOMMAND | MF_ENABLED);
        }

        ClientToScreen(&m_omRightClickPoint);
        pomSubMenu->TrackPopupMenu( TPM_LEFTALIGN |TPM_RIGHTBUTTON,
                                    m_omRightClickPoint.x,
                                    m_omRightClickPoint.y,
                                    this,
                                    NULL);
    }

    if (m_pomContextMenu != NULL )
    {
        delete m_pomContextMenu;
    }

    *pResult = 0;
}
/*******************************************************************************
  Function Name  : vPopulateElementList
  Input(s)       : -
  Output         : -
  Functionality  : This function will read global element list and will update
                   element UI list control
  Member of      : CSigGrphConfigDlg
  Author(s)      : ArunKumar K
  Date Created   : 27-10-2010
  Modifications  :
*******************************************************************************/
void CSigGrphConfigDlg::vPopulateElementList()
{
    // Get Element List from Main Frame
    CGraphList* podList = NULL;
    // Remove All items in the list
    m_omSignalList.DeleteAllItems();
    // Get List pointer
    podList = &(m_pMainFrame->m_odGraphList[m_omCmbBusType.GetCurSel()]);
    // Get Database Pointer
    CMsgSignal* pomDatabase = theApp.m_pouMsgSignal;
    CGraphElement odTemp;

    if( podList != NULL && pomDatabase != NULL )
    {
        UINT unMsgID = 0;
        CString omStrName;
        int nItemCount  = podList->m_omElementList.GetSize();

        // Add items to the list
        for( int nIndex = 0; nIndex < nItemCount; nIndex++ )
        {
            odTemp = podList->m_omElementList[ nIndex ];

            // Statistics Parameter
            if( odTemp.m_nValueType == eSTAT_PARAM )
            {
                // Insert Category
                m_omSignalList.InsertItem( nIndex, defSTR_STATISTICS_NAME);
                // Insert element name
                m_omSignalList.SetItemText( nIndex, 1,
                                            odTemp.m_omStrElementName );
                // Insert Channel String
                CString omStrChannel;
                omStrChannel.Format( defSTR_CHANNEL_NAME_FORMAT,
                                     defSTR_CHANNEL_NAME,
                                     odTemp.m_nFrameFormat );
                m_omSignalList.SetItemText( nIndex, 2, omStrChannel );
                // Set Color of the entry
                m_omSignalList.SetItemData( nIndex, odTemp.m_nLineColor );
            }
            else
            {
                unMsgID = odTemp.m_nMsgID;
                // Get Message Name
                omStrName =
                    pomDatabase->omStrGetMessageNameFromMsgCode( unMsgID );
                // Add Element Catogory
                m_omSignalList.InsertItem( nIndex, omStrName );
                // Add Element Name
                m_omSignalList.SetItemText( nIndex, 1,
                                            odTemp.m_omStrElementName );
                // Set Color of the entry
                m_omSignalList.SetItemData( nIndex, odTemp.m_nLineColor );

                // Add Value Type
                if( odTemp.m_nValueType == eRAW_VALUE )
                {
                    m_omSignalList.SetItemText( nIndex, 2, defSTR_RAW_VALUE );
                }
                else
                {
                    m_omSignalList.SetItemText( nIndex, 2, defSTR_PHY_VALUE );
                }
            }
        }
    }
}
void CValueDescriptionDlg::OnClickedOk()
{
    UpdateData(TRUE);
    BOOL bRetValue = TRUE;
    // Validate data
    if ( m_omStrValueDescriptor.IsEmpty() == TRUE )
    {
        AfxMessageBox("Signal Description cannot be emtpy!",MB_OK);
        GetDlgItem(IDC_EDIT_VALUE_DESC)->SetFocus();
        bRetValue = FALSE;
    }

    if ( bRetValue == TRUE)
    {
        if ( m_omStrValue.IsEmpty() == TRUE )
        {
            AfxMessageBox("Signal value cannot be emtpy!",MB_OK);
            GetDlgItem(IDC_EDIT_VAL)->SetFocus();
            bRetValue = FALSE;
        }

        if ( bRetValue == TRUE )
        {
            // Get appropriate msg structure ptr
            CMsgSignal* pTempMsgSg = NULL;
            pTempMsgSg = *((CMsgSignal**)(m_sDbParams.m_ppvActiveDB));

            if ( pTempMsgSg != NULL )
            {
                // Check if description is duplicate
                if ( m_omStrPrevDesc != m_omStrValueDescriptor )
                {
                    if(pTempMsgSg->bIsDuplicateValueDescription(m_omStrMessageCode,
                            m_omStrSgName,
                            m_omStrValue,
                            m_omStrValueDescriptor,
                            m_nIndex,
                            m_bMode))
                    {
                        AfxMessageBox("Signal Descriptor already exists!",MB_OK);
                        GetDlgItem(IDC_EDIT_VALUE_DESC)->SetFocus();
                        bRetValue = FALSE;
                    }
                }

                // Check if signal value is duplicate
                if ( bRetValue == TRUE )
                {
                    if ( m_omStrPrevSignalVal  != m_omStrValue )
                    {
                        if ( pTempMsgSg->bIsDuplicateSignalValue(m_omStrMessageCode,
                                m_omStrSgName,
                                m_omStrValue,
                                m_omStrValueDescriptor,
                                m_nIndex,
                                m_bMode))
                        {
                            AfxMessageBox("Signal Value already exists!", MB_OK);
                            GetDlgItem(IDC_EDIT_VAL )->SetFocus();
                            bRetValue = FALSE;
                        }
                    }
                }

                // Check if the signal value is within the range
                if ( bRetValue == TRUE )
                {
                    if (pTempMsgSg->bIsSignalValueOutofRange(m_omStrMessageCode,
                            m_omStrSgName,
                            m_omStrValue ))
                    {
                        AfxMessageBox( MSG_SG_VAL_OUT_OF_RANGE, MB_OK);
                        GetDlgItem(IDC_EDIT_VAL )->SetFocus();
                        bRetValue = FALSE;
                    }

                    if ( bRetValue == TRUE )
                    {
                        // Update the desc into the data structure
                        CSignalDescVal* pNew = new CSignalDescVal;
                        CMainFrame* pMainFrame =
                            static_cast<CMainFrame*> (AfxGetApp()->m_pMainWnd);

                        if ( pNew       != NULL &&
                                pMainFrame != NULL)
                        {
                            CString omStrPrevDesc = STR_EMPTY;
                            if ( MD_ADD == m_bMode )
                            {
                                // new desc and val hence allocate memory
                                pTempMsgSg->bAddSgDescVal( m_omStrMessageCode,
                                                           m_omStrSgName );
                            }
                            // convert string to int
                            pNew->m_n64SignalVal =
                                pMainFrame->nConvertStringToInt( m_omStrValue );
                            pNew->m_omStrSignalDescriptor =
                                m_omStrValueDescriptor;
                            if (MD_EDIT == m_bMode)
                            {
                                //m_omStrPrevDesc = m_omStrValueDescriptor;
                            }
                            // update the edited values to the data structure
                            if ( !pTempMsgSg->bUpdateSgDescVal( m_omStrMessageCode,
                                                                m_omStrSgName,
                                                                m_omStrPrevDesc,
                                                                pNew ))
                            {
                                AfxMessageBox("Could not update...",
                                              MB_OK|MB_ICONINFORMATION);
                            }
                            // clean up
                            delete pNew;
                            pNew = NULL;
                            CDialog::OnOK();
                        }
                    }
                }
            }
        }
    }
}
void CValueDescriptionDlg::OnClickedOk()
{
    UpdateData(TRUE);
    BOOL bRetValue = TRUE;
    BOOL bModifiedFlag = FALSE;
    // Validate data
    if ( m_omStrDescriptor.IsEmpty() == TRUE )
    {
        AfxMessageBox("Signal Description cannot be emtpy!",MB_OK);
        GetDlgItem(IDC_EDIT_VALUE_DESC)->SetFocus();
        bRetValue = FALSE;
    }

    if ( bRetValue == TRUE)
    {
        if ( m_omStrValue.IsEmpty() == TRUE )
        {
            AfxMessageBox("Signal value cannot be emtpy!",MB_OK);
            GetDlgItem(IDC_EDIT_VAL)->SetFocus();
            bRetValue = FALSE;
        }

        if ( bRetValue == TRUE )
        {
            // Get appropriate msg structure ptr
            CMsgSignal* pTempMsgSg = NULL;
            pTempMsgSg = *((CMsgSignal**)(m_sDbParams.m_ppvActiveDB));

            if ( pTempMsgSg != NULL )
            {
                // Check if description is duplicate
                if ( m_omStrPrevDesc != m_omStrDescriptor )
                {
                    if(pTempMsgSg->bIsDuplicateValueDescription(m_omStrMessageCode,
                            m_omStrSgName,
                            m_omStrValue,
                            m_omStrDescriptor,
                            m_nIndex,
                            m_bMode))
                    {
                        AfxMessageBox("Signal Descriptor already exists!",MB_OK);
                        GetDlgItem(IDC_EDIT_VALUE_DESC)->SetFocus();
                        bRetValue = FALSE;
                    }
                }

                // Check if signal value is duplicate
                if ( bRetValue == TRUE )
                {
                    if ( m_omStrPrevSignalVal  != m_omStrValue )
                    {
                        if ( pTempMsgSg->bIsDuplicateSignalValue(m_omStrMessageCode,
                                m_omStrSgName,
                                m_omStrValue,
                                m_omStrDescriptor,
                                m_nIndex,
                                m_bMode))
                        {
                            AfxMessageBox("Signal Value already exists!", MB_OK);
                            GetDlgItem(IDC_EDIT_VAL )->SetFocus();
                            bRetValue = FALSE;
                        }
                    }
                }

                // Check if the signal value is within the range
                if ( bRetValue == TRUE )
                {
                    if (pTempMsgSg->bIsSignalValueOutofRange(m_omStrMessageCode,
                            m_omStrSgName,
                            m_omStrValue ))
                    {
                        AfxMessageBox( MSG_SG_VAL_OUT_OF_RANGE, MB_OK);
                        GetDlgItem(IDC_EDIT_VAL )->SetFocus();
                        bRetValue = FALSE;
                    }

                    //check the value is changed or not
                    if (bIsDataModified()&&( bRetValue == TRUE ))
                    {
                        bModifiedFlag = TRUE;
                        // Update the desc into the data structure
                        CSignalDescVal* pNew = new CSignalDescVal;
                        //                      CMainFrame* pMainFrame =
                        //                          static_cast<CMainFrame*> (AfxGetApp()->m_pMainWnd);

                        if (pNew != NULL)
                        {
                            CString omStrPrevDesc = STR_EMPTY;
                            if ( MD_ADD == m_bMode )
                            {
                                // new desc and val hence allocate memory
                                pTempMsgSg->bAddSgDescVal( m_omStrMessageCode,
                                                           m_omStrSgName );
                            }
                            //                              pNew->m_n64SignalVal = _strtoi64( m_omStrValue, NULL, 10);
                            if(bSignalType.CompareNoCase(defSIGNED_INT) == 0)
                            {
                                pNew->m_DescValue.n64Value = _strtoi64( m_omStrValue, NULL, 10);
                            }
                            else
                            {
                                pNew->m_DescValue.un64Value = _strtoui64( m_omStrValue, NULL, 10);
                            }

                            //                              // convert string to int
                            //                              pNew->m_n64SignalVal = pMainFrame->nConvertStringToInt( m_omStrValue );
                            pNew->m_omStrSignalDescriptor = m_omStrDescriptor;

                            if (MD_EDIT == m_bMode)
                            {
                                m_omStrPrevDesc = m_omStrDescriptor;
                            }
                            // update the edited values to the data structure
                            if ( !pTempMsgSg->bUpdateSgDescVal( m_omStrMessageCode,
                                                                m_omStrSgName,
                                                                m_omStrPrevDesc,
                                                                pNew ))
                            {
                                AfxMessageBox("Could not update...",
                                              MB_OK|MB_ICONINFORMATION);
                                bRetValue = FALSE;
                            }
                            // clean up
                            delete pNew;
                            pNew = NULL;
                        }
                    }
                }
            }
        }
    }

    if(bRetValue == TRUE)//no error occurs
    {
        if(bModifiedFlag == TRUE)//some modification done
        {
            CDialog::OnOK();
        }
        else //no modification
        {
            CDialog::OnCancel();
        }
    }
}
Exemple #10
0
void CTxMsgListView::vUpdateMsgListDisplay(sTXCANMSGDETAILS sMsgDetail,
        INT nCurrentIndex)
{
    CString omStrMsgID( "" );
    CString omStrMsgData( "" );
    CString omStrMsgType( "" );
    CString omStrDLC( "" );
    CString omStrChannel( "" );
    INT nIndex           = -1;
    UINT unImageID       = 0;
    CString omStrFormat( "" );
    CString omStrMsgName( "" );
    // Set Edit flag to TRUE
    m_bInitDlg = TRUE;

    // format the message data length
    // Get the base and accordingly change the format for Format function of
    // CString class.
    if( TRUE == CTxMsgManager::s_TxFlags.nGetFlagStatus(TX_HEX) )
    {
        omStrMsgID.Format(defFORMAT_MSGID_HEX,sMsgDetail.m_sTxMsg.m_unMsgID);
        omStrFormat = defFORMAT_DATA_HEX;
    }
    else
    {
        omStrMsgID.Format( defFORMAT_MSGID_DECIMAL,
                           sMsgDetail.m_sTxMsg.m_unMsgID );
        omStrFormat = defFORMAT_DATA_DECIMAL;
    }    // Message Details View
    CTxMsgDetailsView* pomDetailsView = nullptr;
    CMsgSignal* pDBptr = nullptr;
    pomDetailsView = (CTxMsgDetailsView*)pomGetDetailsViewPointer();
    if (nullptr != pomDetailsView)
    {
        pDBptr =  pomDetailsView->m_pouDBPtr;
    }
    CString omStrUpdatedMsgLength = "";
    // See if the msg ID is in the database
    // If yes load appropriate image
    if (nullptr != pDBptr)
    {
        omStrMsgName =
            pDBptr->omStrGetMessageNameFromMsgCode(sMsgDetail.m_sTxMsg.m_unMsgID);
        //omStrUpdatedMsgLength = pDBptr->omStrGetMessageLengthFromMsgCode(sMsgDetail.m_sTxMsg.m_unMsgID);
    }
    if ( omStrMsgName.IsEmpty() == FALSE )
    {
        unImageID = 1;// Database Image
        // Add message Name with the entry
        omStrMsgID += " [" +
                      pDBptr->omStrGetMessageNameFromMsgCode(sMsgDetail.m_sTxMsg.m_unMsgID )
                      + "]";
    }
    else
    {
        unImageID = 2;// Non-Database image
    }

    // Format channel ID
    omStrChannel.Format("%d", sMsgDetail.m_sTxMsg.m_ucChannel );

    // Format Message Type
    omStrFormat.Insert(omStrFormat.GetLength(),defEMPTY_CHAR);
    CString omStrTemp = "";

    for(INT i=0; i<sMsgDetail.m_sTxMsg.m_ucDataLen; i++)
    {
        omStrTemp.Format(omStrFormat,sMsgDetail.m_sTxMsg.m_ucData[i]);
        omStrMsgData +=  omStrTemp;
    }
    // Format the Message type
    if(sMsgDetail.m_sTxMsg.m_ucEXTENDED == TRUE)
    {
        omStrMsgType = defMSGID_EXTENDED;
    }
    else
    {
        omStrMsgType = defMSGID_STD;
    }
    if(sMsgDetail.m_sTxMsg.m_ucRTR == TRUE)
    {
        omStrMsgType += defMSGID_RTR;
    }
    // Format the DLC
    omStrDLC.Format("%d",sMsgDetail.m_sTxMsg.m_ucDataLen);
    // Get the current count if this is new items and insert it
    // as new item. Otherwise set the current item text.
    if(nCurrentIndex == -1)
    {
        INT nCount = m_omLctrMsgList.GetItemCount();
        if(nCount != -1 )
        {
            nIndex = m_omLctrMsgList.
                     InsertItem(nCount,omStrMsgID,unImageID);
        }
    }
    else
    {
        LVITEM sItem;
        sItem.mask      = LVIF_IMAGE;
        sItem.iItem     = nCurrentIndex;
        sItem.iSubItem  = defMAIN_ITEM;
        sItem.iImage    = unImageID;
        m_omLctrMsgList.
        SetItemText(nCurrentIndex,defMAIN_ITEM,omStrMsgID);
        m_omLctrMsgList.SetItem(&sItem);
        nIndex = nCurrentIndex;
    }
    // Set the list control item with string formatted for each column.
    if(nIndex != -1 )
    {
        // Update Channel ID
        m_omLctrMsgList.SetItemText( nIndex,
                                     defSUBITEM_MSGDETAILS_CHANNEL_ID,
                                     omStrChannel );
        // Update Message Type
        m_omLctrMsgList.SetItemText( nIndex,
                                     defSUBITEM_MSGDETAILS_TYPE,
                                     omStrMsgType );
        // Update Message Length
        m_omLctrMsgList.SetItemText( nIndex,
                                     defSUBITEM_MSGDETAILS_DLC,
                                     omStrDLC );
        // Update Data Bytes with Dirty Flag
        if( sMsgDetail.m_bIsMsgDirty == TRUE &&
                unImageID == 1 &&
                sMsgDetail.m_sTxMsg.m_ucDataLen > 0 )
        {
            omStrMsgData +=defASSETRIC;
        }
        m_omLctrMsgList.SetItemText( nIndex,
                                     defSUBITEM_MSGDETAILS_DATA,
                                     omStrMsgData);
        // Update Check box status
        m_omLctrMsgList.SetCheck( nIndex, sMsgDetail.m_bEnabled );
    }

    // Set Edit flag to FALSE
    m_bInitDlg = FALSE;
}