コード例 #1
0
ファイル: TxFunctionsView.cpp プロジェクト: bagge/busmaster
/*******************************************************************************
 Function Name    : vApplyChanges
 Input(s)         :
 Output           :
 Functionality    : This function is used to apply changes in the global shared
                    memory
 Member of        : CTxFunctionsView
 Friend of        :  -
 Author(s)        : Raja N
 Date Created     : 19.07.2004
 Modification By  :
 Modification on  :
*******************************************************************************/
void CTxFunctionsView::vApplyChanges()
{
    // Get Other view pointers
    CTxMsgBlocksView* pomBlockView = NULL;
    CTxMsgListView* pomListView = NULL;
    pomBlockView = (CTxMsgBlocksView*)pomGetBlocksViewPointer();
    pomListView = (CTxMsgListView* )pomGetListViewPointer();

    if( pomBlockView != NULL && pomListView != NULL )
    {
        PSMSGBLOCKLIST psMsgBlock = NULL;
        psMsgBlock = pomBlockView->psGetMsgBlockPointer(
                         pomBlockView->m_nSelectedMsgBlockIndex,
                         pomBlockView->m_psMsgBlockList );
        // Update the last selected message block details in case user has
        // modified it.
        if(psMsgBlock != NULL )
        {
            pomBlockView->vUpdateMsgBlockDetials(psMsgBlock);
            psMsgBlock->m_bModified = true;
        }

        // Set the value in configuration class.
        CTxWndDataStore::ouGetTxWndDataStoreObj().bSetTxData( TX_MSG_BLOCK_COUNT,
                (void*)&(pomBlockView->m_unMsgBlockCount) );
        // Data is set only if messagae block count is more then zero.
        if( pomBlockView->m_unMsgBlockCount > 0 )
        {
            CTxWndDataStore::ouGetTxWndDataStoreObj().bSetTxData( TX_MSG_UPDATE,
                    (void*)(pomBlockView->m_psMsgBlockList) );
            // Allocate memory for globle list
            BOOL bAllocateMemory =
                CTxMsgManager::s_podGetTxMsgManager()->bAllocateMemoryForGlobalTxList();
            // Update Message List
            if(bAllocateMemory == TRUE )
            {
                CTxMsgManager::s_podGetTxMsgManager()->vAssignMsgBlockList();
            }
        }
        //Save Window position
        CTxMsgChildFrame* pTxWnd = (CTxMsgChildFrame*)pomGetParentWindow();
        // Update view pointer
        if( pTxWnd != NULL )
        {
            // Register this view pointer
            pTxWnd->vUpdateWndCo_Ords();

        }
        /* CString                     csTimeDelay;
         ((CEdit*)pomBlockView->GetDlgItem(IDC_EDIT_BLOCK_TRG_TIMER_VAL))->GetWindowTextA(csTimeDelay);
         CTxMsgManager::s_unTimeDelayBtnMsgBlocks = atol(csTimeDelay.GetBuffer(0));*/
    }
}
コード例 #2
0
void CTxFunctionsView::OnInvokeClose()
{
    CTxMsgBlocksView* pBlocksView = (CTxMsgBlocksView*)pomGetBlocksViewPointer();
    bool        bUnChanged = true;

    if(m_CheckBoxAutoUpdate.GetCheck() == BST_CHECKED)  //setting will already be saved so exit
    {
        return;
    }
    if(pBlocksView != NULL)
    {

        PSMSGBLOCKLIST psMsgBlock = NULL;
        psMsgBlock = pBlocksView->psGetMsgBlockPointer(
                         0,
                         pBlocksView->m_psMsgBlockList );

        if(psMsgBlock != NULL)
        {
            bUnChanged = CTxWndDataStore::ouGetTxWndDataStoreObj().nCompareBlockLists(psMsgBlock);
            if(pBlocksView->m_bDelayBtnBlocks != CTxWndDataStore::ouGetTxWndDataStoreObj().m_bDelayBetweenMsgBlocks)
            {
                bUnChanged = false;
            }
            CString  omstrData;
            pBlocksView->m_omTimeDelayBtwnBlocks.GetWindowTextA(omstrData);
            if(atoi(omstrData.GetBuffer(0)) != CTxWndDataStore::ouGetTxWndDataStoreObj().m_unTimeDelayBtwnMsgBlocks)
            {
                bUnChanged = false;
            }
        }
        else if(CTxWndDataStore::ouGetTxWndDataStoreObj().psReturnMsgBlockPointer()!= NULL)
        {
            bUnChanged = false;
        }
        if(bUnChanged == true)
        {
            return;
        }
    }

    if( bUnChanged == false)            //if there are any changes, then save it.
    {
        if( AfxMessageBox( defSTR_TX_SAVE_CONFIRMATION,
                           MB_YESNO | MB_ICONQUESTION ) == IDYES )
        {
            // Save Changes
            OnButtonApply();
        }
    }
}
コード例 #3
0
ファイル: TxMsgListView.cpp プロジェクト: sgnes/busmaster
void CTxMsgListView::OnDeleteAllMsg()
{
    CTxMsgBlocksView* pomBlocksView = nullptr;
    pomBlocksView = ( CTxMsgBlocksView*)pomGetBlocksViewPointer();

    CTxMsgDetailsView* pomDetailsView = nullptr;
    pomDetailsView = (CTxMsgDetailsView*)pomGetDetailsViewPointer();

    CTxFunctionsView* pomFunctionsView = nullptr;
    pomFunctionsView = (CTxFunctionsView*)pomGetFunctionsViewPointer();

    if( pomBlocksView != nullptr && pomDetailsView != nullptr &&
            pomFunctionsView != nullptr )
    {
        // give a warning message before deleting it.
        if ( AfxMessageBox( _(defDEL_ALL_MSG_FRAME),
                            MB_YESNO|MB_ICONQUESTION) == IDYES)
        {
            // check for valid message block selection index.
            if( pomBlocksView->m_nSelectedMsgBlockIndex != -1)
            {
                BOOL bDeleted = FALSE;
                PSMSGBLOCKLIST psMsgCurrentBlock = nullptr;
                // Get the current message block pointer.
                psMsgCurrentBlock = pomBlocksView->psGetMsgBlockPointer(
                                        pomBlocksView->m_nSelectedMsgBlockIndex,
                                        pomBlocksView->m_psMsgBlockList );
                if(psMsgCurrentBlock != nullptr )
                {
                    // Call function to delete all message and clear the list
                    // control if the delete is successfull.
                    bDeleted = bDeleteAllMsgFromBlock(psMsgCurrentBlock);
                    if(bDeleted == TRUE )
                    {
                        m_omLctrMsgList.DeleteAllItems();
                        //Disable Delete All button
                        m_omButtonDeleteAllMsg.EnableWindow(FALSE);
                        m_omButtonDeleteSelMsg.EnableWindow(FALSE);

                        if(pomFunctionsView->m_CheckBoxAutoUpdate.GetCheck() == BST_UNCHECKED)
                        {
                            pomFunctionsView->m_omButtonApply.EnableWindow(TRUE);
                        }
                        // Update Add button status
                        pomDetailsView->vEnableAddButton( TRUE );
                        // Update Modified Flag
                        pomBlocksView->m_bModified = TRUE;
                    }
                    m_omButtonSendMsg.EnableWindow(FALSE);

                    //changes added to update the Global in case of autoupdate
                    CTxFunctionsView* pView =
                        ( CTxFunctionsView* )pomGetFunctionsViewPointer();
                    if( pView != nullptr )
                    {
                        if(pView->m_CheckBoxAutoUpdate.GetCheck() == BST_CHECKED)
                        {
                            pView->vAccessButtonApply();
                            this->SetFocus();
                        }
                    }
                }
            }
        }
    }
}
コード例 #4
0
ファイル: TxMsgListView.cpp プロジェクト: sgnes/busmaster
void CTxMsgListView::OnDeleteSelectedMsg()
{
    CTxMsgBlocksView* pomBlocksView = nullptr;
    pomBlocksView = ( CTxMsgBlocksView*)pomGetBlocksViewPointer();

    CTxMsgDetailsView* pomDetailsView = nullptr;
    pomDetailsView = (CTxMsgDetailsView*)pomGetDetailsViewPointer();

    CTxFunctionsView* pomFunctionsView = nullptr;
    pomFunctionsView = (CTxFunctionsView*)pomGetFunctionsViewPointer();

    if( pomBlocksView != nullptr && pomDetailsView != nullptr &&
            pomFunctionsView != nullptr )
    {
        if ( AfxMessageBox( _(defDEL_SEL_MSG_FRAME),
                            MB_YESNO|MB_ICONQUESTION) == IDYES)
        {
            if(m_nSelectedMsgIndex != -1)
            {
                if(pomBlocksView->m_nSelectedMsgBlockIndex != -1 )
                {
                    PSMSGBLOCKLIST psCurrentMsgBlock = nullptr;
                    psCurrentMsgBlock = pomBlocksView->psGetMsgBlockPointer(
                                            pomBlocksView->m_nSelectedMsgBlockIndex,
                                            pomBlocksView->m_psMsgBlockList);

                    if(psCurrentMsgBlock != nullptr )
                    {
                        BOOL bReturn = FALSE;
                        bReturn = bDeleteMsgFromBlock(psCurrentMsgBlock);
                        if(bReturn == TRUE )
                        {
                            if(pomFunctionsView->m_CheckBoxAutoUpdate.GetCheck() == BST_UNCHECKED)
                                pomFunctionsView->m_omButtonApply.
                                EnableWindow(TRUE);

                            pomDetailsView->vEnableAddButton( TRUE );
                            // Update Modified Flag
                            pomBlocksView->m_bModified = TRUE;
                        }
                        // Set the focus to list control back if it is not empty
                        // Shift the selection to item under fucus as selection
                        // deos not move up if an selected item is deleted.
                        m_nSelectedMsgIndex =
                            m_omLctrMsgList.GetNextItem(-1,LVIS_FOCUSED);
                        if(m_nSelectedMsgIndex != -1 )
                        {
                            m_omLctrMsgList.SetItemState(
                                m_nSelectedMsgIndex,
                                LVIS_SELECTED,
                                LVIS_SELECTED);
                        }
                        //changes added to update the Global in case of autoupdate
                        CTxFunctionsView* pView =
                            ( CTxFunctionsView* )pomGetFunctionsViewPointer();
                        if( pView != nullptr )
                        {
                            if(pView->m_CheckBoxAutoUpdate.GetCheck() == BST_CHECKED)
                            {
                                pView->vAccessButtonApply();
                                /*this->SetFocus();*/
                                m_omLctrMsgList.SetFocus();
                            }
                        }

                    }
                }
            }
        }
    }
}
コード例 #5
0
ファイル: TxMsgListView.cpp プロジェクト: sgnes/busmaster
void CTxMsgListView::OnSendSelectedMsg()
{
    PSTXSELMSGDATA psTxCanMsg = nullptr;
    UINT unTotalSelection = m_omLctrMsgList.GetSelectedCount();

    CTxMsgBlocksView* pomBlocksView = nullptr;
    pomBlocksView = ( CTxMsgBlocksView*)pomGetBlocksViewPointer();
    if( pomBlocksView != nullptr )
    {
        // Get the total selected count.
        if(unTotalSelection > 0 )
        {
            // create the pointer and check if it has created successfully.
            psTxCanMsg  = new STXSELMSGDATA;
            if(psTxCanMsg != nullptr )
            {
                // Fill the structure and create memory for array of message
                // frame to be transmitted.
                psTxCanMsg->m_unCount = unTotalSelection;
                psTxCanMsg->m_psTxMsg = new STCAN_MSG[unTotalSelection];
                if(psTxCanMsg->m_psTxMsg != nullptr )
                {
                    // get the current message block
                    PSMSGBLOCKLIST psMsgBlock = nullptr;
                    psMsgBlock = pomBlocksView->psGetMsgBlockPointer(
                                     pomBlocksView->m_nSelectedMsgBlockIndex,
                                     pomBlocksView->m_psMsgBlockList );
                    if(psMsgBlock != nullptr )
                    {
                        PSTXCANMSGLIST  psTxMsgList = nullptr;
                        INT nCurrentIndex           = -1;
                        // Get the message which is selected for transmission
                        // Since selection may be random so get the selection
                        // index one by one and get the pointer for that message
                        // frame . After that copy it to the structure.
                        for(UINT i =0 ; i<unTotalSelection; i++)
                        {
                            nCurrentIndex = m_omLctrMsgList.GetNextItem(
                                                nCurrentIndex,
                                                LVNI_SELECTED );
                            // If failure to get the index then assign Invalid
                            // message ID to avoid any problem in transmission.
                            if(nCurrentIndex != -1 )
                            {
                                psTxMsgList = psGetMsgDetailPointer (
                                                  nCurrentIndex,
                                                  psMsgBlock );
								updateRollingCntCheckSum(psTxMsgList);
                                if(psTxMsgList != nullptr )
                                {
                                    memcpy( &(psTxCanMsg->m_psTxMsg[i]),
                                            &(psTxMsgList->m_sTxMsgDetails.m_sTxMsg),
                                            sizeof(STCAN_MSG) );
                                }
                                else
                                {
                                    psTxCanMsg->m_psTxMsg[i].m_unMsgID =
                                        static_cast <UINT> (-1);
                                }
                            }
                            else
                            {
                                psTxCanMsg->m_psTxMsg[i].m_unMsgID =
                                    static_cast <UINT> (-1 );
                            }
                        }
                        g_bStopSelectedMsgTx = FALSE;
                        // Get handle of thread and assign it to pulic data
                        // member in app class. This will be used to terminate
                        // the thread.
                        CWinThread* pomThread = nullptr ;
                        pomThread =
                            AfxBeginThread( CTxMsgManager::s_unSendSelectedMsg,
                                            psTxCanMsg );
                        if(pomThread != nullptr  &&
                                CTxMsgManager::s_sUtilThread.m_hThread
                                == nullptr )
                        {
                            CTxMsgManager::s_sUtilThread.m_hThread
                                = pomThread->m_hThread;
                        }
                    }
                }
            }
        }
    }
}
コード例 #6
0
ファイル: TxMsgListView.cpp プロジェクト: sgnes/busmaster
void CTxMsgListView::OnItemchangedLstcMsgDetails(NMHDR* pNMHDR,
        LRESULT* pResult)
{
    NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;

    CTxMsgBlocksView* pomBlocksView = nullptr;
    pomBlocksView = ( CTxMsgBlocksView*)pomGetBlocksViewPointer();
    if( pomBlocksView != nullptr && m_bInitDlg == FALSE )
    {
        // Get new state of the list control items
        // and check for if it is selected and focused.
        UINT unCurrentState = pNMListView->uNewState & defMASK_LIST_CTRL;
        if(pNMListView->uNewState & (LVIS_FOCUSED|LVIS_SELECTED) )
        {
            if((TRUE == CTxMsgManager::s_TxFlags.nGetFlagStatus(TX_CONNECTED)) && (pNMListView->uNewState & LVIS_SELECTED))
                //&& (pNMListView->uNewState&LVIS_FOCUSED))
            {
                m_omButtonSendMsg.EnableWindow(TRUE);
            }
            if(FALSE == CTxMsgManager::s_TxFlags.nGetFlagStatus(TX_SENDMESG))
            {
                m_omButtonDeleteSelMsg.EnableWindow(!CTxMsgManager::s_TxFlags.nGetFlagStatus(TX_SENDMESG));
                m_omButtonDeleteAllMsg.EnableWindow(!CTxMsgManager::s_TxFlags.nGetFlagStatus(TX_SENDMESG));

            }
        }
        else if(pNMListView->uChanged == LVIF_STATE)
        {

            //Check for the count
            UINT unCount = m_omLctrMsgList.GetItemCount();
            if ( unCount <= 0)
            {
                m_omButtonDeleteAllMsg.EnableWindow(FALSE);
            }
            if(!(pNMListView->uNewState & defMASK_CHECK_UNCHECK))
            {
                m_omButtonSendMsg.EnableWindow(FALSE);
                m_omButtonDeleteSelMsg.EnableWindow(FALSE);
            }
        }
        if( pNMListView->uChanged  == LVIF_STATE )
        {
            PSTXCANMSGLIST   psTxMsgList = nullptr ;
            PSMSGBLOCKLIST    psMsgBlock = nullptr ;
            // check if the item is focused and selected.
            unCurrentState =
                pNMListView->uNewState &(LVIS_FOCUSED |LVIS_SELECTED);
            psMsgBlock = pomBlocksView->psGetMsgBlockPointer(
                             pomBlocksView->m_nSelectedMsgBlockIndex,
                             pomBlocksView->m_psMsgBlockList );
            // If yes, update message information for newly selected item.
            if(unCurrentState != FALSE)
            {
                psTxMsgList = psGetMsgDetailPointer( pNMListView->iItem,
                                                     psMsgBlock );
                m_nSelectedMsgIndex = pNMListView->iItem;
                if(psTxMsgList != nullptr )
                {
                    CTxMsgDetailsView* pView = (CTxMsgDetailsView*)
                                               pomGetDetailsViewPointer();
                    if( pView != nullptr )
                    {
                        pView->vSetValues((psTxMsgList));
                        // Insert Signal List Update Code Here
                        pView->bUpdateSignalList(
                            psTxMsgList->m_sTxMsgDetails.m_sTxMsg );
                        pView->vEnableAddButton( TRUE );
                        // Clear error message if any
                        pView->bSetStatusText("");
                        psMsgBlock->m_bModified = true;
                    }
                }
            }
            else
            {
                m_nSelectedMsgIndex = -1;
            }
        }
        if( pNMListView->uNewState & defMASK_CHECK_UNCHECK )
        {
            PSTXCANMSGLIST   psTxMsgList = nullptr ;
            PSMSGBLOCKLIST    psMsgBlock = nullptr ;

            psMsgBlock = pomBlocksView->psGetMsgBlockPointer(
                             pomBlocksView->m_nSelectedMsgBlockIndex,
                             pomBlocksView->m_psMsgBlockList );

            psTxMsgList = psGetMsgDetailPointer(pNMListView->iItem,psMsgBlock);
            m_nSelectedMsgIndex = pNMListView->iItem ;
            //pNMListView->uNewState =  (LVIS_FOCUSED|LVIS_SELECTED);
            //Ashwin changes for selecting the item during unchecking
            int     nChecked = 0, nUnCkecked = 0;
            for(int nCnt =0; nCnt< m_omLctrMsgList.GetItemCount(); nCnt++)
            {
                if(m_omLctrMsgList.GetCheck(nCnt) == TRUE)
                {
                    nChecked++;
                }
                else if(m_omLctrMsgList.GetCheck(nCnt) == FALSE)
                {
                    nUnCkecked++;
                }
                m_omLctrMsgList.SetItemState(nCnt, 0, LVIS_SELECTED);
            }


            if(nChecked == m_omLctrMsgList.GetItemCount())
            {
                vCheckHeaderCtrl(true);
            }
            else if(nUnCkecked == m_omLctrMsgList.GetItemCount())
            {
                vCheckHeaderCtrl(false);
            }
            m_omLctrMsgList.SetItemState(pNMListView->iItem, LVIS_SELECTED, LVIS_SELECTED);//LVIS_SELECTED

            if(psTxMsgList != nullptr )
            {
                int nCurrentState =
                    m_omLctrMsgList.GetCheck(pNMListView->iItem);
                CTxFunctionsView* pView = (CTxFunctionsView*)
                                          pomGetFunctionsViewPointer();
                if( pView != nullptr )
                {
                    if( nCurrentState !=
                            psTxMsgList->m_sTxMsgDetails.m_bEnabled )
                    {
                        psTxMsgList->m_sTxMsgDetails.m_bEnabled = nCurrentState;
                        psTxMsgList->m_bModified = true;
                        // Enable Update Button
                        if(pView->m_CheckBoxAutoUpdate.GetCheck() == BST_UNCHECKED)
                        {
                            pView->m_omButtonApply.EnableWindow();
                        }
                        psMsgBlock->m_bModified = true;
                    }
                }
                else
                {
                    m_omLctrMsgList.SetCheck( pNMListView->iItem,
                                              psTxMsgList->m_sTxMsgDetails.m_bEnabled );
                }

                if( pView != nullptr )
                {
                    if(pView->m_CheckBoxAutoUpdate.GetCheck() == BST_CHECKED)
                    {
                        pView->vAccessButtonApply();
                        this->SetFocus();
                    }
                }
            }

        }



    }
    *pResult = 0;
}
コード例 #7
0
ファイル: TxMsgListView.cpp プロジェクト: sgnes/busmaster
void CTxMsgListView::vSetMessageCheckValue(BOOL bCheck)
{
    // Get Other View Pointers
    // Blocks View
    CTxMsgBlocksView* pomBlocksView = nullptr;
    pomBlocksView = ( CTxMsgBlocksView*)pomGetBlocksViewPointer();
    // Message Details View
    CTxMsgDetailsView* pomDetailsView = nullptr;
    pomDetailsView = (CTxMsgDetailsView*)pomGetDetailsViewPointer();
    // Functions view
    CTxFunctionsView* pomFunctionsView = nullptr;
    pomFunctionsView = (CTxFunctionsView*)pomGetFunctionsViewPointer();
    // If all pointers are valid
    if( pomBlocksView != nullptr && pomDetailsView != nullptr &&
            pomFunctionsView != nullptr )
    {
        // If selected message block index is valid
        if(pomBlocksView->m_nSelectedMsgBlockIndex != -1 )
        {
            PSMSGBLOCKLIST psCurrentMsgBlock = nullptr;
            // Get current block pointer
            psCurrentMsgBlock = pomBlocksView->psGetMsgBlockPointer(
                                    pomBlocksView->m_nSelectedMsgBlockIndex,
                                    pomBlocksView->m_psMsgBlockList );
            psCurrentMsgBlock->m_bModified = true;
            // Get the message list
            PSTXCANMSGLIST psMsgList = psCurrentMsgBlock->m_psTxCANMsgList;
            int nIndex = 0;
            // Set programmed UI update to TRUE
            BOOL bModified = FALSE;
            m_bInitDlg = TRUE;

            // Update check box status of all messages in this list
            while(psMsgList != nullptr )
            {
                if( psMsgList->m_sTxMsgDetails.m_bEnabled != bCheck )
                {
                    // Update message list
                    psMsgList->m_sTxMsgDetails.m_bEnabled = bCheck;
                    psMsgList->m_bModified = true;
                    // Update UI Control
                    m_omLctrMsgList.SetCheck( nIndex, bCheck );
                    // Update Modified flag
                    bModified = TRUE;
                }
                // Go to Next Node
                psMsgList = psMsgList->m_psNextMsgDetails;
                // Increment list item index count
                nIndex++;
            }
            // Set programmed UI update to FALSE
            m_bInitDlg = FALSE;
            // Enable Update button only if data got modified
            if( bModified == TRUE )
            {
                // If data is modified then update apply button
                if(pomFunctionsView->m_CheckBoxAutoUpdate.GetCheck() == BST_UNCHECKED)
                {
                    pomFunctionsView->m_omButtonApply.EnableWindow();
                }
            }
        }
    }
}