void CTxFunctionsView::vReloadData() { // Get Other View Ponters CTxMsgBlocksView* pomBlockView = NULL; CTxMsgListView* pomlistView = NULL; CTxMsgDetailsView* pomDetailsView = NULL; // Fetch pointers from Tx Child Frame pomBlockView = ( CTxMsgBlocksView* )pomGetBlocksViewPointer(); pomlistView = ( CTxMsgListView* )pomGetListViewPointer(); pomDetailsView = ( CTxMsgDetailsView* )pomGetDetailsViewPointer(); if( pomBlockView != NULL && pomlistView != NULL && pomDetailsView != NULL ) { // Clear all data pomBlockView->m_omLctrMsgBlockName.DeleteAllItems(); pomlistView->m_omLctrMsgList.DeleteAllItems(); pomDetailsView->m_omLctrSigList.DeleteAllItems(); // Set this flag to avoid processing item change messages during init pomBlockView->m_bInitDlg = TRUE; pomlistView->m_bInitDlg = TRUE; //Clear the existing memory CTxWndDataStore::ouGetTxWndDataStoreObj().vReleaseMultiMsgInfo( pomBlockView->m_psMsgBlockList ); pomBlockView->m_psMsgBlockList = NULL; /*vRelease( TX_SEND_MULTI_MSGS, (void**)&(pomBlockView->m_psMsgBlockList) );*/ // Get the message block count. No memory allocation is required. UINT* punCount = &( pomBlockView->m_unMsgBlockCount ); CTxWndDataStore::ouGetTxWndDataStoreObj().bGetTxData(TX_MSG_BLOCK_COUNT, (void**)&punCount); // Make a local copy of the data structure // The local copy will be used to manipulate message frame details // Memory allocation will be done in the CConfigDetails class. // Get the pointer only if there m_unMsgBlockCount>0 if( pomBlockView->m_unMsgBlockCount > 0 ) { CTxWndDataStore::ouGetTxWndDataStoreObj().bGetTxData( TX_SEND_MULTI_MSGS, (void**)&(pomBlockView->m_psMsgBlockList) ); } if( pomBlockView->m_unMsgBlockCount == 0 ) { pomBlockView->vEnableControls(FALSE); /*pomBlockView->m_omButtonTxAllFrame.EnableWindow(FALSE);*/ pomBlockView->m_omComboAllMsgs.EnableWindow(FALSE); pomlistView->m_omButtonDeleteAllMsg.EnableWindow(FALSE); pomlistView->m_omButtonDeleteSelMsg.EnableWindow(FALSE); } else { pomlistView->m_omButtonDeleteAllMsg. EnableWindow(!CTxMsgManager::s_TxFlags.nGetFlagStatus(TX_SENDMESG) ); } PSMSGBLOCKLIST psCurrentMsgBlock = NULL; CString omStr = STR_EMPTY; psCurrentMsgBlock = pomBlockView->m_psMsgBlockList; // Disable AllTxMessage check box // This will be updated in the function vDisplayMsgBlockDetails // Disabling it here will avoid enabling the control when no blocks or // messages are present pomBlockView->m_omComboAllMsgs.EnableWindow(FALSE); /*pomBlockView->m_omButtonTxAllFrame.EnableWindow( FALSE );*/ for(UINT i = 0; i< pomBlockView->m_unMsgBlockCount; i++) { omStr = STR_EMPTY; if(psCurrentMsgBlock != NULL ) { pomBlockView->m_omLctrMsgBlockName.InsertItem( i, psCurrentMsgBlock->m_acStrBlockName); if(psCurrentMsgBlock->m_bType == TRUE) { pomBlockView->m_omLctrMsgBlockName.SetItemText( i, defSUBITEM_MSGBLOCK_TYPE, defMSG_CYCLIC ); } else { pomBlockView->m_omLctrMsgBlockName.SetItemText( i, defSUBITEM_MSGBLOCK_TYPE, defMSG_MONOSHOT ); } // Use Macros to find the type // Timer? if( IS_TIME_TRIGGERED(psCurrentMsgBlock->m_ucTrigger) ) { omStr.Format( defSTR_TIMER_VAL_FMT_SPECIFIER, psCurrentMsgBlock->m_unTimeInterval ); omStr += defMESSAGE_TRIG_MS; if( IS_KEY_TRIGGERED(psCurrentMsgBlock->m_ucTrigger) ) { omStr += defSTR_MSG_BLOCK_TRIGGER_SEPRATOR; } } // Key ? if( IS_KEY_TRIGGERED(psCurrentMsgBlock->m_ucTrigger) ) { CString omStrKeyVal; omStrKeyVal.Format( defSTR_KEY_VAL_FMT_SPECIFIER, psCurrentMsgBlock->m_ucKeyValue ); omStr += omStrKeyVal; } pomBlockView->m_omLctrMsgBlockName.SetItemText( i, defSUBITEM_MSGBLOCK_TRG_VAL, omStr ); pomBlockView->m_omLctrMsgBlockName.SetCheck( i, psCurrentMsgBlock->m_bActive ); psCurrentMsgBlock = psCurrentMsgBlock->m_psNextMsgBlocksList; } } // Clear Init Flag pomBlockView->m_bInitDlg = FALSE; pomlistView->m_bInitDlg = FALSE; pomBlockView->m_omLctrMsgBlockName.SetItemState( pomBlockView->m_nSelectedMsgBlockIndex, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED ); // Clear the Modified Flag pomBlockView->m_bModified = FALSE; // Disable Update Button m_omButtonApply.EnableWindow( FALSE ); } }
LRESULT CTxMsgChildFrame::vUserCommand(WPARAM wParam, LPARAM lParam) { if( m_pomTxMsgBlocksView != nullptr && m_pomTxMsgDetailsView != nullptr && m_pomTxMsgListView != nullptr && m_pomFunctionsView != nullptr ) { INT nBase = 0; BOOL bTxON = FALSE; BOOL bConnect = FALSE; eUSERSELCTION eUserSel = eDATABASEIMPORTCMD; //CFlags * pouFlag = nullptr; eUserSel = static_cast <eUSERSELCTION>(wParam); switch(eUserSel) { case eHEXDECCMD: //// Get the flag status. //pouFlag = pouGetFlagsPtr(); //if ( pouFlag != nullptr ) //{ // nBase = pouFlag->nGetFlagStatus( HEX ); //} nBase = (INT)lParam; // Check if the flag is changed and if so, // change the display format. if(nBase != CTxMsgManager::s_TxFlags.nGetFlagStatus(TX_HEX)) { CTxMsgManager::s_TxFlags.vSetFlagStatus(TX_HEX, nBase); // Hide any edit controls if it is visible m_pomTxMsgDetailsView->m_omLctrSigList.SetFocus(); if ( m_pomTxMsgBlocksView->m_psMsgBlockList != nullptr ) { PSMSGBLOCKLIST psMsgBlock = m_pomTxMsgBlocksView->psGetMsgBlockPointer( m_pomTxMsgBlocksView->m_nSelectedMsgBlockIndex, m_pomTxMsgBlocksView->m_psMsgBlockList ); if(psMsgBlock != nullptr) { m_pomTxMsgListView-> m_omLctrMsgList.DeleteAllItems(); m_pomTxMsgBlocksView-> vDisplayMsgBlockDetails(psMsgBlock); } } m_pomTxMsgBlocksView->vSetControlProperties(); m_pomTxMsgDetailsView->vSetControlProperties(); // Clear the controls after changing the properties. m_pomTxMsgDetailsView->vSetValues(nullptr); // Remove all entries in the list and disable m_pomTxMsgDetailsView->vDisableSignalComponents(); // Disable Delete Button & Send Button as the focus is lost m_pomTxMsgListView-> m_omButtonDeleteSelMsg.EnableWindow(FALSE); m_pomTxMsgListView-> m_omButtonSendMsg.EnableWindow(FALSE); m_pomTxMsgListView->m_nSelectedMsgIndex = -1; // Set Lable to indicate Mode CString omStrText = CTxMsgManager::s_TxFlags.nGetFlagStatus(TX_HEX) ? _(defSTR_HEX_MODE) : _(defSTR_DEC_MODE); CWnd* pomLabel = m_pomTxMsgDetailsView->GetDlgItem(IDC_STAT_HEADER2); if( pomLabel != nullptr ) { // Set the text with Hex/Dec mode pomLabel->SetWindowText(omStrText); } } break; case eTXMSGCMD: // Get the flag status. /*pouFlag = pouGetFlagsPtr(); if(pouFlag != nullptr ) { bTxON = static_cast<BOOL> (pouFlag->nGetFlagStatus( SENDMESG )); }*/ bTxON = (BOOL)lParam; // If transmission is ON, user should not be able to // delete any message or block. if(bTxON != CTxMsgManager::s_TxFlags.nGetFlagStatus(TX_SENDMESG)) { CTxMsgManager::s_TxFlags.vSetFlagStatus(TX_SENDMESG, bTxON); // Get the message count and disable if // there is some message list in the currently // selected block. if ( m_pomTxMsgBlocksView->m_psMsgBlockList != nullptr ) { PSMSGBLOCKLIST psMsgBlock = m_pomTxMsgBlocksView->psGetMsgBlockPointer( m_pomTxMsgBlocksView->m_nSelectedMsgBlockIndex, m_pomTxMsgBlocksView->m_psMsgBlockList ); if(psMsgBlock != nullptr) { if( psMsgBlock->m_unMsgCount > 0 ) { m_pomTxMsgListView->m_omButtonDeleteAllMsg. EnableWindow(!bTxON); } } //If it is key triggered then Enable/Diable All Messages //Check box and Key val edit box if( IS_KEY_TRIGGERED (psMsgBlock->m_ucTrigger) ) { /*m_pomTxMsgBlocksView->m_omButtonTxAllFrame. EnableWindow(!bTxON);*/ m_pomTxMsgBlocksView->m_omComboAllMsgs.EnableWindow(!bTxON); m_pomTxMsgBlocksView->m_omEditTrgKeyVal. EnableWindow(!bTxON); } if(bTxON) { m_pomTxMsgBlocksView->m_omComboAllMsgs.EnableWindow(!bTxON); m_pomTxMsgBlocksView->m_omEditTrgKeyVal. EnableWindow(!bTxON); } //AUC //only if DElay btn msg blocks check box is not checked den check time trigger button if(((CButton*) m_pomTxMsgBlocksView-> GetDlgItem(IDC_CHECK_MSG_BLOCK_DELAY))->GetCheck() == BST_UNCHECKED) { m_pomTxMsgBlocksView->m_omButtonTimeTrigger. EnableWindow(!bTxON); // If it is time triggered then time interval edit box if( IS_TIME_TRIGGERED (psMsgBlock->m_ucTrigger) ) { m_pomTxMsgBlocksView->m_omEditTrgTimeIntervalVal. EnableWindow(!bTxON); } } ((CButton*) m_pomTxMsgBlocksView->GetDlgItem(IDC_CHECK_MSG_BLOCK_DELAY))->EnableWindow(!bTxON); if((((CButton*) m_pomTxMsgBlocksView-> GetDlgItem(IDC_CHECK_MSG_BLOCK_DELAY))->IsWindowEnabled() == TRUE)&& ((CButton*) m_pomTxMsgBlocksView-> GetDlgItem(IDC_CHECK_MSG_BLOCK_DELAY))->GetCheck() == BST_CHECKED) { ((CEdit*) m_pomTxMsgBlocksView-> GetDlgItem(IDC_EDIT_BLOCK_TRG_TIMER_VAL))->EnableWindow(TRUE); } else { ((CEdit*) m_pomTxMsgBlocksView-> GetDlgItem(IDC_EDIT_BLOCK_TRG_TIMER_VAL))->EnableWindow(FALSE); } m_pomTxMsgBlocksView->m_omButtonKeyTrigger. EnableWindow(!bTxON); CButton* pRadioMonoshot = (CButton*)m_pomTxMsgBlocksView->GetDlgItem(IDC_RADIOMONOSHOT); CButton* pRadioCyclic = (CButton*)m_pomTxMsgBlocksView->GetDlgItem(IDC_RADIOCYCLIC); if ((pRadioMonoshot != nullptr) && (pRadioCyclic != nullptr)) { pRadioMonoshot->EnableWindow(!bTxON); pRadioCyclic->EnableWindow(!bTxON); } m_pomTxMsgBlocksView->m_omButtonAddMsgBlock.EnableWindow(!bTxON); m_pomTxMsgBlocksView->m_omEditMsgBlockName.EnableWindow(!bTxON); /*m_pomTxMsgBlocksView->m_omButtonTriggerType. EnableWindow(!bTxON);*/ } if( m_pomTxMsgListView->m_nSelectedMsgIndex != -1 ) { m_pomTxMsgListView->m_omButtonDeleteSelMsg. EnableWindow(!bTxON); } if(m_pomTxMsgBlocksView->m_nSelectedMsgBlockIndex != -1 ) { m_pomTxMsgBlocksView->m_omButtonDeleteMsgBlock. EnableWindow(!bTxON); } // Set the focus to the block list control if transmission is started // to capture the key events if (bTxON) { m_pomTxMsgBlocksView->m_omLctrMsgBlockName.SetFocus(); } } break; case eCONNECTCMD: // Get the flag status. /*pouFlag = pouGetFlagsPtr(); if(pouFlag != nullptr ) { bConnect = static_cast<BOOL> (pouFlag->nGetFlagStatus( CONNECTED )); }*/ bConnect = (BOOL)lParam; // If the tool is disconnected, user should not be able // send any message. if(bConnect != CTxMsgManager::s_TxFlags.nGetFlagStatus(TX_CONNECTED)) { CTxMsgManager::s_podGetTxMsgManager()->vSetSlaveMsgList(); if( m_pomTxMsgListView->m_nSelectedMsgIndex != -1 ) { m_pomTxMsgListView->m_omButtonSendMsg. EnableWindow(bConnect); } else { m_pomTxMsgListView->m_omButtonSendMsg. EnableWindow(FALSE); } CTxMsgManager::s_TxFlags.vSetFlagStatus(TX_CONNECTED, bConnect); } if ( bConnect == FALSE ) { /* Reset slave response data */ //g_pouDIL_LIN_Interface-> } break; case eDATABASEIMPORTCMD: m_pomTxMsgDetailsView->m_omComboMsgIDorName.ResetContent(); //m_pomTxMsgDetailsView->vPopulateMessageComboBox(); // The icon for database message may change to change the // display. if ( m_pomTxMsgBlocksView->m_psMsgBlockList != nullptr ) { PSMSGBLOCKLIST psMsgBlock = m_pomTxMsgBlocksView->psGetMsgBlockPointer( m_pomTxMsgBlocksView->m_nSelectedMsgBlockIndex, m_pomTxMsgBlocksView->m_psMsgBlockList ); if(psMsgBlock != nullptr) { m_pomTxMsgListView->m_omLctrMsgList.DeleteAllItems(); m_pomTxMsgBlocksView-> vDisplayMsgBlockDetails(psMsgBlock); m_pomTxMsgDetailsView->vUpdateAllBlocksFrmDB(); m_pomTxMsgBlocksView->AutoUpdateChanges(); } } m_pomTxMsgDetailsView->vSetValues(nullptr); // Clear Signal Components m_pomTxMsgDetailsView->vDisableSignalComponents(); // Disable Delete Button & Send Button as the focus is lost m_pomTxMsgListView->m_omButtonDeleteSelMsg.EnableWindow(FALSE); m_pomTxMsgListView->m_omButtonSendMsg.EnableWindow(FALSE); m_pomTxMsgListView->m_nSelectedMsgIndex = -1; break; case eCHANNELCOUNTUPDATED: m_pomTxMsgDetailsView->vUpdateChannelIDInfo(); break; default: ASSERT( FALSE ); break; } } return 0; }