// FilePage.cpp : implementation file // #include "stdafx.h" #include "afxpriv.h" // afxpriv.h has WM_COMMANDHELP id #include "FilePageRes.h" #include "FilePage.h" #include "FileBrowse.h" #include "IniUtil.h" #include "scommon.h" #include ".\filepage.h" #include "UserMsgs.h" #include "CmdWaitDlg.h" #include "msectimer.h" #include "AsciiCmdUtilities.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CFilePage property page IMPLEMENT_DYNCREATE(CFilePage, CCfgPropPage) // #define IDD_FILE_PAGE 104 //CFilePage::CFilePage() : CCfgPropPage(CFilePage::IDD) //, m_strConfigIn(_T("")) //, m_strConfigOut(_T("")) CFilePage::CFilePage() : CCfgPropPage("IDD_FILE_PAGE") , m_strConfigIn(_T("")) , m_strConfigOut(_T("")) { //{{AFX_DATA_INIT(CFilePage) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // auto load hw config if connected, timer calls function m_nTmrConfigId = 0; // return SetTimer Return Value (0=false,TimerID if OK) m_nTmrConfigEventId = 4; // Timer Event Identifier m_nTmrConfigElapse = 500; // Timeout value in milliseconds } CFilePage::~CFilePage() { } void CFilePage::DoDataExchange(CDataExchange* pDX) { CCfgPropPage::DoDataExchange(pDX); //{{AFX_DATA_MAP(CFilePage) //}}AFX_DATA_MAP DDX_Control(pDX, IDC_STATIC_FILE_PAGE, m_FilePageLabel); DDX_Control(pDX, IDC_READDETECTORCONFIGCOMBO, m_ReadDetectorConfigCombo); DDX_Control(pDX, IDC_STATIC_FILE_ADVANCED, m_FileAdvancedLabel); DDX_Control(pDX, IDC_STATIC_FILE_STANDARD, m_FileStandardLabel); } BEGIN_MESSAGE_MAP(CFilePage, CCfgPropPage) //{{AFX_MSG_MAP(CFilePage) //}}AFX_MSG_MAP // Read/Save ini format config file ON_BN_CLICKED(IDC_BUTTON_READ_CONFIG, OnBnClickedButtonReadConfig) ON_BN_CLICKED(IDC_BUTTON_SAVE_CONFIG, OnBnClickedButtonSaveConfig) // reset configuration to defaults (this command is now hidden, default->RESC=YES;) ON_CBN_SELCHANGE(IDC_OPT_COMBO_RESC, OnCbnSelchangeOptComboResc) //ON_BN_CLICKED(IDC_BUTTON_FIND_COMMAND, OnBnClickedButtonFindCommand) // read current configuration from hardware (active DPP) // reads config to configuration dialog for editing // if a dpp device is present, this is done when the dialog is opened ON_BN_CLICKED(IDC_BUTTON_EDIT_CONFIG_FROM_HW, OnBnClickedButtonEditConfigFromHw) // send current configuration to hardware (active DPP) // if a dpp device is present, this is done when apply or OK buttons are pressed ON_BN_CLICKED(IDC_BUTTON_SEND_TO_HARDWARE, OnBnClickedButtonSendToHardware) ON_WM_TIMER() // reads cfg file and directly sends commands to hardware // this function can send new and unsupported commands ON_BN_CLICKED(IDC_BUTTON_SEND_TO_HARDWARE_NO_EDIT, OnBnClickedButtonSendToHardwareNoEdit) // Select device type and pc5 option when creating config and DPP is not connected // TYPE1=DP5, TYPE2=PX5, TYPE3=DP5G, TYPE4=MCA8000D, TYPE5=TB5 ON_BN_CLICKED(IDC_RADIO_DPP_DEVICE_TYPE1, OnBnClickedRadioDppDeviceType1) ON_BN_CLICKED(IDC_RADIO_DPP_DEVICE_TYPE2, OnBnClickedRadioDppDeviceType2) ON_BN_CLICKED(IDC_RADIO_DPP_DEVICE_TYPE3, OnBnClickedRadioDppDeviceType3) ON_BN_CLICKED(IDC_RADIO_DPP_DEVICE_TYPE4, OnBnClickedRadioDppDeviceType4) ON_BN_CLICKED(IDC_RADIO_DPP_DEVICE_TYPE5, OnBnClickedRadioDppDeviceType5) ON_BN_CLICKED(IDC_RADIO_DPP_DEVICE_TYPE6, OnBnClickedRadioDppDeviceType6) ON_BN_CLICKED(IDC_CHECK_PC5_PRESENT, OnBnClickedCheckPc5Present) ON_BN_CLICKED(IDC_CHECK_DP5_DX_GAIN, OnBnClickedCheckDP5DxGains) // read predefined configurations // defined in AmptekDC_NP.ini (Amptek Detector Configurations, New (FW6) Protocol) ON_CBN_SELENDOK(IDC_READDETECTORCONFIGCOMBO, OnCbnSelendokReaddetectorconfigcombo) ON_CBN_SELCHANGE(IDC_READDETECTORCONFIGCOMBO, OnCbnSelchangeReaddetectorconfigcombo) // respond to the read/save config folder icon next to the command button ON_STN_CLICKED(IDC_STATIC_READ_CONFIG, OnStnClickedStaticReadConfig) ON_STN_CLICKED(IDC_STATIC_SAVE_CONFIG, OnStnClickedStaticSaveConfig) // send typed in text command string ON_BN_CLICKED(IDC_BUTTON_SEND_COMMAND, OnBnClickedButtonSendCommand) ON_COMMAND(ID_HELP, OnHelp) ON_WM_HELPINFO() ON_BN_CLICKED(IDC_BUTTON_SEND_COMMAND2, OnBnClickedButtonSendCommand2) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CFilePage message handlers BOOL CFilePage::OnSetActive() { // TODO: Add your specialized code here and/or call the base class if (s.ReloadCfg) { InitControls(); } return CCfgPropPage::OnSetActive(); } BOOL CFilePage::OnInitDialog() { CCfgPropPage::OnInitDialog(); SelectRadioDppDeviceType(s.profile->device_type); isClosing = FALSE; m_FilePageLabel .SetFontName("Arial") .SetFontSize(24) .SetTextColor(RGB(0,0,255)) .SetBkColor(RGB(244, 243, 238)) .SetFontItalic(TRUE) .SetFontBold(TRUE); m_FileAdvancedLabel .SetFontName("Arial") .SetFontSize(18) .SetTextColor(RGB(0, 70, 213)) .SetBkColor(RGB(245, 245, 242)) .SetFontItalic(TRUE) .SetFontBold(FALSE); m_FileStandardLabel .SetFontName("Arial") .SetFontSize(18) .SetTextColor(RGB(0, 70, 213)) .SetBkColor(RGB(252, 252, 254)) .SetFontItalic(TRUE) .SetFontBold(FALSE); //GetDlgItem(IDC_READDETECTORCONFIGCOMBO)->EnableWindow(FALSE); InitControls(); if (s.isDppConnected) { s.HaveConfig = FALSE; EnableControls(FALSE); EnableDeviceSelection(FALSE); SelectRadioDppDeviceType(s.profile->device_type); m_nTmrConfigId = SetTimer(m_nTmrConfigEventId, m_nTmrConfigElapse, NULL); GetDlgItem(IDC_STATIC_SEND_COMMAND_LABEL)->ShowWindow(SW_SHOW); GetDlgItem(IDC_BUTTON_SEND_COMMAND)->ShowWindow(SW_SHOW); GetDlgItem(IDC_BUTTON_SEND_COMMAND2)->ShowWindow(SW_SHOW); GetDlgItem(IDC_EDIT_SEND_COMMAND)->ShowWindow(SW_SHOW); } else { EnableDeviceSelection(TRUE); // must select dpp device type to enable controls //-------------------------------------------------------------- //s.DP5Stat.m_DP5_Status.DPP_options = PX5_OPTION_HPGe_HVPS; s.DP5Stat.m_DP5_Status.DPP_options = PX5_OPTION_NONE; //DPP_options == NONE unless PX5 and has options //-------------------------------------------------------------- GetDlgItem(IDC_STATIC_SEND_COMMAND_LABEL)->ShowWindow(SW_HIDE); GetDlgItem(IDC_BUTTON_SEND_COMMAND)->ShowWindow(SW_HIDE); GetDlgItem(IDC_BUTTON_SEND_COMMAND2)->ShowWindow(SW_HIDE); GetDlgItem(IDC_EDIT_SEND_COMMAND)->ShowWindow(SW_HIDE); GetDlgItem(IDC_EDIT_RCV_CFG)->ShowWindow(SW_HIDE); } // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } //dciRESC RESC IDC_OPT_COMBO_RESC 0 dctCbo dcgFile Reset Configuration void CFilePage::InitControls() { HWND hPage = this->GetSafeHwnd();\ InitDlgItem(hPage,s.m_DP5Cfg[dciRESC]); CboUpdate(dciRESC); GetDlgItem(IDC_STATIC_CFG_LEN_LABEL)->ShowWindow(SW_HIDE); GetDlgItem(IDC_STATIC_CFG_LENGTH)->ShowWindow(SW_HIDE); GetDlgItem(IDC_STATIC_CFG_LENGTH)->SetWindowText(""); if (!s.isDppConnected) { GetDlgItem(IDC_BUTTON_EDIT_CONFIG_FROM_HW)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_SEND_TO_HARDWARE)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_SEND_TO_HARDWARE_NO_EDIT)->EnableWindow(FALSE); } ReadAmptekDetectorConfigNames(); //if (s.profile->device_type == dppMCA8000D) { // ShowMCA8000D_Controls(SW_HIDE); //} else { // ShowMCA8000D_Controls(SW_SHOW); //} } void CFilePage::InitDlgItem(HWND hDlg, DP5_CONFIGURATION cfg) { int cboDP5CtrlID = cfg.ListCtrlID; CString strVal = cfg.Setting; int idxList; if ((cfg.CtrlType & dctCbo) > 0) { // try to find list index for any combo CComboBox &cb = *(CComboBox *) GetDlgItem(cboDP5CtrlID); //idxList = s.CtrlUtil.FindCboIdx(hDlg,cboDP5CtrlID,strVal); idxList = s.CtrlUtil.FindCboIdxExact(hDlg,cboDP5CtrlID,strVal); // try exact first if (idxList == LB_ERR) { idxList = s.CtrlUtil.FindCboIdx(hDlg,cboDP5CtrlID,strVal); } if (idxList == LB_ERR) { // if (idxList != LB_ERR) we already found the value idxList = 0; // set to first item } cb.SetCurSel(idxList); } } // pass dci id to update combo control and display edit controls if any void CFilePage::CboUpdate(int nID_dci) { CString strCboText; int nID; nID = s.m_DP5Cfg[nID_dci].ListCtrlID; if (nID == NULL) { return; } CComboBox &cb = *(CComboBox *) GetDlgItem(nID); int idx = cb.GetCurSel(); if (idx > LB_ERR) { cb.GetLBText(idx,strCboText); s.m_DP5Cfg[nID_dci].ComboIndex = idx; s.m_DP5Cfg[nID_dci].ComboValue = strCboText; } else { return; } SetModified(TRUE); } BOOL CALLBACK EnumChildControls(HWND hWnd, LPARAM lParam) { // Make sure window is valid if (hWnd && IsWindow(hWnd)) { CWnd* pWnd = CWnd::FromHandle(hWnd); ASSERT_VALID(pWnd); // Get the class name for the window TCHAR szClassName[100]; GetClassName(hWnd, szClassName, 100); int iStyle = GetWindowLong(hWnd, GWL_STYLE); iStyle &= 0xF; CString strControl; //TRACE(_T("Class Name: %s\n"), szClassName); if (_tcscmp(_T("ComboBox"), szClassName) == 0) { CComboBox* pComboBox = (CComboBox*)pWnd; pComboBox->GetWindowText(strControl); //TRACE(_T("ComboBox: %s\n"), strControl); } else if (_tcscmp(_T("Edit"), szClassName) == 0) { CEdit* pEdit = (CEdit*)pWnd; pEdit->GetWindowText(strControl); //TRACE(_T("Edit: %s\n"), strControl); } else if (_tcscmp(_T("Static"), szClassName) == 0) { CStatic* pStatic = (CStatic*)pWnd; pStatic->GetWindowText(strControl); //TRACE(_T("Static: %s\n"), strControl); } else //if (_tcscmp(_T("ListBox"), szClassName) == 0) { // // don't use ListBox for options //} else if (_tcscmp(_T("Button"), szClassName) == 0) { // check button type controls CButton* pButton = (CButton*)pWnd; switch (iStyle) { case BS_CHECKBOX: case BS_AUTOCHECKBOX: case BS_3STATE: case BS_AUTO3STATE: //CHECKBOX break; case BS_RADIOBUTTON: case BS_AUTORADIOBUTTON: //RADIO break; case BS_GROUPBOX: //FRAME pButton->GetWindowText(strControl); //TRACE(_T("Frame: %s\n"), strControl); break; case BS_PUSHBUTTON: case BS_OWNERDRAW: case BS_DEFPUSHBUTTON: //BUTTON //pButton->GetWindowText(strButton); //TRACE(_T("Push Button: %s\n"), strButton); break; default: // not defined here break; } } } return TRUE; } void CFilePage::ReadConfig() { UpdateData(TRUE); CFileBrowse BR; CString strDfltExt; CIniUtil ciu; CString csData; CString csCmts; CString sCurrentDir; CString strFilename; bool isTestApp; s.CreateDP5Cfg(); sCurrentDir = s.strHelpFilePath; sCurrentDir = sCurrentDir.Left(sCurrentDir.ReverseFind('\\')); strFilename = sCurrentDir + "\\DP5 Config.txt"; DWORD dwAttr = GetFileAttributes((LPCTSTR)strFilename); if (dwAttr == 0xffffffff) // test if test ini file exists isTestApp = false; else isTestApp = true; if (isTestApp) { // read test profile path m_strConfigIn = strFilename; } else { strDfltExt = "txt"; if (BR.DoModal(BR.OPEN, "Open Configuration", BR.CfgFileFilter, strDfltExt, _T(""), &m_strConfigIn)) { } else { return; } } //m_strConfigIn = "C:\\Projects\\DP5_PROTOCOL\\DppMCA\\DP5CfgTest.txt"; UpdateData(FALSE); for (int idxCmd = DP5_CMD_MIN;idxCmd<=DP5_CMD_MAX;idxCmd++) { csData = ""; csCmts = ""; if (ciu.GetDP5Data(m_strConfigIn,_T("DP5 Configuration File"),s.m_DP5Cfg[idxCmd].Command,&csData,&csCmts)) { s.m_DP5Cfg[idxCmd].Setting = csData; s.m_DP5Cfg[idxCmd].Comments = csCmts; } if ((s.m_DP5Cfg[idxCmd].CtrlType & HasTextCtrl) > 0) { csData = ""; csCmts = ""; if (ciu.GetDP5Data(m_strConfigIn,_T("DP5 Configuration Values"),s.m_DP5Cfg[idxCmd].Command,&csData,&csCmts)) { s.m_DP5Cfg[idxCmd].TextValue = csData; s.m_DP5Cfg[idxCmd].ValComments = csCmts; } } s.CtrlUtil.RemoveUnitsFromDecString(&s.m_DP5Cfg[idxCmd]); } s.HaveConfig = TRUE; //GetDlgItem(IDC_BUTTON_FIND_COMMAND)->EnableWindow(TRUE); s.ReloadCfg = TRUE; CCfgPropSheet &pp = *(CCfgPropSheet *) this->GetSafeOwner(); pp.UpdateAll(); s.ReloadCfg = FALSE; //} } void CFilePage::OnBnClickedButtonReadConfig() { UpdateData(TRUE); CFileBrowse BR; CString strDfltExt; CIniUtil ciu; CString csData; CString csCmts; CString csDataVal; CString csCmtsVal; CString strConfigName; strConfigName = "Configuration File"; strDfltExt = "txt"; s.CreateDP5Cfg(); if (BR.DoModal(BR.OPEN, "Open Configuration", BR.CfgFileFilter, strDfltExt, _T(""), &m_strConfigIn)) { UpdateData(FALSE); for (int idxCmd = DP5_CMD_MIN;idxCmd<=DP5_CMD_MAX;idxCmd++) { //csData = ""; //csCmts = ""; if (ciu.GetDP5Data(m_strConfigIn,_T("DP5 Configuration File"),s.m_DP5Cfg[idxCmd].Command,&csData,&csCmts)) { if (csData.Find(";",0) >= 0) { csData = ""; } s.m_DP5Cfg[idxCmd].Setting = csData; s.m_DP5Cfg[idxCmd].Comments = csCmts; } if (s.m_DP5Cfg[idxCmd].Command == "CLCK") { s.DppConfig.b80MHzModeCfg = FALSE; if (csData.Find("80",0) >= 0) { s.DppConfig.b80MHzModeCfg = TRUE; } } if ((s.m_DP5Cfg[idxCmd].CtrlType & HasTextCtrl) > 0) { csData = ""; csCmts = ""; if (ciu.GetDP5Data(m_strConfigIn,_T("DP5 Configuration Values"),s.m_DP5Cfg[idxCmd].Command,&csData,&csCmts)) { if (csData.Find(";",0) >= 0) { csData = ""; } s.m_DP5Cfg[idxCmd].TextValue = csData; s.m_DP5Cfg[idxCmd].ValComments = csCmts; } } s.CtrlUtil.RemoveUnitsFromDecString(&s.m_DP5Cfg[idxCmd]); } if (s.SCAEnabled) { s.sca.strIniFilename = m_strConfigIn; s.scafn.GetSCASetupINI(&s.sca); for(int iIndex=1; iIndex<=MAX_SCA_REGISTER; iIndex++) { s.scafn.GetSCASettingsINI(&s.sca, iIndex); } } s.HaveConfig = TRUE; //GetDlgItem(IDC_BUTTON_FIND_COMMAND)->EnableWindow(TRUE); s.ReloadCfg = TRUE; CCfgPropSheet &pp = *(CCfgPropSheet *) this->GetSafeOwner(); pp.UpdateAll(); s.ReloadCfg = FALSE; EnableControls(TRUE); SetModified(TRUE); strConfigName = m_strConfigIn.Mid(m_strConfigIn.ReverseFind('\\')); GetDlgItem(IDC_STATIC_CONFIG_NAME)->SetWindowText(strConfigName); } } void CFilePage::ReadConfigFromAmptek_NP(CString strFilename, CString strKeyName) { UpdateData(TRUE); CString strFilter; CString strDfltExt; CIniUtil ciu; CString csData; CString csCmts; CString csDataVal; CString csCmtsVal; strFilter = "Text Files (*.txt)|*.txt|DP5 Setup Files (*.dp5)|*.dp5|All Files (*.*)|*.*||"; strDfltExt = "txt"; s.CreateDP5Cfg(); ciu.ini.setINIFileName(strFilename); BOOL bExists = ciu.ini.sectionExists("DP5 Configuration File"); if(!bExists) { // no configuration file or configuratiion section is missing return; } else { m_strConfigIn = strFilename; UpdateData(FALSE); for (int idxCmd = DP5_CMD_MIN;idxCmd<=DP5_CMD_MAX;idxCmd++) { //csData = ""; //csCmts = ""; if (ciu.GetDP5Data(m_strConfigIn,_T("DP5 Configuration File"),s.m_DP5Cfg[idxCmd].Command,&csData,&csCmts)) { if (csData.Find(";",0) >= 0) { csData = ""; } s.m_DP5Cfg[idxCmd].Setting = csData; s.m_DP5Cfg[idxCmd].Comments = csCmts; } if (s.m_DP5Cfg[idxCmd].Command == "CLCK") { s.DppConfig.b80MHzModeCfg = FALSE; if (csData.Find("80",0) >= 0) { s.DppConfig.b80MHzModeCfg = TRUE; } } if ((s.m_DP5Cfg[idxCmd].CtrlType & HasTextCtrl) > 0) { csData = ""; csCmts = ""; if (ciu.GetDP5Data(m_strConfigIn,_T("DP5 Configuration Values"),s.m_DP5Cfg[idxCmd].Command,&csData,&csCmts)) { if (csData.Find(";",0) >= 0) { csData = ""; } s.m_DP5Cfg[idxCmd].TextValue = csData; s.m_DP5Cfg[idxCmd].ValComments = csCmts; } } s.CtrlUtil.RemoveUnitsFromDecString(&s.m_DP5Cfg[idxCmd]); } s.HaveConfig = TRUE; //GetDlgItem(IDC_BUTTON_FIND_COMMAND)->EnableWindow(TRUE); s.ReloadCfg = TRUE; CCfgPropSheet &pp = *(CCfgPropSheet *) this->GetSafeOwner(); pp.UpdateAll(); s.ReloadCfg = FALSE; EnableControls(TRUE); SetModified(TRUE); GetDlgItem(IDC_STATIC_CONFIG_NAME)->SetWindowText(strKeyName); } } //void CFilePage::OnBnClickedButtonFindCommand() //{ // UINT NewActivePage; // int nPage; // s.FindCommand = TRUE; // s.FindCtrlID = IDC_OPT_COMBO_DACO; // NewActivePage = ID_MISC_TAB; // nPage = 5; // CCfgPropSheet &pp = *(CCfgPropSheet *) this->GetSafeOwner(); // pp.OnSelectTab(NewActivePage, nPage); //} void CFilePage::OnBnClickedButtonSaveConfig() { UpdateData(TRUE); CFileBrowse BR; CString strDfltExt; CIniUtil ciu; CString csData; CString csCmts; int idxReOrderCmd; int idxCmd; strDfltExt = "txt"; if (BR.DoModal(BR.SAVE, "Save Configuration", BR.CfgFileFilter, strDfltExt, _T(""), &m_strConfigOut)) { UpdateData(FALSE); for (idxCmd = DP5_CMD_MIN;idxCmd<=DP5_CMD_MAX;idxCmd++) { idxReOrderCmd = s.CtrlUtil.OrderOut(idxCmd); s.CtrlUtil.UpdateSetting(&s.m_DP5Cfg[idxReOrderCmd]); // process setting csData = s.m_DP5Cfg[idxReOrderCmd].Setting; csCmts = s.m_DP5Cfg[idxReOrderCmd].Comments; if (csData.Find(";",0) >= 0) { csData = ""; } //if (s.m_DP5Cfg[idxReOrderCmd].Command.GetLength() > 0) { if (ciu.SaveDP5Data(m_strConfigOut,_T("DP5 Configuration File"),s.m_DP5Cfg[idxReOrderCmd].Command,csData,csCmts)) { // get last error here } if ((s.m_DP5Cfg[idxReOrderCmd].CtrlType & dctTxt) > 0) { // has text value csData = s.CtrlUtil.GetValueWithUnitsString(s.m_DP5Cfg[idxReOrderCmd]); csCmts = s.m_DP5Cfg[idxReOrderCmd].ValComments; if (csData.Find(";",0) >= 0) { csData = ""; } if (ciu.SaveDP5Data(m_strConfigOut,_T("DP5 Configuration Values"),s.m_DP5Cfg[idxReOrderCmd].Command,csData,csCmts)) { // get last error here } } //} } if (s.SCAEnabled) { s.sca.strIniFilename = m_strConfigOut; s.scafn.SaveSCASetupINI(s.sca); for(int iIndex=1; iIndex<=MAX_SCA_REGISTER; iIndex++) { s.scafn.SaveSCASettingsINI(s.sca, iIndex); } } } } //============================================================ CString CFilePage::SaveConfigString() { UpdateData(TRUE); CString csCmd; CString csData; int idxReOrderCmd; int idxCmd; CString strDP5Cfg; strDP5Cfg = ""; UpdateData(FALSE); for (idxCmd = DP5_CMD_MIN;idxCmd<=DP5_CMD_MAX;idxCmd++) { idxReOrderCmd = s.CtrlUtil.OrderOut(idxCmd); s.CtrlUtil.UpdateSetting(&s.m_DP5Cfg[idxReOrderCmd]); // process setting csCmd = s.m_DP5Cfg[idxReOrderCmd].Command; csData = s.m_DP5Cfg[idxReOrderCmd].Setting; if ((csData.GetLength()>0) && (csData != ";")) { strDP5Cfg += csCmd; strDP5Cfg += "="; strDP5Cfg += csData; strDP5Cfg += ";"; } } return strDP5Cfg; } //============================================================ CString CFilePage::GetCmdKeyData(CString strCmd, CString strCfgData) { int iStart,iEnd,iCmd; CString strCmdData; strCmdData = ""; if (strCfgData.GetLength() < 7) { return strCmdData; } // no data if (strCmd.GetLength() != 4) { return strCmdData; } // bad command iCmd = strCfgData.Find(strCmd+"=",0); if (iCmd == -1) { return strCmdData; } // cmd not found iStart = strCfgData.Find("=",iCmd); if (iStart == -1) { return strCmdData; } // data start not found iEnd = strCfgData.Find(";",iCmd); if (iEnd == -1) {return strCmdData; } // data end found if (iStart >= iEnd) { return strCmdData; } // data error strCmdData = strCfgData.Mid(iStart+1,(iEnd - (iStart+1))); //AfxMessageBox(strCmdData); return strCmdData; } void CFilePage::OnBnClickedButtonEditConfigFromHw() { cWaitDialog dlg; CString strWait; CString strReady; CStringArray cChar; CMSecTimer tmr; int numTries = 7; s.HwCfgReady = FALSE; s.HwCfgExReady = FALSE; ::SendMessage(s.hWnd_Main,WM_USER_READ_DPP_CONFIG,0L,0L); tmr.msTimer(500); cChar.Add("-"); cChar.Add("\\"); cChar.Add("|"); cChar.Add("/"); cChar.Add("-"); cChar.Add("\\"); cChar.Add("|"); cChar.Add("/"); cChar.Add("-"); cChar.Add("\\"); cChar.Add("|"); cChar.Add("/"); cChar.Add("-"); cChar.Add("\\"); cChar.Add("|"); cChar.Add("/"); cChar.Add("-"); cChar.Add("\\"); cChar.Add("|"); cChar.Add("/"); cChar.Add("-"); cChar.Add("\\"); cChar.Add("|"); cChar.Add("/"); cChar.Add("-"); cChar.Add("\\"); cChar.Add("|"); cChar.Add("/"); cChar.Add("-"); cChar.Add("\\"); cChar.Add("|"); cChar.Add("/"); for (int idxWait=0;idxWait 0) { s.m_DP5Cfg[idxCmd].Setting = csData; s.m_DP5Cfg[idxCmd].Comments = ""; } if (s.m_DP5Cfg[idxCmd].Command == "CLCK") { s.DppConfig.b80MHzModeCfg = FALSE; if (csData.Find("80",0) >= 0) { s.DppConfig.b80MHzModeCfg = TRUE; } } s.CtrlUtil.RemoveUnitsFromDecString(&s.m_DP5Cfg[idxCmd]); } // have config update from hardware, if using scas, update sca data structure too if (s.SCAEnabled) { s.sca.HaveScaUpdate = FALSE; s.HwCfgReady = FALSE; ::SendMessage(s.hWnd_Main,WM_USER_READ_SCA_CONFIG,0L,0L); tmr.msTimer(500); if (s.HwCfgReady == TRUE) { s.sca.HaveScaUpdate = TRUE; //AfxMessageBox(s.scafn.SCAStringALLDisplay(s.sca)); } else { // try one more time s.HwCfgReady = FALSE; ::SendMessage(s.hWnd_Main,WM_USER_READ_SCA_CONFIG,0L,0L); tmr.msTimer(500); if (s.HwCfgReady == TRUE) { s.sca.HaveScaUpdate = TRUE; } } if (!s.sca.HaveScaUpdate) { EnableControls(TRUE); return; } } s.HaveConfig = TRUE; //GetDlgItem(IDC_BUTTON_FIND_COMMAND)->EnableWindow(TRUE); s.ReloadCfg = TRUE; CCfgPropSheet &pp = *(CCfgPropSheet *) this->GetSafeOwner(); pp.UpdateAll(); s.ReloadCfg = FALSE; EnableControls(TRUE); SetModified(FALSE); GetDlgItem(IDC_STATIC_CONFIG_NAME)->SetWindowText("Hardware Configuration"); } void CFilePage::OnBnClickedButtonSendToHardware() { CMSecTimer tmr; CString strCfgMFC(""); std::string strCfg(""); bool isPC5Present=false; //Needed to remove pc5 commands int DppType=0; //Needed to remove CAsciiCmdUtilities AsciiCmdUtil; //ASCII command utility library long lCfgLen=0; //ASCII Configuration Command String Length int idxSplitCfg=0; //Configuration split position, only if necessary bool bSplitCfg=false; //Configuration split flag std::string strSplitCfg(""); //Configuration split string second buffer bool isDP5_RevDxGains; /// use dp5 dx gains unsigned char DPP_ECO; /// holds eco indicator BOOL isDP5_DxK=false; //DP5 Rev Dx config K needs PAPZ (not removed, *special case) BOOL isDP5_DxL=false; //DP5 Rev Dx config L needs PAPZ (not removed, *special case) DppType = s.profile->device_type; isPC5Present = (bool)(!(s.DP5Stat.m_DP5_Status.PC5_PRESENT == 0)); isDP5_RevDxGains = s.DP5Stat.m_DP5_Status.isDP5_RevDxGains; DPP_ECO = s.DP5Stat.m_DP5_Status.DPP_ECO; s.HwCfgReady = FALSE; s.HwCfgExReady = FALSE; s.HwCfgDP5Out = ""; strCfgMFC = SaveConfigString(); strCfg = strCfgMFC; // Configuration Oversize Fix 20141224 // The hardware cannot handle ASCII Configurations Larger than 512 Bytes // The original solution was to separately send the SCA Commands // Now the number of command excluding SCA command may exceed 512 Bytes // New methods of controlling the size of the cfg string are needed // 1. Run the RemoveCmdByDeviceType here (is also in CSendCommand::WM_USER_SEND_CONFIG_TO_HW) // --> RemoveCmdByDeviceType is done here to accurately measure size. // 2. Measure final ASCII cfg string size if ((DppType == dppDP5) && s.DP5Stat.m_DP5_Status.isDP5_RevDxGains) { if ((s.DP5Stat.m_DP5_Status.DPP_ECO & 0x0F) == 0x0A) { isDP5_DxK = true; } if ((s.DP5Stat.m_DP5_Status.DPP_ECO & 0x0F) == 0x0B) { isDP5_DxL = true; } } if (isDP5_DxK || isDP5_DxL) { // keeps PAPZ for DP5 DxK/DxL strCfg = AsciiCmdUtil.RemoveCmdByDeviceTypeDP5DxK(strCfg, isPC5Present, DppType); } else { strCfg = AsciiCmdUtil.RemoveCmdByDeviceType(strCfg, isPC5Present, DppType, isDP5_RevDxGains, DPP_ECO); } lCfgLen = (long)strCfg.length(); //Test configuration size // 3. If needed shorten cmds, ReMeasure final ASCII cfg string size if (lCfgLen > 512) { //configuration is too large, try to reduce strCfg = AsciiCmdUtil.ReplaceCmdText(strCfg, "US;", ";"); strCfg = AsciiCmdUtil.ReplaceCmdText(strCfg, "OFF;", "OF;"); strCfg = AsciiCmdUtil.ReplaceCmdText(strCfg, "RISING;", "RI;"); strCfg = AsciiCmdUtil.ReplaceCmdText(strCfg, "FALLING;", "FA;"); lCfgLen = (long)strCfg.length(); //Test configuration size // 4. If needed split cmd string, send cfg in two blocks if (lCfgLen > 512) { //configuration is still too large, split cfg bSplitCfg = true; idxSplitCfg = AsciiCmdUtil.GetCmdChunk(strCfg); strSplitCfg = strCfg.substr(idxSplitCfg); strCfg = strCfg.substr(0, idxSplitCfg); } } strCfgMFC = strCfg.c_str(); s.HwCfgDP5Out = strCfgMFC; if (s.HwCfgDP5Out.GetLength() >0 ) { s.HwCfgReady = TRUE; // filter out messages by device, gain, and option types ::PostMessage(s.hWnd_Main,WM_USER_SEND_CONFIG_TO_HW,0L,0L); } if (bSplitCfg) { tmr.msTimer(500); s.HwCfgReady = FALSE; s.HwCfgExReady = FALSE; strCfgMFC = strSplitCfg.c_str(); s.HwCfgDP5Out = strCfgMFC; if (s.HwCfgDP5Out.GetLength() >0 ) { s.HwCfgReady = TRUE; // filter out messages by device, gain, and option types ::PostMessage(s.hWnd_Main,WM_USER_SEND_CONFIG_TO_HW,0L,0L); } } if (s.SCAEnabled) { tmr.msTimer(500); s.HwCfgReady = FALSE; s.HwCfgExReady = FALSE; s.HwCfgDP5Out = s.scafn.SCAStringALL(s.sca, TRUE); if (s.HwCfgDP5Out.GetLength() >0 ) { s.HwCfgExReady = TRUE; // bypass command filters for scas ::PostMessage(s.hWnd_Main,WM_USER_SEND_CONFIG_TO_HW,0L,0L); } } } BOOL CFilePage::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class //================================================================== if ( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN ) { CWnd* pCurrent= GetFocus(); int ctrl = pCurrent->GetDlgCtrlID(); //if (ctrl == IDC_OPT_TEXT_MCST) { if (isCEditBox(ctrl)) { if (ctrl==IDC_EDIT_SEND_COMMAND) { OnBnClickedButtonSendCommand(); } else { ::SendMessage(this->m_hWnd, WM_COMMAND, MAKEWPARAM(ctrl, EN_CHANGE), (LPARAM) m_hWnd); CWnd* pNext= pCurrent->GetNextWindow( GW_HWNDNEXT ); pMsg->wParam = VK_TAB; //if ( pNext != NULL ) { // if (pNext->GetDlgCtrlID() != IDOK ) { // pNext->SetFocus(); // return TRUE; // } //} } } else if (isCComboBox(ctrl)) { CWnd* pNext= pCurrent->GetNextWindow( GW_HWNDNEXT ); pMsg->wParam = VK_TAB; } } //================================================================== return CCfgPropPage::PreTranslateMessage(pMsg); } BOOL CFilePage::isCEditBox(int nID) { BOOL isEdit = FALSE; switch (nID) { case IDC_EDIT_SEND_COMMAND: isEdit = TRUE; break; default: isEdit = FALSE; break; } return isEdit; } BOOL CFilePage::isCComboBox(int nID) { BOOL isCombo = FALSE; switch (nID) { case IDC_OPT_COMBO_RESC: isCombo = TRUE; break; } return isCombo; } void CFilePage::OnCbnSelchangeOptComboResc() { CboUpdate(dciRESC); } void CFilePage::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default KillTimer(m_nTmrConfigId); if (s.isDppConnected) { OnBnClickedButtonEditConfigFromHw(); } CCfgPropPage::OnTimer(nIDEvent); } BOOL CFilePage::OnApply() { // TODO: Add your specialized code here and/or call the base class isClosing = TRUE; if (s.isDppConnected) { OnBnClickedButtonSendToHardware(); } return CCfgPropPage::OnApply(); } void CFilePage::OnCancel() { // TODO: Add your specialized code here and/or call the base class isClosing = TRUE; CCfgPropPage::OnCancel(); } void CFilePage::EnableControls(BOOL bEnable) { GetDlgItem(IDC_STATIC_FILE_PAGE)->EnableWindow(bEnable); GetDlgItem(IDC_OPT_FRAME_RESC)->EnableWindow(bEnable); GetDlgItem(IDC_OPT_COMBO_RESC)->EnableWindow(bEnable); GetDlgItem(IDC_BUTTON_READ_CONFIG)->EnableWindow(bEnable); GetDlgItem(IDC_BUTTON_SAVE_CONFIG)->EnableWindow(bEnable); GetDlgItem(IDC_BUTTON_EDIT_CONFIG_FROM_HW)->EnableWindow(bEnable); GetDlgItem(IDC_BUTTON_SEND_TO_HARDWARE)->EnableWindow(bEnable); GetDlgItem(IDC_BUTTON_SEND_TO_HARDWARE_NO_EDIT)->EnableWindow(bEnable); //GetDlgItem(IDC_READDETECTORCONFIGCOMBO)->EnableWindow(bEnable); if (!s.isDppConnected) { GetDlgItem(IDC_BUTTON_EDIT_CONFIG_FROM_HW)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_SEND_TO_HARDWARE)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_SEND_TO_HARDWARE_NO_EDIT)->EnableWindow(FALSE); } } void CFilePage::OnBnClickedButtonSendToHardwareNoEdit() { CFileBrowse BR; CString strDfltExt; CIniUtil ciu; CString cstCfg; CString m_strConfigInNoEdit; CStringList m_strListDP5section; CString strCmdLen; strDfltExt = "txt"; s.HwCfgReady = FALSE; s.HwCfgExReady = FALSE; s.HwCfgDP5Out = ""; if (BR.DoModal(BR.OPEN, "Open Configuration", BR.CfgFileFilter, strDfltExt, _T(""), &m_strConfigInNoEdit)) { if (ciu.GetDP5Section(m_strConfigInNoEdit, _T("DP5 Configuration File"), &m_strListDP5section)) { cstCfg = ciu.ConvertCmdListToCString(&m_strListDP5section,FALSE,TRUE); if (cstCfg != "") { s.HwCfgDP5Out = cstCfg; strCmdLen.Format("%d",cstCfg.GetLength()); s.HaveConfig = TRUE; if (s.HwCfgDP5Out.GetLength() >0 ) { s.HwCfgReady = TRUE; ::PostMessage(s.hWnd_Main,WM_USER_SEND_CONFIG_TO_HW,0L,0L); } cstCfg = ciu.ConvertCmdListToCString(&m_strListDP5section,TRUE,TRUE); GetDlgItem(IDC_EDIT_HW_CFG_SECTION)->SetWindowText(cstCfg); GetDlgItem(IDC_STATIC_CFG_LEN_LABEL)->ShowWindow(SW_SHOW); GetDlgItem(IDC_STATIC_CFG_LENGTH)->ShowWindow(SW_SHOW); GetDlgItem(IDC_STATIC_CFG_LENGTH)->SetWindowText(strCmdLen); } } } } // dp5 void CFilePage::OnBnClickedRadioDppDeviceType1() { SelectRadioDppDeviceType(dppDP5); ReadAmptekDetectorConfigNames(); // load amptek configurations from AmptekDC_NP.ini } //px5 void CFilePage::OnBnClickedRadioDppDeviceType2() { SelectRadioDppDeviceType(dppPX5); ReadAmptekDetectorConfigNames(); // load amptek configurations from AmptekDC_NP.ini } //dp5g void CFilePage::OnBnClickedRadioDppDeviceType3() { SelectRadioDppDeviceType(dppDP5G); ReadAmptekDetectorConfigNames(); // load amptek configurations from AmptekDC_NP.ini } //mca8000d void CFilePage::OnBnClickedRadioDppDeviceType4() { SelectRadioDppDeviceType(dppMCA8000D); ReadAmptekDetectorConfigNames(); // load amptek configurations from AmptekDC_NP.ini } //tb5 void CFilePage::OnBnClickedRadioDppDeviceType5() { SelectRadioDppDeviceType(dppTB5); ReadAmptekDetectorConfigNames(); // load amptek configurations from AmptekDC_NP.ini } // dp5x void CFilePage::OnBnClickedRadioDppDeviceType6() { SelectRadioDppDeviceType(dppDP5X); ReadAmptekDetectorConfigNames(); // load amptek configurations from AmptekDC_NP.ini } void CFilePage::SetDppDeviceType(int DeviceType) { s.profile->device_type = DeviceType; s.DppConfig.DeviceType = DeviceType; s.profile->strDevice = s.GetDeviceNameFromVal(DeviceType); SetCheckPc5Present(); SetCheckDP5DxGains(); } void CFilePage::SelectRadioDppDeviceType(int DeviceType) { if (DeviceType == dppDP5) { CheckRadioButton(IDC_RADIO_DPP_DEVICE_TYPE1, IDC_RADIO_DPP_DEVICE_TYPE6, IDC_RADIO_DPP_DEVICE_TYPE1); SetDppDeviceType(dppDP5); } else if (DeviceType == dppPX5) { CheckRadioButton(IDC_RADIO_DPP_DEVICE_TYPE1, IDC_RADIO_DPP_DEVICE_TYPE6, IDC_RADIO_DPP_DEVICE_TYPE2); SetDppDeviceType(dppPX5); } else if (DeviceType == dppDP5G) { CheckRadioButton(IDC_RADIO_DPP_DEVICE_TYPE1, IDC_RADIO_DPP_DEVICE_TYPE6, IDC_RADIO_DPP_DEVICE_TYPE3); SetDppDeviceType(dppDP5G); } else if (DeviceType == dppMCA8000D) { CheckRadioButton(IDC_RADIO_DPP_DEVICE_TYPE1, IDC_RADIO_DPP_DEVICE_TYPE6, IDC_RADIO_DPP_DEVICE_TYPE4); SetDppDeviceType(dppMCA8000D); } else if (DeviceType == dppTB5) { CheckRadioButton(IDC_RADIO_DPP_DEVICE_TYPE1, IDC_RADIO_DPP_DEVICE_TYPE6, IDC_RADIO_DPP_DEVICE_TYPE5); SetDppDeviceType(dppTB5); } else if (DeviceType == dppDP5X) { CheckRadioButton(IDC_RADIO_DPP_DEVICE_TYPE1, IDC_RADIO_DPP_DEVICE_TYPE6, IDC_RADIO_DPP_DEVICE_TYPE6); SetDppDeviceType(dppDP5X); } else { CheckRadioButton(IDC_RADIO_DPP_DEVICE_TYPE1, IDC_RADIO_DPP_DEVICE_TYPE6, IDC_RADIO_DPP_DEVICE_TYPE1); SetDppDeviceType(dppDP5); } } void CFilePage::EnableDeviceSelection(BOOL bEnable) { GetDlgItem(IDC_RADIO_DPP_DEVICE_TYPE1)->EnableWindow(bEnable); GetDlgItem(IDC_RADIO_DPP_DEVICE_TYPE2)->EnableWindow(bEnable); GetDlgItem(IDC_RADIO_DPP_DEVICE_TYPE3)->EnableWindow(bEnable); GetDlgItem(IDC_RADIO_DPP_DEVICE_TYPE4)->EnableWindow(bEnable); GetDlgItem(IDC_RADIO_DPP_DEVICE_TYPE5)->EnableWindow(bEnable); GetDlgItem(IDC_RADIO_DPP_DEVICE_TYPE6)->EnableWindow(bEnable); GetDlgItem(IDC_STATIC_DPP_DEVICE_TYPE)->EnableWindow(bEnable); } CString CFilePage::GetAmptekDC_NP_Section() { CString strDeviceType(""); //strDeviceType = "Amptek Detector Configurations"; switch (s.profile->device_type) { case dppDP5: strDeviceType = "Amptek Detector Configurations DP5"; break; case dppPX5: strDeviceType = "Amptek Detector Configurations PX5"; break; case dppDP5G: strDeviceType = "Amptek Detector Configurations DP5G"; break; case dppMCA8000D: strDeviceType = "Amptek Detector Configurations MCA8000D"; break; case dppTB5: strDeviceType = "Amptek Detector Configurations TB5"; break; case dppDP5X: strDeviceType = "Amptek Detector Configurations DP5-X"; break; default: strDeviceType = "Amptek Detector Configurations"; break; } return strDeviceType; } void CFilePage::OnCbnSelchangeReaddetectorconfigcombo() { CString strSection; CString strKeyName; CString strKeyValue; CIniUtil ciu; CString filename; CString sCurrentDir = theApp.m_pszHelpFilePath; sCurrentDir = sCurrentDir.Left(sCurrentDir.ReverseFind('\\')); filename = sCurrentDir + "\\AmptekDC_NP.ini"; ciu.ini.setINIFileName(filename); m_ReadDetectorConfigCombo.GetWindowText(strKeyName); strSection = GetAmptekDC_NP_Section(); strKeyValue = ciu.ini.getKeyValue(strKeyName,strSection); filename = sCurrentDir + "\\" + strKeyValue; ReadConfigFromAmptek_NP(filename,strKeyName); } void CFilePage::ReadAmptekDetectorConfigNames() { CString strSection; CIniUtil ciu; CString filename; CString sCurrentDir = theApp.m_pszHelpFilePath; sCurrentDir = sCurrentDir.Left(sCurrentDir.ReverseFind('\\')); filename = sCurrentDir + "\\AmptekDC_NP.ini"; ciu.ini.setINIFileName(filename); m_ReadDetectorConfigCombo.ResetContent(); strSection = GetAmptekDC_NP_Section(); BOOL bExists = ciu.ini.sectionExists(strSection); if(!bExists) { //AfxMessageBox("Amptek Configuration By Detector Data Load Error"); GetDlgItem(IDC_READDETECTORCONFIGCOMBO)->ShowWindow(SW_HIDE); return; } //load listbox from collection returned from getSectionData(sectionname) CStringList* DetCfgFileList = ciu.ini.getSectionData(strSection); POSITION position; CString strKey; int EqPos; for(position = DetCfgFileList->GetHeadPosition(); position != NULL; ) { strKey = DetCfgFileList->GetNext(position); EqPos = strKey.Find("=",0); strKey = strKey.Left(EqPos); m_ReadDetectorConfigCombo.AddString(strKey); } } void CFilePage::OnCbnSelendokReaddetectorconfigcombo() { CString CfgName; m_ReadDetectorConfigCombo.GetWindowText(CfgName); //AfxMessageBox(CfgName); } void CFilePage::OnBnClickedCheckPc5Present() { CButton *chkPresent; if ((!s.isDppConnected) && (s.profile->device_type == dppDP5)) { chkPresent = (CButton *)GetDlgItem(IDC_CHECK_PC5_PRESENT); // this assignment is for bool PC5_PRESENT (standard C++ vars) s.DP5Stat.m_DP5_Status.PC5_PRESENT = (chkPresent->GetCheck() == BST_CHECKED); // this assignment is for BOOL PC5_PRESENT (MFC vars) //s.DP5Stat.m_DP5_Status.PC5_PRESENT = (BOOL)chkPresent->GetCheck(); } else { GetDlgItem(IDC_CHECK_PC5_PRESENT)->ShowWindow(SW_HIDE); } } void CFilePage::SetCheckPc5Present() { CButton *chkPresent; BOOL isPC5Present; if ((!s.isDppConnected) && (s.profile->device_type == dppDP5)) { GetDlgItem(IDC_CHECK_PC5_PRESENT)->ShowWindow(SW_SHOW); chkPresent = (CButton *)GetDlgItem(IDC_CHECK_PC5_PRESENT); isPC5Present = s.DP5Stat.m_DP5_Status.PC5_PRESENT; chkPresent->SetCheck(isPC5Present); } else { // PC5_PRESENT should always be set for DP5X if ((!s.isDppConnected) && (s.profile->device_type == dppDP5X)) { s.DP5Stat.m_DP5_Status.PC5_PRESENT = true; } GetDlgItem(IDC_CHECK_PC5_PRESENT)->ShowWindow(SW_HIDE); } } //// DP5 Rev Dx Have 24 Analog Gains and a wider gain range //if ((s.profile->device_type == dppDP5) && (s.DP5Stat.m_DP5_Status.isDP5_RevDxGains)) { // GainTable = dagtDP5Dx; //} void CFilePage::OnBnClickedCheckDP5DxGains() { CButton *chkDP5DxGains; if ((!s.isDppConnected) && (s.profile->device_type == dppDP5)) { // DP5 Dx Configuration K,L Only Settings chkDP5DxGains = (CButton *)GetDlgItem(IDC_CHECK_DP5_DX_GAIN); // 0==unchecked,1==checked,2==indeterminate, getCheck-->int, isDP5_RevDxGains->bool s.DP5Stat.m_DP5_Status.isDP5_RevDxGains = (bool)(chkDP5DxGains->GetCheck() == 1); } else { GetDlgItem(IDC_CHECK_DP5_DX_GAIN)->ShowWindow(SW_HIDE); } } void CFilePage::SetCheckDP5DxGains() { CButton *chkDP5DxGains; BOOL isDP5DxGains; if ((!s.isDppConnected) && (s.profile->device_type == dppDP5)) { GetDlgItem(IDC_CHECK_DP5_DX_GAIN)->ShowWindow(SW_SHOW); chkDP5DxGains = (CButton *)GetDlgItem(IDC_CHECK_DP5_DX_GAIN); // DP5 Dx Configuration K,L Only Settings isDP5DxGains = s.DP5Stat.m_DP5_Status.isDP5_RevDxGains; chkDP5DxGains->SetCheck(isDP5DxGains); } else { GetDlgItem(IDC_CHECK_DP5_DX_GAIN)->ShowWindow(SW_HIDE); } } //================================= //================================= //================================= //================================= void CFilePage::OnStnClickedStaticReadConfig() { OnBnClickedButtonReadConfig(); } void CFilePage::OnStnClickedStaticSaveConfig() { OnBnClickedButtonSaveConfig(); } void CFilePage::OnBnClickedButtonSendCommand() { CString cstCfg; CMSecTimer tmr; //IDC_STATIC_SEND_COMMAND_LABEL GetDlgItem(IDC_BUTTON_SEND_COMMAND)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT_SEND_COMMAND)->EnableWindow(FALSE); s.HwCfgReady = FALSE; s.HwCfgExReady = FALSE; s.HwCfgDP5Out = ""; GetDlgItem(IDC_EDIT_SEND_COMMAND)->GetWindowText(cstCfg); cstCfg.Trim(); cstCfg.MakeUpper(); GetDlgItem(IDC_EDIT_SEND_COMMAND)->SetWindowText(cstCfg); if (cstCfg != "") { s.HwCfgDP5Out = cstCfg; s.HaveConfig = TRUE; if (s.HwCfgDP5Out.GetLength() >0 ) { s.HwCfgReady = TRUE; ::PostMessage(s.hWnd_Main,WM_USER_SEND_CONFIG_TO_HW,0L,0L); } } tmr.msTimer(500); OnBnClickedButtonEditConfigFromHw(); GetDlgItem(IDC_BUTTON_SEND_COMMAND)->EnableWindow(TRUE); GetDlgItem(IDC_EDIT_SEND_COMMAND)->EnableWindow(TRUE); } void CFilePage::OnBnClickedButtonSendCommand2() { CString cstCfg; CMSecTimer tmr; //IDC_STATIC_SEND_COMMAND_LABEL GetDlgItem(IDC_BUTTON_SEND_COMMAND2)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT_SEND_COMMAND)->EnableWindow(FALSE); s.HwCfgReady = FALSE; s.HwCfgExReady = FALSE; s.HwCfgDP5Out = ""; GetDlgItem(IDC_EDIT_SEND_COMMAND)->GetWindowText(cstCfg); cstCfg.Trim(); cstCfg.MakeUpper(); GetDlgItem(IDC_EDIT_SEND_COMMAND)->SetWindowText(cstCfg); if (cstCfg != "") { s.HwCfgDP5Out = cstCfg; if (s.HwCfgDP5Out.GetLength() >0 ) { ::PostMessage(s.hWnd_Main,WM_USER_READ_DPP_CONFIG_EX,0L,0L); } tmr.msTimer(500); if (s.HwCfgReady) { GetDlgItem(IDC_EDIT_RCV_CFG)->ShowWindow(SW_SHOW); GetDlgItem(IDC_EDIT_RCV_CFG)->SetWindowText(s.HwCfgDP5); } } GetDlgItem(IDC_BUTTON_SEND_COMMAND2)->EnableWindow(TRUE); GetDlgItem(IDC_EDIT_SEND_COMMAND)->EnableWindow(TRUE); } //////////////////////////////////////////////////////////////////////////////////// // HtmlHelp for shared dialog // NOTE: shared dialogs use string type IDD, not global IDD BOOL CFilePage::OnHelpInfo(HELPINFO* pHelpInfo) { CString strHelp; if (pHelpInfo->iContextType == HELPINFO_WINDOW) { if (pHelpInfo->dwContextId == 0) { ::HtmlHelp(this->GetSafeHwnd(), theApp.m_pszHelpFilePath, HH_HELP_CONTEXT, HIDD_FILE_PAGE); } else { // } } return true; } void CFilePage::OnHelp() // enable property sheet help button help { ::HtmlHelp(this->GetSafeHwnd(), theApp.m_pszHelpFilePath, HH_HELP_CONTEXT, HIDD_FILE_PAGE); //SendMessage(WM_COMMANDHELP); // } ////////////////////////////////////////////////////////////////////////////////////