예제 #1
0
/*******************************************************************************
  Function Name  : OnVScroll
  Input(s)       : nSBCode, nPos, pScrollBar
  Output         : -
  Functionality  : Handles the Vertical scrolling event.
  Member of      : CRxMsgList
  Author(s)      : Arunkumar K
  Date Created   : 20-05-2010
  Modifications  : 
*******************************************************************************/
void CRxMsgList::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
	BOOL bInterpret = FALSE;
	::SendMessage( m_hParent, WM_GET_INTERPRET_STATE, (WPARAM)&bInterpret, 0);
	if ( bInterpret && theApp.pouGetFlagsPtr()->nGetFlagStatus( SENDMESG ) )
	{
		AfxBeginThread(UpDateThread, (LPVOID)this);					
		CFlickerFreeListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
		return;
	}    
	::SendMessage( m_hParent, WM_UPDATE_TREE_ITEMS_POS, 0, 0);		
    RedrawWindow();		
    CFlickerFreeListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
}
예제 #2
0
void CMsgSignalDBWnd::OnClose()
{
    // Get active frame
    CMainFrame* pFrame =
        static_cast<CMainFrame*> (AfxGetApp()->m_pMainWnd);

    if (pFrame != NULL)
    {
        // Get appropriate data structure
        CMsgSignal** ppTempMsgSg = NULL;
        ppTempMsgSg = (CMsgSignal**)(m_sDbParams.m_ppvActiveDB);
        //CMsgSgDetView* podMsgSg =
        pFrame->podGetMsgSgDetView(m_sDbParams.m_eBus);

        if ((*ppTempMsgSg)->bGetModifiedFlag() == FALSE)
        {
            UINT bRetVal =  AfxMessageBox(ASK_SAVE_PROMPT,
                                          MB_YESNO|MB_ICONQUESTION);

            if ( bRetVal == IDYES )
            {
                (*ppTempMsgSg)->
                bWriteIntoDatabaseFileFromDataStructure(
                    m_sDbParams.m_omDBPath );

                if ((*ppTempMsgSg)->bGetDBAcitveFlagStatus() == TRUE)
                {
                    pFrame->vPostMsgToSendMsgDlg(m_sDbParams.m_eBus);
                }

                // Check if the modified file is being loaded or not.
                //If yes then prompt the user whether he wants to
                //import it or not.
                CStringArray omImportedDBNames;
                CMsgSignal** m_ppsMSTemp = (CMsgSignal**)(m_sDbParams.m_ppvImportedDBs);

                if ((*m_ppsMSTemp) != NULL)
                {
                    (*m_ppsMSTemp)->vGetDataBaseNames(&omImportedDBNames);

                    for (INT nDBCount = 0; nDBCount < omImportedDBNames.GetSize();
                            nDBCount++)
                    {
                        if (m_sDbParams.m_omDBPath ==
                                omImportedDBNames.GetAt(nDBCount))
                        {
                            CString omText;
                            omText.Format( _T("File  \"%s\"  has been modified which is currently being loaded.\nDo you want to re-import it to reflect the changes?"),
                                           m_sDbParams.m_omDBPath);

                            if (MessageBox(omText, "", MB_ICONQUESTION | MB_YESNO) == IDYES)
                            {
                                switch (m_sDbParams.m_eBus)
                                {
                                    case CAN:
                                    {
                                        pFrame->dLoadDataBaseFile(m_sDbParams.m_omDBPath, FALSE);
                                    }
                                    break;

                                    case J1939:
                                    {
                                        pFrame->dLoadJ1939DBFile(m_sDbParams.m_omDBPath, FALSE);
                                    }
                                    break;
                                };
                            }
                        }
                    }
                }

                //Checking ends

                // Set the modified flag as saved
                if (NULL != (*ppTempMsgSg))
                {
                    (*ppTempMsgSg)->vSetModifiedFlag(TRUE);
                }
            }
            else if( bRetVal == IDNO )
            {
                // if this is new database
                // then delete the memory and the file itself
                if ( pFrame->vGetNewDatabaseFlag())
                {
                    // This file is no longer required
                    CFile::Remove( m_sDbParams.m_omDBPath );
                    pFrame->vSetNewDatabaseFlag(FALSE);
                }
            }
        }
        else
        {
            // If the user just creates new database,
            // and closes the window
            // delete the file
            if ( pFrame->vGetNewDatabaseFlag() )
            {
                // This file is no longer required
                CFile::Remove( m_sDbParams.m_omDBPath );
                pFrame->vSetNewDatabaseFlag(FALSE);
            }
        }

        // delete previously allocated memory if any
        (*ppTempMsgSg)->bDeAllocateMemoryInactive();

        // Reset the flag to indicate the closing of database window
        if (m_sDbParams.m_eBus == CAN)
        {
            CFlags* pFlags = theApp.pouGetFlagsPtr();

            if ( pFlags != NULL )
            {
                pFlags->vSetFlagStatus( DBOPEN, FALSE );
            }
        }
        else if (m_sDbParams.m_eBus == J1939)
        {
            CMsgSignalDBWnd::sm_bValidJ1939Wnd = FALSE;
        }

        CMDIChildWnd::OnClose();
    }
}
예제 #3
0
void CMsgSignalDBWnd::OnClose() 
{
    // Get active frame
    CMainFrame *pFrame = 
                (CMainFrame*)AfxGetApp()->m_pMainWnd;
    
    if (pFrame != NULL)
    {
        // Get appropriate data structure
        CMsgSignal** ppTempMsgSg = NULL;

        ppTempMsgSg = (CMsgSignal**)(m_sDbParams.m_ppvActiveDB);
        
        //CMsgSgDetView* podMsgSg = 
        pFrame->podGetMsgSgDetView(m_sDbParams.m_eBus);

        if ((*ppTempMsgSg)->bGetModifiedFlag() == FALSE)
        {
            UINT bRetVal =  AfxMessageBox(ASK_SAVE_PROMPT,
                                    MB_YESNO|MB_ICONQUESTION);
            if ( bRetVal == IDYES )
            {
                //save the database modificatins.
				vSaveModifiedDBs(ppTempMsgSg);
            }
            else if( bRetVal == IDNO )
            {
                // if this is new database
                // then delete the memory and the file itself
                if ( pFrame->vGetNewDatabaseFlag())
                {
                    // This file is no longer required
                    CFile::Remove( m_sDbParams.m_omDBPath );
                    pFrame->vSetNewDatabaseFlag(FALSE);
                }
            }

        }
        else
        {
            // If the user just creates new database,
            // and closes the window
            // delete the file
            if ( pFrame->vGetNewDatabaseFlag() )
            {
                // This file is no longer required
                CFile::Remove( m_sDbParams.m_omDBPath );
                pFrame->vSetNewDatabaseFlag(FALSE);
            }

        }

         // delete previously allocated memory if any
         (*ppTempMsgSg)->bDeAllocateMemoryInactive();

        // Reset the flag to indicate the closing of database window
        if (m_sDbParams.m_eBus == CAN)
        {
            CFlags* pFlags = theApp.pouGetFlagsPtr();
            if ( pFlags != NULL )
            {
                pFlags->vSetFlagStatus( DBOPEN, FALSE );
            }
        }
        else if (m_sDbParams.m_eBus == J1939)
        {
            CMsgSignalDBWnd::sm_bValidJ1939Wnd = FALSE;
        }
        CMDIChildWnd::OnClose();
    }
}
/******************************************************************************
  Function Name    :  OnBnClickedCbtnDissociate

  Input(s)         :
  Output           :
  Functionality    :  Call the functions to remove the selected Databases
  Member of        :  CDatabaseDissociateDlg
  Friend of        :      -

  Author(s)        :  Anish Kumar
  Date Created     :  06.12.2006
  Modifications    :
******************************************************************************/
void CDatabaseDissociateDlg::OnBnClickedCbtnDissociate()
{
    //TO store the path of files dissociated
    CStringArray aomStrFilesDissociated;
    CMainFrame* pMainFrame = static_cast<CMainFrame*> (theApp.m_pMainWnd);
    // Get the indexes of all the selected items.
    int nCount = m_omDissociateDbLst.GetSelCount();

    if ( nullptr == pMainFrame )
    {
        return;
    }
    if(nCount > 0)
    {
        // Array of selected item's position
        CArray<int,int> aomListBoxSel;
        aomListBoxSel.SetSize(nCount);
        //Pass the array pointer to get the selected item's positions
        m_omDissociateDbLst.GetSelItems(nCount, aomListBoxSel.GetData());
        aomStrFilesDissociated.RemoveAll();

        for(int nTempCnt = 0 ; nTempCnt < nCount ; nTempCnt++)
        {
            BOOL bDBDeleted = FALSE;
            CString omstrDBPath ;
            //Selected file's index
            int nSelectedPos = aomListBoxSel.GetAt(nTempCnt);
            //Find the length of string to pass the buffer to have the selected File path
            int nBufferSize = m_omDissociateDbLst.GetTextLen(nSelectedPos);
            m_omDissociateDbLst.GetText(nSelectedPos,omstrDBPath.GetBuffer(nBufferSize));
            bDBDeleted = (*(CMsgSignal**)(m_sDbParams.m_ppvImportedDBs))->bDeAllocateMemory(omstrDBPath.GetBuffer(0));

            if(TRUE == bDBDeleted)
            {
                aomStrFilesDissociated.Add(omstrDBPath.GetBuffer(0));
            }
        }

        //To remove from theApp class
        CStringArray aomstrDBFiles;
        (*(CMsgSignal**)(m_sDbParams.m_ppvImportedDBs))->vGetDataBaseNames(&aomstrDBFiles);
        //Delete the file path from the List box
        int nTotalCount = aomStrFilesDissociated.GetSize();
        CString omStrTempFile;

        for(int nCount=0 ; nCount<nTotalCount ; nCount++)
        {
            omStrTempFile = aomStrFilesDissociated.GetAt(nCount);
            int nIndex = 0;

            if( (nIndex = m_omDissociateDbLst.FindString(0,
                          omStrTempFile)) != LB_ERR )
            {
                //Delete the file path from the list box
                m_omDissociateDbLst.DeleteString(nIndex);
                int nStoredFile = aomstrDBFiles.GetSize();
                CString omStrTemp;
                BOOL bRemoved = FALSE;

                for(int nTemp = 0 ; nTemp < nStoredFile && bRemoved != TRUE; nTemp++)
                {
                    omStrTemp = aomstrDBFiles.GetAt(nTemp);

                    if(!(omStrTemp.Compare(omStrTempFile)))
                    {
                        aomstrDBFiles.RemoveAt(nTemp);
                        bRemoved = TRUE;
                    }
                }
            }
        }

        //Set the new file name array
        (*(CMsgSignal**)(m_sDbParams.m_ppvImportedDBs))->vSetDataBaseNames(&aomstrDBFiles);
        // Send a message to Tx Window about database change
        if( pMainFrame != nullptr)
        {
            eUSERSELCTION eUserSel = eDATABASEIMPORTCMD;
            pMainFrame->m_objTxHandler.vPostMessageToTxWnd(WM_USER_CMD, (WPARAM)eUserSel,0);
        }
        ////Delete Signal watch list and Graph window list
        //// Check for Signal Watch & DLL load Condition
        //
        BOOL bUserOption = FALSE;
        if(pMainFrame->m_psSignalWatchList != nullptr)
        {
            if(theApp.m_bFromAutomation == FALSE)
                bUserOption = AfxMessageBox(_(defIMPORT_WARNING),
                                            MB_YESNO | MB_DEFBUTTON1 | MB_ICONQUESTION) ==
                              IDYES;
            // If user wants to clear
            if(bUserOption == TRUE )
            {
                // Clear Signal Watch List
                pMainFrame->vUpdateSWList();
            }
        }
        //Added by Arun to update Data Handler Main entry list.
        pMainFrame->vUpdateMainEntryListInWaveDataHandler();
        pMainFrame->vClearSignalInfoList();
        if(!pMainFrame->m_ouWaveTransmitter.bIsBlockEnabled())
        {
            theApp.pouGetFlagsPtr()->vSetFlagStatus( SEND_SIGNAL_MSG, FALSE );
        }

        //Update Message windows
        pMainFrame->vUpdateAllMsgWndInterpretStatus(m_sDbParams.m_eBus, FALSE);

        // Check for Graph list
        for(register int nBusID = CAN; nBusID < AVAILABLE_PROTOCOLS; nBusID++)
        {
            if( pMainFrame->m_odGraphList[nBusID].m_omElementList.GetSize() > 0 )
            {
                // Get the delete confirmation from the user
                if(theApp.m_bFromAutomation == FALSE)
                    bUserOption = AfxMessageBox(_(defIMPORT_WARNING_GRAPH),
                                                MB_YESNO | MB_DEFBUTTON1 | MB_ICONQUESTION) ==
                                  IDYES;

                // If user wants to clear
                if(bUserOption == TRUE )
                {
                    // Clear Graph List for all buses.
                    for(register int nID = CAN; nID < AVAILABLE_PROTOCOLS; nID++)
                    {
                        pMainFrame->m_odGraphList[nID].m_omElementList.RemoveAll();
                    }

                    // Send the Message to the Left View to Update List for all buses
                    if( pMainFrame != nullptr )
                    {
                        pMainFrame->vPostConfigChangeCmdToSigGrphWnds(FALSE);
                    }
                }
                break;
            }
        }
    }
}