/** * @brief Updates channel information * * Updates channel information */ void CTxMsgWndJ1939::vUpdateChannelIDInfo() { /* Clear existing channel info */ m_omComboChannel.ResetContent(); /* Update with latest channel info */ LPARAM lParam; GetICANDIL()->getControllerParameters(lParam, 0, NUMBER_HW); for (INT_PTR i = 0; i < lParam; i++) { CString omChannel; omChannel.Format("%d", i + 1); m_omComboChannel.InsertString(i, omChannel); } m_omComboChannel.SetCurSel(0); }
BOOL CConfigMsgLogDlg::OnInitDialog() { CDialog::OnInitDialog(); m_ChkbEnableLogOnConnect.SetCheck(m_bLogOnConnect == TRUE? BST_CHECKED : BST_UNCHECKED); m_odStartMsgID.vSetConfigData(IDC_EDIT_STARTMSGID); m_odStopMsgID.vSetConfigData(IDC_EDIT_STOPMSGID); m_odStartMsgID.vSetBase(BASE_HEXADECIMAL); m_odStopMsgID.vSetBase(BASE_HEXADECIMAL); m_odStartMsgID.vSetSigned(false); m_odStopMsgID.vSetSigned(false); vCreateFileList(); //Load channel combo box m_omComboChannel.ResetContent(); if (NULL != GetICANDIL()) { LPARAM lParam = 0; if (S_OK == GetICANDIL()->DILC_GetControllerParams(lParam, NULL, NUMBER_HW)) { m_unChannelCount = (UINT)lParam; } } m_omComboChannel.InsertString(0, _("ALL")); for (UINT i = 1; i <= m_unChannelCount; i++) { CString omChannel; omChannel.Format("%d", i); m_omComboChannel.InsertString(i, omChannel.GetBuffer(MAX_PATH)); } m_omComboChannel.SetCurSel(0); USHORT LogBlocks = GetLoggingBlockCount(); if (LogBlocks > 0) { for (USHORT i = 0; i < LogBlocks; i++) { SLOGINFO sLogObject; HANDLE hFind; WIN32_FIND_DATA FindData; CStdioFile omStdiofile; GetLoggingBlock(i, sLogObject); // check for valid log file CString strTempLog = sLogObject.m_sLogFileName; hFind = FindFirstFile(strTempLog, &FindData); if(hFind == INVALID_HANDLE_VALUE )//file not found { DWORD dError = GetLastError(); if(dError == ERROR_FILE_NOT_FOUND)//file not found { BOOL bFileOpen = omStdiofile.Open(strTempLog, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary); if(bFileOpen == TRUE)///file created, add in the list { omStdiofile.Close(); AddNewItem_GUI(sLogObject, i); } else //not a valid file { RemoveLoggingBlock(i--); //remove the old log data LogBlocks = GetLoggingBlockCount(); //refresh the log count } } else //not a valid filepath / file folder is removed { RemoveLoggingBlock(i--); //remove the old log data LogBlocks = GetLoggingBlockCount(); //refresh the log count } } else ///file found add in the list { AddNewItem_GUI(sLogObject, i); } } m_nLogIndexSel = 0; if(m_omListLogFiles.GetItemCount() > 0 )//check for log files exists { m_omListLogFiles.SetItemState(m_nLogIndexSel, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); } else { vEnableDisableControls(FALSE);//disable controls if no log files exists } } else { vEnableDisableControls(FALSE); } SetWindowText(m_strCurrWndText); if (m_bLogON) { vEnableDisableControls(FALSE); if(m_omListLogFiles.GetItemCount()>0) { vUpdate_GUI_From_Datastore(0); } GetDlgItem(IDC_CBTN_ADDLOG)->EnableWindow(FALSE); GetDlgItem(IDC_CHECK_RESET_TIMESTAMP)->EnableWindow(FALSE); GetWindowText(m_strCurrWndText); m_strCurrWndText+=_(" - Read Only as Logging is ON"); //SetWindowText(m_strCurrWndText); // PTV [1.6.4] // If Logging is on GetDlgItem(IDOK)->EnableWindow(FALSE); // PTV [1.6.4] SetWindowText(""); m_unDispUpdateTimerId = SetTimer(600, 600, NULL); } else { // PTV [1.6.4] // If Logging is on GetDlgItem(IDOK)->EnableWindow(TRUE); // PTV [1.6.4] } // Hide or show the Filters button in the dialog based on the protocol if (CAN == m_eCurrBus) { GetDlgItem(IDC_LOG_FILTER)->ShowWindow(1); } else if (J1939 == m_eCurrBus) { GetDlgItem(IDC_LOG_FILTER)->ShowWindow(0); } return TRUE; }
void CTxMsgWndJ1939::vInitializeTpfFields(void) { //Set the properties first m_omDLCEdit.vSetBase(BASE_DECIMAL); m_omMsgDataEdit.vSetBase(BASE_HEXADECIMAL); m_omDLCEdit.vSetSigned(false); m_omMsgDataEdit.vSetSigned(false); m_omPriorityEdit.vSetBase(BASE_HEXADECIMAL); m_omPriorityEdit.vSetSigned(true); m_omPriorityEdit.LimitText(1); m_omFromEdit.vSetBase(BASE_HEXADECIMAL); m_omFromEdit.vSetSigned(true); m_omFromEdit.LimitText(2); m_omTOEdit.vSetBase(BASE_HEXADECIMAL); m_omTOEdit.vSetSigned(true); m_omTOEdit.LimitText(2); //Initialize with default values LPARAM lParam; GetICANDIL()->DILC_GetControllerParams(lParam, 0, NUMBER_HW); for (INT_PTR i = 0; i < lParam; i++) { CString omChannel; omChannel.Format("%d", i + 1); m_omComboChannel.InsertString(i, omChannel); } m_omComboChannel.SetCurSel(0); //Populate PGN combo box if ((m_psMsgRoot != NULL) && (m_psMsgRoot->m_psMsg != NULL)) { // If atleast one database message is present m_CS_ConfigData.Lock(); vPopulatePGNComboBox(); m_omMsgTypeCombo.SetCurSel(0); } else { m_omComboPGN.SetWindowText("0"); vVerifyPDUFormatInPGN(0); } //Calling this to update the message type combobox OnCbnSelchangeComboPgn(); m_omMsgTypeCombo.SetCurSel(0); // Refreshing Msg type Combo for the selected PGN INT nCurrCursel = m_omComboPGN.GetCurSel(); if(nCurrCursel != -1) { CString omPGN; m_omComboPGN.GetLBText(nCurrCursel, omPGN); UINT unPGN = unGetMsgIDFromName(omPGN); vVerifyPDUFormatInPGN(unPGN); if(m_omMsgTypeCombo.GetCount() > 0) { m_omMsgTypeCombo.SetCurSel(0); } } m_omPriorityEdit.vSetValue(DEFAULT_PRIORITY); m_omFromEdit.vSetValue(m_sClientParams.m_byAddress); m_omTOEdit.vSetValue(ADDRESS_ALL); m_omDLCEdit.vSetValue(0x3); m_omMsgDataEdit.vSetValue(0); UpdateData(TRUE); }
void CTxMsgWndJ1939::OnBnClickedSend() { UpdateData(); LPARAM lParam = 0; GetICANDIL()->DILC_GetControllerParams(lParam, 0, NUMBER_HW); UINT unChannel = (UINT) lParam; if (m_bNM == TRUE) { BYTE byAddress = (BYTE)m_omCurAddress.lGetValue(); BYTE byEcuName = (BYTE)m_omEcuName.lGetValue(); CButton* pButton = (CButton*)GetDlgItem(IDC_CLAIM_ADDRESS); if (pButton->GetCheck() == BST_CHECKED) { for (UINT i = 0; i < unChannel; i++) { GetIJ1939DIL()->DILIJ_NM_ClaimAddress(m_sClientParams.m_dwClientId, i + 1, byAddress); } } pButton = (CButton*)GetDlgItem(IDC_RQST_ADDRESS); if (pButton->GetCheck() == BST_CHECKED) { for (UINT i = 0; i < unChannel; i++) { GetIJ1939DIL()->DILIJ_NM_RequestAddress(m_sClientParams.m_dwClientId, i + 1, DEFAULT_PRIORITY, byAddress, byEcuName); } } pButton = (CButton*)GetDlgItem(IDC_CMD_ADDRESS); if (pButton->GetCheck() == BST_CHECKED) { UINT64 unECUNAME = m_omEcuName.lGetValue(); for (UINT i = 0; i < unChannel; i++) { GetIJ1939DIL()->DILIJ_NM_CommandAddress(m_sClientParams.m_dwClientId, i + 1, unECUNAME, byAddress, DEFAULT_PRIORITY, byAddress, ADDRESS_ALL); } } } else { if ((eGetTransState() == TRANS_STOPPED) && GetIJ1939DIL()->DILIJ_bIsOnline()) { m_sMsgToBeSent.m_unChannel = 1; CString omChannel; int nIndex = m_omComboChannel.GetCurSel(); if (nIndex != -1) { m_omComboChannel.GetLBText(m_omComboChannel.GetCurSel(), omChannel); m_sMsgToBeSent.m_unChannel = _ttoi(omChannel); } //Check for DLC length if (m_unDataLength > MAX_DATA_LEN_J1939) { CString omInvDLCMsg; omInvDLCMsg.Format("Invalid DLC value: %d, Please enter a value between 0 and %d", m_unDataLength, MAX_DATA_LEN_J1939); vSetStatusBarText(omInvDLCMsg); return; } //Data bytes if (m_omMsgDataEditVal.GetLength() > (INT)(2 * m_unDataLength)) { m_omMsgDataEditVal = m_omMsgDataEditVal.Left(2 * m_unDataLength); } //DLC m_sMsgToBeSent.m_unDLC = CString_2_ByteArray(m_omMsgDataEditVal, m_sMsgToBeSent.m_abyData, MAX_DATA_LEN_J1939); //Msg type m_sMsgToBeSent.m_eMsgType = eGetCurrMsgType(); //Destination address m_sMsgToBeSent.m_byDest = (BYTE)m_omTOEdit.lGetValue(); //Source address m_sMsgToBeSent.m_bySrc = (BYTE)m_omFromEdit.lGetValue(); //Priority m_sMsgToBeSent.m_byPriority = (BYTE)m_omPriorityEdit.lGetValue(); //PGN value CString omPGN; nIndex = m_omComboPGN.GetCurSel(); if (nIndex != -1) { m_omComboPGN.GetLBText(m_omComboPGN.GetCurSel(), omPGN); } else { m_omComboPGN.GetWindowText(omPGN); omPGN = "0x" + omPGN; } m_sMsgToBeSent.m_unPGN = unGetMsgIDFromName(omPGN); if (m_sMsgToBeSent.m_unPGN > MAX_LMT_FOR_PGN) { CString omPGN; omPGN.Format("Invalid PGN value: %x, Please enter a value between 0 and 0x%x", m_sMsgToBeSent.m_unPGN, MAX_LMT_FOR_PGN); vSetStatusBarText(omPGN); return; } //Now send the message //Check for cyclic transmission if (m_omCheckCyclic.GetCheck() == BST_CHECKED) { m_sMsgToBeSent.m_unTimerVal = (UINT)m_omMiliSecs.lGetValue(); vProcessTransmission(TRUE); if (m_bThreadStarted == FALSE) { m_sCyclicThread.m_pBuffer = this; m_sCyclicThread.m_unActionCode = INVOKE_FUNCTION; m_bThreadStarted = m_sCyclicThread.bStartThread(Cyclic_Transmission_Thread); SetEvent(m_sCyclicThread.m_hActionEvent); } else { m_sCyclicThread.m_pBuffer = this; m_sCyclicThread.m_unActionCode = INVOKE_FUNCTION; SetEvent(m_sCyclicThread.m_hActionEvent); } } else { vSetStatusBarText(""); //Clear status bar. SendSavedMessage(); } } else if (eGetTransState() == TRANS_STARTED) { vSetTransState(TRANS_TO_BE_STOPPED); SetEvent(sg_hMsgSent); SetEvent(m_sCyclicThread.m_hActionEvent); } } }